| 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 |
|
| 40 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, group->group_name_utf8, gaim_connection_get_account(gc)); |
|
| 41 if (conv == NULL) /* show only one window per group */ |
|
| 42 serv_got_joined_chat(gc, qd->channel++, group->group_name_utf8); |
|
| 43 } |
|
| 44 |
|
| 45 /* refresh online member in group conversation window */ |
|
| 46 void qq_group_conv_refresh_online_member(GaimConnection *gc, qq_group *group) |
|
| 47 { |
|
| 48 GList *names, *list, *flags; |
|
| 49 qq_buddy *member; |
|
| 50 gchar *member_name; |
|
| 51 GaimConversation *conv; |
|
| 52 gint flag; |
|
| 53 g_return_if_fail(gc != NULL && group != NULL); |
|
| 54 |
|
| 55 names = NULL; |
|
| 56 flags = NULL; |
|
| 57 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, group->group_name_utf8, gaim_connection_get_account(gc)); |
|
| 58 if (conv != NULL && group->members != NULL) { |
|
| 59 list = group->members; |
|
| 60 while (list != NULL) { |
|
| 61 member = (qq_buddy *) list->data; |
|
| 62 /* always put it even offline */ |
|
| 63 names = g_list_append(names, |
|
| 64 (member->nickname != |
|
| 65 NULL) ? |
|
| 66 g_strdup(member->nickname) : uid_to_gaim_name(member->uid)); |
|
| 67 |
|
| 68 flag = 0; |
|
| 69 /* TYPING to put online above OP and FOUNDER */ |
|
| 70 if (is_online(member->status)) flag |= (GAIM_CBFLAGS_TYPING | GAIM_CBFLAGS_VOICE); |
|
| 71 if(1 == (member->role & 1)) flag |= GAIM_CBFLAGS_OP; |
|
| 72 if(member->uid == group->creator_uid) flag |= GAIM_CBFLAGS_FOUNDER; |
|
| 73 flags = g_list_append(flags, GINT_TO_POINTER(flag)); |
|
| 74 list = list->next; |
|
| 75 } |
|
| 76 |
|
| 77 gaim_conv_chat_clear_users(GAIM_CONV_CHAT(conv)); |
|
| 78 gaim_conv_chat_add_users(GAIM_CONV_CHAT(conv), names, NULL, flags, FALSE); |
|
| 79 } |
|
| 80 /* clean up names */ |
|
| 81 while (names != NULL) { |
|
| 82 member_name = (gchar *) names->data; |
|
| 83 names = g_list_remove(names, member_name); |
|
| 84 g_free(member_name); |
|
| 85 } |
|
| 86 g_list_free(flags); |
|
| 87 } |
|