summaryrefslogtreecommitdiff
path: root/protocols/Gadu-Gadu/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/Gadu-Gadu/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/Gadu-Gadu/src')
-rw-r--r--protocols/Gadu-Gadu/src/import.cpp82
1 files changed, 5 insertions, 77 deletions
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){