Mercurial > pidgin
annotate libpurple/protocols/qq/group_conv.c @ 17011:e44a272b27a8
merge of '41f3a410baa40935d56c676abbf69c92987f86b7'
and 'b8101f7594a660d5b9f9a0a1ad0e740ed9a78364'
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Fri, 11 May 2007 00:16:58 +0000 |
parents | 85d5942e80e9 |
children | b8572b937c09 |
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_conv.c |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 * |
15822 | 4 * purple |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5 * |
15822 | 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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
25 #include <glib.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
26 #include "conversation.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
27 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
28 #include "buddy_status.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
29 #include "group_conv.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
30 #include "qq.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 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
33 /* show group conversation window */ |
15822 | 34 void qq_group_conv_show_window(PurpleConnection *gc, qq_group *group) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
35 { |
15822 | 36 PurpleConversation *conv; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
37 qq_data *qd; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
38 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
39 g_return_if_fail(group != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
40 qd = (qq_data *) gc->proto_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
41 |
15822 | 42 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, |
43 group->group_name_utf8, purple_connection_get_account(gc)); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
44 if (conv == NULL) /* show only one window per group */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
45 serv_got_joined_chat(gc, qd->channel++, group->group_name_utf8); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
46 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
47 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
48 /* refresh online member in group conversation window */ |
15822 | 49 void qq_group_conv_refresh_online_member(PurpleConnection *gc, qq_group *group) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
50 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
51 GList *names, *list, *flags; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
52 qq_buddy *member; |
16208
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
53 gchar *member_name, *member_uid; |
15822 | 54 PurpleConversation *conv; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
55 gint flag; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 g_return_if_fail(group != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
57 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
58 names = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
59 flags = NULL; |
16208
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
60 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, |
15822 | 61 group->group_name_utf8, purple_connection_get_account(gc)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
62 if (conv != NULL && group->members != NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 list = group->members; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 while (list != NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
65 member = (qq_buddy *) list->data; |
16208
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
66 |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
67 /* we need unique identifiers for everyone in the chat or else we'll |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
68 * run into problems with functions like get_cb_real_name from qq.c */ |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
69 member_name = (member->nickname != NULL && *(member->nickname) != '\0') ? |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
70 g_strdup_printf("%s (qq-%u)", member->nickname, member->uid) : |
16208
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
71 g_strdup_printf("(qq-%u)", member->uid); |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
72 member_uid = g_strdup_printf("(qq-%u)", member->uid); |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
73 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
74 flag = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
75 /* TYPING to put online above OP and FOUNDER */ |
16208
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
76 if (is_online(member->status)) |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
77 flag |= (PURPLE_CBFLAGS_TYPING | PURPLE_CBFLAGS_VOICE); |
15822 | 78 if(1 == (member->role & 1)) flag |= PURPLE_CBFLAGS_OP; |
79 if(member->uid == group->creator_uid) flag |= PURPLE_CBFLAGS_FOUNDER; | |
16208
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
80 |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
81 if (purple_conv_chat_find_user(PURPLE_CONV_CHAT(conv), member_name)) |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
82 { |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
83 purple_conv_chat_user_set_flags(PURPLE_CONV_CHAT(conv), |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
84 member_name, |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
85 flag); |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
86 } else if (purple_conv_chat_find_user(PURPLE_CONV_CHAT(conv), member_uid)) |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
87 { |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
88 purple_conv_chat_user_set_flags(PURPLE_CONV_CHAT(conv), |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
89 member_uid, |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
90 flag); |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
91 purple_conv_chat_rename_user(PURPLE_CONV_CHAT(conv), member_uid, member_name); |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
92 } else { |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
93 /* always put it even offline */ |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
94 names = g_list_append(names, member_name); |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
95 flags = g_list_append(flags, GINT_TO_POINTER(flag)); |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
96 } |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
97 g_free(member_uid); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
98 list = list->next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
99 } |
16208
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
100 |
15822 | 101 purple_conv_chat_add_users(PURPLE_CONV_CHAT(conv), names, NULL, flags, FALSE); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
102 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
103 /* clean up names */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
104 while (names != NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
105 member_name = (gchar *) names->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
106 names = g_list_remove(names, member_name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
107 g_free(member_name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
108 } |
16208
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15822
diff
changeset
|
109 g_list_free(flags); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
110 } |