From 54e2470db2c13b37d560d0408b8fa829df413444 Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Sun, 15 Sep 2013 11:37:55 +0000 Subject: removed custom translation format, because it isn't needed in Miranda NG any longer git-svn-id: http://svn.miranda-ng.org/main/trunk@6070 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirFox/res/resource.rc | 23 ++-- plugins/MirFox/src/MirandaInterface.cpp | 34 ++---- plugins/MirFox/src/MirandaOptions.cpp | 101 ++++-------------- plugins/MirFox/src/MirandaUtils.cpp | 181 +++++++------------------------- plugins/MirFox/src/MirandaUtils.h | 5 - plugins/MirFox/src/MirfoxMiranda.cpp | 80 +++----------- plugins/MirFox/src/MirfoxMiranda.h | 4 - 7 files changed, 84 insertions(+), 344 deletions(-) diff --git a/plugins/MirFox/res/resource.rc b/plugins/MirFox/res/resource.rc index 272cc8092a..6f52b4c9e1 100644 --- a/plugins/MirFox/res/resource.rc +++ b/plugins/MirFox/res/resource.rc @@ -26,17 +26,10 @@ BEGIN BEGIN BLOCK "000004b0" BEGIN -#ifdef _WIN64 - VALUE "FileDescription", __DESCRIPTION " (x64)" - VALUE "ProductName", __PLUGIN_NAME " (x64)" - VALUE "FileVersion", __VERSION_STRING " (x64)" - VALUE "ProductVersion", __VERSION_STRING " (x64)" -#else VALUE "FileDescription", __DESCRIPTION VALUE "ProductName", __PLUGIN_NAME VALUE "FileVersion", __VERSION_STRING VALUE "ProductVersion", __VERSION_STRING -#endif VALUE "InternalName", __PLUGIN_NAME VALUE "OriginalFilename", __FILENAME VALUE "Author", __AUTHOR @@ -78,26 +71,24 @@ STYLE DS_SETFONT | WS_POPUP FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN GROUPBOX "",IDC1_STATIC_G1,17,10,275,146 - LTEXT "",IDC1_LABEL1,25,16,261,20 - LTEXT "",IDC1_LABEL2,48,37,234,10 + LTEXT "Send to contact action",IDC1_LABEL1,25,16,261,20 + LTEXT "on left mouse button click",IDC1_LABEL2,48,37,234,10 COMBOBOX IDC1_COMBO1,48,48,235,16,CBS_DROPDOWNLIST | WS_TABSTOP - LTEXT "",IDC1_LABEL3,48,71,234,10 + LTEXT "on right mouse button click",IDC1_LABEL3,48,71,234,10 COMBOBOX IDC1_COMBO2,48,83,235,12,CBS_DROPDOWNLIST | WS_TABSTOP - LTEXT "",IDC1_LABEL4,48,108,234,30 + LTEXT "on middle mouse button click\n(note: use middle mouse button to send multiple messages from Firefox)",IDC1_LABEL4,48,108,234,30 COMBOBOX IDC1_COMBO3,48,132,235,15,CBS_DROPDOWNLIST | WS_TABSTOP GROUPBOX "",IDC1_STATIC_G2,17,162,275,55 - CONTROL "",IDC1_CHECK1,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,27,171,259,20 + CONTROL "Show Miranda menu only in this firefox profiles (comma delimeted)",IDC1_CHECK1,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,27,171,259,20 EDITTEXT IDC1_EDIT1,41,195,242,14,ES_AUTOHSCROLL GROUPBOX "",IDC1_STATIC_G3,19,218,273,10,NOT WS_VISIBLE - //LTEXT "Refresh firefox data",IDC1_STATIC_INVALIDATE,25,218,178,8,NOT WS_VISIBLE - //PUSHBUTTON "Refresh",IDC1_BUTTON_INVALIDATE,205,219,77,6,NOT WS_VISIBLE END IDD_OPT2 DIALOGEX 0, 0, 310, 230 STYLE DS_SETFONT | WS_POPUP FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN - LTEXT "",IDC2_LABEL1,4,5,301,19 + LTEXT "Show this contacts in 'Send ... to' option in Firefox",IDC2_LABEL1,4,5,301,19 CONTROL "",IDC2_CONTACTS_LIST,"CListControl",WS_TABSTOP | 0x1d2,4,25,302,201,WS_EX_CLIENTEDGE END @@ -106,7 +97,7 @@ STYLE DS_SETFONT | WS_POPUP FONT 8, "MS Sans Serif", 0, 0, 0x0 BEGIN GROUPBOX "",IDC3_STATIC_G1,17,18,275,180 - LTEXT "",IDC3_LABEL1,23,31,261,19 + LTEXT "Show this accounts in 'Set status message' option in Firefox",IDC3_LABEL1,23,31,261,19 CONTROL "",IDC3_PROTOCOLS_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SORTASCENDING | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,61,52,183,126 END diff --git a/plugins/MirFox/src/MirandaInterface.cpp b/plugins/MirFox/src/MirandaInterface.cpp index b72a7f52d3..066ce93299 100644 --- a/plugins/MirFox/src/MirandaInterface.cpp +++ b/plugins/MirFox/src/MirandaInterface.cpp @@ -51,41 +51,22 @@ extern "C" BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpv int lowVersionUserAnswer = -1; extern "C" __declspec (dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) { - - if(mirfoxMiranda.onMirandaPluginInfoExCheck(mirandaVersion)){ - return &pluginInfo; - } else { - if (lowVersionUserAnswer == -1){ - lowVersionUserAnswer = MessageBox(NULL - //, mfTranslate(TEXT("mirfox.too.old.miranda"), TEXT("You use old Miranda version, whitch MirFox was not tested. Do You want to load MirFox plugin ?")) - //@langpack: [mirfox.too.old.miranda] Używasz starszej wersji Mirandy, dla której plugin MirFox nie został przetestowany. Czy chcesz uruchomić ten plugin ? - , (LPCWSTR)TEXT("You use old Miranda version, whitch MirFox was not tested. Do You want to load MirFox plugin ?") //TODO - translation crash here - , (LPCWSTR)TEXT("MirFox") - , MB_YESNO | MB_ICONWARNING ); - } - if (lowVersionUserAnswer == IDYES){ - return &pluginInfo; - } else { - return NULL; - } - } - + return &pluginInfo; } /* * hook on ME_SYSTEM_MODULESLOADED at Load() */ -static int onModulesLoaded(WPARAM wParam, LPARAM lParam) +static int onModulesLoaded(WPARAM, LPARAM) { - //init popup classes POPUPCLASS puc = {0}; puc.cbSize = sizeof(puc); puc.flags = PCF_TCHAR; puc.pszName = "MirFox_Notify"; - puc.ptszDescription = MirandaUtils::getInstance()->mfTranslate(LPGENT("mirfox.popup.notify.description"), TEXT("MirFox/Notification")); + puc.ptszDescription = TranslateT("MirFox/Notification"); puc.colorBack = RGB(173, 206, 247); //light blue puc.colorText = GetSysColor(COLOR_WINDOWTEXT); puc.iSeconds = 3; @@ -93,7 +74,7 @@ static int onModulesLoaded(WPARAM wParam, LPARAM lParam) hPopupNotify = Popup_RegisterClass(&puc); puc.pszName = "MirFox_Error"; - puc.ptszDescription = MirandaUtils::getInstance()->mfTranslate(LPGENT("mirfox.popup.error.description"), TEXT("MirFox/Error")); + puc.ptszDescription = TranslateT("MirFox/Error"); puc.colorBack = RGB(255, 128, 128); //light red puc.colorText = GetSysColor(COLOR_WINDOWTEXT); puc.iSeconds = 20; @@ -103,9 +84,8 @@ static int onModulesLoaded(WPARAM wParam, LPARAM lParam) return 0; } -static int OnShutdown(WPARAM wParam, LPARAM lParam) +static int OnShutdown(WPARAM, LPARAM) { - Popup_UnregisterClass(hPopupError); Popup_UnregisterClass(hPopupNotify); @@ -120,8 +100,6 @@ extern "C" int __declspec(dllexport) Load(void){ hProtoAck = HookEvent(ME_PROTO_ACK, MirandaUtils::onProtoAck); - - //Ensure that the common control DLL is loaded. needed to use ICC_LISTVIEW_CLASSES control in options TODO move to InitOptions();? INITCOMMONCONTROLSEX icex = {0}; icex.dwSize = sizeof(icex); @@ -131,7 +109,7 @@ extern "C" int __declspec(dllexport) Load(void){ mirfoxMiranda.getMirfoxData().Plugin_Terminated = false; mirfoxMiranda.getMirfoxData().setPluginState(MFENUM_PLUGIN_STATE_INIT); mirfoxMiranda.onMirandaInterfaceLoad(); - /**MirandaOptions.cpp**/InitOptions(); + InitOptions(); if (mirfoxMiranda.getMirfoxData().getPluginState() != MFENUM_PLUGIN_STATE_ERROR){ mirfoxMiranda.getMirfoxData().setPluginState(MFENUM_PLUGIN_STATE_WORK); diff --git a/plugins/MirFox/src/MirandaOptions.cpp b/plugins/MirFox/src/MirandaOptions.cpp index ec95c8657b..8404d37ce7 100644 --- a/plugins/MirFox/src/MirandaOptions.cpp +++ b/plugins/MirFox/src/MirandaOptions.cpp @@ -15,53 +15,31 @@ INT_PTR CALLBACK DlgProcOpts_Tab1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM case WM_INITDIALOG: { //executed once, during each tab initialization during each miranda options open - mirfoxMiranda.getMirfoxData().setTab1OptionsState(MFENUM_OPTIONS_INIT); + TranslateDialogDefault(hwndDlg); - MirandaUtils* mu = MirandaUtils::getInstance(); - - mu->mfTranslateControl(hwndDlg, IDC1_LABEL1, - LPGENT("mirfox.options.tab1.sendtocontacts"), TEXT("Send to contact action") - ); - mu->mfTranslateControl(hwndDlg, IDC1_LABEL2, - LPGENT("mirfox.options.tab1.left"), TEXT("on left mouse button click") - ); //IDC1_COMBO1 - SendDlgItemMessage(hwndDlg, IDC1_COMBO1, CB_ADDSTRING, 0, (LPARAM)mu->mfTranslate(LPGENT("mirfox.options.onlysend"), TEXT("just send message"))); - SendDlgItemMessage(hwndDlg, IDC1_COMBO1, CB_ADDSTRING, 0, (LPARAM)mu->mfTranslate(LPGENT("mirfox.options.sendandshow"), TEXT("send message and open message window"))); - SendDlgItemMessage(hwndDlg, IDC1_COMBO1, CB_ADDSTRING, 0, (LPARAM)mu->mfTranslate(LPGENT("mirfox.options.onlyshow"), TEXT("show message window with pasted message"))); + SendDlgItemMessage(hwndDlg, IDC1_COMBO1, CB_ADDSTRING, 0, (LPARAM)TranslateT("just send message")); + SendDlgItemMessage(hwndDlg, IDC1_COMBO1, CB_ADDSTRING, 0, (LPARAM)TranslateT("send message and open message window")); + SendDlgItemMessage(hwndDlg, IDC1_COMBO1, CB_ADDSTRING, 0, (LPARAM)TranslateT("show message window with pasted message")); SendDlgItemMessage(hwndDlg, IDC1_COMBO1, CB_SETCURSEL, (int)mirfoxMiranda.getMirfoxData().leftClickSendMode - 1, 0); - mu->mfTranslateControl(hwndDlg, IDC1_LABEL3, - LPGENT("mirfox.options.tab1.right"), TEXT("on right mouse button click") - ); //IDC1_COMBO2 - SendDlgItemMessage(hwndDlg, IDC1_COMBO2, CB_ADDSTRING, 0, (LPARAM)mu->mfTranslate(LPGENT("mirfox.options.onlysend"), TEXT("just send message"))); - SendDlgItemMessage(hwndDlg, IDC1_COMBO2, CB_ADDSTRING, 0, (LPARAM)mu->mfTranslate(LPGENT("mirfox.options.sendandshow"), TEXT("send message and open message window"))); - SendDlgItemMessage(hwndDlg, IDC1_COMBO2, CB_ADDSTRING, 0, (LPARAM)mu->mfTranslate(LPGENT("mirfox.options.onlyshow"), TEXT("show message window with pasted message"))); + SendDlgItemMessage(hwndDlg, IDC1_COMBO2, CB_ADDSTRING, 0, (LPARAM)TranslateT("just send message")); + SendDlgItemMessage(hwndDlg, IDC1_COMBO2, CB_ADDSTRING, 0, (LPARAM)TranslateT("send message and open message window")); + SendDlgItemMessage(hwndDlg, IDC1_COMBO2, CB_ADDSTRING, 0, (LPARAM)TranslateT("show message window with pasted message")); SendDlgItemMessage(hwndDlg, IDC1_COMBO2, CB_SETCURSEL, (int)mirfoxMiranda.getMirfoxData().rightClickSendMode - 1, 0); - - mu->mfTranslateControl(hwndDlg, IDC1_LABEL4, - LPGENT("mirfox.options.tab1.middle"), TEXT("on middle mouse button click\n(note: use middle mouse button to send multiple messages from Firefox)") - ); //IDC1_COMBO3 - SendDlgItemMessage(hwndDlg, IDC1_COMBO3, CB_ADDSTRING, 0, (LPARAM)mu->mfTranslate(LPGENT("mirfox.options.onlysend"), TEXT("just send message"))); + SendDlgItemMessage(hwndDlg, IDC1_COMBO3, CB_ADDSTRING, 0, (LPARAM)TranslateT("just send message")); //disabled due to Firefox bug. opening other window while firefox menu is still open -> firefox crash - //SendDlgItemMessage(hwndDlg, IDC1_COMBO3, CB_ADDSTRING, 0, (LPARAM)mu->mfTranslate(LPGENT("mirfox.options.sendandshow"), TEXT("send message and open message window"))); - //SendDlgItemMessage(hwndDlg, IDC1_COMBO3, CB_ADDSTRING, 0, (LPARAM)mu->mfTranslate(LPGENT("mirfox.options.onlyshow"), TEXT("show message window with pasted message"))); + //SendDlgItemMessage(hwndDlg, IDC1_COMBO3, CB_ADDSTRING, 0, (LPARAM)TranslateT("send message and open message window")); + //SendDlgItemMessage(hwndDlg, IDC1_COMBO3, CB_ADDSTRING, 0, (LPARAM)TranslateT("show message window with pasted message")); SendDlgItemMessage(hwndDlg, IDC1_COMBO3, CB_SETCURSEL, (int)mirfoxMiranda.getMirfoxData().middleClickSendMode - 1, 0); - - mu->mfTranslateControl(hwndDlg, IDC1_CHECK1, - LPGENT("mirfox.options.tab1.profiles"), TEXT("Show Miranda menu only in this firefox profiles (comma delimeted)") - ); - - - //other options initialization SetDlgItemText(hwndDlg, IDC1_EDIT1, mirfoxMiranda.getMirfoxData().getClientsProfilesFilterStringPtr()->c_str()); @@ -129,12 +107,8 @@ INT_PTR CALLBACK DlgProcOpts_Tab1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM } - if (((LPNMHDR)lParam)->idFrom == 0 && - ((LPNMHDR)lParam)->code == PSN_APPLY - ){ + 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); @@ -144,8 +118,6 @@ INT_PTR CALLBACK DlgProcOpts_Tab1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM 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); - - if (IsDlgButtonChecked(hwndDlg, IDC1_CHECK1) == BST_CHECKED){ mirfoxMiranda.getMirfoxData().setClientsProfilesFilterCheckbox(true); db_set_b(0, PLUGIN_DB_ID, "clientsProfilesFilterCheckbox", 1); @@ -183,13 +155,7 @@ INT_PTR CALLBACK DlgProcOpts_Tab1(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM return 0; } - - - //--------------------------------------TAB 2------------------------------------------------------------------ - - - static void setListContactIcons(HWND hwndList){ @@ -229,10 +195,6 @@ static void setListContactIcons(HWND hwndList){ } - - -#define SIZEOF(X) (sizeof(X)/sizeof(X[0])) - static void setListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentItem, int *groupChildCount){ int iconOn[1]={1}; @@ -383,15 +345,10 @@ INT_PTR CALLBACK DlgProcOpts_Tab2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM switch ( msg ) { case WM_INITDIALOG: { + TranslateDialogDefault(hwndDlg); mirfoxMiranda.getMirfoxData().setTab2OptionsState(MFENUM_OPTIONS_INIT); - - MirandaUtils::getInstance()->mfTranslateControl(hwndDlg, IDC2_LABEL1, - LPGENT("mirfox.options.tab2.contacts"), TEXT("Show this contacts in 'Send ... to' option in Firefox") - ); - - //load icons HIMAGELIST hIml; int smCx = GetSystemMetrics(SM_CXSMICON); @@ -421,7 +378,7 @@ INT_PTR CALLBACK DlgProcOpts_Tab2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM CLCINFOITEM cii = {0}; cii.cbSize = sizeof(cii); cii.flags = CLCIIF_GROUPFONT; - cii.pszText = MirandaUtils::getInstance()->mfTranslate(LPGENT("mirfox.options.tab2.allcontacts"), TEXT("** All contacts **")); + cii.pszText =TranslateT("** All contacts **"); hItemAll = (HANDLE)SendDlgItemMessage(hwndDlg, IDC2_CONTACTS_LIST, CLM_ADDINFOITEM, 0, (LPARAM)&cii); } @@ -595,10 +552,6 @@ INT_PTR CALLBACK DlgProcOpts_Tab2(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM return 0; } - - - - /* * callback function for tab 3 options page */ @@ -611,11 +564,7 @@ INT_PTR CALLBACK DlgProcOpts_Tab3(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM mirfoxMiranda.getMirfoxData().setTab3OptionsState(MFENUM_OPTIONS_INIT); - - MirandaUtils::getInstance()->mfTranslateControl(hwndDlg, IDC3_LABEL1, - LPGENT("mirfox.options.tab3.accounts"), TEXT("Show this accounts in 'Set status message' option in Firefox") - ); - + TranslateDialogDefault(hwndDlg); //protocol list initialization HWND hAccountsList = GetDlgItem(hwndDlg, IDC3_PROTOCOLS_LIST); @@ -624,7 +573,7 @@ INT_PTR CALLBACK DlgProcOpts_Tab3(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM LVCOLUMN lvCol = {0}; lvCol.mask = LVCF_WIDTH|LVCF_TEXT; - lvCol.pszText=TEXT("Protocol"); + lvCol.pszText=TranslateT("Protocol"); lvCol.cx = 260; //column width ListView_InsertColumn(hAccountsList, 0, &lvCol); @@ -689,12 +638,10 @@ INT_PTR CALLBACK DlgProcOpts_Tab3(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM ((LPNMHDR)lParam)->code == PSN_APPLY ){ //SaveOptions from tab3 mirfoxData to miranda database - - int i; HWND hList = GetDlgItem(hwndDlg, IDC3_PROTOCOLS_LIST); LVITEM lvItem = {0}; lvItem.mask = LVIF_PARAM; - for (i=0; imfTranslate(LPGENT("mirfox.options.tab1"), TEXT("Options")); + odp.ptszTab = LPGENT("Options"); odp.pfnDlgProc = DlgProcOpts_Tab1; Options_AddPage(wParam, &odp); //2 - contacts odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT2); - odp.ptszTab = MirandaUtils::getInstance()->mfTranslate(LPGENT("mirfox.options.tab2"), TEXT("Contacts")); + odp.ptszTab = LPGENT("Contacts"); odp.pfnDlgProc = DlgProcOpts_Tab2; Options_AddPage(wParam, &odp); //3 - accounts odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT3); - odp.ptszTab = MirandaUtils::getInstance()->mfTranslate(LPGENT("mirfox.options.tab3"), TEXT("Accounts")); + odp.ptszTab = LPGENT("Accounts"); odp.pfnDlgProc = DlgProcOpts_Tab3; Options_AddPage(wParam, &odp); diff --git a/plugins/MirFox/src/MirandaUtils.cpp b/plugins/MirFox/src/MirandaUtils.cpp index 146db14619..6952966cba 100644 --- a/plugins/MirFox/src/MirandaUtils.cpp +++ b/plugins/MirFox/src/MirandaUtils.cpp @@ -30,22 +30,19 @@ MirandaUtils::netlibLog_int(const wchar_t* szText){ #endif //_DEBUG } -void -MirandaUtils::netlibRegister(){ - +void MirandaUtils::netlibRegister(){ // Register netlib user for logging function NETLIBUSER nlu = { 0 }; nlu.cbSize = sizeof(nlu); nlu.flags = NUF_TCHAR | NUF_NOOPTIONS; nlu.szSettingsModule = PLUGIN_DB_ID; - nlu.ptszDescriptiveName = mfTranslate(LPGENT("mirfox.netlib.name"), TEXT("MirFox log")); + nlu.ptszDescriptiveName = TranslateT("MirFox log"); netlibHandle = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu); } -void -MirandaUtils::netlibUnregister(){ +void MirandaUtils::netlibUnregister(){ Netlib_CloseHandle(netlibHandle); netlibHandle = NULL; @@ -53,8 +50,7 @@ MirandaUtils::netlibUnregister(){ } -std::wstring& -MirandaUtils::getProfileName() +std::wstring& MirandaUtils::getProfileName() { if (profileName.size()>0){ //profileName is now inited @@ -69,8 +65,7 @@ MirandaUtils::getProfileName() } -std::wstring& -MirandaUtils::getDisplayName() +std::wstring& MirandaUtils::getDisplayName() { if (displayName.size()>0){ //displayName is now inited @@ -90,45 +85,7 @@ MirandaUtils::getDisplayName() } -/* - * mfTranslate - * It is my old solution of problem with not unique strings that must be translate by miranda. - * Function takes unique code (string id) and default translation (english) - * if no translation for code is found it returns default string. - * mfTranslate works on plugins layer and can't be used with core translated strings - * Tell me if this not standard solution cause problems in NG langpacks environment. - */ -TCHAR* -MirandaUtils::mfTranslate(const TCHAR* msgCode, TCHAR* msgDefault) -{ - TCHAR* msgTranslated = TranslateTS(msgCode); - if (_tcscmp(msgCode, msgTranslated) == 0){ - //no translation in miranda langpack - return msgDefault; - } else { - return msgTranslated; - } -} - - -void -MirandaUtils::mfTranslateControl(HWND parentWindowHwnd, long controlId, const TCHAR* msgCode, TCHAR* msgDefault) -{ - HWND controlHwnd = GetDlgItem(parentWindowHwnd, controlId); - if (controlHwnd != NULL){ - int currentTextLength = GetWindowTextLength(controlHwnd) + 1; - TCHAR* currentTextPtr = new TCHAR[currentTextLength]; - GetWindowText(controlHwnd, currentTextPtr, currentTextLength); - SetWindowText(controlHwnd, mfTranslate(msgCode, msgDefault)); - delete [] currentTextPtr; - } -} - - - - -/*static*/ void -MirandaUtils::userActionThread(void* threadArg) +void MirandaUtils::userActionThread(void* threadArg) { Thread_Push(0); ActionThreadArgStruct* actionThreadArgPtr = (ActionThreadArgStruct*)threadArg; @@ -163,12 +120,8 @@ MirandaUtils::userActionThread(void* threadArg) } - - -void -MirandaUtils::sendMessageToContact(ActionThreadArgStruct* args) +void MirandaUtils::sendMessageToContact(ActionThreadArgStruct* args) { - logger->log(L"MirandaUtils::sendMessageToContact: start"); if (args->targetHandle == NULL){ @@ -183,12 +136,9 @@ MirandaUtils::sendMessageToContact(ActionThreadArgStruct* args) } else { //'L'eft mouse button this->sendMessage(args, args->mirfoxDataPtr->leftClickSendMode); } - } - -void -MirandaUtils::sendMessage(ActionThreadArgStruct* args, MFENUM_SEND_MESSAGE_MODE mode) +void MirandaUtils::sendMessage(ActionThreadArgStruct* args, MFENUM_SEND_MESSAGE_MODE mode) { logger->log_p(L"MirandaUtils::sendMessage: mode = [%d] to = [" SCNuPTR L"] msg = [%s]", mode, args->targetHandle, args->userActionSelection ); @@ -284,13 +234,13 @@ MirandaUtils::sendMessage(ActionThreadArgStruct* args, MFENUM_SEND_MESSAGE_MODE //show notyfication popup (only in SMM_ONLY_SEND mode) wchar_t* buffer = new wchar_t[1024 * sizeof(wchar_t)]; if (contactNameW != NULL && tszAccountName != NULL){ - mir_sntprintf(buffer, 1024, mfTranslate(LPGENT("mirfox.message.sent"), TEXT("Message sent to %s (%s)")), contactNameW, tszAccountName); + mir_sntprintf(buffer, 1024, TranslateT("Message sent to %s (%s)"), contactNameW, tszAccountName); } else { - buffer = mir_wstrdup(mfTranslate(LPGENT("mirfox.message.sent.unknown"), TEXT("Message sent"))); + buffer = mir_wstrdup(TranslateT("Message sent")); } if(ServiceExists(MS_POPUP_ADDPOPUPCLASS)) { - ShowClassPopupT("MirFox_Notify", mfTranslate(LPGENT("mirfox.popup.notify.title"), TEXT("MirFox")), buffer); + ShowClassPopupT("MirFox_Notify", TranslateT("MirFox"), buffer); } else { PUShowMessageT(buffer, SM_NOTIFY); } @@ -323,29 +273,29 @@ MirandaUtils::sendMessage(ActionThreadArgStruct* args, MFENUM_SEND_MESSAGE_MODE logger->log_p(L"SMTC: ERROR - Can not send message - result = [%d] ", myMfAck->result); if (myMfAck->errorDesc != NULL){ if (contactNameW != NULL && tszAccountName != NULL){ - mir_sntprintf(buffer, 1024, mfTranslate(LPGENT("mirfox.message.badack.errordesc"), TEXT("Can not send message to %s (%s) - %S")), contactNameW, tszAccountName, myMfAck->errorDesc); + mir_sntprintf(buffer, 1024, TranslateT("Can not send message to %s (%s) - %S"), contactNameW, tszAccountName, myMfAck->errorDesc); } else { - mir_sntprintf(buffer, 1024, mfTranslate(LPGENT("mirfox.message.badack.errordesc.unknown"), TEXT("Can not send message - %S")), myMfAck->errorDesc); + mir_sntprintf(buffer, 1024, TranslateT("Can not send message - %S"), myMfAck->errorDesc); } } else { if (contactNameW != NULL && tszAccountName != NULL){ - mir_sntprintf(buffer, 1024, mfTranslate(LPGENT("mirfox.message.badack"), TEXT("Can not send message to %s (%s)")), contactNameW, tszAccountName); + mir_sntprintf(buffer, 1024, TranslateT("Can not send message to %s (%s)"), contactNameW, tszAccountName); } else { - buffer = mir_wstrdup(mfTranslate(LPGENT("mirfox.message.badack.unknown"), TEXT("Can not send message - %S"))); + buffer = mir_wstrdup(TranslateT("Can not send message - %S")); } } } else { logger->log(L"SMTC: ERROR - Can not send message 2"); if (contactNameW != NULL && tszAccountName != NULL){ - mir_sntprintf(buffer, 1024, mfTranslate(LPGENT("mirfox.message.noack"), TEXT("Can not send message to %s (%s)")), contactNameW, tszAccountName); + mir_sntprintf(buffer, 1024, TranslateT("Can not send message to %s (%s)"), contactNameW, tszAccountName); } else { - buffer = mir_wstrdup(mfTranslate(LPGENT("mirfox.message.noack.unknown"), TEXT("Can not send message"))); + buffer = mir_wstrdup(TranslateT("Can not send message")); } } if(ServiceExists(MS_POPUP_ADDPOPUPCLASS)) { - ShowClassPopupT("MirFox_Error", mfTranslate(LPGENT("mirfox.popup.error.title"), TEXT("MirFox error")), buffer); + ShowClassPopupT("MirFox_Error", TranslateT("MirFox error"), buffer); } else { PUShowMessageT(buffer, SM_WARNING); } @@ -387,9 +337,7 @@ MirandaUtils::sendMessage(ActionThreadArgStruct* args, MFENUM_SEND_MESSAGE_MODE } - -int -MirandaUtils::getMirandaSendModeFlag(char* targetHandleSzProto) +int MirandaUtils::getMirandaSendModeFlag(char* targetHandleSzProto) { if (CallProtoService(targetHandleSzProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_IMSENDUTF){ return PREF_UTF; @@ -399,16 +347,12 @@ MirandaUtils::getMirandaSendModeFlag(char* targetHandleSzProto) } - -HANDLE -MirandaUtils::sendMessageMiranda(HANDLE hContact, int mirandaSendModeFlag, char* msgBuffer) +HANDLE MirandaUtils::sendMessageMiranda(HANDLE hContact, int mirandaSendModeFlag, char* msgBuffer) { return (HANDLE)CallContactService(hContact, PSS_MESSAGE, (WPARAM)mirandaSendModeFlag, (LPARAM)msgBuffer); } - -void -MirandaUtils::addMessageToDB(HANDLE hContact, int mirandaSendModeFlag, char* msgBuffer, std::size_t bufSize, char* targetHandleSzProto) +void MirandaUtils::addMessageToDB(HANDLE hContact, int mirandaSendModeFlag, char* msgBuffer, std::size_t bufSize, char* targetHandleSzProto) { DBEVENTINFO dbei = {0}; dbei.cbSize = sizeof(dbei); @@ -423,8 +367,7 @@ MirandaUtils::addMessageToDB(HANDLE hContact, int mirandaSendModeFlag, char* msg //http://www.shloemi.com/2012/09/solved-setforegroundwindow-win32-api-not-always-works/ -/*static*/ void -MirandaUtils::ForceForegroundWindow(HWND hWnd) +void MirandaUtils::ForceForegroundWindow(HWND hWnd) { DWORD foreThread = GetWindowThreadProcessId(GetForegroundWindow(), NULL); DWORD appThread = GetCurrentThreadId(); @@ -440,37 +383,19 @@ MirandaUtils::ForceForegroundWindow(HWND hWnd) } } - -/*static*/ int -MirandaUtils::on_hook_OpenMW(WPARAM wParam, LPARAM lParam) +int MirandaUtils::on_hook_OpenMW(WPARAM wParam, LPARAM lParam) { - OnHookOpenMvStruct* param = (OnHookOpenMvStruct*)wParam; if (param->msgBuffer != NULL){ - - //open window and paste text - if (ServiceExists(MS_MSG_SENDMESSAGEW)){ - - char* msgBuffer = (char*)mir_wstrdup(param->msgBuffer->c_str()); - CallServiceSync(MS_MSG_SENDMESSAGEW, (WPARAM)param->targetHandle, (LPARAM)msgBuffer); - mir_free(msgBuffer); - - } else { - - char* msgBuffer = mir_u2a(param->msgBuffer->c_str()); - CallServiceSync(MS_MSG_SENDMESSAGE, (WPARAM)param->targetHandle, (LPARAM)msgBuffer); - mir_free(msgBuffer); - - } + TCHAR *msgBuffer = mir_tstrdup(param->msgBuffer->c_str()); + CallServiceSync(MS_MSG_SENDMESSAGET, (WPARAM)param->targetHandle, (LPARAM)msgBuffer); + mir_free(msgBuffer); delete param->msgBuffer; - } else { - //only open window - CallServiceSync(MS_MSG_SENDMESSAGE, (WPARAM)param->targetHandle, LPARAM(NULL)); - + CallServiceSync(MS_MSG_SENDMESSAGET, (WPARAM)param->targetHandle, 0); } // show and focus window @@ -501,12 +426,7 @@ MirandaUtils::on_hook_OpenMW(WPARAM wParam, LPARAM lParam) return 0; } - - - - -void -MirandaUtils::setStatusOnAccount(ActionThreadArgStruct* args) +void MirandaUtils::setStatusOnAccount(ActionThreadArgStruct* args) { logger->log(L"MirandaUtils::setStatusOnAccount: start"); @@ -535,14 +455,14 @@ MirandaUtils::setStatusOnAccount(ActionThreadArgStruct* args) if (tszAccountName != NULL){ logger->log_p(L"SSOA: Status message set on [%s]", tszAccountName); - mir_sntprintf(buffer, 1024, mfTranslate(LPGENT("mirfox.statusmsg.set"), TEXT("Status message set on %s")), tszAccountName); + mir_sntprintf(buffer, 1024, TranslateT("Status message set on %s"), tszAccountName); } else { logger->log(L"SSOA: Status message set"); - buffer = mir_wstrdup(mfTranslate(LPGENT("mirfox.statusmsg.set.unknown"), TEXT("Status message set"))); + buffer = mir_wstrdup(TranslateT("Status message set")); } if(ServiceExists(MS_POPUP_ADDPOPUPCLASS)) { - ShowClassPopupT("MirFox_Notify", mfTranslate(LPGENT("mirfox.popup.notify.title"), TEXT("MirFox")), buffer); + ShowClassPopupT("MirFox_Notify", TranslateT("MirFox"), buffer); } else { PUShowMessageT(buffer, SM_NOTIFY); } @@ -551,14 +471,14 @@ MirandaUtils::setStatusOnAccount(ActionThreadArgStruct* args) if (tszAccountName != NULL){ logger->log_p(L"SSOA: ERROR - Can not set status message 2 on [%s] - result = [%d] ", tszAccountName, result); - mir_sntprintf(buffer, 1024, mfTranslate(LPGENT("mirfox.statusmsg.error"), TEXT("Can not set status message on %s")), tszAccountName); + mir_sntprintf(buffer, 1024, TranslateT("Can not set status message on %s"), tszAccountName); } else { logger->log_p(L"SSOA: ERROR - Can not set status message 2 - result = [%d] ", result); - buffer = mir_wstrdup(mfTranslate(LPGENT("mirfox.statusmsg.error.unknown"), TEXT("Can not set status message"))); + buffer = mir_wstrdup(TranslateT("Can not set status message")); } if(ServiceExists(MS_POPUP_ADDPOPUPCLASS)) { - ShowClassPopupT("MirFox_Error", mfTranslate(LPGENT("mirfox.popup.error.title"), TEXT("MirFox error")), buffer); + ShowClassPopupT("MirFox_Error", TranslateT("MirFox error"), buffer); } else { PUShowMessageT(buffer, SM_WARNING); } @@ -568,22 +488,15 @@ MirandaUtils::setStatusOnAccount(ActionThreadArgStruct* args) } - - - -int -MirandaUtils::onProtoAck(WPARAM wParam, LPARAM lParam) +int MirandaUtils::onProtoAck(WPARAM wParam, LPARAM lParam) { MirandaUtils* mirandaUtils = MirandaUtils::getInstance(); mirandaUtils->onProtoAckOnInstance((ACKDATA*)lParam); return 0; } - -void -MirandaUtils::onProtoAckOnInstance(ACKDATA* ack) +void MirandaUtils::onProtoAckOnInstance(ACKDATA* ack) { - if (ack == NULL || ack->type != ACKTYPE_MESSAGE){ //we are waiting for ACKTYPE_MESSAGE ack's return; @@ -616,21 +529,12 @@ MirandaUtils::onProtoAckOnInstance(ACKDATA* ack) } - - - - - - - #define OLD_PLUGIN_DB_ID "MirfoxMiranda" + /** * function changes db module name from "MirfoxMiranda" (used before 0.3.0.0) to "Mirfox" */ -void -MirandaUtils::translateOldDBNames() { - - +void MirandaUtils::translateOldDBNames() { //settings "clientsProfilesFilterCheckbox", "clientsProfilesFilterString" int opt1KeyValue = db_get_b(0, OLD_PLUGIN_DB_ID, "clientsProfilesFilterCheckbox", 0); if (opt1KeyValue != 0){ @@ -643,10 +547,8 @@ MirandaUtils::translateOldDBNames() { logger->log(L"TranslateOldDBNames: no old settings found. returning."); return; - } - DBVARIANT opt2Dbv = {0}; INT_PTR opt2Result = db_get_s(0, OLD_PLUGIN_DB_ID, "clientsProfilesFilterString", &opt2Dbv, DBVT_TCHAR); if (opt2Result == 0){ //success @@ -659,9 +561,6 @@ MirandaUtils::translateOldDBNames() { } db_free(&opt2Dbv); - - - //account's settings "ACCOUNTSTATE_" int accountsTmpCount = 0; PROTOACCOUNT **accountsTmp; @@ -681,7 +580,6 @@ MirandaUtils::translateOldDBNames() { } - //contacts "state" for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)){ @@ -696,10 +594,7 @@ MirandaUtils::translateOldDBNames() { } - - //delete db module CallService(MS_DB_MODULE_DELETE, 0, (LPARAM)OLD_PLUGIN_DB_ID); - } diff --git a/plugins/MirFox/src/MirandaUtils.h b/plugins/MirFox/src/MirandaUtils.h index 673a4495eb..b0a05fce6f 100644 --- a/plugins/MirFox/src/MirandaUtils.h +++ b/plugins/MirFox/src/MirandaUtils.h @@ -49,11 +49,6 @@ public: std::wstring& getDisplayName(); - //description at MirandaUtils.cpp - TCHAR* mfTranslate(const TCHAR* msgCode, TCHAR* msgDefault); - - void mfTranslateControl(HWND parentWindowHwnd, long controlId, const TCHAR* msgCode, TCHAR* msgDefault); - static void userActionThread(void* threadArg); static int onProtoAck(WPARAM wParam, LPARAM lParam); diff --git a/plugins/MirFox/src/MirfoxMiranda.cpp b/plugins/MirFox/src/MirfoxMiranda.cpp index 0c031276a7..518431672c 100644 --- a/plugins/MirFox/src/MirfoxMiranda.cpp +++ b/plugins/MirFox/src/MirfoxMiranda.cpp @@ -17,28 +17,11 @@ CMirfoxMiranda::~CMirfoxMiranda() { } - -MirfoxData& -CMirfoxMiranda::getMirfoxData(){ +MirfoxData& CMirfoxMiranda::getMirfoxData(){ return mirfoxData; } - -bool -CMirfoxMiranda::onMirandaPluginInfoExCheck(DWORD actualMirandaVersion) -{ -// DWORD minimalMirandaVersion = PLUGIN_MAKE_VERSION(0,8,0,0); -// if ( actualMirandaVersion < minimalMirandaVersion) { -// return false; -// } else { - return true; -// } -} - - - -int -CMirfoxMiranda::onMirandaInterfaceLoad() +int CMirfoxMiranda::onMirandaInterfaceLoad() { mirandaUtils->netlibRegister(); //for Miranda logger init @@ -70,8 +53,7 @@ CMirfoxMiranda::onMirandaInterfaceLoad() } -int -CMirfoxMiranda::onMirandaInterfaceUnload() +int CMirfoxMiranda::onMirandaInterfaceUnload() { UnhookEvent(mirfoxData.hhook_OpenMW); @@ -88,9 +70,7 @@ CMirfoxMiranda::onMirandaInterfaceUnload() return 0; } - -void -CMirfoxMiranda::initializeSharedMemory(MirfoxData& mirfoxData) +void CMirfoxMiranda::initializeSharedMemory(MirfoxData& mirfoxData) { //initialize CSM record and MSMs with data from mirfoxData @@ -105,16 +85,13 @@ CMirfoxMiranda::initializeSharedMemory(MirfoxData& mirfoxData) } -void -CMirfoxMiranda::commitSharedMemory() +void CMirfoxMiranda::commitSharedMemory() { //commitSM(); sharedMemoryUtils->commitSM(); } - -void -CMirfoxMiranda::initializeSharedMemoryData(MirfoxData& mirfoxData, SharedMemoryUtils* sharedMemoryUtils) +void CMirfoxMiranda::initializeSharedMemoryData(MirfoxData& mirfoxData, SharedMemoryUtils* sharedMemoryUtils) { std::wstring visableTo; @@ -129,16 +106,10 @@ CMirfoxMiranda::initializeSharedMemoryData(MirfoxData& mirfoxData, SharedMemoryU if(result.errorCode != 0){ //error if (result.errorCode == -3){ //existing csm version is too high -> i'm too old - MessageBox(NULL, - MirandaUtils::getInstance()->mfTranslate(LPGENT("mirfox.msgbox.csmtooold.message"), TEXT("This MirFox (Miranda) plugin is too old. Please update it.")), - MirandaUtils::getInstance()->mfTranslate(LPGENT("mirfox.msgbox.csmtooold.title"), TEXT("MirFox (Miranda) - Error")), - MB_OK | MB_ICONWARNING ); + MessageBox(NULL, TranslateT("This MirFox (Miranda) plugin is too old. Please update it."), TranslateT("MirFox (Miranda) - Error"), MB_OK | MB_ICONWARNING ); } if (result.errorCode == -4){ //existing csm version is too low -> sb is too old - MessageBox(NULL, - MirandaUtils::getInstance()->mfTranslate(LPGENT("mirfox.msgbox.csmtoonew.message"), TEXT("This MirFox (Miranda) plugin can not start beacouse some other MirFox component is too old. Please, check and update your MirFox components.")), - MirandaUtils::getInstance()->mfTranslate(LPGENT("mirfox.msgbox.csmtoonew.title"), TEXT("MirFox (Miranda) - Error")), - MB_OK | MB_ICONWARNING ); + MessageBox(NULL, TranslateT("This MirFox (Miranda) plugin can not start beacouse some other MirFox component is too old. Please, check and update your MirFox components."), TranslateT("MirFox (Miranda) - Error"), MB_OK | MB_ICONWARNING ); } mirfoxData.setPluginState(MFENUM_PLUGIN_STATE_ERROR); return; @@ -182,27 +153,17 @@ CMirfoxMiranda::initializeSharedMemoryData(MirfoxData& mirfoxData, SharedMemoryU sharedMemoryUtils->addContactToSM((uint64_t)mirandaContactsIter->contactHandle, (uint64_t)NULL, (uint64_t)1, mirandaContactsIter->contactNameW); } } - - } -void -CMirfoxMiranda::unloadSharedMemory() +void CMirfoxMiranda::unloadSharedMemory() { - sharedMemoryUtils->unloadSharedMemory(mirfoxData.processCsmId); //all msm's will be deleted when miranda process returns - } - - - - -/*static*/ void -CMirfoxMiranda::csmThread(void* threadArg) +void CMirfoxMiranda::csmThread(void* threadArg) { Thread_Push(0); @@ -291,11 +252,7 @@ CMirfoxMiranda::csmThread(void* threadArg) } - - - -void -CMirfoxMiranda::initializeMessageQueue(MirfoxData& mirfoxData) +void CMirfoxMiranda::initializeMessageQueue(MirfoxData& mirfoxData) { MessageQueueUtils* messageQueueUtils = MessageQueueUtils::getInstance(); @@ -315,8 +272,7 @@ CMirfoxMiranda::initializeMessageQueue(MirfoxData& mirfoxData) } -void -CMirfoxMiranda::unloadMessageQueue(uint16_t unloadedMQProcessId) +void CMirfoxMiranda::unloadMessageQueue(uint16_t unloadedMQProcessId) { MessageQueueUtils* messageQueueUtils = MessageQueueUtils::getInstance(); @@ -324,9 +280,7 @@ CMirfoxMiranda::unloadMessageQueue(uint16_t unloadedMQProcessId) } - -/*static*/ void -CMirfoxMiranda::msgQueueThread(void* threadArg) +void CMirfoxMiranda::msgQueueThread(void* threadArg) { Thread_Push(0); @@ -425,10 +379,7 @@ CMirfoxMiranda::msgQueueThread(void* threadArg) mir_forkthread(MirandaUtils::userActionThread, actionThreadArgPtr); } - - } - } i--; @@ -452,7 +403,4 @@ CMirfoxMiranda::msgQueueThread(void* threadArg) mirfoxDataPtr->workerThreadsCount--; Thread_Pop(); return; - -} - - +} \ No newline at end of file diff --git a/plugins/MirFox/src/MirfoxMiranda.h b/plugins/MirFox/src/MirfoxMiranda.h index 0d78e0cfc0..0bcce0cf99 100644 --- a/plugins/MirFox/src/MirfoxMiranda.h +++ b/plugins/MirFox/src/MirfoxMiranda.h @@ -18,10 +18,6 @@ public: MirfoxData& getMirfoxData(); - - - bool onMirandaPluginInfoExCheck(DWORD actualMirandaVersion); - int onMirandaInterfaceLoad(); int onMirandaInterfaceUnload(); -- cgit v1.2.3