From 7ea99ae92f255ea2b9df5a3a4711264b967a55fb Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 2 Jul 2024 15:22:01 +0300 Subject: =?UTF-8?q?fixes=20#4507=20(UInfoEx:=20=D0=B8=D0=BC=D0=BF=D0=BE?= =?UTF-8?q?=D1=80=D1=82=20=D0=B3=D1=80=D1=83=D0=BF=D0=BF=D1=8B=20=D0=B2?= =?UTF-8?q?=D1=8B=D0=B7=D1=8B=D0=B2=D0=B0=D0=B5=D1=82=20=D1=8D=D0=BA=D1=81?= =?UTF-8?q?=D0=BF=D0=BE=D1=80=D1=82)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/UserInfoEx/src/dlg_propsheet.cpp | 4 +- plugins/UserInfoEx/src/ex_import/svc_ExImport.cpp | 81 +++++++++-------------- plugins/UserInfoEx/src/ex_import/svc_ExImport.h | 12 ++-- plugins/UserInfoEx/src/mir_menuitems.cpp | 31 ++++----- 4 files changed, 52 insertions(+), 76 deletions(-) (limited to 'plugins/UserInfoEx') diff --git a/plugins/UserInfoEx/src/dlg_propsheet.cpp b/plugins/UserInfoEx/src/dlg_propsheet.cpp index 4d1805c6d8..344b401f34 100644 --- a/plugins/UserInfoEx/src/dlg_propsheet.cpp +++ b/plugins/UserInfoEx/src/dlg_propsheet.cpp @@ -1268,14 +1268,14 @@ static INT_PTR CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lPar break; case BTN_IMPORT: - svcExIm_ContactImport_Service((WPARAM)pPs->hContact, 0); + svcImportContact(pPs->hContact, 0); break; case BTN_EXPORT: // save changes before exporting data DlgProc(hDlg, WM_COMMAND, MAKEWPARAM(IDAPPLY, BN_CLICKED), (LPARAM)GetDlgItem(hDlg, IDAPPLY)); // do the exporting stuff - svcExIm_ContactExport_Service((WPARAM)pPs->hContact, 0); + svcExportContact(pPs->hContact, 0); break; } break; diff --git a/plugins/UserInfoEx/src/ex_import/svc_ExImport.cpp b/plugins/UserInfoEx/src/ex_import/svc_ExImport.cpp index 145959d32f..abfd58e804 100644 --- a/plugins/UserInfoEx/src/ex_import/svc_ExImport.cpp +++ b/plugins/UserInfoEx/src/ex_import/svc_ExImport.cpp @@ -156,6 +156,10 @@ INT_PTR SvcExImport_Export(lpExImParam ExImContact, HWND hwndParent) INT_PTR SvcExImport_Import(lpExImParam ExImContact, HWND hwndParent) { + // Still under development + if (ExImContact->Typ == EXIM_ACCOUNT || ExImContact->Typ == EXIM_GROUP) + return 1; + wchar_t szFileName[MAX_PATH]; szFileName[0] = 0; // create the filename to suggest the user for the to export contact @@ -163,10 +167,6 @@ INT_PTR SvcExImport_Import(lpExImParam ExImContact, HWND hwndParent) int nIndex = DlgExIm_OpenFileName(hwndParent, TranslateT("Import User Details from VCard"), FilterString(ExImContact), szFileName); - // Stop during develop - if (ExImContact->Typ == EXIM_ACCOUNT || - ExImContact->Typ == EXIM_GROUP) return 1; - switch (nIndex) { case 1: CFileXml().Import(ExImContact->hContact, szFileName); @@ -199,7 +199,7 @@ INT_PTR SvcExImport_Import(lpExImParam ExImContact, HWND hwndParent) * Ex/import All (MainMenu) *********************************/ -INT_PTR svcExIm_MainExport_Service(WPARAM, LPARAM lParam) +static INT_PTR svcExIm_MainExport_Service(WPARAM, LPARAM lParam) { ExImParam ExIm; memset(&ExIm, 0, sizeof(ExIm)); @@ -208,7 +208,7 @@ INT_PTR svcExIm_MainExport_Service(WPARAM, LPARAM lParam) return SvcExImport_Export(&ExIm, (HWND)lParam); } -INT_PTR svcExIm_MainImport_Service(WPARAM, LPARAM lParam) +static INT_PTR svcExIm_MainImport_Service(WPARAM, LPARAM lParam) { ExImParam ExIm; memset(&ExIm, 0, sizeof(ExIm)); @@ -221,7 +221,7 @@ INT_PTR svcExIm_MainImport_Service(WPARAM, LPARAM lParam) * Ex/import Contact (ContactMenu) *********************************/ -INT_PTR svcExIm_ContactExport_Service(WPARAM hContact, LPARAM lParam) +INT_PTR svcExportContact(WPARAM hContact, LPARAM lParam) { ExImParam ExIm; memset(&ExIm, 0, sizeof(ExIm)); @@ -230,7 +230,7 @@ INT_PTR svcExIm_ContactExport_Service(WPARAM hContact, LPARAM lParam) return SvcExImport_Export(&ExIm, (HWND)lParam); } -INT_PTR svcExIm_ContactImport_Service(WPARAM hContact, LPARAM lParam) +INT_PTR svcImportContact(WPARAM hContact, LPARAM lParam) { ExImParam ExIm; memset(&ExIm, 0, sizeof(ExIm)); @@ -253,45 +253,29 @@ INT_PTR svcExIm_ContactImport_Service(WPARAM hContact, LPARAM lParam) * @return always 0 **/ -INT_PTR svcExIm_Group_Service(WPARAM wParam, LPARAM) +INT_PTR svcExportGroup(WPARAM wParam, LPARAM) { - ExImParam ExIm; - INT_PTR hItem = 0, hRoot = 0, hParent = 0; - wchar_t tszGroup[120], tszItem[120]; - memset(&tszGroup, 0, sizeof(tszGroup)); - memset(&tszItem, 0, sizeof(tszItem)); - memset(&ExIm, 0, sizeof(ExIm)); - LPTSTR ptszGroup = tszGroup; - LPTSTR ptszItem = tszItem; + auto *grp = (ClcGroup *)wParam; - HWND hClist = g_clistApi.hwndContactTree; - // get clist selection - hItem = SendMessage(hClist, CLM_GETSELECTION, 0, 0); - hRoot = SendMessage(hClist, CLM_GETNEXTITEM, (WPARAM)CLGN_ROOT, (LPARAM)hItem); - while (hItem) { - if (SendMessage(hClist, CLM_GETITEMTYPE, (WPARAM)hItem, 0) == CLCIT_GROUP) { - SendMessage(hClist, CLM_GETITEMTEXT, (WPARAM)hItem, (LPARAM)ptszItem); - LPTSTR temp = mir_wstrdup(ptszGroup); - mir_snwprintf(tszGroup, L"%s%s%s", ptszItem, mir_wstrlen(temp) ? L"\\" : L"", temp); - mir_free(temp); - } - hParent = SendMessage(hClist, CLM_GETNEXTITEM, (WPARAM)CLGN_PARENT, (LPARAM)hItem); - hItem = (hParent != hRoot) ? hParent : 0; - } - ExIm.ptszName = ptszGroup; + ExImParam ExIm; + ExIm.ptszName = Clist_GroupGetName(grp->groupId); ExIm.Typ = EXIM_SUBGROUP; + SvcExImport_Export(&ExIm, g_clistApi.hwndContactTree); + return 0; +}; - if (wParam) { - //Export "/ExportGroup" - SvcExImport_Export(&ExIm, hClist); - } - else { - //Import "/ImportGroup" - SvcExImport_Import(&ExIm, hClist); - } +/* +INT_PTR svcImportGroup(WPARAM wParam, LPARAM) +{ + auto *grp = (ClcGroup *)wParam; + ExImParam ExIm; + ExIm.ptszName = Clist_GroupGetName(grp->groupId); + ExIm.Typ = EXIM_SUBGROUP; + SvcExImport_Import(&ExIm, g_clistApi.hwndContactTree); return 0; }; +*/ /********************************* *Ex/Import Account (AccountMenu) @@ -320,24 +304,19 @@ struct StatusMenuExecParam * @return always 0 **/ -INT_PTR svcExIm_Account_Service(WPARAM, LPARAM lParam) +INT_PTR svcExImAccount(WPARAM, LPARAM lParam) { ExImParam ExIm; memset(&ExIm, 0, sizeof(ExIm)); HWND hClist = g_clistApi.hwndContactTree; StatusMenuExecParam *smep = (StatusMenuExecParam*)Menu_GetItemData((HGENMENU)lParam); - ExIm.pszName = mir_strdup(smep->proto); + ExIm.pszName = smep->proto; ExIm.Typ = EXIM_ACCOUNT; - if (strstr(smep->svc, "/ExportAccount")) { - //Export "/ExportAccount" + if (strstr(smep->svc, "/ExportAccount")) SvcExImport_Export(&ExIm, hClist); - } - else { - //Import "/ImportAccount" + else SvcExImport_Import(&ExIm, hClist); - } - mir_free(ExIm.pszName); return 0; }; @@ -352,6 +331,6 @@ void SvcExImport_LoadModule() { CreateServiceFunction(MS_USERINFO_VCARD_EXPORTALL, svcExIm_MainExport_Service); CreateServiceFunction(MS_USERINFO_VCARD_IMPORTALL, svcExIm_MainImport_Service); - CreateServiceFunction(MS_USERINFO_VCARD_EXPORT, svcExIm_ContactExport_Service); - CreateServiceFunction(MS_USERINFO_VCARD_IMPORT, svcExIm_ContactImport_Service); + CreateServiceFunction(MS_USERINFO_VCARD_EXPORT, svcExportContact); + CreateServiceFunction(MS_USERINFO_VCARD_IMPORT, svcImportContact); } diff --git a/plugins/UserInfoEx/src/ex_import/svc_ExImport.h b/plugins/UserInfoEx/src/ex_import/svc_ExImport.h index c4f0b3ed3b..c484336610 100644 --- a/plugins/UserInfoEx/src/ex_import/svc_ExImport.h +++ b/plugins/UserInfoEx/src/ex_import/svc_ExImport.h @@ -42,12 +42,12 @@ enum ExImType EXIM_ACCOUNT = 16 }; -INT_PTR svcExIm_MainExport_Service(WPARAM wParam, LPARAM lParam); -INT_PTR svcExIm_MainImport_Service(WPARAM wParam, LPARAM lParam); -INT_PTR svcExIm_ContactExport_Service(WPARAM wParam, LPARAM lParam); -INT_PTR svcExIm_ContactImport_Service(WPARAM wParam, LPARAM lParam); -INT_PTR svcExIm_Group_Service(WPARAM wParam, LPARAM lParam); -INT_PTR svcExIm_Account_Service(WPARAM wParam, LPARAM lParam); +INT_PTR svcExportContact(WPARAM wParam, LPARAM lParam); +INT_PTR svcImportContact(WPARAM wParam, LPARAM lParam); +INT_PTR svcExportGroup(WPARAM wParam, LPARAM lParam); +INT_PTR svcImportGroup(WPARAM wParam, LPARAM lParam); + +INT_PTR svcExImAccount(WPARAM wParam, LPARAM lParam); void SvcExImport_LoadModule(); diff --git a/plugins/UserInfoEx/src/mir_menuitems.cpp b/plugins/UserInfoEx/src/mir_menuitems.cpp index 6635f70216..4fe339784e 100644 --- a/plugins/UserInfoEx/src/mir_menuitems.cpp +++ b/plugins/UserInfoEx/src/mir_menuitems.cpp @@ -374,7 +374,6 @@ void RebuildSubGroup() { int flag = 0; uint8_t item = 0; - GroupMenuParam gmp = { 0 }; // load options flag = g_plugin.getByte(SET_MI_SUBGROUP, MCAS_NOTINITIATED); @@ -387,12 +386,8 @@ void RebuildSubGroup() RemoveMenuItems(hSubGroupMenuItems, _countof(hSubGroupMenuItems)); // create service name main (prevent to generate {(Null)/Ex-/Import Group} in db) and set pointer to end it - char text[200]; - mir_strcpy(text, "UserInfo"); CMenuItem mi(&g_plugin); - mi.pszService = text; - char* tDest = text + mir_strlen(text); HGENMENU mhRoot; @@ -430,23 +425,23 @@ void RebuildSubGroup() // Export SET_UID(mi, 0x65be2523, 0x15fd, 0x45ca, 0xae, 0xe6, 0xc2, 0x98, 0xd2, 0xa9, 0xff, 0xd5); - mir_strcpy(tDest, "/ExportGroup"); //mi.pszService - if (!ServiceExists(mi.pszService)) CreateServiceFunction(mi.pszService, svcExIm_Group_Service); + mi.pszService = "UserInfo/ExportGroup"; + CreateServiceFunction(mi.pszService, svcExportGroup); mi.name.a = mhRoot!= NULL ? LPGEN("&Export") : LPGEN("&Export group"); mi.position = 1050200; mi.hIcolibItem = g_plugin.getIconHandle(IDI_EXPORT); - gmp.wParam = TRUE; - hSubGroupMenuItems[item++] = Menu_AddGroupMenuItem(&mi, &gmp); + hSubGroupMenuItems[item++] = Menu_AddGroupMenuItem(&mi); - // Import + // Import (not implemented yet) + /* SET_UID(mi, 0xf6be7278, 0x4adb, 0x4e6a, 0x9f, 0x63, 0x79, 0xda, 0xbb, 0xcd, 0xbe, 0x42); - mir_strcpy(tDest, "/ImportGroup"); //mi.pszService - if (!ServiceExists(mi.pszService)) CreateServiceFunction(mi.pszService, svcExIm_Group_Service); + mi.pszService = "UserInfo/ImportGroup"; + CreateServiceFunction(mi.pszService, svcImportGroup); mi.name.a = mhRoot != NULL ? LPGEN("&Import") : LPGEN("&Import group"); mi.position = 1050300; mi.hIcolibItem = g_plugin.getIconHandle(IDI_IMPORT); - gmp.wParam = FALSE; - hSubGroupMenuItems[item++] = Menu_AddGroupMenuItem(&mi, &gmp); + hSubGroupMenuItems[item++] = Menu_AddGroupMenuItem(&mi); + */ } int OnBuildGroupMenu(WPARAM wParam, LPARAM) @@ -560,19 +555,21 @@ int OnBuildStatusMenu(WPARAM, LPARAM lParam) // Export mir_strcpy(tDest, "/ExportAccount"); - CreateServiceFunction(mi.pszService, svcExIm_Account_Service); + CreateServiceFunction(mi.pszService, svcExImAccount); mi.name.a = LPGEN("&Export xml"); mi.position = 50200; mi.hIcolibItem = g_plugin.getIconHandle(IDI_EXPORT); hMenuItemAccount[mItems*i + item++] = Menu_AddStatusMenuItem(&mi, pa->szModuleName); - // Import + // Import (not implemented yet) + /* mir_strcpy(tDest, "/ImportAccount"); - CreateServiceFunction(mi.pszService, svcExIm_Account_Service); + CreateServiceFunction(mi.pszService, svcExImAccount); mi.name.a = LPGEN("&Import xml"); mi.position = 50300; mi.hIcolibItem = g_plugin.getIconHandle(IDI_IMPORT); hMenuItemAccount[mItems*i + item++] = Menu_AddStatusMenuItem(&mi, pa->szModuleName); + */ } return 0; } -- cgit v1.2.3