summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2023-03-02 14:16:29 +0300
committerGeorge Hazan <ghazan@miranda.im>2023-03-02 14:16:29 +0300
commit504dffe560e81242764071a7624695b015b6ddbc (patch)
treeae6dfe8a55570038984c46a19e38dace07c4dea6
parent118580d1089cd4677031f7490f161f02f0fc6286 (diff)
ICQ: server groups editor moved to the separate module
-rw-r--r--protocols/ICQ-WIM/ICQ-WIM.vcxproj1
-rw-r--r--protocols/ICQ-WIM/ICQ-WIM.vcxproj.filters3
-rw-r--r--protocols/ICQ-WIM/src/groups.cpp125
-rw-r--r--protocols/ICQ-WIM/src/proto.cpp107
4 files changed, 129 insertions, 107 deletions
diff --git a/protocols/ICQ-WIM/ICQ-WIM.vcxproj b/protocols/ICQ-WIM/ICQ-WIM.vcxproj
index 8ee9249589..e9b9f8c37e 100644
--- a/protocols/ICQ-WIM/ICQ-WIM.vcxproj
+++ b/protocols/ICQ-WIM/ICQ-WIM.vcxproj
@@ -27,6 +27,7 @@
</ImportGroup>
<ItemGroup>
<ClCompile Include="src\groupchats.cpp" />
+ <ClCompile Include="src\groups.cpp" />
<ClCompile Include="src\http.cpp" />
<ClCompile Include="src\ignore.cpp" />
<ClCompile Include="src\main.cpp" />
diff --git a/protocols/ICQ-WIM/ICQ-WIM.vcxproj.filters b/protocols/ICQ-WIM/ICQ-WIM.vcxproj.filters
index 52a8649bb9..62171a5720 100644
--- a/protocols/ICQ-WIM/ICQ-WIM.vcxproj.filters
+++ b/protocols/ICQ-WIM/ICQ-WIM.vcxproj.filters
@@ -38,6 +38,9 @@
<ClCompile Include="src\mra.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="src\groups.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\http.h">
diff --git a/protocols/ICQ-WIM/src/groups.cpp b/protocols/ICQ-WIM/src/groups.cpp
new file mode 100644
index 0000000000..93c7ef6e8b
--- /dev/null
+++ b/protocols/ICQ-WIM/src/groups.cpp
@@ -0,0 +1,125 @@
+/*
+Copyright (C) 2012-23 Miranda NG team (https://miranda-ng.org)
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation version 2
+of the License.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "stdafx.h"
+
+INT_PTR CIcqProto::UploadGroups(WPARAM, LPARAM)
+{
+ for (auto &it : AccContacts()) {
+ if (isChatRoom(it))
+ continue;
+
+ ptrW wszIcqGroup(getWStringA(it, "IcqGroup"));
+ if (wszIcqGroup == nullptr)
+ continue;
+
+ ptrW wszMirGroup(Clist_GetGroup(it));
+ if (!wszMirGroup)
+ wszMirGroup = mir_wstrdup(L"General");
+ if (mir_wstrcmp(wszIcqGroup, wszMirGroup))
+ MoveContactToGroup(it, wszIcqGroup, wszMirGroup);
+ }
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+class CGroupEditDlg : public CIcqDlgBase
+{
+ CCtrlListView groups;
+
+public:
+
+ static CGroupEditDlg *pDlg;
+
+ CGroupEditDlg(CIcqProto *ppro) :
+ CIcqDlgBase(ppro, IDD_EDITGROUPS),
+ groups(this, IDC_GROUPS)
+ {
+ groups.OnBuildMenu = Callback(this, &CGroupEditDlg::onMenu);
+ }
+
+ void RefreshGroups()
+ {
+ groups.DeleteAllItems();
+
+ for (auto &it : m_proto->m_arGroups.rev_iter())
+ groups.AddItem(it->wszName, 0, (LPARAM)it);
+ }
+
+ bool OnInitDialog() override
+ {
+ pDlg = this;
+ groups.AddColumn(0, TranslateT("Name"), 300);
+ RefreshGroups();
+ return true;
+ }
+
+ void OnDestroy() override
+ {
+ pDlg = nullptr;
+ }
+
+ void onMenu(void *)
+ {
+ int cur = groups.GetSelectionMark();
+ if (cur == -1)
+ return;
+
+ IcqGroup *pGroup = (IcqGroup *)groups.GetItemData(cur);
+
+ HMENU hMenu = CreatePopupMenu();
+ AppendMenu(hMenu, MF_STRING, 1, TranslateT("Rename"));
+ AppendMenu(hMenu, MF_STRING, 2, TranslateT("Delete"));
+
+ POINT pt;
+ GetCursorPos(&pt);
+ int cmd = TrackPopupMenu(hMenu, TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, m_hwnd, nullptr);
+ DestroyMenu(hMenu);
+
+ if (cmd == 1) { // rename
+ ENTER_STRING es = {};
+ es.szModuleName = m_proto->m_szModuleName;
+ es.caption = TranslateT("Enter new group name");
+ if (!EnterString(&es))
+ return;
+
+ m_proto->Push(new AsyncHttpRequest(CONN_MAIN, REQUEST_GET, ICQ_API_SERVER "/buddylist/renameGroup")
+ << AIMSID(m_proto) << WCHAR_PARAM("oldGroup", pGroup->wszSrvName) << GROUP_PARAM("newGroup", es.ptszResult));
+
+ mir_free(es.ptszResult);
+ }
+ else if (cmd == 2) { // delete
+ m_proto->Push(new AsyncHttpRequest(CONN_MAIN, REQUEST_GET, ICQ_API_SERVER "/buddylist/removeGroup")
+ << AIMSID(m_proto) << WCHAR_PARAM("group", pGroup->wszSrvName));
+ }
+ }
+};
+
+CGroupEditDlg *CGroupEditDlg::pDlg = nullptr;
+
+INT_PTR CIcqProto::EditGroups(WPARAM, LPARAM)
+{
+ (new CGroupEditDlg(this))->Show();
+ return 0;
+}
+
+void RefreshGroups(void)
+{
+ if (CGroupEditDlg::pDlg != nullptr)
+ CGroupEditDlg::pDlg->RefreshGroups();
+}
diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp
index 18064206d4..bcb0fd3056 100644
--- a/protocols/ICQ-WIM/src/proto.cpp
+++ b/protocols/ICQ-WIM/src/proto.cpp
@@ -207,107 +207,6 @@ void CIcqProto::OnBuildProtoMenu()
Menu_ShowItem(m_hUploadGroups, false);
}
-INT_PTR CIcqProto::UploadGroups(WPARAM, LPARAM)
-{
- for (auto &it : AccContacts()) {
- if (isChatRoom(it))
- continue;
-
- ptrW wszIcqGroup(getWStringA(it, "IcqGroup"));
- if (wszIcqGroup == nullptr)
- continue;
-
- ptrW wszMirGroup(Clist_GetGroup(it));
- if (!wszMirGroup)
- wszMirGroup = mir_wstrdup(L"General");
- if (mir_wstrcmp(wszIcqGroup, wszMirGroup))
- MoveContactToGroup(it, wszIcqGroup, wszMirGroup);
- }
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
-class CGroupEditDlg : public CIcqDlgBase
-{
- CCtrlListView groups;
-
-public:
-
- static CGroupEditDlg *pDlg;
-
- CGroupEditDlg(CIcqProto *ppro) :
- CIcqDlgBase(ppro, IDD_EDITGROUPS),
- groups(this, IDC_GROUPS)
- {
- groups.OnBuildMenu = Callback(this, &CGroupEditDlg::onMenu);
- }
-
- void RefreshGroups()
- {
- groups.DeleteAllItems();
-
- for (auto &it : m_proto->m_arGroups.rev_iter())
- groups.AddItem(it->wszName, 0, (LPARAM)it);
- }
-
- bool OnInitDialog() override
- {
- pDlg = this;
- groups.AddColumn(0, TranslateT("Name"), 300);
- RefreshGroups();
- return true;
- }
-
- void OnDestroy() override
- {
- pDlg = nullptr;
- }
-
- void onMenu(void *)
- {
- int cur = groups.GetSelectionMark();
- if (cur == -1)
- return;
-
- IcqGroup *pGroup = (IcqGroup *)groups.GetItemData(cur);
-
- HMENU hMenu = CreatePopupMenu();
- AppendMenu(hMenu, MF_STRING, 1, TranslateT("Rename"));
- AppendMenu(hMenu, MF_STRING, 2, TranslateT("Delete"));
-
- POINT pt;
- GetCursorPos(&pt);
- int cmd = TrackPopupMenu(hMenu, TPM_RIGHTBUTTON | TPM_RETURNCMD, pt.x, pt.y, 0, m_hwnd, nullptr);
- DestroyMenu(hMenu);
-
- if (cmd == 1) { // rename
- ENTER_STRING es = {};
- es.szModuleName = m_proto->m_szModuleName;
- es.caption = TranslateT("Enter new group name");
- if (!EnterString(&es))
- return;
-
- m_proto->Push(new AsyncHttpRequest(CONN_MAIN, REQUEST_GET, ICQ_API_SERVER "/buddylist/renameGroup")
- << AIMSID(m_proto) << WCHAR_PARAM("oldGroup", pGroup->wszSrvName) << GROUP_PARAM("newGroup", es.ptszResult));
-
- mir_free(es.ptszResult);
- }
- else if (cmd == 2) { // delete
- m_proto->Push(new AsyncHttpRequest(CONN_MAIN, REQUEST_GET, ICQ_API_SERVER "/buddylist/removeGroup")
- << AIMSID(m_proto) << WCHAR_PARAM("group", pGroup->wszSrvName));
- }
- }
-};
-
-CGroupEditDlg *CGroupEditDlg::pDlg = nullptr;
-
-INT_PTR CIcqProto::EditGroups(WPARAM, LPARAM)
-{
- (new CGroupEditDlg(this))->Show();
- return 0;
-}
-
INT_PTR CIcqProto::EditProfile(WPARAM, LPARAM)
{
if (mir_wstrlen(m_szOwnId))
@@ -315,12 +214,6 @@ INT_PTR CIcqProto::EditProfile(WPARAM, LPARAM)
return 0;
}
-void RefreshGroups(void)
-{
- if (CGroupEditDlg::pDlg != nullptr)
- CGroupEditDlg::pDlg->RefreshGroups();
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
INT_PTR CIcqProto::GetEmailCount(WPARAM, LPARAM)