14192
|
1 /**
|
|
2 * The QQ2003C protocol plugin
|
|
3 *
|
|
4 * for gaim
|
|
5 *
|
|
6 * Copyright (C) 2004 Puzzlebird
|
|
7 *
|
|
8 * This program is free software; you can redistribute it and/or modify
|
|
9 * it under the terms of the GNU General Public License as published by
|
|
10 * the Free Software Foundation; either version 2 of the License, or
|
|
11 * (at your option) any later version.
|
|
12 *
|
|
13 * This program is distributed in the hope that it will be useful,
|
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 * GNU General Public License for more details.
|
|
17 *
|
|
18 * You should have received a copy of the GNU General Public License
|
|
19 * along with this program; if not, write to the Free Software
|
|
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
21 */
|
|
22
|
|
23 #include <glib.h>
|
|
24 #include "conversation.h"
|
|
25
|
|
26 #include "buddy_status.h"
|
|
27 #include "group_conv.h"
|
|
28 #include "qq.h"
|
|
29 #include "utils.h"
|
|
30
|
|
31 /* show group conversation window */
|
|
32 void qq_group_conv_show_window(GaimConnection *gc, qq_group *group)
|
|
33 {
|
|
34 GaimConversation *conv;
|
|
35 qq_data *qd;
|
|
36
|
|
37 g_return_if_fail(gc != NULL && gc->proto_data != NULL && group != NULL);
|
|
38 qd = (qq_data *) gc->proto_data;
|
|
39
|
14404
|
40 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT,
|
|
41 group->group_name_utf8, gaim_connection_get_account(gc));
|
14192
|
42 if (conv == NULL) /* show only one window per group */
|
|
43 serv_got_joined_chat(gc, qd->channel++, group->group_name_utf8);
|
|
44 }
|
|
45
|
|
46 /* refresh online member in group conversation window */
|
|
47 void qq_group_conv_refresh_online_member(GaimConnection *gc, qq_group *group)
|
|
48 {
|
|
49 GList *names, *list, *flags;
|
|
50 qq_buddy *member;
|
|
51 gchar *member_name;
|
|
52 GaimConversation *conv;
|
|
53 gint flag;
|
|
54 g_return_if_fail(gc != NULL && group != NULL);
|
|
55
|
|
56 names = NULL;
|
|
57 flags = NULL;
|
14404
|
58 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT,
|
|
59 group->group_name_utf8, gaim_connection_get_account(gc));
|
14192
|
60 if (conv != NULL && group->members != NULL) {
|
|
61 list = group->members;
|
|
62 while (list != NULL) {
|
|
63 member = (qq_buddy *) list->data;
|
|
64 /* always put it even offline */
|
|
65 names = g_list_append(names,
|
14404
|
66 /* we need unique identifiers for everyone in the chat or else we'll
|
|
67 * run into problems with functions like get_cb_real_name from qq.c */
|
|
68 (member->nickname != NULL && *(member->nickname) != '\0') ?
|
|
69 g_strdup_printf("%s (qq-%u)", member->nickname, member->uid) :
|
|
70 g_strdup_printf("(qq-%u)", member->uid));
|
14192
|
71 flag = 0;
|
|
72 /* TYPING to put online above OP and FOUNDER */
|
|
73 if (is_online(member->status)) flag |= (GAIM_CBFLAGS_TYPING | GAIM_CBFLAGS_VOICE);
|
|
74 if(1 == (member->role & 1)) flag |= GAIM_CBFLAGS_OP;
|
|
75 if(member->uid == group->creator_uid) flag |= GAIM_CBFLAGS_FOUNDER;
|
|
76 flags = g_list_append(flags, GINT_TO_POINTER(flag));
|
|
77 list = list->next;
|
|
78 }
|
|
79
|
|
80 gaim_conv_chat_clear_users(GAIM_CONV_CHAT(conv));
|
|
81 gaim_conv_chat_add_users(GAIM_CONV_CHAT(conv), names, NULL, flags, FALSE);
|
|
82 }
|
|
83 /* clean up names */
|
|
84 while (names != NULL) {
|
|
85 member_name = (gchar *) names->data;
|
|
86 names = g_list_remove(names, member_name);
|
|
87 g_free(member_name);
|
|
88 }
|
|
89 g_list_free(flags);
|
|
90 }
|