annotate libpurple/protocols/qq/group_conv.c @ 24095:25f62d21b3f8

disapproval of revision '8cebefbc6cd5d84acb69c74e69e8821f11dd225d'
author Daniel Atallah <daniel.atallah@gmail.com>
date Mon, 15 Sep 2008 03:04:07 +0000
parents 147ada94a1d8
children 225e0e9e1055
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_conv.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: 18210
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 #include <glib.h>
18210
b8572b937c09 #include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents: 16208
diff changeset
26 #include "qq.h"
b8572b937c09 #include reorganizations to allow compiling with glib < 2.8 using the
Stu Tomlinson <stu@nosnilmot.com>
parents: 16208
diff changeset
27
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "conversation.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30 #include "group_conv.h"
23638
1c50f12b1c52 2008.08.02 - csyfek <csyfek(at)gmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 23561
diff changeset
31 #include "buddy_list.h"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 #include "utils.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 /* show group conversation window */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
35 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
36 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
37 PurpleConversation *conv;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 qq_data *qd;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40 g_return_if_fail(group != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 qd = (qq_data *) gc->proto_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
43 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT,
24095
25f62d21b3f8 disapproval of revision '8cebefbc6cd5d84acb69c74e69e8821f11dd225d'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24088
diff changeset
44 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
45 if (conv == NULL) /* show only one window per group */
24095
25f62d21b3f8 disapproval of revision '8cebefbc6cd5d84acb69c74e69e8821f11dd225d'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24088
diff changeset
46 serv_got_joined_chat(gc, qd->channel++, group->group_name_utf8);
15373
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
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 /* refresh online member in group conversation window */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
50 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
51 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 GList *names, *list, *flags;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 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
54 gchar *member_name, *member_uid;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
55 PurpleConversation *conv;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 gint flag;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 g_return_if_fail(group != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 names = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 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
61 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT,
24095
25f62d21b3f8 disapproval of revision '8cebefbc6cd5d84acb69c74e69e8821f11dd225d'
Daniel Atallah <daniel.atallah@gmail.com>
parents: 24088
diff changeset
62 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
63 if (conv != NULL && group->members != NULL) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 list = group->members;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 while (list != NULL) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 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
67
85d5942e80e9 Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents: 15822
diff changeset
68 /* 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
69 * 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
70 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
71 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
72 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 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
74
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 flag = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 /* 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
77 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
78 flag |= (PURPLE_CBFLAGS_TYPING | PURPLE_CBFLAGS_VOICE);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
79 if(1 == (member->role & 1)) flag |= PURPLE_CBFLAGS_OP;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15373
diff changeset
80 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
81
85d5942e80e9 Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents: 15822
diff changeset
82 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
83 {
85d5942e80e9 Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents: 15822
diff changeset
84 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
85 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
86 flag);
85d5942e80e9 Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents: 15822
diff changeset
87 } 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
88 {
85d5942e80e9 Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents: 15822
diff changeset
89 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
90 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
91 flag);
85d5942e80e9 Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents: 15822
diff changeset
92 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
93 } else {
85d5942e80e9 Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents: 15822
diff changeset
94 /* 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
95 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
96 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
97 }
85d5942e80e9 Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents: 15822
diff changeset
98 g_free(member_uid);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 list = list->next;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 }
16208
85d5942e80e9 Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents: 15822
diff changeset
101
23561
bdb38a8bf721 20080717-05-1-fix-keep-alive ccpaging <ecc_hy(at)hotmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19681
diff changeset
102 if (names != NULL && flags != NULL) {
bdb38a8bf721 20080717-05-1-fix-keep-alive ccpaging <ecc_hy(at)hotmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19681
diff changeset
103 purple_conv_chat_add_users(PURPLE_CONV_CHAT(conv), names, NULL, flags, FALSE);
bdb38a8bf721 20080717-05-1-fix-keep-alive ccpaging <ecc_hy(at)hotmail.com>
SHiNE CsyFeK <csyfek@gmail.com>
parents: 19681
diff changeset
104 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 /* clean up names */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107 while (names != NULL) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 member_name = (gchar *) names->data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 names = g_list_remove(names, member_name);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 g_free(member_name);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 }
16208
85d5942e80e9 Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents: 15822
diff changeset
112 g_list_free(flags);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 }