summaryrefslogtreecommitdiff
path: root/plugins/Clist_modern
diff options
context:
space:
mode:
authorVlad Mironov <mironych@googlemail.com>2015-01-01 04:03:43 +0000
committerVlad Mironov <mironych@googlemail.com>2015-01-01 04:03:43 +0000
commitc97742103384c452ec50f0f8607233e45956da24 (patch)
tree2659a91b5d952d845948ef079700c8f868e9c373 /plugins/Clist_modern
parentfe0ede95649f375f4f7aa422079dbdd7f7fbafbc (diff)
Clist_modern: tray icons refactoring, attempt second.
git-svn-id: http://svn.miranda-ng.org/main/trunk@11711 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Clist_modern')
-rw-r--r--plugins/Clist_modern/res/resource.rc34
-rw-r--r--plugins/Clist_modern/src/hdr/modern_clc.h8
-rw-r--r--plugins/Clist_modern/src/hdr/modern_commonprototypes.h4
-rw-r--r--plugins/Clist_modern/src/init.cpp5
-rw-r--r--plugins/Clist_modern/src/modern_clcopts.cpp213
-rw-r--r--plugins/Clist_modern/src/modern_clisttray.cpp496
-rw-r--r--plugins/Clist_modern/src/resource.h24
7 files changed, 540 insertions, 244 deletions
diff --git a/plugins/Clist_modern/res/resource.rc b/plugins/Clist_modern/res/resource.rc
index 6c5efbf13c..8ca1c1252a 100644
--- a/plugins/Clist_modern/res/resource.rc
+++ b/plugins/Clist_modern/res/resource.rc
@@ -427,7 +427,7 @@ BEGIN
CONTROL "Tree1",IDC_GREYOUTOPTS,"SysTreeView32",TVS_DISABLEDRAGDROP | TVS_NOTOOLTIPS | TVS_NONEVENHEIGHT | WS_BORDER | WS_HSCROLL | WS_TABSTOP,165,168,130,46
END
-IDD_OPT_TRAY DIALOGEX 0, 0, 296, 152
+IDD_OPT_TRAY DIALOGEX 0, 0, 296, 200
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD | WS_VISIBLE
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 0, 0, 0x1
@@ -438,21 +438,33 @@ BEGIN
EDITTEXT IDC_BLINKTIME,12,59,35,12,ES_NUMBER
CONTROL "",IDC_BLINKSPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,47,59,11,12
LTEXT "ms, delay between icon blinking",IDC_STATIC,62,61,104,8
- CONTROL "Show",IDC_DONTCYCLE,"Button",BS_AUTORADIOBUTTON | WS_GROUP,10,94,97,10
- COMBOBOX IDC_PRIMARYSTATUS,107,94,78,101,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
- CONTROL "Cycle icons every",IDC_CYCLE,"Button",BS_AUTORADIOBUTTON,10,110,97,10
- EDITTEXT IDC_CYCLETIME,107,110,29,12,ES_RIGHT | ES_NUMBER
- CONTROL "",IDC_CYCLETIMESPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,136,110,11,12
- LTEXT "seconds, when statuses differ",IDC_STATIC,151,111,132,8,NOT WS_GROUP
- CONTROL "Show multiple icons",IDC_MULTITRAY,"Button",BS_AUTORADIOBUTTON,10,126,97,10
- CONTROL "only when statuses differ",IDC_ALWAYSMULTI,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,107,126,181,10
GROUPBOX "System tray icon",IDC_STATIC,2,6,292,73
- GROUPBOX "System tray icon mode",IDC_STATIC,2,80,292,61
CONTROL "Use xStatus icon",IDC_SHOWXSTATUS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,171,19,117,10
CONTROL "Show normal status as overlay",IDC_SHOWNORMAL,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,171,32,117,10
CONTROL "Status overlay opacity is 75%",IDC_TRANSPARENTOVERLAY,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,171,45,117,10
- CONTROL "only when statuses differ",IDC_ALWAYSPRIMARY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,190,94,98,10
+
+ GROUPBOX "Icon mode", IDC_STATIC, 2, 80, 292, 110
+
+ GROUPBOX "Statuses the same", IDC_STATIC, 8, 90, 138, 74
+ CONTROL "Global status", IDC_ICON_GLOBAL_S, "Button", BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP, 14, 100, 97, 10
+ CONTROL "Single account", IDC_ICON_ACC_S, "Button", BS_AUTORADIOBUTTON, 14, 116, 60, 10
+ CONTROL "Cycle icons", IDC_ICON_CYCLE_S, "Button", BS_AUTORADIOBUTTON, 14, 132, 97, 10
+ CONTROL "All accounts", IDC_ICON_ALL_S, "Button", BS_AUTORADIOBUTTON, 14, 148, 97, 10
+ COMBOBOX IDC_PRIMARYSTATUS_S, 80, 114, 60, 101, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP | WS_DISABLED
+
+ GROUPBOX "Statuses various", IDC_STATIC, 150, 90, 138, 74
+ CONTROL "Global status", IDC_ICON_GLOBAL_V, "Button", BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP, 156, 100, 97, 10
+ CONTROL "Single account", IDC_ICON_ACC_V, "Button", BS_AUTORADIOBUTTON, 156, 116, 60, 10
+ CONTROL "Cycle icons", IDC_ICON_CYCLE_V, "Button", BS_AUTORADIOBUTTON, 156, 132, 97, 10
+ CONTROL "All accounts", IDC_ICON_ALL_V, "Button", BS_AUTORADIOBUTTON, 156, 148, 97, 10
+ COMBOBOX IDC_PRIMARYSTATUS_V, 222, 114, 60, 101, CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP | WS_DISABLED
+
+ EDITTEXT IDC_CYCLETIME, 88, 170, 29, 12, ES_RIGHT | ES_NUMBER
+ CONTROL "", IDC_CYCLETIMESPIN, "msctls_updown32",
+ UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK, 80, 170, 11, 14
+ LTEXT "Cycle period, seconds", IDC_STATIC, 8, 172, 80, 8
+
END
IDD_OPT_META_CLC DIALOGEX 0, 0, 225, 186
diff --git a/plugins/Clist_modern/src/hdr/modern_clc.h b/plugins/Clist_modern/src/hdr/modern_clc.h
index c335a078ba..f5fb9b2222 100644
--- a/plugins/Clist_modern/src/hdr/modern_clc.h
+++ b/plugins/Clist_modern/src/hdr/modern_clc.h
@@ -32,9 +32,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "modern_defsettings.h"
#include "modern_clist.h"
-#define SETTING_TRAYICON_SINGLE 0
-#define SETTING_TRAYICON_CYCLE 1
-#define SETTING_TRAYICON_MULTI 2
+// Новый формат настроек.
+#define TRAY_ICON_MODE_GLOBAL 1
+#define TRAY_ICON_MODE_ACC 2
+#define TRAY_ICON_MODE_CYCLE 4
+#define TRAY_ICON_MODE_ALL 8
#define NIIF_INTERN_UNICODE 0x00000100
diff --git a/plugins/Clist_modern/src/hdr/modern_commonprototypes.h b/plugins/Clist_modern/src/hdr/modern_commonprototypes.h
index 339cc83eb1..a4bb5bfaab 100644
--- a/plugins/Clist_modern/src/hdr/modern_commonprototypes.h
+++ b/plugins/Clist_modern/src/hdr/modern_commonprototypes.h
@@ -282,7 +282,6 @@ int cliShowHide(WPARAM wParam, LPARAM lParam);
BOOL CLUI__cliInvalidateRect(HWND hWnd, CONST RECT* lpRect, BOOL bErase);
int cliCompareContacts(const ClcContact *contact1, const ClcContact *contact2);
int cliFindItem(HWND hwnd, ClcData *dat, DWORD dwItem, ClcContact **contact, ClcGroup **subgroup, int *isVisible);
-int cliTrayCalcChanged(const char *szChangedProto, int averageMode, int netProtoCount);
int cliTrayIconPauseAutoHide(WPARAM wParam, LPARAM lParam);
void cliCluiProtocolStatusChanged(int status, const char * proto);
HMENU cliBuildGroupPopupMenu(ClcGroup *group);
@@ -292,6 +291,9 @@ void cli_SaveStateAndRebuildList(HWND hwnd, ClcData *dat);
void CLUI_cli_LoadCluiGlobalOpts(void);
INT_PTR cli_TrayIconProcessMessage(WPARAM wParam, LPARAM lParam);
BOOL CLUI__cliInvalidateRect(HWND hWnd, CONST RECT* lpRect, BOOL bErase);
+int cliTrayIconInit(HWND hwnd);
+int cliTrayIconAdd(HWND hwnd, const char *szProto, const char *szIconProto, int status);
+void cliTrayIconUpdateBase(const char *szChangedProto);
ClcContact* cliCreateClcContact(void);
ClcCacheEntry* cliCreateCacheItem(MCONTACT hContact);
diff --git a/plugins/Clist_modern/src/init.cpp b/plugins/Clist_modern/src/init.cpp
index ef12820536..438149c564 100644
--- a/plugins/Clist_modern/src/init.cpp
+++ b/plugins/Clist_modern/src/init.cpp
@@ -144,7 +144,10 @@ static HRESULT SubclassClistInterface()
pcli->pfnInvalidateDisplayNameCacheEntry = cliInvalidateDisplayNameCacheEntry;
pcli->pfnTrayIconPauseAutoHide = cliTrayIconPauseAutoHide;
- pcli->pfnTrayCalcChanged = cliTrayCalcChanged;
+ pcli->pfnTrayIconInit = cliTrayIconInit;
+ pcli->pfnTrayIconAdd = cliTrayIconAdd;
+ pcli->pfnTrayIconUpdateBase = cliTrayIconUpdateBase;
+
pcli->pfnCluiProtocolStatusChanged = cliCluiProtocolStatusChanged;
pcli->pfnBeginRenameSelection = cliBeginRenameSelection;
diff --git a/plugins/Clist_modern/src/modern_clcopts.cpp b/plugins/Clist_modern/src/modern_clcopts.cpp
index dc5381db09..ea0f7a68e0 100644
--- a/plugins/Clist_modern/src/modern_clcopts.cpp
+++ b/plugins/Clist_modern/src/modern_clcopts.cpp
@@ -594,86 +594,93 @@ static INT_PTR CALLBACK DlgProcTrayOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
switch (msg) {
case WM_INITDIALOG:
TranslateDialogDefault(hwndDlg);
+
+ CheckDlgButton(hwndDlg, IDC_NOOFFLINEMOVE, db_get_b(NULL, "CList", "NoOfflineBottom", SETTING_NOOFFLINEBOTTOM_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_OFFLINETOROOT, db_get_b(NULL, "CList", "PlaceOfflineToRoot", SETTING_PLACEOFFLINETOROOT_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_ONECLK, db_get_b(NULL, "CList", "Tray1Click", SETTING_TRAY1CLICK_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
{
- CheckDlgButton(hwndDlg, IDC_NOOFFLINEMOVE, db_get_b(NULL, "CList", "NoOfflineBottom", SETTING_NOOFFLINEBOTTOM_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_OFFLINETOROOT, db_get_b(NULL, "CList", "PlaceOfflineToRoot", SETTING_PLACEOFFLINETOROOT_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_ONECLK, db_get_b(NULL, "CList", "Tray1Click", SETTING_TRAY1CLICK_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
- {
- BYTE trayOption = db_get_b(NULL, "CLUI", "XStatusTray", SETTING_TRAYOPTION_DEFAULT);
- CheckDlgButton(hwndDlg, IDC_SHOWXSTATUS, (trayOption & 3) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_SHOWNORMAL, (trayOption & 2) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_TRANSPARENTOVERLAY, (trayOption & 4) ? BST_CHECKED : BST_UNCHECKED);
+ BYTE trayOption = db_get_b(NULL, "CLUI", "XStatusTray", SETTING_TRAYOPTION_DEFAULT);
+ CheckDlgButton(hwndDlg, IDC_SHOWXSTATUS, (trayOption & 3) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_SHOWNORMAL, (trayOption & 2) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_TRANSPARENTOVERLAY, (trayOption & 4) ? BST_CHECKED : BST_UNCHECKED);
- EnableWindow(GetDlgItem(hwndDlg, IDC_SHOWNORMAL), IsDlgButtonChecked(hwndDlg, IDC_SHOWXSTATUS));
- EnableWindow(GetDlgItem(hwndDlg, IDC_TRANSPARENTOVERLAY), IsDlgButtonChecked(hwndDlg, IDC_SHOWXSTATUS) && IsDlgButtonChecked(hwndDlg, IDC_SHOWNORMAL));
- }
- CheckDlgButton(hwndDlg, IDC_ALWAYSSTATUS, db_get_b(NULL, "CList", "AlwaysStatus", SETTING_ALWAYSSTATUS_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
-
- CheckDlgButton(hwndDlg, IDC_ALWAYSPRIMARY, !db_get_b(NULL, "CList", "AlwaysPrimary", SETTING_ALWAYSPRIMARY_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
-
- CheckDlgButton(hwndDlg, IDC_ALWAYSMULTI, !db_get_b(NULL, "CList", "AlwaysMulti", SETTING_ALWAYSMULTI_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_DONTCYCLE, db_get_b(NULL, "CList", "TrayIcon", SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_SINGLE ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_CYCLE, db_get_b(NULL, "CList", "TrayIcon", SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_CYCLE ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_MULTITRAY, db_get_b(NULL, "CList", "TrayIcon", SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_MULTI ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_DISABLEBLINK, db_get_b(NULL, "CList", "DisableTrayFlash", SETTING_DISABLETRAYFLASH_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_SHOW_AVATARS, db_get_b(NULL, "CList", "AvatarsShow", SETTINGS_SHOWAVATARS_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED);
- CheckDlgButton(hwndDlg, IDC_SHOW_ANIAVATARS, db_get_b(NULL, "CList", "AvatarsAnimated", ServiceExists(MS_AV_GETAVATARBITMAP)) == 1 ? BST_CHECKED : BST_UNCHECKED);
-
- if (IsDlgButtonChecked(hwndDlg, IDC_DONTCYCLE)) {
- EnableWindow(GetDlgItem(hwndDlg, IDC_CYCLETIMESPIN), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CYCLETIME), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_ALWAYSMULTI), FALSE);
- }
- if (IsDlgButtonChecked(hwndDlg, IDC_CYCLE)) {
- EnableWindow(GetDlgItem(hwndDlg, IDC_PRIMARYSTATUS), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_ALWAYSMULTI), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_ALWAYSPRIMARY), FALSE);
- }
- if (IsDlgButtonChecked(hwndDlg, IDC_MULTITRAY)) {
- EnableWindow(GetDlgItem(hwndDlg, IDC_CYCLETIMESPIN), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CYCLETIME), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_PRIMARYSTATUS), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_ALWAYSPRIMARY), FALSE);
- }
- SendDlgItemMessage(hwndDlg, IDC_CYCLETIMESPIN, UDM_SETRANGE, 0, MAKELONG(120, 1));
- SendDlgItemMessage(hwndDlg, IDC_CYCLETIMESPIN, UDM_SETPOS, 0, MAKELONG(db_get_w(NULL, "CList", "CycleTime", SETTING_CYCLETIME_DEFAULT), 0));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SHOWNORMAL), IsDlgButtonChecked(hwndDlg, IDC_SHOWXSTATUS));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_TRANSPARENTOVERLAY), IsDlgButtonChecked(hwndDlg, IDC_SHOWXSTATUS) && IsDlgButtonChecked(hwndDlg, IDC_SHOWNORMAL));
+ }
+ CheckDlgButton(hwndDlg, IDC_ALWAYSSTATUS, db_get_b(NULL, "CList", "AlwaysStatus", SETTING_ALWAYSSTATUS_DEFAULT) ? BST_CHECKED : BST_UNCHECKED);
+
+ CheckDlgButton(hwndDlg, IDC_DISABLEBLINK, db_get_b(NULL, "CList", "DisableTrayFlash", SETTING_DISABLETRAYFLASH_DEFAULT) == 1 ? BST_CHECKED : BST_UNCHECKED);
+ SendDlgItemMessage(hwndDlg, IDC_BLINKSPIN, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_BLINKTIME), 0); // set buddy
+ SendDlgItemMessage(hwndDlg, IDC_BLINKSPIN, UDM_SETRANGE, 0, MAKELONG(0x3FFF, 250));
+ SendDlgItemMessage(hwndDlg, IDC_BLINKSPIN, UDM_SETPOS, 0, MAKELONG(db_get_w(NULL, "CList", "IconFlashTime", SETTING_ICONFLASHTIME_DEFAULT), 0));
+
+ // == Tray icon mode ==
+ // Готовим список аккаунтов.
+ {
+ int AccNum, i, siS, siV, item;
+ PROTOACCOUNT **acc;
+
+ ProtoEnumAccounts(&AccNum, &acc);
+
+ for (siS = siV = -1, i = 0; i < AccNum; i++)
{
- int i, count, item;
- PROTOACCOUNT **accs;
- DBVARIANT dbv = { DBVT_DELETED };
- db_get(NULL, "CList", "PrimaryStatus", &dbv);
- ProtoEnumAccounts(&count, &accs);
- item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_ADDSTRING, 0, (LPARAM)TranslateT("Global"));
- SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_SETITEMDATA, item, 0);
- for (i = 0; i < count; i++) {
- if (!IsAccountEnabled(accs[i]) || CallProtoService(accs[i]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0) == 0)
- continue;
+ if (!acc[i]->bIsVirtual && acc[i]->bIsVisible && !acc[i]->bDynDisabled)
+ {
+ item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_S, CB_ADDSTRING, 0, (LPARAM)acc[i]->tszAccountName);
+ SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_S, CB_SETITEMDATA, item, (LPARAM)acc[i]);
+
+ if (!strcmp(acc[i]->szModuleName, db_get_sa(NULL, "CList", "tiAccS")))
+ siS = item;
+
+ item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_V, CB_ADDSTRING, 0, (LPARAM)acc[i]->tszAccountName);
+ SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_V, CB_SETITEMDATA, item, (LPARAM)acc[i]);
+
+ if (!strcmp(acc[i]->szModuleName, db_get_sa(NULL, "CList", "tiAccV")))
+ siV = item;
- item = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_ADDSTRING, 0, (LPARAM)accs[i]->tszAccountName);
- SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_SETITEMDATA, item, (LPARAM)accs[i]);
- if ((dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_UTF8) && !mir_strcmp(dbv.pszVal, accs[i]->szModuleName))
- SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_SETCURSEL, item, 0);
}
- db_free(&dbv);
- }
- if (-1 == (int)SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_GETCURSEL, 0, 0))
- SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_SETCURSEL, 0, 0);
- SendDlgItemMessage(hwndDlg, IDC_BLINKSPIN, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, IDC_BLINKTIME), 0); // set buddy
- SendDlgItemMessage(hwndDlg, IDC_BLINKSPIN, UDM_SETRANGE, 0, MAKELONG(0x3FFF, 250));
- SendDlgItemMessage(hwndDlg, IDC_BLINKSPIN, UDM_SETPOS, 0, MAKELONG(db_get_w(NULL, "CList", "IconFlashTime", SETTING_ICONFLASHTIME_DEFAULT), 0));
-
- int i = _GetNetVisibleProtoCount();
- if (i < 2) {
- EnableWindow(GetDlgItem(hwndDlg, IDC_PRIMARYSTATUS), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CYCLETIMESPIN), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CYCLETIME), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_ALWAYSPRIMARY), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_ALWAYSPRIMARY), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_CYCLE), FALSE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_MULTITRAY), FALSE);
- CheckDlgButton(hwndDlg, IDC_DONTCYCLE, BST_CHECKED);
}
+ if (siS < 0) siS = 0; if (siV < 0) siV = 0; // Пустой элемент в качестве выбранного оставлять нельзя.
+ SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_S, CB_SETCURSEL, siS, 0);
+ SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_V, CB_SETCURSEL, siV, 0);
}
+ // Какой период смены иконок?
+ SendDlgItemMessage(hwndDlg, IDC_CYCLETIMESPIN, UDM_SETRANGE, 0, MAKELONG(120, 1));
+ SendDlgItemMessage(hwndDlg, IDC_CYCLETIMESPIN, UDM_SETPOS, 0, MAKELONG(db_get_w(NULL, "CList", "CycleTime", SETTING_CYCLETIME_DEFAULT), 0));
+ // Какой режим иконок?
+ switch (db_get_b(NULL, "CList", "tiModeS", TRAY_ICON_MODE_GLOBAL))
+ {
+ case TRAY_ICON_MODE_GLOBAL:
+ CheckDlgButton(hwndDlg, IDC_ICON_GLOBAL_S, 1);
+ break;
+ case TRAY_ICON_MODE_ACC:
+ CheckDlgButton(hwndDlg, IDC_ICON_ACC_S, 1);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PRIMARYSTATUS_S), TRUE);
+ break;
+ case TRAY_ICON_MODE_CYCLE:
+ CheckDlgButton(hwndDlg, IDC_ICON_CYCLE_S, 1);
+ break;
+ case TRAY_ICON_MODE_ALL:
+ CheckDlgButton(hwndDlg, IDC_ICON_ALL_S, 1);
+ break;
+ }
+ switch (db_get_b(NULL, "CList", "tiModeV", TRAY_ICON_MODE_GLOBAL))
+ {
+ case TRAY_ICON_MODE_GLOBAL:
+ CheckDlgButton(hwndDlg, IDC_ICON_GLOBAL_V, 1);
+ break;
+ case TRAY_ICON_MODE_ACC:
+ CheckDlgButton(hwndDlg, IDC_ICON_ACC_V, 1);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PRIMARYSTATUS_V), TRUE);
+ break;
+ case TRAY_ICON_MODE_CYCLE:
+ CheckDlgButton(hwndDlg, IDC_ICON_CYCLE_V, 1);
+ break;
+ case TRAY_ICON_MODE_ALL:
+ CheckDlgButton(hwndDlg, IDC_ICON_ALL_V, 1);
+ break;
+ }
+
return TRUE;
case WM_COMMAND:
@@ -681,14 +688,21 @@ static INT_PTR CALLBACK DlgProcTrayOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
EnableWindow(GetDlgItem(hwndDlg, IDC_SHOWNORMAL), IsDlgButtonChecked(hwndDlg, IDC_SHOWXSTATUS));
EnableWindow(GetDlgItem(hwndDlg, IDC_TRANSPARENTOVERLAY), IsDlgButtonChecked(hwndDlg, IDC_SHOWXSTATUS) && IsDlgButtonChecked(hwndDlg, IDC_SHOWNORMAL));
}
- if (LOWORD(wParam) == IDC_DONTCYCLE || LOWORD(wParam) == IDC_CYCLE || LOWORD(wParam) == IDC_MULTITRAY) {
- EnableWindow(GetDlgItem(hwndDlg, IDC_PRIMARYSTATUS), IsDlgButtonChecked(hwndDlg, IDC_DONTCYCLE));
- EnableWindow(GetDlgItem(hwndDlg, IDC_CYCLETIME), IsDlgButtonChecked(hwndDlg, IDC_CYCLE));
- EnableWindow(GetDlgItem(hwndDlg, IDC_CYCLETIMESPIN), IsDlgButtonChecked(hwndDlg, IDC_CYCLE));
- EnableWindow(GetDlgItem(hwndDlg, IDC_ALWAYSMULTI), IsDlgButtonChecked(hwndDlg, IDC_MULTITRAY));
- EnableWindow(GetDlgItem(hwndDlg, IDC_ALWAYSPRIMARY), IsDlgButtonChecked(hwndDlg, IDC_DONTCYCLE));
- }
- if (LOWORD(wParam) == IDC_PRIMARYSTATUS && HIWORD(wParam) != CBN_SELCHANGE)
+
+ if ( LOWORD(wParam) == IDC_ICON_GLOBAL_S
+ || LOWORD(wParam) == IDC_ICON_ACC_S
+ || LOWORD(wParam) == IDC_ICON_CYCLE_S
+ || LOWORD(wParam) == IDC_ICON_ALL_S)
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PRIMARYSTATUS_S), IsDlgButtonChecked(hwndDlg, IDC_ICON_ACC_S));
+ if ( LOWORD(wParam) == IDC_ICON_GLOBAL_V
+ || LOWORD(wParam) == IDC_ICON_ACC_V
+ || LOWORD(wParam) == IDC_ICON_CYCLE_V
+ || LOWORD(wParam) == IDC_ICON_ALL_V)
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PRIMARYSTATUS_V), IsDlgButtonChecked(hwndDlg, IDC_ICON_ACC_V));
+
+ if (LOWORD(wParam) == IDC_PRIMARYSTATUS_S && HIWORD(wParam) != CBN_SELCHANGE)
+ return 0;
+ if (LOWORD(wParam) == IDC_PRIMARYSTATUS_V && HIWORD(wParam) != CBN_SELCHANGE)
return 0;
if ((LOWORD(wParam) == IDC_BLINKTIME || LOWORD(wParam) == IDC_CYCLETIME) && (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus()))
return 0;
@@ -703,28 +717,39 @@ static INT_PTR CALLBACK DlgProcTrayOpts(HWND hwndDlg, UINT msg, WPARAM wParam, L
db_set_b(NULL, "CList", "Tray1Click", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ONECLK));
db_set_b(NULL, "CList", "AlwaysStatus", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ALWAYSSTATUS));
- db_set_b(NULL, "CList", "AlwaysMulti", (BYTE)BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_ALWAYSMULTI));
- db_set_b(NULL, "CList", "AlwaysPrimary", (BYTE)BST_UNCHECKED == IsDlgButtonChecked(hwndDlg, IDC_ALWAYSPRIMARY));
-
- db_set_w(NULL, "CList", "CycleTime", (WORD)SendDlgItemMessage(hwndDlg, IDC_CYCLETIMESPIN, UDM_GETPOS, 0, 0));
db_set_w(NULL, "CList", "IconFlashTime", (WORD)SendDlgItemMessage(hwndDlg, IDC_BLINKSPIN, UDM_GETPOS, 0, 0));
db_set_b(NULL, "CList", "DisableTrayFlash", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DISABLEBLINK));
- if (_GetNetVisibleProtoCount() > 1)
- db_set_b(NULL, "CList", "TrayIcon", (BYTE)(IsDlgButtonChecked(hwndDlg, IDC_DONTCYCLE) ? SETTING_TRAYICON_SINGLE : (IsDlgButtonChecked(hwndDlg, IDC_CYCLE) ? SETTING_TRAYICON_CYCLE : SETTING_TRAYICON_MULTI)));
-
BYTE xOptions = 0;
xOptions = IsDlgButtonChecked(hwndDlg, IDC_SHOWXSTATUS) ? 1 : 0;
xOptions |= (xOptions && IsDlgButtonChecked(hwndDlg, IDC_SHOWNORMAL)) ? 2 : 0;
xOptions |= (xOptions && IsDlgButtonChecked(hwndDlg, IDC_TRANSPARENTOVERLAY)) ? 4 : 0;
db_set_b(NULL, "CLUI", "XStatusTray", xOptions);
- int cursel = SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_GETCURSEL, 0, 0);
- PROTOACCOUNT *pa = (PROTOACCOUNT *)SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS, CB_GETITEMDATA, cursel, 0);
- if (!pa)
- db_unset(NULL, "CList", "PrimaryStatus");
- else
- db_set_s(NULL, "CList", "PrimaryStatus", pa->szModuleName);
+ // == Tray icon mode ==
+ // Имя выбранного аккаунта.
+ {
+ PROTOACCOUNT *pa;
+ pa = (PROTOACCOUNT*)SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_S, CB_GETITEMDATA,
+ SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_S, CB_GETCURSEL, 0, 0), 0);
+ db_set_s(NULL, "CList", "tiAccS", pa->szModuleName);
+ pa = (PROTOACCOUNT*)SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_V, CB_GETITEMDATA,
+ SendDlgItemMessage(hwndDlg, IDC_PRIMARYSTATUS_V, CB_GETCURSEL, 0, 0), 0);
+ db_set_s(NULL, "CList", "tiAccV", pa->szModuleName);
+ }
+ // Период смены иконок.
+ db_set_w(NULL, "CList", "CycleTime", (WORD)SendDlgItemMessage(hwndDlg, IDC_CYCLETIMESPIN, UDM_GETPOS, 0, 0));
+ // Режим иконок.
+ db_set_b(NULL, "CList", "tiModeS",
+ IsDlgButtonChecked(hwndDlg, IDC_ICON_GLOBAL_S) << 0
+ | IsDlgButtonChecked(hwndDlg, IDC_ICON_ACC_S) << 1
+ | IsDlgButtonChecked(hwndDlg, IDC_ICON_CYCLE_S) << 2
+ | IsDlgButtonChecked(hwndDlg, IDC_ICON_ALL_S) << 3);
+ db_set_b(NULL, "CList", "tiModeV",
+ IsDlgButtonChecked(hwndDlg, IDC_ICON_GLOBAL_V) << 0
+ | IsDlgButtonChecked(hwndDlg, IDC_ICON_ACC_V) << 1
+ | IsDlgButtonChecked(hwndDlg, IDC_ICON_CYCLE_V) << 2
+ | IsDlgButtonChecked(hwndDlg, IDC_ICON_ALL_V) << 3);
pcli->pfnTrayIconIconsChanged();
pcli->pfnLoadContactTree(); /* this won't do job properly since it only really works when changes happen */
diff --git a/plugins/Clist_modern/src/modern_clisttray.cpp b/plugins/Clist_modern/src/modern_clisttray.cpp
index 1684796c9f..5d369333cc 100644
--- a/plugins/Clist_modern/src/modern_clisttray.cpp
+++ b/plugins/Clist_modern/src/modern_clisttray.cpp
@@ -27,6 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "hdr/modern_clist.h"
#include "hdr/modern_commonprototypes.h"
#include "hdr/modern_statusbar.h"
+#include <m_protoint.h>
int g_mutex_bOnTrayRightClick = 0;
BOOL g_bMultiConnectionMode = FALSE;
@@ -62,7 +63,6 @@ void mir_strset(TCHAR ** dest, TCHAR *source)
if (source) *dest = mir_tstrdup(source);
}
-static DLLVERSIONINFO dviShell;
BOOL g_MultiConnectionMode = FALSE;
char * g_szConnectingProto = NULL;
int GetStatusVal(int status)
@@ -108,7 +108,6 @@ INT_PTR CListTray_GetGlobalStatus(WPARAM, LPARAM)
curstatus = GetStatusOrder(curstatus, p.dwStatus);
}
if (connectingCount == 0) {
- //g_szConnectingProto = NULL;
g_bMultiConnectionMode = FALSE;
}
else if (connectingCount > 1)
@@ -120,131 +119,6 @@ INT_PTR CListTray_GetGlobalStatus(WPARAM, LPARAM)
/////////////////////////////////////////////////////////////////////////////////////////
-int cliTrayCalcChanged(const char *szChangedProto, int averageMode, int netProtoCount)
-{
- HWND hwnd = pcli->hwndContactList;
- HICON hIcon;
- int status;
-
- if (netProtoCount > 1) {
- if (averageMode >= ID_STATUS_OFFLINE) {
- if (db_get_b(NULL, "CList", "TrayIcon", SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_MULTI) {
- if (db_get_b(NULL, "CList", "AlwaysMulti", SETTING_ALWAYSMULTI_DEFAULT))
- return pcli->pfnTrayIconSetBaseInfo(cliGetIconFromStatusMode(NULL, szChangedProto, averageMode), szChangedProto);
-
- if (pcli->trayIcon == NULL || pcli->trayIcon[0].szProto == NULL)
- return pcli->pfnTrayIconSetBaseInfo(cliGetIconFromStatusMode(NULL, NULL, averageMode), NULL);
-
- pcli->pfnTrayIconDestroy(hwnd);
- pcli->pfnTrayIconInit(hwnd);
- }
- else {
- if (db_get_b(NULL, "CList", "TrayIcon", SETTING_TRAYICON_DEFAULT) == SETTING_TRAYICON_SINGLE &&
- db_get_b(NULL, "CList", "AlwaysPrimary", SETTING_ALWAYSPRIMARY_DEFAULT)) {
- ptrA szProto(db_get_sa(NULL, "CList", "PrimaryStatus"));
- return pcli->pfnTrayIconSetBaseInfo(cliGetIconFromStatusMode(NULL, szProto, averageMode), NULL);
- }
- return pcli->pfnTrayIconSetBaseInfo(cliGetIconFromStatusMode(NULL, NULL, averageMode), NULL);
- }
- }
- else {
- switch (db_get_b(NULL, "CList", "TrayIcon", SETTING_TRAYICON_DEFAULT)) {
- case SETTING_TRAYICON_SINGLE:
- status = CallProtoService(szChangedProto, PS_GETSTATUS, 0, 0);
-
- if (g_StatusBarData.bConnectingIcon && status >= ID_STATUS_CONNECTING && status <= ID_STATUS_CONNECTING + MAX_CONNECT_RETRIES) {
- // 1 check if multi connecting icon
- CListTray_GetGlobalStatus(0, 0);
- if (g_bMultiConnectionMode) {
- if (_strcmpi(szChangedProto, g_szConnectingProto))
- return -1;
-
- hIcon = (HICON)CLUI_GetConnectingIconService(NULL, 1);
- }
- else hIcon = (HICON)CLUI_GetConnectingIconService((WPARAM)szChangedProto, 0);
- }
- else {
- ptrA szProto(db_get_sa(NULL, "CList", "PrimaryStatus"));
- hIcon = cliGetIconFromStatusMode(NULL, szProto, (szProto) ? CallProtoService(szProto, PS_GETSTATUS, 0, 0) : CallService(MS_CLIST_GETSTATUSMODE, 0, 0));
- }
- if (hIcon)
- return pcli->pfnTrayIconSetBaseInfo(hIcon, NULL);
- break;
-
- case SETTING_TRAYICON_CYCLE:
- status = szChangedProto ? CallProtoService(szChangedProto, PS_GETSTATUS, 0, 0) : averageMode;
- if (g_StatusBarData.bConnectingIcon && CListTray_GetGlobalStatus(0, 0) &&
- ((status >= ID_STATUS_CONNECTING && status <= ID_STATUS_CONNECTING + MAX_CONNECT_RETRIES) || g_bMultiConnectionMode)) {
- //stop cycling
- if (pcli->cycleTimerId)
- KillTimer(NULL, pcli->cycleTimerId);
- pcli->cycleTimerId = 0;
-
- // 1 check if multi connecting icon
- if (g_bMultiConnectionMode) {
- if (_strcmpi(szChangedProto, g_szConnectingProto))
- return -1;
- hIcon = (HICON)CLUI_GetConnectingIconService((WPARAM)"", 1);
- }
- else hIcon = (HICON)CLUI_GetConnectingIconService((WPARAM)szChangedProto, 0);
- if (hIcon)
- return pcli->pfnTrayIconSetBaseInfo(hIcon, NULL);
- }
- else {
- pcli->cycleTimerId = CLUI_SafeSetTimer(NULL, 0, db_get_w(NULL, "CList", "CycleTime", SETTING_CYCLETIME_DEFAULT) * 1000, pcli->pfnTrayCycleTimerProc);
- return pcli->pfnTrayIconSetBaseInfo(cliGetIconFromStatusMode(NULL, szChangedProto, status), NULL);
- }
- break;
-
- case SETTING_TRAYICON_MULTI:
- if (!pcli->trayIcon)
- pcli->pfnTrayIconRemove(NULL, NULL);
- else if (db_get_b(NULL, "CList", "AlwaysMulti", SETTING_ALWAYSMULTI_DEFAULT)) {
- if (!pcli->pfnGetProtocolVisibility(szChangedProto))
- return -1;
-
- status = CallProtoService(szChangedProto, PS_GETSTATUS, 0, 0);
- if (g_StatusBarData.bConnectingIcon && status >= ID_STATUS_CONNECTING && status <= ID_STATUS_CONNECTING + MAX_CONNECT_RETRIES)
- hIcon = (HICON)CLUI_GetConnectingIconService((WPARAM)szChangedProto, 0);
- else
- hIcon = cliGetIconFromStatusMode(NULL, szChangedProto, CallProtoService(szChangedProto, PS_GETSTATUS, 0, 0));
- if (hIcon)
- return pcli->pfnTrayIconSetBaseInfo(hIcon, szChangedProto);
- }
- else if (pcli->pfnGetProtocolVisibility(szChangedProto)) {
- int i = pcli->pfnTrayIconSetBaseInfo(cliGetIconFromStatusMode(NULL, szChangedProto, CallProtoService(szChangedProto, PS_GETSTATUS, 0, 0)), szChangedProto);
- if (i < 0) {
- pcli->pfnTrayIconDestroy(hwnd);
- pcli->pfnTrayIconInit(hwnd);
- return -1;
- }
-
- status = CallProtoService(szChangedProto, PS_GETSTATUS, 0, 0);
- if (g_StatusBarData.bConnectingIcon && status >= ID_STATUS_CONNECTING && status <= ID_STATUS_CONNECTING + MAX_CONNECT_RETRIES)
- if (hIcon = (HICON)CLUI_GetConnectingIconService((WPARAM)szChangedProto, 0))
- return pcli->pfnTrayIconSetBaseInfo(hIcon, szChangedProto);
-
- return i;
- }
- break;
- }
- }
- }
- else if (pcli->pfnGetProtocolVisibility(szChangedProto)) {
- status = CallProtoService(szChangedProto, PS_GETSTATUS, 0, 0);
-
- if (g_StatusBarData.bConnectingIcon && status >= ID_STATUS_CONNECTING && status <= ID_STATUS_CONNECTING + MAX_CONNECT_RETRIES) {
- if (hIcon = (HICON)CLUI_GetConnectingIconService((WPARAM)szChangedProto, 0))
- return pcli->pfnTrayIconSetBaseInfo(hIcon, NULL);
- }
- else if (status >= ID_STATUS_OFFLINE && status <= ID_STATUS_IDLE) {
- ptrA szProto(db_get_sa(NULL, "CList", "PrimaryStatus"));
- return pcli->pfnTrayIconSetBaseInfo(cliGetIconFromStatusMode(NULL, szProto, status), NULL);
- }
- }
-
- return -1;
-}
static UINT_PTR autoHideTimerId;
@@ -277,7 +151,7 @@ void DestroyTrayMenu(HMENU hMenu)
int cnt = GetMenuItemCount(hMenu);
for (int i = 0; i < cnt; ++i) {
HMENU hSubMenu = GetSubMenu(hMenu, i);
- if (hSubMenu && (hSubMenu == hStatusMenu || hSubMenu == hMainMenu))
+ if (hSubMenu && ((hSubMenu == hStatusMenu) || (hSubMenu == hMainMenu)))
RemoveMenu(hMenu, i--, MF_BYPOSITION);
}
DestroyMenu(hMenu);
@@ -391,6 +265,10 @@ INT_PTR cli_TrayIconProcessMessage(WPARAM wParam, LPARAM lParam)
}
return FALSE; //to avoid autohideTimer in core
+ case TIM_CREATE:
+ pcli->pfnTrayIconInit(msg->hwnd);
+ return TRUE;
+
case TIM_CALLBACK:
if ((GetAsyncKeyState(VK_CONTROL) & 0x8000) && msg->lParam == WM_LBUTTONDOWN && !db_get_b(NULL, "CList", "Tray1Click", SETTING_TRAY1CLICK_DEFAULT)) {
POINT pt;
@@ -503,3 +381,365 @@ void UninitTrayMenu()
hTrayMenuObject = NULL;
}
}
+
+
+VOID CALLBACK cliTrayCycleTimerProc(HWND, UINT, UINT_PTR, DWORD)
+{
+ PROTOACCOUNT **acc;
+ int AccNum, t;
+
+ if (!pcli->trayIconCount)
+ return;
+
+ ProtoEnumAccounts(&AccNum, &acc);
+
+ // Нужно найти подходящий аккаунт, чтобы показать его значок.
+ t = pcli->cycleStep;
+ do
+ {
+ pcli->cycleStep = (pcli->cycleStep + 1) % AccNum;
+ if (pcli->cycleStep == t)
+ return;
+ }
+ while (acc[pcli->cycleStep]->bIsVirtual || !acc[pcli->cycleStep]->bIsVisible);
+
+ cliTrayIconUpdateBase(acc[pcli->cycleStep]->szModuleName);
+}
+
+// INFO Эта функция устанавливает настройки по умолчанию при создании
+// нового профиля. Также она выполняет перевод старых настроек в новый формат.
+void SettingsMigrate(void)
+{
+ BYTE TrayIcon, AlwaysPrimary, AlwaysMulti;
+ char *PrimaryStatus;
+
+ // Получаем все старые настроки иконок трея.
+ TrayIcon = db_get_b(NULL, "CList", "TrayIcon", 0);
+ AlwaysPrimary = db_get_b(NULL, "CList", "AlwaysPrimary", 1);
+ AlwaysMulti = db_get_b(NULL, "CList", "AlwaysMulti", 0);
+ PrimaryStatus = db_get_sa(NULL, "CList", "PrimaryStatus");
+
+ // Эти строки обязательно должны присутствовать.
+ db_set_s(NULL, "CList", "tiAccS", "");
+ db_set_s(NULL, "CList", "tiAccV", "");
+
+ // Нужно вычислить новый режим.
+ switch (TrayIcon)
+ {
+ case 0: // global or single acc
+ if (AlwaysPrimary)
+ {
+ if (!PrimaryStatus) // global always
+ {
+ db_set_b(NULL, "CList", "tiModeS", TRAY_ICON_MODE_GLOBAL);
+ db_set_b(NULL, "CList", "tiModeV", TRAY_ICON_MODE_GLOBAL);
+ }
+ else // single acc always
+ {
+ db_set_b(NULL, "CList", "tiModeS", TRAY_ICON_MODE_ACC);
+ db_set_b(NULL, "CList", "tiModeV", TRAY_ICON_MODE_ACC);
+ db_set_s(NULL, "CList", "tiAccS", PrimaryStatus);
+ db_set_s(NULL, "CList", "tiAccV", PrimaryStatus);
+ }
+ }
+ else
+ {
+ if (!PrimaryStatus) // global if various
+ {
+ db_set_b(NULL, "CList", "tiModeS", TRAY_ICON_MODE_ALL);
+ db_set_b(NULL, "CList", "tiModeV", TRAY_ICON_MODE_GLOBAL);
+ }
+ else // single acc if various
+ {
+ db_set_b(NULL, "CList", "tiModeS", TRAY_ICON_MODE_GLOBAL);
+ db_set_b(NULL, "CList", "tiModeV", TRAY_ICON_MODE_ACC);
+ db_set_s(NULL, "CList", "tiAccS", PrimaryStatus);
+ db_set_s(NULL, "CList", "tiAccV", PrimaryStatus);
+ }
+ }
+ break;
+ case 1: // cycle
+ db_set_b(NULL, "CList", "tiModeS", TRAY_ICON_MODE_CYCLE);
+ db_set_b(NULL, "CList", "tiModeV", TRAY_ICON_MODE_CYCLE);
+ break;
+ case 2: // multiple
+ switch (AlwaysMulti)
+ {
+ case 0: // all accs if differ
+ db_set_b(NULL, "CList", "tiModeS", TRAY_ICON_MODE_GLOBAL);
+ db_set_b(NULL, "CList", "tiModeV", TRAY_ICON_MODE_ALL);
+ break;
+ case 1: // all accs always
+ db_set_b(NULL, "CList", "tiModeS", TRAY_ICON_MODE_ALL);
+ db_set_b(NULL, "CList", "tiModeV", TRAY_ICON_MODE_ALL);
+ break;
+ }
+ break;
+ }
+}
+
+/* Функция вычисляет два параметра: количество годных аккаунтов и признак
+ * неравнозначности их статусов. */
+int GetGoodAccNum(BYTE *Var)
+{
+ PROTOACCOUNT **acc;
+ int AccNum, i;
+ WORD s;
+ BYTE d;
+
+ ProtoEnumAccounts(&AccNum, &acc);
+
+ // Узнать количество аккаунтов, которые заслуживают того,
+ // чтобы быть показанными в трее. Это все аккаунты, кроме
+ // виртуальных, скрытых и тех, чьи DLL не были загружены.
+ // Заодно можно узнать одинаковые статусы или нет.
+ d = 0;
+ for (i = AccNum, AccNum = 0; i--; )
+ {
+ if (!acc[i]->bIsVirtual && acc[i]->bIsVisible && !acc[i]->bDynDisabled)
+ {
+ AccNum++;
+ if (!d)
+ {
+ s = acc[i]->ppro->m_iStatus;
+ d = 1;
+ }
+ else
+ if (s != acc[i]->ppro->m_iStatus)
+ d = 2;
+ }
+ }
+
+ *Var = d == 2;
+
+ return AccNum;
+}
+
+BYTE OldMode; //
+
+int cliTrayIconInit(HWND hwnd)
+{
+ BYTE Mode, d;
+
+ // Нулевое количество иконок означает, что инициализация не была проведена.
+ if (pcli->trayIconCount != 0)
+ return 0;
+
+ if (pcli->cycleTimerId)
+ {
+ KillTimer(NULL, pcli->cycleTimerId);
+ pcli->cycleTimerId = 0;
+ }
+
+ // Присутствуют ли в базе новые настройки? Если да, то обновление не нужно.
+ if (-1 == db_get_b(NULL, "CList", "tiModeS", -1))
+ SettingsMigrate();
+
+ // Нужно узнать количество годных аккаунтов и неодинаковость их статусов.
+ pcli->trayIconCount = GetGoodAccNum(&d);
+ // Если таковых аккаунтов не нашлось вообще, то будем показывать основную иконку Миранды.
+ if (!pcli->trayIconCount)
+ {
+ pcli->trayIconCount = 1;
+ pcli->trayIcon = (trayIconInfo_t*)mir_calloc(sizeof(trayIconInfo_t) * pcli->trayIconCount);
+ pcli->pfnTrayIconAdd(hwnd, NULL, NULL, CListTray_GetGlobalStatus(0, 0));
+ OldMode = TRAY_ICON_MODE_GLOBAL;
+ return 0;
+ }
+
+ // В зависимости от равенства статусов режим отличается.
+ switch (d)
+ {
+ case 0: // все равны
+ OldMode = Mode = db_get_b(NULL, "CList", "tiModeS", TRAY_ICON_MODE_GLOBAL);
+ break;
+ case 1: // не все равны
+ OldMode = Mode = db_get_b(NULL, "CList", "tiModeV", TRAY_ICON_MODE_GLOBAL);
+ break;
+ }
+
+ // Некоторые режимы всегда показывают единственную иконку.
+ if (Mode < 8)
+ pcli->trayIconCount = 1;
+
+ pcli->trayIcon = (trayIconInfo_t*)mir_calloc(sizeof(trayIconInfo_t) * pcli->trayIconCount);
+
+ // Добавляем иконки.
+ switch (Mode)
+ {
+ case TRAY_ICON_MODE_GLOBAL:
+ pcli->pfnTrayIconAdd(hwnd, NULL, NULL, CListTray_GetGlobalStatus(0, 0));
+ break;
+ case TRAY_ICON_MODE_ACC:
+ {
+ PROTOACCOUNT *pa;
+ switch (d)
+ {
+ case 0: // все равны
+ pa = ProtoGetAccount(db_get_sa(NULL, "CList", "tiAccS"));
+ break;
+ case 1: // не все равны
+ pa = ProtoGetAccount(db_get_sa(NULL, "CList", "tiAccV"));
+ break;
+ }
+ // Если злоумышленник удалил ключ или с протокольной DLL случилось нехорошее,
+ // то устанавливаем глобальную иконку.
+ if (!pa || !pa->ppro)
+ {
+ pcli->pfnTrayIconAdd(hwnd, NULL, NULL, CListTray_GetGlobalStatus(0, 0));
+ return 0;
+ }
+ pcli->pfnTrayIconAdd(hwnd, pa->szModuleName, NULL, pa->ppro->m_iStatus);
+ }
+ break;
+ case TRAY_ICON_MODE_CYCLE:
+ pcli->pfnTrayIconAdd(hwnd, NULL, NULL, CListTray_GetGlobalStatus(0, 0));
+ pcli->cycleStep = 0;
+ cliTrayCycleTimerProc(0, 0, 0, 0); // Это затем, чтобы сразу обновить иконку.
+ pcli->cycleTimerId = CLUI_SafeSetTimer(NULL, 0, db_get_w(NULL, "CList", "CycleTime", SETTING_CYCLETIME_DEFAULT) * 1000, cliTrayCycleTimerProc);
+ break;
+ case TRAY_ICON_MODE_ALL:
+ {
+ PROTOACCOUNT **acc;
+ int AccNum, i;
+
+ ProtoEnumAccounts(&AccNum, &acc);
+
+ for (i = AccNum; i--; )
+ {
+ if (!acc[i]->bIsVirtual && acc[i]->bIsVisible && !acc[i]->bDynDisabled)
+ pcli->pfnTrayIconAdd(hwnd, acc[i]->szModuleName, NULL, acc[i]->ppro->m_iStatus);
+ }
+ }
+ break;
+ }
+
+ return 0;
+}
+
+int cliTrayIconAdd(HWND hwnd, const char *szProto, const char *szIconProto, int status)
+{
+ int i;
+ NOTIFYICONDATA nid = { sizeof(NOTIFYICONDATA) };
+
+ // Поиск первой пустой записи во внутреннем списке.
+ for (i = 0; i < pcli->trayIconCount; i++)
+ if (pcli->trayIcon[i].id == 0)
+ break;
+
+ pcli->trayIcon[i].id = TRAYICON_ID_BASE + i;
+ pcli->trayIcon[i].szProto = (char*)szProto;
+ pcli->trayIcon[i].hBaseIcon = pcli->pfnGetIconFromStatusMode(NULL, szIconProto ? szIconProto : pcli->trayIcon[i].szProto, status);
+
+ pcli->pfnTrayIconMakeTooltip(NULL, pcli->trayIcon[i].szProto);
+ pcli->trayIcon[i].ptszToolTip = mir_tstrdup(pcli->szTip);
+
+ nid.hWnd = hwnd;
+ nid.uID = pcli->trayIcon[i].id;
+ nid.uCallbackMessage = TIM_CALLBACK;
+ nid.hIcon = pcli->trayIcon[i].hBaseIcon;
+
+ nid.uFlags = NIF_ICON
+ | NIF_MESSAGE
+ | NIF_TIP
+ | (pcli->shellVersion >= 5 ? NIF_INFO : 0);
+ // INFO Если Tipper отсутствует или не хочет заниматься треевыми тултипами,
+ // то тогда тултипы показывает система.
+ if (!ServiceExists("mToolTip/ShowTip") || !db_get_b(NULL, "Tipper", "TrayTip", 0))
+ lstrcpyn(nid.szTip, pcli->szTip, SIZEOF(nid.szTip));
+
+ Shell_NotifyIcon(NIM_ADD, &nid);
+
+ return 0;
+}
+
+void cliTrayIconUpdateBase(const char *szChangedProto)
+{
+ int i;
+ PROTOACCOUNT *pa;
+ NOTIFYICONDATA nid = { sizeof(NOTIFYICONDATA) };
+ HICON hIcon;
+ BYTE d, Mode;
+
+ if (!szChangedProto)
+ return;
+
+ if (!pcli->trayIconCount)
+ return;
+
+ pa = ProtoGetAccount(szChangedProto);
+ if (!pa->bIsVisible || pa->bIsVirtual)
+ return;
+
+ // Нужно узнать про неодинаковость статусов.
+ GetGoodAccNum(&d);
+ // В зависимости от равенства статусов режим отличается.
+ switch (d)
+ {
+ case 0: // все равны
+ Mode = db_get_b(NULL, "CList", "tiModeS", TRAY_ICON_MODE_GLOBAL);
+ break;
+ case 1: // не все равны
+ Mode = db_get_b(NULL, "CList", "tiModeV", TRAY_ICON_MODE_GLOBAL);
+ break;
+ }
+
+ // Если смена режима требует смены количества иконок, то выполняем инициализацию заново.
+ if (Mode != OldMode)
+ {
+ OldMode = Mode;
+ pcli->pfnTrayIconIconsChanged();
+ }
+
+ i = 0;
+ switch (Mode)
+ {
+ case TRAY_ICON_MODE_GLOBAL:
+ hIcon = pcli->pfnGetIconFromStatusMode(NULL, NULL, CListTray_GetGlobalStatus(0, 0));
+ pcli->pfnTrayIconMakeTooltip(NULL, NULL);
+ break;
+ case TRAY_ICON_MODE_ACC:
+ // Если изменяется не тот аккаунт, что выбран в настройках, то ничего не делаем.
+ if (strcmp(pcli->trayIcon[i].szProto, szChangedProto))
+ return;
+ if (g_StatusBarData.bConnectingIcon && pa->ppro->m_iStatus >= ID_STATUS_CONNECTING && pa->ppro->m_iStatus <= ID_STATUS_CONNECTING + MAX_CONNECT_RETRIES)
+ hIcon = (HICON)CLUI_GetConnectingIconService((WPARAM)szChangedProto, 0);
+ else
+ hIcon = pcli->pfnGetIconFromStatusMode(NULL, szChangedProto, pa->ppro->m_iStatus);
+ pcli->pfnTrayIconMakeTooltip(NULL, pcli->trayIcon[i].szProto);
+ break;
+ case TRAY_ICON_MODE_CYCLE:
+ hIcon = pcli->pfnGetIconFromStatusMode(NULL, szChangedProto, pa->ppro->m_iStatus);
+ pcli->pfnTrayIconMakeTooltip(NULL, NULL);
+ break;
+ case TRAY_ICON_MODE_ALL:
+ // Какой индекс у аккаунта, который будем апдейтить?
+ for ( ; i < pcli->trayIconCount; i++)
+ if (!strcmp(pcli->trayIcon[i].szProto, szChangedProto))
+ break;
+
+ if (g_StatusBarData.bConnectingIcon && pa->ppro->m_iStatus >= ID_STATUS_CONNECTING && pa->ppro->m_iStatus <= ID_STATUS_CONNECTING + MAX_CONNECT_RETRIES)
+ hIcon = (HICON)CLUI_GetConnectingIconService((WPARAM)szChangedProto, 0);
+ else
+ hIcon = pcli->pfnGetIconFromStatusMode(NULL, szChangedProto, pa->ppro->m_iStatus);
+ pcli->pfnTrayIconMakeTooltip(NULL, pcli->trayIcon[i].szProto);
+ break;
+ }
+
+ DestroyIcon(pcli->trayIcon[i].hBaseIcon);
+ pcli->trayIcon[i].hBaseIcon = hIcon;
+
+ pcli->trayIcon[i].ptszToolTip = mir_tstrdup(pcli->szTip);
+
+ nid.hWnd = pcli->hwndContactList;
+ nid.uID = pcli->trayIcon[i].id;
+ nid.hIcon = pcli->trayIcon[i].hBaseIcon;
+ nid.uFlags = NIF_ICON
+ | NIF_TIP;
+ // Если Tipper отсутствует или не хочет заниматься треевыми тултипами,
+ // то тогда тултипы показывает система.
+ if (!ServiceExists("mToolTip/ShowTip") || !db_get_b(NULL, "Tipper", "TrayTip", 0))
+ lstrcpyn(nid.szTip, pcli->szTip, SIZEOF(nid.szTip));
+
+ Shell_NotifyIcon(NIM_MODIFY, &nid);
+}
diff --git a/plugins/Clist_modern/src/resource.h b/plugins/Clist_modern/src/resource.h
index 900679e2b6..7fbac92156 100644
--- a/plugins/Clist_modern/src/resource.h
+++ b/plugins/Clist_modern/src/resource.h
@@ -186,19 +186,19 @@
#define IDC_GAMMACORRECT 1302
#define IDC_TILEVROWH 1302
#define IDC_HIDEOFFLINEOPTS 1308
-#define IDC_DONTCYCLE 1315
-#define IDC_PRIMARYSTATUS 1316
-#define IDC_CYCLE 1317
+//#define IDC_DONTCYCLE 1315
+//#define IDC_PRIMARYSTATUS 1316
+//#define IDC_CYCLE 1317
#define IDC_CYCLETIME 1318
#define IDC_CYCLETIMESPIN 1319
#define IDC_HIDETIMESPIN 1320
-#define IDC_MULTITRAY 1321
+//#define IDC_MULTITRAY 1321
#define IDC_FRAMESSPIN 1321
-#define IDC_ALWAYSMULTI 1322
+//#define IDC_ALWAYSMULTI 1322
#define IDC_CAPTIONSSPIN 1322
#define IDC_SHOWICON 1323
#define IDC_HIDETIMESPIN2 1323
-#define IDC_ALWAYSPRIMARY 1323
+//#define IDC_ALWAYSPRIMARY 1323
#define IDC_SHOWPROTO 1324
#define IDC_HIDETIMESPIN3 1324
#define IDC_SHOWSTATUS 1325
@@ -513,6 +513,18 @@
#define IDC_FRAME_META 40054
#define IDC_FRAME_META2 40055
+#define IDC_ICON_GLOBAL_S 40056
+#define IDC_ICON_ACC_S 40057
+#define IDC_ICON_CYCLE_S 40058
+#define IDC_ICON_ALL_S 40059
+#define IDC_PRIMARYSTATUS_S 40060
+
+#define IDC_ICON_GLOBAL_V 40061
+#define IDC_ICON_ACC_V 40062
+#define IDC_ICON_CYCLE_V 40063
+#define IDC_ICON_ALL_V 40064
+#define IDC_PRIMARYSTATUS_V 40065
+
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED