annotate libpurple/protocols/qq/group_internal.c @ 24162:f4f29fac96c6

2008.10.20 - ccpaging <ccpaging(at)gmail.com> * Support incoming authorization of 'buddy_adding' protocol of QQ2007/2008
author SHiNE CsyFeK <csyfek@gmail.com>
date Tue, 28 Oct 2008 16:45:10 +0000
parents b6f09c1c79ce
children 95735ee46dd9 5ace6c024230 e35115192593
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /**
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * @file group_internal.c
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
4 * purple
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
6 * Purple is the legal property of its developers, whose names are too numerous
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 * to list here. Please refer to the COPYRIGHT file distributed with this
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * source distribution.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * (at your option) any later version.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * GNU General Public License for more details.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
19681
44b4e8bd759b The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 18807
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24
18210
b8572b937c09 #include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents: 15822
diff changeset
25 #include "internal.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 #include "blist.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 #include "debug.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 #include "buddy_opt.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "group_internal.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 #include "utils.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
33 static qq_room_data *room_data_new(guint32 id, guint32 ext_id, gchar *title)
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
34 {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
35 qq_room_data *rmd;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
36
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
37 purple_debug_info("QQ", "Created room data: %s, ext id %d, id %d\n",
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
38 title, ext_id, id);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
39 rmd = g_new0(qq_room_data, 1);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
40 rmd->my_role = QQ_ROOM_ROLE_NO;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
41 rmd->id = id;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
42 rmd->ext_id = ext_id;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
43 rmd->type8 = 0x01; /* assume permanent Qun */
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
44 rmd->creator_uid = 10000; /* assume by QQ admin */
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
45 rmd->category = 0x01;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
46 rmd->auth_type = 0x02; /* assume need auth */
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
47 rmd->title_utf8 = g_strdup(title == NULL ? "" : title);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
48 rmd->desc_utf8 = g_strdup("");
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
49 rmd->notice_utf8 = g_strdup("");
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
50 rmd->members = NULL;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
51 rmd->is_got_buddies = FALSE;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
52 return rmd;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
53 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
54
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
55 /* create a qq_room_data from hashtable */
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
56 static qq_room_data *room_data_new_by_hashtable(PurpleConnection *gc, GHashTable *data)
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
57 {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
58 qq_room_data *rmd;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
59 guint32 id, ext_id;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
60 gchar *value;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
61
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
62 value = g_hash_table_lookup(data, QQ_ROOM_KEY_INTERNAL_ID);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
63 id = value ? strtol(value, NULL, 10) : 0;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
64 value= g_hash_table_lookup(data, QQ_ROOM_KEY_EXTERNAL_ID);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
65 ext_id = value ? strtol(value, NULL, 10) : 0;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
66 value = g_strdup(g_hash_table_lookup(data, QQ_ROOM_KEY_TITLE_UTF8));
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
67
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
68 rmd = room_data_new(id, ext_id, value);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
69 rmd->my_role = QQ_ROOM_ROLE_YES;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
70 return rmd;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
71 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
72
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
73 /* gracefully free all members in a room */
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
74 static void room_buddies_free(qq_room_data *rmd)
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
75 {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
76 gint i;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
77 GList *list;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
78 qq_buddy_data *bd;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
79
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
80 g_return_if_fail(rmd != NULL);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
81 i = 0;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
82 while (NULL != (list = rmd->members)) {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
83 bd = (qq_buddy_data *) list->data;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
84 i++;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
85 rmd->members = g_list_remove(rmd->members, bd);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
86 qq_buddy_data_free(bd);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
87 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
88
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
89 rmd->members = NULL;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
90 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
91
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
92 /* gracefully free the memory for one qq_room_data */
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
93 static void room_data_free(qq_room_data *rmd)
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
94 {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
95 g_return_if_fail(rmd != NULL);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
96 room_buddies_free(rmd);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
97 g_free(rmd->title_utf8);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
98 g_free(rmd->desc_utf8);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
99 g_free(rmd->notice_utf8);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
100 g_free(rmd);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
101 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
102
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
103 void qq_room_update_chat_info(PurpleChat *chat, qq_room_data *rmd)
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
104 {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
105 if (rmd->title_utf8 != NULL && strlen(rmd->title_utf8) > 0) {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
106 purple_blist_alias_chat(chat, rmd->title_utf8);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
107 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
108 g_hash_table_replace(chat->components,
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
109 g_strdup(QQ_ROOM_KEY_INTERNAL_ID),
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
110 g_strdup_printf("%d", rmd->id));
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
111 g_hash_table_replace(chat->components,
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
112 g_strdup(QQ_ROOM_KEY_EXTERNAL_ID),
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
113 g_strdup_printf("%d", rmd->ext_id));
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
114 g_hash_table_replace(chat->components,
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
115 g_strdup(QQ_ROOM_KEY_TITLE_UTF8), g_strdup(rmd->title_utf8));
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
116 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
117
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
118 static PurpleChat *chat_new(PurpleConnection *gc, qq_room_data *rmd)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 GHashTable *components;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
121 PurpleGroup *g;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
122 PurpleChat *chat;
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
123
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
124 purple_debug_info("QQ", "Add new chat: id %d, ext id %d, title %s\n",
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
125 rmd->id, rmd->ext_id, rmd->title_utf8);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
126
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
127 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
128 g_hash_table_insert(components,
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
129 g_strdup(QQ_ROOM_KEY_INTERNAL_ID), g_strdup_printf("%d", rmd->id));
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
130 g_hash_table_insert(components, g_strdup(QQ_ROOM_KEY_EXTERNAL_ID),
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
131 g_strdup_printf("%d", rmd->ext_id));
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
132 g_hash_table_insert(components, g_strdup(QQ_ROOM_KEY_TITLE_UTF8), g_strdup(rmd->title_utf8));
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
133
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
134 chat = purple_chat_new(purple_connection_get_account(gc), rmd->title_utf8, components);
24148
1bdf7b602684 2008.10.07 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24135
diff changeset
135 g = qq_group_find_or_new(PURPLE_GROUP_QQ_QUN);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
136 purple_blist_add_chat(chat, g, NULL);
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
137
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
138 return chat;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
139 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
140
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
141 PurpleChat *qq_room_find_or_new(PurpleConnection *gc, guint32 id, guint32 ext_id)
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
142 {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
143 qq_data *qd;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
144 qq_room_data *rmd;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
145 PurpleChat *chat;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
146 gchar *num_str;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
147
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
148 g_return_val_if_fail (gc != NULL && gc->proto_data != NULL, NULL);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
149 qd = (qq_data *) gc->proto_data;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
150
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
151 g_return_val_if_fail(id != 0 && ext_id != 0, NULL);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
152
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
153 purple_debug_info("QQ", "Find or add new room: id %d, ext id %d\n", id, ext_id);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
154
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
155 rmd = qq_room_data_find(gc, id);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
156 if (rmd == NULL) {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
157 rmd = room_data_new(id, ext_id, NULL);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
158 g_return_val_if_fail(rmd != NULL, NULL);
24158
b6f09c1c79ce 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24157
diff changeset
159 rmd->my_role = QQ_ROOM_ROLE_YES;
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
160 qd->groups = g_list_append(qd->groups, rmd);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
161 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
162
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
163 num_str = g_strdup_printf("%d", ext_id);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
164 chat = purple_blist_find_chat(purple_connection_get_account(gc), num_str);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
165 g_free(num_str);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
166 if (chat) {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
167 return chat;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
168 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
169
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
170 return chat_new(gc, rmd);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
173 void qq_room_remove(PurpleConnection *gc, guint32 id)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 {
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
175 qq_data *qd;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
176 PurpleChat *chat;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
177 qq_room_data *rmd;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
178 gchar *num_str;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
179 guint32 ext_id;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
181 g_return_if_fail (gc != NULL && gc->proto_data != NULL);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
182 qd = (qq_data *) gc->proto_data;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
184 purple_debug_info("QQ", "Find and remove room data, id %d", id);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
185 rmd = qq_room_data_find(gc, id);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
186 g_return_if_fail (rmd != NULL);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
187
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
188 ext_id = rmd->ext_id;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
189 qd->groups = g_list_remove(qd->groups, rmd);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
190 room_data_free(rmd);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
192 purple_debug_info("QQ", "Find and remove chat, ext_id %d", ext_id);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
193 num_str = g_strdup_printf("%d", ext_id);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
194 chat = purple_blist_find_chat(purple_connection_get_account(gc), num_str);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
195 g_free(num_str);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
197 g_return_if_fail (chat != NULL);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
198
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
199 purple_blist_remove_chat(chat);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
202 /* find a qq_buddy_data by uid, called by im.c */
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
203 qq_buddy_data *qq_room_buddy_find(qq_room_data *rmd, guint32 uid)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 {
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
205 GList *list;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
206 qq_buddy_data *bd;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
207 g_return_val_if_fail(rmd != NULL && uid > 0, NULL);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
208
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
209 list = rmd->members;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
210 while (list != NULL) {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
211 bd = (qq_buddy_data *) list->data;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
212 if (bd->uid == uid)
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
213 return bd;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
214 else
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
215 list = list->next;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
216 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
217
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
218 return NULL;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
219 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
220
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
221 /* remove a qq_buddy_data by uid, called by qq_group_opt.c */
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
222 void qq_room_buddy_remove(qq_room_data *rmd, guint32 uid)
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
223 {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
224 GList *list;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
225 qq_buddy_data *bd;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
226 g_return_if_fail(rmd != NULL && uid > 0);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
227
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
228 list = rmd->members;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
229 while (list != NULL) {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
230 bd = (qq_buddy_data *) list->data;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
231 if (bd->uid == uid) {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
232 rmd->members = g_list_remove(rmd->members, bd);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
233 return;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
234 } else {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
235 list = list->next;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
236 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
237 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
238 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
239
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
240 qq_buddy_data *qq_room_buddy_find_or_new(PurpleConnection *gc, qq_room_data *rmd, guint32 member_uid)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
241 {
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
242 qq_buddy_data *member, *bd;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
243 PurpleBuddy *buddy;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
244 g_return_val_if_fail(rmd != NULL && member_uid > 0, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
246 member = qq_room_buddy_find(rmd, member_uid);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
247 if (member == NULL) { /* first appear during my session */
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
248 member = g_new0(qq_buddy_data, 1);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
249 member->uid = member_uid;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
250 buddy = purple_find_buddy(purple_connection_get_account(gc), uid_to_purple_name(member_uid));
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
251 if (buddy != NULL) {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
252 bd = (qq_buddy_data *) buddy->proto_data;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
253 if (bd != NULL && bd->nickname != NULL)
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
254 member->nickname = g_strdup(bd->nickname);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
255 else if (buddy->alias != NULL)
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
256 member->nickname = g_strdup(buddy->alias);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
257 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
258 rmd->members = g_list_append(rmd->members, member);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
259 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
260
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
261 return member;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
264 qq_room_data *qq_room_data_find(PurpleConnection *gc, guint32 room_id)
24154
237e5a94e11c 2008.10.08 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24148
diff changeset
265 {
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
266 GList *list;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
267 qq_room_data *rmd;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
268 qq_data *qd;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
269
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
270 qd = (qq_data *) gc->proto_data;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
271
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
272 if (qd->groups == NULL || room_id <= 0)
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
273 return 0;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
274
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
275 list = qd->groups;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
276 while (list != NULL) {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
277 rmd = (qq_room_data *) list->data;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
278 if (rmd->id == room_id) {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
279 return rmd;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
280 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
281 list = list->next;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
282 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
283
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
284 return NULL;
24154
237e5a94e11c 2008.10.08 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24148
diff changeset
285 }
237e5a94e11c 2008.10.08 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24148
diff changeset
286
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
287 guint32 qq_room_get_next(PurpleConnection *gc, guint32 room_id)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288 {
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
289 GList *list;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
290 qq_room_data *rmd;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291 qq_data *qd;
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
292 gboolean is_find = FALSE;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294 qd = (qq_data *) gc->proto_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
296 if (qd->groups == NULL) {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
297 return 0;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
298 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
299
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
300 if (room_id <= 0) {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
301 rmd = (qq_room_data *) qd->groups->data;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
302 return rmd->id;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
303 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
305 list = qd->groups;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
306 while (list != NULL) {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
307 rmd = (qq_room_data *) list->data;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
308 list = list->next;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
309 if (rmd->id == room_id) {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
310 is_find = TRUE;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
311 break;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
312 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
313 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
314
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
315 g_return_val_if_fail(is_find, 0);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
316 if (list == NULL) return 0; /* be the end */
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
317 rmd = (qq_room_data *) list->data;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
318 g_return_val_if_fail(rmd != NULL, 0);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
319 return rmd->id;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
322 guint32 qq_room_get_next_conv(PurpleConnection *gc, guint32 room_id)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
323 {
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
324 GList *list;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
325 qq_room_data *rmd;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
326 qq_data *qd;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
327 gboolean is_find;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
328
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
329 qd = (qq_data *) gc->proto_data;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
330
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
331 list = qd->groups;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
332 if (room_id > 0) {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
333 /* search next room */
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
334 is_find = FALSE;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
335 while (list != NULL) {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
336 rmd = (qq_room_data *) list->data;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
337 list = list->next;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
338 if (rmd->id == room_id) {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
339 is_find = TRUE;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
340 break;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
341 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
342 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
343 g_return_val_if_fail(is_find, 0);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
344 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
345
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
346 while (list != NULL) {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
347 rmd = (qq_room_data *) list->data;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
348 g_return_val_if_fail(rmd != NULL, 0);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
349
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
350 if (rmd->my_role == QQ_ROOM_ROLE_YES || rmd->my_role == QQ_ROOM_ROLE_ADMIN) {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
351 if (NULL != purple_find_conversation_with_account(
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
352 PURPLE_CONV_TYPE_CHAT,rmd->title_utf8, purple_connection_get_account(gc))) {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
353 /* In convseration*/
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
354 return rmd->id;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
355 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
356 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
357 list = list->next;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
358 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
359
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
360 return 0;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
361 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
362
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
363 /* this should be called upon signin, even when we did not open group chat window */
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
364 void qq_room_data_initial(PurpleConnection *gc)
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
365 {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
366 PurpleAccount *account;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
367 PurpleChat *chat;
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
368 PurpleGroup *purple_group;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
369 PurpleBlistNode *node;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
370 qq_data *qd;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
371 qq_room_data *rmd;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
372 gint count;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
374 account = purple_connection_get_account(gc);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
375 qd = (qq_data *) gc->proto_data;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
376
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
377 purple_debug_info("QQ", "Initial QQ Qun configurations\n");
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
378 purple_group = purple_find_group(PURPLE_GROUP_QQ_QUN);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
379 if (purple_group == NULL) {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
380 purple_debug_info("QQ", "We have no QQ Qun\n");
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
381 return;
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
382 }
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
383
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
384 count = 0;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
385 for (node = ((PurpleBlistNode *) purple_group)->child; node != NULL; node = node->next) {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
386 if ( !PURPLE_BLIST_NODE_IS_CHAT(node)) {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
387 continue;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
388 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
389 /* got one */
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
390 chat = (PurpleChat *) node;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
391 if (account != chat->account) /* not qq account*/
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
392 continue;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
393
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
394 rmd = room_data_new_by_hashtable(gc, chat->components);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
395 qd->groups = g_list_append(qd->groups, rmd);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
396 count++;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
397 }
24115
bcfc98c7a55f merge of '546bf87105ac5b97c3962c083dfab015d37d9b05'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24114
diff changeset
398
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
399 purple_debug_info("QQ", "Load %d QQ Qun configurations\n", count);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
400 }
24157
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
401
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
402 void qq_room_data_free_all(PurpleConnection *gc)
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
403 {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
404 qq_data *qd;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
405 qq_room_data *rmd;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
406 gint count;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
407
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
408 g_return_if_fail (gc != NULL && gc->proto_data != NULL);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
409 qd = (qq_data *) gc->proto_data;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
410
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
411 count = 0;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
412 while (qd->groups != NULL) {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
413 rmd = (qq_room_data *) qd->groups->data;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
414 qd->groups = g_list_remove(qd->groups, rmd);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
415 room_data_free(rmd);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
416 count++;
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
417 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
418
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
419 if (count > 0) {
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
420 purple_debug_info("QQ", "%d rooms are freed\n", count);
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
421 }
1ee91ff0d5fe 2008.10.09 - ccpaging <ccpaging(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 24155
diff changeset
422 }