summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-09-07 12:09:27 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-09-07 12:09:27 +0000
commit03a0b643b94d5aa7f9c129fe73eea314d099cf56 (patch)
tree221081ffe0602905765815d302b02d1f761cf100 /protocols/JabberG/src
parent0ac4b544972fb011e7c7c69e60a1d5d180ada0ac (diff)
shameful end of the group processing zoo, part 1
git-svn-id: http://svn.miranda-ng.org/main/trunk@5994 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG/src')
-rw-r--r--protocols/JabberG/src/jabber.h1
-rw-r--r--protocols/JabberG/src/jabber_iq_handlers.cpp8
-rw-r--r--protocols/JabberG/src/jabber_iqid.cpp5
-rw-r--r--protocols/JabberG/src/jabber_misc.cpp49
-rw-r--r--protocols/JabberG/src/jabber_privacy.cpp26
5 files changed, 6 insertions, 83 deletions
diff --git a/protocols/JabberG/src/jabber.h b/protocols/JabberG/src/jabber.h
index 1a20f671c9..585f434a88 100644
--- a/protocols/JabberG/src/jabber.h
+++ b/protocols/JabberG/src/jabber.h
@@ -676,7 +676,6 @@ int g_OnToolbarInit(WPARAM, LPARAM);
void JabberChatDllError(void);
int JabberCompareJids(const TCHAR *jid1, const TCHAR *jid2);
-void JabberContactListCreateGroup(TCHAR* groupName);
TCHAR* EscapeChatTags(TCHAR* pszText);
TCHAR* UnEscapeChatTags(TCHAR* str_in);
diff --git a/protocols/JabberG/src/jabber_iq_handlers.cpp b/protocols/JabberG/src/jabber_iq_handlers.cpp
index 24d72a83f6..aa00846287 100644
--- a/protocols/JabberG/src/jabber_iq_handlers.cpp
+++ b/protocols/JabberG/src/jabber_iq_handlers.cpp
@@ -608,14 +608,12 @@ BOOL CJabberProto::OnRosterPushRequest(HXML, CJabberIqInfo *pInfo)
}
else db_unset(hContact, "CList", "MyHandle");
- if ( !m_options.IgnoreRosterGroups)
- {
+ if ( !m_options.IgnoreRosterGroups) {
if (item->group != NULL) {
- JabberContactListCreateGroup(item->group);
+ Clist_CreateGroup(0, item->group);
db_set_ts(hContact, "CList", "Group", item->group);
}
- else
- db_unset(hContact, "CList", "Group");
+ else db_unset(hContact, "CList", "Group");
}
}
mir_free(nick);
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp
index 17c070d9fd..aa906cdc4e 100644
--- a/protocols/JabberG/src/jabber_iqid.cpp
+++ b/protocols/JabberG/src/jabber_iqid.cpp
@@ -484,7 +484,7 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo* pInfo)
if ( !m_options.IgnoreRosterGroups) {
if (item->group != NULL) {
- JabberContactListCreateGroup(item->group);
+ Clist_CreateGroup(0, item->group);
// Don't set group again if already correct, or Miranda may show wrong group count in some case
DBVARIANT dbv;
@@ -495,8 +495,7 @@ void CJabberProto::OnIqResultGetRoster(HXML iqNode, CJabberIqInfo* pInfo)
}
else db_set_ts(hContact, "CList", "Group", item->group);
}
- else
- db_unset(hContact, "CList", "Group");
+ else db_unset(hContact, "CList", "Group");
}
if (hContact != NULL) {
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp
index f66613402b..d5f38fb6e7 100644
--- a/protocols/JabberG/src/jabber_misc.cpp
+++ b/protocols/JabberG/src/jabber_misc.cpp
@@ -65,55 +65,6 @@ int JabberCompareJids(const TCHAR *jid1, const TCHAR *jid2)
}
///////////////////////////////////////////////////////////////////////////////
-// JabberContactListCreateGroup()
-
-static void JabberContactListCreateClistGroup(TCHAR* groupName)
-{
- char str[33];
- int i;
- DBVARIANT dbv;
-
- for (i=0;;i++) {
- _itoa(i, str, 10);
- if ( db_get_ts(NULL, "CListGroups", str, &dbv))
- break;
- TCHAR *name = dbv.ptszVal;
- if (name[0]!='\0' && !_tcscmp(name+1, groupName)) {
- // Already exists, no need to create
- db_free(&dbv);
- return;
- }
- db_free(&dbv);
- }
-
- // Create new group with id = i (str is the text representation of i)
- TCHAR newName[128];
- newName[0] = 1 | GROUPF_EXPANDED;
- _tcsncpy(newName+1, groupName, SIZEOF(newName)-1);
- newName[ SIZEOF(newName)-1] = '\0';
- db_set_ts(NULL, "CListGroups", str, newName);
- CallService(MS_CLUI_GROUPADDED, i+1, 0);
-}
-
-void JabberContactListCreateGroup(TCHAR* groupName)
-{
- TCHAR name[128], *p;
-
- if (groupName == NULL || groupName[0]=='\0' || groupName[0]=='\\') return;
-
- _tcsncpy(name, groupName, SIZEOF(name));
- name[ SIZEOF(name)-1] = '\0';
- for (p=name; *p!='\0'; p++) {
- if (*p == '\\') {
- *p = '\0';
- JabberContactListCreateClistGroup(name);
- *p = '\\';
- }
- }
- JabberContactListCreateClistGroup(name);
-}
-
-///////////////////////////////////////////////////////////////////////////////
// JabberDBAddAuthRequest()
void CJabberProto::DBAddAuthRequest(const TCHAR *jid, const TCHAR *nick)
diff --git a/protocols/JabberG/src/jabber_privacy.cpp b/protocols/JabberG/src/jabber_privacy.cpp
index abe3a5dead..a0b7704844 100644
--- a/protocols/JabberG/src/jabber_privacy.cpp
+++ b/protocols/JabberG/src/jabber_privacy.cpp
@@ -642,7 +642,6 @@ protected:
void CListResetOptions(HWND hwndList);
void CListFilter(HWND hwndList);
bool CListIsGroup(HANDLE hGroup);
- HANDLE CListFindGroupByName(TCHAR *name);
void CListResetIcons(HWND hwndList, HANDLE hItem, bool hide=false);
void CListSetupIcons(HWND hwndList, HANDLE hItem, int iSlot, DWORD dwProcess, BOOL bAction);
HANDLE CListAddContact(HWND hwndList, TCHAR *jid);
@@ -1373,29 +1372,6 @@ bool CJabberDlgPrivacyLists::CListIsGroup(HANDLE hGroup)
return result;
}
-HANDLE CJabberDlgPrivacyLists::CListFindGroupByName(TCHAR *name)
-{
- char idstr[33];
- DBVARIANT dbv;
-
- HANDLE hGroup = 0;
-
- for (int i= 0; !hGroup; i++)
- {
- _itoa(i, idstr, 10);
-
- if ( db_get_ts(NULL, "CListGroups", idstr, &dbv))
- break;
-
- if ( !_tcscmp(dbv.ptszVal + 1, name))
- hGroup = (HANDLE)(i+1);
-
- db_free(&dbv);
- }
-
- return hGroup;
-}
-
void CJabberDlgPrivacyLists::CListResetIcons(HWND, HANDLE hItem, bool hide)
{
for (int i = 0; i < 4; i++)
@@ -1477,7 +1453,7 @@ void CJabberDlgPrivacyLists::CListApplyList(HWND hwndList, CPrivacyList *pList)
}
case Group:
{
- HANDLE hGroup = CListFindGroupByName(pRule->GetValue());
+ HANDLE hGroup = Clist_GroupExists(pRule->GetValue());
hItem = m_clcClist.FindGroup(hGroup);
break;
}