summaryrefslogtreecommitdiff
path: root/src/mir_app
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 /src/mir_app
parent810ed4dea67b54a18f6ec3f5273d2f8efe08708c (diff)
manual access to CList/Group restricted
Diffstat (limited to 'src/mir_app')
-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
9 files changed, 37 insertions, 21 deletions
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;