summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorVadim Dashevskiy <watcherhd@gmail.com>2013-01-18 17:53:47 +0000
committerVadim Dashevskiy <watcherhd@gmail.com>2013-01-18 17:53:47 +0000
commita95d0313e639fa16ee6e371d7a82d7d16e203d25 (patch)
tree3aecbbc71ba8d27f09716e2d8c5146deb56af0d5 /plugins
parent4a34c6a6c70e52ff67d43f75ebdc68395bcc8e25 (diff)
- Boltun: code cleanup (patch from person)
git-svn-id: http://svn.miranda-ng.org/main/trunk@3156 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Boltun/src/actionQueue.cpp2
-rw-r--r--plugins/Boltun/src/boltun.cpp43
-rw-r--r--plugins/Boltun/src/boltun.h22
-rw-r--r--plugins/Boltun/src/config.cpp8
4 files changed, 37 insertions, 38 deletions
diff --git a/plugins/Boltun/src/actionQueue.cpp b/plugins/Boltun/src/actionQueue.cpp
index d0ba9adae8..cc9e642600 100644
--- a/plugins/Boltun/src/actionQueue.cpp
+++ b/plugins/Boltun/src/actionQueue.cpp
@@ -242,7 +242,7 @@ void AnswerToContact(HANDLE hContact, const TCHAR* messageToAnswer)
DB_CONTACT_WARNED, FALSE) == FALSE)
{
DoAnswer(hContact, new TalkBot::MessageInfo((const TCHAR*)Config.WarnText), true);
- DBWriteContactSettingByte(hContact, BOLTUN_KEY, DB_CONTACT_WARNED, TRUE);
+ db_set_b(hContact, BOLTUN_KEY, DB_CONTACT_WARNED, TRUE);
}
else
DoAnswer(hContact, bot->Reply(hContact, messageToAnswer, false));
diff --git a/plugins/Boltun/src/boltun.cpp b/plugins/Boltun/src/boltun.cpp
index 42149db57a..59077852d3 100644
--- a/plugins/Boltun/src/boltun.cpp
+++ b/plugins/Boltun/src/boltun.cpp
@@ -213,7 +213,7 @@ static bool LoadMind(const TCHAR* filename, int &line)
static bool BoltunAutoChat(HANDLE hContact)
{
- if (DBGetContactSettingByte(hContact, BOLTUN_KEY, DB_CONTACT_BOLTUN_NOT_TO_CHAT
+ if (db_get_b(hContact, BOLTUN_KEY, DB_CONTACT_BOLTUN_NOT_TO_CHAT
, FALSE) == TRUE)
return false;
@@ -232,11 +232,11 @@ static bool BoltunAutoChat(HANDLE hContact)
return true;
}
- if ((DBGetContactSettingByte(hContact,"CList","NotOnList",0) == 1) &&
+ if ((db_get_b(hContact,"CList","NotOnList",0) == 1) &&
Config.TalkWithNotInList)
return true;
- if (DBGetContactSettingByte(hContact, BOLTUN_KEY, DB_CONTACT_BOLTUN_AUTO_CHAT,
+ if (db_get_b(hContact, BOLTUN_KEY, DB_CONTACT_BOLTUN_AUTO_CHAT,
FALSE) == TRUE)
return true;
@@ -366,7 +366,7 @@ static INT_PTR CALLBACK MainDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPAR
if(bTranslated)
Config.WarnText = c;
else
- Config.WarnText = TranslateTS(DEFAULT_WARN_TEXT);
+ Config.WarnText = DEFAULT_WARN_TEXT;
}
return TRUE;
}
@@ -424,8 +424,8 @@ static INT_PTR CALLBACK EngineDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP
ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = GetParent(hwndDlg);
- TCHAR* mind = TranslateTS(MIND_FILE_DESC);
- TCHAR* anyfile = TranslateTS(ALL_FILES_DESC);
+ TCHAR* mind = MIND_FILE_DESC;
+ TCHAR* anyfile = ALL_FILES_DESC;
size_t l = _tcslen(MIND_DIALOG_FILTER)
+ _tcslen(mind) + _tcslen(anyfile);
TCHAR *filt = new TCHAR[l];
@@ -471,7 +471,7 @@ static INT_PTR CALLBACK EngineDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LP
{
TCHAR* message = new TCHAR[5000];
wsprintf(message, TranslateTS(FAILED_TO_LOAD_BASE), line, c);
- MessageBox(NULL, message, TranslateTS(BOLTUN_ERROR), MB_ICONERROR|MB_TASKMODAL|MB_OK);
+ MessageBox(NULL, message, BOLTUN_ERROR, MB_ICONERROR|MB_TASKMODAL|MB_OK);
delete[] message;
}
break;
@@ -522,7 +522,7 @@ static int MessageOptInit(WPARAM wParam, LPARAM lParam)
odp.position = 910000000;
odp.hInstance = hInst;
odp.pszGroup = BOLTUN_GROUP;
- odp.pszTitle = BOLTUN_NAME;
+ odp.pszTitle = Translate(BOLTUN_NAME);
odp.pfnDlgProc = MainDlgProc;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_MAIN);
odp.pszTab = TAB_GENERAL;
@@ -538,8 +538,8 @@ static int ContactClick(WPARAM wParam, LPARAM lParam, BOOL clickNotToChat)
{
HANDLE hContact = (HANDLE)wParam;
- BOOL boltunautochat = DBGetContactSettingByte(hContact, BOLTUN_KEY, DB_CONTACT_BOLTUN_AUTO_CHAT, FALSE);
- BOOL boltunnottochat = DBGetContactSettingByte(hContact, BOLTUN_KEY, DB_CONTACT_BOLTUN_NOT_TO_CHAT, FALSE);
+ BOOL boltunautochat = db_get_b(hContact, BOLTUN_KEY, DB_CONTACT_BOLTUN_AUTO_CHAT, FALSE);
+ BOOL boltunnottochat = db_get_b(hContact, BOLTUN_KEY, DB_CONTACT_BOLTUN_NOT_TO_CHAT, FALSE);
if (clickNotToChat)
{
@@ -558,12 +558,12 @@ static int ContactClick(WPARAM wParam, LPARAM lParam, BOOL clickNotToChat)
}
else
{
- DBWriteContactSettingByte(hContact, BOLTUN_KEY, DB_CONTACT_WARNED, FALSE);
+ db_set_b(hContact, BOLTUN_KEY, DB_CONTACT_WARNED, FALSE);
}
}
- DBWriteContactSettingByte(hContact, BOLTUN_KEY, DB_CONTACT_BOLTUN_AUTO_CHAT, (BYTE)boltunautochat);
- DBWriteContactSettingByte(hContact, BOLTUN_KEY, DB_CONTACT_BOLTUN_NOT_TO_CHAT, (BYTE)boltunnottochat);
+ db_set_b(hContact, BOLTUN_KEY, DB_CONTACT_BOLTUN_AUTO_CHAT, (BYTE)boltunautochat);
+ db_set_b(hContact, BOLTUN_KEY, DB_CONTACT_BOLTUN_NOT_TO_CHAT, (BYTE)boltunnottochat);
return 0;
}
@@ -590,7 +590,7 @@ static int MessagePrebuild(WPARAM wParam, LPARAM lParam)
CLISTMENUITEM clmi = { sizeof(clmi) };
HANDLE hContact = (HANDLE)wParam;
- if (!blInit || (DBGetContactSettingByte(hContact,"CList","NotOnList",0) == 1))
+ if (!blInit || (db_get_b(hContact,"CList","NotOnList",0) == 1))
{
clmi.flags = CMIM_FLAGS | CMIF_GRAYED;
@@ -599,8 +599,8 @@ static int MessagePrebuild(WPARAM wParam, LPARAM lParam)
}
else
{
- BOOL boltunautochat = DBGetContactSettingByte(hContact, BOLTUN_KEY, DB_CONTACT_BOLTUN_AUTO_CHAT, FALSE);
- BOOL boltunnottochat = DBGetContactSettingByte(hContact, BOLTUN_KEY, DB_CONTACT_BOLTUN_NOT_TO_CHAT, FALSE);
+ BOOL boltunautochat = db_get_b(hContact, BOLTUN_KEY, DB_CONTACT_BOLTUN_AUTO_CHAT, FALSE);
+ BOOL boltunnottochat = db_get_b(hContact, BOLTUN_KEY, DB_CONTACT_BOLTUN_NOT_TO_CHAT, FALSE);
clmi.flags = CMIM_FLAGS | CMIM_ICON | (boltunautochat ? CMIF_CHECKED : 0);
clmi.hIcon = LoadIcon( GetModuleHandle(NULL), MAKEINTRESOURCE((boltunautochat ? IDI_TICK : IDI_NOTICK)));
@@ -671,11 +671,10 @@ extern "C" int __declspec(dllexport) Load(void)
if (!blInit)
{
TCHAR path[2000];
- wsprintf(path, TranslateTS(FAILED_TO_LOAD_BASE), line, (const TCHAR*)Config.MindFileName);
- MessageBox(NULL, path, TranslateTS(BOLTUN_ERROR), MB_ICONERROR|MB_TASKMODAL|MB_OK);
+ wsprintf(path, FAILED_TO_LOAD_BASE, line, (const TCHAR*)Config.MindFileName);
+ MessageBox(NULL, path, BOLTUN_ERROR, MB_ICONERROR|MB_TASKMODAL|MB_OK);
}
- /*record for Uninstall plugin*/
- DBWriteContactSettingString(NULL, "Uninstall", BOLTUN_NAME, BOLTUN_KEY);
+
return 0;
}
@@ -693,8 +692,8 @@ extern "C" int __declspec(dllexport) Unload(void)
//So in case of saving error we will remain silent
#if 0
TCHAR path[MAX_PATH];
- wsprintf(path, TranslateTS(FAILED_TO_SAVE_BASE), (const TCHAR*)Config.MindFileName);
- TCHAR* err = TranslateTS(BOLTUN_ERROR);
+ wsprintf(path, FAILED_TO_SAVE_BASE, (const TCHAR*)Config.MindFileName);
+ TCHAR* err = BOLTUN_ERROR;
MessageBox(NULL, path, err, MB_ICONERROR|MB_TASKMODAL|MB_OK);*/
#endif
}
diff --git a/plugins/Boltun/src/boltun.h b/plugins/Boltun/src/boltun.h
index dc0cdcdb22..591626885a 100644
--- a/plugins/Boltun/src/boltun.h
+++ b/plugins/Boltun/src/boltun.h
@@ -50,23 +50,23 @@
//Plugin name
#define BOLTUN_NAME "Boltun"
-#define MIND_FILE_DESC _T("Mind Files")
-#define ALL_FILES_DESC _T("All Files")
+#define MIND_FILE_DESC TranslateT("Mind Files")
+#define ALL_FILES_DESC TranslateT("All Files")
//UI strings
-#define BOLTUN_AUTO_CHAT "Boltun/Auto Chat"
-#define BOLTUN_NOT_TO_CHAT "Boltun/Not to Chat"
-#define BOLTUN_START_CHATTING "Boltun/Start Chatting"
+#define BOLTUN_AUTO_CHAT LPGEN("Boltun/Auto Chat")
+#define BOLTUN_NOT_TO_CHAT LPGEN("Boltun/Not to Chat")
+#define BOLTUN_START_CHATTING LPGEN("Boltun/Start Chatting")
-#define DEFAULT_WARN_TEXT _T("Hello. I'm Boltun! I'll talk to you, while my owner is away. Please write without mistakes!")
+#define DEFAULT_WARN_TEXT TranslateT("Hello. I'm Boltun! I'll talk to you, while my owner is away. Please write without mistakes!")
// Error messages
-#define BOLTUN_ERROR _T("Boltun Error")
-#define FAILED_TO_LOAD_BASE _T("Failed to load base of remarks. Error at line %d of %s. (Or few lines before).")
-#define FAILED_TO_SAVE_BASE _T("Failed to save base of remarks to %s")
+#define BOLTUN_ERROR TranslateT("Boltun Error")
+#define FAILED_TO_LOAD_BASE TranslateT("Failed to load base of remarks. Error at line %d of %s. (Or few lines before).")
+#define FAILED_TO_SAVE_BASE TranslateT("Failed to save base of remarks to %s")
//Settings tab names
-#define TAB_GENERAL "General Settings"
-#define TAB_ENGINE "Engine Settings"
+#define TAB_GENERAL Translate("General Settings")
+#define TAB_ENGINE Translate("Engine Settings")
#endif /*_BOLTUN_H*/
diff --git a/plugins/Boltun/src/config.cpp b/plugins/Boltun/src/config.cpp
index 4a88bf2df3..2b4e2157e0 100644
--- a/plugins/Boltun/src/config.cpp
+++ b/plugins/Boltun/src/config.cpp
@@ -49,7 +49,7 @@ inline TCHAR* GetString(char* key, const TCHAR* def)
{
DBVARIANT dbv;
TCHAR* val;
- if (!DBGetContactSettingTString(NULL, BOLTUN_KEY, key, &dbv))
+ if (!db_get_s(NULL, BOLTUN_KEY, key, &dbv))
{
size_t len = wcslen(dbv.ptszVal) + 1;
val = new TCHAR[len];
@@ -70,7 +70,7 @@ inline const TCHAR* SetString(char* key, const TCHAR* value)
size_t len = _tcslen(value) + 1;
TCHAR* val = new TCHAR[len];
_tcscpy_s(val, len, value);
- DBWriteContactSettingTString(NULL, BOLTUN_KEY, key, val);
+ db_set_ws(NULL, BOLTUN_KEY, key, val);
return val;
}
@@ -78,14 +78,14 @@ inline const TCHAR* SetString(char* key, const TCHAR* value)
const bool BoltunConfig::Get##x() { \
return DBGetContactSettingDword(NULL, BOLTUN_KEY, str, def) != 0; } \
const bool BoltunConfig::Set##x(const bool value) { \
- DBWriteContactSettingDword(NULL, BOLTUN_KEY, str, value); \
+ db_set_dw(NULL, BOLTUN_KEY, str, value); \
return value; }
#define BUILDINTETTERS(x, str, def) \
const int BoltunConfig::Get##x() { \
return DBGetContactSettingDword(NULL, BOLTUN_KEY, str, def); } \
const int BoltunConfig::Set##x(const int value) { \
- DBWriteContactSettingDword(NULL, BOLTUN_KEY, str, value); \
+ db_set_dw(NULL, BOLTUN_KEY, str, value); \
return value; }
#define BUILDSTRETTERS(x, str, def) \