Mercurial > pidgin
annotate src/protocols/gg/confer.c @ 12153:abe41ae8dd82
[gaim-migrate @ 14454]
Signal name fix in the signals test plugin
committer: Tailor Script <tailor@pidgin.im>
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Sat, 19 Nov 2005 13:21:57 +0000 |
parents | 8724718d387f |
children | 508512caa22e |
rev | line source |
---|---|
11414 | 1 /** |
2 * @file confer.c | |
3 * | |
4 * gaim | |
5 * | |
6 * Copyright (C) 2005 Bartosz Oler <bartosz@bzimage.us> | |
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 | |
24 #include "lib/libgadu.h" | |
25 #include "gg.h" | |
26 #include "utils.h" | |
27 #include "confer.h" | |
28 | |
29 /* GaimConversation *ggp_confer_find_by_name(GaimConnection *gc, const gchar *name) {{{ */ | |
30 GaimConversation *ggp_confer_find_by_name(GaimConnection *gc, const gchar *name) | |
31 { | |
32 g_return_val_if_fail(gc != NULL, NULL); | |
33 g_return_val_if_fail(name != NULL, NULL); | |
34 | |
35 return gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, name, | |
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
36 gaim_connection_get_account(gc)); |
11414 | 37 } |
38 /* }}} */ | |
39 | |
40 /* void ggp_confer_participants_add_uin(GaimConnection *gc, const gchar *chat_name, const uin_t uin) {{{ */ | |
41 void ggp_confer_participants_add_uin(GaimConnection *gc, const gchar *chat_name, | |
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
42 const uin_t uin) |
11414 | 43 { |
44 GaimConversation *conv; | |
45 GGPInfo *info = gc->proto_data; | |
46 GGPChat *chat; | |
47 GList *l; | |
48 gchar *str_uin; | |
49 | |
50 str_uin = g_strdup_printf("%lu", (unsigned long int)uin); | |
51 | |
52 for (l = info->chats; l != NULL; l = l->next) { | |
53 chat = l->data; | |
54 | |
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
55 if (g_utf8_collate(chat->name, chat_name) != 0) |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
56 continue; |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
57 |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
58 if (g_list_find(chat->participants, str_uin) == NULL) { |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
59 chat->participants = g_list_append( |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
60 chat->participants, str_uin); |
11414 | 61 |
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
62 conv = ggp_confer_find_by_name(gc, chat_name); |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
63 |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
64 gaim_conv_chat_add_user(GAIM_CONV_CHAT(conv), |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
65 ggp_buddy_get_name(gc, uin), NULL, |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
66 GAIM_CBFLAGS_NONE, TRUE); |
11414 | 67 } |
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
68 break; |
11414 | 69 } |
70 } | |
71 /* }}} */ | |
72 | |
73 /* void ggp_confer_participants_add(GaimConnection *gc, const gchar *chat_name, const uin_t *recipients, int count) {{{ */ | |
74 void ggp_confer_participants_add(GaimConnection *gc, const gchar *chat_name, | |
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
75 const uin_t *recipients, int count) |
11414 | 76 { |
77 GaimConversation *conv; | |
78 GGPInfo *info = gc->proto_data; | |
79 GGPChat *chat; | |
80 GList *l; | |
81 int i; | |
82 gchar *uin; | |
83 | |
84 for (l = info->chats; l != NULL; l = l->next) { | |
85 chat = l->data; | |
86 | |
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
87 if (g_utf8_collate(chat->name, chat_name) != 0) |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
88 continue; |
11414 | 89 |
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
90 for (i = 0; i < count; i++) { |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
91 uin = g_strdup_printf("%lu", (unsigned long int)recipients[i]); |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
92 |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
93 if (g_list_find(chat->participants, uin) != NULL) { |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
94 g_free(uin); |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
95 continue; |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
96 } |
11414 | 97 |
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
98 chat->participants = g_list_append(chat->participants, uin); |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
99 conv = ggp_confer_find_by_name(gc, chat_name); |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
100 |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
101 gaim_conv_chat_add_user(GAIM_CONV_CHAT(conv), |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
102 ggp_buddy_get_name(gc, recipients[i]), |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
103 NULL, GAIM_CBFLAGS_NONE, TRUE); |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
104 |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
105 g_free(uin); |
11414 | 106 } |
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
107 break; |
11414 | 108 } |
109 } | |
110 /* }}} */ | |
111 | |
112 /* const char *ggp_confer_find_by_participants(GaimConnection *gc, const uin_t *recipients, int count) {{{ */ | |
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
113 const char *ggp_confer_find_by_participants(GaimConnection *gc, |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
114 const uin_t *recipients, int count) |
11414 | 115 { |
116 GGPInfo *info = gc->proto_data; | |
117 GGPChat *chat = NULL; | |
118 GList *l, *m; | |
119 int i; | |
120 int maches; | |
121 | |
122 g_return_val_if_fail(info->chats != NULL, NULL); | |
123 | |
124 for (l = info->chats; l != NULL; l = l->next) { | |
125 chat = l->data; | |
126 maches = 0; | |
127 | |
128 for (m = chat->participants; m != NULL; m = m->next) { | |
129 uin_t p = ggp_str_to_uin(m->data); | |
130 | |
131 for (i = 0; i < count; i++) | |
132 if (p == recipients[i]) | |
133 maches++; | |
134 } | |
135 | |
136 if (maches == count) | |
137 break; | |
138 | |
139 chat = NULL; | |
140 } | |
141 | |
142 if (chat == NULL) | |
143 return NULL; | |
144 else | |
145 return chat->name; | |
146 } | |
147 /* }}} */ | |
148 | |
149 /* const char *ggp_confer_add_new(GaimConnection *gc, const char *name) {{{ */ | |
150 const char *ggp_confer_add_new(GaimConnection *gc, const char *name) | |
151 { | |
152 GGPInfo *info = gc->proto_data; | |
153 GGPChat *chat; | |
154 | |
155 chat = g_new0(GGPChat, 1); | |
156 | |
157 if (name == NULL) | |
158 chat->name = g_strdup_printf("conf#%d", info->chats_count++); | |
159 else | |
160 chat->name = g_strdup(name); | |
161 | |
162 chat->participants = NULL; | |
163 | |
164 info->chats = g_list_append(info->chats, chat); | |
165 | |
166 return chat->name; | |
167 } | |
168 /* }}} */ | |
169 | |
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
170 /* vim: set ts=8 sts=0 sw=8 noet: */ |