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