summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-06-27 21:23:35 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-06-27 21:23:35 +0300
commit44525f461757fc859616fda16820351b07238842 (patch)
tree117ad05514eed381fc13dcf8befcf0ff06023e57
parent810ed4dea67b54a18f6ec3f5273d2f8efe08708c (diff)
manual access to CList/Group restricted
-rw-r--r--include/m_clist.h11
-rw-r--r--libs/win32/mir_app.libbin191642 -> 192070 bytes
-rw-r--r--libs/win64/mir_app.libbin187504 -> 187896 bytes
-rw-r--r--plugins/Clist_modern/src/modern_clcitems.cpp4
-rw-r--r--plugins/Clist_nicer/src/clcitems.cpp4
-rw-r--r--plugins/MirandaG15/src/CAppletManager.cpp20
-rw-r--r--plugins/NewXstatusNotify/src/popup.cpp4
-rw-r--r--plugins/QuickContacts/src/dialog.cpp10
-rw-r--r--plugins/SeenPlugin/src/utils.cpp12
-rwxr-xr-xplugins/StopSpamMod/src/stopspam.cpp6
-rw-r--r--plugins/StopSpamPlus/src/services.cpp2
-rw-r--r--plugins/TabSRMM/src/utils.cpp2
-rw-r--r--plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp2
-rw-r--r--plugins/Variables/src/contact.cpp2
-rw-r--r--protocols/Discord/src/guilds.cpp4
-rw-r--r--protocols/Discord/src/proto.cpp2
-rw-r--r--protocols/Discord/src/utils.cpp2
-rw-r--r--protocols/FacebookRM/src/contacts.cpp3
-rw-r--r--protocols/Gadu-Gadu/src/import.cpp2
-rw-r--r--protocols/ICQ-WIM/src/poll.cpp11
-rw-r--r--protocols/ICQ-WIM/src/proto.cpp7
-rw-r--r--protocols/JabberG/src/jabber_events.cpp2
-rw-r--r--protocols/NewsAggregator/Src/Options.cpp4
-rw-r--r--protocols/Non-IM Contact/src/contactinfo.cpp11
-rw-r--r--protocols/SkypeWeb/src/skype_contacts.cpp2
-rw-r--r--protocols/Steam/src/steam_contacts.cpp3
-rw-r--r--protocols/Tox/src/tox_contacts.cpp3
-rw-r--r--protocols/Twitter/src/contacts.cpp5
-rw-r--r--protocols/VKontakte/src/misc.cpp2
-rw-r--r--src/mir_app/src/addcontact.cpp2
-rw-r--r--src/mir_app/src/chat_clist.cpp10
-rw-r--r--src/mir_app/src/clcitems.cpp6
-rw-r--r--src/mir_app/src/clistgroups.cpp28
-rw-r--r--src/mir_app/src/clistsettings.cpp2
-rw-r--r--src/mir_app/src/meta_menu.cpp4
-rw-r--r--src/mir_app/src/mir_app.def2
-rw-r--r--src/mir_app/src/mir_app64.def2
-rw-r--r--src/mir_app/src/movetogroup.cpp2
38 files changed, 106 insertions, 94 deletions
diff --git a/include/m_clist.h b/include/m_clist.h
index 37751dc3fa..47a64f7c79 100644
--- a/include/m_clist.h
+++ b/include/m_clist.h
@@ -460,6 +460,17 @@ EXTERN_C MIR_APP_DLL(int) Clist_GroupMoveBefore(MGROUP hGroup, MGROUP hGroupBefo
EXTERN_C MIR_APP_DLL(HMENU) Clist_GroupBuildMenu(void);
/////////////////////////////////////////////////////////////////////////////////////////
+// gets group name for a contact
+// might return NULL if a group isn't set
+
+EXTERN_C MIR_APP_DLL(wchar_t*) Clist_GetGroup(MCONTACT hContact);
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// sets group name for a contact
+
+EXTERN_C MIR_APP_DLL(void) Clist_SetGroup(MCONTACT hContact, const wchar_t *pwszName);
+
+/////////////////////////////////////////////////////////////////////////////////////////
// end a rebuild of the contact list
EXTERN_C MIR_APP_DLL(void) Clist_EndRebuild(void);
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib
index 0d8746bb48..d496b1bb43 100644
--- a/libs/win32/mir_app.lib
+++ b/libs/win32/mir_app.lib
Binary files differ
diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib
index 01b061bd23..a5abd82c62 100644
--- a/libs/win64/mir_app.lib
+++ b/libs/win64/mir_app.lib
Binary files differ
diff --git a/plugins/Clist_modern/src/modern_clcitems.cpp b/plugins/Clist_modern/src/modern_clcitems.cpp
index 9fd277cb48..d9e9c35246 100644
--- a/plugins/Clist_modern/src/modern_clcitems.cpp
+++ b/plugins/Clist_modern/src/modern_clcitems.cpp
@@ -446,10 +446,10 @@ int CLVM_GetContactHiddenStatus(MCONTACT hContact, char *szProto, ClcData *dat)
}
if (g_CluiData.bFilterEffective & CLVM_FILTER_GROUPS) {
- ptrW tszGroup(g_plugin.getWStringA(hContact, "Group"));
+ ptrW tszGroup(Clist_GetGroup(hContact));
if (tszGroup != nullptr) {
wchar_t szGroupMask[256];
- mir_snwprintf(szGroupMask, L"%s|", tszGroup);
+ mir_snwprintf(szGroupMask, L"%s|", tszGroup.get());
filterResult = (g_CluiData.filterFlags & CLVM_PROTOGROUP_OP) ? (filterResult | (wcsstr(g_CluiData.groupFilter, szGroupMask) ? 1 : 0)) : (filterResult & (wcsstr(g_CluiData.groupFilter, szGroupMask) ? 1 : 0));
}
else if (g_CluiData.filterFlags & CLVM_INCLUDED_UNGROUPED)
diff --git a/plugins/Clist_nicer/src/clcitems.cpp b/plugins/Clist_nicer/src/clcitems.cpp
index 87255a4556..023ba9a40d 100644
--- a/plugins/Clist_nicer/src/clcitems.cpp
+++ b/plugins/Clist_nicer/src/clcitems.cpp
@@ -405,10 +405,10 @@ int CLVM_GetContactHiddenStatus(MCONTACT hContact, char *szProto, struct ClcData
}
if (cfg::dat.bFilterEffective & CLVM_FILTER_GROUPS) {
- ptrW tszGroup(g_plugin.getWStringA(hContact, "Group"));
+ ptrW tszGroup(Clist_GetGroup(hContact));
if (tszGroup != NULL) {
wchar_t szGroupMask[256];
- mir_snwprintf(szGroupMask, L"%s|", tszGroup);
+ mir_snwprintf(szGroupMask, L"%s|", tszGroup.get());
int bHasGroup = wcsstr(cfg::dat.groupFilter, szGroupMask) ? 1 : 0;
filterResult = (cfg::dat.filterFlags & CLVM_PROTOGROUP_OP) ? (filterResult | bHasGroup) : (filterResult & bHasGroup);
}
diff --git a/plugins/MirandaG15/src/CAppletManager.cpp b/plugins/MirandaG15/src/CAppletManager.cpp
index 3534f2ea7f..8c88700675 100644
--- a/plugins/MirandaG15/src/CAppletManager.cpp
+++ b/plugins/MirandaG15/src/CAppletManager.cpp
@@ -441,15 +441,8 @@ tstring CAppletManager::GetContactDisplayname(MCONTACT hContact, bool bShortened
//************************************************************************
tstring CAppletManager::GetContactGroup(MCONTACT hContact)
{
- DBVARIANT dbv;
- int res = db_get_ws(hContact, "CList", "Group", &dbv);
-
- tstring strGroup = L"";
- if (!res)
- strGroup = dbv.pwszVal;
-
- db_free(&dbv);
- return strGroup;
+ ptrW wszGroup(Clist_GetGroup(hContact));
+ return (wszGroup) ? wszGroup : L"";
}
//************************************************************************
@@ -1654,11 +1647,10 @@ int CAppletManager::HookSettingChanged(WPARAM hContact, LPARAM lParam)
}
else if (!strcmp(dbcws->szSetting, "Group")) {
Event.eType = EVENT_CONTACT_GROUP;
- DBVARIANT dbv;
- int res = db_get_ws(hContact, "CList", "Group", &dbv);
- if (!res)
- Event.strValue = dbv.pwszVal;
- db_free(&dbv);
+
+ ptrW wszGroup(Clist_GetGroup(hContact));
+ if (wszGroup)
+ Event.strValue = wszGroup;
}
else return 0;
}
diff --git a/plugins/NewXstatusNotify/src/popup.cpp b/plugins/NewXstatusNotify/src/popup.cpp
index db5724b5c6..f34743fc1e 100644
--- a/plugins/NewXstatusNotify/src/popup.cpp
+++ b/plugins/NewXstatusNotify/src/popup.cpp
@@ -30,9 +30,9 @@ void ShowChangePopup(MCONTACT hContact, HICON hIcon, WORD newStatus, const wchar
// add group name to popup title
if (opt.ShowGroup) {
- ptrW tszGroup(db_get_wsa(hContact, "CList", "Group"));
+ ptrW tszGroup(Clist_GetGroup(hContact));
if (tszGroup)
- buf.AppendFormat(L" (%s)", tszGroup);
+ buf.AppendFormat(L" (%s)", tszGroup.get());
}
wcsncpy_s(ppd.lpwzContactName, buf, _TRUNCATE);
wcsncpy_s(ppd.lpwzText, stzText, _TRUNCATE);
diff --git a/plugins/QuickContacts/src/dialog.cpp b/plugins/QuickContacts/src/dialog.cpp
index c0f386018a..36e198c813 100644
--- a/plugins/QuickContacts/src/dialog.cpp
+++ b/plugins/QuickContacts/src/dialog.cpp
@@ -190,13 +190,9 @@ void LoadContacts(HWND hwndDlg, BOOL show_all)
c_struct *contact = new c_struct();
if (opts.group_append) {
- DBVARIANT dbv;
- if (db_get_ws(hMeta == NULL ? hContact : hMeta, "CList", "Group", &dbv) == 0) {
- if (dbv.pwszVal != nullptr)
- mir_wstrncpy(contact->szgroup, dbv.pwszVal, _countof(contact->szgroup));
-
- db_free(&dbv);
- }
+ ptrW wszGroup(Clist_GetGroup(hMeta == NULL ? hContact : hMeta));
+ if (wszGroup)
+ wcsncpy_s(contact->szgroup, wszGroup, _TRUNCATE);
}
// Make contact name
diff --git a/plugins/SeenPlugin/src/utils.cpp b/plugins/SeenPlugin/src/utils.cpp
index 27c20abc76..a5ccd6ef54 100644
--- a/plugins/SeenPlugin/src/utils.cpp
+++ b/plugins/SeenPlugin/src/utils.cpp
@@ -272,11 +272,13 @@ wchar_t* ParseString(wchar_t *szstring, MCONTACT hcontact)
goto LBL_noData;
case 'G':
- if (!db_get_ws(hcontact, "CList", "Group", &dbv)) {
- wcsncpy(szdbsetting, dbv.pwszVal, _countof(szdbsetting));
- db_free(&dbv);
- charPtr = szdbsetting;
- goto LBL_charPtr;
+ {
+ ptrW wszGroup(Clist_GetGroup(hcontact));
+ if (wszGroup) {
+ wcsncpy_s(szdbsetting, wszGroup, _TRUNCATE);
+ charPtr = szdbsetting;
+ goto LBL_charPtr;
+ }
}
break;
diff --git a/plugins/StopSpamMod/src/stopspam.cpp b/plugins/StopSpamMod/src/stopspam.cpp
index c9b460211c..b3035150e4 100755
--- a/plugins/StopSpamMod/src/stopspam.cpp
+++ b/plugins/StopSpamMod/src/stopspam.cpp
@@ -46,7 +46,7 @@ int OnDbEventAdded(WPARAM hContact, LPARAM hDbEvent)
if (gbHideContacts)
db_set_b(hcntct, "CList", "Hidden", 1);
if (gbSpecialGroup)
- db_set_ws(hcntct, "CList", "Group", gbSpammersGroup.c_str());
+ Clist_SetGroup(hcntct, gbSpammersGroup.c_str());
BYTE msg = 1;
if (gbIgnoreURL) {
wchar_t* EventText = ReqGetText(&dbei); //else return NULL
@@ -183,7 +183,7 @@ int OnDbEventFilterAdd(WPARAM hContact, LPARAM l)
CallProtoService(dbei->szModule, "/GrantAuth", hContact, 0);
// add contact to server list and local group
if (gbAutoAddToServerList) {
- db_set_ws(hContact, "CList", "Group", gbAutoAuthGroup.c_str());
+ Clist_SetGroup(hContact, gbAutoAuthGroup.c_str());
db_unset(hContact, "CList", "NotOnList");
}
@@ -272,7 +272,7 @@ int OnDbEventFilterAdd(WPARAM hContact, LPARAM l)
if (gbHideContacts)
db_set_b(hContact, "CList", "Hidden", 1);
if (gbSpecialGroup)
- db_set_ws(hContact, "CList", "Group", gbSpammersGroup.c_str());
+ Clist_SetGroup(hContact, gbSpammersGroup.c_str());
db_set_b(hContact, "CList", "NotOnList", 1);
// save first message from contact
diff --git a/plugins/StopSpamPlus/src/services.cpp b/plugins/StopSpamPlus/src/services.cpp
index 0c640fee6a..05fd78bc3d 100644
--- a/plugins/StopSpamPlus/src/services.cpp
+++ b/plugins/StopSpamPlus/src/services.cpp
@@ -25,7 +25,7 @@ INT_PTR RemoveTempContacts(WPARAM, LPARAM lParam)
{
for (MCONTACT hContact = db_find_first(); hContact;) {
MCONTACT hNext = db_find_next(hContact);
- ptrW szGroup(db_get_wsa(hContact, "CList", "Group"));
+ ptrW szGroup(Clist_GetGroup(hContact));
if (db_get_b(hContact, "CList", "NotOnList", 0) || (szGroup != NULL && (wcsstr(szGroup, L"Not In List") || wcsstr(szGroup, TranslateT("Not In List"))))) {
char *szProto = GetContactProto(hContact);
diff --git a/plugins/TabSRMM/src/utils.cpp b/plugins/TabSRMM/src/utils.cpp
index 3311f2272f..1304d29ec7 100644
--- a/plugins/TabSRMM/src/utils.cpp
+++ b/plugins/TabSRMM/src/utils.cpp
@@ -294,7 +294,7 @@ bool CTabBaseDlg::FormatTitleBar(const wchar_t *szFormat, CMStringW &dest)
case 'g':
{
- ptrW tszGroup(db_get_wsa(m_hContact, "CList", "Group"));
+ ptrW tszGroup(Clist_GetGroup(m_hContact));
if (tszGroup != nullptr)
dest.Append(tszGroup);
}
diff --git a/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp b/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp
index 717203bab7..36896aa558 100644
--- a/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp
+++ b/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp
@@ -257,7 +257,7 @@ MCONTACT CExImContactBase::toDB()
// add group
if (_pszGroup) {
ptrW ptszGroup(mir_utf8decodeW(_pszGroup));
- db_set_ws(_hContact, MOD_CLIST, "Group", ptszGroup);
+ Clist_SetGroup(_hContact, ptszGroup);
Clist_GroupCreate(NULL, ptszGroup);
}
}
diff --git a/plugins/Variables/src/contact.cpp b/plugins/Variables/src/contact.cpp
index 411df6581b..8c8144a665 100644
--- a/plugins/Variables/src/contact.cpp
+++ b/plugins/Variables/src/contact.cpp
@@ -150,7 +150,7 @@ wchar_t* getContactInfoT(BYTE type, MCONTACT hContact)
return nullptr;
case CCNF_GROUP:
- if ((res = db_get_wsa(hContact, "CList", "Group")) != nullptr)
+ if ((res = Clist_GetGroup(hContact)) != nullptr)
return res;
break;
diff --git a/protocols/Discord/src/guilds.cpp b/protocols/Discord/src/guilds.cpp
index 7b48b87e90..b2d6e85b11 100644
--- a/protocols/Discord/src/guilds.cpp
+++ b/protocols/Discord/src/guilds.cpp
@@ -75,14 +75,14 @@ void CDiscordProto::ProcessRole(CDiscordGuild *guild, const JSONNode &role)
static void sttSetGroupName(MCONTACT hContact, const wchar_t *pwszGroupName)
{
- ptrW wszOldName(db_get_wsa(hContact, "CList", "Group"));
+ ptrW wszOldName(Clist_GetGroup(hContact));
if (wszOldName != nullptr) {
ptrW wszChatGroup(Chat_GetGroup());
if (mir_wstrcmpi(wszOldName, wszChatGroup))
return; // custom group, don't touch it
}
- db_set_ws(hContact, "CList", "Group", pwszGroupName);
+ Clist_SetGroup(hContact, pwszGroupName);
}
void CDiscordProto::BatchChatCreate(void *param)
diff --git a/protocols/Discord/src/proto.cpp b/protocols/Discord/src/proto.cpp
index 0526883730..b3388a3268 100644
--- a/protocols/Discord/src/proto.cpp
+++ b/protocols/Discord/src/proto.cpp
@@ -355,7 +355,7 @@ MCONTACT CDiscordProto::AddToList(int flags, PROTOSEARCHRESULT *psr)
setId(hContact, DB_KEY_ID, pUser->id);
}
- db_set_ws(hContact, "CList", "Group", m_wszDefaultGroup);
+ Clist_SetGroup(hContact, m_wszDefaultGroup);
setWString(hContact, DB_KEY_NICK, pUser->wszUsername);
setDword(hContact, DB_KEY_DISCR, pUser->iDiscriminator);
arUsers.insert(pUser);
diff --git a/protocols/Discord/src/utils.cpp b/protocols/Discord/src/utils.cpp
index 8735b2bffe..95a7b098c3 100644
--- a/protocols/Discord/src/utils.cpp
+++ b/protocols/Discord/src/utils.cpp
@@ -165,7 +165,7 @@ CDiscordUser* CDiscordProto::PrepareUser(const JSONNode &user)
MCONTACT hContact = db_add_contact();
Proto_AddToContact(hContact, m_szModuleName);
- db_set_ws(hContact, "CList", "Group", m_wszDefaultGroup);
+ Clist_SetGroup(hContact, m_wszDefaultGroup);
setId(hContact, DB_KEY_ID, id);
setWString(hContact, DB_KEY_NICK, username);
setDword(hContact, DB_KEY_DISCR, iDiscriminator);
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp
index 30271d8bb0..74f73fae43 100644
--- a/protocols/FacebookRM/src/contacts.cpp
+++ b/protocols/FacebookRM/src/contacts.cpp
@@ -246,8 +246,7 @@ MCONTACT FacebookProto::AddToContactList(facebook_user* fbu, bool force_add, boo
db_unset(hContact, "CList", "MyHandle");
- if (m_tszDefaultGroup)
- db_set_ws(hContact, "CList", "Group", m_tszDefaultGroup);
+ Clist_SetGroup(hContact, m_tszDefaultGroup);
setByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, fbu->type);
diff --git a/protocols/Gadu-Gadu/src/import.cpp b/protocols/Gadu-Gadu/src/import.cpp
index 8c8a73128f..f8e93fd33f 100644
--- a/protocols/Gadu-Gadu/src/import.cpp
+++ b/protocols/Gadu-Gadu/src/import.cpp
@@ -228,7 +228,7 @@ void GaduProto::parsecontacts(char *contacts)
if (hContact && strGroup) {
ptrW tszGrpName(mir_a2u(strGroup));
Clist_GroupCreate(0, tszGrpName);
- db_set_ws(hContact, "CList", "Group", tszGrpName);
+ Clist_SetGroup(hContact, tszGrpName);
}
// Write misc data
diff --git a/protocols/ICQ-WIM/src/poll.cpp b/protocols/ICQ-WIM/src/poll.cpp
index 0f53a249fd..2c8fead4ea 100644
--- a/protocols/ICQ-WIM/src/poll.cpp
+++ b/protocols/ICQ-WIM/src/poll.cpp
@@ -37,17 +37,17 @@ void CIcqProto::ProcessBuddyList(const JSONNode &ev)
setWString(hContact, "IcqGroup", szGroup);
- CMStringW mirGroup(db_get_sm(hContact, "CList", "Group"));
+ ptrW mirGroup(Clist_GetGroup(hContact));
if (mirGroup != szGroup)
bEnableMenu = true;
- if (mirGroup.IsEmpty()) {
+ if (mirGroup) {
if (!bCreated) {
Clist_GroupCreate(0, szGroup);
bCreated = true;
}
- db_set_ws(hContact, "CList", "Group", szGroup);
+ Clist_SetGroup(hContact, szGroup);
}
}
}
@@ -81,13 +81,14 @@ void CIcqProto::ProcessDiff(const JSONNode &ev)
setWString(hContact, "IcqGroup", szGroup);
- if (db_get_sm(hContact, "CList", "Group").IsEmpty()) {
+ ptrW wszGroup(Clist_GetGroup(hContact));
+ if (!wszGroup) {
if (!bCreated) {
Clist_GroupCreate(0, szGroup);
bCreated = true;
}
- db_set_ws(hContact, "CList", "Group", szGroup);
+ Clist_SetGroup(hContact, szGroup);
}
}
}
diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp
index 49e5c4fb93..87dd35189a 100644
--- a/protocols/ICQ-WIM/src/proto.cpp
+++ b/protocols/ICQ-WIM/src/proto.cpp
@@ -169,9 +169,10 @@ INT_PTR CIcqProto::UploadGroups(WPARAM, LPARAM)
if (isChatRoom(it))
continue;
- CMStringW wszIcqGroup(getMStringW(it, "IcqGroup")), wszMirGroup(db_get_wsm(it, "CList", "Group"));
- if (wszMirGroup.IsEmpty())
- wszMirGroup = L"General";
+ CMStringW wszIcqGroup(getMStringW(it, "IcqGroup"));
+ ptrW wszMirGroup(Clist_GetGroup(it));
+ if (!wszMirGroup)
+ wszMirGroup = mir_wstrdup(L"General");
if (wszIcqGroup != wszMirGroup)
MoveContactToGroup(it, wszIcqGroup, wszMirGroup);
}
diff --git a/protocols/JabberG/src/jabber_events.cpp b/protocols/JabberG/src/jabber_events.cpp
index 325de81a36..5e0751fb10 100644
--- a/protocols/JabberG/src/jabber_events.cpp
+++ b/protocols/JabberG/src/jabber_events.cpp
@@ -141,7 +141,7 @@ void __cdecl CJabberProto::OnAddContactForever(MCONTACT hContact)
if (nick == nullptr)
return;
- AddContactToRoster(jid, nick, ptrA(db_get_utfa(hContact, "CList", "Group")));
+ AddContactToRoster(jid, nick, T2Utf(ptrW(Clist_GetGroup(hContact))));
XmlNode xPresence("presence"); xPresence << XATTR("to", jid) << XATTR("type", "subscribe");
ptrA myNick(getUStringA(0, "Nick"));
diff --git a/protocols/NewsAggregator/Src/Options.cpp b/protocols/NewsAggregator/Src/Options.cpp
index 6239ce15c1..986051a6bf 100644
--- a/protocols/NewsAggregator/Src/Options.cpp
+++ b/protocols/NewsAggregator/Src/Options.cpp
@@ -229,7 +229,7 @@ void CExportFeed::OnOk(CCtrlBase*)
*title = g_plugin.getWStringA(hContact, "Nick"),
*url = g_plugin.getWStringA(hContact, "URL"),
*siteurl = g_plugin.getWStringA(hContact, "Homepage"),
- *group = db_get_wsa(hContact, "CList", "Group");
+ *group = Clist_GetGroup(hContact);
TiXmlElement *elem = xmlBody;
if (group) {
@@ -579,8 +579,8 @@ void CImportFeed::OnOk(CCtrlBase*)
}
if (!wszGroup.IsEmpty()) {
- db_set_ws(hContact, "CList", "Group", wszGroup);
Clist_GroupCreate(0, wszGroup);
+ Clist_SetGroup(hContact, wszGroup);
}
}
mir_free(text);
diff --git a/protocols/Non-IM Contact/src/contactinfo.cpp b/protocols/Non-IM Contact/src/contactinfo.cpp
index 00c718fad2..38a6312728 100644
--- a/protocols/Non-IM Contact/src/contactinfo.cpp
+++ b/protocols/Non-IM Contact/src/contactinfo.cpp
@@ -135,10 +135,9 @@ INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
for (int i = 1; (szGroup = Clist_GroupGetName(i, nullptr)) != nullptr; i++)
SendDlgItemMessage(hwnd, IDC_GROUP, CB_INSERTSTRING, 0, LPARAM(szGroup));
- if (!db_get_ws(hContact, "CList", "Group", &dbv)) {
- SetDlgItemText(hwnd, IDC_GROUP, dbv.pwszVal);
- db_free(&dbv);
- }
+ ptrW wszGroup(Clist_GetGroup(hContact));
+ if (wszGroup)
+ SetDlgItemTextW(hwnd, IDC_GROUP, wszGroup);
/* icons */
CheckRadioButton(hwnd, 40072, 40077, g_plugin.getWord(hContact, "Icon", ID_STATUS_ONLINE));
@@ -237,9 +236,9 @@ INT_PTR CALLBACK DlgProcOtherStuff(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP
wchar_t text[512];
GetDlgItemText(hwnd, IDC_GROUP, text, _countof(text));
Clist_GroupCreate(NULL, text);
- db_set_ws(hContact, "CList", "Group", text);
+ Clist_SetGroup(hContact, text);
}
- else db_unset(hContact, "CList", "Group");
+ else Clist_SetGroup(hContact, nullptr);
for (int i = ID_STATUS_ONLINE; i <= ID_STATUS_MAX; i++)
if (IsDlgButtonChecked(hwnd, i))
diff --git a/protocols/SkypeWeb/src/skype_contacts.cpp b/protocols/SkypeWeb/src/skype_contacts.cpp
index 7ed1b5991d..93b938e1e6 100644
--- a/protocols/SkypeWeb/src/skype_contacts.cpp
+++ b/protocols/SkypeWeb/src/skype_contacts.cpp
@@ -78,7 +78,7 @@ MCONTACT CSkypeProto::AddContact(const char *skypename, bool isTemporary)
if (m_opts.wstrCListGroup) {
Clist_GroupCreate(0, m_opts.wstrCListGroup);
- db_set_ws(hContact, "CList", "Group", m_opts.wstrCListGroup);
+ Clist_SetGroup(hContact, m_opts.wstrCListGroup);
}
setByte(hContact, "Auth", 1);
diff --git a/protocols/Steam/src/steam_contacts.cpp b/protocols/Steam/src/steam_contacts.cpp
index f9264b7b7b..9552ee3485 100644
--- a/protocols/Steam/src/steam_contacts.cpp
+++ b/protocols/Steam/src/steam_contacts.cpp
@@ -362,8 +362,7 @@ MCONTACT CSteamProto::AddContact(const char *steamId, const wchar_t *nick, bool
//setByte(hContact, "Grant", 1);
// move to default group
- if (m_defaultGroup)
- db_set_ws(hContact, "CList", "Group", m_defaultGroup);
+ Clist_SetGroup(hContact, m_defaultGroup);
return hContact;
}
diff --git a/protocols/Tox/src/tox_contacts.cpp b/protocols/Tox/src/tox_contacts.cpp
index 082c6c9019..ea388e0748 100644
--- a/protocols/Tox/src/tox_contacts.cpp
+++ b/protocols/Tox/src/tox_contacts.cpp
@@ -92,8 +92,7 @@ MCONTACT CToxProto::AddContact(const char *address, const wchar_t *nick, const w
setWString(hContact, TOX_SETTINGS_DNS, dnsId);
if (!isTemporary) {
- if (m_defaultGroup)
- db_set_ws(hContact, "CList", "Group", m_defaultGroup);
+ Clist_SetGroup(hContact, m_defaultGroup);
setByte(hContact, "Auth", 1);
setByte(hContact, "Grant", 1);
diff --git a/protocols/Twitter/src/contacts.cpp b/protocols/Twitter/src/contacts.cpp
index 7f22e8e700..caed5ebeb9 100644
--- a/protocols/Twitter/src/contacts.cpp
+++ b/protocols/Twitter/src/contacts.cpp
@@ -245,10 +245,7 @@ MCONTACT TwitterProto::AddToClientList(const char *name, const char *status)
db_set_utf(hContact, "CList", "StatusMsg", status);
Skin_PlaySound("TwitterNewContact");
- ptrW wszGroup(getWStringA(TWITTER_KEY_GROUP));
- if (wszGroup)
- db_set_ws(hContact, "CList", "Group", wszGroup);
-
+ Clist_SetGroup(hContact, getMStringW(TWITTER_KEY_GROUP));
return hContact;
}
db_delete_contact(hContact);
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index 4765e129a3..18b19121df 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -183,7 +183,7 @@ MCONTACT CVkProto::FindUser(LONG dwUserid, bool bCreate)
MCONTACT hNewContact = db_add_contact();
Proto_AddToContact(hNewContact, m_szModuleName);
setDword(hNewContact, "ID", dwUserid);
- db_set_ws(hNewContact, "CList", "Group", m_vkOptions.pwszDefaultGroup);
+ Clist_SetGroup(hNewContact, m_vkOptions.pwszDefaultGroup);
if (dwUserid < 0)
setByte(hNewContact, "IsGroup", 1);
return hNewContact;
diff --git a/src/mir_app/src/addcontact.cpp b/src/mir_app/src/addcontact.cpp
index a2c80accc2..4d89422941 100644
--- a/src/mir_app/src/addcontact.cpp
+++ b/src/mir_app/src/addcontact.cpp
@@ -74,7 +74,7 @@ public:
SetCaption(TranslateT("Add contact"));
int groupSel = 0;
- ptrW tszGroup(db_get_wsa(m_hContact, "CList", "Group"));
+ ptrW tszGroup(Clist_GetGroup(m_hContact));
wchar_t *grpName;
for (int groupId = 1; (grpName = Clist_GroupGetName(groupId, nullptr)) != nullptr; groupId++) {
int id = m_group.AddString(grpName, groupId);
diff --git a/src/mir_app/src/chat_clist.cpp b/src/mir_app/src/chat_clist.cpp
index 3a40052fc0..cbfa2c6118 100644
--- a/src/mir_app/src/chat_clist.cpp
+++ b/src/mir_app/src/chat_clist.cpp
@@ -37,9 +37,9 @@ MCONTACT AddRoom(const char *pszModule, const wchar_t *pszRoom, const wchar_t *p
MCONTACT hContact = g_chatApi.FindRoom(pszModule, pszRoom);
if (hContact) { // contact exist, make sure it is in the right group
if (mir_wstrlen(wszGroup)) {
- ptrW grpName(db_get_wsa(hContact, "CList", "Group"));
+ ptrW grpName(Clist_GetGroup(hContact));
if (!mir_wstrcmp(wszGroup, grpName))
- db_set_ws(hContact, "CList", "Group", wszGroup);
+ Clist_SetGroup(hContact, wszGroup);
}
db_set_w(hContact, pszModule, "Status", ID_STATUS_OFFLINE);
@@ -52,10 +52,8 @@ MCONTACT AddRoom(const char *pszModule, const wchar_t *pszRoom, const wchar_t *p
return 0;
Proto_AddToContact(hContact, pszModule);
- if (mir_wstrlen(wszGroup))
- db_set_ws(hContact, "CList", "Group", wszGroup);
- else
- db_unset(hContact, "CList", "Group");
+ Clist_SetGroup(hContact, wszGroup);
+
db_set_ws(hContact, pszModule, "Nick", pszDisplayName);
db_set_ws(hContact, pszModule, "ChatRoomID", pszRoom);
db_set_b(hContact, pszModule, "ChatRoom", (BYTE)iType);
diff --git a/src/mir_app/src/clcitems.cpp b/src/mir_app/src/clcitems.cpp
index 72df88ccc5..006b36d6ae 100644
--- a/src/mir_app/src/clcitems.cpp
+++ b/src/mir_app/src/clcitems.cpp
@@ -224,7 +224,7 @@ void fnAddContactToTree(HWND hwnd, ClcData *dat, MCONTACT hContact, int updateTo
int i;
DWORD groupFlags;
ClcGroup *group;
- ptrW tszGroup(db_get_wsa(hContact, "CList", "Group"));
+ ptrW tszGroup(Clist_GetGroup(hContact));
if (tszGroup == nullptr)
group = &dat->list;
else {
@@ -315,7 +315,7 @@ MIR_APP_DLL(void) Clist_DeleteItemFromTree(HWND hwnd, MCONTACT hItem)
if (!IsHContactContact(hItem))
return;
- ptrW wszGroup(db_get_wsa(hItem, "CList", "Group"));
+ ptrW wszGroup(Clist_GetGroup(hItem));
if (wszGroup == nullptr)
return;
@@ -369,7 +369,7 @@ void fnRebuildEntireList(HWND hwnd, ClcData *dat)
continue;
ClcGroup *group;
- ptrW tszGroupName(db_get_wsa(hContact, "CList", "Group"));
+ ptrW tszGroupName(Clist_GetGroup(hContact));
if (tszGroupName == nullptr)
group = &dat->list;
else {
diff --git a/src/mir_app/src/clistgroups.cpp b/src/mir_app/src/clistgroups.cpp
index 8ef54a46b6..e3d7163257 100644
--- a/src/mir_app/src/clistgroups.cpp
+++ b/src/mir_app/src/clistgroups.cpp
@@ -216,17 +216,15 @@ MIR_APP_DLL(int) Clist_GroupDelete(MGROUP hGroup)
}
for (auto &hContact : Contacts()) {
- ptrW tszGroupName(db_get_wsa(hContact, "CList", "Group"));
+ ptrW tszGroupName(Clist_GetGroup(hContact));
if (!tszGroupName || !isParentOf(wszOldName, tszGroupName))
continue;
+ Clist_SetGroup(hContact, wszNewParent);
+
CLISTGROUPCHANGE grpChg = { wszOldName, 0 };
- if (!wszNewParent.IsEmpty()) {
- db_set_ws(hContact, "CList", "Group", wszNewParent);
+ if (!wszNewParent.IsEmpty())
grpChg.pszNewName = wszNewParent;
- }
- else db_unset(hContact, "CList", "Group");
-
NotifyEventHooks(hGroupChangeEvent, hContact, (LPARAM)&grpChg);
}
@@ -350,7 +348,7 @@ static int RenameGroupWithMove(int groupId, const wchar_t *szName, int move)
for (auto &hContact : Contacts()) {
ClcCacheEntry *cache = Clist_GetCacheEntry(hContact);
if (!mir_wstrcmp(cache->tszGroup, oldName)) {
- db_set_ws(hContact, "CList", "Group", szName);
+ Clist_SetGroup(hContact, szName);
replaceStrW(cache->tszGroup, szName);
}
}
@@ -432,6 +430,22 @@ MIR_APP_DLL(int) Clist_GroupSetFlags(MGROUP hGroup, LPARAM iNewFlags)
/////////////////////////////////////////////////////////////////////////////////////////
+MIR_APP_DLL(wchar_t*) Clist_GetGroup(MCONTACT hContact)
+{
+ ptrW wszName(db_get_wsa(hContact, "CList", "Group"));
+ return (mir_wstrlen(wszName)) ? wszName.detach() : nullptr;
+}
+
+MIR_APP_DLL(void) Clist_SetGroup(MCONTACT hContact, const wchar_t *pwszName)
+{
+ if (mir_wstrlen(pwszName))
+ db_set_ws(hContact, "CList", "Group", pwszName);
+ else
+ db_unset(hContact, "CList", "Group");
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
MIR_APP_DLL(HMENU) Clist_GroupBuildMenu()
{
if (arByIds.getCount() == 0)
diff --git a/src/mir_app/src/clistsettings.cpp b/src/mir_app/src/clistsettings.cpp
index 67040037db..9a6c18a7b2 100644
--- a/src/mir_app/src/clistsettings.cpp
+++ b/src/mir_app/src/clistsettings.cpp
@@ -63,7 +63,7 @@ ClcCacheEntry* fnCreateCacheItem(MCONTACT hContact)
void fnCheckCacheItem(ClcCacheEntry *p)
{
if (p->tszGroup == nullptr)
- p->tszGroup = db_get_wsa(p->hContact, "CList", "Group", L"");
+ p->tszGroup = Clist_GetGroup(p->hContact);
if (p->szProto == nullptr)
p->szProto = GetContactProto(p->hContact);
diff --git a/src/mir_app/src/meta_menu.cpp b/src/mir_app/src/meta_menu.cpp
index 1b9ab895e5..bdc340e79d 100644
--- a/src/mir_app/src/meta_menu.cpp
+++ b/src/mir_app/src/meta_menu.cpp
@@ -49,7 +49,7 @@ static HGENMENU
INT_PTR Meta_Convert(WPARAM wParam, LPARAM)
{
- ptrW tszGroup(db_get_wsa(wParam, "CList", "Group"));
+ ptrW tszGroup(Clist_GetGroup(wParam));
// Create a new metacontact
MCONTACT hMetaContact = db_add_contact();
@@ -68,7 +68,7 @@ INT_PTR Meta_Convert(WPARAM wParam, LPARAM)
Proto_AddToContact(hMetaContact, META_PROTO);
if (tszGroup)
- db_set_ws(hMetaContact, "CList", "Group", tszGroup);
+ Clist_SetGroup(hMetaContact, tszGroup);
// Assign the contact to the MetaContact just created (and make default).
if (!Meta_Assign(wParam, hMetaContact, TRUE)) {
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index c2b15bb198..892a952925 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -682,3 +682,5 @@ Srmm_SetIconFlags @767
?addImgListIcon@CMPluginBase@@QAEHPAU_IMAGELIST@@H@Z @772 NONAME
ImageList_AddProtoIcon @773
ImageList_AddSkinIcon @774
+Clist_GetGroup @775
+Clist_SetGroup @776
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 864376d2ca..6db702af0e 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -682,3 +682,5 @@ Srmm_SetIconFlags @767
?addImgListIcon@CMPluginBase@@QEAAHPEAU_IMAGELIST@@H@Z @772 NONAME
ImageList_AddProtoIcon @773
ImageList_AddSkinIcon @774
+Clist_GetGroup @775
+Clist_SetGroup @776
diff --git a/src/mir_app/src/movetogroup.cpp b/src/mir_app/src/movetogroup.cpp
index d3ce3f24ae..f5d4a96962 100644
--- a/src/mir_app/src/movetogroup.cpp
+++ b/src/mir_app/src/movetogroup.cpp
@@ -92,7 +92,7 @@ static int OnContactMenuBuild(WPARAM wParam, LPARAM)
Menu_RemoveItem((HGENMENU)p);
lphGroupsItems.destroy();
- ptrW szContactGroup(db_get_wsa(wParam, "CList", "Group"));
+ ptrW szContactGroup(Clist_GetGroup(wParam));
int pos = 1000;