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/MirFox/src/MirandaInterface.cpp | 10 +++++--- plugins/MirFox/src/MirandaOptions.cpp | 24 +++++++++--------- plugins/MirFox/src/MirandaUtils.cpp | 12 ++++----- plugins/MirFox/src/MirfoxData.cpp | 44 ++++++++++++++++----------------- plugins/MirFox/src/common.h | 7 +++--- 5 files changed, 50 insertions(+), 47 deletions(-) (limited to 'plugins/MirFox') diff --git a/plugins/MirFox/src/MirandaInterface.cpp b/plugins/MirFox/src/MirandaInterface.cpp index 416ebcaf24..db64cd26ae 100644 --- a/plugins/MirFox/src/MirandaInterface.cpp +++ b/plugins/MirFox/src/MirandaInterface.cpp @@ -20,7 +20,7 @@ CMirfoxMiranda mirfoxMiranda; ///////////////////////////////////////////////////////////////////////////////////////// -PLUGININFOEX pluginInfo = +PLUGININFOEX pluginInfoEx = { sizeof(PLUGININFOEX), __PLUGIN_NAME, @@ -33,9 +33,13 @@ PLUGININFOEX pluginInfo = { 0xe99a09b2, 0xe05b, 0x4633, { 0xaa, 0x3a, 0x5c, 0x83, 0xef, 0x1c, 0xba, 0xb6 } } }; +CMPlugin::CMPlugin() : + PLUGIN(MODULENAME, pluginInfoEx) +{} + extern "C" __declspec (dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD) { - return &pluginInfo; + return &pluginInfoEx; } ///////////////////////////////////////////////////////////////////////////////////////// @@ -138,7 +142,7 @@ static int OnShutdown(WPARAM, LPARAM) extern "C" int __declspec(dllexport) Load(void) { - mir_getLP(&pluginInfo); + mir_getLP(&pluginInfoEx); HookEvent(ME_SYSTEM_MODULESLOADED, onModulesLoaded); HookEvent(ME_SYSTEM_SHUTDOWN, OnShutdown); diff --git a/plugins/MirFox/src/MirandaOptions.cpp b/plugins/MirFox/src/MirandaOptions.cpp index b339b885c8..7cb9a470e7 100644 --- a/plugins/MirFox/src/MirandaOptions.cpp +++ b/plugins/MirFox/src/MirandaOptions.cpp @@ -102,32 +102,32 @@ INT_PTR CALLBACK DlgProcOpts_Tab1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM if (((LPNMHDR)lParam)->idFrom == 0 && ((LPNMHDR)lParam)->code == PSN_APPLY){ //SaveOptions from tab1 mirfoxData to miranda database mirfoxMiranda.getMirfoxData().leftClickSendMode = (MFENUM_SEND_MESSAGE_MODE)( 1 + (WORD)SendDlgItemMessage(hwndDlg, IDC1_COMBO1, CB_GETCURSEL, 0, 0)); - db_set_b(0, PLUGIN_DB_ID, "leftClickSendMode", (int)mirfoxMiranda.getMirfoxData().leftClickSendMode); + db_set_b(0, MODULENAME, "leftClickSendMode", (int)mirfoxMiranda.getMirfoxData().leftClickSendMode); mirfoxMiranda.getMirfoxData().rightClickSendMode = (MFENUM_SEND_MESSAGE_MODE)( 1 + (WORD)SendDlgItemMessage(hwndDlg, IDC1_COMBO2, CB_GETCURSEL, 0, 0)); - db_set_b(0, PLUGIN_DB_ID, "rightClickSendMode", (int)mirfoxMiranda.getMirfoxData().rightClickSendMode); + db_set_b(0, MODULENAME, "rightClickSendMode", (int)mirfoxMiranda.getMirfoxData().rightClickSendMode); mirfoxMiranda.getMirfoxData().middleClickSendMode = (MFENUM_SEND_MESSAGE_MODE)( 1 + (WORD)SendDlgItemMessage(hwndDlg, IDC1_COMBO3, CB_GETCURSEL, 0, 0)); - db_set_b(0, PLUGIN_DB_ID, "middleClickSendMode", (int)mirfoxMiranda.getMirfoxData().middleClickSendMode); + db_set_b(0, MODULENAME, "middleClickSendMode", (int)mirfoxMiranda.getMirfoxData().middleClickSendMode); if (IsDlgButtonChecked(hwndDlg, IDC1_CHECK1) == BST_CHECKED){ mirfoxMiranda.getMirfoxData().setClientsProfilesFilterCheckbox(true); - db_set_b(0, PLUGIN_DB_ID, "clientsProfilesFilterCheckbox", 1); + db_set_b(0, MODULENAME, "clientsProfilesFilterCheckbox", 1); } else { mirfoxMiranda.getMirfoxData().setClientsProfilesFilterCheckbox(false); - db_set_b(0, PLUGIN_DB_ID, "clientsProfilesFilterCheckbox", 2); + db_set_b(0, MODULENAME, "clientsProfilesFilterCheckbox", 2); } if (IsDlgButtonChecked(hwndDlg, IDC1_CHECK2) == BST_CHECKED){ if (mirfoxMiranda.getMirfoxData().getAddAccountToContactNameCheckbox() != true){ mirfoxMiranda.getMirfoxData().setAddAccountToContactNameCheckbox(true); - db_set_b(0, PLUGIN_DB_ID, "addAccountToContactNameCheckbox", 1); + db_set_b(0, MODULENAME, "addAccountToContactNameCheckbox", 1); mirfoxMiranda.getMirfoxData().updateAllMirandaContactsNames(mirfoxMiranda.getSharedMemoryUtils()); } } else { if (mirfoxMiranda.getMirfoxData().getAddAccountToContactNameCheckbox() != false){ mirfoxMiranda.getMirfoxData().setAddAccountToContactNameCheckbox(false); - db_set_b(0, PLUGIN_DB_ID, "addAccountToContactNameCheckbox", 2); + db_set_b(0, MODULENAME, "addAccountToContactNameCheckbox", 2); mirfoxMiranda.getMirfoxData().updateAllMirandaContactsNames(mirfoxMiranda.getSharedMemoryUtils()); } } @@ -142,7 +142,7 @@ INT_PTR CALLBACK DlgProcOpts_Tab1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM MFLogger* logger = MFLogger::getInstance(); logger->log_p(L"Options. Save clientsProfilesFilterString: [%s]", mirfoxMiranda.getMirfoxData().getClientsProfilesFilterStringPtr()->c_str()); - db_set_ws(0, PLUGIN_DB_ID, "clientsProfilesFilterString", mirfoxMiranda.getMirfoxData().getClientsProfilesFilterStringPtr()->c_str()); + db_set_ws(0, MODULENAME, "clientsProfilesFilterString", mirfoxMiranda.getMirfoxData().getClientsProfilesFilterStringPtr()->c_str()); //TODO fire actualization visableTo field at CSM record @@ -483,9 +483,9 @@ INT_PTR CALLBACK DlgProcOpts_Tab2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM //save to db 1 - on, 2 - off if (contactState == MFENUM_MIRANDACONTACT_STATE_OFF){ - db_set_b(hContact, PLUGIN_DB_ID, "state", 2); + db_set_b(hContact, MODULENAME, "state", 2); } else { - db_set_b(hContact, PLUGIN_DB_ID, "state", 1); + db_set_b(hContact, MODULENAME, "state", 1); } @@ -641,9 +641,9 @@ INT_PTR CALLBACK DlgProcOpts_Tab3(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM std::string mirandaAccountDBKey("ACCOUNTSTATE_"); mirandaAccountDBKey += accountId; if (accountState == MFENUM_MIRANDAACCOUNT_STATE_OFF){ - db_set_b(0, PLUGIN_DB_ID, mirandaAccountDBKey.c_str(), 2); + db_set_b(0, MODULENAME, mirandaAccountDBKey.c_str(), 2); } else { - db_set_b(0, PLUGIN_DB_ID, mirandaAccountDBKey.c_str(), 1); + db_set_b(0, MODULENAME, mirandaAccountDBKey.c_str(), 1); } diff --git a/plugins/MirFox/src/MirandaUtils.cpp b/plugins/MirFox/src/MirandaUtils.cpp index 20deed6d35..585a6bbdca 100644 --- a/plugins/MirFox/src/MirandaUtils.cpp +++ b/plugins/MirFox/src/MirandaUtils.cpp @@ -31,7 +31,7 @@ void MirandaUtils::netlibRegister(){ // Register netlib user for logging function NETLIBUSER nlu = {}; nlu.flags = NUF_UNICODE | NUF_NOOPTIONS; - nlu.szSettingsModule = PLUGIN_DB_ID; + nlu.szSettingsModule = MODULENAME; nlu.szDescriptiveName.w = TranslateT("MirFox log"); netlibHandle = Netlib_RegisterUser(&nlu); @@ -351,7 +351,7 @@ int MirandaUtils::on_hook_OpenMW(WPARAM wParam, LPARAM lParam) } // show and focus window - if (db_get_b(0, PLUGIN_DB_ID, "doNotFocusWhenOpenMW", 0) == 1){ + if (db_get_b(0, MODULENAME, "doNotFocusWhenOpenMW", 0) == 1){ delete param; return 0; } @@ -467,7 +467,7 @@ void MirandaUtils::translateOldDBNames() { //settings "clientsProfilesFilterCheckbox", "clientsProfilesFilterString" int opt1KeyValue = db_get_b(0, OLD_PLUGIN_DB_ID, "clientsProfilesFilterCheckbox", 0); if (opt1KeyValue != 0){ - db_set_b(0, PLUGIN_DB_ID, "clientsProfilesFilterCheckbox", opt1KeyValue); + db_set_b(0, MODULENAME, "clientsProfilesFilterCheckbox", opt1KeyValue); db_unset(0, OLD_PLUGIN_DB_ID, "clientsProfilesFilterCheckbox"); logger->log(L"TranslateOldDBNames: 'clientsProfilesFilterCheckbox' db entry found and moved"); } else { @@ -479,7 +479,7 @@ void MirandaUtils::translateOldDBNames() { INT_PTR opt2Result = db_get_s(0, OLD_PLUGIN_DB_ID, "clientsProfilesFilterString", &opt2Dbv, DBVT_WCHAR); if (opt2Result == 0){ //success std::wstring clientsProfilesFilterString = opt2Dbv.pwszVal; - db_set_ws(0, PLUGIN_DB_ID, "clientsProfilesFilterString", clientsProfilesFilterString.c_str()); + db_set_ws(0, MODULENAME, "clientsProfilesFilterString", clientsProfilesFilterString.c_str()); db_unset(0, OLD_PLUGIN_DB_ID, "clientsProfilesFilterString"); logger->log(L"TranslateOldDBNames: 'clientsProfilesFilterString' db entry found and moved"); db_free(&opt2Dbv); @@ -493,7 +493,7 @@ void MirandaUtils::translateOldDBNames() { mirandaAccountDBKey += pa->szModuleName; int keyValue = db_get_b(0, OLD_PLUGIN_DB_ID, mirandaAccountDBKey.c_str(), 0); if (keyValue != 0){ - db_set_b(0, PLUGIN_DB_ID, mirandaAccountDBKey.c_str(), keyValue); + db_set_b(0, MODULENAME, mirandaAccountDBKey.c_str(), keyValue); db_unset(0, OLD_PLUGIN_DB_ID, mirandaAccountDBKey.c_str()); logger->log(L"TranslateOldDBNames: ACCOUNT db entry found and moved"); } @@ -505,7 +505,7 @@ void MirandaUtils::translateOldDBNames() { int keyValue = db_get_b(hContact, OLD_PLUGIN_DB_ID, "state", 0); if (keyValue != 0){ - db_set_b(hContact, PLUGIN_DB_ID, "state", keyValue); + db_set_b(hContact, MODULENAME, "state", keyValue); db_unset(hContact, OLD_PLUGIN_DB_ID, "state"); logger->log(L"TranslateOldDBNames: CONTACT db entry found and moved"); } diff --git a/plugins/MirFox/src/MirfoxData.cpp b/plugins/MirFox/src/MirfoxData.cpp index a58df3d5f0..c1734eb3b1 100644 --- a/plugins/MirFox/src/MirfoxData.cpp +++ b/plugins/MirFox/src/MirfoxData.cpp @@ -268,7 +268,7 @@ void MirfoxData::refreshAccount_Add(SharedMemoryUtils& sharedMemoryUtils, char* MFENUM_MIRANDAACCOUNT_STATE getOrCreateAccountStateInDB(char* szModuleName); std::string mirandaAccountDBKey("ACCOUNTSTATE_"); mirandaAccountDBKey += szModuleName; - int keyValue = db_get_b(0, PLUGIN_DB_ID, mirandaAccountDBKey.c_str(), 0); + int keyValue = db_get_b(0, MODULENAME, mirandaAccountDBKey.c_str(), 0); if (keyValue == 1 || keyValue == 2){ //setting exist if (keyValue == 1){ @@ -280,10 +280,10 @@ void MirfoxData::refreshAccount_Add(SharedMemoryUtils& sharedMemoryUtils, char* //setting does not exist, or is invalid -> save default setting (1 - ON) if (getAccountDefaultState(mirandaAccountItemPtr) == 1){ //on = 1 mirandaAccountItemPtr->accountState = MFENUM_MIRANDAACCOUNT_STATE_ON; //1 - db_set_b(0, PLUGIN_DB_ID, mirandaAccountDBKey.c_str(), 1); + db_set_b(0, MODULENAME, mirandaAccountDBKey.c_str(), 1); } else { //off = 2 mirandaAccountItemPtr->accountState = MFENUM_MIRANDAACCOUNT_STATE_OFF; //2 - db_set_b(0, PLUGIN_DB_ID, mirandaAccountDBKey.c_str(), 2); + db_set_b(0, MODULENAME, mirandaAccountDBKey.c_str(), 2); } } */ @@ -337,7 +337,7 @@ void MirfoxData::refreshAccount_Delete(SharedMemoryUtils& sharedMemoryUtils, cha std::string mirandaAccountDBKey("ACCOUNTSTATE_"); mirandaAccountDBKey += szModuleName; - db_unset(0, PLUGIN_DB_ID, mirandaAccountDBKey.c_str()); + db_unset(0, MODULENAME, mirandaAccountDBKey.c_str()); //del proto from SM sharedMemoryUtils.refreshMsm_Delete('A', deletedId); @@ -530,7 +530,7 @@ MirfoxData::createOrGetAccountStateFromDB(MirandaAccount* mirandaAccount){ std::string mirandaAccountDBKey("ACCOUNTSTATE_"); mirandaAccountDBKey += mirandaAccount->szModuleName; - int keyValue = db_get_b(0, PLUGIN_DB_ID, mirandaAccountDBKey.c_str(), 0); + int keyValue = db_get_b(0, MODULENAME, mirandaAccountDBKey.c_str(), 0); if (keyValue == 1 || keyValue == 2){ //setting exist if (keyValue == 1){ @@ -541,10 +541,10 @@ MirfoxData::createOrGetAccountStateFromDB(MirandaAccount* mirandaAccount){ } else { //setting does not exist, or is invalid -> save default setting (1 - ON) if (getAccountDefaultState(mirandaAccount) == 1){ //on = 1 - db_set_b(0, PLUGIN_DB_ID, mirandaAccountDBKey.c_str(), 1); + db_set_b(0, MODULENAME, mirandaAccountDBKey.c_str(), 1); return MFENUM_MIRANDAACCOUNT_STATE_ON; //1 } else { //off = 2 - db_set_b(0, PLUGIN_DB_ID, mirandaAccountDBKey.c_str(), 2); + db_set_b(0, MODULENAME, mirandaAccountDBKey.c_str(), 2); return MFENUM_MIRANDAACCOUNT_STATE_OFF; //2 } } @@ -554,7 +554,7 @@ MirfoxData::createOrGetAccountStateFromDB(MirandaAccount* mirandaAccount){ MFENUM_MIRANDACONTACT_STATE MirfoxData::createOrGetContactStateFromDB(MirandaContact* mirandaContact){ - int keyValue = db_get_b(mirandaContact->contactHandle, PLUGIN_DB_ID, "state", 0); + int keyValue = db_get_b(mirandaContact->contactHandle, MODULENAME, "state", 0); if (keyValue == 1 || keyValue == 2){ //setting exist if (keyValue == 1){ @@ -565,10 +565,10 @@ MirfoxData::createOrGetContactStateFromDB(MirandaContact* mirandaContact){ } else { //setting does not exist, or is invalid -> save default setting (1 - ON) if (MirfoxData::getContactDefaultState(mirandaContact->getObjectPtr()) == 1){ //on = 1 - db_set_b(mirandaContact->contactHandle, PLUGIN_DB_ID, "state", 1); + db_set_b(mirandaContact->contactHandle, MODULENAME, "state", 1); return MFENUM_MIRANDACONTACT_STATE_ON; //1 } else { //off = 2 - db_set_b(mirandaContact->contactHandle, PLUGIN_DB_ID, "state", 2); + db_set_b(mirandaContact->contactHandle, MODULENAME, "state", 2); return MFENUM_MIRANDACONTACT_STATE_OFF; //2 } } @@ -664,7 +664,7 @@ void MirfoxData::initializeOptions() { //addAccountToContactNameCheckbox - int opt2KeyValue = db_get_b(0, PLUGIN_DB_ID, "addAccountToContactNameCheckbox", 0); + int opt2KeyValue = db_get_b(0, MODULENAME, "addAccountToContactNameCheckbox", 0); if (opt2KeyValue == 1 || opt2KeyValue == 2){ //setting exist if (opt2KeyValue == 1){ @@ -675,12 +675,12 @@ void MirfoxData::initializeOptions() } else { //setting does not exist, or is invalid -> save default setting (2 - false) setAddAccountToContactNameCheckbox(false); //2 - db_set_b(0, PLUGIN_DB_ID, "addAccountToContactNameCheckbox", 2); + db_set_b(0, MODULENAME, "addAccountToContactNameCheckbox", 2); } //clientsProfilesFilterCheckbox - int opt1KeyValue = db_get_b(0, PLUGIN_DB_ID, "clientsProfilesFilterCheckbox", 0); + int opt1KeyValue = db_get_b(0, MODULENAME, "clientsProfilesFilterCheckbox", 0); if (opt1KeyValue == 1 || opt1KeyValue == 2){ //setting exist if (opt1KeyValue == 1){ @@ -691,53 +691,53 @@ void MirfoxData::initializeOptions() } else { //setting does not exist, or is invalid -> save default setting (2 - false) setClientsProfilesFilterCheckbox(false); //2 - db_set_b(0, PLUGIN_DB_ID, "clientsProfilesFilterCheckbox", 2); + db_set_b(0, MODULENAME, "clientsProfilesFilterCheckbox", 2); } //clientsProfilesFilterString DBVARIANT opt2Dbv = {0}; - INT_PTR opt2Result = db_get_s(0, PLUGIN_DB_ID, "clientsProfilesFilterString", &opt2Dbv, DBVT_WCHAR); + INT_PTR opt2Result = db_get_s(0, MODULENAME, "clientsProfilesFilterString", &opt2Dbv, DBVT_WCHAR); if (opt2Result == 0){ //success //option exists in DB, get value (* getClientsProfilesFilterStringPtr()) = opt2Dbv.pwszVal; } else { //option not exists in DB, set default value (* getClientsProfilesFilterStringPtr()) = L""; - db_set_ws(0, PLUGIN_DB_ID, "clientsProfilesFilterString", getClientsProfilesFilterStringPtr()->c_str()); + db_set_ws(0, MODULENAME, "clientsProfilesFilterString", getClientsProfilesFilterStringPtr()->c_str()); } db_free(&opt2Dbv); - int opt3KeyValue = db_get_b(0, PLUGIN_DB_ID, "leftClickSendMode", 0); + int opt3KeyValue = db_get_b(0, MODULENAME, "leftClickSendMode", 0); if (opt3KeyValue == MFENUM_SMM_ONLY_SEND || opt3KeyValue == MFENUM_SMM_SEND_AND_SHOW_MW || opt3KeyValue == MFENUM_SMM_ONLY_SHOW_MW){ //setting exist leftClickSendMode = (MFENUM_SEND_MESSAGE_MODE)opt3KeyValue; } else { //setting does not exist, or is invalid -> save default setting (MFENUM_SMM_ONLY_SEND) leftClickSendMode = MFENUM_SMM_ONLY_SEND; - db_set_b(0, PLUGIN_DB_ID, "leftClickSendMode", MFENUM_SMM_ONLY_SEND); + db_set_b(0, MODULENAME, "leftClickSendMode", MFENUM_SMM_ONLY_SEND); } - int opt4KeyValue = db_get_b(0, PLUGIN_DB_ID, "rightClickSendMode", 0); + int opt4KeyValue = db_get_b(0, MODULENAME, "rightClickSendMode", 0); if (opt4KeyValue == MFENUM_SMM_ONLY_SEND || opt4KeyValue == MFENUM_SMM_SEND_AND_SHOW_MW || opt4KeyValue == MFENUM_SMM_ONLY_SHOW_MW){ //setting exist rightClickSendMode = (MFENUM_SEND_MESSAGE_MODE)opt4KeyValue; } else { //setting does not exist, or is invalid -> save default setting (MFENUM_SMM_SEND_AND_SHOW_MW) rightClickSendMode = MFENUM_SMM_SEND_AND_SHOW_MW; - db_set_b(0, PLUGIN_DB_ID, "rightClickSendMode", MFENUM_SMM_SEND_AND_SHOW_MW); + db_set_b(0, MODULENAME, "rightClickSendMode", MFENUM_SMM_SEND_AND_SHOW_MW); } - int opt5KeyValue = db_get_b(0, PLUGIN_DB_ID, "middleClickSendMode", 0); + int opt5KeyValue = db_get_b(0, MODULENAME, "middleClickSendMode", 0); if (opt5KeyValue == MFENUM_SMM_ONLY_SEND || opt5KeyValue == MFENUM_SMM_SEND_AND_SHOW_MW || opt5KeyValue == MFENUM_SMM_ONLY_SHOW_MW){ //setting exist middleClickSendMode = (MFENUM_SEND_MESSAGE_MODE)opt5KeyValue; } else { //setting does not exist, or is invalid -> save default setting (must be MFENUM_SMM_ONLY_SEND due to Firefox bug and crash) middleClickSendMode = MFENUM_SMM_ONLY_SEND; - db_set_b(0, PLUGIN_DB_ID, "middleClickSendMode", MFENUM_SMM_ONLY_SEND); + db_set_b(0, MODULENAME, "middleClickSendMode", MFENUM_SMM_ONLY_SEND); } diff --git a/plugins/MirFox/src/common.h b/plugins/MirFox/src/common.h index 95b80f9861..21eefe49e8 100644 --- a/plugins/MirFox/src/common.h +++ b/plugins/MirFox/src/common.h @@ -19,14 +19,13 @@ #include #include -#define PLUGIN_DB_ID "MirFox" +#define MODULENAME "MirFox" + #define PLUGIN_OPTIONS_NAME "MirFox" struct CMPlugin : public PLUGIN { - CMPlugin() : - PLUGIN(PLUGIN_DB_ID) - {} + CMPlugin(); }; //for MirandaUtils.h and MirfoxData.h and MirfoxMiranda.h -- cgit v1.2.3