summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-01-18 17:25:28 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-01-18 17:25:28 +0000
commit593062caed4a856b47172ace150c7eefdac54de0 (patch)
tree98e952a666f9f5ccb8107abefe628948c44e18a8
parent5ae171790b75db5510cc808199a51ae1dc227320 (diff)
alternative user sorting support
git-svn-id: http://svn.miranda-ng.org/main/trunk@7733 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--include/m_chat_int.h1
-rw-r--r--plugins/TabSRMM/src/chat/chat.h2
-rw-r--r--plugins/TabSRMM/src/chat/main.cpp1
-rw-r--r--plugins/TabSRMM/src/chat/manager.cpp40
-rw-r--r--src/modules/chat/manager.cpp1
5 files changed, 45 insertions, 0 deletions
diff --git a/include/m_chat_int.h b/include/m_chat_int.h
index da0b627819..b75f525f58 100644
--- a/include/m_chat_int.h
+++ b/include/m_chat_int.h
@@ -359,6 +359,7 @@ struct CHAT_MANAGER
TCHAR* (*UM_FindUserAutoComplete)(USERINFO* pUserList, const TCHAR* pszOriginal, const TCHAR* pszCurrent);
BOOL (*UM_RemoveUser)(USERINFO** pUserList, const TCHAR *pszUID);
BOOL (*UM_RemoveAll)(USERINFO** ppUserList);
+ int (*UM_CompareItem)(USERINFO * u1, const TCHAR *pszNick, WORD wStatus);
LOGINFO* (*LM_AddEvent)(LOGINFO** ppLogListStart, LOGINFO** ppLogListEnd);
BOOL (*LM_TrimLog)(LOGINFO** ppLogListStart, LOGINFO** ppLogListEnd, int iCount);
diff --git a/plugins/TabSRMM/src/chat/chat.h b/plugins/TabSRMM/src/chat/chat.h
index 025a854983..84004e5fb3 100644
--- a/plugins/TabSRMM/src/chat/chat.h
+++ b/plugins/TabSRMM/src/chat/chat.h
@@ -156,6 +156,8 @@ SESSION_INFO* SM_FindSessionAutoComplete(const char* pszModule, SESSION_INFO* cu
void SM_RemoveContainer(TContainerData *pContainer);
BOOL SM_ReconfigureFilters();
+int UM_CompareItem(USERINFO *u1, const TCHAR* pszNick, WORD wStatus);
+
//clist.c
//tools.c
diff --git a/plugins/TabSRMM/src/chat/main.cpp b/plugins/TabSRMM/src/chat/main.cpp
index 5989cbf31b..7e3137bafc 100644
--- a/plugins/TabSRMM/src/chat/main.cpp
+++ b/plugins/TabSRMM/src/chat/main.cpp
@@ -278,6 +278,7 @@ int Chat_Load()
pci->DoPopup = DoPopup;
pci->ShowPopup = ShowPopup;
pci->Log_CreateRtfHeader = Log_CreateRtfHeader;
+ pci->UM_CompareItem = UM_CompareItem;
pci->ReloadSettings();
g_hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU));
diff --git a/plugins/TabSRMM/src/chat/manager.cpp b/plugins/TabSRMM/src/chat/manager.cpp
index d58f487c7d..1a4f357acd 100644
--- a/plugins/TabSRMM/src/chat/manager.cpp
+++ b/plugins/TabSRMM/src/chat/manager.cpp
@@ -23,6 +23,46 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "..\commonheaders.h"
+static int sttCompareNicknames(const TCHAR *s1, const TCHAR *s2)
+{
+ // skip rubbish
+ while (*s1 && !_istalpha(*s1)) ++s1;
+ while (*s2 && !_istalpha(*s2)) ++s2;
+
+ // are there ~0veRy^kEwL_n1kz?
+ if (!*s1 && !*s2) return 0;
+ if (!*s1 && *s2) return +1;
+ if (*s1 && !*s2) return -1;
+
+ // compare tails
+ return lstrcmpi(s1, s2);
+}
+
+int UM_CompareItem(USERINFO *u1, const TCHAR* pszNick, WORD wStatus)
+{
+ WORD dw1 = u1->Status;
+ WORD dw2 = wStatus;
+
+ for (int i = 0; i < 8; i++) {
+ if ((dw1 & 1) && !(dw2 & 1))
+ return -1;
+ if ((dw2 & 1) && !(dw1 & 1))
+ return 1;
+ if ((dw1 & 1) && (dw2 & 1)) {
+ if (g_Settings.bAlternativeSorting)
+ return sttCompareNicknames(u1->pszNick, pszNick);
+ else
+ return lstrcmp(u1->pszNick, pszNick);
+ }
+ dw1 = dw1 >> 1;
+ dw2 = dw2 >> 1;
+ }
+
+ if (g_Settings.bAlternativeSorting)
+ return sttCompareNicknames(u1->pszNick, pszNick);
+ return lstrcmp(u1->pszNick, pszNick);
+}
+
//---------------------------------------------------
// Session Manager functions
//
diff --git a/src/modules/chat/manager.cpp b/src/modules/chat/manager.cpp
index c8ae7836eb..5f0dcd3e5c 100644
--- a/src/modules/chat/manager.cpp
+++ b/src/modules/chat/manager.cpp
@@ -1399,6 +1399,7 @@ CHAT_MANAGER ci =
UM_FindUserAutoComplete,
UM_RemoveUser,
UM_RemoveAll,
+ UM_CompareItem,
LM_AddEvent,
LM_TrimLog,