From 03a0b643b94d5aa7f9c129fe73eea314d099cf56 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 7 Sep 2013 12:09:27 +0000 Subject: 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 --- plugins/Scriver/src/chat/chat.h | 1 - plugins/Scriver/src/chat/clist.cpp | 57 +++----------------------------------- 2 files changed, 4 insertions(+), 54 deletions(-) (limited to 'plugins/Scriver') 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) -- cgit v1.2.3