summaryrefslogtreecommitdiff
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
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
-rw-r--r--plugins/Clist_modern/src/modern_groupmenu.cpp2
-rw-r--r--plugins/Clist_mw/src/groupmenu.cpp209
-rw-r--r--plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp7
-rw-r--r--plugins/Clist_nicer/src/clui.cpp2
-rw-r--r--plugins/CryptoPP/src/cpp_rsam.cpp4
-rw-r--r--plugins/DbEditorPP/src/exportimport.cpp26
-rw-r--r--plugins/Scriver/src/chat/chat.h1
-rw-r--r--plugins/Scriver/src/chat/clist.cpp57
-rw-r--r--plugins/TabSRMM/src/chat/clist.cpp17
-rw-r--r--plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp28
-rw-r--r--protocols/AimOscar/src/utility.cpp2
-rw-r--r--protocols/FacebookRM/src/connection.cpp2
-rw-r--r--protocols/FacebookRM/src/dialogs.cpp2
-rw-r--r--protocols/Gadu-Gadu/src/import.cpp82
-rw-r--r--protocols/IcqOscarJ/src/icq_proto.h1
-rw-r--r--protocols/IcqOscarJ/src/icq_servlist.cpp49
-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
-rw-r--r--protocols/MSN/src/msn_srv.cpp6
-rw-r--r--protocols/Skype/src/skype_account.cpp2
-rw-r--r--protocols/Skype/src/skype_dialogs.cpp2
-rw-r--r--protocols/Tlen/src/tlen.h2
-rw-r--r--protocols/Tlen/src/tlen_avatar.cpp6
-rw-r--r--protocols/Tlen/src/tlen_file.cpp4
-rw-r--r--protocols/Tlen/src/tlen_iqid.cpp4
-rw-r--r--protocols/Tlen/src/tlen_misc.cpp85
-rw-r--r--protocols/Tlen/src/tlen_muc.cpp2
-rw-r--r--protocols/Tlen/src/tlen_p2p_new.cpp6
-rw-r--r--protocols/Tlen/src/tlen_p2p_old.cpp4
-rw-r--r--protocols/Tlen/src/tlen_picture.cpp4
-rw-r--r--protocols/Tlen/src/tlen_svc.cpp12
-rw-r--r--protocols/Tlen/src/tlen_thread.cpp6
-rw-r--r--protocols/Tlen/src/tlen_voice.cpp8
-rw-r--r--src/core/stdchat/src/chat.h1
-rw-r--r--src/core/stdchat/src/clist.cpp63
38 files changed, 175 insertions, 622 deletions
diff --git a/plugins/Clist_modern/src/modern_groupmenu.cpp b/plugins/Clist_modern/src/modern_groupmenu.cpp
index 74dc4383a5..e54e8e1908 100644
--- a/plugins/Clist_modern/src/modern_groupmenu.cpp
+++ b/plugins/Clist_modern/src/modern_groupmenu.cpp
@@ -200,7 +200,7 @@ INT_PTR CreateGroupHelper(WPARAM wParam,LPARAM lParam)
{
SendMessage((HWND)CallService(MS_CLUI_GETHWNDTREE, 0, 0), CLM_SETHIDEEMPTYGROUPS, 0, 0);
SendMessage((HWND)CallService(MS_CLUI_GETHWNDTREE, 0, 0), CLM_SETUSEGROUPS, 1, 0);
- CallService(MS_CLIST_GROUPCREATE, 0, 0);
+ Clist_CreateGroup(0, 0);
return 0;
};
diff --git a/plugins/Clist_mw/src/groupmenu.cpp b/plugins/Clist_mw/src/groupmenu.cpp
index 821a57d754..3a79598ab5 100644
--- a/plugins/Clist_mw/src/groupmenu.cpp
+++ b/plugins/Clist_mw/src/groupmenu.cpp
@@ -240,7 +240,7 @@ void InitGroupMenus(void)
HICON hicon;
hicon = LoadIconFromExternalFile("clisticons.dll",2,TRUE,TRUE,"NewGroup","Contact List","New Group",-IDI_NEWGROUP2,0);
NewGroupIconidx = ImageList_AddIcon(hCListImages,hicon );
-
+
CreateServiceFunction("CLISTMENUSGroup/ExecService",GroupMenuExecService);
CreateServiceFunction("CLISTMENUSGroup/FreeOwnerDataGroupMenu",FreeOwnerDataGroupMenu);
CreateServiceFunction("CLISTMENUSGroup/GroupMenuonAddService",GroupMenuonAddService);
@@ -263,13 +263,13 @@ void InitGroupMenus(void)
tmp.ExecService = "CLISTMENUSGroup/ExecService";
tmp.name = "Group Menu";
hGroupMenuObject = (HANDLE)CallService(MO_CREATENEWMENUOBJECT,0,(LPARAM)&tmp);
-
-
+
+
op.Handle = hGroupMenuObject;
op.Setting = OPT_USERDEFINEDITEMS;
op.Value = TRUE;
CallService(MO_SETOPTIONSMENUOBJECT,0,(LPARAM)&op);
-
+
op.Handle = hGroupMenuObject;
op.Setting = OPT_MENUOBJECT_SET_FREE_SERVICE;
op.Value = (INT_PTR)"CLISTMENUSGroup/FreeOwnerDataGroupMenu";
@@ -281,109 +281,104 @@ void InitGroupMenus(void)
CallService(MO_SETOPTIONSMENUOBJECT,0,(LPARAM)&op);
{
- //add exit command to menu
- GroupMenuParam gmp;
-
- CLISTMENUITEM mi = { sizeof(mi) };
- mi.position = 1900000;
- mi.pszService = "CloseAction";
- mi.pszName = LPGEN("E&xit");
- AddGroupMenuItem(0,(LPARAM)&mi);
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize = sizeof(mi);
- mi.position = 500;
- mi.pszService = MS_CLIST_SHOWHIDE;
- mi.pszName = LPGEN("&Hide/Show");
- hHideShowMainMenuItem = (HANDLE)AddGroupMenuItem(0,(LPARAM)&mi);
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize = sizeof(mi);
- mi.position = 200000;
- mi.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_FINDUSER));
- mi.pszService = "FindAdd/FindAddCommand";
- mi.pszName = LPGEN("&Find/Add Contacts...");
- AddGroupMenuItem(0,(LPARAM)&mi);
-
-
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize = sizeof(mi);
- mi.position = 300000;
- mi.pszService = "";
- mi.pszName = LPGEN("&Main Menu");
- hGroupMainMenuItemProxy = (HANDLE)AddGroupMenuItem(0,(LPARAM)&mi);
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize = sizeof(mi);
- mi.position = 300100;
- mi.pszService = "";
- mi.pszName = LPGEN("&Status");
- hGroupStatusMenuItemProxy = (HANDLE)AddGroupMenuItem(0,(LPARAM)&mi);
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize = sizeof(mi);
- mi.position = 400000;
- mi.hIcon = LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_OPTIONS));
- mi.pszService = "Options/OptionsCommand";
- mi.pszName = LPGEN("&Options...");
-
- AddGroupMenuItem(0,(LPARAM)&mi);
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize = sizeof(mi);
- mi.position = 500000;
- mi.hIcon = LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_CLIENTMIRANDA));
- mi.pszService = "Help/AboutCommand";
- mi.pszName = LPGEN("&About");
-
- //AddGroupMenuItem(0,(LPARAM)&mi);
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize = sizeof(mi);
- mi.position = 100000;
- mi.hIcon = ImageList_GetIcon(hCListImages,NewGroupIconidx,0);
- mi.pszService = MS_CLIST_GROUPCREATE;
- mi.pszName = LPGEN("&New Group");
- hNewGroupMenuItem = (HGENMENU)AddGroupMenuItem(0,(LPARAM)&mi);
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize = sizeof(mi);
- mi.position = 100001;
- mi.hIcon = NULL;
- mi.pszService = MS_CLIST_SETHIDEOFFLINE;
- mi.pszName = LPGEN("&Hide Offline Users");
- gmp.lParam = 0;gmp.wParam = -1;
- hHideOfflineUsersMenuItem = (HGENMENU)AddGroupMenuItem((WPARAM)&gmp,(LPARAM)&mi);
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize = sizeof(mi);
- mi.position = 100002;
- mi.hIcon = NULL;
- mi.pszService = "CLISTMENUSGroup/HideOfflineRootHelper";
- mi.pszName = LPGEN("Hide &Offline Users out here");
- hHideOfflineUsersOutHereMenuItem = (HGENMENU)AddGroupMenuItem(0,(LPARAM)&mi);
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize = sizeof(mi);
- mi.position = 100003;
- mi.hIcon = NULL;
- mi.pszService = "CLISTMENUSGroup/HideGroupsHelper";
- mi.pszName = LPGEN("Hide &Empty Groups");
- hHideEmptyGroupsMenuItem = (HGENMENU)AddGroupMenuItem(0,(LPARAM)&mi);
-
- memset(&mi,0,sizeof(mi));
- mi.cbSize = sizeof(mi);
- mi.position = 100004;
- mi.hIcon = NULL;
- mi.pszService = "CLISTMENUSGroup/UseGroupsHelper";
- mi.pszName = LPGEN("Disable &Groups");
- hDisableGroupsMenuItem = (HGENMENU)AddGroupMenuItem(0,(LPARAM)&mi);
-
- HookEvent(ME_SKIN2_ICONSCHANGED,OnIconLibIconChanged);
-
- //MS_CLIST_GROUPCREATE
-
+ //add exit command to menu
+ GroupMenuParam gmp;
+
+ CLISTMENUITEM mi = { sizeof(mi) };
+ mi.position = 1900000;
+ mi.pszService = "CloseAction";
+ mi.pszName = LPGEN("E&xit");
+ AddGroupMenuItem(0,(LPARAM)&mi);
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 500;
+ mi.pszService = MS_CLIST_SHOWHIDE;
+ mi.pszName = LPGEN("&Hide/Show");
+ hHideShowMainMenuItem = (HANDLE)AddGroupMenuItem(0,(LPARAM)&mi);
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 200000;
+ mi.hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_FINDUSER));
+ mi.pszService = "FindAdd/FindAddCommand";
+ mi.pszName = LPGEN("&Find/Add Contacts...");
+ AddGroupMenuItem(0,(LPARAM)&mi);
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 300000;
+ mi.pszService = "";
+ mi.pszName = LPGEN("&Main Menu");
+ hGroupMainMenuItemProxy = (HANDLE)AddGroupMenuItem(0,(LPARAM)&mi);
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 300100;
+ mi.pszService = "";
+ mi.pszName = LPGEN("&Status");
+ hGroupStatusMenuItemProxy = (HANDLE)AddGroupMenuItem(0,(LPARAM)&mi);
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 400000;
+ mi.hIcon = LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_OPTIONS));
+ mi.pszService = "Options/OptionsCommand";
+ mi.pszName = LPGEN("&Options...");
+
+ AddGroupMenuItem(0,(LPARAM)&mi);
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 500000;
+ mi.hIcon = LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_CLIENTMIRANDA));
+ mi.pszService = "Help/AboutCommand";
+ mi.pszName = LPGEN("&About");
+
+ //AddGroupMenuItem(0,(LPARAM)&mi);
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 100000;
+ mi.hIcon = ImageList_GetIcon(hCListImages,NewGroupIconidx,0);
+ mi.pszService = MS_CLIST_GROUPCREATE;
+ mi.pszName = LPGEN("&New Group");
+ hNewGroupMenuItem = (HGENMENU)AddGroupMenuItem(0,(LPARAM)&mi);
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 100001;
+ mi.hIcon = NULL;
+ mi.pszService = MS_CLIST_SETHIDEOFFLINE;
+ mi.pszName = LPGEN("&Hide Offline Users");
+ gmp.lParam = 0;gmp.wParam = -1;
+ hHideOfflineUsersMenuItem = (HGENMENU)AddGroupMenuItem((WPARAM)&gmp,(LPARAM)&mi);
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 100002;
+ mi.hIcon = NULL;
+ mi.pszService = "CLISTMENUSGroup/HideOfflineRootHelper";
+ mi.pszName = LPGEN("Hide &Offline Users out here");
+ hHideOfflineUsersOutHereMenuItem = (HGENMENU)AddGroupMenuItem(0,(LPARAM)&mi);
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 100003;
+ mi.hIcon = NULL;
+ mi.pszService = "CLISTMENUSGroup/HideGroupsHelper";
+ mi.pszName = LPGEN("Hide &Empty Groups");
+ hHideEmptyGroupsMenuItem = (HGENMENU)AddGroupMenuItem(0,(LPARAM)&mi);
+
+ memset(&mi,0,sizeof(mi));
+ mi.cbSize = sizeof(mi);
+ mi.position = 100004;
+ mi.hIcon = NULL;
+ mi.pszService = "CLISTMENUSGroup/UseGroupsHelper";
+ mi.pszName = LPGEN("Disable &Groups");
+ hDisableGroupsMenuItem = (HGENMENU)AddGroupMenuItem(0,(LPARAM)&mi);
+
+ HookEvent(ME_SKIN2_ICONSCHANGED,OnIconLibIconChanged);
}
}
diff --git a/plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp b/plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp
index 580aa254f8..20d51f2385 100644
--- a/plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp
+++ b/plugins/Clist_nicer/src/CLUIFrames/groupmenu.cpp
@@ -363,9 +363,7 @@ void InitGroupMenus(void)
mi.cbSize=sizeof(mi);
mi.position=100000;
mi.hIcon=ImageList_GetIcon(hCListImages,NewGroupIconidx,0);
- //mi.pszService=MS_CLIST_GROUPCREATE;
mi.pszService="CLISTMENUSSubGroup/GroupMenuExecProxy";
- //mi.pszService="CLISTMENUSGroup/ExecService";
mi.pszName=LPGEN("&New Group");
gmp.lParam=0;gmp.wParam=POPUP_NEWGROUP;
hNewGroupMenuItem = (HGENMENU)AddGroupMenuItem((WPARAM)&gmp,(LPARAM)&mi);
@@ -402,10 +400,7 @@ void InitGroupMenus(void)
mi.pszService="CLISTMENUSGroup/UseGroupsHelper";
mi.pszName=LPGEN("Disable &Groups");
hDisableGroupsMenuItem = (HGENMENU)AddGroupMenuItem(0,(LPARAM)&mi);
-
- //MS_CLIST_GROUPCREATE
-
- };
+ }
}
HANDLE hSubGroupMenuObject;
diff --git a/plugins/Clist_nicer/src/clui.cpp b/plugins/Clist_nicer/src/clui.cpp
index 2b02c47f1d..a758656de2 100644
--- a/plugins/Clist_nicer/src/clui.cpp
+++ b/plugins/Clist_nicer/src/clui.cpp
@@ -1520,7 +1520,7 @@ buttons_done:
case POPUP_NEWGROUP:
SendMessage(pcli->hwndContactTree, CLM_SETHIDEEMPTYGROUPS, 0, 0);
SendMessage(pcli->hwndContactTree, CLM_SETUSEGROUPS, 1, 0);
- CallService(MS_CLIST_GROUPCREATE, 0, 0);
+ Clist_CreateGroup(NULL, NULL);
break;
case POPUP_HIDEOFFLINE:
case IDC_TBHIDEOFFLINE:
diff --git a/plugins/CryptoPP/src/cpp_rsam.cpp b/plugins/CryptoPP/src/cpp_rsam.cpp
index a356e7ad0a..2c0593bbfa 100644
--- a/plugins/CryptoPP/src/cpp_rsam.cpp
+++ b/plugins/CryptoPP/src/cpp_rsam.cpp
@@ -918,8 +918,8 @@ unsigned __stdcall sttConnectThread( LPVOID arg ) {
if ( p->thread_exit == 1 ) return 0;
if ( p->thread_exit == 2 ) {
// мы в свободном плавании - освободим память и завершим трэд
- CloseHandle( p->thread );
- CloseHandle( p->event );
+ CloseHandle(p->thread);
+ CloseHandle(p->event);
SAFE_DELETE(p->queue);
SAFE_DELETE(p);
return 0;
diff --git a/plugins/DbEditorPP/src/exportimport.cpp b/plugins/DbEditorPP/src/exportimport.cpp
index f1e24cfc7c..23cea2f5dd 100644
--- a/plugins/DbEditorPP/src/exportimport.cpp
+++ b/plugins/DbEditorPP/src/exportimport.cpp
@@ -339,30 +339,6 @@ HANDLE CheckNewContact(char *myProto, char *uid, char *myName)
return INVALID_HANDLE_VALUE;
}
-HANDLE Clist_GroupExists(WCHAR *tszGroup)
-{
- unsigned int i = 0;
- WCHAR *_t = 0;
- char str[10];
- INT_PTR result = 0;
- DBVARIANT dbv = {0};
- int match;
-
- do {
- _itoa(i, str, 10);
- result = db_get_ts(0, "CListGroups", str, &dbv);
- if (!result) {
- match = (!lstrcmpW(tszGroup, (LPCWSTR)&dbv.ptszVal[1]) && (lstrlenW(tszGroup) == lstrlenW((LPCWSTR)&dbv.ptszVal[1])));
- db_free(&dbv);
- if(match)
- return((HANDLE)(i + 1));
- }
- i++;
- }
- while(result == 0);
- return(0);
-}
-
void importSettings(HANDLE hContact, char *importstring )
{
char module[256] = "", setting[256] = "", *end;
@@ -463,7 +439,7 @@ void importSettings(HANDLE hContact, char *importstring )
WCHAR* GroupName = mir_a2u(end+2);
if (!GroupName)
continue;
- HANDLE GroupHandle = Clist_GroupExists(GroupName);
+ HANDLE GroupHandle = (HANDLE)CallService(MS_CLIST_GROUPEXISTS, 0, LPARAM(GroupName));
if(GroupHandle == 0) {
GroupHandle = (HANDLE)CallService(MS_CLIST_GROUPCREATE, 0, (LPARAM)GroupName);
diff --git a/plugins/Scriver/src/chat/chat.h b/plugins/Scriver/src/chat/chat.h
index 23322099b3..0a702cd0f6 100644
--- a/plugins/Scriver/src/chat/chat.h
+++ b/plugins/Scriver/src/chat/chat.h
@@ -406,7 +406,6 @@ INT_PTR CList_JoinChat(WPARAM wParam, LPARAM lParam);
INT_PTR CList_LeaveChat(WPARAM wParam, LPARAM lParam);
INT_PTR CList_PrebuildContactMenuSvc(WPARAM wParam, LPARAM lParam);
int CList_PrebuildContactMenu(WPARAM wParam, LPARAM lParam);
-void CList_CreateGroup(TCHAR* group);
BOOL CList_AddEvent(HANDLE hContact, HICON Icon, HANDLE event, int type, TCHAR* fmt, ... ) ;
HANDLE CList_FindRoom (const char* pszModule, const TCHAR* pszRoom) ;
int WCCmp(TCHAR* wild, TCHAR*string);
diff --git a/plugins/Scriver/src/chat/clist.cpp b/plugins/Scriver/src/chat/clist.cpp
index 64fe7dfd7f..25ea62df58 100644
--- a/plugins/Scriver/src/chat/clist.cpp
+++ b/plugins/Scriver/src/chat/clist.cpp
@@ -38,33 +38,15 @@ HANDLE CList_AddRoom(const char* pszModule, const TCHAR* pszRoom, const TCHAR* p
else lstrcpyn( pszGroup, _T("Chat rooms"), 50);
if (pszGroup[0])
- CList_CreateGroup(pszGroup);
+ Clist_CreateGroup(0, pszGroup);
if (hContact) { //contact exist, make sure it is in the right group
if (pszGroup[0]) {
- for (int i = 0;; i++) {
- char str[50];
- _itoa(i, str, 10);
-
- DBVARIANT dbv, dbv2;
- if (db_get_ts( NULL, "CListGroups", str, &dbv)) {
- db_set_ts(hContact, "CList", "Group", pszGroup);
- goto END_GROUPLOOP;
- }
-
- if ( !db_get_ts( hContact, "CList", "Group", &dbv2 )) {
- if ( dbv.ptszVal[0] != '\0' && dbv2.ptszVal[0] != '\0' && !lstrcmpi( dbv.ptszVal + 1, dbv2.ptszVal )) {
- db_free(&dbv);
- db_free(&dbv2);
- goto END_GROUPLOOP;
- }
- db_free(&dbv2);
- }
- db_free(&dbv);
- }
+ ptrT grpName( db_get_tsa(hContact, "CList", "Group"));
+ if ( !lstrcmp(pszGroup, grpName))
+ db_set_ts(hContact, "CList", "Group", pszGroup);
}
-END_GROUPLOOP:
db_set_w(hContact, pszModule, "Status", ID_STATUS_OFFLINE);
db_set_ts(hContact, pszModule, "Nick", pszDisplayName );
return hContact;
@@ -221,37 +203,6 @@ INT_PTR CList_PrebuildContactMenuSvc(WPARAM wParam, LPARAM lParam)
return CList_PrebuildContactMenu(wParam, lParam);
}
-void CList_CreateGroup(TCHAR* group)
-{
- int i;
- char str[50];
- TCHAR name[256];
- DBVARIANT dbv;
-
- if (!group)
- return;
-
- for (i = 0;; i++) {
- _itoa(i, str, 10);
- if ( db_get_ts( NULL, "CListGroups", str, &dbv ))
- break;
-
- if ( dbv.pszVal[0] != '\0' && !lstrcmpi(dbv.ptszVal + 1, group)) {
- db_free(&dbv);
- return;
- }
-
- db_free(&dbv);
- }
-
- // CallService(MS_CLIST_GROUPCREATE, (WPARAM)group, 0);
- name[0] = 1 | GROUPF_EXPANDED;
- _tcsncpy(name + 1, group, SIZEOF(name) - 1);
- name[ lstrlen(group) + 1] = '\0';
- db_set_ts(NULL, "CListGroups", str, name);
- CallService(MS_CLUI_GROUPADDED, i + 1, 0);
-}
-
BOOL CList_AddEvent(HANDLE hContact, HICON Icon, HANDLE event, int type, TCHAR* fmt, ... )
{
if (!fmt || lstrlen(fmt) < 1 || lstrlen(fmt) > 2000)
diff --git a/plugins/TabSRMM/src/chat/clist.cpp b/plugins/TabSRMM/src/chat/clist.cpp
index 644fdf2338..3afb600074 100644
--- a/plugins/TabSRMM/src/chat/clist.cpp
+++ b/plugins/TabSRMM/src/chat/clist.cpp
@@ -36,20 +36,6 @@ plugin, originally written by Jцrgen Persson
char *szChatIconString = "chaticon";
-static HANDLE Clist_GroupExists(TCHAR *tszGroup)
-{
- for (int i=0; ; i++) {
- char str[10];
- _itoa(i, str, 10);
- ptrT groupName( db_get_tsa(0, "CListGroups", str));
- if (groupName == NULL)
- return NULL;
-
- if (!_tcscmp(tszGroup, &groupName[1]) && lstrlen(tszGroup) == lstrlen(&groupName[1]))
- return HANDLE(i + 1);
- }
-}
-
HANDLE CList_AddRoom(const char* pszModule, const TCHAR* pszRoom, const TCHAR* pszDisplayName, int iType)
{
TCHAR pszGroup[50]; *pszGroup = '\0';
@@ -222,9 +208,8 @@ void CList_CreateGroup(TCHAR* group)
return;
g_Settings.hGroup = Clist_GroupExists(group);
-
if (g_Settings.hGroup == 0) {
- g_Settings.hGroup = (HANDLE)CallService(MS_CLIST_GROUPCREATE, 0, (LPARAM)group);
+ g_Settings.hGroup = Clist_CreateGroup(0, group);
if (g_Settings.hGroup) {
CallService(MS_CLUI_GROUPADDED, (WPARAM)g_Settings.hGroup, 0);
diff --git a/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp b/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp
index 6a7851d374..a33df3f01f 100644
--- a/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp
+++ b/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp
@@ -21,25 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "..\commonheaders.h"
-HANDLE CListFindGroup(LPCSTR pszGroup)
-{
- CHAR buf[4];
- BYTE i;
- DBVARIANT dbv;
-
- for (i = 0; i < 255; i++) {
- _itoa(i, buf, 10);
- if (DB::Setting::GetUString(NULL, "CListGroups", buf, &dbv))
- break;
- if (dbv.pszVal && pszGroup && !_stricmp(dbv.pszVal + 1, pszGroup)) {
- db_free(&dbv);
- return (HANDLE)(INT_PTR)(i+1);
- }
- db_free(&dbv);
- }
- return INVALID_HANDLE_VALUE;
-}
-
/**
* name: CExImContactBase
* class: CExImContactBase
@@ -280,13 +261,14 @@ HANDLE CExImContactBase::toDB()
// add group
if (_pszGroup) {
- db_set_utf(_hContact, MOD_CLIST, "Group", _pszGroup);
- if (CListFindGroup(_pszGroup) == INVALID_HANDLE_VALUE) {
- WPARAM hGroup = (WPARAM)CallService(MS_CLIST_GROUPCREATE, 0, 0);
+ ptrT ptszGroup( mir_utf8decodeT(_pszGroup));
+ db_set_ts(_hContact, MOD_CLIST, "Group", ptszGroup);
+ if ( Clist_GroupExists(ptszGroup) == NULL) {
+ HANDLE hGroup = Clist_CreateGroup(NULL, NULL);
if (hGroup) {
// renaming twice is stupid but the only way to avoid error dialog telling shit like
// a group with that name does exist
- CallService(MS_CLIST_GROUPRENAME, (WPARAM)hGroup, (LPARAM)_pszGroup);
+ CallService(MS_CLIST_GROUPRENAME, (WPARAM)hGroup, (LPARAM)ptszGroup);
}
}
}
diff --git a/protocols/AimOscar/src/utility.cpp b/protocols/AimOscar/src/utility.cpp
index 1600e3dc3a..1ae59c437f 100644
--- a/protocols/AimOscar/src/utility.cpp
+++ b/protocols/AimOscar/src/utility.cpp
@@ -372,7 +372,7 @@ void create_group(const char *group)
if (strcmp(group, AIM_DEFAULT_GROUP) == 0) return;
TCHAR* szGroupName = mir_utf8decodeT(group);
- CallService(MS_CLIST_GROUPCREATE, 0, (LPARAM)szGroupName);
+ Clist_CreateGroup(0, szGroupName);
mir_free(szGroupName);
}
diff --git a/protocols/FacebookRM/src/connection.cpp b/protocols/FacebookRM/src/connection.cpp
index afe0fbcf45..38e00a4fc2 100644
--- a/protocols/FacebookRM/src/connection.cpp
+++ b/protocols/FacebookRM/src/connection.cpp
@@ -187,7 +187,7 @@ bool FacebookProto::NegotiateConnection()
// Create default group for new contacts
ptrT groupName( getTStringA(FACEBOOK_KEY_DEF_GROUP));
if (groupName != NULL)
- CallService(MS_CLIST_GROUPCREATE, 0, (LPARAM)groupName);
+ Clist_CreateGroup(0, groupName);
return facy.login(user, pass);
}
diff --git a/protocols/FacebookRM/src/dialogs.cpp b/protocols/FacebookRM/src/dialogs.cpp
index 1d968768af..b2181d8aa9 100644
--- a/protocols/FacebookRM/src/dialogs.cpp
+++ b/protocols/FacebookRM/src/dialogs.cpp
@@ -422,7 +422,7 @@ INT_PTR CALLBACK FBOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
if (lstrlen(tstr) > 0)
{
proto->setTString(FACEBOOK_KEY_DEF_GROUP, tstr);
- CallService(MS_CLIST_GROUPCREATE, 0, (LPARAM)tstr);
+ Clist_CreateGroup( 0, tstr);
}
else proto->delSetting(FACEBOOK_KEY_DEF_GROUP);
diff --git a/protocols/Gadu-Gadu/src/import.cpp b/protocols/Gadu-Gadu/src/import.cpp
index 11cf777cd9..6299539c8a 100644
--- a/protocols/Gadu-Gadu/src/import.cpp
+++ b/protocols/Gadu-Gadu/src/import.cpp
@@ -20,81 +20,6 @@
#include "gg.h"
-////////////////////////////////////////////////////////////////////////////////
-// Checks if a group already exists in Miranda with
-// the specified name.
-// Returns 1 if a group with the name exists, returns 0 otherwise.
-int GroupNameExists(const char *name)
-{
- char idstr[33];
- DBVARIANT dbv;
- int i;
-
- for (i = 0; ; i++) {
- _itoa(i, idstr, 10);
- if (db_get_s(NULL, "CListGroups", idstr, &dbv, DBVT_ASCIIZ)) break;
- if (!strcmp(dbv.pszVal + 1, name)) {
- db_free(&dbv);
- return 1;
- }
- db_free(&dbv);
- }
- return 0;
-}
-
-
-////////////////////////////////////////////////////////////////////////////////
-// Creates a group with a specified name in the
-// Miranda contact list.
-// Returns proper group name
-
-char *CreateGroup(char *groupName)
-{
- int groupId;
- char groupIdStr[11];
- char groupName2[127];
- char *p;
- DBVARIANT dbv;
-
- // Cleanup group name from weird characters
-
- // Skip first break
- while(*groupName && *groupName == '\\') groupName++;
-
- p = strrchr(groupName, '\\');
- // Cleanup end
- while(p && !(*(p + 1)))
- {
- *p = 0;
- p = strrchr(groupName, '\\');
- }
- // Create upper groups
- if (p)
- {
- *p = 0;
- CreateGroup(groupName);
- *p = '\\';
- }
-
- // Is this a duplicate?
- if (!GroupNameExists(groupName))
- {
- lstrcpynA(groupName2 + 1, groupName, (int)strlen(groupName) + 1);
-
- // Find an unused id
- for (groupId = 0; ; groupId++) {
- _itoa(groupId, groupIdStr,10);
- if (db_get_s(NULL, "CListGroups", groupIdStr, &dbv, DBVT_ASCIIZ))
- break;
- db_free(&dbv);
- }
-
- groupName2[0] = 1|GROUPF_EXPANDED; // 1 is required so we never get '\0'
- db_set_s(NULL, "CListGroups", groupIdStr, groupName2);
- }
- return groupName;
-}
-
char *gg_makecontacts(GGPROTO *gg, int cr)
{
string_t s = string_init(NULL);
@@ -290,8 +215,11 @@ void GGPROTO::parsecontacts(char *contacts)
netlog("parsecontacts(): Found contact %d with nickname \"%s\".", uin, strNick);
#endif
// Write group
- if (hContact && strGroup)
- db_set_s(hContact, "CList", "Group", CreateGroup(strGroup));
+ if (hContact && strGroup) {
+ ptrT tszGrpName( mir_a2t(strGroup));
+ Clist_CreateGroup(0, tszGrpName);
+ db_set_ts(hContact, "CList", "Group", tszGrpName);
+ }
// Write misc data
if (hContact && strFirstName){
diff --git a/protocols/IcqOscarJ/src/icq_proto.h b/protocols/IcqOscarJ/src/icq_proto.h
index af852a7b8f..98dfb90c1c 100644
--- a/protocols/IcqOscarJ/src/icq_proto.h
+++ b/protocols/IcqOscarJ/src/icq_proto.h
@@ -678,7 +678,6 @@ struct CIcqProto : public PROTO<CIcqProto>
void resetServContactAuthState(HANDLE hContact, DWORD dwUin);
void FlushSrvGroupsCache();
- int getCListGroupHandle(const char *szGroup);
int getCListGroupExists(const char *szGroup);
int moveContactToCListGroup(HANDLE hContact, const char *szGroup); /// TODO: this should be DB function
diff --git a/protocols/IcqOscarJ/src/icq_servlist.cpp b/protocols/IcqOscarJ/src/icq_servlist.cpp
index 7110e3ea2e..3d5c88e85d 100644
--- a/protocols/IcqOscarJ/src/icq_servlist.cpp
+++ b/protocols/IcqOscarJ/src/icq_servlist.cpp
@@ -1571,40 +1571,6 @@ void CIcqProto::setServListGroupLinkID(const char *szPath, WORD wGroupID)
db_unset(NULL, szModule, szPath);
}
-
-// this function takes all backslashes in szGroup as group-level separators
-int CIcqProto::getCListGroupHandle(const char *szGroup)
-{
- char *pszGroup = (char*)szGroup;
- int hParentGroup = 0, hGroup = 0;
-
- if (!strlennull(szGroup)) return 0; // no group
-
- if (strrchr(szGroup, '\\'))
- { // create parent group
- char *szSeparator = (char*)strrchr(szGroup, '\\');
-
- *szSeparator = '\0';
- hParentGroup = getCListGroupHandle(szGroup);
- *szSeparator = '\\';
- // take only sub-group name
- pszGroup = ++szSeparator;
- }
-
- int size = strlennull(szGroup) + 2;
- TCHAR *tszGroup = (TCHAR*)_alloca(size * sizeof(TCHAR));
-
- if (utf8_to_tchar_static(pszGroup, tszGroup, size))
- hGroup = CallService(MS_CLIST_GROUPCREATE, hParentGroup, (LPARAM)tszGroup); // 0.7+
-
-#ifdef _DEBUG
- NetLog_Server("Obtained CList group \"%s\" handle %x", szGroup, hGroup);
-#endif
-
- return hGroup;
-}
-
-
// determine if the specified clist group path exists
//!! this function is not thread-safe due to the use of cli->pfnGetGroupName()
int CIcqProto::getCListGroupExists(const char *szGroup)
@@ -1612,7 +1578,6 @@ int CIcqProto::getCListGroupExists(const char *szGroup)
if (!szGroup)
return 0;
- int hGroup = 0;
int size = strlennull(szGroup) + 2;
TCHAR *tszGroup = (TCHAR*)_alloca(size * sizeof(TCHAR));
@@ -1622,23 +1587,21 @@ int CIcqProto::getCListGroupExists(const char *szGroup)
if (!tszGroupName)
break;
- if (!_tcscmp(tszGroup, tszGroupName)) {
- // we have found the group
- hGroup = i;
- break;
- }
+ // we have found the group
+ if (!_tcscmp(tszGroup, tszGroupName))
+ return i;
}
- return hGroup;
+ return 0;
}
int CIcqProto::moveContactToCListGroup(HANDLE hContact, const char *szGroup)
{
- int hGroup = getCListGroupHandle(szGroup);
+ HANDLE hGroup = Clist_CreateGroup(0, _A2T(szGroup));
if (ServiceExists(MS_CLIST_CONTACTCHANGEGROUP))
- return CallService(MS_CLIST_CONTACTCHANGEGROUP, (WPARAM)hContact, hGroup);
+ return CallService(MS_CLIST_CONTACTCHANGEGROUP, (WPARAM)hContact, (LPARAM)hGroup);
else /// TODO: is this neccessary ?
return db_set_utf(hContact, "CList", "Group", szGroup);
}
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;
}
diff --git a/protocols/MSN/src/msn_srv.cpp b/protocols/MSN/src/msn_srv.cpp
index 984f49d2c6..1fcdb0eba2 100644
--- a/protocols/MSN/src/msn_srv.cpp
+++ b/protocols/MSN/src/msn_srv.cpp
@@ -39,11 +39,7 @@ void CMsnProto::MSN_AddGroup(const char* grpName, const char *grpId, bool init)
grpList.insert(p);
if (init)
- {
- TCHAR* szGroupName = mir_utf8decodeT(grpName);
- CallService(MS_CLIST_GROUPCREATE, 0, (LPARAM)szGroupName);
- mir_free(szGroupName);
- }
+ Clist_CreateGroup(0, ptrT( mir_utf8decodeT(grpName)));
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/Skype/src/skype_account.cpp b/protocols/Skype/src/skype_account.cpp
index d62613e1d1..218639d919 100644
--- a/protocols/Skype/src/skype_account.cpp
+++ b/protocols/Skype/src/skype_account.cpp
@@ -151,7 +151,7 @@ void CSkypeProto::SetAccountSettings()
if ( !getTString(SKYPE_SETTINGS_DEF_GROUP, &dbv) && lstrlen(dbv.ptszVal) > 0)
{
this->Log(L"Setting default group for new contacts");
- ::CallService(MS_CLIST_GROUPCREATE, 0, (LPARAM)dbv.ptszVal);
+ ::Clist_CreateGroup(0, dbv.ptszVal);
::db_free(&dbv);
}
}
diff --git a/protocols/Skype/src/skype_dialogs.cpp b/protocols/Skype/src/skype_dialogs.cpp
index 88d0254bcc..3a830b2471 100644
--- a/protocols/Skype/src/skype_dialogs.cpp
+++ b/protocols/Skype/src/skype_dialogs.cpp
@@ -174,7 +174,7 @@ INT_PTR CALLBACK CSkypeProto::SkypeMainOptionsProc(HWND hwnd, UINT message, WPAR
if (lstrlen(tstr) > 0)
{
::db_set_ts(NULL, proto->m_szModuleName, SKYPE_SETTINGS_DEF_GROUP, tstr);
- ::CallService(MS_CLIST_GROUPCREATE, 0, (LPARAM)tstr);
+ ::Clist_CreateGroup(0, tstr);
}
else
::db_unset(NULL, proto->m_szModuleName, SKYPE_SETTINGS_DEF_GROUP);
diff --git a/protocols/Tlen/src/tlen.h b/protocols/Tlen/src/tlen.h
index e271a3d915..c6b4b64845 100644
--- a/protocols/Tlen/src/tlen.h
+++ b/protocols/Tlen/src/tlen.h
@@ -496,8 +496,6 @@ void TlenStringAppend(char **str, int *sizeAlloced, const char *fmt, ...);
void TlenDBAddEvent(TlenProtocol *proto, HANDLE hContact, int eventType, DWORD flags, PBYTE pBlob, DWORD cbBlob);
void TlenDBAddAuthRequest(TlenProtocol *proto, char *jid, char *nick);
HANDLE TlenDBCreateContact(TlenProtocol *proto, char *jid, char *nick, BOOL temporary);
-void TlenContactListCreateGroup(char *groupName);
-unsigned long TlenForkThread(void (__cdecl *threadcode)(void*), unsigned long stacksize, void *arg);
// tlen_svc.cpp
int TlenRunSearch(TlenProtocol *proto);
// tlen_opt.cpp
diff --git a/protocols/Tlen/src/tlen_avatar.cpp b/protocols/Tlen/src/tlen_avatar.cpp
index f832ba9188..2fd8436226 100644
--- a/protocols/Tlen/src/tlen_avatar.cpp
+++ b/protocols/Tlen/src/tlen_avatar.cpp
@@ -298,7 +298,7 @@ void TlenGetAvatar(TlenProtocol *proto, HANDLE hContact) {
TLENGETAVATARTHREADDATA *data = (TLENGETAVATARTHREADDATA *)mir_alloc(sizeof(TLENGETAVATARTHREADDATA));
data->proto = proto;
data->hContact = hContact;
- TlenForkThread(TlenGetAvatarThread, 0, data);
+ forkthread(TlenGetAvatarThread, 0, data);
}
}
@@ -361,7 +361,7 @@ void TlenRemoveAvatar(TlenProtocol *proto) {
req->cbSize = sizeof(NETLIBHTTPREQUEST);
req->requestType = proto->threadData->tlenConfig.avatarGetMthd;
req->szUrl = request;
- TlenForkThread(TlenRemoveAvatarRequestThread, 0, data);
+ forkthread(TlenRemoveAvatarRequestThread, 0, data);
}
}
@@ -401,7 +401,7 @@ void TlenUploadAvatar(TlenProtocol *proto, unsigned char *data, int dataLen, int
threadData->data = (char *) mir_alloc(dataLen);
memcpy(threadData->data, data, dataLen);
threadData->length = dataLen;
- TlenForkThread(TlenUploadAvatarRequestThread, 0, threadData);
+ forkthread(TlenUploadAvatarRequestThread, 0, threadData);
}
}
diff --git a/protocols/Tlen/src/tlen_file.cpp b/protocols/Tlen/src/tlen_file.cpp
index 2bfb56f791..fed69c8ae6 100644
--- a/protocols/Tlen/src/tlen_file.cpp
+++ b/protocols/Tlen/src/tlen_file.cpp
@@ -654,7 +654,7 @@ void TlenProcessF(XmlNode *node, ThreadData *info)
if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) {
if ((item=TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) {
if (!strcmp(item->ft->jid, jid))
- TlenForkThread((void (__cdecl *)(void*))TlenFileSendingThread, 0, item->ft);
+ forkthread((void (__cdecl *)(void*))TlenFileSendingThread, 0, item->ft);
}
}
}
@@ -666,7 +666,7 @@ void TlenProcessF(XmlNode *node, ThreadData *info)
item->ft->hostName = mir_strdup(p);
if ((p=TlenXmlGetAttrValue(node, "p")) != NULL) {
item->ft->wPort = atoi(p);
- TlenForkThread((void (__cdecl *)(void*))TlenFileReceiveThread, 0, item->ft);
+ forkthread((void (__cdecl *)(void*))TlenFileReceiveThread, 0, item->ft);
}
}
}
diff --git a/protocols/Tlen/src/tlen_iqid.cpp b/protocols/Tlen/src/tlen_iqid.cpp
index a9637df40c..a7638ad549 100644
--- a/protocols/Tlen/src/tlen_iqid.cpp
+++ b/protocols/Tlen/src/tlen_iqid.cpp
@@ -107,7 +107,7 @@ void TlenResultSetRoster(TlenProtocol *proto, XmlNode *queryNode) {
if (item->group) mir_free(item->group);
if ((groupNode=TlenXmlGetChild(itemNode, "group")) != NULL && groupNode->text != NULL) {
item->group = TlenGroupDecode(groupNode->text);
- TlenContactListCreateGroup(item->group);
+ Clist_CreateGroup(0, _A2T(item->group));
// Don't set group again if already correct, or Miranda may show wrong group count in some case
if (!db_get(hContact, "CList", "Group", &dbv)) {
if (strcmp(dbv.pszVal, item->group))
@@ -179,7 +179,7 @@ void TlenIqResultRoster(TlenProtocol *proto, XmlNode *iqNode)
if (item->group) mir_free(item->group);
if ((groupNode=TlenXmlGetChild(itemNode, "group")) != NULL && groupNode->text != NULL) {
item->group = TlenGroupDecode(groupNode->text);
- TlenContactListCreateGroup(item->group);
+ Clist_CreateGroup(0, _A2T(item->group));
// Don't set group again if already correct, or Miranda may show wrong group count in some case
if (!db_get(hContact, "CList", "Group", &dbv)) {
if (strcmp(dbv.pszVal, item->group))
diff --git a/protocols/Tlen/src/tlen_misc.cpp b/protocols/Tlen/src/tlen_misc.cpp
index 4c05d5e566..7876d2348e 100644
--- a/protocols/Tlen/src/tlen_misc.cpp
+++ b/protocols/Tlen/src/tlen_misc.cpp
@@ -123,88 +123,3 @@ HANDLE TlenDBCreateContact(TlenProtocol *proto, char *jid, char *nick, BOOL temp
}
return hContact;
}
-
-static void TlenContactListCreateClistGroup(char *groupName)
-{
- char str[33], newName[128];
- int i;
- DBVARIANT dbv;
- char *name;
-
- for (i=0;;i++) {
- itoa(i, str, 10);
- if (db_get(NULL, "CListGroups", str, &dbv))
- break;
- name = dbv.pszVal;
- if (name[0] != '\0' && !strcmp(name+1, groupName)) {
- // Already exist, no need to create
- db_free(&dbv);
- return;
- }
- db_free(&dbv);
- }
-
- // Create new group with id = i (str is the text representation of i)
- newName[0] = 1 | GROUPF_EXPANDED;
- strncpy(newName+1, groupName, sizeof(newName)-1);
- newName[sizeof(newName)-1] = '\0';
- db_set_s(NULL, "CListGroups", str, newName);
- CallService(MS_CLUI_GROUPADDED, i+1, 0);
-}
-
-void TlenContactListCreateGroup(char *groupName)
-{
- char name[128];
- char *p;
-
- if (groupName == NULL || groupName[0] == '\0' || groupName[0] == '\\') return;
-
- strncpy(name, groupName, sizeof(name));
- name[sizeof(name)-1] = '\0';
- for (p=name; *p != '\0'; p++) {
- if (*p == '\\') {
- *p = '\0';
- TlenContactListCreateClistGroup(name);
- *p = '\\';
- }
- }
- TlenContactListCreateClistGroup(name);
-}
-
-
-struct FORK_ARG {
- HANDLE hEvent;
- void (__cdecl *threadcode)(void*);
- void *arg;
-};
-
-static void __cdecl forkthread_r(struct FORK_ARG *fa)
-{
- void (*callercode)(void*) = fa->threadcode;
- void *arg = fa->arg;
- Thread_Push(0);
- SetEvent(fa->hEvent);
- callercode(arg);
- Thread_Pop();
- return;
-}
-
-unsigned long TlenForkThread(
- void (__cdecl *threadcode)(void*),
- unsigned long stacksize,
- void *arg
-)
-{
- unsigned long rc;
- struct FORK_ARG fa;
-
- fa.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
- fa.threadcode = threadcode;
- fa.arg = arg;
- rc = _beginthread((void (__cdecl *)(void*))forkthread_r, stacksize, &fa);
- if ((unsigned long) -1L != rc) {
- WaitForSingleObject(fa.hEvent, INFINITE);
- }
- CloseHandle(fa.hEvent);
- return rc;
-}
diff --git a/protocols/Tlen/src/tlen_muc.cpp b/protocols/Tlen/src/tlen_muc.cpp
index a62601b760..102a54ffbd 100644
--- a/protocols/Tlen/src/tlen_muc.cpp
+++ b/protocols/Tlen/src/tlen_muc.cpp
@@ -996,7 +996,7 @@ static int TlenMUCQueryContacts(TlenProtocol *proto, const char *roomId) {
MUCSENDQUERYTHREADDATA *threadData = (MUCSENDQUERYTHREADDATA *)mir_alloc(sizeof(MUCSENDQUERYTHREADDATA));
threadData->proto = proto;
threadData->roomId = mir_strdup(roomId);
- TlenForkThread(TlenMUCCSendQueryResultThread, 0, (void *)threadData);
+ forkthread(TlenMUCCSendQueryResultThread, 0, (void *)threadData);
return 1;
}
diff --git a/protocols/Tlen/src/tlen_p2p_new.cpp b/protocols/Tlen/src/tlen_p2p_new.cpp
index 74e7e28f8d..c8a9c49ea2 100644
--- a/protocols/Tlen/src/tlen_p2p_new.cpp
+++ b/protocols/Tlen/src/tlen_p2p_new.cpp
@@ -331,8 +331,8 @@ void __cdecl TlenProcessP2P(XmlNode *node, ThreadData *info) {
TlenBindUDPSocket(item->ft);
TlenSend(info->proto, "<iq to='%s'><query xmlns='p2p'><dcng la='%s' lp='%d' pa='%s' pp='%d' i='%s' k='5' s='4'/></query></iq>",
item->ft->jid, item->ft->localName, item->ft->wLocalPort, item->ft->localName, item->ft->wLocalPort, item->ft->id2);
- TlenForkThread((void (__cdecl *)(void*))TlenNewFileReceiveThread, 0, item->ft);
- TlenForkThread((void (__cdecl *)(void*))TlenNewFileSendThread, 0, item->ft);
+ forkthread((void (__cdecl *)(void*))TlenNewFileReceiveThread, 0, item->ft);
+ forkthread((void (__cdecl *)(void*))TlenNewFileSendThread, 0, item->ft);
}
} else if (!strcmp(s, "4")) {
/* IP and port */
@@ -340,7 +340,7 @@ void __cdecl TlenProcessP2P(XmlNode *node, ThreadData *info) {
TlenLog(info->proto, "step = 4");
item->ft->hostName = mir_strdup(TlenXmlGetAttrValue(dcng, "pa"));
item->ft->wPort = atoi(TlenXmlGetAttrValue(dcng, "pp"));
- TlenForkThread((void (__cdecl *)(void*))TlenNewFileReceiveThread, 0, item->ft);
+ forkthread((void (__cdecl *)(void*))TlenNewFileReceiveThread, 0, item->ft);
}
}
diff --git a/protocols/Tlen/src/tlen_p2p_old.cpp b/protocols/Tlen/src/tlen_p2p_old.cpp
index 4eb07d5be6..92ee4b6681 100644
--- a/protocols/Tlen/src/tlen_p2p_old.cpp
+++ b/protocols/Tlen/src/tlen_p2p_old.cpp
@@ -348,7 +348,7 @@ static TLEN_SOCKET TlenP2PBindSocks4(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft)
strcpy(sb->szHost, inet_ntoa(in));
sb->wPort = htons(*(PWORD)(buf+2));
ft->s = s;
- TlenForkThread((void (__cdecl *)(void*))TlenFileBindSocks4Thread, 0, ft);
+ forkthread((void (__cdecl *)(void*))TlenFileBindSocks4Thread, 0, ft);
return s;
}
@@ -448,7 +448,7 @@ static TLEN_SOCKET TlenP2PBindSocks5(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft)
sb->wPort = htons(*(PWORD)(buf+len));
ft->s = s;
- TlenForkThread((void (__cdecl *)(void*))TlenFileBindSocks5Thread, 0, ft);
+ forkthread((void (__cdecl *)(void*))TlenFileBindSocks5Thread, 0, ft);
return s;
}
diff --git a/protocols/Tlen/src/tlen_picture.cpp b/protocols/Tlen/src/tlen_picture.cpp
index d121d0984e..25618f9bec 100644
--- a/protocols/Tlen/src/tlen_picture.cpp
+++ b/protocols/Tlen/src/tlen_picture.cpp
@@ -98,7 +98,7 @@ static void TlenPsPost(TlenProtocol *proto, TLEN_LIST_ITEM *item) {
TLENPSREQUESTTHREADDATA *threadData = (TLENPSREQUESTTHREADDATA *)mir_alloc(sizeof(TLENPSREQUESTTHREADDATA));
threadData->proto = proto;
threadData->item = item;
- TlenForkThread(TlenPsPostThread, 0, threadData);
+ forkthread(TlenPsPostThread, 0, threadData);
}
static void TlenPsGetThread(void *ptr) {
@@ -171,7 +171,7 @@ static void TlenPsGet(TlenProtocol *proto, TLEN_LIST_ITEM *item) {
TLENPSREQUESTTHREADDATA *threadData = (TLENPSREQUESTTHREADDATA *)mir_alloc(sizeof(TLENPSREQUESTTHREADDATA));
threadData->proto = proto;
threadData->item = item;
- TlenForkThread(TlenPsGetThread, 0, threadData);
+ forkthread(TlenPsGetThread, 0, threadData);
}
void TlenProcessPic(XmlNode *node, TlenProtocol *proto) {
diff --git a/protocols/Tlen/src/tlen_svc.cpp b/protocols/Tlen/src/tlen_svc.cpp
index c8298b9b88..558358bb2e 100644
--- a/protocols/Tlen/src/tlen_svc.cpp
+++ b/protocols/Tlen/src/tlen_svc.cpp
@@ -359,7 +359,7 @@ static void TlenConnect(TlenProtocol *proto, int initialStatus)
oldStatus = proto->m_iStatus;
proto->m_iStatus = ID_STATUS_CONNECTING;
ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE) oldStatus, proto->m_iStatus);
- thread->hThread = (HANDLE) TlenForkThread((void (__cdecl *)(void*))TlenServerThread, 0, thread);
+ thread->hThread = (HANDLE) forkthread((void (__cdecl *)(void*))TlenServerThread, 0, thread);
}
}
@@ -602,7 +602,7 @@ int TlenProtocol::SendMsg(HANDLE hContact, int flags, const char* msgRAW)
char msgType[16];
if (!isOnline || db_get(hContact, m_szModuleName, "jid", &dbv)) {
- TlenForkThread(TlenSendMessageFailedThread, 0, new SENDACKTHREADDATA(this, hContact, 2));
+ forkthread(TlenSendMessageFailedThread, 0, new SENDACKTHREADDATA(this, hContact, 2));
return 2;
}
@@ -619,11 +619,11 @@ int TlenProtocol::SendMsg(HANDLE hContact, int flags, const char* msgRAW)
if (!strcmp(msg, "<alert>")) {
TlenSend(this, "<m tp='a' to='%s'/>", dbv.pszVal);
- TlenForkThread(TlenSendMessageAckThread, 0, new SENDACKTHREADDATA(this, hContact, id));
+ forkthread(TlenSendMessageAckThread, 0, new SENDACKTHREADDATA(this, hContact, id));
}
else if (!strcmp(msg, "<image>")) {
TlenSend(this, "<message to='%s' type='%s' crc='%x' idt='%d'/>", dbv.pszVal, "pic", 0x757f044, id);
- TlenForkThread(TlenSendMessageAckThread, 0, new SENDACKTHREADDATA(this, hContact, id));
+ forkthread(TlenSendMessageAckThread, 0, new SENDACKTHREADDATA(this, hContact, id));
}
else {
if ((msgEnc=TlenTextEncode(msg)) != NULL) {
@@ -645,7 +645,7 @@ int TlenProtocol::SendMsg(HANDLE hContact, int flags, const char* msgRAW)
else
TlenSend(this, "<message to='%s' type='%s' id='"TLEN_IQID"%d'><body>%s</body><x xmlns='jabber:x:event'><composing/></x></message>", dbv.pszVal, msgType, id, msgEnc);
- TlenForkThread(TlenSendMessageAckThread, 0, new SENDACKTHREADDATA(this, hContact, id));
+ forkthread(TlenSendMessageAckThread, 0, new SENDACKTHREADDATA(this, hContact, id));
}
else {
if ((item=TlenListGetItemPtr(this, LIST_ROSTER, dbv.pszVal)) != NULL)
@@ -705,7 +705,7 @@ INT_PTR TlenProtocol::GetAvatarInfo(WPARAM wParam, LPARAM lParam)
HANDLE TlenProtocol::GetAwayMsg(HANDLE hContact)
{
SENDACKTHREADDATA *tdata = new SENDACKTHREADDATA(this, hContact, 0);
- TlenForkThread((void (__cdecl *)(void*))TlenGetAwayMsgThread, 0, (void*)tdata);
+ forkthread((void (__cdecl *)(void*))TlenGetAwayMsgThread, 0, (void*)tdata);
return (HANDLE)1;
}
diff --git a/protocols/Tlen/src/tlen_thread.cpp b/protocols/Tlen/src/tlen_thread.cpp
index 5f143389ae..f9fe2ef01e 100644
--- a/protocols/Tlen/src/tlen_thread.cpp
+++ b/protocols/Tlen/src/tlen_thread.cpp
@@ -277,7 +277,7 @@ void __cdecl TlenServerThread(ThreadData *info)
if (info->proto->m_iDesiredStatus != ID_STATUS_OFFLINE) {
info->proto->isConnected = TRUE;
- TlenForkThread(TlenKeepAliveThread, 0, info->proto);
+ forkthread(TlenKeepAliveThread, 0, info->proto);
TlenXmlInitState(&xmlState);
TlenXmlSetCallback(&xmlState, 1, ELEM_OPEN, (void (__cdecl *)(XmlNode *,void *))TlenProcessStreamOpening, info);
@@ -795,7 +795,7 @@ static void TlenProcessIq(XmlNode *node, ThreadData *info)
if (item->group) mir_free(item->group);
if ((groupNode=TlenXmlGetChild(itemNode, "group")) != NULL && groupNode->text != NULL) {
item->group = TlenGroupDecode(groupNode->text);
- TlenContactListCreateGroup(item->group);
+ Clist_CreateGroup(0, _A2T(item->group));
db_set_s(hContact, "CList", "Group", item->group);
}
else {
@@ -1353,7 +1353,7 @@ static void TlenProcessV(XmlNode *node, ThreadData *info)
if ((p=TlenXmlGetAttrValue(node, "p")) != NULL) {
item->ft->wPort = atoi(p);
TlenVoiceStart(item->ft, 0);
- //TlenForkThread((void (__cdecl *)(void*))TlenVoiceReceiveThread, 0, item->ft);
+ //forkthread((void (__cdecl *)(void*))TlenVoiceReceiveThread, 0, item->ft);
}
}
}
diff --git a/protocols/Tlen/src/tlen_voice.cpp b/protocols/Tlen/src/tlen_voice.cpp
index a0b2c7ccd6..cff67606c0 100644
--- a/protocols/Tlen/src/tlen_voice.cpp
+++ b/protocols/Tlen/src/tlen_voice.cpp
@@ -936,11 +936,11 @@ int TlenVoiceStart(TLEN_FILE_TRANSFER *ft, int mode)
TlenLog(ft->proto, "starting voice %d", mode);
if (mode == 0) {
- TlenForkThread((void (__cdecl *)(void*))TlenVoiceReceiveThread, 0, ft);
+ forkthread((void (__cdecl *)(void*))TlenVoiceReceiveThread, 0, ft);
} else if (mode == 1) {
- TlenForkThread((void (__cdecl *)(void*))TlenVoiceSendingThread, 0, ft);
+ forkthread((void (__cdecl *)(void*))TlenVoiceSendingThread, 0, ft);
} else {
- TlenForkThread((void (__cdecl *)(void*))TlenVoiceDlgThread, 0, ft);
+ forkthread((void (__cdecl *)(void*))TlenVoiceDlgThread, 0, ft);
}
return 0;
}
@@ -1065,7 +1065,7 @@ int TlenVoiceAccept(TlenProtocol *proto, const char *id, const char *from)
ACCEPTDIALOGDATA *data = (ACCEPTDIALOGDATA *)mir_alloc(sizeof(ACCEPTDIALOGDATA));
data->proto = proto;
data->item = item;
- TlenForkThread((void (__cdecl *)(void*))TlenVoiceAcceptDlgThread, 0, data);
+ forkthread((void (__cdecl *)(void*))TlenVoiceAcceptDlgThread, 0, data);
} else if (proto->isOnline) {
item->ft = TlenFileCreateFT(proto, from);
item->ft->iqId = mir_strdup(id);
diff --git a/src/core/stdchat/src/chat.h b/src/core/stdchat/src/chat.h
index e496c6489a..72e3ecd5cf 100644
--- a/src/core/stdchat/src/chat.h
+++ b/src/core/stdchat/src/chat.h
@@ -512,7 +512,6 @@ INT_PTR CList_JoinChat(WPARAM wParam, LPARAM lParam);
INT_PTR CList_LeaveChat(WPARAM wParam, LPARAM lParam);
int CList_PrebuildContactMenu(WPARAM wParam, LPARAM lParam);
INT_PTR CList_PrebuildContactMenuSvc(WPARAM wParam, LPARAM lParam);
-void CList_CreateGroup(TCHAR* group);
BOOL CList_AddEvent(HANDLE hContact, HICON hIcon, HANDLE hEvent, int type, TCHAR* fmt, ... ) ;
HANDLE CList_FindRoom (const char* pszModule, const TCHAR* pszRoom) ;
int WCCmp(TCHAR* wild, TCHAR*string);
diff --git a/src/core/stdchat/src/clist.cpp b/src/core/stdchat/src/clist.cpp
index 8ddc8c40d8..b25f555ecf 100644
--- a/src/core/stdchat/src/clist.cpp
+++ b/src/core/stdchat/src/clist.cpp
@@ -35,34 +35,15 @@ HANDLE CList_AddRoom(const char* pszModule, const TCHAR* pszRoom, const TCHAR* p
else lstrcpyn( pszGroup, _T("Chat rooms"), 50);
if ( pszGroup[0] )
- CList_CreateGroup( pszGroup );
+ Clist_CreateGroup(0, pszGroup);
if ( hContact ) { //contact exist, make sure it is in the right group
- DBVARIANT dbv;
- DBVARIANT dbv2;
- char str[50];
- int i;
-
- if ( pszGroup[0] ) {
- for (i = 0;; i++) {
- _itoa( i, str, 10 );
- if ( db_get_ts( NULL, "CListGroups", str, &dbv )) {
- db_set_ts(hContact, "CList", "Group", pszGroup);
- goto END_GROUPLOOP;
- }
-
- if ( !db_get_ts( hContact, "CList", "Group", &dbv2 )) {
- if ( dbv.ptszVal[0] != '\0' && dbv2.ptszVal[0] != '\0' && !lstrcmpi( dbv.ptszVal + 1, dbv2.ptszVal )) {
- db_free( &dbv );
- db_free( &dbv2 );
- goto END_GROUPLOOP;
- }
- db_free(&dbv2);
- }
- db_free(&dbv);
- } }
+ if (pszGroup[0]) {
+ ptrT grpName( db_get_tsa(hContact, "CList", "Group"));
+ if ( !lstrcmp(pszGroup, grpName))
+ db_set_ts(hContact, "CList", "Group", pszGroup);
+ }
-END_GROUPLOOP:
db_set_w( hContact, pszModule, "Status", ID_STATUS_OFFLINE );
db_set_ts(hContact, pszModule, "Nick", pszDisplayName );
return hContact;
@@ -217,38 +198,6 @@ INT_PTR CList_PrebuildContactMenuSvc(WPARAM wParam, LPARAM lParam)
return CList_PrebuildContactMenu(wParam, lParam);
}
-
-void CList_CreateGroup(TCHAR* group)
-{
- int i;
- char str[50];
- TCHAR name[256];
- DBVARIANT dbv;
-
- if ( !group )
- return;
-
- for (i = 0;; i++)
- {
- _itoa(i, str, 10);
- if ( db_get_ts( NULL, "CListGroups", str, &dbv ))
- break;
-
- if ( dbv.pszVal[0] != '\0' && !lstrcmpi(dbv.ptszVal + 1, group)) {
- db_free(&dbv);
- return;
- }
-
- db_free(&dbv);
- }
-
- name[0] = 1 | GROUPF_EXPANDED;
- _tcsncpy(name + 1, group, SIZEOF(name) - 1);
- name[ lstrlen(group) + 1] = '\0';
- db_set_ts(NULL, "CListGroups", str, name);
- CallService(MS_CLUI_GROUPADDED, i + 1, 0);
-}
-
BOOL CList_AddEvent(HANDLE hContact, HICON hIcon, HANDLE hEvent, int type, TCHAR* fmt, ... )
{
CLISTEVENT cle = {0};