summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-03-30 16:52:28 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-03-30 16:52:28 +0300
commit64303ec8f7d8fd491247a2c06ee133e4f5f3c942 (patch)
treefd57755518819e33a7ed03c8fef389396c0d61df /src
parent1043ccf5d184151af43a417cd6e6c1a800b678dd (diff)
Contact lists:
- all common options moved to the Clist namespace; - fixes #2281 (Add option to not clear "NotOnList" group at start);
Diffstat (limited to 'src')
-rw-r--r--src/core/stdclist/res/resource.rc27
-rw-r--r--src/core/stdclist/src/clistopts.cpp29
-rw-r--r--src/core/stdclist/src/resource.h8
-rw-r--r--src/core/stdmsg/src/msgoptions.cpp2
-rw-r--r--src/mir_app/res/resource.rc22
-rw-r--r--src/mir_app/src/clc.h55
-rw-r--r--src/mir_app/src/clistgroups.cpp2
-rw-r--r--src/mir_app/src/clistmod.cpp97
-rw-r--r--src/mir_app/src/clistopts.cpp74
-rw-r--r--src/mir_app/src/clui.cpp10
-rw-r--r--src/mir_app/src/cluiservices.cpp12
-rw-r--r--src/mir_app/src/contact.cpp6
-rw-r--r--src/mir_app/src/menu_groups.cpp4
-rw-r--r--src/mir_app/src/mir_app.def4
-rw-r--r--src/mir_app/src/mir_app64.def4
-rw-r--r--src/mir_app/src/resource.h14
16 files changed, 229 insertions, 141 deletions
diff --git a/src/core/stdclist/res/resource.rc b/src/core/stdclist/res/resource.rc
index 0b367c5e78..c20cb6bfb6 100644
--- a/src/core/stdclist/res/resource.rc
+++ b/src/core/stdclist/res/resource.rc
@@ -15,13 +15,11 @@
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
-// English (U.S.) resources
+// English (United States) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
-#endif //_WIN32
/////////////////////////////////////////////////////////////////////////////
//
@@ -48,10 +46,6 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
- CONTROL "Hide offline users",IDC_HIDEOFFLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,17,124,10
- CONTROL "Hide empty groups",IDC_HIDEEMPTYGROUPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,33,124,10
- CONTROL "Disable groups",IDC_DISABLEGROUPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,50,124,10
- CONTROL "Ask before deleting contacts",IDC_CONFIRMDELETE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,67,124,10
CONTROL "Sort contacts by name",IDC_SORTBYNAME,"Button",BS_AUTORADIOBUTTON | WS_GROUP,153,14,144,10
CONTROL "Sort contacts by status",IDC_SORTBYSTATUS,"Button",BS_AUTORADIOBUTTON,153,26,149,10
CONTROL "Sort contacts by protocol",IDC_SORTBYPROTO,"Button",BS_AUTORADIOBUTTON,153,38,151,10
@@ -74,7 +68,7 @@ BEGIN
GROUPBOX "System tray icon when using multiple protocols",IDC_STATIC,2,131,310,66
GROUPBOX "Contact list sorting",IDC_STATIC,143,2,169,54,WS_GROUP
CONTROL "Spin5",IDC_BLINKSPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,173,97,11,21
- CONTROL "Disable icon blinking",IDC_ICONBLINK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,84,97,10
+ CONTROL "Disable icon blinking",IDC_ICONBLINK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,15,97,10
END
IDD_OPT_CLUI DIALOGEX 0, 0, 313, 245
@@ -222,7 +216,7 @@ END
//
#ifdef APSTUDIO_INVOKED
-GUIDELINES DESIGNINFO
+GUIDELINES DESIGNINFO
BEGIN
IDD_DELETECONTACT, DIALOG
BEGIN
@@ -344,10 +338,23 @@ END
//
IDC_HYPERLINKHAND CURSOR "hyperlin.cur"
+
IDC_DROP CURSOR "dragcopy.cur"
+
IDC_DROPUSER CURSOR "dropuser.cur"
-#endif // English (U.S.) resources
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// AFX_DIALOG_LAYOUT
+//
+
+IDD_OPT_CLIST AFX_DIALOG_LAYOUT
+BEGIN
+ 0
+END
+
+#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
diff --git a/src/core/stdclist/src/clistopts.cpp b/src/core/stdclist/src/clistopts.cpp
index 8f5ac3150f..12b21edb8a 100644
--- a/src/core/stdclist/src/clistopts.cpp
+++ b/src/core/stdclist/src/clistopts.cpp
@@ -27,39 +27,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static INT_PTR CALLBACK DlgProcGenOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
- case WM_USER + 1:
- {
- MCONTACT hContact = wParam;
- DBCONTACTWRITESETTING *ws = (DBCONTACTWRITESETTING *)lParam;
- if (hContact == NULL && ws != nullptr && ws->szModule != nullptr && ws->szSetting != nullptr &&
- strcmp(ws->szModule, "CList") == 0 && strcmp(ws->szSetting, "UseGroups") == 0 && IsWindowVisible(hwndDlg))
- {
- CheckDlgButton(hwndDlg, IDC_DISABLEGROUPS, ws->value.bVal == 0 ? BST_CHECKED : BST_UNCHECKED);
- }
- }
- break;
-
- case WM_DESTROY:
- UnhookEvent((HANDLE)GetWindowLongPtr(hwndDlg, GWLP_USERDATA));
- break;
-
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)HookEventMessage(ME_DB_CONTACT_SETTINGCHANGED, hwndDlg, WM_USER + 1));
- CheckDlgButton(hwndDlg, IDC_HIDEOFFLINE,
- g_plugin.getByte("HideOffline", SETTING_HIDEOFFLINE_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_HIDEEMPTYGROUPS,
- g_plugin.getByte("HideEmptyGroups", SETTING_HIDEEMPTYGROUPS_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_DISABLEGROUPS,
- g_plugin.getByte("UseGroups", SETTING_USEGROUPS_DEFAULT) ? BST_UNCHECKED : BST_CHECKED);
CheckDlgButton(hwndDlg, IDC_SORTBYNAME, !g_plugin.getByte("SortByStatus", SETTING_SORTBYSTATUS_DEFAULT)
&& !g_plugin.getByte("SortByProto", SETTING_SORTBYPROTO_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_SORTBYSTATUS,
g_plugin.getByte("SortByStatus", SETTING_SORTBYSTATUS_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_SORTBYPROTO,
g_plugin.getByte("SortByProto", SETTING_SORTBYPROTO_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CONFIRMDELETE,
- g_plugin.getByte("ConfirmDelete", SETTING_CONFIRMDELETE_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
CheckDlgButton(hwndDlg, IDC_ONECLK,
g_plugin.getByte("Tray1Click", SETTING_TRAY1CLICK_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
@@ -146,16 +122,11 @@ static INT_PTR CALLBACK DlgProcGenOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
case 0:
switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
- g_plugin.setByte("HideOffline", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_HIDEOFFLINE));
- g_plugin.setByte("HideEmptyGroups", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_HIDEEMPTYGROUPS));
- g_plugin.setByte("UseGroups", (BYTE)!IsDlgButtonChecked(hwndDlg, IDC_DISABLEGROUPS));
-
g_bSortByStatus = IsDlgButtonChecked(hwndDlg, IDC_SORTBYSTATUS);
g_bSortByProto = IsDlgButtonChecked(hwndDlg, IDC_SORTBYPROTO);
g_plugin.setByte("SortByStatus", (BYTE)g_bSortByStatus);
g_plugin.setByte("SortByProto", (BYTE)g_bSortByProto);
- g_plugin.setByte("ConfirmDelete", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CONFIRMDELETE));
g_plugin.setByte("Tray1Click", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ONECLK));
g_plugin.setByte("AlwaysStatus", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ALWAYSSTATUS));
g_plugin.setByte("AlwaysMulti", (BYTE)!IsDlgButtonChecked(hwndDlg, IDC_ALWAYSMULTI));
diff --git a/src/core/stdclist/src/resource.h b/src/core/stdclist/src/resource.h
index 7315124d9c..92d8716ed6 100644
--- a/src/core/stdclist/src/resource.h
+++ b/src/core/stdclist/src/resource.h
@@ -1,6 +1,6 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
-// Used by resource.rc
+// Used by w:\miranda-ng\src\core\stdclist\res\resource.rc
//
#define IDD_OPT_CLIST 126
#define IDC_DROP 183
@@ -20,18 +20,14 @@
#define IDC_TOOLWND 1097
#define IDC_ONECLK 1098
#define IDC_SHOWCAPTION 1098
-#define IDC_HIDEOFFLINE 1099
#define IDC_SHOWHIDE 1100
-#define IDC_HIDEEMPTYGROUPS 1100
#define IDC_SORTBYSTATUS 1101
#define IDC_FADEINOUT 1101
#define IDC_READMSG 1102
#define IDC_AUTOSIZE 1102
-#define IDC_DISABLEGROUPS 1102
#define IDC_AUTOSIZEUPWARD 1103
#define IDC_ALWAYSSTATUS 1103
#define IDC_NETSEARCH 1104
-#define IDC_CONFIRMDELETE 1104
#define IDC_SORTBYPROTO 1105
#define IDC_SHOWOPTIONS 1105
#define IDC_SEARCHURL 1106
@@ -134,7 +130,7 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 292
+#define _APS_NEXT_RESOURCE_VALUE 293
#define _APS_NEXT_COMMAND_VALUE 40018
#define _APS_NEXT_CONTROL_VALUE 1662
#define _APS_NEXT_SYMED_VALUE 101
diff --git a/src/core/stdmsg/src/msgoptions.cpp b/src/core/stdmsg/src/msgoptions.cpp
index 131862920b..561ef27cf0 100644
--- a/src/core/stdmsg/src/msgoptions.cpp
+++ b/src/core/stdmsg/src/msgoptions.cpp
@@ -435,7 +435,7 @@ public:
void ResetCList(CCtrlClc::TEventInfo* = nullptr)
{
- clist.SetUseGroups(db_get_b(0, "CList", "UseGroups", SETTING_USEGROUPS_DEFAULT));
+ clist.SetUseGroups(Clist::UseGroups);
clist.SetHideEmptyGroups(1);
}
diff --git a/src/mir_app/res/resource.rc b/src/mir_app/res/resource.rc
index ae65720b51..c3890aec81 100644
--- a/src/mir_app/res/resource.rc
+++ b/src/mir_app/res/resource.rc
@@ -774,6 +774,19 @@ BEGIN
EDITTEXT IDC_CREDITSFILE,4,32,202,67,ES_CENTER | ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_READONLY | NOT WS_BORDER | WS_VSCROLL
END
+IDD_OPT_CLIST DIALOGEX 0, 0, 302, 202
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
+EXSTYLE WS_EX_CONTROLPARENT
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ CONTROL "Hide offline users",IDC_HIDEOFFLINE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,17,124,10
+ CONTROL "Hide empty groups",IDC_HIDEEMPTYGROUPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,29,124,10
+ CONTROL "Enable groups",IDC_USEGROUPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,41,124,10
+ CONTROL "Ask before deleting contacts",IDC_CONFIRMDELETE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,53,124,10
+ GROUPBOX "Contact list",IDC_STATIC,6,5,289,77
+ CONTROL "Remove temporary contacts on exit",IDC_REMOVETEMP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,65,276,10
+END
+
IDD_EMPTY DIALOGEX 0, 0, 212, 131
STYLE DS_FIXEDSYS | WS_POPUP
CAPTION "Hidden window"
@@ -1072,6 +1085,10 @@ BEGIN
TOPMARGIN, 7
BOTTOMMARGIN, 126
END
+
+ IDD_OPT_CLIST, DIALOG
+ BEGIN
+ END
END
#endif // APSTUDIO_INVOKED
@@ -1353,6 +1370,11 @@ BEGIN
0
END
+IDD_OPT_CLIST AFX_DIALOG_LAYOUT
+BEGIN
+ 0
+END
+
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
diff --git a/src/mir_app/src/clc.h b/src/mir_app/src/clc.h
index a9f97f0044..fc7805ab4a 100644
--- a/src/mir_app/src/clc.h
+++ b/src/mir_app/src/clc.h
@@ -91,7 +91,7 @@ int fnRowHitTest(ClcData *dat, int y);
int GetDropTargetInformation(HWND hwnd, ClcData *dat, POINT pt);
/* clcopts.c */
-int ClcOptInit(WPARAM wParam, LPARAM lParam);
+int ClcOptInit(WPARAM, LPARAM);
/* clistmenus.c */
void RebuildMenuOrder(void);
@@ -107,45 +107,58 @@ void fnCheckCacheItem(ClcCacheEntry *p);
void fnFreeCacheItem(ClcCacheEntry *p);
/* clcfiledrop.c */
-void RegisterFileDropping(HWND hwnd);
-void UnregisterFileDropping(HWND hwnd);
+void RegisterFileDropping(HWND hwnd);
+void UnregisterFileDropping(HWND hwnd);
/* clistevents.c */
struct CListEvent* fnAddEvent(CLISTEVENT *cle);
CLISTEVENT* fnGetEvent(MCONTACT hContact, int idx);
-int fnGetImlIconIndex(HICON hIcon);
-int fnRemoveEvent(MCONTACT hContact, MEVENT dbEvent);
+int fnGetImlIconIndex(HICON hIcon);
+int fnRemoveEvent(MCONTACT hContact, MEVENT dbEvent);
-int EventsProcessContactDoubleClick(MCONTACT hContact);
+int EventsProcessContactDoubleClick(MCONTACT hContact);
+
+int InitCListEvents(void);
+void UninitCListEvents(void);
+
+/* clistgroups.c */
+int InitGroupServices(void);
+void UninitGroupServices(void);
/* clistmod.c */
-int fnIconFromStatusMode(const char *szProto, int status, MCONTACT hContact);
-int fnShowHide(void);
-HICON fnGetIconFromStatusMode(MCONTACT hContact, const char *szProto, int status);
-int fnGetWindowVisibleState(HWND hWnd, int iStepX, int iStepY);
+int fnIconFromStatusMode(const char *szProto, int status, MCONTACT hContact);
+int fnShowHide(void);
+HICON fnGetIconFromStatusMode(MCONTACT hContact, const char *szProto, int status);
+int fnGetWindowVisibleState(HWND hWnd, int iStepX, int iStepY);
+
+/* clistsettings.cpp */
+int ContactAdded(WPARAM, LPARAM);
+int ContactDeleted(WPARAM, LPARAM);
/* clisttray.c */
extern mir_cs trayLockCS;
-int fnTrayIconInit(HWND hwnd);
-int fnTrayIconPauseAutoHide(WPARAM wParam, LPARAM lParam);
-INT_PTR fnTrayIconProcessMessage(WPARAM wParam, LPARAM lParam);
-int fnTrayCalcChanged(const char *szChangedProto, int averageMode, int netProtoCount);
+int fnTrayIconInit(HWND hwnd);
+int fnTrayIconPauseAutoHide(WPARAM, LPARAM);
+INT_PTR fnTrayIconProcessMessage(WPARAM, LPARAM);
+int fnTrayCalcChanged(const char *szChangedProto, int averageMode, int netProtoCount);
-void InitTray(void);
-void TrayIconSetToBase(char *szPreferredProto);
-void TrayIconTaskbarCreated(HWND hwnd);
-int TrayIconUpdate(HICON hNewIcon, const wchar_t *szNewTip, const char *szPreferredProto, int isBase);
-void TrayIconUpdateWithImageList(int iImage, const wchar_t *szNewTip, const char *szPreferredProto);
+void InitTray(void);
+void TrayIconSetToBase(char *szPreferredProto);
+void TrayIconTaskbarCreated(HWND hwnd);
+int TrayIconUpdate(HICON hNewIcon, const wchar_t *szNewTip, const char *szPreferredProto, int isBase);
+void TrayIconUpdateWithImageList(int iImage, const wchar_t *szNewTip, const char *szPreferredProto);
/* clui.c */
-LRESULT CALLBACK fnContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+LRESULT CALLBACK fnContactListWndProc(HWND, UINT, WPARAM, LPARAM);
void fnLoadCluiGlobalOpts(void);
void fnCluiProtocolStatusChanged(int, const char*);
+int LoadCLUIModule(void);
+
/* contact.c */
-int fnSetHideOffline(int iValue);
+int fnSetHideOffline(int iValue);
/* docking.c */
int fnDocking_ProcessWindowMessage(WPARAM wParam, LPARAM lParam);
diff --git a/src/mir_app/src/clistgroups.cpp b/src/mir_app/src/clistgroups.cpp
index 51b6ecd4c0..4a308edb28 100644
--- a/src/mir_app/src/clistgroups.cpp
+++ b/src/mir_app/src/clistgroups.cpp
@@ -197,7 +197,7 @@ MIR_APP_DLL(int) Clist_GroupDelete(MGROUP hGroup)
if (pGroup == nullptr)
return 1;
- if (db_get_b(0, "CList", "ConfirmDelete", SETTING_CONFIRMDELETE_DEFAULT)) {
+ if (Clist::ConfirmDelete) {
wchar_t szQuestion[256 + 100];
mir_snwprintf(szQuestion, TranslateT("Are you sure you want to delete group '%s'? This operation cannot be undone."), pGroup->groupName+1);
if (MessageBox(g_clistApi.hwndContactList, szQuestion, TranslateT("Delete group"), MB_YESNO | MB_ICONQUESTION) == IDNO)
diff --git a/src/mir_app/src/clistmod.cpp b/src/mir_app/src/clistmod.cpp
index b91799c0ed..fdf0b99dc9 100644
--- a/src/mir_app/src/clistmod.cpp
+++ b/src/mir_app/src/clistmod.cpp
@@ -27,22 +27,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "clc.h"
#include "genmenu.h"
-int InitCListEvents(void);
-void UninitCListEvents(void);
-void UninitGroupServices(void);
int ContactSettingChanged(WPARAM wParam, LPARAM lParam);
-int ContactAdded(WPARAM hContact, LPARAM);
-int ContactDeleted(WPARAM hContact, LPARAM);
-int InitGroupServices(void);
-INT_PTR Docking_IsDocked(WPARAM wParam, LPARAM lParam);
-int LoadCLUIModule(void);
int InitClistHotKeys(void);
void ScheduleMenuUpdate(void);
HANDLE hContactDoubleClicked, hContactIconChangedEvent;
HIMAGELIST hCListImages;
-extern BYTE nameOrder[];
+/////////////////////////////////////////////////////////////////////////////////////////
MIR_APP_DLL(wchar_t*) Clist_GetStatusModeDescription(int mode, int flags)
{
@@ -95,6 +87,41 @@ MIR_APP_DLL(wchar_t*) Clist_GetStatusModeDescription(int mode, int flags)
return (flags & GSMDF_UNTRANSLATED) ? descr : TranslateW(descr);
}
+MIR_APP_DLL(void) Clist_ContactDoubleClicked(MCONTACT hContact)
+{
+ // Try to process event myself
+ if (EventsProcessContactDoubleClick(hContact) == 0)
+ return;
+
+ // Allow third-party plugins to process a dblclick
+ if (NotifyEventHooks(hContactDoubleClicked, hContact, 0))
+ return;
+
+ // Otherwise try to execute the default action
+ TIntMenuObject *pmo = GetMenuObjbyId(hContactMenuObject);
+ if (pmo != nullptr) {
+ NotifyEventHooks(hPreBuildContactMenuEvent, hContact, 0);
+
+ TMO_IntMenuItem *pimi = Menu_GetDefaultItem(pmo->m_items.first);
+ if (pimi != nullptr)
+ Menu_ProcessCommand(pimi, hContact);
+ }
+}
+
+MIR_APP_DLL(HIMAGELIST) Clist_GetImageList(void)
+{
+ return hCListImages;
+}
+
+MIR_APP_DLL(int) Clist_GetContactIcon(MCONTACT hContact)
+{
+ char *szProto = Proto_GetBaseAccountName(hContact);
+ return g_clistApi.pfnIconFromStatusMode(szProto,
+ szProto == nullptr ? ID_STATUS_OFFLINE : db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE), hContact);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
HICON fnGetIconFromStatusMode(MCONTACT hContact, const char *szProto, int status)
{
return ImageList_GetIcon(hCListImages, g_clistApi.pfnIconFromStatusMode(szProto, status, hContact), ILD_NORMAL);
@@ -119,12 +146,7 @@ int fnIconFromStatusMode(const char *szProto, int status, MCONTACT)
return 1;
}
-MIR_APP_DLL(int) Clist_GetContactIcon(MCONTACT hContact)
-{
- char *szProto = Proto_GetBaseAccountName(hContact);
- return g_clistApi.pfnIconFromStatusMode(szProto,
- szProto == nullptr ? ID_STATUS_OFFLINE : db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE), hContact);
-}
+/////////////////////////////////////////////////////////////////////////////////////////
static void AddProtoIconIndex(PROTOACCOUNT *pa)
{
@@ -135,11 +157,6 @@ static void AddProtoIconIndex(PROTOACCOUNT *pa)
}
}
-static void RemoveProtoIconIndex(PROTOACCOUNT *pa)
-{
- pa->iIconBase = -1;
-}
-
static int ContactListModulesLoaded(WPARAM, LPARAM)
{
ScheduleMenuUpdate();
@@ -181,32 +198,6 @@ static int ContactListAccountsChanged(WPARAM eventCode, LPARAM lParam)
return 0;
}
-MIR_APP_DLL(void) Clist_ContactDoubleClicked(MCONTACT hContact)
-{
- // Try to process event myself
- if (EventsProcessContactDoubleClick(hContact) == 0)
- return;
-
- // Allow third-party plugins to process a dblclick
- if (NotifyEventHooks(hContactDoubleClicked, hContact, 0))
- return;
-
- // Otherwise try to execute the default action
- TIntMenuObject *pmo = GetMenuObjbyId(hContactMenuObject);
- if (pmo != nullptr) {
- NotifyEventHooks(hPreBuildContactMenuEvent, hContact, 0);
-
- TMO_IntMenuItem *pimi = Menu_GetDefaultItem(pmo->m_items.first);
- if (pimi != nullptr)
- Menu_ProcessCommand(pimi, hContact);
- }
-}
-
-MIR_APP_DLL(HIMAGELIST) Clist_GetImageList(void)
-{
- return hCListImages;
-}
-
static int CListIconsChanged(WPARAM, LPARAM)
{
for (int i = 0; i < _countof(g_statuses); i++)
@@ -385,6 +376,7 @@ int LoadContactListModule2(void)
HookEvent(ME_DB_CONTACT_SETTINGCHANGED, ContactSettingChanged);
HookEvent(ME_DB_CONTACT_ADDED, ContactAdded);
HookEvent(ME_DB_CONTACT_DELETED, ContactDeleted);
+ HookEvent(ME_OPT_INITIALISE, ClcOptInit);
hContactDoubleClicked = CreateHookableEvent(ME_CLIST_DOUBLECLICKED);
hContactIconChangedEvent = CreateHookableEvent(ME_CLIST_CONTACTICONCHANGED);
@@ -403,12 +395,15 @@ void UnloadContactListModule()
return;
// remove transitory contacts
- for (MCONTACT hContact = db_find_first(); hContact != 0; ) {
- MCONTACT hNext = db_find_next(hContact);
- if (!Contact_OnList(hContact))
- db_delete_contact(hContact);
- hContact = hNext;
+ if (Clist::RemoveTempContacts) {
+ for (MCONTACT hContact = db_find_first(); hContact != 0; ) {
+ MCONTACT hNext = db_find_next(hContact);
+ if (!Contact_OnList(hContact))
+ db_delete_contact(hContact);
+ hContact = hNext;
+ }
}
+
ImageList_Destroy(hCListImages);
UninitCListEvents();
UninitGroupServices();
diff --git a/src/mir_app/src/clistopts.cpp b/src/mir_app/src/clistopts.cpp
new file mode 100644
index 0000000000..ed7bf9baad
--- /dev/null
+++ b/src/mir_app/src/clistopts.cpp
@@ -0,0 +1,74 @@
+/*
+
+Miranda NG: the free IM client for Microsoft* Windows*
+
+Copyright (C) 2012-20 Miranda NG team (https://miranda-ng.org),
+Copyright (c) 2000-12 Miranda IM project,
+all portions of this codebase are copyrighted to the people
+listed in contributors.txt.
+
+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; either version 2
+of the License, or (at your option) any later version.
+
+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, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "stdafx.h"
+#include "clc.h"
+
+#define MODULENAME "CList"
+
+CMOption<bool> Clist::UseGroups(MODULENAME, "UseGroups", true);
+CMOption<bool> Clist::HideOffline(MODULENAME, "HideOffline", false);
+CMOption<bool> Clist::ConfirmDelete(MODULENAME, "ConfirmDelete", true);
+CMOption<bool> Clist::HideEmptyGroups(MODULENAME, "HideEmptyGroups", false);
+CMOption<bool> Clist::RemoveTempContacts(MODULENAME, "RemoveTempContacts", true);
+
+class ClistCommonOptsDlg : public CDlgBase
+{
+ CCtrlCheck chkUseGroups, chkHideOffline, chkConfirmDelete, chkHideEmptyGroups, chkRemoveTempContacts;
+
+public:
+ ClistCommonOptsDlg() :
+ CDlgBase(g_plugin, IDD_OPT_CLIST),
+ chkUseGroups(this, IDC_USEGROUPS),
+ chkHideOffline(this, IDC_HIDEOFFLINE),
+ chkConfirmDelete(this, IDC_CONFIRMDELETE),
+ chkHideEmptyGroups(this, IDC_HIDEEMPTYGROUPS),
+ chkRemoveTempContacts(this, IDC_REMOVETEMP)
+ {
+ CreateLink(chkUseGroups, Clist::UseGroups);
+ CreateLink(chkHideOffline, Clist::HideOffline);
+ CreateLink(chkConfirmDelete, Clist::ConfirmDelete);
+ CreateLink(chkHideEmptyGroups, Clist::HideEmptyGroups);
+ CreateLink(chkRemoveTempContacts, Clist::RemoveTempContacts);
+ }
+
+ bool OnApply() override
+ {
+ Clist_LoadContactTree();
+ Clist_InitAutoRebuild(g_clistApi.hwndContactTree);
+ return true;
+ }
+};
+
+int ClcOptInit(WPARAM wParam, LPARAM)
+{
+ OPTIONSDIALOGPAGE odp = {};
+ odp.position = -200000000;
+ odp.szGroup.a = LPGEN("Contact list");
+ odp.szTitle.a = LPGEN("Common");
+ odp.flags = ODPF_BOLDGROUPS;
+ odp.pDialog = new ClistCommonOptsDlg();
+ g_plugin.addOptions(wParam, &odp);
+ return 0;
+}
diff --git a/src/mir_app/src/clui.cpp b/src/mir_app/src/clui.cpp
index f4a2f21511..cde9dc267f 100644
--- a/src/mir_app/src/clui.cpp
+++ b/src/mir_app/src/clui.cpp
@@ -195,7 +195,7 @@ static INT_PTR MenuItem_DeleteContact(WPARAM wParam, LPARAM lParam)
//see notes about deleting contacts on PF1_SERVERCLIST servers in m_protosvc.h
UINT_PTR action;
- if (db_get_b(0, "CList", "ConfirmDelete", SETTING_CONFIRMDELETE_DEFAULT) && !(GetKeyState(VK_SHIFT) & 0x8000))
+ if (Clist::ConfirmDelete && !(GetKeyState(VK_SHIFT) & 0x8000))
// Ask user for confirmation, and if the contact should be archived (hidden, not deleted)
action = DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_DELETECONTACT), (HWND)lParam, AskForConfirmationDlgProc, wParam);
else
@@ -476,12 +476,8 @@ LRESULT CALLBACK fnContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
case M_CREATECLC:
g_clistApi.hwndContactTree = CreateWindow(CLISTCONTROL_CLASSW, L"",
- WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN
- | CLS_CONTACTLIST
- | (db_get_b(0, "CList", "UseGroups", SETTING_USEGROUPS_DEFAULT) ? CLS_USEGROUPS : 0)
- | (db_get_b(0, "CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT) ? CLS_HIDEOFFLINE : 0)
- | (db_get_b(0, "CList", "HideEmptyGroups", SETTING_HIDEEMPTYGROUPS_DEFAULT) ? CLS_HIDEEMPTYGROUPS : 0),
- 0, 0, 0, 0, hwnd, nullptr, g_clistApi.hInst, nullptr);
+ WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | CLS_CONTACTLIST | (Clist::UseGroups ? CLS_USEGROUPS : 0) | (Clist::HideOffline ? CLS_HIDEOFFLINE : 0) | (Clist::HideEmptyGroups ? CLS_HIDEEMPTYGROUPS : 0),
+ 0, 0, 0, 0, hwnd, nullptr, g_clistApi.hInst, nullptr);
SendMessage(hwnd, WM_SIZE, 0, 0);
break;
diff --git a/src/mir_app/src/cluiservices.cpp b/src/mir_app/src/cluiservices.cpp
index 3382706ea8..9fd57d5c1b 100644
--- a/src/mir_app/src/cluiservices.cpp
+++ b/src/mir_app/src/cluiservices.cpp
@@ -48,24 +48,24 @@ EXTERN_C MIR_APP_DLL(void) Clist_EndRebuild(void)
LONG_PTR dwStyle = GetWindowLongPtr(g_clistApi.hwndContactTree, GWL_STYLE);
// CLC does this automatically, but we need to force it if hideoffline or hideempty has changed
- if ((db_get_b(0, "CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT) == 0) != ((dwStyle & CLS_HIDEOFFLINE) == 0)) {
- if (db_get_b(0, "CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT))
+ if ((Clist::HideOffline == 0) != ((dwStyle & CLS_HIDEOFFLINE) == 0)) {
+ if (Clist::HideOffline)
dwStyle |= CLS_HIDEOFFLINE;
else
dwStyle &= ~CLS_HIDEOFFLINE;
bRebuild = true;
}
- if ((db_get_b(0, "CList", "HideEmptyGroups", SETTING_HIDEEMPTYGROUPS_DEFAULT) == 0) != ((dwStyle & CLS_HIDEEMPTYGROUPS) == 0)) {
- if (db_get_b(0, "CList", "HideEmptyGroups", SETTING_HIDEEMPTYGROUPS_DEFAULT))
+ if ((Clist::HideEmptyGroups == 0) != ((dwStyle & CLS_HIDEEMPTYGROUPS) == 0)) {
+ if (Clist::HideEmptyGroups)
dwStyle |= CLS_HIDEEMPTYGROUPS;
else
dwStyle &= ~CLS_HIDEEMPTYGROUPS;
bRebuild = true;
}
- if ((db_get_b(0, "CList", "UseGroups", SETTING_USEGROUPS_DEFAULT) == 0) != ((dwStyle & CLS_USEGROUPS) == 0)) {
- if (db_get_b(0, "CList", "UseGroups", SETTING_USEGROUPS_DEFAULT))
+ if ((Clist::UseGroups == 0) != ((dwStyle & CLS_USEGROUPS) == 0)) {
+ if (Clist::UseGroups)
dwStyle |= CLS_USEGROUPS;
else
dwStyle &= ~CLS_USEGROUPS;
diff --git a/src/mir_app/src/contact.cpp b/src/mir_app/src/contact.cpp
index 9631710cdb..f8e32961b0 100644
--- a/src/mir_app/src/contact.cpp
+++ b/src/mir_app/src/contact.cpp
@@ -29,7 +29,7 @@ extern HANDLE hGroupChangeEvent;
MIR_APP_DLL(void) Clist_LoadContactTree(void)
{
- int hideOffline = db_get_b(0, "CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT);
+ bool hideOffline = Clist::HideOffline;
for (auto &hContact : Contacts()) {
int status = Contact_GetStatus(hContact);
if ((!hideOffline || status != ID_STATUS_OFFLINE) && !Contact_IsHidden(hContact))
@@ -56,12 +56,12 @@ MIR_APP_DLL(int) Clist_ContactChangeGroup(MCONTACT hContact, MGROUP hGroup)
int fnSetHideOffline(int iValue)
{
if (iValue == -1) // invert the current value
- iValue = !db_get_b(0, "CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT);
+ iValue = !Clist::HideOffline;
switch (iValue) {
case 0:
case 1:
- db_set_b(0, "CList", "HideOffline", iValue);
+ Clist::HideOffline = iValue;
break;
default:
diff --git a/src/mir_app/src/menu_groups.cpp b/src/mir_app/src/menu_groups.cpp
index 60af0b07b6..b63144d1be 100644
--- a/src/mir_app/src/menu_groups.cpp
+++ b/src/mir_app/src/menu_groups.cpp
@@ -114,7 +114,7 @@ static INT_PTR HideGroupsHelper(WPARAM, LPARAM)
static INT_PTR UseGroupsHelper(WPARAM, LPARAM)
{
int newVal = !(GetWindowLongPtr(g_clistApi.hwndContactTree, GWL_STYLE) & CLS_USEGROUPS);
- db_set_b(0, "CList", "UseGroups", (BYTE)newVal);
+ Clist::UseGroups = newVal;
SendMessage(g_clistApi.hwndContactTree, CLM_SETUSEGROUPS, newVal,0);
return newVal;
}
@@ -141,7 +141,7 @@ static INT_PTR CreateGroupHelper(WPARAM, LPARAM)
static int OnBuildGroupMenu(WPARAM, LPARAM)
{
- bool bChecked = db_get_b(0, "CList", "HideOffline", SETTING_HIDEOFFLINE_DEFAULT) != 0;
+ bool bChecked = Clist::HideOffline;
Menu_SetChecked(hHideOfflineUsersMenuItem, bChecked);
bChecked = SendMessage(g_clistApi.hwndContactTree, CLM_GETHIDEOFFLINEROOT, 0, 0) != 0;
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 2bf18c7b40..8c084e9810 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -725,3 +725,7 @@ Netlib_Dump @812 NONAME
?ProtoBroadcastAsync@PROTO_INTERFACE@@QAEXIHHPAXJ@Z @813 NONAME
ProtoBroadcastAsync @814 NONAME
?ProcessFileDrop@@YG_NPAUHDROP__@@I@Z @815 NONAME
+?ConfirmDelete@Clist@@3V?$CMOption@_N@@A @816 NONAME
+?HideEmptyGroups@Clist@@3V?$CMOption@_N@@A @817 NONAME
+?HideOffline@Clist@@3V?$CMOption@_N@@A @818 NONAME
+?UseGroups@Clist@@3V?$CMOption@_N@@A @819 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index f87708dd0e..f05d983ed1 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -725,3 +725,7 @@ Netlib_Dump @812 NONAME
?ProtoBroadcastAsync@PROTO_INTERFACE@@QEAAXIHHPEAX_J@Z @813 NONAME
ProtoBroadcastAsync @814 NONAME
?ProcessFileDrop@@YA_NPEAUHDROP__@@I@Z @815 NONAME
+?ConfirmDelete@Clist@@3V?$CMOption@_N@@A @816 NONAME
+?HideEmptyGroups@Clist@@3V?$CMOption@_N@@A @817 NONAME
+?HideOffline@Clist@@3V?$CMOption@_N@@A @818 NONAME
+?UseGroups@Clist@@3V?$CMOption@_N@@A @819 NONAME
diff --git a/src/mir_app/src/resource.h b/src/mir_app/src/resource.h
index fc2881993f..781b5bb44a 100644
--- a/src/mir_app/src/resource.h
+++ b/src/mir_app/src/resource.h
@@ -1,6 +1,6 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
-// Used by resource.rc
+// Used by w:\miranda-ng\src\mir_app\res\resource.rc
//
#define IDC_AUTHICON 1
#define IDC_NOTOALL 3
@@ -18,13 +18,14 @@
#define IDD_OPT_PROTOCOLORDER 109
#define IDD_OPT_ICOLIB 110
#define IDD_ICOLIB_IMPORT 111
-#define IDD_OPT_SRMMLOG 112
+#define IDD_OPT_SRMMLOG 112
#define IDI_LOADED_GRAY 113
#define IDI_NOTLOADED_GRAY 114
#define IDD_ADDED 115
#define IDD_ENTER_STRING 116
#define IDI_ADDGROUP 117
#define IDD_EMPTY 118
+#define IDD_OPT_CLIST 119
#define IDD_AUTHREQ 121
#define IDD_DETAILS 125
#define IDD_HISTORY 127
@@ -208,6 +209,7 @@
#define IDC_CHK_FORCEDEFAULT 1027
#define IDC_ED_NAME 1028
#define IDC_ED_DEFAULT 1029
+#define IDC_REMOVETEMP 1030
#define IDC_SHOWNAMES 1031
#define IDC_ABOUT 1032
#define IDC_MYNOTES 1033
@@ -255,6 +257,10 @@
#define IDC_TIMEZONESELECT 1071
#define IDC_MOREOPTIONS 1071
#define IDC_USERMENU 1071
+#define IDC_HIDEOFFLINE 1072
+#define IDC_HIDEEMPTYGROUPS 1073
+#define IDC_USEGROUPS 1074
+#define IDC_CONFIRMDELETE 1075
#define IDC_SLOT_L 1075
#define IDC_SLOT 1076
#define IDC_MAX_ICONS_L 1077
@@ -596,9 +602,9 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 330
+#define _APS_NEXT_RESOURCE_VALUE 331
#define _APS_NEXT_COMMAND_VALUE 40018
-#define _APS_NEXT_CONTROL_VALUE 1748
+#define _APS_NEXT_CONTROL_VALUE 1749
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif