Mercurial > pidgin
annotate src/protocols/gg/confer.c @ 12760:c5acba513363
[gaim-migrate @ 15107]
Request the public IP everytime it is used since there may be
information or a new IP.
committer: Tailor Script <tailor@pidgin.im>
author | Thomas Butter <tbutter> |
---|---|
date | Sun, 08 Jan 2006 01:16:23 +0000 |
parents | 508512caa22e |
children | 4eae108efdde |
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) { |
12373
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
59 GaimBuddy *buddy; |
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
60 |
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
61 chat->participants = g_list_append( |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
62 chat->participants, str_uin); |
11414 | 63 |
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
64 conv = ggp_confer_find_by_name(gc, chat_name); |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
65 |
12373
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
66 buddy = gaim_find_buddy(gaim_connection_get_account(gc), str_uin); |
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
67 if (buddy != NULL) { |
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
68 gaim_conv_chat_add_user(GAIM_CONV_CHAT(conv), |
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
69 gaim_buddy_get_alias(buddy), NULL, |
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
70 GAIM_CBFLAGS_NONE, TRUE); |
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
71 } else { |
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
72 gaim_conv_chat_add_user(GAIM_CONV_CHAT(conv), |
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
73 str_uin, NULL, |
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
74 GAIM_CBFLAGS_NONE, TRUE); |
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
75 } |
11414 | 76 } |
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
77 break; |
11414 | 78 } |
12373
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
79 |
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
80 g_free(str_uin); |
11414 | 81 } |
82 /* }}} */ | |
83 | |
84 /* void ggp_confer_participants_add(GaimConnection *gc, const gchar *chat_name, const uin_t *recipients, int count) {{{ */ | |
85 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
|
86 const uin_t *recipients, int count) |
11414 | 87 { |
88 GGPInfo *info = gc->proto_data; | |
89 GList *l; | |
90 | |
91 for (l = info->chats; l != NULL; l = l->next) { | |
12373
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
92 GGPChat *chat = l->data; |
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
93 int i; |
11414 | 94 |
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
95 if (g_utf8_collate(chat->name, chat_name) != 0) |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
96 continue; |
11414 | 97 |
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
98 for (i = 0; i < count; i++) { |
12373
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
99 gchar *str_uin = g_strdup_printf("%lu", (unsigned long int)recipients[i]); |
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
100 GaimConversation *conv; |
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
101 GaimBuddy *buddy; |
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
102 |
12373
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
103 if (g_list_find(chat->participants, str_uin) != NULL) { |
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
104 g_free(str_uin); |
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
105 continue; |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
106 } |
11414 | 107 |
12373
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
108 chat->participants = g_list_append(chat->participants, str_uin); |
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
109 conv = ggp_confer_find_by_name(gc, chat_name); |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
110 |
12373
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
111 buddy = gaim_find_buddy(gaim_connection_get_account(gc), str_uin); |
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
112 if (buddy != NULL) { |
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
113 gaim_conv_chat_add_user(GAIM_CONV_CHAT(conv), |
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
114 gaim_buddy_get_alias(buddy), NULL, |
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
115 GAIM_CBFLAGS_NONE, TRUE); |
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
116 } else { |
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
117 gaim_conv_chat_add_user(GAIM_CONV_CHAT(conv), |
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
118 str_uin, NULL, |
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
119 GAIM_CBFLAGS_NONE, TRUE); |
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
120 } |
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
121 g_free(str_uin); |
11414 | 122 } |
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
123 break; |
11414 | 124 } |
125 } | |
126 /* }}} */ | |
127 | |
128 /* 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
|
129 const char *ggp_confer_find_by_participants(GaimConnection *gc, |
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
130 const uin_t *recipients, int count) |
11414 | 131 { |
132 GGPInfo *info = gc->proto_data; | |
133 GGPChat *chat = NULL; | |
12373
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
134 GList *l; |
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
135 int matches; |
11414 | 136 |
137 g_return_val_if_fail(info->chats != NULL, NULL); | |
138 | |
139 for (l = info->chats; l != NULL; l = l->next) { | |
12373
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
140 GList *m; |
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
141 |
11414 | 142 chat = l->data; |
12373
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
143 matches = 0; |
11414 | 144 |
145 for (m = chat->participants; m != NULL; m = m->next) { | |
146 uin_t p = ggp_str_to_uin(m->data); | |
12373
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
147 int i; |
11414 | 148 |
149 for (i = 0; i < count; i++) | |
150 if (p == recipients[i]) | |
12373
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
151 matches++; |
11414 | 152 } |
153 | |
12373
508512caa22e
[gaim-migrate @ 14677]
Richard Laager <rlaager@wiktel.com>
parents:
12007
diff
changeset
|
154 if (matches == count) |
11414 | 155 break; |
156 | |
157 chat = NULL; | |
158 } | |
159 | |
160 if (chat == NULL) | |
161 return NULL; | |
162 else | |
163 return chat->name; | |
164 } | |
165 /* }}} */ | |
166 | |
167 /* const char *ggp_confer_add_new(GaimConnection *gc, const char *name) {{{ */ | |
168 const char *ggp_confer_add_new(GaimConnection *gc, const char *name) | |
169 { | |
170 GGPInfo *info = gc->proto_data; | |
171 GGPChat *chat; | |
172 | |
173 chat = g_new0(GGPChat, 1); | |
174 | |
175 if (name == NULL) | |
176 chat->name = g_strdup_printf("conf#%d", info->chats_count++); | |
177 else | |
178 chat->name = g_strdup(name); | |
179 | |
180 chat->participants = NULL; | |
181 | |
182 info->chats = g_list_append(info->chats, chat); | |
183 | |
184 return chat->name; | |
185 } | |
186 /* }}} */ | |
187 | |
12007
8724718d387f
[gaim-migrate @ 14300]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11414
diff
changeset
|
188 /* vim: set ts=8 sts=0 sw=8 noet: */ |