summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-10-30 16:41:09 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-10-30 16:41:09 +0000
commit211967c3ae7d510f2e63aac7fe912d040ad1ebc3 (patch)
treea65d43fbe91878ecc3008da5996e6e43faee257b /src
parente57ba22d8dd05efc14197c764daed53e61a59636 (diff)
old unused code that belongs to StdClist moved from the core to plugin
git-svn-id: http://svn.miranda-ng.org/main/trunk@15652 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r--src/core/stdclist/src/clc.h4
-rw-r--r--src/core/stdclist/src/clistopts.cpp8
-rw-r--r--src/core/stdclist/src/init.cpp4
-rw-r--r--src/core/stdclist/src/stdafx.h1
-rw-r--r--src/mir_app/src/clc.h42
-rw-r--r--src/mir_app/src/clistcore.cpp2
-rw-r--r--src/mir_app/src/clistevents.cpp1
-rw-r--r--src/mir_app/src/clistmod.cpp75
-rw-r--r--src/mir_app/src/clistsettings.cpp2
-rw-r--r--src/mir_app/src/contact.cpp80
10 files changed, 48 insertions, 171 deletions
diff --git a/src/core/stdclist/src/clc.h b/src/core/stdclist/src/clc.h
index d1e2196ac1..565fc7bd8a 100644
--- a/src/core/stdclist/src/clc.h
+++ b/src/core/stdclist/src/clc.h
@@ -24,10 +24,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define FONTID_LAST 7
+int CompareContacts(const ClcContact *contact1, const ClcContact *contact2);
+
struct ClcContact : public ClcContactBase
{
};
struct ClcData : public ClcDataBase
{
-}; \ No newline at end of file
+};
diff --git a/src/core/stdclist/src/clistopts.cpp b/src/core/stdclist/src/clistopts.cpp
index 3027e38563..2484b8db5b 100644
--- a/src/core/stdclist/src/clistopts.cpp
+++ b/src/core/stdclist/src/clistopts.cpp
@@ -197,8 +197,12 @@ static INT_PTR CALLBACK DlgProcGenOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
(WORD)SendDlgItemMessage(hwndDlg, IDC_HIDETIMESPIN, UDM_GETPOS, 0, 0));
}
}
- db_set_b(NULL, "CList", "SortByStatus", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SORTBYSTATUS));
- db_set_b(NULL, "CList", "SortByProto", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SORTBYPROTO));
+
+ g_bSortByStatus = IsDlgButtonChecked(hwndDlg, IDC_SORTBYSTATUS);
+ g_bSortByProto = IsDlgButtonChecked(hwndDlg, IDC_SORTBYPROTO);
+
+ db_set_b(NULL, "CList", "SortByStatus", (BYTE)g_bSortByStatus);
+ db_set_b(NULL, "CList", "SortByProto", (BYTE)g_bSortByProto);
db_set_b(NULL, "CList", "ConfirmDelete", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CONFIRMDELETE));
db_set_b(NULL, "CList", "Tray1Click", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ONECLK));
db_set_b(NULL, "CList", "AlwaysStatus", (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ALWAYSSTATUS));
diff --git a/src/core/stdclist/src/init.cpp b/src/core/stdclist/src/init.cpp
index 5b84ea4b1e..2e36764da3 100644
--- a/src/core/stdclist/src/init.cpp
+++ b/src/core/stdclist/src/init.cpp
@@ -135,10 +135,14 @@ extern "C" __declspec(dllexport) int CListInitialise()
mir_getLP(&pluginInfo);
mir_getCLI();
+ g_bSortByStatus = db_get_b(NULL, "CList", "SortByStatus", SETTING_SORTBYSTATUS_DEFAULT);
+ g_bSortByProto = db_get_b(NULL, "CList", "SortByProto", SETTING_SORTBYPROTO_DEFAULT);
+
coreCli = *pcli;
pcli->hInst = g_hInst;
pcli->pfnPaintClc = PaintClc;
pcli->pfnLoadClcOptions = LoadClcOptions;
+ pcli->pfnCompareContacts = CompareContacts;
CreateServiceFunction(MS_CLIST_GETSTATUSMODE, GetStatusMode);
diff --git a/src/core/stdclist/src/stdafx.h b/src/core/stdclist/src/stdafx.h
index 827b60261e..74d4e569f9 100644
--- a/src/core/stdclist/src/stdafx.h
+++ b/src/core/stdclist/src/stdafx.h
@@ -59,5 +59,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// shared vars
extern HINSTANCE g_hInst;
extern CLIST_INTERFACE coreCli;
+extern int g_bSortByStatus, g_bSortByProto;
void LoadClcOptions(HWND hwnd, struct ClcData *dat, BOOL bFirst);
diff --git a/src/mir_app/src/clc.h b/src/mir_app/src/clc.h
index dfb5a93dba..4258eb1e57 100644
--- a/src/mir_app/src/clc.h
+++ b/src/mir_app/src/clc.h
@@ -125,15 +125,15 @@ void fnGetDefaultFontSetting(int i, LOGFONT* lf, COLORREF * colour);
void fnInvalidateDisplayNameCacheEntry(MCONTACT hContact);
ClcCacheEntry* fnGetCacheEntry(MCONTACT hContact);
-ClcCacheEntry* fnCreateCacheItem (MCONTACT hContact);
+ClcCacheEntry* fnCreateCacheItem(MCONTACT hContact);
void fnCheckCacheItem(ClcCacheEntry *p);
void fnFreeCacheItem(ClcCacheEntry *p);
/* clcfiledrop.c */
void InitFileDropping(void);
-void fnRegisterFileDropping (HWND hwnd);
-void fnUnregisterFileDropping (HWND hwnd);
+void fnRegisterFileDropping(HWND hwnd);
+void fnUnregisterFileDropping(HWND hwnd);
/* clistevents.c */
struct CListEvent* fnAddEvent(CLISTEVENT *cle);
@@ -163,44 +163,42 @@ void fnUninitTray(void);
int fnCListTrayNotify(MIRANDASYSTRAYNOTIFY *msn);
int fnTrayIconAdd(HWND hwnd, const char *szProto, const char *szIconProto, int status);
int fnTrayIconDestroy(HWND hwnd);
-void fnTrayIconIconsChanged (void);
+void fnTrayIconIconsChanged(void);
int fnTrayIconInit(HWND hwnd);
TCHAR* fnTrayIconMakeTooltip(const TCHAR *szPrefix, const char *szProto);
-int fnTrayIconPauseAutoHide (WPARAM wParam, LPARAM lParam);
-INT_PTR fnTrayIconProcessMessage (WPARAM wParam, LPARAM lParam);
+int fnTrayIconPauseAutoHide(WPARAM wParam, LPARAM lParam);
+INT_PTR fnTrayIconProcessMessage(WPARAM wParam, LPARAM lParam);
void fnTrayIconRemove(HWND hwnd, const char *szProto);
int fnTrayIconSetBaseInfo(HICON hIcon, const char *szPreferredProto);
-void fnTrayIconSetToBase (char *szPreferredProto);
+void fnTrayIconSetToBase(char *szPreferredProto);
void fnTrayIconTaskbarCreated(HWND hwnd);
int fnTrayIconUpdate(HICON hNewIcon, const TCHAR *szNewTip, const char *szPreferredProto, int isBase);
-void fnTrayIconUpdateBase (const char *szChangedProto);
+void fnTrayIconUpdateBase(const char *szChangedProto);
int fnTrayCalcChanged(const char *szChangedProto, int averageMode, int netProtoCount);
-void fnTrayIconUpdateWithImageList (int iImage, const TCHAR *szNewTip, char *szPreferredProto);
+void fnTrayIconUpdateWithImageList(int iImage, const TCHAR *szNewTip, char *szPreferredProto);
VOID CALLBACK fnTrayCycleTimerProc(HWND hwnd, UINT message, UINT_PTR idEvent, DWORD dwTime);
/* clui.c */
-LRESULT CALLBACK fnContactListWndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+LRESULT CALLBACK fnContactListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
void fnLoadCluiGlobalOpts(void);
void fnCluiProtocolStatusChanged(int, const char*);
void fnDrawMenuItem(DRAWITEMSTRUCT *dis, HICON hIcon, HICON eventIcon);
/* contact.c */
-void fnChangeContactIcon (MCONTACT hContact, int iIcon, int add);
-void fnLoadContactTree (void);
-int fnCompareContacts (const ClcContact *contact1, const ClcContact *contact2);
-void fnSortContacts (void);
-int fnSetHideOffline (WPARAM wParam, LPARAM lParam);
+void fnChangeContactIcon(MCONTACT hContact, int iIcon, int add);
+void fnLoadContactTree(void);
+int fnSetHideOffline(WPARAM wParam, LPARAM lParam);
/* docking.c */
-int fnDocking_ProcessWindowMessage (WPARAM wParam, LPARAM lParam);
+int fnDocking_ProcessWindowMessage(WPARAM wParam, LPARAM lParam);
/* group.c */
-TCHAR* fnGetGroupName (int idx, DWORD* pdwFlags);
-int fnRenameGroup (int groupID, TCHAR* newName);
+TCHAR* fnGetGroupName(int idx, DWORD* pdwFlags);
+int fnRenameGroup(int groupID, TCHAR* newName);
/* keyboard.c */
-int fnHotKeysRegister (HWND hwnd);
-void fnHotKeysUnregister (HWND hwnd);
-int fnHotKeysProcess (HWND hwnd, WPARAM wParam, LPARAM lParam);
-int fnHotkeysProcessMessage (WPARAM wParam, LPARAM lParam);
+int fnHotKeysRegister(HWND hwnd);
+void fnHotKeysUnregister(HWND hwnd);
+int fnHotKeysProcess(HWND hwnd, WPARAM wParam, LPARAM lParam);
+int fnHotkeysProcessMessage(WPARAM wParam, LPARAM lParam);
diff --git a/src/mir_app/src/clistcore.cpp b/src/mir_app/src/clistcore.cpp
index 7df2f0d0ed..ad60954e37 100644
--- a/src/mir_app/src/clistcore.cpp
+++ b/src/mir_app/src/clistcore.cpp
@@ -181,8 +181,6 @@ static INT_PTR srvRetrieveInterface(WPARAM, LPARAM)
cli.pfnChangeContactIcon = fnChangeContactIcon;
cli.pfnLoadContactTree = fnLoadContactTree;
- cli.pfnCompareContacts = fnCompareContacts;
- cli.pfnSortContacts = fnSortContacts;
cli.pfnSetHideOffline = fnSetHideOffline;
cli.pfnDocking_ProcessWindowMessage = fnDocking_ProcessWindowMessage;
diff --git a/src/mir_app/src/clistevents.cpp b/src/mir_app/src/clistevents.cpp
index af2a581041..cc55ef5091 100644
--- a/src/mir_app/src/clistevents.cpp
+++ b/src/mir_app/src/clistevents.cpp
@@ -179,7 +179,6 @@ CListEvent* fnAddEvent(CLISTEVENT *cle)
cli.pfnTrayIconUpdateWithImageList(p->imlIconIndex, p->cle.ptszTooltip, szProto);
}
cli.pfnChangeContactIcon(cle->hContact, p->imlIconIndex, 1);
- cli.pfnSortContacts();
return p;
}
diff --git a/src/mir_app/src/clistmod.cpp b/src/mir_app/src/clistmod.cpp
index db63eae84c..701ef7da12 100644
--- a/src/mir_app/src/clistmod.cpp
+++ b/src/mir_app/src/clistmod.cpp
@@ -251,14 +251,12 @@ static INT_PTR ContactFilesDropped(WPARAM wParam, LPARAM lParam)
static int CListIconsChanged(WPARAM, LPARAM)
{
- int i, j;
-
- for (i = 0; i < _countof(statusModeList); i++)
+ for (int i = 0; i < _countof(statusModeList); i++)
ImageList_ReplaceIcon_IconLibLoaded(hCListImages, i + 1, Skin_LoadIcon(skinIconStatusList[i]));
ImageList_ReplaceIcon_IconLibLoaded(hCListImages, IMAGE_GROUPOPEN, Skin_LoadIcon(SKINICON_OTHER_GROUPOPEN));
ImageList_ReplaceIcon_IconLibLoaded(hCListImages, IMAGE_GROUPSHUT, Skin_LoadIcon(SKINICON_OTHER_GROUPSHUT));
- for (i = 0; i < protoIconIndex.getCount(); i++)
- for (j = 0; j < _countof(statusModeList); j++)
+ for (int i = 0; i < protoIconIndex.getCount(); i++)
+ for (int j = 0; j < _countof(statusModeList); j++)
ImageList_ReplaceIcon_IconLibLoaded(hCListImages, protoIconIndex[i].iIconBase + j, Skin_LoadProtoIcon(protoIconIndex[i].szProto, statusModeList[j]));
cli.pfnTrayIconIconsChanged();
cli.pfnInvalidateRect(cli.hwndContactList, NULL, TRUE);
@@ -333,7 +331,7 @@ int fnGetWindowVisibleState(HWND hWnd, int iStepX, int iStepY)
if (iNotCoveredDots == 0) //They're all covered!
return GWVS_COVERED;
- //There are dots which are visible, but they are not as many as the ones we counted: it's partially covered.
+ // There are dots which are visible, but they are not as many as the ones we counted: it's partially covered.
return GWVS_PARTIALLY_COVERED;
}
@@ -361,8 +359,6 @@ int fnShowHide(WPARAM, LPARAM)
}
if (bShow == TRUE) {
- RECT rcWindow;
-
ShowWindow(cli.hwndContactList, SW_RESTORE);
if (!db_get_b(NULL, "CList", "OnTop", SETTING_ONTOP_DEFAULT))
SetWindowPos(cli.hwndContactList, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
@@ -372,14 +368,13 @@ int fnShowHide(WPARAM, LPARAM)
SetForegroundWindow(cli.hwndContactList);
db_set_b(NULL, "CList", "State", SETTING_STATE_NORMAL);
- //this forces the window onto the visible screen
+ // this forces the window onto the visible screen
+ RECT rcWindow;
GetWindowRect(cli.hwndContactList, &rcWindow);
- if (Utils_AssertInsideScreen(&rcWindow) == 1) {
- MoveWindow(cli.hwndContactList, rcWindow.left, rcWindow.top,
- rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top, TRUE);
- }
+ if (Utils_AssertInsideScreen(&rcWindow) == 1)
+ MoveWindow(cli.hwndContactList, rcWindow.left, rcWindow.top, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top, TRUE);
}
- else { //It needs to be hidden
+ else { // It needs to be hidden
if (db_get_b(NULL, "CList", "ToolWindow", SETTING_TOOLWINDOW_DEFAULT) ||
db_get_b(NULL, "CList", "Min2Tray", SETTING_MIN2TRAY_DEFAULT)) {
ShowWindow(cli.hwndContactList, SW_HIDE);
@@ -396,57 +391,15 @@ int fnShowHide(WPARAM, LPARAM)
return 0;
}
-///////////////////////////////////////////////////////////////////////////////
-// old evil code. hopefully it will be deleted soon, cause nobody uses it now
-
-#define SAFESTRING(a) a?a:""
-
-int GetStatusModeOrdering(int statusMode);
-extern int sortByStatus, sortByProto;
+/////////////////////////////////////////////////////////////////////////////////////////
static INT_PTR CompareContacts(WPARAM wParam, LPARAM lParam)
{
- MCONTACT a = wParam, b = lParam;
- TCHAR namea[128], *nameb;
- int rc;
-
- char *szProto1 = GetContactProto(a);
- char *szProto2 = GetContactProto(b);
- int statusa = db_get_w(a, SAFESTRING(szProto1), "Status", ID_STATUS_OFFLINE);
- int statusb = db_get_w(b, SAFESTRING(szProto2), "Status", ID_STATUS_OFFLINE);
-
- if (sortByProto) {
- /* deal with statuses, online contacts have to go above offline */
- if ((statusa == ID_STATUS_OFFLINE) != (statusb == ID_STATUS_OFFLINE)) {
- return 2 * (statusa == ID_STATUS_OFFLINE) - 1;
- }
- /* both are online, now check protocols */
- rc = mir_strcmp(SAFESTRING(szProto1), SAFESTRING(szProto2)); /* mir_strcmp() doesn't like NULL so feed in "" as needed */
- if (rc != 0 && (szProto1 != NULL && szProto2 != NULL))
- return rc;
- /* protocols are the same, order by display name */
- }
-
- if (sortByStatus) {
- int ordera, orderb;
- ordera = GetStatusModeOrdering(statusa);
- orderb = GetStatusModeOrdering(statusb);
- if (ordera != orderb)
- return ordera - orderb;
- }
- else {
- //one is offline: offline goes below online
- if ((statusa == ID_STATUS_OFFLINE) != (statusb == ID_STATUS_OFFLINE)) {
- return 2 * (statusa == ID_STATUS_OFFLINE) - 1;
- }
- }
+ ClcContact *p1, *p2;
+ if (!cli.pfnFindItem(cli.hwndContactTree, NULL, wParam, &p1, NULL, NULL) && !cli.pfnFindItem(cli.hwndContactTree, NULL, lParam, &p2, NULL, NULL))
+ return cli.pfnCompareContacts(p1, p2);
- nameb = cli.pfnGetContactDisplayName(a, 0);
- _tcsncpy_s(namea, nameb, _TRUNCATE);
- nameb = cli.pfnGetContactDisplayName(b, 0);
-
- //otherwise just compare names
- return mir_tstrcmpi(namea, nameb);
+ return 0;
}
/***************************************************************************************/
diff --git a/src/mir_app/src/clistsettings.cpp b/src/mir_app/src/clistsettings.cpp
index 2c0780aaa7..b202ed0572 100644
--- a/src/mir_app/src/clistsettings.cpp
+++ b/src/mir_app/src/clistsettings.cpp
@@ -149,7 +149,6 @@ INT_PTR InvalidateDisplayName(WPARAM wParam, LPARAM)
int ContactAdded(WPARAM wParam, LPARAM)
{
cli.pfnChangeContactIcon(wParam, cli.pfnIconFromStatusMode(GetContactProto(wParam), ID_STATUS_OFFLINE, NULL), 1);
- cli.pfnSortContacts();
return 0;
}
@@ -196,7 +195,6 @@ int ContactSettingChanged(WPARAM hContact, LPARAM lParam)
mir_free(dbv.pszVal);
return 0;
}
- cli.pfnSortContacts();
}
}
diff --git a/src/mir_app/src/contact.cpp b/src/mir_app/src/contact.cpp
index 560eb60d5a..d561c1faa7 100644
--- a/src/mir_app/src/contact.cpp
+++ b/src/mir_app/src/contact.cpp
@@ -28,23 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern HANDLE hContactIconChangedEvent;
extern HANDLE hGroupChangeEvent;
-int sortByStatus;
-int sortByProto;
-
-static const struct {
- int status, order;
-} statusModeOrder[] = {
- {ID_STATUS_OFFLINE, 500},
- {ID_STATUS_ONLINE, 10},
- {ID_STATUS_AWAY, 200},
- {ID_STATUS_DND, 110},
- {ID_STATUS_NA, 450},
- {ID_STATUS_OCCUPIED, 100},
- {ID_STATUS_FREECHAT, 0},
- {ID_STATUS_INVISIBLE, 20},
- {ID_STATUS_ONTHEPHONE, 150},
- {ID_STATUS_OUTTOLUNCH, 425}};
-
static int GetContactStatus(MCONTACT hContact)
{
char *szProto = GetContactProto(hContact);
@@ -59,15 +42,6 @@ void fnChangeContactIcon(MCONTACT hContact, int iIcon, int add)
NotifyEventHooks(hContactIconChangedEvent, hContact, iIcon);
}
-int GetStatusModeOrdering(int statusMode)
-{
- int i;
- for (i=0; i < _countof(statusModeOrder); i++)
- if (statusModeOrder[i].status == statusMode)
- return statusModeOrder[i].order;
- return 1000;
-}
-
void fnLoadContactTree(void)
{
CallService(MS_CLUI_LISTBEGINREBUILD, 0, 0);
@@ -83,63 +57,9 @@ void fnLoadContactTree(void)
if ((!hideOffline || status != ID_STATUS_OFFLINE) && !db_get_b(hContact, "CList", "Hidden", 0))
cli.pfnChangeContactIcon(hContact, cli.pfnIconFromStatusMode(GetContactProto(hContact), status, hContact), 1);
}
- sortByStatus = db_get_b(NULL, "CList", "SortByStatus", SETTING_SORTBYSTATUS_DEFAULT);
- sortByProto = db_get_b(NULL, "CList", "SortByProto", SETTING_SORTBYPROTO_DEFAULT);
CallService(MS_CLUI_LISTENDREBUILD, 0, 0);
}
-int fnCompareContacts(const ClcContact* c1, const ClcContact* c2)
-{
- MCONTACT a = c1->hContact, b = c2->hContact;
- TCHAR namea[128], *nameb;
- int statusa, statusb;
- int rc;
-
- statusa = db_get_w(a, c1->proto, "Status", ID_STATUS_OFFLINE);
- statusb = db_get_w(b, c2->proto, "Status", ID_STATUS_OFFLINE);
-
- if (sortByProto) {
- /* deal with statuses, online contacts have to go above offline */
- if ((statusa == ID_STATUS_OFFLINE) != (statusb == ID_STATUS_OFFLINE)) {
- return 2 * (statusa == ID_STATUS_OFFLINE) - 1;
- }
- /* both are online, now check protocols */
- if (c1->proto != NULL && c2->proto != NULL) {
- rc = mir_strcmp(c1->proto, c2->proto);
- if (rc != 0)
- return rc;
- }
- /* protocols are the same, order by display name */
- }
-
- if (sortByStatus) {
- int ordera = GetStatusModeOrdering(statusa);
- int orderb = GetStatusModeOrdering(statusb);
- if (ordera != orderb)
- return ordera - orderb;
- }
- else {
- //one is offline: offline goes below online
- if ((statusa == ID_STATUS_OFFLINE) != (statusb == ID_STATUS_OFFLINE))
- return 2 * (statusa == ID_STATUS_OFFLINE) - 1;
- }
-
- nameb = cli.pfnGetContactDisplayName(a, 0);
- _tcsncpy_s(namea, nameb, _TRUNCATE);
- namea[ _countof(namea)-1 ] = 0;
- nameb = cli.pfnGetContactDisplayName(b, 0);
-
- //otherwise just compare names
- return mir_tstrcmpi(namea, nameb);
-}
-
-void fnSortContacts(void)
-{
- //avoid doing lots of resorts in quick succession
- sortByStatus = db_get_b(NULL, "CList", "SortByStatus", SETTING_SORTBYSTATUS_DEFAULT);
- sortByProto = db_get_b(NULL, "CList", "SortByProto", SETTING_SORTBYPROTO_DEFAULT);
-}
-
INT_PTR ContactChangeGroup(WPARAM wParam, LPARAM lParam)
{
CLISTGROUPCHANGE grpChg = { sizeof(CLISTGROUPCHANGE), NULL, NULL };