1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
/*
Copyright (C) 2012-24 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)
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, "/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, "/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();
}
|