Mercurial > pidgin.yaz
annotate libpurple/protocols/qq/group_conv.c @ 19842:92968272518e
Added hints to qq group_im.c
author | Gabriel Schulhof <nix@go-nix.ca> |
---|---|
date | Sun, 12 Aug 2007 20:50:56 +0000 |
parents | b8572b937c09 |
children | 44b4e8bd759b |
rev | line source |
---|---|
15374
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 * |
15823 | 4 * purple |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5 * |
15823 | 6 * Purple is the legal property of its developers, whose names are too numerous |
15374
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> |
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 |
15374
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 "buddy_status.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 #include "group_conv.h" |
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 */ |
15823 | 35 void qq_group_conv_show_window(PurpleConnection *gc, qq_group *group) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
36 { |
15823 | 37 PurpleConversation *conv; |
15374
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 |
15823 | 43 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, |
44 group->group_name_utf8, purple_connection_get_account(gc)); | |
15374
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 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
46 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
|
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 */ |
15823 | 50 void qq_group_conv_refresh_online_member(PurpleConnection *gc, qq_group *group) |
15374
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:
15823
diff
changeset
|
54 gchar *member_name, *member_uid; |
15823 | 55 PurpleConversation *conv; |
15374
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:
15823
diff
changeset
|
61 conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, |
15823 | 62 group->group_name_utf8, purple_connection_get_account(gc)); |
15374
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:
15823
diff
changeset
|
67 |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15823
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:
15823
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:
15823
diff
changeset
|
70 member_name = (member->nickname != NULL && *(member->nickname) != '\0') ? |
15374
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:
15823
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:
15823
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:
15823
diff
changeset
|
74 |
15374
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:
15823
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:
15823
diff
changeset
|
78 flag |= (PURPLE_CBFLAGS_TYPING | PURPLE_CBFLAGS_VOICE); |
15823 | 79 if(1 == (member->role & 1)) flag |= PURPLE_CBFLAGS_OP; |
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:
15823
diff
changeset
|
81 |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15823
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:
15823
diff
changeset
|
83 { |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15823
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:
15823
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:
15823
diff
changeset
|
86 flag); |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15823
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:
15823
diff
changeset
|
88 { |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15823
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:
15823
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:
15823
diff
changeset
|
91 flag); |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15823
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:
15823
diff
changeset
|
93 } else { |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15823
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:
15823
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:
15823
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:
15823
diff
changeset
|
97 } |
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15823
diff
changeset
|
98 g_free(member_uid); |
15374
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:
15823
diff
changeset
|
101 |
15823 | 102 purple_conv_chat_add_users(PURPLE_CONV_CHAT(conv), names, NULL, flags, FALSE); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
103 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
104 /* clean up names */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
105 while (names != NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
106 member_name = (gchar *) names->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
107 names = g_list_remove(names, member_name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
108 g_free(member_name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
109 } |
16208
85d5942e80e9
Port SVN revisions 18230 to 18232 from Mark Huetsch from sf SVN to
Mark Doliner <mark@kingant.net>
parents:
15823
diff
changeset
|
110 g_list_free(flags); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
111 } |