summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/m_clist.h7
-rw-r--r--libs/win32/mir_app.libbin304322 -> 304098 bytes
-rw-r--r--libs/win64/mir_app.libbin304444 -> 304238 bytes
-rw-r--r--plugins/Clist_modern/src/modern_clcmsgs.cpp13
-rw-r--r--src/mir_app/mir_app.vcxproj.filters6
-rw-r--r--src/mir_app/src/clc.cpp12
-rw-r--r--src/mir_app/src/clc.h6
-rw-r--r--src/mir_app/src/clcitems.cpp8
-rw-r--r--src/mir_app/src/clcmsgs.cpp16
-rw-r--r--src/mir_app/src/clistgroups.cpp99
-rw-r--r--src/mir_app/src/cluiservices.cpp14
-rw-r--r--src/mir_app/src/mir_app.def1
-rw-r--r--src/mir_app/src/mir_app64.def1
13 files changed, 73 insertions, 110 deletions
diff --git a/include/m_clist.h b/include/m_clist.h
index 35578c7d91..b5879d4256 100644
--- a/include/m_clist.h
+++ b/include/m_clist.h
@@ -357,13 +357,6 @@ EXTERN_C MIR_APP_DLL(MGROUP) Clist_GroupExists(LPCTSTR ptszGroupName);
EXTERN_C MIR_APP_DLL(MGROUP) Clist_GroupCreate(MGROUP hParent, const wchar_t *ptszGroupName);
/////////////////////////////////////////////////////////////////////////////////////////
-// a new group was created. Add it to the list
-// this is also called when the contact list is being rebuilt
-// new groups are always created with the name "New Group"
-
-EXTERN_C MIR_APP_DLL(void) Clist_GroupAdded(MGROUP hGroup);
-
-/////////////////////////////////////////////////////////////////////////////////////////
// deletes a group and calls CLUI to display the change
// returns 0 on success, nonzero on failure
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib
index c9b3d74fe4..d9ca86c2b9 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 d1c5d77fb0..1cc8ce2e5c 100644
--- a/libs/win64/mir_app.lib
+++ b/libs/win64/mir_app.lib
Binary files differ
diff --git a/plugins/Clist_modern/src/modern_clcmsgs.cpp b/plugins/Clist_modern/src/modern_clcmsgs.cpp
index 25fcccf9af..22bfe3805c 100644
--- a/plugins/Clist_modern/src/modern_clcmsgs.cpp
+++ b/plugins/Clist_modern/src/modern_clcmsgs.cpp
@@ -59,19 +59,6 @@ LRESULT cli_ProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wP
cliInvalidateRect(hwnd, nullptr, FALSE);
return 0;
- case CLM_SETHIDEEMPTYGROUPS:
- {
- BOOL old = ((GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_HIDEEMPTYGROUPS) != 0);
- if (wParam)
- SetWindowLongPtr(hwnd, GWL_STYLE, GetWindowLongPtr(hwnd, GWL_STYLE) | CLS_HIDEEMPTYGROUPS);
- else
- SetWindowLongPtr(hwnd, GWL_STYLE, GetWindowLongPtr(hwnd, GWL_STYLE) &~CLS_HIDEEMPTYGROUPS);
- BOOL newval = ((GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_HIDEEMPTYGROUPS) != 0);
- if (newval != old)
- Clist_InitAutoRebuild(hwnd);
- }
- return 0;
-
case CLM_SETTEXTCOLOR:
if (wParam > FONTID_MODERN_MAX) break;
diff --git a/src/mir_app/mir_app.vcxproj.filters b/src/mir_app/mir_app.vcxproj.filters
index 5586935271..4fb2f19c70 100644
--- a/src/mir_app/mir_app.vcxproj.filters
+++ b/src/mir_app/mir_app.vcxproj.filters
@@ -386,9 +386,6 @@
<ClCompile Include="src\clccontact.cpp">
<Filter>Source Files\Contact list</Filter>
</ClCompile>
- <ClCompile Include="src\clc.cpp">
- <Filter>Source Files\MetaContacts</Filter>
- </ClCompile>
<ClCompile Include="src\chat_loginfo.cpp">
<Filter>Source Files\Chats</Filter>
</ClCompile>
@@ -434,6 +431,9 @@
<ClCompile Include="src\clistcontacts.cpp">
<Filter>Source Files\Contact list</Filter>
</ClCompile>
+ <ClCompile Include="src\clc.cpp">
+ <Filter>Source Files\Contact list</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\filter.h">
diff --git a/src/mir_app/src/clc.cpp b/src/mir_app/src/clc.cpp
index 6b8fadb013..788931360d 100644
--- a/src/mir_app/src/clc.cpp
+++ b/src/mir_app/src/clc.cpp
@@ -70,6 +70,12 @@ static int ClcSettingChanged(WPARAM hContact, LPARAM lParam)
{
DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)lParam;
+ if (!strcmp(cws->szModule, GROUPS_MODULE)) {
+ if (!g_bGroupsLocked)
+ Clist_Broadcast(INTM_GROUPSCHANGED, hContact, lParam);
+ return 0;
+ }
+
if (!strcmp(cws->szModule, "CList")) {
if (!strcmp(cws->szSetting, "MyHandle")) {
g_clistApi.pfnInvalidateDisplayNameCacheEntry(hContact);
@@ -375,12 +381,10 @@ LRESULT CALLBACK fnContactListControlWndProc(HWND hwnd, UINT uMsg, WPARAM wParam
bool eq = !mir_wstrcmp(szFullName, pGroup->groupName);
if (eq && contact->group->bHideOffline == ((pGroup->flags & GROUPF_HIDEOFFLINE) != 0))
break; // only expanded has changed: no action reqd
-
- Clist_SaveStateAndRebuildList(hwnd, dat);
- break;
}
+ Clist_SaveStateAndRebuildList(hwnd, dat);
}
- Clist_InitAutoRebuild(hwnd);
+ else Clist_InitAutoRebuild(hwnd);
break;
case INTM_NAMEORDERCHANGED:
diff --git a/src/mir_app/src/clc.h b/src/mir_app/src/clc.h
index 559db8dbaa..935baed370 100644
--- a/src/mir_app/src/clc.h
+++ b/src/mir_app/src/clc.h
@@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#pragma once
#define MODULENAME "CList"
+#define GROUPS_MODULE "ClistGroups"
struct ClcContact : public ClcContactBase
{
@@ -176,9 +177,12 @@ struct CGroupInternal
CGroupInternal(int _id, const wchar_t *_name, int _flags);
~CGroupInternal();
- int groupId, oldId = -1, flags;
+ int groupId, flags;
bool bSaveExpanded;
wchar_t *groupName;
+ void remove();
void save();
};
+
+void Clist_RebuildGroups(HWND hwnd, ClcData *dat);
diff --git a/src/mir_app/src/clcitems.cpp b/src/mir_app/src/clcitems.cpp
index 2611c2a30d..df60a7ee3d 100644
--- a/src/mir_app/src/clcitems.cpp
+++ b/src/mir_app/src/clcitems.cpp
@@ -351,13 +351,7 @@ void fnRebuildEntireList(HWND hwnd, ClcData *dat)
dat->list.totalMembers = 0;
dat->selection = -1;
- for (int i = 1;; i++) {
- uint32_t groupFlags;
- wchar_t *szGroupName = Clist_GroupGetName(i, &groupFlags);
- if (szGroupName == nullptr)
- break;
- g_clistApi.pfnAddGroup(hwnd, dat, szGroupName, groupFlags, i, 0);
- }
+ Clist_RebuildGroups(hwnd, dat);
for (auto &hContact : Contacts()) {
int nHiddenStatus = g_clistApi.pfnGetContactHiddenStatus(hContact, nullptr, dat);
diff --git a/src/mir_app/src/clcmsgs.cpp b/src/mir_app/src/clcmsgs.cpp
index 70c7e209f1..23260fd237 100644
--- a/src/mir_app/src/clcmsgs.cpp
+++ b/src/mir_app/src/clcmsgs.cpp
@@ -382,11 +382,17 @@ LRESULT fnProcessExternalMessages(HWND hwnd, ClcData *dat, UINT msg, WPARAM wPar
break;
case CLM_SETHIDEEMPTYGROUPS:
- if (wParam)
- SetWindowLongPtr(hwnd, GWL_STYLE, GetWindowLongPtr(hwnd, GWL_STYLE) | CLS_HIDEEMPTYGROUPS);
- else
- SetWindowLongPtr(hwnd, GWL_STYLE, GetWindowLongPtr(hwnd, GWL_STYLE) & ~CLS_HIDEEMPTYGROUPS);
- Clist_InitAutoRebuild(hwnd);
+ {
+ BOOL oldVal = ((GetWindowLongPtr(hwnd, GWL_STYLE) & CLS_HIDEEMPTYGROUPS) != 0);
+ BOOL newVal = (wParam != 0);
+ if (newVal)
+ SetWindowLongPtr(hwnd, GWL_STYLE, GetWindowLongPtr(hwnd, GWL_STYLE) | CLS_HIDEEMPTYGROUPS);
+ else
+ SetWindowLongPtr(hwnd, GWL_STYLE, GetWindowLongPtr(hwnd, GWL_STYLE) & ~CLS_HIDEEMPTYGROUPS);
+
+ if (newVal != oldVal)
+ Clist_InitAutoRebuild(hwnd);
+ }
break;
case CLM_SETHIDEOFFLINEROOT:
diff --git a/src/mir_app/src/clistgroups.cpp b/src/mir_app/src/clistgroups.cpp
index 37219791b3..96fff9ba8f 100644
--- a/src/mir_app/src/clistgroups.cpp
+++ b/src/mir_app/src/clistgroups.cpp
@@ -25,8 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
#include "clc.h"
-#define GROUPS_MODULE "ClistGroups"
-
#define MAX_GROUPNAME_LEN 256
HANDLE hGroupChangeEvent;
@@ -52,28 +50,6 @@ static CGroupInternal* FindGroup(int key)
}
/////////////////////////////////////////////////////////////////////////////////////////
-
-static CTimer *g_pTimer;
-
-struct CGroupImpl
-{
- void OnTimer(CTimer *)
- {
- g_pTimer->Stop();
-
- for (auto &it : arByIds) {
- JSONNode grp;
- grp << INT_PARAM("id", it->groupId) << WCHAR_PARAM("name", it->groupName) << INT_PARAM("flags", it->flags);
-
- char szSetting[40];
- itoa(it->groupId, szSetting, 10);
- db_set_s(0, GROUPS_MODULE, szSetting, grp.write().c_str());
- }
- }
-}
-g_impl;
-
-/////////////////////////////////////////////////////////////////////////////////////////
// CGroupInternal members
CGroupInternal::CGroupInternal(int _id, const wchar_t *_name, int _flags) :
@@ -89,12 +65,23 @@ CGroupInternal::~CGroupInternal()
mir_free(groupName);
}
+void CGroupInternal::remove()
+{
+ char szSetting[40];
+ itoa(groupId, szSetting, 10);
+ db_unset(0, GROUPS_MODULE, szSetting);
+}
+
void CGroupInternal::save()
{
Clist_BroadcastAsync(INTM_GROUPSCHANGED, 0, LPARAM(this));
- if (g_pTimer)
- g_pTimer->Start(1000);
+ JSONNode grp;
+ grp << INT_PARAM("id", groupId) << WCHAR_PARAM("name", groupName) << INT_PARAM("flags", flags);
+
+ char szSetting[40];
+ itoa(groupId, szSetting, 10);
+ db_set_s(0, GROUPS_MODULE, szSetting, grp.write().c_str());
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -118,6 +105,28 @@ MIR_APP_DLL(MGROUP) Clist_GroupExists(LPCTSTR ptszGroupName)
/////////////////////////////////////////////////////////////////////////////////////////
+void Clist_RebuildGroups(HWND hwnd, ClcData *dat)
+{
+ for (auto &it: arByIds)
+ g_clistApi.pfnAddGroup(hwnd, dat, it->groupName, it->flags, it->groupId+1, 0);
+}
+
+void Clist_GroupAdded(MGROUP hGroup)
+{
+ // CLC does this automatically unless it's a new group
+ HWND hwndFocus = GetFocus();
+
+ wchar_t szFocusClass[64];
+ GetClassName(hwndFocus, szFocusClass, _countof(szFocusClass));
+ if (!mir_wstrcmp(szFocusClass, CLISTCONTROL_CLASSW)) {
+ HANDLE hItem = (HANDLE)SendMessage(hwndFocus, CLM_FINDGROUP, hGroup, 0);
+ if (hItem)
+ SendMessage(hwndFocus, CLM_EDITLABEL, (WPARAM)hItem, 0);
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
static INT_PTR CreateGroupInternal(MGROUP hParent, const wchar_t *ptszName)
{
wchar_t newBaseName[MAX_GROUPNAME_LEN-1], newName[MAX_GROUPNAME_LEN];
@@ -143,7 +152,7 @@ static INT_PTR CreateGroupInternal(MGROUP hParent, const wchar_t *ptszName)
mir_snwprintf(newName, L"%s (%d)", newBaseName, idCopy);
}
- int newId = arByIds.getCount();
+ int newId = arByIds.getCount() ? arByIds[arByIds.getCount() - 1]->groupId + 1 : 0;
CGroupInternal *pNew = new CGroupInternal(newId, newName, GROUPF_EXPANDED);
arByIds.insert(pNew);
arByName.insert(pNew);
@@ -244,25 +253,15 @@ MIR_APP_DLL(int) Clist_GroupDelete(MGROUP hGroup, bool bSilent)
NotifyEventHooks(hGroupChangeEvent, hContact, (LPARAM)&grpChg);
}
- // shuffle list of groups up to fill gap
- for (auto &it : arByIds)
- it->oldId = it->groupId;
-
- int iGap = 0;
- for (auto &it : arByIds.rev_iter()) {
- if (!isParentOf(wszOldName, it->groupName))
- continue;
-
- iGap++;
- arByName.remove(it);
- arByIds.removeItem(&it);
- }
-
- for (auto &it : arByIds) {
- it->groupId = arByIds.indexOf(&it);
- if (it->groupId != it->oldId)
- it->save();
- }
+ // remove all child groups
+ for (auto &it : arByIds.rev_iter())
+ if (isParentOf(wszOldName, it->groupName)) {
+ auto *p = it;
+ arByName.remove(it);
+ arByIds.removeItem(&it);
+ p->remove();
+ delete p;
+ }
SetCursor(LoadCursor(nullptr, IDC_ARROW));
Clist_LoadContactTree();
@@ -271,7 +270,6 @@ MIR_APP_DLL(int) Clist_GroupDelete(MGROUP hGroup, bool bSilent)
const CLISTGROUPCHANGE grpChg = { wszOldName, nullptr };
NotifyEventHooks(hGroupChangeEvent, 0, (LPARAM)&grpChg);
- delete pGroup;
return 0;
}
@@ -579,9 +577,6 @@ static int enumGroups(const char *szSetting, void *)
int InitGroupServices(void)
{
- g_pTimer = new CTimer(Miranda_GetSystemWindow(), UINT_PTR(&g_pTimer));
- g_pTimer->OnEvent = Callback(&g_impl, &CGroupImpl::OnTimer);
-
if (!db_get_b(0, "Compatibility", "Groups")) {
char str[32];
for (int i = 0;; i++) {
@@ -606,7 +601,6 @@ int InitGroupServices(void)
arByIds.insert(p);
arByName.insert(p);
}
- g_pTimer->Start(100);
DeleteFileW(wszJson);
}
else db_enum_settings(0, &enumGroups, GROUPS_MODULE);
@@ -618,9 +612,6 @@ int InitGroupServices(void)
void UninitGroupServices(void)
{
- g_pTimer->OnTimer();
- delete g_pTimer;
-
for (auto &p : arByIds)
delete p;
diff --git a/src/mir_app/src/cluiservices.cpp b/src/mir_app/src/cluiservices.cpp
index f4e2fee28f..9bab528b29 100644
--- a/src/mir_app/src/cluiservices.cpp
+++ b/src/mir_app/src/cluiservices.cpp
@@ -25,20 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "stdafx.h"
#include "clc.h"
-EXTERN_C MIR_APP_DLL(void) Clist_GroupAdded(MGROUP hGroup)
-{
- // CLC does this automatically unless it's a new group
- HWND hwndFocus = GetFocus();
-
- wchar_t szFocusClass[64];
- GetClassName(hwndFocus, szFocusClass, _countof(szFocusClass));
- if (!mir_wstrcmp(szFocusClass, CLISTCONTROL_CLASSW)) {
- HANDLE hItem = (HANDLE)SendMessage(hwndFocus, CLM_FINDGROUP, hGroup, 0);
- if (hItem)
- SendMessage(hwndFocus, CLM_EDITLABEL, (WPARAM)hItem, 0);
- }
-}
-
EXTERN_C MIR_APP_DLL(void) Clist_EndRebuild(void)
{
if (g_clistApi.hwndContactTree == nullptr)
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 66816d653b..af9cf10b8c 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -177,7 +177,6 @@ Clist_GroupSetFlags @256
Clist_GroupGetName @257
Clist_GroupRename @258
Clist_EndRebuild @259
-Clist_GroupAdded @260
?GetInfo@Contact@@YGPA_WHIPBD@Z @261 NONAME
Clist_ContactToHItem @262 NONAME
Clist_ContactToItemHandle @263
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 4873b014dc..7b0063123a 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -177,7 +177,6 @@ Clist_GroupSetFlags @256
Clist_GroupGetName @257
Clist_GroupRename @258
Clist_EndRebuild @259
-Clist_GroupAdded @260
?GetInfo@Contact@@YAPEA_WHIPEBD@Z @261 NONAME
Clist_ContactToHItem @262 NONAME
Clist_ContactToItemHandle @263 NONAME