From 8a74e7495ce5ad39de4f5c25121a84d35df90c36 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 20 May 2018 15:08:48 +0300 Subject: CMPlugin to receive a reference to PLUGININFOEX --- plugins/SimpleAR/src/Main.cpp | 50 ++++++++++++++++++++++------------------ plugins/SimpleAR/src/Options.cpp | 20 ++++++++-------- plugins/SimpleAR/src/stdafx.h | 6 ++--- 3 files changed, 39 insertions(+), 37 deletions(-) (limited to 'plugins/SimpleAR/src') diff --git a/plugins/SimpleAR/src/Main.cpp b/plugins/SimpleAR/src/Main.cpp index 98e99e3200..af14ff2daf 100644 --- a/plugins/SimpleAR/src/Main.cpp +++ b/plugins/SimpleAR/src/Main.cpp @@ -49,6 +49,10 @@ PLUGININFOEX pluginInfoEx = { 0x46bf191f, 0x8dfb, 0x4656, { 0x88, 0xb2, 0x4c, 0x20, 0xbe, 0x4c, 0xfa, 0x44 } } }; +CMPlugin::CMPlugin() : + PLUGIN(MODULENAME, pluginInfoEx) +{} + extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) { return &pluginInfoEx; @@ -58,8 +62,8 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) INT_PTR ToggleEnable(WPARAM, LPARAM) { - BOOL fEnabled = !db_get_b(NULL, protocolname, KEY_ENABLED, 1); - db_set_b(NULL, protocolname, KEY_ENABLED, fEnabled); + BOOL fEnabled = !db_get_b(NULL, MODULENAME, KEY_ENABLED, 1); + db_set_b(NULL, MODULENAME, KEY_ENABLED, fEnabled); if (fEnabled) Menu_ModifyItem(hEnableMenu, LPGENW("Disable Auto&reply"), iconList[0].hIcolib); @@ -70,8 +74,8 @@ INT_PTR ToggleEnable(WPARAM, LPARAM) INT_PTR Toggle(WPARAM hContact, LPARAM) { - BOOL on = !db_get_b(hContact, protocolname, "TurnedOn", 0); - db_set_b(hContact, protocolname, "TurnedOn", on); + BOOL on = !db_get_b(hContact, MODULENAME, "TurnedOn", 0); + db_set_b(hContact, MODULENAME, "TurnedOn", on); on = !on; if (on) @@ -83,7 +87,7 @@ INT_PTR Toggle(WPARAM hContact, LPARAM) INT OnPreBuildContactMenu(WPARAM hContact, LPARAM) { - BOOL on = !db_get_b(hContact, protocolname, "TurnedOn", 0); + BOOL on = !db_get_b(hContact, MODULENAME, "TurnedOn", 0); if (on) Menu_ModifyItem(hToggle, LPGENW("Turn off Autoanswer"), iconList[0].hIcolib); else @@ -93,12 +97,12 @@ INT OnPreBuildContactMenu(WPARAM hContact, LPARAM) INT CheckDefaults(WPARAM, LPARAM) { - interval = db_get_w(NULL, protocolname, KEY_REPEATINTERVAL, 300); + interval = db_get_w(NULL, MODULENAME, KEY_REPEATINTERVAL, 300); - wchar_t *ptszVal = db_get_wsa(NULL, protocolname, KEY_HEADING); + wchar_t *ptszVal = db_get_wsa(NULL, MODULENAME, KEY_HEADING); if (ptszVal == nullptr) // Heading not set - db_set_ws(NULL, protocolname, KEY_HEADING, TranslateT("Dear %user%, the owner left the following message:")); + db_set_ws(NULL, MODULENAME, KEY_HEADING, TranslateT("Dear %user%, the owner left the following message:")); else mir_free(ptszVal); @@ -108,7 +112,7 @@ INT CheckDefaults(WPARAM, LPARAM) else { char szStatus[6] = { 0 }; mir_snprintf(szStatus, "%d", c); - ptszVal = db_get_wsa(NULL, protocolname, szStatus); + ptszVal = db_get_wsa(NULL, MODULENAME, szStatus); if (ptszVal == nullptr) { wchar_t *ptszDefault; if (c < ID_STATUS_FREECHAT) @@ -119,7 +123,7 @@ INT CheckDefaults(WPARAM, LPARAM) else ptszDefault = nullptr; if (ptszDefault) - db_set_ws(NULL, protocolname, szStatus, TranslateW(ptszDefault)); + db_set_ws(NULL, MODULENAME, szStatus, TranslateW(ptszDefault)); } else mir_free(ptszVal); @@ -129,7 +133,7 @@ INT CheckDefaults(WPARAM, LPARAM) if (ServiceExists(MS_VARS_FORMATSTRING)) gbVarsServiceExist = TRUE; - BOOL fEnabled = db_get_b(NULL, protocolname, KEY_ENABLED, 1); + BOOL fEnabled = db_get_b(NULL, MODULENAME, KEY_ENABLED, 1); if (fEnabled) Menu_ModifyItem(hEnableMenu, LPGENW("Disable Auto&reply"), iconList[0].hIcolib); else @@ -139,7 +143,7 @@ INT CheckDefaults(WPARAM, LPARAM) INT addEvent(WPARAM hContact, LPARAM hDBEvent) { - BOOL fEnabled = db_get_b(NULL, protocolname, KEY_ENABLED, 1); + BOOL fEnabled = db_get_b(NULL, MODULENAME, KEY_ENABLED, 1); if (!fEnabled || !hContact || !hDBEvent) return FALSE; /// unspecifyed error @@ -170,12 +174,12 @@ INT addEvent(WPARAM hContact, LPARAM hDBEvent) if (db_get_b(hContact, "CList", "NotOnList", 0)) return FALSE; - if (db_get_b(hContact, protocolname, "TurnedOn", 0)) + if (db_get_b(hContact, MODULENAME, "TurnedOn", 0)) return FALSE; if (!(dbei.flags & DBEF_SENT)) { - int timeBetween = time(0) - db_get_dw(hContact, protocolname, "LastReplyTS", 0); - if (timeBetween > interval || db_get_w(hContact, protocolname, "LastStatus", 0) != status) { + int timeBetween = time(0) - db_get_dw(hContact, MODULENAME, "LastReplyTS", 0); + if (timeBetween > interval || db_get_w(hContact, MODULENAME, "LastStatus", 0) != status) { size_t msgLen = 1; int isQun = db_get_b(hContact, pszProto, "IsQun", 0); if (isQun) @@ -183,7 +187,7 @@ INT addEvent(WPARAM hContact, LPARAM hDBEvent) char szStatus[6] = { 0 }; mir_snprintf(szStatus, "%d", status); - ptszVal = db_get_wsa(NULL, protocolname, szStatus); + ptszVal = db_get_wsa(NULL, MODULENAME, szStatus); if (ptszVal) { if (*ptszVal) { CMStringW ptszTemp; @@ -196,7 +200,7 @@ INT addEvent(WPARAM hContact, LPARAM hDBEvent) msgLen += mir_wstrlen(ptszVal); - wchar_t *ptszHead = db_get_wsa(NULL, protocolname, KEY_HEADING); + wchar_t *ptszHead = db_get_wsa(NULL, MODULENAME, KEY_HEADING); if (ptszHead != nullptr) { ptszTemp = ptszHead; ptszTemp.Replace(L"%user%", ptszNick); @@ -230,8 +234,8 @@ INT addEvent(WPARAM hContact, LPARAM hDBEvent) } } - db_set_dw(hContact, protocolname, "LastReplyTS", time(0)); - db_set_w(hContact, protocolname, "LastStatus", status); + db_set_dw(hContact, MODULENAME, "LastReplyTS", time(0)); + db_set_w(hContact, MODULENAME, "LastStatus", status); } return 0; } @@ -249,21 +253,21 @@ extern "C" int __declspec(dllexport)Load(void) mir_getLP(&pluginInfoEx); pcli = Clist_GetInterface(); - CreateServiceFunction(protocolname"/ToggleEnable", ToggleEnable); - CreateServiceFunction(protocolname"/ToggleAutoanswer", Toggle); + CreateServiceFunction(MODULENAME"/ToggleEnable", ToggleEnable); + CreateServiceFunction(MODULENAME"/ToggleAutoanswer", Toggle); CMenuItem mi; SET_UID(mi, 0xac1c64a, 0x82ca, 0x4845, 0x86, 0x89, 0x59, 0x76, 0x12, 0x74, 0x72, 0x7b); mi.position = 500090000; mi.name.w = L""; - mi.pszService = protocolname"/ToggleEnable"; + mi.pszService = MODULENAME"/ToggleEnable"; hEnableMenu = Menu_AddMainMenuItem(&mi); SET_UID(mi, 0xb290cccd, 0x4ecc, 0x475e, 0x87, 0xcb, 0x51, 0xf4, 0x3b, 0xc3, 0x44, 0x9c); mi.position = -0x7FFFFFFF; mi.name.w = L""; - mi.pszService = protocolname"/ToggleAutoanswer"; + mi.pszService = MODULENAME"/ToggleAutoanswer"; hToggle = Menu_AddContactMenuItem(&mi); //add hook diff --git a/plugins/SimpleAR/src/Options.cpp b/plugins/SimpleAR/src/Options.cpp index e1f0f583ef..fa93906df2 100644 --- a/plugins/SimpleAR/src/Options.cpp +++ b/plugins/SimpleAR/src/Options.cpp @@ -11,11 +11,11 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara { char tszStatus[6] = { 0 }; - CheckDlgButton(hwndDlg, IDC_ENABLEREPLIER, db_get_b(NULL, protocolname, KEY_ENABLED, 1) == 1 ? BST_CHECKED : BST_UNCHECKED); - SetDlgItemInt(hwndDlg, IDC_INTERVAL, db_get_w(NULL, protocolname, KEY_REPEATINTERVAL, 300) / 60, FALSE); + CheckDlgButton(hwndDlg, IDC_ENABLEREPLIER, db_get_b(NULL, MODULENAME, KEY_ENABLED, 1) == 1 ? BST_CHECKED : BST_UNCHECKED); + SetDlgItemInt(hwndDlg, IDC_INTERVAL, db_get_w(NULL, MODULENAME, KEY_REPEATINTERVAL, 300) / 60, FALSE); DBVARIANT dbv; - if (!db_get_ws(NULL, protocolname, KEY_HEADING, &dbv)) { + if (!db_get_ws(NULL, MODULENAME, KEY_HEADING, &dbv)) { SetDlgItemText(hwndDlg, IDC_HEADING, dbv.ptszVal); db_free(&dbv); } @@ -28,7 +28,7 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara else { SendDlgItemMessage(hwndDlg, IDC_STATUSMODE, CB_ADDSTRING, 0, (LPARAM)pszStatus); - if (!db_get_ws(NULL, protocolname, tszStatus, &dbv)) { + if (!db_get_ws(NULL, MODULENAME, tszStatus, &dbv)) { if (c < ID_STATUS_FREECHAT) ptszMessage[c - ID_STATUS_ONLINE - 1] = wcsdup(dbv.ptszVal); else if (c > ID_STATUS_INVISIBLE) @@ -80,7 +80,7 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara BOOL translated; BOOL fEnabled = IsDlgButtonChecked(hwndDlg, IDC_ENABLEREPLIER) == 1; - db_set_b(NULL, protocolname, KEY_ENABLED, (BYTE)fEnabled); + db_set_b(NULL, MODULENAME, KEY_ENABLED, (BYTE)fEnabled); if (fEnabled) Menu_ModifyItem(hEnableMenu, LPGENW("Disable Auto&reply"), iconList[0].hIcolib); @@ -88,12 +88,12 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara Menu_ModifyItem(hEnableMenu, LPGENW("Enable Auto&reply"), iconList[1].hIcolib); GetDlgItemText(hwndDlg, IDC_HEADING, ptszText, _countof(ptszText)); - db_set_ws(NULL, protocolname, KEY_HEADING, ptszText); + db_set_ws(NULL, MODULENAME, KEY_HEADING, ptszText); INT size = GetDlgItemInt(hwndDlg, IDC_INTERVAL, &translated, FALSE); if (translated) interval = size * 60; - db_set_w(NULL, protocolname, KEY_REPEATINTERVAL, interval); + db_set_w(NULL, MODULENAME, KEY_REPEATINTERVAL, interval); size = SendDlgItemMessage(hwndDlg, IDC_MESSAGE, WM_GETTEXTLENGTH, 0, 0) + 1; GetDlgItemText(hwndDlg, IDC_MESSAGE, ptszMessage[lastIndex], size); @@ -106,11 +106,11 @@ INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara mir_snprintf(szStatus, "%d", c); if (cID_STATUS_INVISIBLE && ptszMessage[c - ID_STATUS_ONLINE - 3]) - db_set_ws(NULL, protocolname, szStatus, ptszMessage[c - ID_STATUS_ONLINE - 3]); + db_set_ws(NULL, MODULENAME, szStatus, ptszMessage[c - ID_STATUS_ONLINE - 3]); else - db_unset(NULL, protocolname, szStatus); + db_unset(NULL, MODULENAME, szStatus); } } return TRUE; diff --git a/plugins/SimpleAR/src/stdafx.h b/plugins/SimpleAR/src/stdafx.h index 863bdca124..5cb8c46b34 100644 --- a/plugins/SimpleAR/src/stdafx.h +++ b/plugins/SimpleAR/src/stdafx.h @@ -16,7 +16,7 @@ #include "Resource.h" #include "version.h" -#define protocolname "SimpleAutoReplier" //no spaces here :) +#define MODULENAME "SimpleAutoReplier" #define KEY_ENABLED "Enabled" #define KEY_HEADING "Heading" @@ -26,9 +26,7 @@ struct CMPlugin : public PLUGIN { - CMPlugin() : - PLUGIN(protocolname) - {} + CMPlugin(); }; extern INT interval; -- cgit v1.2.3