Mercurial > pidgin.yaz
annotate src/protocols/sametime/sametime.c @ 13203:1455bbb38194
[gaim-migrate @ 15566]
These guys deserve some credit for thenon-blocking patches that they made.
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Thu, 09 Feb 2006 04:42:07 +0000 |
parents | 3a97c65196d1 |
children | 76c66b7e1327 |
rev | line source |
---|---|
10977 | 1 |
2 /* | |
3 Meanwhile Protocol Plugin for Gaim | |
4 Adds Lotus Sametime support to Gaim using the Meanwhile library | |
5 | |
6 Copyright (C) 2004 Christopher (siege) O'Brien <siege@preoccupied.net> | |
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 (at | |
11 your option) any later version. | |
12 | |
13 This program is distributed in the hope that it will be useful, but | |
14 WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 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, | |
21 USA. | |
22 */ | |
23 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
24 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
25 /* system includes */ |
10977 | 26 #include <stdlib.h> |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
27 #include <time.h> |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
28 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
29 /* glib includes */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
30 #include <glib.h> |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
31 #include <glib/ghash.h> |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
32 #include <glib/glist.h> |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
33 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
34 /* gaim includes */ |
10977 | 35 #include <internal.h> |
36 #include <gaim.h> | |
37 #include <config.h> | |
38 | |
39 #include <account.h> | |
40 #include <accountopt.h> | |
41 #include <conversation.h> | |
42 #include <debug.h> | |
43 #include <ft.h> | |
44 #include <imgstore.h> | |
45 #include <mime.h> | |
46 #include <notify.h> | |
47 #include <plugin.h> | |
48 #include <privacy.h> | |
49 #include <prpl.h> | |
50 #include <request.h> | |
51 #include <util.h> | |
52 #include <version.h> | |
53 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
54 /* meanwhile includes */ |
10977 | 55 #include <mw_cipher.h> |
56 #include <mw_common.h> | |
57 #include <mw_error.h> | |
58 #include <mw_service.h> | |
59 #include <mw_session.h> | |
60 #include <mw_srvc_aware.h> | |
61 #include <mw_srvc_conf.h> | |
62 #include <mw_srvc_ft.h> | |
63 #include <mw_srvc_im.h> | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
64 #include <mw_srvc_place.h> |
10977 | 65 #include <mw_srvc_resolve.h> |
66 #include <mw_srvc_store.h> | |
67 #include <mw_st_list.h> | |
68 | |
12813
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
69 /* plugin includes */ |
10977 | 70 #include "sametime.h" |
71 | |
72 | |
73 /* considering that there's no display of this information for prpls, | |
74 I don't know why I even bother providing these. Oh valiant reader, | |
75 I do it all for you. */ | |
76 /* scratch that, I just added it to the prpl options panel */ | |
77 #define PLUGIN_ID "prpl-meanwhile" | |
78 #define PLUGIN_NAME "Sametime" | |
79 #define PLUGIN_SUMMARY "Sametime Protocol Plugin" | |
80 #define PLUGIN_DESC "Open implementation of a Lotus Sametime client" | |
81 #define PLUGIN_AUTHOR "Christopher (siege) O'Brien <siege@preoccupied.net>" | |
82 #define PLUGIN_HOMEPAGE "http://meanwhile.sourceforge.net/" | |
83 | |
84 | |
85 /* plugin preference names */ | |
86 #define MW_PRPL_OPT_BASE "/plugins/prpl/meanwhile" | |
87 #define MW_PRPL_OPT_BLIST_ACTION MW_PRPL_OPT_BASE "/blist_action" | |
88 #define MW_PRPL_OPT_PSYCHIC MW_PRPL_OPT_BASE "/psychic" | |
89 #define MW_PRPL_OPT_FORCE_LOGIN MW_PRPL_OPT_BASE "/force_login" | |
90 #define MW_PRPL_OPT_SAVE_DYNAMIC MW_PRPL_OPT_BASE "/save_dynamic" | |
91 | |
92 | |
93 /* stages of connecting-ness */ | |
12813
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
94 #define MW_CONNECT_STEPS 10 |
10977 | 95 |
96 | |
97 /* stages of conciousness */ | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
98 #define MW_STATE_OFFLINE "offline" |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
99 #define MW_STATE_ACTIVE "active" |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
100 #define MW_STATE_AWAY "away" |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
101 #define MW_STATE_BUSY "dnd" |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
102 #define MW_STATE_MESSAGE "message" |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
103 #define MW_STATE_ENLIGHTENED "buddha" |
10977 | 104 |
105 | |
106 /* keys to get/set chat information */ | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
107 #define CHAT_KEY_CREATOR "chat.creator" |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
108 #define CHAT_KEY_NAME "chat.name" |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
109 #define CHAT_KEY_TOPIC "chat.topic" |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
110 #define CHAT_KEY_INVITE "chat.invite" |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
111 #define CHAT_KEY_IS_PLACE "chat.is_place" |
10977 | 112 |
113 | |
114 /* key for associating a mwLoginType with a buddy */ | |
115 #define BUDDY_KEY_CLIENT "meanwhile.client" | |
116 | |
117 /* store the remote alias so that we can re-create it easily */ | |
118 #define BUDDY_KEY_NAME "meanwhile.shortname" | |
119 | |
120 /* enum mwSametimeUserType */ | |
121 #define BUDDY_KEY_TYPE "meanwhile.type" | |
122 | |
123 | |
124 /* key for the real group name for a meanwhile group */ | |
125 #define GROUP_KEY_NAME "meanwhile.group" | |
126 | |
127 /* enum mwSametimeGroupType */ | |
128 #define GROUP_KEY_TYPE "meanwhile.type" | |
129 | |
130 /* NAB group owning account */ | |
131 #define GROUP_KEY_OWNER "meanwhile.account" | |
132 | |
133 /* key gtk blist uses to indicate a collapsed group */ | |
134 #define GROUP_KEY_COLLAPSED "collapsed" | |
135 | |
136 | |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
137 /* verification replacement */ |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
138 #define mwSession_NO_SECRET "meanwhile.no_secret" |
10977 | 139 |
140 | |
141 /* keys to get/set gaim plugin information */ | |
142 #define MW_KEY_HOST "server" | |
143 #define MW_KEY_PORT "port" | |
144 #define MW_KEY_ACTIVE_MSG "active_msg" | |
145 #define MW_KEY_AWAY_MSG "away_msg" | |
146 #define MW_KEY_BUSY_MSG "busy_msg" | |
147 #define MW_KEY_MSG_PROMPT "msg_prompt" | |
148 #define MW_KEY_INVITE "conf_invite" | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
149 #define MW_KEY_ENCODING "encoding" |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
150 #define MW_KEY_FORCE "force_login" |
12311
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
151 #define MW_KEY_FAKE_IT "fake_client_id" |
10977 | 152 |
153 | |
154 /** number of seconds from the first blist change before a save to the | |
155 storage service occurs. */ | |
156 #define BLIST_SAVE_SECONDS 15 | |
157 | |
158 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
159 /** the possible buddy list storage settings */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
160 enum blist_choice { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
161 blist_choice_LOCAL = 1, /**< local only */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
162 blist_choice_MERGE = 2, /**< merge from server */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
163 blist_choice_STORE = 3, /**< merge from and save to server */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
164 blist_choice_SYNCH = 4, /**< sync with server */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
165 }; |
10977 | 166 |
167 | |
168 /** the default blist storage option */ | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
169 #define BLIST_CHOICE_DEFAULT blist_choice_SYNCH |
10977 | 170 |
171 | |
172 /* testing for the above */ | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
173 #define BLIST_PREF_IS(n) (gaim_prefs_get_int(MW_PRPL_OPT_BLIST_ACTION)==(n)) |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
174 #define BLIST_PREF_IS_LOCAL() BLIST_PREF_IS(blist_choice_LOCAL) |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
175 #define BLIST_PREF_IS_MERGE() BLIST_PREF_IS(blist_choice_MERGE) |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
176 #define BLIST_PREF_IS_STORE() BLIST_PREF_IS(blist_choice_STORE) |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
177 #define BLIST_PREF_IS_SYNCH() BLIST_PREF_IS(blist_choice_SYNCH) |
10977 | 178 |
179 | |
180 /* debugging output */ | |
181 #define DEBUG_ERROR(a...) gaim_debug_error(G_LOG_DOMAIN, a) | |
182 #define DEBUG_INFO(a...) gaim_debug_info(G_LOG_DOMAIN, a) | |
183 #define DEBUG_MISC(a...) gaim_debug_misc(G_LOG_DOMAIN, a) | |
184 #define DEBUG_WARN(a...) gaim_debug_warning(G_LOG_DOMAIN, a) | |
185 | |
186 | |
187 /** ensure non-null strings */ | |
188 #ifndef NSTR | |
189 # define NSTR(str) ((str)? (str): "(null)") | |
190 #endif | |
191 | |
192 | |
193 /** calibrates distinct secure channel nomenclature */ | |
194 static const unsigned char no_secret[] = { | |
195 0x2d, 0x2d, 0x20, 0x73, 0x69, 0x65, 0x67, 0x65, | |
196 0x20, 0x6c, 0x6f, 0x76, 0x65, 0x73, 0x20, 0x6a, | |
197 0x65, 0x6e, 0x6e, 0x69, 0x20, 0x61, 0x6e, 0x64, | |
198 0x20, 0x7a, 0x6f, 0x65, 0x20, 0x2d, 0x2d, 0x00, | |
199 }; | |
200 | |
201 | |
202 /** handler IDs from g_log_set_handler in mw_plugin_init */ | |
203 static guint log_handler[2] = { 0, 0 }; | |
204 | |
205 | |
206 /** the gaim plugin data. | |
207 available as gc->proto_data and mwSession_getClientData */ | |
208 struct mwGaimPluginData { | |
209 struct mwSession *session; | |
210 | |
211 struct mwServiceAware *srvc_aware; | |
212 struct mwServiceConference *srvc_conf; | |
213 struct mwServiceFileTransfer *srvc_ft; | |
214 struct mwServiceIm *srvc_im; | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
215 struct mwServicePlace *srvc_place; |
10977 | 216 struct mwServiceResolve *srvc_resolve; |
217 struct mwServiceStorage *srvc_store; | |
218 | |
219 /** map of GaimGroup:mwAwareList and mwAwareList:GaimGroup */ | |
220 GHashTable *group_list_map; | |
221 | |
222 /** event id for the buddy list save callback */ | |
223 guint save_event; | |
224 | |
225 /** socket fd */ | |
226 int socket; | |
227 | |
228 GaimConnection *gc; | |
229 }; | |
230 | |
231 | |
232 /* blist and aware functions */ | |
233 | |
234 static void blist_export(GaimConnection *gc, struct mwSametimeList *stlist); | |
235 | |
236 static void blist_store(struct mwGaimPluginData *pd); | |
237 | |
238 static void blist_schedule(struct mwGaimPluginData *pd); | |
239 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
240 static void blist_merge(GaimConnection *gc, struct mwSametimeList *stlist); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
241 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
242 static void blist_sync(GaimConnection *gc, struct mwSametimeList *stlist); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
243 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
244 static gboolean buddy_is_external(GaimBuddy *b); |
10977 | 245 |
246 static void buddy_add(struct mwGaimPluginData *pd, GaimBuddy *buddy); | |
247 | |
248 static GaimBuddy * | |
249 buddy_ensure(GaimConnection *gc, GaimGroup *group, | |
250 struct mwSametimeUser *stuser); | |
251 | |
252 static void group_add(struct mwGaimPluginData *pd, GaimGroup *group); | |
253 | |
254 static GaimGroup * | |
255 group_ensure(GaimConnection *gc, struct mwSametimeGroup *stgroup); | |
256 | |
257 static struct mwAwareList * | |
258 list_ensure(struct mwGaimPluginData *pd, GaimGroup *group); | |
259 | |
260 | |
261 /* session functions */ | |
262 | |
263 static struct mwSession * | |
264 gc_to_session(GaimConnection *gc); | |
265 | |
266 static GaimConnection *session_to_gc(struct mwSession *session); | |
267 | |
268 | |
269 /* conference functions */ | |
270 | |
271 static struct mwConference * | |
272 conf_find_by_id(struct mwGaimPluginData *pd, int id); | |
273 | |
274 | |
275 /* conversation functions */ | |
276 | |
277 struct convo_msg { | |
278 enum mwImSendType type; | |
279 gpointer data; | |
280 GDestroyNotify clear; | |
281 }; | |
282 | |
283 | |
284 struct convo_data { | |
285 struct mwConversation *conv; | |
286 GList *queue; /**< outgoing message queue, list of convo_msg */ | |
287 }; | |
288 | |
289 static void convo_data_new(struct mwConversation *conv); | |
290 | |
291 static void convo_data_free(struct convo_data *conv); | |
292 | |
293 static void convo_features(struct mwConversation *conv); | |
294 | |
295 static GaimConversation *convo_get_gconv(struct mwConversation *conv); | |
296 | |
297 | |
12629
fee6a32644a4
[gaim-migrate @ 14965]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
298 /* name and id */ |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
299 |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
300 struct named_id { |
10977 | 301 char *id; |
302 char *name; | |
303 }; | |
304 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
305 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
306 /* connection functions */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
307 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
308 static void connect_cb(gpointer data, gint source, GaimInputCondition cond); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
309 |
10977 | 310 |
311 /* ----- session ------ */ | |
312 | |
313 | |
314 /** resolves a mwSession from a GaimConnection */ | |
315 static struct mwSession *gc_to_session(GaimConnection *gc) { | |
316 struct mwGaimPluginData *pd; | |
317 | |
318 g_return_val_if_fail(gc != NULL, NULL); | |
319 | |
320 pd = gc->proto_data; | |
321 g_return_val_if_fail(pd != NULL, NULL); | |
322 | |
323 return pd->session; | |
324 } | |
325 | |
326 | |
327 /** resolves a GaimConnection from a mwSession */ | |
328 static GaimConnection *session_to_gc(struct mwSession *session) { | |
329 struct mwGaimPluginData *pd; | |
330 | |
331 g_return_val_if_fail(session != NULL, NULL); | |
332 | |
333 pd = mwSession_getClientData(session); | |
334 g_return_val_if_fail(pd != NULL, NULL); | |
335 | |
336 return pd->gc; | |
337 } | |
338 | |
339 | |
340 static int mw_session_io_write(struct mwSession *session, | |
12311
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
341 const guchar *buf, gsize len) { |
10977 | 342 struct mwGaimPluginData *pd; |
343 int ret = 0; | |
344 | |
345 pd = mwSession_getClientData(session); | |
346 | |
347 /* socket was already closed. */ | |
348 if(pd->socket == 0) | |
349 return 1; | |
350 | |
351 while(len) { | |
352 ret = write(pd->socket, buf, len); | |
353 if(ret <= 0) break; | |
354 len -= ret; | |
355 } | |
356 | |
357 if(len > 0) { | |
358 DEBUG_ERROR("write returned %i, %i bytes left unwritten\n", ret, len); | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
359 gaim_connection_error(pd->gc, _("Connection closed (writing)")); |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
360 |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
361 #if 0 |
10977 | 362 close(pd->socket); |
363 pd->socket = 0; | |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
364 #endif |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
365 |
10977 | 366 return -1; |
367 } | |
368 | |
369 return 0; | |
370 } | |
371 | |
372 | |
373 static void mw_session_io_close(struct mwSession *session) { | |
374 struct mwGaimPluginData *pd; | |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
375 GaimConnection *gc; |
10977 | 376 |
377 pd = mwSession_getClientData(session); | |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
378 g_return_if_fail(pd != NULL); |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
379 |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
380 gc = pd->gc; |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
381 |
10977 | 382 if(pd->socket) { |
383 close(pd->socket); | |
384 pd->socket = 0; | |
385 } | |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
386 |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
387 if(gc->inpa) { |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
388 gaim_input_remove(gc->inpa); |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
389 gc->inpa = 0; |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
390 } |
10977 | 391 } |
392 | |
393 | |
394 static void mw_session_clear(struct mwSession *session) { | |
395 ; /* nothing for now */ | |
396 } | |
397 | |
398 | |
399 /* ----- aware list ----- */ | |
400 | |
401 | |
402 static void blist_resolve_alias_cb(struct mwServiceResolve *srvc, | |
403 guint32 id, guint32 code, GList *results, | |
404 gpointer data) { | |
405 struct mwResolveResult *result; | |
406 struct mwResolveMatch *match; | |
407 | |
408 g_return_if_fail(results != NULL); | |
409 | |
410 result = results->data; | |
411 g_return_if_fail(result != NULL); | |
412 g_return_if_fail(result->matches != NULL); | |
413 | |
414 match = result->matches->data; | |
415 g_return_if_fail(match != NULL); | |
416 | |
417 gaim_blist_server_alias_buddy(data, match->name); | |
418 gaim_blist_node_set_string(data, BUDDY_KEY_NAME, match->name); | |
419 } | |
420 | |
421 | |
422 static void mw_aware_list_on_aware(struct mwAwareList *list, | |
423 struct mwAwareSnapshot *aware) { | |
424 | |
425 GaimConnection *gc; | |
11638 | 426 GaimAccount *acct; |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
427 |
10977 | 428 struct mwGaimPluginData *pd; |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
429 time_t idle; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
430 guint stat; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
431 const char *id; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
432 const char *status = MW_STATE_ACTIVE; |
10977 | 433 |
434 gc = mwAwareList_getClientData(list); | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
435 acct = gaim_connection_get_account(gc); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
436 |
10977 | 437 pd = gc->proto_data; |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
438 idle = aware->status.time; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
439 stat = aware->status.status; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
440 id = aware->id.user; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
441 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
442 /* not sure which client sends this yet */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
443 if(idle == 0xdeadbeef) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
444 /* knock knock! |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
445 who's there? |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
446 rude interrupting cow. |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
447 rude interr... |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
448 MOO! */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
449 idle = -1; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
450 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
451 |
10977 | 452 switch(stat) { |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
453 case mwStatus_ACTIVE: |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
454 status = MW_STATE_ACTIVE; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
455 idle = 0; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
456 break; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
457 |
10977 | 458 case mwStatus_IDLE: |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
459 if(! idle) idle = -1; |
10977 | 460 break; |
461 | |
462 case mwStatus_AWAY: | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
463 status = MW_STATE_AWAY; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
464 break; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
465 |
10977 | 466 case mwStatus_BUSY: |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
467 status = MW_STATE_BUSY; |
10977 | 468 break; |
469 } | |
470 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
471 /* NAB group members */ |
10977 | 472 if(aware->group) { |
473 GaimGroup *group; | |
474 GaimBuddy *buddy; | |
475 GaimBlistNode *bnode; | |
476 | |
477 group = g_hash_table_lookup(pd->group_list_map, list); | |
478 buddy = gaim_find_buddy_in_group(acct, id, group); | |
479 bnode = (GaimBlistNode *) buddy; | |
480 | |
481 if(! buddy) { | |
482 struct mwServiceResolve *srvc; | |
483 GList *query; | |
484 | |
485 buddy = gaim_buddy_new(acct, id, NULL); | |
486 gaim_blist_add_buddy(buddy, NULL, group, NULL); | |
487 | |
488 bnode = (GaimBlistNode *) buddy; | |
489 | |
490 srvc = pd->srvc_resolve; | |
491 query = g_list_append(NULL, (char *) id); | |
492 | |
493 mwServiceResolve_resolve(srvc, query, mwResolveFlag_USERS, | |
494 blist_resolve_alias_cb, buddy, NULL); | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
495 g_list_free(query); |
10977 | 496 } |
497 | |
498 gaim_blist_node_set_int(bnode, BUDDY_KEY_TYPE, mwSametimeUser_NORMAL); | |
499 } | |
500 | |
12263
8190a70d2c34
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
501 if(aware->online) { |
8190a70d2c34
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
502 gaim_prpl_got_user_status(acct, id, status, NULL); |
8190a70d2c34
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
503 gaim_prpl_got_user_idle(acct, id, !!idle, idle); |
8190a70d2c34
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
504 |
8190a70d2c34
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
505 } else { |
8190a70d2c34
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
506 gaim_prpl_got_user_status(acct, id, MW_STATE_OFFLINE, NULL); |
8190a70d2c34
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
507 } |
10977 | 508 } |
509 | |
510 | |
511 static void mw_aware_list_on_attrib(struct mwAwareList *list, | |
512 struct mwAwareIdBlock *id, | |
513 struct mwAwareAttribute *attrib) { | |
514 | |
515 ; /* nothing. We'll get attribute data as we need it */ | |
516 } | |
517 | |
518 | |
519 static void mw_aware_list_clear(struct mwAwareList *list) { | |
520 ; /* nothing for now */ | |
521 } | |
522 | |
523 | |
524 static struct mwAwareListHandler mw_aware_list_handler = { | |
525 .on_aware = mw_aware_list_on_aware, | |
526 .on_attrib = mw_aware_list_on_attrib, | |
527 .clear = mw_aware_list_clear, | |
528 }; | |
529 | |
530 | |
531 /** Ensures that an Aware List is associated with the given group, and | |
532 returns that list. */ | |
533 static struct mwAwareList * | |
534 list_ensure(struct mwGaimPluginData *pd, GaimGroup *group) { | |
535 | |
536 struct mwAwareList *list; | |
537 | |
538 g_return_val_if_fail(pd != NULL, NULL); | |
539 g_return_val_if_fail(group != NULL, NULL); | |
540 | |
541 list = g_hash_table_lookup(pd->group_list_map, group); | |
542 if(! list) { | |
543 list = mwAwareList_new(pd->srvc_aware, &mw_aware_list_handler); | |
544 mwAwareList_setClientData(list, pd->gc, NULL); | |
545 | |
546 mwAwareList_watchAttributes(list, | |
547 mwAttribute_AV_PREFS_SET, | |
548 mwAttribute_MICROPHONE, | |
549 mwAttribute_SPEAKERS, | |
550 mwAttribute_VIDEO_CAMERA, | |
551 mwAttribute_FILE_TRANSFER, | |
552 NULL); | |
553 | |
554 g_hash_table_replace(pd->group_list_map, group, list); | |
555 g_hash_table_insert(pd->group_list_map, list, group); | |
556 } | |
557 | |
558 return list; | |
559 } | |
560 | |
561 | |
562 static void blist_export(GaimConnection *gc, struct mwSametimeList *stlist) { | |
563 /* - find the account for this connection | |
564 - iterate through the buddy list | |
565 - add each buddy matching this account to the stlist | |
566 */ | |
567 | |
568 GaimAccount *acct; | |
569 GaimBuddyList *blist; | |
570 GaimBlistNode *gn, *cn, *bn; | |
571 GaimGroup *grp; | |
572 GaimBuddy *bdy; | |
573 | |
574 struct mwSametimeGroup *stg = NULL; | |
575 struct mwIdBlock idb = { NULL, NULL }; | |
576 | |
577 acct = gaim_connection_get_account(gc); | |
578 g_return_if_fail(acct != NULL); | |
579 | |
580 blist = gaim_get_blist(); | |
581 g_return_if_fail(blist != NULL); | |
582 | |
583 for(gn = blist->root; gn; gn = gn->next) { | |
584 const char *owner; | |
585 const char *gname; | |
586 enum mwSametimeGroupType gtype; | |
587 gboolean gopen; | |
588 | |
589 if(! GAIM_BLIST_NODE_IS_GROUP(gn)) continue; | |
590 grp = (GaimGroup *) gn; | |
591 | |
592 /* the group's type (normal or dynamic) */ | |
593 gtype = gaim_blist_node_get_int(gn, GROUP_KEY_TYPE); | |
594 if(! gtype) gtype = mwSametimeGroup_NORMAL; | |
595 | |
596 /* if it's a normal group with none of our people in it, skip it */ | |
597 if(gtype == mwSametimeGroup_NORMAL && !gaim_group_on_account(grp, acct)) | |
598 continue; | |
599 | |
600 /* if the group has an owner and we're not it, skip it */ | |
601 owner = gaim_blist_node_get_string(gn, GROUP_KEY_OWNER); | |
602 if(owner && strcmp(owner, gaim_account_get_username(acct))) | |
603 continue; | |
604 | |
605 /* the group's actual name may be different from the gaim group's | |
606 name. Find whichever is there */ | |
607 gname = gaim_blist_node_get_string(gn, GROUP_KEY_NAME); | |
608 if(! gname) gname = grp->name; | |
609 | |
610 /* we save this, but never actually honor it */ | |
611 gopen = ! gaim_blist_node_get_bool(gn, GROUP_KEY_COLLAPSED); | |
612 | |
613 stg = mwSametimeGroup_new(stlist, gtype, gname); | |
614 mwSametimeGroup_setAlias(stg, grp->name); | |
615 mwSametimeGroup_setOpen(stg, gopen); | |
616 | |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
617 /* don't attempt to put buddies in a dynamic group, it breaks |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
618 other clients */ |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
619 if(gtype == mwSametimeGroup_DYNAMIC) |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
620 continue; |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
621 |
10977 | 622 for(cn = gn->child; cn; cn = cn->next) { |
623 if(! GAIM_BLIST_NODE_IS_CONTACT(cn)) continue; | |
624 | |
625 for(bn = cn->child; bn; bn = bn->next) { | |
626 if(! GAIM_BLIST_NODE_IS_BUDDY(bn)) continue; | |
627 if(! GAIM_BLIST_NODE_SHOULD_SAVE(bn)) continue; | |
628 | |
629 bdy = (GaimBuddy *) bn; | |
630 | |
631 if(bdy->account == acct) { | |
632 struct mwSametimeUser *stu; | |
633 enum mwSametimeUserType utype; | |
634 | |
635 idb.user = bdy->name; | |
636 | |
637 utype = gaim_blist_node_get_int(bn, BUDDY_KEY_TYPE); | |
638 if(! utype) utype = mwSametimeUser_NORMAL; | |
639 | |
640 stu = mwSametimeUser_new(stg, utype, &idb); | |
641 mwSametimeUser_setShortName(stu, bdy->server_alias); | |
642 mwSametimeUser_setAlias(stu, bdy->alias); | |
643 } | |
644 } | |
645 } | |
646 } | |
647 } | |
648 | |
649 | |
650 static void blist_store(struct mwGaimPluginData *pd) { | |
651 | |
652 struct mwSametimeList *stlist; | |
653 struct mwServiceStorage *srvc; | |
654 struct mwStorageUnit *unit; | |
655 | |
656 GaimConnection *gc; | |
657 | |
658 struct mwPutBuffer *b; | |
659 struct mwOpaque *o; | |
660 | |
661 g_return_if_fail(pd != NULL); | |
662 | |
663 srvc = pd->srvc_store; | |
664 g_return_if_fail(srvc != NULL); | |
665 | |
666 gc = pd->gc; | |
667 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
668 if(BLIST_PREF_IS_LOCAL() || BLIST_PREF_IS_MERGE()) { |
10977 | 669 DEBUG_INFO("preferences indicate not to save remote blist\n"); |
670 return; | |
671 | |
672 } else if(MW_SERVICE_IS_DEAD(srvc)) { | |
673 DEBUG_INFO("aborting save of blist: storage service is not alive\n"); | |
674 return; | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
675 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
676 } else if(BLIST_PREF_IS_STORE() || BLIST_PREF_IS_SYNCH()) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
677 DEBUG_INFO("saving remote blist\n"); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
678 |
10977 | 679 } else { |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
680 g_return_if_reached(); |
10977 | 681 } |
682 | |
683 /* create and export to a list object */ | |
684 stlist = mwSametimeList_new(); | |
685 blist_export(gc, stlist); | |
686 | |
687 /* write it to a buffer */ | |
688 b = mwPutBuffer_new(); | |
689 mwSametimeList_put(b, stlist); | |
690 mwSametimeList_free(stlist); | |
691 | |
692 /* put the buffer contents into a storage unit */ | |
693 unit = mwStorageUnit_new(mwStore_AWARE_LIST); | |
694 o = mwStorageUnit_asOpaque(unit); | |
695 mwPutBuffer_finalize(o, b); | |
696 | |
697 /* save the storage unit to the service */ | |
698 mwServiceStorage_save(srvc, unit, NULL, NULL, NULL); | |
699 } | |
700 | |
701 | |
702 static gboolean blist_save_cb(gpointer data) { | |
703 struct mwGaimPluginData *pd = data; | |
704 | |
705 blist_store(pd); | |
706 pd->save_event = 0; | |
707 return FALSE; | |
708 } | |
709 | |
710 | |
711 /** schedules the buddy list to be saved to the server */ | |
712 static void blist_schedule(struct mwGaimPluginData *pd) { | |
713 if(pd->save_event) return; | |
714 | |
715 pd->save_event = gaim_timeout_add(BLIST_SAVE_SECONDS * 1000, | |
716 blist_save_cb, pd); | |
717 } | |
718 | |
719 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
720 static gboolean buddy_is_external(GaimBuddy *b) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
721 g_return_val_if_fail(b != NULL, FALSE); |
12166 | 722 return gaim_str_has_prefix(b->name, "@E "); |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
723 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
724 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
725 |
10977 | 726 /** Actually add a buddy to the aware service, and schedule the buddy |
727 list to be saved to the server */ | |
728 static void buddy_add(struct mwGaimPluginData *pd, | |
729 GaimBuddy *buddy) { | |
730 | |
731 struct mwAwareIdBlock idb = { mwAware_USER, (char *) buddy->name, NULL }; | |
732 struct mwAwareList *list; | |
733 | |
734 GaimGroup *group; | |
735 GList *add; | |
736 | |
737 add = g_list_prepend(NULL, &idb); | |
738 | |
12088 | 739 group = gaim_buddy_get_group(buddy); |
10977 | 740 list = list_ensure(pd, group); |
741 | |
742 if(mwAwareList_addAware(list, add)) { | |
743 gaim_blist_remove_buddy(buddy); | |
744 } | |
745 | |
746 blist_schedule(pd); | |
747 | |
748 g_list_free(add); | |
749 } | |
750 | |
751 | |
752 /** ensure that a GaimBuddy exists in the group with data | |
753 appropriately matching the st user entry from the st list */ | |
754 static GaimBuddy *buddy_ensure(GaimConnection *gc, GaimGroup *group, | |
755 struct mwSametimeUser *stuser) { | |
756 | |
757 struct mwGaimPluginData *pd = gc->proto_data; | |
758 GaimBuddy *buddy; | |
759 GaimAccount *acct = gaim_connection_get_account(gc); | |
760 | |
761 const char *id = mwSametimeUser_getUser(stuser); | |
762 const char *name = mwSametimeUser_getShortName(stuser); | |
763 const char *alias = mwSametimeUser_getAlias(stuser); | |
764 enum mwSametimeUserType type = mwSametimeUser_getType(stuser); | |
765 | |
766 g_return_val_if_fail(id != NULL, NULL); | |
767 g_return_val_if_fail(strlen(id) > 0, NULL); | |
768 | |
769 buddy = gaim_find_buddy_in_group(acct, id, group); | |
770 if(! buddy) { | |
771 buddy = gaim_buddy_new(acct, id, alias); | |
772 | |
773 gaim_blist_add_buddy(buddy, NULL, group, NULL); | |
774 buddy_add(pd, buddy); | |
775 } | |
776 | |
777 gaim_blist_alias_buddy(buddy, alias); | |
778 gaim_blist_server_alias_buddy(buddy, name); | |
779 gaim_blist_node_set_string((GaimBlistNode *) buddy, BUDDY_KEY_NAME, name); | |
780 gaim_blist_node_set_int((GaimBlistNode *) buddy, BUDDY_KEY_TYPE, type); | |
781 | |
782 return buddy; | |
783 } | |
784 | |
785 | |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
786 /** add aware watch for a dynamic group */ |
10977 | 787 static void group_add(struct mwGaimPluginData *pd, |
788 GaimGroup *group) { | |
789 | |
790 struct mwAwareIdBlock idb = { mwAware_GROUP, NULL, NULL }; | |
791 struct mwAwareList *list; | |
792 const char *n; | |
793 GList *add; | |
794 | |
795 n = gaim_blist_node_get_string((GaimBlistNode *) group, GROUP_KEY_NAME); | |
796 if(! n) n = group->name; | |
797 | |
798 idb.user = (char *) n; | |
799 add = g_list_prepend(NULL, &idb); | |
800 | |
801 list = list_ensure(pd, group); | |
802 mwAwareList_addAware(list, add); | |
803 g_list_free(add); | |
804 } | |
805 | |
806 | |
807 /** ensure that a GaimGroup exists in the blist with data | |
808 appropriately matching the st group entry from the st list */ | |
809 static GaimGroup *group_ensure(GaimConnection *gc, | |
810 struct mwSametimeGroup *stgroup) { | |
811 GaimAccount *acct; | |
12006
de25a063aebe
[gaim-migrate @ 14299]
Christopher O'Brien <siege@pidgin.im>
parents:
12005
diff
changeset
|
812 GaimGroup *group = NULL; |
12005
5b3368008513
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
813 GaimBuddyList *blist; |
10977 | 814 GaimBlistNode *gn; |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
815 const char *name, *alias, *owner; |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
816 enum mwSametimeGroupType type; |
10977 | 817 |
818 acct = gaim_connection_get_account(gc); | |
819 owner = gaim_account_get_username(acct); | |
820 | |
12005
5b3368008513
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
821 blist = gaim_get_blist(); |
5b3368008513
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
822 g_return_val_if_fail(blist != NULL, NULL); |
5b3368008513
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
823 |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
824 name = mwSametimeGroup_getName(stgroup); |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
825 alias = mwSametimeGroup_getAlias(stgroup); |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
826 type = mwSametimeGroup_getType(stgroup); |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
827 |
12524
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
828 DEBUG_INFO("attempting to ensure group %s, called %s\n", |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
829 NSTR(name), NSTR(alias)); |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
830 |
12005
5b3368008513
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
831 /* first attempt at finding the group, by the name key */ |
5b3368008513
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
832 for(gn = blist->root; gn; gn = gn->next) { |
12524
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
833 const char *n, *o; |
12005
5b3368008513
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
834 if(! GAIM_BLIST_NODE_IS_GROUP(gn)) continue; |
5b3368008513
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
835 n = gaim_blist_node_get_string(gn, GROUP_KEY_NAME); |
12524
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
836 o = gaim_blist_node_get_string(gn, GROUP_KEY_OWNER); |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
837 |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
838 DEBUG_INFO("found group named %s, owned by %s\n", NSTR(n), NSTR(o)); |
12005
5b3368008513
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
839 |
5b3368008513
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
840 if(n && !strcmp(n, name)) { |
12524
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
841 if(!o || !strcmp(o, owner)) { |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
842 DEBUG_INFO("that'll work\n"); |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
843 group = (GaimGroup *) gn; |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
844 break; |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
845 } |
12005
5b3368008513
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
846 } |
12524
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
847 } |
12005
5b3368008513
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
848 |
5b3368008513
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
849 /* try again, by alias */ |
12524
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
850 if(! group) { |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
851 DEBUG_INFO("searching for group by alias %s\n", NSTR(alias)); |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
852 group = gaim_find_group(alias); |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
853 } |
12005
5b3368008513
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
854 |
5b3368008513
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
855 /* oh well, no such group. Let's create it! */ |
10977 | 856 if(! group) { |
12524
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
857 DEBUG_INFO("creating group\n"); |
10977 | 858 group = gaim_group_new(alias); |
859 gaim_blist_add_group(group, NULL); | |
860 } | |
861 | |
862 gn = (GaimBlistNode *) group; | |
863 gaim_blist_node_set_string(gn, GROUP_KEY_NAME, name); | |
864 gaim_blist_node_set_int(gn, GROUP_KEY_TYPE, type); | |
865 | |
866 if(type == mwSametimeGroup_DYNAMIC) { | |
867 gaim_blist_node_set_string(gn, GROUP_KEY_OWNER, owner); | |
868 group_add(gc->proto_data, group); | |
869 } | |
870 | |
871 return group; | |
872 } | |
873 | |
874 | |
875 /** merge the entries from a st list into the gaim blist */ | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
876 static void blist_merge(GaimConnection *gc, struct mwSametimeList *stlist) { |
10977 | 877 struct mwSametimeGroup *stgroup; |
878 struct mwSametimeUser *stuser; | |
879 | |
880 GaimGroup *group; | |
881 GaimBuddy *buddy; | |
882 | |
883 GList *gl, *gtl, *ul, *utl; | |
884 | |
885 gl = gtl = mwSametimeList_getGroups(stlist); | |
886 for(; gl; gl = gl->next) { | |
887 | |
888 stgroup = (struct mwSametimeGroup *) gl->data; | |
889 group = group_ensure(gc, stgroup); | |
890 | |
891 ul = utl = mwSametimeGroup_getUsers(stgroup); | |
892 for(; ul; ul = ul->next) { | |
893 | |
894 stuser = (struct mwSametimeUser *) ul->data; | |
895 buddy = buddy_ensure(gc, group, stuser); | |
896 } | |
897 g_list_free(utl); | |
898 } | |
899 g_list_free(gtl); | |
900 } | |
901 | |
902 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
903 /** remove all buddies on account from group. If del is TRUE and group |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
904 is left empty, remove group as well */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
905 static void group_clear(GaimGroup *group, GaimAccount *acct, gboolean del) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
906 GaimConnection *gc; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
907 GList *prune = NULL; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
908 GaimBlistNode *gn, *cn, *bn; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
909 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
910 g_return_if_fail(group != NULL); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
911 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
912 DEBUG_INFO("clearing members from pruned group %s\n", NSTR(group->name)); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
913 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
914 gc = gaim_account_get_connection(acct); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
915 g_return_if_fail(gc != NULL); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
916 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
917 gn = (GaimBlistNode *) group; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
918 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
919 for(cn = gn->child; cn; cn = cn->next) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
920 if(! GAIM_BLIST_NODE_IS_CONTACT(cn)) continue; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
921 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
922 for(bn = cn->child; bn; bn = bn->next) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
923 GaimBuddy *gb = (GaimBuddy *) bn; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
924 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
925 if(! GAIM_BLIST_NODE_IS_BUDDY(bn)) continue; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
926 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
927 if(gb->account == acct) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
928 DEBUG_INFO("clearing %s from group\n", NSTR(gb->name)); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
929 prune = g_list_prepend(prune, gb); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
930 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
931 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
932 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
933 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
934 /* quickly unsubscribe from presence for the entire group */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
935 gaim_account_remove_group(acct, group); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
936 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
937 /* remove blist entries that need to go */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
938 while(prune) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
939 gaim_blist_remove_buddy(prune->data); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
940 prune = g_list_delete_link(prune, prune); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
941 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
942 DEBUG_INFO("cleared buddies\n"); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
943 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
944 /* optionally remove group from blist */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
945 if(del && !gaim_blist_get_group_size(group, TRUE)) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
946 DEBUG_INFO("removing empty group\n"); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
947 gaim_blist_remove_group(group); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
948 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
949 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
950 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
951 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
952 /** prune out group members that shouldn't be there */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
953 static void group_prune(GaimConnection *gc, GaimGroup *group, |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
954 struct mwSametimeGroup *stgroup) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
955 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
956 GaimAccount *acct; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
957 GaimBlistNode *gn, *cn, *bn; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
958 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
959 GHashTable *stusers; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
960 GList *prune = NULL; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
961 GList *ul, *utl; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
962 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
963 g_return_if_fail(group != NULL); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
964 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
965 DEBUG_INFO("pruning membership of group %s\n", NSTR(group->name)); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
966 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
967 acct = gaim_connection_get_account(gc); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
968 g_return_if_fail(acct != NULL); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
969 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
970 stusers = g_hash_table_new(g_str_hash, g_str_equal); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
971 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
972 /* build a hash table for quick lookup while pruning the group |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
973 contents */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
974 utl = mwSametimeGroup_getUsers(stgroup); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
975 for(ul = utl; ul; ul = ul->next) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
976 const char *id = mwSametimeUser_getUser(ul->data); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
977 g_hash_table_insert(stusers, (char *) id, ul->data); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
978 DEBUG_INFO("server copy has %s\n", NSTR(id)); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
979 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
980 g_list_free(utl); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
981 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
982 gn = (GaimBlistNode *) group; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
983 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
984 for(cn = gn->child; cn; cn = cn->next) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
985 if(! GAIM_BLIST_NODE_IS_CONTACT(cn)) continue; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
986 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
987 for(bn = cn->child; bn; bn = bn->next) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
988 GaimBuddy *gb = (GaimBuddy *) bn; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
989 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
990 if(! GAIM_BLIST_NODE_IS_BUDDY(bn)) continue; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
991 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
992 /* if the account is correct and they're not in our table, mark |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
993 them for pruning */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
994 if(gb->account == acct && !g_hash_table_lookup(stusers, gb->name)) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
995 DEBUG_INFO("marking %s for pruning\n", NSTR(gb->name)); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
996 prune = g_list_prepend(prune, gb); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
997 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
998 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
999 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1000 DEBUG_INFO("done marking\n"); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1001 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1002 g_hash_table_destroy(stusers); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1003 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1004 if(prune) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1005 gaim_account_remove_buddies(acct, prune, NULL); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1006 while(prune) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1007 gaim_blist_remove_buddy(prune->data); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1008 prune = g_list_delete_link(prune, prune); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1009 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1010 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1011 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1012 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1013 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1014 /** synch the entries from a st list into the gaim blist, removing any |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1015 existing buddies that aren't in the st list */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1016 static void blist_sync(GaimConnection *gc, struct mwSametimeList *stlist) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1017 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1018 GaimAccount *acct; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1019 GaimBuddyList *blist; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1020 GaimBlistNode *gn; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1021 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1022 GHashTable *stgroups; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1023 GList *g_prune = NULL; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1024 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1025 GList *gl, *gtl; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1026 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1027 const char *acct_n; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1028 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1029 DEBUG_INFO("synchronizing local buddy list from server list\n"); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1030 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1031 acct = gaim_connection_get_account(gc); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1032 g_return_if_fail(acct != NULL); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1033 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1034 acct_n = gaim_account_get_username(acct); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1035 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1036 blist = gaim_get_blist(); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1037 g_return_if_fail(blist != NULL); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1038 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1039 /* build a hash table for quick lookup while pruning the local |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1040 list, mapping group name to group structure */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1041 stgroups = g_hash_table_new(g_str_hash, g_str_equal); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1042 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1043 gtl = mwSametimeList_getGroups(stlist); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1044 for(gl = gtl; gl; gl = gl->next) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1045 const char *name = mwSametimeGroup_getName(gl->data); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1046 g_hash_table_insert(stgroups, (char *) name, gl->data); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1047 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1048 g_list_free(gtl); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1049 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1050 /* find all groups which should be pruned from the local list */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1051 for(gn = blist->root; gn; gn = gn->next) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1052 GaimGroup *grp = (GaimGroup *) gn; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1053 const char *gname, *owner; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1054 struct mwSametimeGroup *stgrp; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1055 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1056 if(! GAIM_BLIST_NODE_IS_GROUP(gn)) continue; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1057 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1058 /* group not belonging to this account */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1059 if(! gaim_group_on_account(grp, acct)) |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1060 continue; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1061 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1062 /* dynamic group belonging to this account. don't prune contents */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1063 owner = gaim_blist_node_get_string(gn, GROUP_KEY_OWNER); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1064 if(owner && !strcmp(owner, acct_n)) |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1065 continue; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1066 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1067 /* we actually are synching by this key as opposed to the group |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1068 title, which can be different things in the st list */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1069 gname = gaim_blist_node_get_string(gn, GROUP_KEY_NAME); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1070 if(! gname) gname = grp->name; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1071 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1072 stgrp = g_hash_table_lookup(stgroups, gname); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1073 if(! stgrp) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1074 /* remove the whole group */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1075 DEBUG_INFO("marking group %s for pruning\n", grp->name); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1076 g_prune = g_list_prepend(g_prune, grp); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1077 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1078 } else { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1079 /* synch the group contents */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1080 group_prune(gc, grp, stgrp); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1081 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1082 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1083 DEBUG_INFO("done marking groups\n"); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1084 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1085 /* don't need this anymore */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1086 g_hash_table_destroy(stgroups); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1087 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1088 /* prune all marked groups */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1089 while(g_prune) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1090 GaimGroup *grp = g_prune->data; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1091 GaimBlistNode *gn = (GaimBlistNode *) grp; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1092 const char *owner; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1093 gboolean del = TRUE; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1094 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1095 owner = gaim_blist_node_get_string(gn, GROUP_KEY_OWNER); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1096 if(owner && strcmp(owner, acct_n)) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1097 /* it's a specialty group belonging to another account with some |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1098 of our members in it, so don't fully delete it */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1099 del = FALSE; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1100 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1101 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1102 group_clear(g_prune->data, acct, del); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1103 g_prune = g_list_delete_link(g_prune, g_prune); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1104 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1105 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1106 /* done with the pruning, let's merge in the additions */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1107 blist_merge(gc, stlist); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1108 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1109 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1110 |
10977 | 1111 /** callback passed to the storage service when it's told to load the |
1112 st list */ | |
1113 static void fetch_blist_cb(struct mwServiceStorage *srvc, | |
1114 guint32 result, struct mwStorageUnit *item, | |
1115 gpointer data) { | |
1116 | |
1117 struct mwGaimPluginData *pd = data; | |
1118 struct mwSametimeList *stlist; | |
1119 struct mwSession *s; | |
1120 | |
1121 struct mwGetBuffer *b; | |
1122 | |
1123 g_return_if_fail(result == ERR_SUCCESS); | |
1124 | |
1125 /* check our preferences for loading */ | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1126 if(BLIST_PREF_IS_LOCAL()) { |
10977 | 1127 DEBUG_INFO("preferences indicate not to load remote buddy list\n"); |
1128 return; | |
1129 } | |
1130 | |
1131 b = mwGetBuffer_wrap(mwStorageUnit_asOpaque(item)); | |
1132 | |
1133 stlist = mwSametimeList_new(); | |
1134 mwSametimeList_get(b, stlist); | |
1135 | |
1136 s = mwService_getSession(MW_SERVICE(srvc)); | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1137 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1138 /* merge or synch depending on preferences */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1139 if(BLIST_PREF_IS_MERGE() || BLIST_PREF_IS_STORE()) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1140 blist_merge(pd->gc, stlist); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1141 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1142 } else if(BLIST_PREF_IS_SYNCH()) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1143 blist_sync(pd->gc, stlist); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1144 } |
10977 | 1145 |
1146 mwSametimeList_free(stlist); | |
1147 } | |
1148 | |
1149 | |
1150 /** signal triggered when a conversation is opened in Gaim */ | |
1151 static void conversation_created_cb(GaimConversation *g_conv, | |
1152 struct mwGaimPluginData *pd) { | |
1153 | |
1154 /* we need to tell the IM service to negotiate features for the | |
1155 conversation right away, otherwise it'll wait until the first | |
1156 message is sent before offering NotesBuddy features. Therefore | |
1157 whenever Gaim creates a conversation, we'll immediately open the | |
1158 channel to the other side and figure out what the target can | |
1159 handle. Unfortunately, this makes us vulnerable to Psychic Mode, | |
1160 whereas a more lazy negotiation based on the first message | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1161 would not */ |
10977 | 1162 |
1163 GaimConnection *gc; | |
1164 struct mwIdBlock who = { 0, 0 }; | |
1165 struct mwConversation *conv; | |
1166 | |
1167 gc = gaim_conversation_get_gc(g_conv); | |
1168 if(pd->gc != gc) | |
1169 return; /* not ours */ | |
1170 | |
11338 | 1171 if(gaim_conversation_get_type(g_conv) != GAIM_CONV_TYPE_IM) |
10977 | 1172 return; /* wrong type */ |
1173 | |
1174 who.user = (char *) gaim_conversation_get_name(g_conv); | |
1175 conv = mwServiceIm_getConversation(pd->srvc_im, &who); | |
1176 | |
1177 convo_features(conv); | |
1178 | |
1179 if(mwConversation_isClosed(conv)) | |
1180 mwConversation_open(conv); | |
1181 } | |
1182 | |
1183 | |
1184 static void blist_menu_nab(GaimBlistNode *node, gpointer data) { | |
1185 struct mwGaimPluginData *pd = data; | |
1186 GaimConnection *gc; | |
1187 | |
1188 GaimGroup *group = (GaimGroup *) node; | |
1189 | |
1190 GString *str; | |
1191 char *tmp; | |
1192 | |
1193 g_return_if_fail(pd != NULL); | |
1194 | |
1195 gc = pd->gc; | |
1196 g_return_if_fail(gc != NULL); | |
1197 | |
1198 g_return_if_fail(GAIM_BLIST_NODE_IS_GROUP(node)); | |
1199 | |
1200 str = g_string_new(NULL); | |
1201 | |
1202 tmp = (char *) gaim_blist_node_get_string(node, GROUP_KEY_NAME); | |
1203 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1204 g_string_append_printf(str, _("<b>Group Title:</b> %s<br>"), group->name); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1205 g_string_append_printf(str, _("<b>Notes Group ID:</b> %s<br>"), tmp); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1206 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1207 tmp = g_strdup_printf(_("Info for Group %s"), group->name); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1208 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1209 gaim_notify_formatted(gc, tmp, _("Notes Address Book Information"), |
10977 | 1210 NULL, str->str, NULL, NULL); |
1211 | |
1212 g_free(tmp); | |
1213 g_string_free(str, TRUE); | |
1214 } | |
1215 | |
1216 | |
1217 /** The normal blist menu prpl function doesn't get called for groups, | |
1218 so we use the blist-node-extended-menu signal to trigger this | |
1219 handler */ | |
1220 static void blist_node_menu_cb(GaimBlistNode *node, | |
13021
eb64b2b26e56
[gaim-migrate @ 15374]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12970
diff
changeset
|
1221 GList **menu, struct mwGaimPluginData *pd) { |
12107
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1222 const char *owner; |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1223 GaimGroup *group; |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1224 GaimAccount *acct; |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12864
diff
changeset
|
1225 GaimMenuAction *act; |
10977 | 1226 |
12107
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1227 /* we only want groups */ |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1228 if(! GAIM_BLIST_NODE_IS_GROUP(node)) return; |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1229 group = (GaimGroup *) node; |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1230 |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1231 acct = gaim_connection_get_account(pd->gc); |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1232 g_return_if_fail(acct != NULL); |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1233 |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1234 /* better make sure we're connected */ |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1235 if(! gaim_account_is_connected(acct)) return; |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1236 |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1237 #if 0 |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1238 /* if there's anyone in the group for this acct, offer to invite |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1239 them all to a conference */ |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1240 if(gaim_group_on_account(group, acct)) { |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12864
diff
changeset
|
1241 act = gaim_menu_action_new(_("Invite Group to Conference..."), |
12923
f50a99d5ba9b
[gaim-migrate @ 15276]
Christopher O'Brien <siege@pidgin.im>
parents:
12921
diff
changeset
|
1242 GAIM_CALLBACK(blist_menu_group_invite), |
13021
eb64b2b26e56
[gaim-migrate @ 15374]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12970
diff
changeset
|
1243 pd, NULL); |
12107
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1244 *menu = g_list_append(*menu, NULL); |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1245 } |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1246 #endif |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1247 |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1248 /* check if it's a NAB group for this account */ |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1249 owner = gaim_blist_node_get_string(node, GROUP_KEY_OWNER); |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
1250 if(owner && !strcmp(owner, gaim_account_get_username(acct))) { |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12864
diff
changeset
|
1251 act = gaim_menu_action_new(_("Get Notes Address Book Info"), |
12921
66e424d4bc77
[gaim-migrate @ 15274]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12919
diff
changeset
|
1252 GAIM_CALLBACK(blist_menu_nab), pd, NULL); |
10977 | 1253 *menu = g_list_append(*menu, act); |
1254 } | |
1255 } | |
1256 | |
1257 | |
12266
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1258 /* lifted this from oldstatus, since HEAD doesn't do this at login |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1259 anymore. */ |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1260 static void blist_init(GaimAccount *acct) { |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1261 GaimBlistNode *gnode, *cnode, *bnode; |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1262 GList *add_buds = NULL; |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1263 |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1264 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1265 if(! GAIM_BLIST_NODE_IS_GROUP(gnode)) continue; |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1266 |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1267 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1268 if(! GAIM_BLIST_NODE_IS_CONTACT(cnode)) |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1269 continue; |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1270 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1271 GaimBuddy *b; |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1272 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1273 continue; |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1274 |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1275 b = (GaimBuddy *)bnode; |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1276 if(b->account == acct) { |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1277 add_buds = g_list_append(add_buds, b); |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1278 } |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1279 } |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1280 } |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1281 } |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1282 |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1283 if(add_buds) { |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1284 gaim_account_add_buddies(acct, add_buds); |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1285 g_list_free(add_buds); |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1286 } |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1287 } |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1288 |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1289 |
10977 | 1290 /** Last thing to happen from a started session */ |
1291 static void services_starting(struct mwGaimPluginData *pd) { | |
1292 | |
1293 GaimConnection *gc; | |
1294 GaimAccount *acct; | |
1295 struct mwStorageUnit *unit; | |
1296 GaimBuddyList *blist; | |
1297 GaimBlistNode *l; | |
1298 | |
1299 gc = pd->gc; | |
1300 acct = gaim_connection_get_account(gc); | |
1301 | |
1302 /* grab the buddy list from the server */ | |
1303 unit = mwStorageUnit_new(mwStore_AWARE_LIST); | |
1304 mwServiceStorage_load(pd->srvc_store, unit, fetch_blist_cb, pd, NULL); | |
1305 | |
1306 /* find all the NAB groups and subscribe to them */ | |
1307 blist = gaim_get_blist(); | |
1308 for(l = blist->root; l; l = l->next) { | |
1309 GaimGroup *group = (GaimGroup *) l; | |
1310 enum mwSametimeGroupType gt; | |
1311 const char *owner; | |
1312 | |
1313 if(! GAIM_BLIST_NODE_IS_GROUP(l)) continue; | |
1314 | |
1315 /* if the group is ownerless, or has an owner and we're not it, | |
1316 skip it */ | |
1317 owner = gaim_blist_node_get_string(l, GROUP_KEY_OWNER); | |
1318 if(!owner || strcmp(owner, gaim_account_get_username(acct))) | |
1319 continue; | |
1320 | |
1321 gt = gaim_blist_node_get_int(l, GROUP_KEY_TYPE); | |
1322 if(gt == mwSametimeGroup_DYNAMIC) | |
1323 group_add(pd, group); | |
1324 } | |
1325 | |
1326 /* set the aware attributes */ | |
1327 /* indicate we understand what AV prefs are, but don't support any */ | |
1328 mwServiceAware_setAttributeBoolean(pd->srvc_aware, | |
1329 mwAttribute_AV_PREFS_SET, TRUE); | |
1330 mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_MICROPHONE); | |
1331 mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_SPEAKERS); | |
1332 mwServiceAware_unsetAttribute(pd->srvc_aware, mwAttribute_VIDEO_CAMERA); | |
1333 | |
1334 /* ... but we can do file transfers! */ | |
1335 mwServiceAware_setAttributeBoolean(pd->srvc_aware, | |
1336 mwAttribute_FILE_TRANSFER, TRUE); | |
12266
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1337 |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1338 blist_init(acct); |
10977 | 1339 } |
1340 | |
1341 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1342 static void session_loginRedirect(struct mwSession *session, |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1343 const char *host) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1344 struct mwGaimPluginData *pd; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1345 GaimConnection *gc; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1346 GaimAccount *account; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1347 guint port; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1348 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1349 pd = mwSession_getClientData(session); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1350 gc = pd->gc; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1351 account = gaim_connection_get_account(gc); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1352 port = gaim_account_get_int(account, MW_KEY_PORT, MW_PLUGIN_DEFAULT_PORT); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1353 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1354 if(gaim_account_get_bool(account, MW_KEY_FORCE, FALSE) || |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1355 gaim_proxy_connect(account, host, port, connect_cb, pd)) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1356 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1357 mwSession_forceLogin(session); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1358 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1359 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1360 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1361 |
12266
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1362 static void mw_prpl_set_status(GaimAccount *acct, GaimStatus *status); |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1363 |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1364 |
10977 | 1365 /** called from mw_session_stateChange when the session's state is |
1366 mwSession_STARTED. Any finalizing of start-up stuff should go | |
1367 here */ | |
1368 static void session_started(struct mwGaimPluginData *pd) { | |
12266
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1369 GaimStatus *status; |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1370 GaimAccount *acct; |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1371 |
12813
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1372 /* set out initial status */ |
12266
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1373 acct = gaim_connection_get_account(pd->gc); |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1374 status = gaim_account_get_active_status(acct); |
0e467757b57a
[gaim-migrate @ 14568]
Christopher O'Brien <siege@pidgin.im>
parents:
12263
diff
changeset
|
1375 mw_prpl_set_status(acct, status); |
12813
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1376 |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1377 /* start watching for new conversations */ |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1378 gaim_signal_connect(gaim_conversations_get_handle(), |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1379 "conversation-created", pd->gc, |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1380 GAIM_CALLBACK(conversation_created_cb), pd); |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1381 |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1382 /* watch for group extended menu items */ |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1383 gaim_signal_connect(gaim_blist_get_handle(), |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1384 "blist-node-extended-menu", pd->gc, |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1385 GAIM_CALLBACK(blist_node_menu_cb), pd); |
10977 | 1386 |
1387 /* use our services to do neat things */ | |
1388 services_starting(pd); | |
1389 } | |
1390 | |
1391 | |
1392 static void mw_session_stateChange(struct mwSession *session, | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1393 enum mwSessionState state, |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1394 gpointer info) { |
10977 | 1395 struct mwGaimPluginData *pd; |
1396 GaimConnection *gc; | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
1397 const char *msg = NULL; |
10977 | 1398 |
1399 pd = mwSession_getClientData(session); | |
1400 gc = pd->gc; | |
1401 | |
1402 switch(state) { | |
1403 case mwSession_STARTING: | |
1404 msg = _("Sending Handshake"); | |
1405 gaim_connection_update_progress(gc, msg, 2, MW_CONNECT_STEPS); | |
1406 break; | |
1407 | |
1408 case mwSession_HANDSHAKE: | |
1409 msg = _("Waiting for Handshake Acknowledgement"); | |
1410 gaim_connection_update_progress(gc, msg, 3, MW_CONNECT_STEPS); | |
1411 break; | |
1412 | |
1413 case mwSession_HANDSHAKE_ACK: | |
1414 msg = _("Handshake Acknowledged, Sending Login"); | |
1415 gaim_connection_update_progress(gc, msg, 4, MW_CONNECT_STEPS); | |
1416 break; | |
1417 | |
1418 case mwSession_LOGIN: | |
1419 msg = _("Waiting for Login Acknowledgement"); | |
1420 gaim_connection_update_progress(gc, msg, 5, MW_CONNECT_STEPS); | |
1421 break; | |
1422 | |
1423 case mwSession_LOGIN_REDIR: | |
1424 msg = _("Login Redirected"); | |
1425 gaim_connection_update_progress(gc, msg, 6, MW_CONNECT_STEPS); | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1426 session_loginRedirect(session, info); |
10977 | 1427 break; |
1428 | |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1429 case mwSession_LOGIN_CONT: |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1430 msg = _("Forcing Login"); |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1431 gaim_connection_update_progress(gc, msg, 7, MW_CONNECT_STEPS); |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1432 |
10977 | 1433 case mwSession_LOGIN_ACK: |
1434 msg = _("Login Acknowledged"); | |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1435 gaim_connection_update_progress(gc, msg, 8, MW_CONNECT_STEPS); |
10977 | 1436 break; |
1437 | |
1438 case mwSession_STARTED: | |
12813
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1439 msg = _("Starting Services"); |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1440 gaim_connection_update_progress(gc, msg, 9, MW_CONNECT_STEPS); |
10977 | 1441 |
1442 session_started(pd); | |
12813
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1443 |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1444 msg = _("Connected"); |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1445 gaim_connection_update_progress(gc, msg, 10, MW_CONNECT_STEPS); |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1446 gaim_connection_set_state(gc, GAIM_CONNECTED); |
10977 | 1447 break; |
1448 | |
1449 case mwSession_STOPPING: | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1450 if(GPOINTER_TO_UINT(info) & ERR_FAILURE) { |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
1451 char *err = mwError(GPOINTER_TO_UINT(info)); |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
1452 gaim_connection_error(gc, err); |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
1453 g_free(err); |
10977 | 1454 } |
1455 break; | |
1456 | |
1457 case mwSession_STOPPED: | |
1458 break; | |
1459 | |
1460 case mwSession_UNKNOWN: | |
1461 default: | |
1462 DEBUG_WARN("session in unknown state\n"); | |
1463 } | |
1464 } | |
1465 | |
1466 | |
1467 static void mw_session_setPrivacyInfo(struct mwSession *session) { | |
1468 struct mwGaimPluginData *pd; | |
1469 GaimConnection *gc; | |
1470 GaimAccount *acct; | |
1471 struct mwPrivacyInfo *privacy; | |
1472 GSList *l, **ll; | |
1473 guint count; | |
1474 | |
1475 DEBUG_INFO("privacy information set from server\n"); | |
1476 | |
1477 g_return_if_fail(session != NULL); | |
1478 | |
1479 pd = mwSession_getClientData(session); | |
1480 g_return_if_fail(pd != NULL); | |
1481 | |
1482 gc = pd->gc; | |
1483 g_return_if_fail(gc != NULL); | |
1484 | |
1485 acct = gaim_connection_get_account(gc); | |
1486 g_return_if_fail(acct != NULL); | |
1487 | |
1488 privacy = mwSession_getPrivacyInfo(session); | |
1489 count = privacy->count; | |
1490 | |
1491 ll = (privacy->deny)? &acct->deny: &acct->permit; | |
1492 for(l = *ll; l; l = l->next) g_free(l->data); | |
1493 g_slist_free(*ll); | |
1494 l = *ll = NULL; | |
1495 | |
1496 while(count--) { | |
1497 struct mwUserItem *u = privacy->users + count; | |
1498 l = g_slist_prepend(l, g_strdup(u->id)); | |
1499 } | |
1500 *ll = l; | |
1501 } | |
1502 | |
1503 | |
1504 static void mw_session_setUserStatus(struct mwSession *session) { | |
1505 struct mwGaimPluginData *pd; | |
1506 GaimConnection *gc; | |
1507 struct mwAwareIdBlock idb = { mwAware_USER, NULL, NULL }; | |
1508 struct mwUserStatus *stat; | |
1509 | |
1510 g_return_if_fail(session != NULL); | |
1511 | |
1512 pd = mwSession_getClientData(session); | |
1513 g_return_if_fail(pd != NULL); | |
1514 | |
1515 gc = pd->gc; | |
1516 g_return_if_fail(gc != NULL); | |
1517 | |
1518 idb.user = mwSession_getProperty(session, mwSession_AUTH_USER_ID); | |
1519 stat = mwSession_getUserStatus(session); | |
1520 | |
1521 /* trigger an update of our own status if we're in the buddy list */ | |
1522 mwServiceAware_setStatus(pd->srvc_aware, &idb, stat); | |
1523 } | |
1524 | |
1525 | |
1526 static void mw_session_admin(struct mwSession *session, | |
1527 const char *text) { | |
12813
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1528 GaimConnection *gc; |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1529 GaimAccount *acct; |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1530 const char *host; |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
1531 const char *msg; |
12813
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1532 char *prim; |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1533 |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1534 gc = session_to_gc(session); |
10977 | 1535 g_return_if_fail(gc != NULL); |
1536 | |
12813
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1537 acct = gaim_connection_get_account(gc); |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1538 g_return_if_fail(acct != NULL); |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1539 |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1540 host = gaim_account_get_string(acct, MW_KEY_HOST, NULL); |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1541 |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
1542 msg = _("A Sametime administrator has issued the following announcement" |
12813
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1543 " on server %s"); |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
1544 prim = g_strdup_printf(msg, NSTR(host)); |
12813
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1545 |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1546 gaim_notify_message(gc, GAIM_NOTIFY_MSG_INFO, |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1547 _("Sametime Administrator Announcement"), |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1548 prim, text, NULL, NULL); |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1549 |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
1550 g_free(prim); |
10977 | 1551 } |
1552 | |
1553 | |
1554 /** called from read_cb, attempts to read available data from sock and | |
1555 pass it to the session, passing back the return code from the read | |
1556 call for handling in read_cb */ | |
1557 static int read_recv(struct mwSession *session, int sock) { | |
12311
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
1558 guchar buf[BUF_LEN]; |
10977 | 1559 int len; |
1560 | |
1561 len = read(sock, buf, BUF_LEN); | |
1562 if(len > 0) mwSession_recv(session, buf, len); | |
1563 | |
1564 return len; | |
1565 } | |
1566 | |
1567 | |
1568 /** callback triggered from gaim_input_add, watches the socked for | |
1569 available data to be processed by the session */ | |
1570 static void read_cb(gpointer data, gint source, | |
1571 GaimInputCondition cond) { | |
1572 | |
1573 struct mwGaimPluginData *pd = data; | |
1574 int ret = 0, err = 0; | |
1575 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1576 /* How the heck can this happen? Fix submitted to Gaim so that it |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1577 won't happen anymore. */ |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1578 if(! cond) return; |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1579 |
10977 | 1580 g_return_if_fail(pd != NULL); |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1581 g_return_if_fail(cond & GAIM_INPUT_READ); |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1582 |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1583 ret = read_recv(pd->session, pd->socket); |
10977 | 1584 |
1585 /* normal operation ends here */ | |
1586 if(ret > 0) return; | |
1587 | |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1588 /* fetch the global error value */ |
10977 | 1589 err = errno; |
1590 | |
1591 /* read problem occured if we're here, so we'll need to take care of | |
1592 it and clean up internal state */ | |
1593 | |
1594 if(pd->socket) { | |
1595 close(pd->socket); | |
1596 pd->socket = 0; | |
1597 } | |
1598 | |
1599 if(pd->gc->inpa) { | |
1600 gaim_input_remove(pd->gc->inpa); | |
1601 pd->gc->inpa = 0; | |
1602 } | |
1603 | |
1604 if(! ret) { | |
1605 DEBUG_INFO("connection reset\n"); | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1606 gaim_connection_error(pd->gc, _("Connection reset")); |
10977 | 1607 |
1608 } else if(ret < 0) { | |
1609 char *msg = strerror(err); | |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1610 |
10977 | 1611 DEBUG_INFO("error in read callback: %s\n", msg); |
1612 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1613 msg = g_strdup_printf(_("Error reading from socket: %s"), msg); |
10977 | 1614 gaim_connection_error(pd->gc, msg); |
1615 g_free(msg); | |
1616 } | |
1617 } | |
1618 | |
1619 | |
1620 /** Callback passed to gaim_proxy_connect when an account is logged | |
1621 in, and if the session logging in receives a redirect message */ | |
1622 static void connect_cb(gpointer data, gint source, | |
1623 GaimInputCondition cond) { | |
1624 | |
1625 struct mwGaimPluginData *pd = data; | |
1626 GaimConnection *gc = pd->gc; | |
1627 | |
1628 if(! g_list_find(gaim_connections_get_all(), pd->gc)) { | |
1629 close(source); | |
1630 g_return_if_reached(); | |
1631 } | |
1632 | |
1633 if(source < 0) { | |
1634 /* connection failed */ | |
1635 | |
1636 if(pd->socket) { | |
1637 /* this is a redirect connect, force login on existing socket */ | |
1638 mwSession_forceLogin(pd->session); | |
1639 | |
1640 } else { | |
1641 /* this is a regular connect, error out */ | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1642 gaim_connection_error(pd->gc, _("Unable to connect to host")); |
10977 | 1643 } |
1644 | |
1645 return; | |
1646 } | |
1647 | |
1648 if(pd->socket) { | |
1649 /* stop any existing login attempt */ | |
1650 mwSession_stop(pd->session, ERR_SUCCESS); | |
1651 } | |
1652 | |
1653 pd->socket = source; | |
1654 gc->inpa = gaim_input_add(source, GAIM_INPUT_READ, read_cb, pd); | |
1655 | |
1656 mwSession_start(pd->session); | |
1657 } | |
1658 | |
1659 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1660 static void mw_session_announce(struct mwSession *s, |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1661 struct mwLoginInfo *from, |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1662 gboolean may_reply, |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1663 const char *text) { |
10977 | 1664 struct mwGaimPluginData *pd; |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1665 GaimAccount *acct; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1666 GaimConversation *conv; |
12126
35c4797c5c57
[gaim-migrate @ 14426]
Richard Laager <rlaager@wiktel.com>
parents:
12107
diff
changeset
|
1667 GaimBuddy *buddy; |
12263
8190a70d2c34
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1668 char *who = from->user_id; |
8190a70d2c34
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1669 char *msg; |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1670 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1671 pd = mwSession_getClientData(s); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1672 acct = gaim_connection_get_account(pd->gc); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1673 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, who, acct); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1674 if(! conv) conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, acct, who); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1675 |
12126
35c4797c5c57
[gaim-migrate @ 14426]
Richard Laager <rlaager@wiktel.com>
parents:
12107
diff
changeset
|
1676 buddy = gaim_find_buddy(acct, who); |
12263
8190a70d2c34
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1677 if(buddy) who = (char *) gaim_buddy_get_contact_alias(buddy); |
8190a70d2c34
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1678 |
8190a70d2c34
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1679 who = g_strdup_printf(_("Announcement from %s"), who); |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1680 msg = gaim_markup_linkify(text); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1681 |
12263
8190a70d2c34
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1682 gaim_conversation_write(conv, who, msg, GAIM_MESSAGE_RECV, time(NULL)); |
8190a70d2c34
[gaim-migrate @ 14565]
Christopher O'Brien <siege@pidgin.im>
parents:
12216
diff
changeset
|
1683 g_free(who); |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1684 g_free(msg); |
10977 | 1685 } |
1686 | |
1687 | |
1688 static struct mwSessionHandler mw_session_handler = { | |
1689 .io_write = mw_session_io_write, | |
1690 .io_close = mw_session_io_close, | |
1691 .clear = mw_session_clear, | |
1692 .on_stateChange = mw_session_stateChange, | |
1693 .on_setPrivacyInfo = mw_session_setPrivacyInfo, | |
1694 .on_setUserStatus = mw_session_setUserStatus, | |
1695 .on_admin = mw_session_admin, | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1696 .on_announce = mw_session_announce, |
10977 | 1697 }; |
1698 | |
1699 | |
1700 static void mw_aware_on_attrib(struct mwServiceAware *srvc, | |
1701 struct mwAwareAttribute *attrib) { | |
1702 | |
1703 ; /** @todo handle server attributes. There may be some stuff we | |
1704 actually want to look for, but I'm not aware of anything right | |
1705 now.*/ | |
1706 } | |
1707 | |
1708 | |
1709 static void mw_aware_clear(struct mwServiceAware *srvc) { | |
1710 ; /* nothing for now */ | |
1711 } | |
1712 | |
1713 | |
1714 static struct mwAwareHandler mw_aware_handler = { | |
1715 .on_attrib = mw_aware_on_attrib, | |
1716 .clear = mw_aware_clear, | |
1717 }; | |
1718 | |
1719 | |
1720 static struct mwServiceAware *mw_srvc_aware_new(struct mwSession *s) { | |
1721 struct mwServiceAware *srvc; | |
1722 srvc = mwServiceAware_new(s, &mw_aware_handler); | |
1723 return srvc; | |
1724 }; | |
1725 | |
1726 | |
1727 static void mw_conf_invited(struct mwConference *conf, | |
1728 struct mwLoginInfo *inviter, | |
1729 const char *invitation) { | |
1730 | |
1731 struct mwServiceConference *srvc; | |
1732 struct mwSession *session; | |
1733 struct mwGaimPluginData *pd; | |
1734 GaimConnection *gc; | |
1735 | |
1736 char *c_inviter, *c_name, *c_topic, *c_invitation; | |
1737 GHashTable *ht; | |
1738 | |
1739 srvc = mwConference_getService(conf); | |
1740 session = mwService_getSession(MW_SERVICE(srvc)); | |
1741 pd = mwSession_getClientData(session); | |
1742 gc = pd->gc; | |
1743 | |
1744 ht = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
1745 | |
1746 c_inviter = g_strdup(inviter->user_id); | |
1747 g_hash_table_insert(ht, CHAT_KEY_CREATOR, c_inviter); | |
1748 | |
1749 c_name = g_strdup(mwConference_getName(conf)); | |
1750 g_hash_table_insert(ht, CHAT_KEY_NAME, c_name); | |
1751 | |
1752 c_topic = g_strdup(mwConference_getTitle(conf)); | |
1753 g_hash_table_insert(ht, CHAT_KEY_TOPIC, c_topic); | |
1754 | |
1755 c_invitation = g_strdup(invitation); | |
1756 g_hash_table_insert(ht, CHAT_KEY_INVITE, c_invitation); | |
1757 | |
1758 DEBUG_INFO("received invitation from '%s' to join ('%s','%s'): '%s'\n", | |
1759 NSTR(c_inviter), NSTR(c_name), | |
1760 NSTR(c_topic), NSTR(c_invitation)); | |
1761 | |
12742
258871a62600
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1762 if(! c_topic) c_topic = "(no title)"; |
258871a62600
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1763 if(! c_invitation) c_invitation = "(no message)"; |
10977 | 1764 serv_got_chat_invite(gc, c_topic, c_inviter, c_invitation, ht); |
1765 } | |
1766 | |
1767 | |
1768 /* The following mess helps us relate a mwConference to a GaimConvChat | |
1769 in the various forms by which either may be indicated */ | |
1770 | |
1771 #define CONF_TO_ID(conf) (GPOINTER_TO_INT(conf)) | |
1772 #define ID_TO_CONF(pd, id) (conf_find_by_id((pd), (id))) | |
1773 | |
1774 #define CHAT_TO_ID(chat) (gaim_conv_chat_get_id(chat)) | |
1775 #define ID_TO_CHAT(id) (gaim_find_chat(id)) | |
1776 | |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1777 #define CHAT_TO_CONF(pd, chat) (ID_TO_CONF((pd), CHAT_TO_ID(chat))) |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
1778 #define CONF_TO_CHAT(conf) (ID_TO_CHAT(CONF_TO_ID(conf))) |
10977 | 1779 |
1780 | |
1781 static struct mwConference * | |
1782 conf_find_by_id(struct mwGaimPluginData *pd, int id) { | |
1783 | |
1784 struct mwServiceConference *srvc = pd->srvc_conf; | |
1785 struct mwConference *conf = NULL; | |
1786 GList *l, *ll; | |
1787 | |
1788 ll = mwServiceConference_getConferences(srvc); | |
1789 for(l = ll; l; l = l->next) { | |
1790 struct mwConference *c = l->data; | |
1791 GaimConvChat *h = mwConference_getClientData(c); | |
1792 | |
1793 if(CHAT_TO_ID(h) == id) { | |
1794 conf = c; | |
1795 break; | |
1796 } | |
1797 } | |
1798 g_list_free(ll); | |
1799 | |
1800 return conf; | |
1801 } | |
1802 | |
1803 | |
1804 static void mw_conf_opened(struct mwConference *conf, GList *members) { | |
1805 struct mwServiceConference *srvc; | |
1806 struct mwSession *session; | |
1807 struct mwGaimPluginData *pd; | |
1808 GaimConnection *gc; | |
1809 GaimConversation *g_conf; | |
1810 | |
1811 const char *n = mwConference_getName(conf); | |
12742
258871a62600
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1812 const char *t = mwConference_getTitle(conf); |
10977 | 1813 |
1814 DEBUG_INFO("conf %s opened, %u initial members\n", | |
1815 NSTR(n), g_list_length(members)); | |
1816 | |
1817 srvc = mwConference_getService(conf); | |
1818 session = mwService_getSession(MW_SERVICE(srvc)); | |
1819 pd = mwSession_getClientData(session); | |
1820 gc = pd->gc; | |
1821 | |
12742
258871a62600
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1822 if(! t) t = "(no title)"; |
258871a62600
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
1823 g_conf = serv_got_joined_chat(gc, CONF_TO_ID(conf), t); |
10977 | 1824 |
1825 mwConference_setClientData(conf, GAIM_CONV_CHAT(g_conf), NULL); | |
1826 | |
1827 for(; members; members = members->next) { | |
1828 struct mwLoginInfo *peer = members->data; | |
1829 gaim_conv_chat_add_user(GAIM_CONV_CHAT(g_conf), peer->user_id, | |
1830 NULL, GAIM_CBFLAGS_NONE, FALSE); | |
1831 } | |
1832 } | |
1833 | |
1834 | |
1835 static void mw_conf_closed(struct mwConference *conf, guint32 reason) { | |
1836 struct mwServiceConference *srvc; | |
1837 struct mwSession *session; | |
1838 struct mwGaimPluginData *pd; | |
1839 GaimConnection *gc; | |
1840 | |
1841 const char *n = mwConference_getName(conf); | |
1842 char *msg = mwError(reason); | |
1843 | |
1844 DEBUG_INFO("conf %s closed, 0x%08x\n", NSTR(n), reason); | |
1845 | |
1846 srvc = mwConference_getService(conf); | |
1847 session = mwService_getSession(MW_SERVICE(srvc)); | |
1848 pd = mwSession_getClientData(session); | |
1849 gc = pd->gc; | |
1850 | |
1851 serv_got_chat_left(gc, CONF_TO_ID(conf)); | |
1852 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
1853 gaim_notify_error(gc, _("Conference Closed"), NULL, msg); |
10977 | 1854 g_free(msg); |
1855 } | |
1856 | |
1857 | |
1858 static void mw_conf_peer_joined(struct mwConference *conf, | |
1859 struct mwLoginInfo *peer) { | |
1860 | |
1861 struct mwServiceConference *srvc; | |
1862 struct mwSession *session; | |
1863 struct mwGaimPluginData *pd; | |
1864 GaimConnection *gc; | |
1865 GaimConvChat *g_conf; | |
1866 | |
1867 const char *n = mwConference_getName(conf); | |
1868 | |
1869 DEBUG_INFO("%s joined conf %s\n", NSTR(peer->user_id), NSTR(n)); | |
1870 | |
1871 srvc = mwConference_getService(conf); | |
1872 session = mwService_getSession(MW_SERVICE(srvc)); | |
1873 pd = mwSession_getClientData(session); | |
1874 gc = pd->gc; | |
1875 | |
1876 g_conf = mwConference_getClientData(conf); | |
1877 g_return_if_fail(g_conf != NULL); | |
1878 | |
1879 gaim_conv_chat_add_user(g_conf, peer->user_id, | |
1880 NULL, GAIM_CBFLAGS_NONE, TRUE); | |
1881 } | |
1882 | |
1883 | |
1884 static void mw_conf_peer_parted(struct mwConference *conf, | |
1885 struct mwLoginInfo *peer) { | |
1886 | |
1887 struct mwServiceConference *srvc; | |
1888 struct mwSession *session; | |
1889 struct mwGaimPluginData *pd; | |
1890 GaimConnection *gc; | |
1891 GaimConvChat *g_conf; | |
1892 | |
1893 const char *n = mwConference_getName(conf); | |
1894 | |
1895 DEBUG_INFO("%s left conf %s\n", NSTR(peer->user_id), NSTR(n)); | |
1896 | |
1897 srvc = mwConference_getService(conf); | |
1898 session = mwService_getSession(MW_SERVICE(srvc)); | |
1899 pd = mwSession_getClientData(session); | |
1900 gc = pd->gc; | |
1901 | |
1902 g_conf = mwConference_getClientData(conf); | |
1903 g_return_if_fail(g_conf != NULL); | |
1904 | |
1905 gaim_conv_chat_remove_user(g_conf, peer->user_id, NULL); | |
1906 } | |
1907 | |
1908 | |
1909 static void mw_conf_text(struct mwConference *conf, | |
1910 struct mwLoginInfo *who, const char *text) { | |
1911 | |
1912 struct mwServiceConference *srvc; | |
1913 struct mwSession *session; | |
1914 struct mwGaimPluginData *pd; | |
1915 GaimConnection *gc; | |
1916 char *esc; | |
1917 | |
12863
7a2169f04bdf
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
1918 if(! text) return; |
7a2169f04bdf
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
1919 |
10977 | 1920 srvc = mwConference_getService(conf); |
1921 session = mwService_getSession(MW_SERVICE(srvc)); | |
1922 pd = mwSession_getClientData(session); | |
1923 gc = pd->gc; | |
1924 | |
12864
2c0f8815aa2e
[gaim-migrate @ 15215]
Christopher O'Brien <siege@pidgin.im>
parents:
12863
diff
changeset
|
1925 esc = g_markup_escape_text(text, -1); |
10977 | 1926 serv_got_chat_in(gc, CONF_TO_ID(conf), who->user_id, 0, esc, time(NULL)); |
1927 g_free(esc); | |
1928 } | |
1929 | |
1930 | |
1931 static void mw_conf_typing(struct mwConference *conf, | |
1932 struct mwLoginInfo *who, gboolean typing) { | |
1933 | |
1934 /* gaim really has no good way to expose this to the user. */ | |
1935 | |
1936 const char *n = mwConference_getName(conf); | |
1937 const char *w = who->user_id; | |
1938 | |
1939 if(typing) { | |
1940 DEBUG_INFO("%s in conf %s: <typing>\n", NSTR(w), NSTR(n)); | |
1941 | |
1942 } else { | |
1943 DEBUG_INFO("%s in conf %s: <stopped typing>\n", NSTR(w), NSTR(n)); | |
1944 } | |
1945 } | |
1946 | |
1947 | |
1948 static void mw_conf_clear(struct mwServiceConference *srvc) { | |
1949 ; | |
1950 } | |
1951 | |
1952 | |
1953 static struct mwConferenceHandler mw_conference_handler = { | |
1954 .on_invited = mw_conf_invited, | |
1955 .conf_opened = mw_conf_opened, | |
1956 .conf_closed = mw_conf_closed, | |
1957 .on_peer_joined = mw_conf_peer_joined, | |
1958 .on_peer_parted = mw_conf_peer_parted, | |
1959 .on_text = mw_conf_text, | |
1960 .on_typing = mw_conf_typing, | |
1961 .clear = mw_conf_clear, | |
1962 }; | |
1963 | |
1964 | |
1965 static struct mwServiceConference *mw_srvc_conf_new(struct mwSession *s) { | |
1966 struct mwServiceConference *srvc; | |
1967 srvc = mwServiceConference_new(s, &mw_conference_handler); | |
1968 return srvc; | |
1969 } | |
1970 | |
1971 | |
1972 static void ft_incoming_cancel(GaimXfer *xfer) { | |
1973 /* incoming transfer rejected or canceled in-progress */ | |
1974 struct mwFileTransfer *ft = xfer->data; | |
1975 if(ft) mwFileTransfer_reject(ft); | |
1976 } | |
1977 | |
1978 | |
1979 static void ft_incoming_init(GaimXfer *xfer) { | |
1980 /* incoming transfer accepted */ | |
1981 | |
1982 /* - accept the mwFileTransfer | |
1983 - open/create the local FILE "wb" | |
1984 - stick the FILE's fp in xfer->dest_fp | |
1985 */ | |
1986 | |
1987 struct mwFileTransfer *ft; | |
1988 FILE *fp; | |
1989 | |
1990 ft = xfer->data; | |
1991 | |
1992 fp = g_fopen(xfer->local_filename, "wb"); | |
1993 if(! fp) { | |
1994 mwFileTransfer_cancel(ft); | |
1995 return; | |
1996 } | |
1997 | |
1998 xfer->dest_fp = fp; | |
1999 mwFileTransfer_accept(ft); | |
2000 } | |
2001 | |
2002 | |
2003 static void mw_ft_offered(struct mwFileTransfer *ft) { | |
2004 /* | |
2005 - create a gaim ft object | |
2006 - offer it | |
2007 */ | |
2008 | |
2009 struct mwServiceFileTransfer *srvc; | |
2010 struct mwSession *session; | |
2011 struct mwGaimPluginData *pd; | |
2012 GaimConnection *gc; | |
2013 GaimAccount *acct; | |
2014 const char *who; | |
2015 GaimXfer *xfer; | |
2016 | |
2017 /* @todo add some safety checks */ | |
2018 srvc = mwFileTransfer_getService(ft); | |
2019 session = mwService_getSession(MW_SERVICE(srvc)); | |
2020 pd = mwSession_getClientData(session); | |
2021 gc = pd->gc; | |
2022 acct = gaim_connection_get_account(gc); | |
2023 | |
2024 who = mwFileTransfer_getUser(ft)->user; | |
2025 | |
2026 DEBUG_INFO("file transfer %p offered\n", ft); | |
2027 DEBUG_INFO(" from: %s\n", NSTR(who)); | |
2028 DEBUG_INFO(" file: %s\n", NSTR(mwFileTransfer_getFileName(ft))); | |
2029 DEBUG_INFO(" size: %u\n", mwFileTransfer_getFileSize(ft)); | |
2030 DEBUG_INFO(" text: %s\n", NSTR(mwFileTransfer_getMessage(ft))); | |
2031 | |
2032 xfer = gaim_xfer_new(acct, GAIM_XFER_RECEIVE, who); | |
2033 | |
2034 gaim_xfer_ref(xfer); | |
2035 mwFileTransfer_setClientData(ft, xfer, (GDestroyNotify) gaim_xfer_unref); | |
2036 xfer->data = ft; | |
2037 | |
2038 gaim_xfer_set_init_fnc(xfer, ft_incoming_init); | |
2039 gaim_xfer_set_cancel_recv_fnc(xfer, ft_incoming_cancel); | |
2040 gaim_xfer_set_request_denied_fnc(xfer, ft_incoming_cancel); | |
2041 | |
2042 gaim_xfer_set_filename(xfer, mwFileTransfer_getFileName(ft)); | |
2043 gaim_xfer_set_size(xfer, mwFileTransfer_getFileSize(ft)); | |
2044 gaim_xfer_set_message(xfer, mwFileTransfer_getMessage(ft)); | |
2045 | |
2046 gaim_xfer_request(xfer); | |
2047 } | |
2048 | |
2049 | |
2050 static void ft_send(struct mwFileTransfer *ft, FILE *fp) { | |
12311
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
2051 guchar buf[BUF_LONG]; |
10977 | 2052 struct mwOpaque o = { .data = buf, .len = BUF_LONG }; |
2053 guint32 rem; | |
2054 GaimXfer *xfer; | |
2055 | |
2056 xfer = mwFileTransfer_getClientData(ft); | |
2057 | |
2058 rem = mwFileTransfer_getRemaining(ft); | |
2059 if(rem < BUF_LONG) o.len = rem; | |
2060 | |
2061 if(fread(buf, (size_t) o.len, 1, fp)) { | |
2062 | |
2063 /* calculate progress first. update is displayed upon ack */ | |
2064 xfer->bytes_sent += o.len; | |
2065 xfer->bytes_remaining -= o.len; | |
2066 | |
2067 /* ... send data second */ | |
2068 mwFileTransfer_send(ft, &o); | |
2069 | |
2070 } else { | |
2071 int err = errno; | |
2072 DEBUG_WARN("problem reading from file %s: %s", | |
2073 NSTR(mwFileTransfer_getFileName(ft)), strerror(err)); | |
2074 | |
2075 mwFileTransfer_cancel(ft); | |
2076 } | |
2077 } | |
2078 | |
2079 | |
2080 static gboolean ft_idle_cb(struct mwFileTransfer *ft) { | |
2081 GaimXfer *xfer = mwFileTransfer_getClientData(ft); | |
2082 g_return_val_if_fail(xfer != NULL, FALSE); | |
2083 | |
2084 xfer->watcher = 0; | |
2085 ft_send(ft, xfer->dest_fp); | |
2086 | |
2087 return FALSE; | |
2088 } | |
2089 | |
2090 | |
2091 static void mw_ft_opened(struct mwFileTransfer *ft) { | |
2092 /* | |
2093 - get gaim ft from client data in ft | |
2094 - set the state to active | |
2095 */ | |
2096 | |
2097 GaimXfer *xfer; | |
2098 | |
2099 xfer = mwFileTransfer_getClientData(ft); | |
2100 | |
2101 if(! xfer) { | |
2102 mwFileTransfer_cancel(ft); | |
2103 mwFileTransfer_free(ft); | |
2104 g_return_if_reached(); | |
2105 } | |
2106 | |
2107 gaim_xfer_update_progress(xfer); | |
2108 | |
2109 if(gaim_xfer_get_type(xfer) == GAIM_XFER_SEND) { | |
2110 xfer->watcher = g_idle_add((GSourceFunc)ft_idle_cb, ft); | |
2111 xfer->dest_fp = g_fopen(xfer->local_filename, "rb"); | |
2112 } | |
2113 } | |
2114 | |
2115 | |
2116 static void mw_ft_closed(struct mwFileTransfer *ft, guint32 code) { | |
2117 /* | |
2118 - get gaim ft from client data in ft | |
2119 - indicate rejection/cancelation/completion | |
2120 - free the file transfer itself | |
2121 */ | |
2122 | |
2123 GaimXfer *xfer; | |
2124 | |
2125 xfer = mwFileTransfer_getClientData(ft); | |
2126 if(xfer) { | |
2127 xfer->data = NULL; | |
2128 | |
2129 if(mwFileTransfer_isDone(ft)) { | |
2130 gaim_xfer_set_completed(xfer, TRUE); | |
2131 gaim_xfer_end(xfer); | |
2132 | |
2133 } else if(mwFileTransfer_isCancelLocal(ft)) { | |
2134 /* calling gaim_xfer_cancel_local is redundant, since that's | |
2135 probably what triggered this function to be called */ | |
2136 ; | |
2137 | |
2138 } else if(mwFileTransfer_isCancelRemote(ft)) { | |
2139 /* steal the reference for the xfer */ | |
2140 mwFileTransfer_setClientData(ft, NULL, NULL); | |
2141 gaim_xfer_cancel_remote(xfer); | |
2142 | |
2143 /* drop the stolen reference */ | |
2144 gaim_xfer_unref(xfer); | |
2145 return; | |
2146 } | |
2147 } | |
2148 | |
2149 mwFileTransfer_free(ft); | |
2150 } | |
2151 | |
2152 | |
2153 static void mw_ft_recv(struct mwFileTransfer *ft, | |
2154 struct mwOpaque *data) { | |
2155 /* | |
2156 - get gaim ft from client data in ft | |
2157 - update transfered percentage | |
2158 - if done, destroy the ft, disassociate from gaim ft | |
2159 */ | |
2160 | |
2161 GaimXfer *xfer; | |
2162 FILE *fp; | |
2163 | |
2164 xfer = mwFileTransfer_getClientData(ft); | |
2165 g_return_if_fail(xfer != NULL); | |
2166 | |
2167 fp = xfer->dest_fp; | |
2168 g_return_if_fail(fp != NULL); | |
2169 | |
2170 /* we must collect and save our precious data */ | |
2171 fwrite(data->data, 1, data->len, fp); | |
2172 | |
2173 /* update the progress */ | |
2174 xfer->bytes_sent += data->len; | |
2175 xfer->bytes_remaining -= data->len; | |
2176 gaim_xfer_update_progress(xfer); | |
2177 | |
2178 /* let the other side know we got it, and to send some more */ | |
2179 mwFileTransfer_ack(ft); | |
2180 } | |
2181 | |
2182 | |
2183 static void mw_ft_ack(struct mwFileTransfer *ft) { | |
2184 GaimXfer *xfer; | |
2185 | |
2186 xfer = mwFileTransfer_getClientData(ft); | |
2187 g_return_if_fail(xfer != NULL); | |
2188 g_return_if_fail(xfer->watcher == 0); | |
2189 | |
2190 gaim_xfer_update_progress(xfer); | |
2191 | |
2192 if(mwFileTransfer_isOpen(ft)) | |
2193 xfer->watcher = g_idle_add((GSourceFunc)ft_idle_cb, ft); | |
2194 } | |
2195 | |
2196 | |
2197 static void mw_ft_clear(struct mwServiceFileTransfer *srvc) { | |
2198 ; | |
2199 } | |
2200 | |
2201 | |
2202 static struct mwFileTransferHandler mw_ft_handler = { | |
2203 .ft_offered = mw_ft_offered, | |
2204 .ft_opened = mw_ft_opened, | |
2205 .ft_closed = mw_ft_closed, | |
2206 .ft_recv = mw_ft_recv, | |
2207 .ft_ack = mw_ft_ack, | |
2208 .clear = mw_ft_clear, | |
2209 }; | |
2210 | |
2211 | |
2212 static struct mwServiceFileTransfer *mw_srvc_ft_new(struct mwSession *s) { | |
2213 struct mwServiceFileTransfer *srvc; | |
2214 GHashTable *ft_map; | |
2215 | |
2216 ft_map = g_hash_table_new(g_direct_hash, g_direct_equal); | |
2217 | |
2218 srvc = mwServiceFileTransfer_new(s, &mw_ft_handler); | |
2219 mwService_setClientData(MW_SERVICE(srvc), ft_map, | |
2220 (GDestroyNotify) g_hash_table_destroy); | |
2221 | |
2222 return srvc; | |
2223 } | |
2224 | |
2225 | |
2226 static void convo_data_free(struct convo_data *cd) { | |
2227 GList *l; | |
2228 | |
2229 /* clean the queue */ | |
2230 for(l = cd->queue; l; l = g_list_delete_link(l, l)) { | |
2231 struct convo_msg *m = l->data; | |
2232 if(m->clear) m->clear(m->data); | |
2233 g_free(m); | |
2234 } | |
2235 | |
2236 g_free(cd); | |
2237 } | |
2238 | |
2239 | |
2240 /** allocates a convo_data structure and associates it with the | |
2241 conversation in the client data slot */ | |
2242 static void convo_data_new(struct mwConversation *conv) { | |
2243 struct convo_data *cd; | |
2244 | |
2245 g_return_if_fail(conv != NULL); | |
2246 | |
2247 if(mwConversation_getClientData(conv)) | |
2248 return; | |
2249 | |
2250 cd = g_new0(struct convo_data, 1); | |
2251 cd->conv = conv; | |
2252 | |
2253 mwConversation_setClientData(conv, cd, (GDestroyNotify) convo_data_free); | |
2254 } | |
2255 | |
2256 | |
2257 static GaimConversation *convo_get_gconv(struct mwConversation *conv) { | |
2258 struct mwServiceIm *srvc; | |
2259 struct mwSession *session; | |
2260 struct mwGaimPluginData *pd; | |
2261 GaimConnection *gc; | |
2262 GaimAccount *acct; | |
2263 | |
2264 struct mwIdBlock *idb; | |
2265 | |
2266 srvc = mwConversation_getService(conv); | |
2267 session = mwService_getSession(MW_SERVICE(srvc)); | |
2268 pd = mwSession_getClientData(session); | |
2269 gc = pd->gc; | |
2270 acct = gaim_connection_get_account(gc); | |
2271 | |
2272 idb = mwConversation_getTarget(conv); | |
2273 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2274 return gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2275 idb->user, acct); |
10977 | 2276 } |
2277 | |
2278 | |
2279 static void convo_queue(struct mwConversation *conv, | |
2280 enum mwImSendType type, gconstpointer data) { | |
2281 | |
2282 struct convo_data *cd; | |
2283 struct convo_msg *m; | |
2284 | |
2285 convo_data_new(conv); | |
2286 cd = mwConversation_getClientData(conv); | |
2287 | |
2288 m = g_new0(struct convo_msg, 1); | |
2289 m->type = type; | |
2290 | |
2291 switch(type) { | |
2292 case mwImSend_PLAIN: | |
2293 m->data = g_strdup(data); | |
2294 m->clear = g_free; | |
2295 break; | |
2296 | |
2297 case mwImSend_TYPING: | |
2298 default: | |
2299 m->data = (gpointer) data; | |
2300 m->clear = NULL; | |
2301 } | |
2302 | |
2303 cd->queue = g_list_append(cd->queue, m); | |
2304 } | |
2305 | |
2306 | |
2307 /* Does what it takes to get an error displayed for a conversation */ | |
2308 static void convo_error(struct mwConversation *conv, guint32 err) { | |
2309 GaimConversation *gconv; | |
2310 char *tmp, *text; | |
2311 struct mwIdBlock *idb; | |
2312 | |
2313 idb = mwConversation_getTarget(conv); | |
2314 | |
2315 tmp = mwError(err); | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2316 text = g_strconcat(_("Unable to send message: "), tmp, NULL); |
10977 | 2317 |
2318 gconv = convo_get_gconv(conv); | |
2319 if(gconv && !gaim_conv_present_error(idb->user, gconv->account, text)) { | |
2320 | |
2321 g_free(text); | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2322 text = g_strdup_printf(_("Unable to send message to %s:"), |
10977 | 2323 (idb->user)? idb->user: "(unknown)"); |
2324 gaim_notify_error(gaim_account_get_connection(gconv->account), | |
2325 NULL, text, tmp); | |
2326 } | |
2327 | |
2328 g_free(tmp); | |
2329 g_free(text); | |
2330 } | |
2331 | |
2332 | |
2333 static void convo_queue_send(struct mwConversation *conv) { | |
2334 struct convo_data *cd; | |
2335 GList *l; | |
2336 | |
2337 cd = mwConversation_getClientData(conv); | |
2338 | |
2339 for(l = cd->queue; l; l = g_list_delete_link(l, l)) { | |
2340 struct convo_msg *m = l->data; | |
2341 | |
2342 mwConversation_send(conv, m->type, m->data); | |
2343 | |
2344 if(m->clear) m->clear(m->data); | |
2345 g_free(m); | |
2346 } | |
2347 | |
2348 cd->queue = NULL; | |
2349 } | |
2350 | |
2351 | |
2352 /** called when a mw conversation leaves a gaim conversation to | |
2353 inform the gaim conversation that it's unsafe to offer any *cool* | |
2354 features. */ | |
2355 static void convo_nofeatures(struct mwConversation *conv) { | |
2356 GaimConversation *gconv; | |
2357 GaimConnection *gc; | |
2358 | |
2359 gconv = convo_get_gconv(conv); | |
2360 if(! gconv) return; | |
2361 | |
2362 gc = gaim_conversation_get_gc(gconv); | |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2363 if(! gc) return; |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2364 |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2365 gaim_conversation_set_features(gconv, gc->flags); |
10977 | 2366 } |
2367 | |
2368 | |
2369 /** called when a mw conversation and gaim conversation come together, | |
2370 to inform the gaim conversation of what features to offer the | |
2371 user */ | |
2372 static void convo_features(struct mwConversation *conv) { | |
2373 GaimConversation *gconv; | |
2374 GaimConnectionFlags feat; | |
2375 | |
2376 gconv = convo_get_gconv(conv); | |
2377 if(! gconv) return; | |
2378 | |
2379 feat = gaim_conversation_get_features(gconv); | |
2380 | |
2381 if(mwConversation_isOpen(conv)) { | |
2382 if(mwConversation_supports(conv, mwImSend_HTML)) { | |
2383 feat |= GAIM_CONNECTION_HTML; | |
2384 } else { | |
2385 feat &= ~GAIM_CONNECTION_HTML; | |
2386 } | |
2387 | |
2388 if(mwConversation_supports(conv, mwImSend_MIME)) { | |
2389 feat &= ~GAIM_CONNECTION_NO_IMAGES; | |
2390 } else { | |
2391 feat |= GAIM_CONNECTION_NO_IMAGES; | |
2392 } | |
2393 | |
2394 DEBUG_INFO("conversation features set to 0x%04x\n", feat); | |
2395 gaim_conversation_set_features(gconv, feat); | |
2396 | |
2397 } else { | |
2398 convo_nofeatures(conv); | |
2399 } | |
2400 } | |
2401 | |
2402 | |
2403 static void mw_conversation_opened(struct mwConversation *conv) { | |
2404 struct mwServiceIm *srvc; | |
2405 struct mwSession *session; | |
2406 struct mwGaimPluginData *pd; | |
2407 GaimConnection *gc; | |
2408 GaimAccount *acct; | |
2409 | |
2410 struct convo_dat *cd; | |
2411 | |
2412 srvc = mwConversation_getService(conv); | |
2413 session = mwService_getSession(MW_SERVICE(srvc)); | |
2414 pd = mwSession_getClientData(session); | |
2415 gc = pd->gc; | |
2416 acct = gaim_connection_get_account(gc); | |
2417 | |
2418 /* set up the queue */ | |
2419 cd = mwConversation_getClientData(conv); | |
2420 if(cd) { | |
2421 convo_queue_send(conv); | |
2422 | |
2423 if(! convo_get_gconv(conv)) { | |
2424 mwConversation_free(conv); | |
2425 return; | |
2426 } | |
2427 | |
2428 } else { | |
2429 convo_data_new(conv); | |
2430 } | |
2431 | |
2432 { /* record the client key for the buddy */ | |
2433 GaimBuddy *buddy; | |
2434 struct mwLoginInfo *info; | |
2435 info = mwConversation_getTargetInfo(conv); | |
2436 | |
2437 buddy = gaim_find_buddy(acct, info->user_id); | |
2438 if(buddy) { | |
2439 gaim_blist_node_set_int((GaimBlistNode *) buddy, | |
2440 BUDDY_KEY_CLIENT, info->type); | |
2441 } | |
2442 } | |
2443 | |
2444 convo_features(conv); | |
2445 } | |
2446 | |
2447 | |
2448 static void mw_conversation_closed(struct mwConversation *conv, | |
2449 guint32 reason) { | |
2450 | |
2451 struct convo_data *cd; | |
2452 | |
2453 g_return_if_fail(conv != NULL); | |
2454 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2455 /* if there's an error code and a non-typing message in the queue, |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2456 print an error message to the conversation */ |
10977 | 2457 cd = mwConversation_getClientData(conv); |
2458 if(reason && cd && cd->queue) { | |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2459 GList *l; |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2460 for(l = cd->queue; l; l = l->next) { |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2461 struct convo_msg *m = l->data; |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2462 if(m->type != mwImSend_TYPING) { |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2463 convo_error(conv, reason); |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2464 break; |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2465 } |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2466 } |
10977 | 2467 } |
2468 | |
2469 #if 0 | |
2470 /* don't do this, to prevent the occasional weird sending of | |
2471 formatted messages as plaintext when the other end closes the | |
2472 conversation after we've begun composing the message */ | |
2473 convo_nofeatures(conv); | |
2474 #endif | |
2475 | |
2476 mwConversation_removeClientData(conv); | |
2477 } | |
2478 | |
2479 | |
2480 static void im_recv_text(struct mwConversation *conv, | |
2481 struct mwGaimPluginData *pd, | |
2482 const char *msg) { | |
2483 | |
2484 struct mwIdBlock *idb; | |
12524
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2485 char *txt, *esc; |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2486 const char *t; |
10977 | 2487 |
2488 idb = mwConversation_getTarget(conv); | |
12524
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2489 |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2490 txt = gaim_utf8_try_convert(msg); |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2491 t = txt? txt: msg; |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2492 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2493 esc = g_markup_escape_text(t, -1); |
10977 | 2494 serv_got_im(pd->gc, idb->user, esc, 0, time(NULL)); |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2495 g_free(esc); |
10977 | 2496 |
2497 g_free(txt); | |
2498 } | |
2499 | |
2500 | |
2501 static void im_recv_typing(struct mwConversation *conv, | |
2502 struct mwGaimPluginData *pd, | |
2503 gboolean typing) { | |
2504 | |
2505 struct mwIdBlock *idb; | |
2506 idb = mwConversation_getTarget(conv); | |
2507 | |
2508 serv_got_typing(pd->gc, idb->user, 0, | |
2509 typing? GAIM_TYPING: GAIM_NOT_TYPING); | |
2510 } | |
2511 | |
2512 | |
2513 static void im_recv_html(struct mwConversation *conv, | |
2514 struct mwGaimPluginData *pd, | |
2515 const char *msg) { | |
2516 struct mwIdBlock *idb; | |
12524
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2517 char *t1, *t2; |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2518 const char *t; |
10977 | 2519 |
2520 idb = mwConversation_getTarget(conv); | |
12524
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2521 |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2522 /* ensure we're receiving UTF8 */ |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2523 t1 = gaim_utf8_try_convert(msg); |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2524 t = t1? t1: msg; |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2525 |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2526 /* convert entities to UTF8 so they'll log correctly */ |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2527 t2 = gaim_utf8_ncr_decode(t); |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2528 t = t2? t2: t; |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2529 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2530 serv_got_im(pd->gc, idb->user, t, 0, time(NULL)); |
10977 | 2531 |
12524
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2532 g_free(t1); |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2533 g_free(t2); |
10977 | 2534 } |
2535 | |
2536 | |
2537 static void im_recv_subj(struct mwConversation *conv, | |
2538 struct mwGaimPluginData *pd, | |
2539 const char *subj) { | |
2540 | |
2541 /** @todo somehow indicate receipt of a conversation subject. It | |
2542 would also be nice if we added a /topic command for the | |
2543 protocol */ | |
2544 ; | |
2545 } | |
2546 | |
2547 | |
2548 /** generate "cid:908@20582notesbuddy" from "<908@20582notesbuddy>" */ | |
2549 static char *make_cid(const char *cid) { | |
2550 gsize n; | |
2551 char *c, *d; | |
2552 | |
2553 g_return_val_if_fail(cid != NULL, NULL); | |
2554 | |
2555 n = strlen(cid); | |
2556 g_return_val_if_fail(n > 2, NULL); | |
2557 | |
2558 c = g_strndup(cid+1, n-2); | |
2559 d = g_strdup_printf("cid:%s", c); | |
2560 | |
2561 g_free(c); | |
2562 return d; | |
2563 } | |
2564 | |
2565 | |
2566 static void im_recv_mime(struct mwConversation *conv, | |
2567 struct mwGaimPluginData *pd, | |
2568 const char *data) { | |
2569 | |
2570 struct mwIdBlock *idb; | |
2571 | |
2572 GHashTable *img_by_cid; | |
2573 GList *images; | |
2574 | |
2575 GString *str; | |
2576 | |
2577 GaimMimeDocument *doc; | |
2578 const GList *parts; | |
2579 | |
2580 idb = mwConversation_getTarget(conv); | |
2581 | |
2582 img_by_cid = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); | |
2583 images = NULL; | |
2584 | |
2585 /* don't want the contained string to ever be NULL */ | |
2586 str = g_string_new(""); | |
2587 | |
2588 doc = gaim_mime_document_parse(data); | |
2589 | |
2590 /* handle all the MIME parts */ | |
2591 parts = gaim_mime_document_get_parts(doc); | |
2592 for(; parts; parts = parts->next) { | |
2593 GaimMimePart *part = parts->data; | |
2594 const char *type; | |
2595 | |
2596 type = gaim_mime_part_get_field(part, "content-type"); | |
2597 DEBUG_INFO("MIME part Content-Type: %s\n", NSTR(type)); | |
2598 | |
2599 if(! type) { | |
2600 ; /* feh */ | |
2601 | |
12166 | 2602 } else if(gaim_str_has_prefix(type, "image")) { |
10977 | 2603 /* put images into the image store */ |
2604 | |
11183 | 2605 guchar *d_dat; |
10977 | 2606 gsize d_len; |
2607 char *cid; | |
2608 int img; | |
2609 | |
2610 /* obtain and unencode the data */ | |
2611 gaim_mime_part_get_data_decoded(part, &d_dat, &d_len); | |
2612 | |
2613 /* look up the content id */ | |
2614 cid = (char *) gaim_mime_part_get_field(part, "Content-ID"); | |
2615 cid = make_cid(cid); | |
2616 | |
2617 /* add image to the gaim image store */ | |
2618 img = gaim_imgstore_add(d_dat, d_len, cid); | |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2619 g_free(d_dat); |
10977 | 2620 |
2621 /* map the cid to the image store identifier */ | |
2622 g_hash_table_insert(img_by_cid, cid, GINT_TO_POINTER(img)); | |
2623 | |
2624 /* recall the image for dereferencing later */ | |
2625 images = g_list_append(images, GINT_TO_POINTER(img)); | |
2626 | |
12166 | 2627 } else if(gaim_str_has_prefix(type, "text")) { |
10977 | 2628 |
2629 /* concatenate all the text parts together */ | |
11183 | 2630 guchar *data; |
10977 | 2631 gsize len; |
2632 | |
2633 gaim_mime_part_get_data_decoded(part, &data, &len); | |
12524
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2634 g_string_append(str, (const char *)data); |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
2635 g_free(data); |
10977 | 2636 } |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2637 } |
10977 | 2638 |
2639 gaim_mime_document_free(doc); | |
2640 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2641 /* @todo should put this in its own function */ |
10977 | 2642 { /* replace each IMG tag's SRC attribute with an ID attribute. This |
2643 actually modifies the contents of str */ | |
2644 GData *attribs; | |
2645 char *start, *end; | |
2646 char *tmp = str->str; | |
2647 | |
2648 while(*tmp && gaim_markup_find_tag("img", tmp, (const char **) &start, | |
2649 (const char **) &end, &attribs)) { | |
2650 | |
2651 char *alt, *align, *border, *src; | |
2652 int img; | |
2653 | |
2654 alt = g_datalist_get_data(&attribs, "alt"); | |
2655 align = g_datalist_get_data(&attribs, "align"); | |
2656 border = g_datalist_get_data(&attribs, "border"); | |
2657 src = g_datalist_get_data(&attribs, "src"); | |
2658 | |
2659 img = GPOINTER_TO_INT(g_hash_table_lookup(img_by_cid, src)); | |
2660 if(img) { | |
2661 GString *atstr; | |
2662 gsize len = (end - start); | |
2663 gsize mov; | |
2664 | |
2665 atstr = g_string_new(""); | |
2666 if(alt) g_string_append_printf(atstr, " alt=\"%s\"", alt); | |
2667 if(align) g_string_append_printf(atstr, " align=\"%s\"", align); | |
2668 if(border) g_string_append_printf(atstr, " border=\"%s\"", border); | |
2669 | |
2670 mov = g_snprintf(start, len, "<img%s id=\"%i\"", atstr->str, img); | |
2671 while(mov < len) start[mov++] = ' '; | |
2672 | |
2673 g_string_free(atstr, TRUE); | |
2674 } | |
2675 | |
2676 g_datalist_clear(&attribs); | |
2677 tmp = end + 1; | |
2678 } | |
2679 } | |
2680 | |
12524
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
2681 im_recv_html(conv, pd, str->str); |
10977 | 2682 |
2683 g_string_free(str, TRUE); | |
2684 | |
2685 /* clean up the cid table */ | |
2686 g_hash_table_destroy(img_by_cid); | |
2687 | |
2688 /* dereference all the imgages */ | |
2689 while(images) { | |
2690 gaim_imgstore_unref(GPOINTER_TO_INT(images->data)); | |
2691 images = g_list_delete_link(images, images); | |
2692 } | |
2693 } | |
2694 | |
2695 | |
2696 static void mw_conversation_recv(struct mwConversation *conv, | |
2697 enum mwImSendType type, | |
2698 gconstpointer msg) { | |
2699 struct mwServiceIm *srvc; | |
2700 struct mwSession *session; | |
2701 struct mwGaimPluginData *pd; | |
2702 | |
2703 srvc = mwConversation_getService(conv); | |
2704 session = mwService_getSession(MW_SERVICE(srvc)); | |
2705 pd = mwSession_getClientData(session); | |
2706 | |
2707 switch(type) { | |
2708 case mwImSend_PLAIN: | |
2709 im_recv_text(conv, pd, msg); | |
2710 break; | |
2711 | |
2712 case mwImSend_TYPING: | |
2713 im_recv_typing(conv, pd, !! msg); | |
2714 break; | |
2715 | |
2716 case mwImSend_HTML: | |
2717 im_recv_html(conv, pd, msg); | |
2718 break; | |
2719 | |
2720 case mwImSend_SUBJECT: | |
2721 im_recv_subj(conv, pd, msg); | |
2722 break; | |
2723 | |
2724 case mwImSend_MIME: | |
2725 im_recv_mime(conv, pd, msg); | |
2726 break; | |
2727 | |
2728 default: | |
2729 DEBUG_INFO("conversation received strange type, 0x%04x\n", type); | |
2730 ; /* erm... */ | |
2731 } | |
2732 } | |
2733 | |
2734 | |
2735 static void mw_place_invite(struct mwConversation *conv, | |
2736 const char *message, | |
2737 const char *title, const char *name) { | |
2738 struct mwServiceIm *srvc; | |
2739 struct mwSession *session; | |
2740 struct mwGaimPluginData *pd; | |
2741 | |
2742 struct mwIdBlock *idb; | |
2743 GHashTable *ht; | |
2744 | |
2745 srvc = mwConversation_getService(conv); | |
2746 session = mwService_getSession(MW_SERVICE(srvc)); | |
2747 pd = mwSession_getClientData(session); | |
2748 | |
2749 idb = mwConversation_getTarget(conv); | |
2750 | |
2751 ht = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
2752 g_hash_table_insert(ht, CHAT_KEY_CREATOR, g_strdup(idb->user)); | |
2753 g_hash_table_insert(ht, CHAT_KEY_NAME, g_strdup(name)); | |
2754 g_hash_table_insert(ht, CHAT_KEY_TOPIC, g_strdup(title)); | |
2755 g_hash_table_insert(ht, CHAT_KEY_INVITE, g_strdup(message)); | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2756 g_hash_table_insert(ht, CHAT_KEY_IS_PLACE, g_strdup("")); /* ugh */ |
10977 | 2757 |
12742
258871a62600
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2758 if(! title) title = "(no title)"; |
258871a62600
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2759 if(! message) message = "(no message)"; |
10977 | 2760 serv_got_chat_invite(pd->gc, title, idb->user, message, ht); |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2761 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2762 mwConversation_close(conv, ERR_SUCCESS); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2763 mwConversation_free(conv); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2764 } |
10977 | 2765 |
2766 | |
2767 static void mw_im_clear(struct mwServiceIm *srvc) { | |
2768 ; | |
2769 } | |
2770 | |
2771 | |
2772 static struct mwImHandler mw_im_handler = { | |
2773 .conversation_opened = mw_conversation_opened, | |
2774 .conversation_closed = mw_conversation_closed, | |
2775 .conversation_recv = mw_conversation_recv, | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2776 .place_invite = mw_place_invite, |
10977 | 2777 .clear = mw_im_clear, |
2778 }; | |
2779 | |
2780 | |
2781 static struct mwServiceIm *mw_srvc_im_new(struct mwSession *s) { | |
2782 struct mwServiceIm *srvc; | |
2783 srvc = mwServiceIm_new(s, &mw_im_handler); | |
2784 mwServiceIm_setClientType(srvc, mwImClient_NOTESBUDDY); | |
2785 return srvc; | |
2786 } | |
2787 | |
2788 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2789 /* The following helps us relate a mwPlace to a GaimConvChat in the |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2790 various forms by which either may be indicated. Uses some of |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2791 the similar macros from the conference service above */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2792 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2793 #define PLACE_TO_ID(place) (GPOINTER_TO_INT(place)) |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2794 #define ID_TO_PLACE(pd, id) (place_find_by_id((pd), (id))) |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2795 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2796 #define CHAT_TO_PLACE(pd, chat) (ID_TO_PLACE((pd), CHAT_TO_ID(chat))) |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2797 #define PLACE_TO_CHAT(place) (ID_TO_CHAT(PLACE_TO_ID(place))) |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2798 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2799 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2800 static struct mwPlace * |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2801 place_find_by_id(struct mwGaimPluginData *pd, int id) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2802 struct mwServicePlace *srvc = pd->srvc_place; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2803 struct mwPlace *place = NULL; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2804 GList *l; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2805 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2806 l = (GList *) mwServicePlace_getPlaces(srvc); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2807 for(; l; l = l->next) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2808 struct mwPlace *p = l->data; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2809 GaimConvChat *h = GAIM_CONV_CHAT(mwPlace_getClientData(p)); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2810 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2811 if(CHAT_TO_ID(h) == id) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2812 place = p; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2813 break; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2814 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2815 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2816 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2817 return place; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2818 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2819 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2820 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2821 static void mw_place_opened(struct mwPlace *place) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2822 struct mwServicePlace *srvc; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2823 struct mwSession *session; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2824 struct mwGaimPluginData *pd; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2825 GaimConnection *gc; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2826 GaimConversation *gconf; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2827 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2828 GList *members, *l; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2829 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2830 const char *n = mwPlace_getName(place); |
12742
258871a62600
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2831 const char *t = mwPlace_getTitle(place); |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2832 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2833 srvc = mwPlace_getService(place); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2834 session = mwService_getSession(MW_SERVICE(srvc)); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2835 pd = mwSession_getClientData(session); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2836 gc = pd->gc; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2837 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2838 members = mwPlace_getMembers(place); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2839 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2840 DEBUG_INFO("place %s opened, %u initial members\n", |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2841 NSTR(n), g_list_length(members)); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2842 |
12742
258871a62600
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2843 if(! t) t = "(no title)"; |
258871a62600
[gaim-migrate @ 15089]
Christopher O'Brien <siege@pidgin.im>
parents:
12735
diff
changeset
|
2844 gconf = serv_got_joined_chat(gc, PLACE_TO_ID(place), t); |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2845 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2846 mwPlace_setClientData(place, gconf, NULL); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2847 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2848 for(l = members; l; l = l->next) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2849 struct mwIdBlock *idb = l->data; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2850 gaim_conv_chat_add_user(GAIM_CONV_CHAT(gconf), idb->user, |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2851 NULL, GAIM_CBFLAGS_NONE, FALSE); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2852 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2853 g_list_free(members); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2854 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2855 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2856 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2857 static void mw_place_closed(struct mwPlace *place, guint32 code) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2858 struct mwServicePlace *srvc; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2859 struct mwSession *session; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2860 struct mwGaimPluginData *pd; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2861 GaimConnection *gc; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2862 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2863 const char *n = mwPlace_getName(place); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2864 char *msg = mwError(code); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2865 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2866 DEBUG_INFO("place %s closed, 0x%08x\n", NSTR(n), code); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2867 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2868 srvc = mwPlace_getService(place); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2869 session = mwService_getSession(MW_SERVICE(srvc)); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2870 pd = mwSession_getClientData(session); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2871 gc = pd->gc; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2872 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2873 serv_got_chat_left(gc, PLACE_TO_ID(place)); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2874 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2875 gaim_notify_error(gc, _("Place Closed"), NULL, msg); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2876 g_free(msg); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2877 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2878 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2879 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2880 static void mw_place_peerJoined(struct mwPlace *place, |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2881 const struct mwIdBlock *peer) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2882 struct mwServicePlace *srvc; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2883 struct mwSession *session; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2884 struct mwGaimPluginData *pd; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2885 GaimConnection *gc; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2886 GaimConversation *gconf; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2887 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2888 const char *n = mwPlace_getName(place); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2889 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2890 DEBUG_INFO("%s joined place %s\n", NSTR(peer->user), NSTR(n)); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2891 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2892 srvc = mwPlace_getService(place); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2893 session = mwService_getSession(MW_SERVICE(srvc)); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2894 pd = mwSession_getClientData(session); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2895 gc = pd->gc; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2896 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2897 gconf = mwPlace_getClientData(place); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2898 g_return_if_fail(gconf != NULL); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2899 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2900 gaim_conv_chat_add_user(GAIM_CONV_CHAT(gconf), peer->user, |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2901 NULL, GAIM_CBFLAGS_NONE, TRUE); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2902 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2903 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2904 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2905 static void mw_place_peerParted(struct mwPlace *place, |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2906 const struct mwIdBlock *peer) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2907 struct mwServicePlace *srvc; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2908 struct mwSession *session; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2909 struct mwGaimPluginData *pd; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2910 GaimConnection *gc; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2911 GaimConversation *gconf; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2912 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2913 const char *n = mwPlace_getName(place); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2914 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2915 DEBUG_INFO("%s left place %s\n", NSTR(peer->user), NSTR(n)); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2916 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2917 srvc = mwPlace_getService(place); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2918 session = mwService_getSession(MW_SERVICE(srvc)); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2919 pd = mwSession_getClientData(session); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2920 gc = pd->gc; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2921 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2922 gconf = mwPlace_getClientData(place); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2923 g_return_if_fail(gconf != NULL); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2924 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2925 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(gconf), peer->user, NULL); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2926 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2927 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2928 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2929 static void mw_place_peerSetAttribute(struct mwPlace *place, |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2930 const struct mwIdBlock *peer, |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2931 guint32 attr, struct mwOpaque *o) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2932 ; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2933 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2934 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2935 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2936 static void mw_place_peerUnsetAttribute(struct mwPlace *place, |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2937 const struct mwIdBlock *peer, |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2938 guint32 attr) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2939 ; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2940 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2941 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2942 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2943 static void mw_place_message(struct mwPlace *place, |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2944 const struct mwIdBlock *who, |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2945 const char *msg) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2946 struct mwServicePlace *srvc; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2947 struct mwSession *session; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2948 struct mwGaimPluginData *pd; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2949 GaimConnection *gc; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2950 char *esc; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2951 |
12863
7a2169f04bdf
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
2952 if(! msg) return; |
7a2169f04bdf
[gaim-migrate @ 15214]
Christopher O'Brien <siege@pidgin.im>
parents:
12830
diff
changeset
|
2953 |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2954 srvc = mwPlace_getService(place); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2955 session = mwService_getSession(MW_SERVICE(srvc)); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2956 pd = mwSession_getClientData(session); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2957 gc = pd->gc; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2958 |
12864
2c0f8815aa2e
[gaim-migrate @ 15215]
Christopher O'Brien <siege@pidgin.im>
parents:
12863
diff
changeset
|
2959 esc = g_markup_escape_text(msg, -1); |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2960 serv_got_chat_in(gc, PLACE_TO_ID(place), who->user, 0, esc, time(NULL)); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2961 g_free(esc); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2962 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2963 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2964 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2965 static void mw_place_clear(struct mwServicePlace *srvc) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2966 ; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2967 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2968 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2969 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2970 static struct mwPlaceHandler mw_place_handler = { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2971 .opened = mw_place_opened, |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2972 .closed = mw_place_closed, |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2973 .peerJoined = mw_place_peerJoined, |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2974 .peerParted = mw_place_peerParted, |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2975 .peerSetAttribute = mw_place_peerSetAttribute, |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2976 .peerUnsetAttribute = mw_place_peerUnsetAttribute, |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2977 .message = mw_place_message, |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2978 .clear = mw_place_clear, |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2979 }; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2980 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2981 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2982 static struct mwServicePlace *mw_srvc_place_new(struct mwSession *s) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2983 struct mwServicePlace *srvc; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2984 srvc = mwServicePlace_new(s, &mw_place_handler); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2985 return srvc; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2986 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2987 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
2988 |
10977 | 2989 static struct mwServiceResolve *mw_srvc_resolve_new(struct mwSession *s) { |
2990 struct mwServiceResolve *srvc; | |
2991 srvc = mwServiceResolve_new(s); | |
2992 return srvc; | |
2993 } | |
2994 | |
2995 | |
2996 static struct mwServiceStorage *mw_srvc_store_new(struct mwSession *s) { | |
2997 struct mwServiceStorage *srvc; | |
2998 srvc = mwServiceStorage_new(s); | |
2999 return srvc; | |
3000 } | |
3001 | |
3002 | |
3003 /** allocate and associate a mwGaimPluginData with a GaimConnection */ | |
3004 static struct mwGaimPluginData *mwGaimPluginData_new(GaimConnection *gc) { | |
3005 struct mwGaimPluginData *pd; | |
3006 | |
3007 g_return_val_if_fail(gc != NULL, NULL); | |
3008 | |
3009 pd = g_new0(struct mwGaimPluginData, 1); | |
3010 pd->gc = gc; | |
3011 pd->session = mwSession_new(&mw_session_handler); | |
3012 pd->srvc_aware = mw_srvc_aware_new(pd->session); | |
3013 pd->srvc_conf = mw_srvc_conf_new(pd->session); | |
3014 pd->srvc_ft = mw_srvc_ft_new(pd->session); | |
3015 pd->srvc_im = mw_srvc_im_new(pd->session); | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3016 pd->srvc_place = mw_srvc_place_new(pd->session); |
10977 | 3017 pd->srvc_resolve = mw_srvc_resolve_new(pd->session); |
3018 pd->srvc_store = mw_srvc_store_new(pd->session); | |
3019 pd->group_list_map = g_hash_table_new(g_direct_hash, g_direct_equal); | |
3020 | |
3021 mwSession_addService(pd->session, MW_SERVICE(pd->srvc_aware)); | |
3022 mwSession_addService(pd->session, MW_SERVICE(pd->srvc_conf)); | |
3023 mwSession_addService(pd->session, MW_SERVICE(pd->srvc_ft)); | |
3024 mwSession_addService(pd->session, MW_SERVICE(pd->srvc_im)); | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3025 mwSession_addService(pd->session, MW_SERVICE(pd->srvc_place)); |
10977 | 3026 mwSession_addService(pd->session, MW_SERVICE(pd->srvc_resolve)); |
3027 mwSession_addService(pd->session, MW_SERVICE(pd->srvc_store)); | |
3028 | |
3029 mwSession_addCipher(pd->session, mwCipher_new_RC2_40(pd->session)); | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3030 mwSession_addCipher(pd->session, mwCipher_new_RC2_128(pd->session)); |
10977 | 3031 |
3032 mwSession_setClientData(pd->session, pd, NULL); | |
3033 gc->proto_data = pd; | |
3034 | |
3035 return pd; | |
3036 } | |
3037 | |
3038 | |
3039 static void mwGaimPluginData_free(struct mwGaimPluginData *pd) { | |
3040 g_return_if_fail(pd != NULL); | |
3041 | |
3042 pd->gc->proto_data = NULL; | |
3043 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3044 mwSession_removeService(pd->session, mwService_AWARE); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3045 mwSession_removeService(pd->session, mwService_CONFERENCE); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3046 mwSession_removeService(pd->session, mwService_FILE_TRANSFER); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3047 mwSession_removeService(pd->session, mwService_IM); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3048 mwSession_removeService(pd->session, mwService_PLACE); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3049 mwSession_removeService(pd->session, mwService_RESOLVE); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3050 mwSession_removeService(pd->session, mwService_STORAGE); |
10977 | 3051 |
3052 mwService_free(MW_SERVICE(pd->srvc_aware)); | |
3053 mwService_free(MW_SERVICE(pd->srvc_conf)); | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3054 mwService_free(MW_SERVICE(pd->srvc_ft)); |
10977 | 3055 mwService_free(MW_SERVICE(pd->srvc_im)); |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3056 mwService_free(MW_SERVICE(pd->srvc_place)); |
10977 | 3057 mwService_free(MW_SERVICE(pd->srvc_resolve)); |
3058 mwService_free(MW_SERVICE(pd->srvc_store)); | |
3059 | |
3060 mwCipher_free(mwSession_getCipher(pd->session, mwCipher_RC2_40)); | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3061 mwCipher_free(mwSession_getCipher(pd->session, mwCipher_RC2_128)); |
10977 | 3062 |
3063 mwSession_free(pd->session); | |
3064 | |
3065 g_hash_table_destroy(pd->group_list_map); | |
3066 | |
3067 g_free(pd); | |
3068 } | |
3069 | |
3070 | |
3071 static const char *mw_prpl_list_icon(GaimAccount *a, GaimBuddy *b) { | |
3072 /* my little green dude is a chopped up version of the aim running | |
3073 guy. First, cut off the head and store someplace safe. Then, | |
3074 take the left-half side of the body and throw it away. Make a | |
3075 copy of the remaining body, and flip it horizontally. Now attach | |
3076 the two pieces into an X shape, and drop the head back on the | |
3077 top, being careful to center it. Then, just change the color | |
3078 saturation to bring the red down a bit, and voila! */ | |
3079 | |
3080 /* then, throw all of that away and use sodipodi to make a new | |
3081 icon. You know, LIKE A REAL MAN. */ | |
3082 | |
3083 return "meanwhile"; | |
3084 } | |
3085 | |
3086 | |
3087 static void mw_prpl_list_emblems(GaimBuddy *b, | |
3088 const char **se, const char **sw, | |
3089 const char **nw, const char **ne) { | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3090 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3091 /* speaking of custom icons, the external icon here is an ugly |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3092 little example of what happens when I use Gimp */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3093 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3094 GaimPresence *presence; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3095 GaimStatus *status; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3096 const char *status_id; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3097 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3098 presence = gaim_buddy_get_presence(b); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3099 status = gaim_presence_get_active_status(presence); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3100 status_id = gaim_status_get_id(status); |
10977 | 3101 |
3102 if(! GAIM_BUDDY_IS_ONLINE(b)) { | |
3103 *se = "offline"; | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3104 } else if(!strcmp(status_id, MW_STATE_AWAY)) { |
10977 | 3105 *se = "away"; |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3106 } else if(!strcmp(status_id, MW_STATE_BUSY)) { |
10977 | 3107 *se = "dnd"; |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3108 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3109 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3110 if(buddy_is_external(b)) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3111 /* best assignment ever */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3112 *(*se?sw:se) = "external"; |
10977 | 3113 } |
3114 } | |
3115 | |
3116 | |
3117 static char *mw_prpl_status_text(GaimBuddy *b) { | |
3118 GaimConnection *gc; | |
3119 struct mwGaimPluginData *pd; | |
3120 struct mwAwareIdBlock t = { mwAware_USER, b->name, NULL }; | |
3121 const char *ret; | |
3122 | |
3123 gc = b->account->gc; | |
3124 pd = gc->proto_data; | |
3125 | |
3126 ret = mwServiceAware_getText(pd->srvc_aware, &t); | |
12496
f9d0ab1474ac
[gaim-migrate @ 14808]
Christopher O'Brien <siege@pidgin.im>
parents:
12489
diff
changeset
|
3127 return ret? g_markup_escape_text(ret, -1): NULL; |
10977 | 3128 } |
3129 | |
3130 | |
3131 static const char *status_text(GaimBuddy *b) { | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3132 GaimPresence *presence; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3133 GaimStatus *status; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3134 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3135 presence = gaim_buddy_get_presence(b); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3136 status = gaim_presence_get_active_status(presence); |
11536 | 3137 |
3138 return gaim_status_get_name(status); | |
10977 | 3139 } |
3140 | |
3141 | |
3142 static gboolean user_supports(struct mwServiceAware *srvc, | |
3143 const char *who, guint32 feature) { | |
3144 | |
3145 const struct mwAwareAttribute *attr; | |
3146 struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; | |
3147 | |
3148 attr = mwServiceAware_getAttribute(srvc, &idb, feature); | |
3149 return (attr != NULL) && mwAwareAttribute_asBoolean(attr); | |
3150 } | |
3151 | |
3152 | |
12422
fe42d9c111f9
[gaim-migrate @ 14729]
Richard Laager <rlaager@wiktel.com>
parents:
12312
diff
changeset
|
3153 static char *user_supports_text(struct mwServiceAware *srvc, const char *who) { |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
3154 const char *feat[] = {NULL, NULL, NULL, NULL, NULL}; |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
3155 const char **f = feat; |
12524
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3156 |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3157 if(user_supports(srvc, who, mwAttribute_AV_PREFS_SET)) { |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3158 gboolean mic, speak, video; |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3159 |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3160 mic = user_supports(srvc, who, mwAttribute_MICROPHONE); |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3161 speak = user_supports(srvc, who, mwAttribute_SPEAKERS); |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3162 video = user_supports(srvc, who, mwAttribute_VIDEO_CAMERA); |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3163 |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3164 if(mic) *f++ = _("Microphone"); |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3165 if(speak) *f++ = _("Speakers"); |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3166 if(video) *f++ = _("Video Camera"); |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3167 } |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3168 |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3169 if(user_supports(srvc, who, mwAttribute_FILE_TRANSFER)) |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3170 *f++ = _("File Transfer"); |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3171 |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
3172 return (*feat)? g_strjoinv(", ", (char **)feat): NULL; |
12524
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3173 /* jenni loves siege */ |
10977 | 3174 } |
3175 | |
3176 | |
12970
ec9b92104904
[gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents:
12954
diff
changeset
|
3177 static void mw_prpl_tooltip_text(GaimBuddy *b, GString *str, gboolean full) { |
10977 | 3178 GaimConnection *gc; |
3179 struct mwGaimPluginData *pd; | |
3180 struct mwAwareIdBlock idb = { mwAware_USER, b->name, NULL }; | |
3181 | |
12953
397dc3344563
[gaim-migrate @ 15306]
Richard Laager <rlaager@wiktel.com>
parents:
12952
diff
changeset
|
3182 const char *message; |
397dc3344563
[gaim-migrate @ 15306]
Richard Laager <rlaager@wiktel.com>
parents:
12952
diff
changeset
|
3183 const char *status; |
12954
aba96d7cee74
[gaim-migrate @ 15307]
Richard Laager <rlaager@wiktel.com>
parents:
12953
diff
changeset
|
3184 char *tmp; |
10977 | 3185 |
3186 gc = b->account->gc; | |
3187 pd = gc->proto_data; | |
3188 | |
12953
397dc3344563
[gaim-migrate @ 15306]
Richard Laager <rlaager@wiktel.com>
parents:
12952
diff
changeset
|
3189 message = mwServiceAware_getText(pd->srvc_aware, &idb); |
397dc3344563
[gaim-migrate @ 15306]
Richard Laager <rlaager@wiktel.com>
parents:
12952
diff
changeset
|
3190 status = status_text(b); |
397dc3344563
[gaim-migrate @ 15306]
Richard Laager <rlaager@wiktel.com>
parents:
12952
diff
changeset
|
3191 |
397dc3344563
[gaim-migrate @ 15306]
Richard Laager <rlaager@wiktel.com>
parents:
12952
diff
changeset
|
3192 if(message != NULL && gaim_utf8_strcasecmp(status, message)) { |
397dc3344563
[gaim-migrate @ 15306]
Richard Laager <rlaager@wiktel.com>
parents:
12952
diff
changeset
|
3193 tmp = g_markup_escape_text(message, -1); |
12954
aba96d7cee74
[gaim-migrate @ 15307]
Richard Laager <rlaager@wiktel.com>
parents:
12953
diff
changeset
|
3194 g_string_append_printf(str, _("\n<b>%s:</b> %s"), status, tmp); |
12953
397dc3344563
[gaim-migrate @ 15306]
Richard Laager <rlaager@wiktel.com>
parents:
12952
diff
changeset
|
3195 g_free(tmp); |
12954
aba96d7cee74
[gaim-migrate @ 15307]
Richard Laager <rlaager@wiktel.com>
parents:
12953
diff
changeset
|
3196 |
aba96d7cee74
[gaim-migrate @ 15307]
Richard Laager <rlaager@wiktel.com>
parents:
12953
diff
changeset
|
3197 } else { |
aba96d7cee74
[gaim-migrate @ 15307]
Richard Laager <rlaager@wiktel.com>
parents:
12953
diff
changeset
|
3198 g_string_append_printf(str, _("\n<b>Status:</b> %s"), status); |
10977 | 3199 } |
3200 | |
12950
96cf4e176ff8
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3201 if(full) { |
96cf4e176ff8
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3202 tmp = user_supports_text(pd->srvc_aware, b->name); |
96cf4e176ff8
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3203 if(tmp) { |
12953
397dc3344563
[gaim-migrate @ 15306]
Richard Laager <rlaager@wiktel.com>
parents:
12952
diff
changeset
|
3204 g_string_append_printf(str, _("\n<b>Supports:</b> %s"), tmp); |
397dc3344563
[gaim-migrate @ 15306]
Richard Laager <rlaager@wiktel.com>
parents:
12952
diff
changeset
|
3205 g_free(tmp); |
12950
96cf4e176ff8
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3206 } |
96cf4e176ff8
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3207 |
96cf4e176ff8
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3208 if(buddy_is_external(b)) { |
96cf4e176ff8
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3209 g_string_append(str, _("\n<b>External User</b>")); |
96cf4e176ff8
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3210 } |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3211 } |
10977 | 3212 } |
3213 | |
3214 | |
3215 static GList *mw_prpl_status_types(GaimAccount *acct) { | |
3216 GList *types = NULL; | |
3217 GaimStatusType *type; | |
3218 | |
3219 type = gaim_status_type_new(GAIM_STATUS_AVAILABLE, MW_STATE_ACTIVE, | |
12950
96cf4e176ff8
[gaim-migrate @ 15303]
Christopher O'Brien <siege@pidgin.im>
parents:
12943
diff
changeset
|
3220 NULL, TRUE); |
10977 | 3221 gaim_status_type_add_attr(type, MW_STATE_MESSAGE, _("Message"), |
3222 gaim_value_new(GAIM_TYPE_STRING)); | |
3223 types = g_list_append(types, type); | |
3224 | |
3225 type = gaim_status_type_new(GAIM_STATUS_AWAY, MW_STATE_AWAY, | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12524
diff
changeset
|
3226 NULL, TRUE); |
10977 | 3227 gaim_status_type_add_attr(type, MW_STATE_MESSAGE, _("Message"), |
3228 gaim_value_new(GAIM_TYPE_STRING)); | |
3229 types = g_list_append(types, type); | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3230 |
10977 | 3231 type = gaim_status_type_new(GAIM_STATUS_UNAVAILABLE, MW_STATE_BUSY, |
3232 _("Do Not Disturb"), TRUE); | |
3233 gaim_status_type_add_attr(type, MW_STATE_MESSAGE, _("Message"), | |
3234 gaim_value_new(GAIM_TYPE_STRING)); | |
3235 types = g_list_append(types, type); | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3236 |
12658 | 3237 type = gaim_status_type_new(GAIM_STATUS_OFFLINE, MW_STATE_OFFLINE, |
3238 NULL, TRUE); | |
3239 types = g_list_append(types, type); | |
3240 | |
10977 | 3241 return types; |
3242 } | |
3243 | |
3244 | |
3245 static void conf_create_prompt_cancel(GaimBuddy *buddy, | |
3246 GaimRequestFields *fields) { | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3247 ; /* nothing to do */ |
10977 | 3248 } |
3249 | |
3250 | |
3251 static void conf_create_prompt_join(GaimBuddy *buddy, | |
3252 GaimRequestFields *fields) { | |
3253 GaimAccount *acct; | |
3254 GaimConnection *gc; | |
3255 struct mwGaimPluginData *pd; | |
3256 struct mwServiceConference *srvc; | |
3257 | |
3258 GaimRequestField *f; | |
3259 | |
3260 const char *topic, *invite; | |
3261 struct mwConference *conf; | |
3262 struct mwIdBlock idb = { NULL, NULL }; | |
3263 | |
3264 acct = buddy->account; | |
3265 gc = gaim_account_get_connection(acct); | |
3266 pd = gc->proto_data; | |
3267 srvc = pd->srvc_conf; | |
3268 | |
3269 f = gaim_request_fields_get_field(fields, CHAT_KEY_TOPIC); | |
3270 topic = gaim_request_field_string_get_value(f); | |
3271 | |
3272 f = gaim_request_fields_get_field(fields, CHAT_KEY_INVITE); | |
3273 invite = gaim_request_field_string_get_value(f); | |
3274 | |
3275 conf = mwConference_new(srvc, topic); | |
3276 mwConference_open(conf); | |
3277 | |
3278 idb.user = buddy->name; | |
3279 mwConference_invite(conf, &idb, invite); | |
3280 } | |
3281 | |
3282 | |
3283 static void blist_menu_conf_create(GaimBuddy *buddy, const char *msg) { | |
3284 | |
3285 GaimRequestFields *fields; | |
3286 GaimRequestFieldGroup *g; | |
3287 GaimRequestField *f; | |
3288 | |
3289 GaimAccount *acct; | |
3290 GaimConnection *gc; | |
3291 | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
3292 const char *msgA; |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
3293 const char *msgB; |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
3294 char *msg1; |
10977 | 3295 |
3296 g_return_if_fail(buddy != NULL); | |
3297 | |
3298 acct = buddy->account; | |
3299 g_return_if_fail(acct != NULL); | |
3300 | |
3301 gc = gaim_account_get_connection(acct); | |
3302 g_return_if_fail(gc != NULL); | |
3303 | |
3304 fields = gaim_request_fields_new(); | |
3305 | |
3306 g = gaim_request_field_group_new(NULL); | |
3307 gaim_request_fields_add_group(fields, g); | |
3308 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3309 f = gaim_request_field_string_new(CHAT_KEY_TOPIC, _("Topic"), NULL, FALSE); |
10977 | 3310 gaim_request_field_group_add_field(g, f); |
3311 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3312 f = gaim_request_field_string_new(CHAT_KEY_INVITE, _("Message"), msg, FALSE); |
10977 | 3313 gaim_request_field_group_add_field(g, f); |
3314 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3315 msgA = _("Create conference with user"); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3316 msgB = _("Please enter a topic for the new conference, and an invitation" |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3317 " message to be sent to %s"); |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
3318 msg1 = g_strdup_printf(msgB, buddy->name); |
10977 | 3319 |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3320 gaim_request_fields(gc, _("New Conference"), |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
3321 msgA, msg1, fields, |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3322 _("Create"), G_CALLBACK(conf_create_prompt_join), |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3323 _("Cancel"), G_CALLBACK(conf_create_prompt_cancel), |
10977 | 3324 buddy); |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
3325 g_free(msg1); |
10977 | 3326 } |
3327 | |
3328 | |
3329 static void conf_select_prompt_cancel(GaimBuddy *buddy, | |
3330 GaimRequestFields *fields) { | |
3331 ; | |
3332 } | |
3333 | |
3334 | |
3335 static void conf_select_prompt_invite(GaimBuddy *buddy, | |
3336 GaimRequestFields *fields) { | |
3337 GaimRequestField *f; | |
3338 const GList *l; | |
3339 const char *msg; | |
3340 | |
3341 f = gaim_request_fields_get_field(fields, CHAT_KEY_INVITE); | |
3342 msg = gaim_request_field_string_get_value(f); | |
3343 | |
3344 f = gaim_request_fields_get_field(fields, "conf"); | |
3345 l = gaim_request_field_list_get_selected(f); | |
3346 | |
3347 if(l) { | |
3348 gpointer d = gaim_request_field_list_get_data(f, l->data); | |
3349 | |
3350 if(GPOINTER_TO_INT(d) == 0x01) { | |
3351 blist_menu_conf_create(buddy, msg); | |
3352 | |
3353 } else { | |
3354 struct mwIdBlock idb = { buddy->name, NULL }; | |
3355 mwConference_invite(d, &idb, msg); | |
3356 } | |
3357 } | |
3358 } | |
3359 | |
3360 | |
3361 static void blist_menu_conf_list(GaimBuddy *buddy, | |
3362 GList *confs) { | |
3363 | |
3364 GaimRequestFields *fields; | |
3365 GaimRequestFieldGroup *g; | |
3366 GaimRequestField *f; | |
3367 | |
3368 GaimAccount *acct; | |
3369 GaimConnection *gc; | |
3370 | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
3371 const char *msgA; |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
3372 const char *msgB; |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
3373 char *msg; |
10977 | 3374 |
3375 acct = buddy->account; | |
3376 g_return_if_fail(acct != NULL); | |
3377 | |
3378 gc = gaim_account_get_connection(acct); | |
3379 g_return_if_fail(gc != NULL); | |
3380 | |
3381 fields = gaim_request_fields_new(); | |
3382 | |
3383 g = gaim_request_field_group_new(NULL); | |
3384 gaim_request_fields_add_group(fields, g); | |
3385 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3386 f = gaim_request_field_list_new("conf", _("Available Conferences")); |
10977 | 3387 gaim_request_field_list_set_multi_select(f, FALSE); |
3388 for(; confs; confs = confs->next) { | |
3389 struct mwConference *c = confs->data; | |
3390 gaim_request_field_list_add(f, mwConference_getTitle(c), c); | |
3391 } | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3392 gaim_request_field_list_add(f, _("Create New Conference..."), |
10977 | 3393 GINT_TO_POINTER(0x01)); |
3394 gaim_request_field_group_add_field(g, f); | |
3395 | |
3396 f = gaim_request_field_string_new(CHAT_KEY_INVITE, "Message", NULL, FALSE); | |
3397 gaim_request_field_group_add_field(g, f); | |
3398 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3399 msgA = _("Invite user to a conference"); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3400 msgB = _("Select a conference from the list below to send an invite to" |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3401 " user %s. Select \"Create New Conference\" if you'd like to" |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3402 " create a new conference to invite this user to."); |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
3403 msg = g_strdup_printf(msgB, buddy->name); |
10977 | 3404 |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3405 gaim_request_fields(gc, _("Invite to Conference"), |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
3406 msgA, msg, fields, |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3407 _("Invite"), G_CALLBACK(conf_select_prompt_invite), |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3408 _("Cancel"), G_CALLBACK(conf_select_prompt_cancel), |
10977 | 3409 buddy); |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
3410 g_free(msg); |
10977 | 3411 } |
3412 | |
3413 | |
3414 static void blist_menu_conf(GaimBlistNode *node, gpointer data) { | |
3415 GaimBuddy *buddy = (GaimBuddy *) node; | |
3416 GaimAccount *acct; | |
3417 GaimConnection *gc; | |
3418 struct mwGaimPluginData *pd; | |
3419 GList *l; | |
3420 | |
3421 g_return_if_fail(node != NULL); | |
3422 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); | |
3423 | |
3424 acct = buddy->account; | |
3425 g_return_if_fail(acct != NULL); | |
3426 | |
3427 gc = gaim_account_get_connection(acct); | |
3428 g_return_if_fail(gc != NULL); | |
3429 | |
3430 pd = gc->proto_data; | |
3431 g_return_if_fail(pd != NULL); | |
3432 | |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3433 /* |
10977 | 3434 - get a list of all conferences on this session |
3435 - if none, prompt to create one, and invite buddy to it | |
3436 - else, prompt to select a conference or create one | |
3437 */ | |
3438 | |
3439 l = mwServiceConference_getConferences(pd->srvc_conf); | |
3440 if(l) { | |
3441 blist_menu_conf_list(buddy, l); | |
3442 g_list_free(l); | |
3443 | |
3444 } else { | |
3445 blist_menu_conf_create(buddy, NULL); | |
3446 } | |
3447 } | |
3448 | |
3449 | |
3450 static GList *mw_prpl_blist_node_menu(GaimBlistNode *node) { | |
3451 GList *l = NULL; | |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12864
diff
changeset
|
3452 GaimMenuAction *act; |
10977 | 3453 |
3454 if(! GAIM_BLIST_NODE_IS_BUDDY(node)) | |
3455 return l; | |
3456 | |
3457 l = g_list_append(l, NULL); | |
3458 | |
12919
248b8b39c671
[gaim-migrate @ 15272]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12864
diff
changeset
|
3459 act = gaim_menu_action_new(_("Invite to Conference..."), |
12923
f50a99d5ba9b
[gaim-migrate @ 15276]
Christopher O'Brien <siege@pidgin.im>
parents:
12921
diff
changeset
|
3460 GAIM_CALLBACK(blist_menu_conf), NULL, NULL); |
10977 | 3461 l = g_list_append(l, act); |
3462 | |
3463 /** note: this never gets called for a GaimGroup, have to use the | |
3464 blist-node-extended-menu signal for that. The function | |
3465 blist_node_menu_cb is assigned to this signal in the function | |
3466 services_starting */ | |
3467 | |
3468 return l; | |
3469 } | |
3470 | |
3471 | |
3472 static GList *mw_prpl_chat_info(GaimConnection *gc) { | |
3473 GList *l = NULL; | |
3474 struct proto_chat_entry *pce; | |
3475 | |
3476 pce = g_new0(struct proto_chat_entry, 1); | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3477 pce->label = _("Topic:"); |
10977 | 3478 pce->identifier = CHAT_KEY_TOPIC; |
3479 l = g_list_append(l, pce); | |
3480 | |
3481 return l; | |
3482 } | |
3483 | |
3484 | |
3485 static GHashTable *mw_prpl_chat_info_defaults(GaimConnection *gc, | |
3486 const char *name) { | |
3487 GHashTable *table; | |
3488 | |
3489 g_return_val_if_fail(gc != NULL, NULL); | |
3490 | |
3491 table = g_hash_table_new_full(g_str_hash, g_str_equal, | |
3492 NULL, g_free); | |
3493 | |
3494 g_hash_table_insert(table, CHAT_KEY_NAME, g_strdup(name)); | |
3495 g_hash_table_insert(table, CHAT_KEY_INVITE, NULL); | |
3496 | |
3497 return table; | |
3498 } | |
3499 | |
3500 | |
11837 | 3501 static void mw_prpl_login(GaimAccount *acct); |
10977 | 3502 |
3503 | |
3504 static void prompt_host_cancel_cb(GaimConnection *gc) { | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3505 gaim_connection_error(gc, _("No Sametime Community Server specified")); |
10977 | 3506 } |
3507 | |
3508 | |
3509 static void prompt_host_ok_cb(GaimConnection *gc, const char *host) { | |
3510 if(host && *host) { | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3511 GaimAccount *acct = gaim_connection_get_account(gc); |
10977 | 3512 gaim_account_set_string(acct, MW_KEY_HOST, host); |
11837 | 3513 mw_prpl_login(acct); |
10977 | 3514 |
3515 } else { | |
3516 prompt_host_cancel_cb(gc); | |
3517 } | |
3518 } | |
3519 | |
3520 | |
3521 static void prompt_host(GaimConnection *gc) { | |
3522 GaimAccount *acct; | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
3523 const char *msgA; |
10977 | 3524 char *msg; |
3525 | |
3526 acct = gaim_connection_get_account(gc); | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
3527 msgA = _("No host or IP address has been configured for the" |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3528 " Meanwhile account %s. Please enter one below to" |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3529 " continue logging in."); |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
3530 msg = g_strdup_printf(msgA, NSTR(gaim_account_get_username(acct))); |
10977 | 3531 |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3532 gaim_request_input(gc, _("Meanwhile Connection Setup"), |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3533 _("No Sametime Community Server Specified"), msg, |
10977 | 3534 MW_PLUGIN_DEFAULT_HOST, FALSE, FALSE, NULL, |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3535 _("Connect"), G_CALLBACK(prompt_host_ok_cb), |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3536 _("Cancel"), G_CALLBACK(prompt_host_cancel_cb), |
10977 | 3537 gc); |
3538 | |
3539 g_free(msg); | |
3540 } | |
3541 | |
3542 | |
11837 | 3543 static void mw_prpl_login(GaimAccount *account) { |
10977 | 3544 GaimConnection *gc; |
3545 struct mwGaimPluginData *pd; | |
3546 | |
3547 char *user, *pass, *host; | |
12311
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3548 guint port, client; |
10977 | 3549 |
3550 gc = gaim_account_get_connection(account); | |
3551 pd = mwGaimPluginData_new(gc); | |
3552 | |
3553 /* while we do support images, the default is to not offer it */ | |
3554 gc->flags |= GAIM_CONNECTION_NO_IMAGES; | |
3555 | |
3556 user = g_strdup(gaim_account_get_username(account)); | |
12524
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3557 pass = g_strdup(gaim_account_get_password(account)); |
10977 | 3558 |
3559 host = strrchr(user, ':'); | |
3560 if(host) { | |
3561 /* annoying user split from 1.2.0, need to undo it */ | |
3562 *host++ = '\0'; | |
3563 gaim_account_set_string(account, MW_KEY_HOST, host); | |
3564 gaim_account_set_username(account, user); | |
3565 | |
3566 } else { | |
3567 host = (char *) gaim_account_get_string(account, MW_KEY_HOST, | |
3568 MW_PLUGIN_DEFAULT_HOST); | |
3569 } | |
3570 | |
3571 if(! host || ! *host) { | |
3572 /* somehow, we don't have a host to connect to. Well, we need one | |
3573 to actually continue, so let's ask the user directly. */ | |
3574 prompt_host(gc); | |
3575 return; | |
3576 } | |
3577 | |
3578 port = gaim_account_get_int(account, MW_KEY_PORT, MW_PLUGIN_DEFAULT_PORT); | |
3579 | |
3580 DEBUG_INFO("user: '%s'\n", user); | |
3581 DEBUG_INFO("host: '%s'\n", host); | |
3582 DEBUG_INFO("port: %u\n", port); | |
3583 | |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3584 mwSession_setProperty(pd->session, mwSession_NO_SECRET, |
10977 | 3585 (char *) no_secret, NULL); |
3586 mwSession_setProperty(pd->session, mwSession_AUTH_USER_ID, user, g_free); | |
12524
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3587 mwSession_setProperty(pd->session, mwSession_AUTH_PASSWORD, pass, g_free); |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3588 |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3589 client = mwLogin_MEANWHILE; |
12311
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3590 if(gaim_account_get_bool(account, MW_KEY_FAKE_IT, FALSE)) |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3591 client = mwLogin_BINARY; |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3592 |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3593 DEBUG_INFO("client id: 0x%04x\n", client); |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3594 |
10977 | 3595 mwSession_setProperty(pd->session, mwSession_CLIENT_TYPE_ID, |
12311
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3596 GUINT_TO_POINTER(client), NULL); |
10977 | 3597 |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3598 gaim_connection_update_progress(gc, _("Connecting"), 1, MW_CONNECT_STEPS); |
10977 | 3599 |
3600 if(gaim_proxy_connect(account, host, port, connect_cb, pd)) { | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3601 gaim_connection_error(gc, _("Unable to connect to host")); |
10977 | 3602 } |
3603 } | |
3604 | |
3605 | |
3606 static void mw_prpl_close(GaimConnection *gc) { | |
3607 struct mwGaimPluginData *pd; | |
3608 | |
3609 g_return_if_fail(gc != NULL); | |
3610 | |
3611 pd = gc->proto_data; | |
3612 g_return_if_fail(pd != NULL); | |
3613 | |
3614 /* get rid of the blist save timeout */ | |
3615 if(pd->save_event) { | |
3616 gaim_timeout_remove(pd->save_event); | |
3617 pd->save_event = 0; | |
3618 blist_store(pd); | |
3619 } | |
3620 | |
3621 /* stop the session */ | |
3622 mwSession_stop(pd->session, 0x00); | |
3623 | |
3624 /* no longer necessary */ | |
3625 gc->proto_data = NULL; | |
3626 | |
3627 /* stop watching the socket */ | |
3628 if(gc->inpa) { | |
3629 gaim_input_remove(gc->inpa); | |
3630 gc->inpa = 0; | |
3631 } | |
3632 | |
3633 /* clean up the rest */ | |
3634 mwGaimPluginData_free(pd); | |
3635 } | |
3636 | |
3637 | |
12735
da9fd490cef9
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3638 static int mw_rand() { |
da9fd490cef9
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3639 static int seed = 0; |
da9fd490cef9
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3640 |
da9fd490cef9
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3641 /* for diversity, not security. don't touch */ |
da9fd490cef9
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3642 srand(time(NULL) ^ seed); |
da9fd490cef9
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3643 seed = rand(); |
da9fd490cef9
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3644 |
da9fd490cef9
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3645 return seed; |
da9fd490cef9
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3646 } |
da9fd490cef9
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3647 |
da9fd490cef9
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3648 |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3649 /** generates a random-ish content id string */ |
10977 | 3650 static char *im_mime_content_id() { |
12524
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3651 return g_strdup_printf("%03x@%05xmeanwhile", |
12735
da9fd490cef9
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3652 mw_rand() & 0xfff, mw_rand() & 0xfffff); |
10977 | 3653 } |
3654 | |
3655 | |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3656 /** generates a multipart/related content type with a random-ish |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3657 boundary value */ |
10977 | 3658 static char *im_mime_content_type() { |
12422
fe42d9c111f9
[gaim-migrate @ 14729]
Richard Laager <rlaager@wiktel.com>
parents:
12312
diff
changeset
|
3659 return g_strdup_printf("multipart/related; boundary=related_MW%03x_%04x", |
12735
da9fd490cef9
[gaim-migrate @ 15080]
Christopher O'Brien <siege@pidgin.im>
parents:
12658
diff
changeset
|
3660 mw_rand() & 0xfff, mw_rand() & 0xffff); |
10977 | 3661 } |
3662 | |
3663 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3664 /** determine content type from extension. Not so happy about this, |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3665 but I don't want to actually write image type detection */ |
12105
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3666 static char *im_mime_img_content_type(GaimStoredImage *img) { |
10977 | 3667 const char *fn = gaim_imgstore_get_filename(img); |
12105
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3668 const char *ct = NULL; |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3669 |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3670 ct = strrchr(fn, '.'); |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3671 if(! ct) { |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3672 ct = "image"; |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3673 |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3674 } else if(! strcmp(".png", ct)) { |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3675 ct = "image/png"; |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3676 |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3677 } else if(! strcmp(".jpg", ct)) { |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3678 ct = "image/jpeg"; |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3679 |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3680 } else if(! strcmp(".jpeg", ct)) { |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3681 ct = "image/jpeg"; |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3682 |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3683 } else if(! strcmp(".gif", ct)) { |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3684 ct = "image/gif"; |
10977 | 3685 |
3686 } else { | |
12105
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3687 ct = "image"; |
10977 | 3688 } |
12105
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3689 |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3690 return g_strdup_printf("%s; name=\"%s\"", ct, fn); |
10977 | 3691 } |
3692 | |
3693 | |
3694 static char *im_mime_img_content_disp(GaimStoredImage *img) { | |
3695 const char *fn = gaim_imgstore_get_filename(img); | |
3696 return g_strdup_printf("attachment; filename=\"%s\"", fn); | |
3697 } | |
3698 | |
3699 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3700 /** turn an IM with embedded images into a multi-part mime document */ |
12105
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3701 static char *im_mime_convert(GaimConnection *gc, |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3702 struct mwConversation *conv, |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3703 const char *message) { |
10977 | 3704 GString *str; |
3705 GaimMimeDocument *doc; | |
3706 GaimMimePart *part; | |
3707 | |
3708 GData *attr; | |
3709 char *tmp, *start, *end; | |
3710 | |
3711 str = g_string_new(NULL); | |
3712 | |
3713 doc = gaim_mime_document_new(); | |
3714 | |
3715 gaim_mime_document_set_field(doc, "Mime-Version", "1.0"); | |
3716 gaim_mime_document_set_field(doc, "Content-Disposition", "inline"); | |
3717 | |
3718 tmp = im_mime_content_type(); | |
3719 gaim_mime_document_set_field(doc, "Content-Type", tmp); | |
3720 g_free(tmp); | |
3721 | |
3722 tmp = (char *) message; | |
3723 while(*tmp && gaim_markup_find_tag("img", tmp, (const char **) &start, | |
3724 (const char **) &end, &attr)) { | |
3725 char *id; | |
3726 GaimStoredImage *img = NULL; | |
3727 | |
3728 gsize len = (start - tmp); | |
3729 | |
3730 /* append the in-between-tags text */ | |
3731 if(len) g_string_append_len(str, tmp, len); | |
3732 | |
3733 /* find the imgstore data by the id tag */ | |
3734 id = g_datalist_get_data(&attr, "id"); | |
3735 if(id && *id) | |
3736 img = gaim_imgstore_get(atoi(id)); | |
3737 | |
3738 if(img) { | |
3739 char *cid; | |
3740 gpointer data; | |
3741 size_t size; | |
3742 | |
3743 part = gaim_mime_part_new(doc); | |
3744 | |
3745 data = im_mime_img_content_disp(img); | |
3746 gaim_mime_part_set_field(part, "Content-Disposition", data); | |
3747 g_free(data); | |
3748 | |
12105
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3749 data = im_mime_img_content_type(img); |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3750 gaim_mime_part_set_field(part, "Content-Type", data); |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3751 g_free(data); |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3752 |
10977 | 3753 cid = im_mime_content_id(); |
3754 data = g_strdup_printf("<%s>", cid); | |
3755 gaim_mime_part_set_field(part, "Content-ID", data); | |
3756 g_free(data); | |
3757 | |
3758 gaim_mime_part_set_field(part, "Content-transfer-encoding", "base64"); | |
3759 | |
3760 /* obtain and base64 encode the image data, and put it in the | |
3761 mime part */ | |
3762 data = gaim_imgstore_get_data(img); | |
3763 size = gaim_imgstore_get_size(img); | |
3764 data = gaim_base64_encode(data, (gsize) size); | |
3765 gaim_mime_part_set_data(part, data); | |
3766 g_free(data); | |
3767 | |
3768 /* append the modified tag */ | |
3769 g_string_append_printf(str, "<img src=\"cid:%s\">", cid); | |
3770 g_free(cid); | |
3771 | |
3772 } else { | |
3773 /* append the literal image tag, since we couldn't find a | |
3774 relative imgstore object */ | |
3775 gsize len = (end - start) + 1; | |
3776 g_string_append_len(str, start, len); | |
3777 } | |
3778 | |
3779 g_datalist_clear(&attr); | |
3780 tmp = end + 1; | |
3781 } | |
3782 | |
3783 /* append left-overs */ | |
3784 g_string_append(str, tmp); | |
3785 | |
12105
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3786 /* add the text/html part */ |
10977 | 3787 part = gaim_mime_part_new(doc); |
3788 gaim_mime_part_set_field(part, "Content-Disposition", "inline"); | |
12105
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3789 |
12813
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3790 tmp = gaim_utf8_ncr_encode(str->str); |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3791 gaim_mime_part_set_field(part, "Content-Type", "text/html"); |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3792 gaim_mime_part_set_field(part, "Content-Transfer-Encoding", "7bit"); |
12821
aacda65b3449
[gaim-migrate @ 15169]
Christopher O'Brien <siege@pidgin.im>
parents:
12813
diff
changeset
|
3793 gaim_mime_part_set_data(part, tmp); |
12813
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3794 g_free(tmp); |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3795 |
10977 | 3796 g_string_free(str, TRUE); |
3797 | |
3798 str = g_string_new(NULL); | |
3799 gaim_mime_document_write(doc, str); | |
3800 tmp = str->str; | |
3801 g_string_free(str, FALSE); | |
3802 | |
3803 return tmp; | |
3804 } | |
3805 | |
3806 | |
3807 static int mw_prpl_send_im(GaimConnection *gc, | |
3808 const char *name, | |
3809 const char *message, | |
12216 | 3810 GaimMessageFlags flags) { |
10977 | 3811 |
3812 struct mwGaimPluginData *pd; | |
3813 struct mwIdBlock who = { (char *) name, NULL }; | |
3814 struct mwConversation *conv; | |
3815 | |
3816 g_return_val_if_fail(gc != NULL, 0); | |
3817 pd = gc->proto_data; | |
3818 | |
3819 g_return_val_if_fail(pd != NULL, 0); | |
3820 | |
3821 conv = mwServiceIm_getConversation(pd->srvc_im, &who); | |
3822 | |
3823 /* this detection of features to determine how to send the message | |
3824 (plain, html, or mime) is flawed because the other end of the | |
3825 conversation could close their channel at any time, rendering any | |
3826 existing formatting in an outgoing message innapropriate. The end | |
3827 result is that it may be possible that the other side of the | |
3828 conversation will receive a plaintext message with html contents, | |
3829 which is bad. I'm not sure how to fix this correctly. */ | |
3830 | |
12105
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3831 if(strstr(message, "<img ") || strstr(message, "<IMG ")) |
12216 | 3832 flags |= GAIM_MESSAGE_IMAGES; |
10977 | 3833 |
3834 if(mwConversation_isOpen(conv)) { | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3835 char *tmp; |
10977 | 3836 int ret; |
3837 | |
12216 | 3838 if((flags & GAIM_MESSAGE_IMAGES) && |
10977 | 3839 mwConversation_supports(conv, mwImSend_MIME)) { |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3840 /* send a MIME message */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3841 |
12105
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3842 tmp = im_mime_convert(gc, conv, message); |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3843 ret = mwConversation_send(conv, mwImSend_MIME, tmp); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3844 g_free(tmp); |
10977 | 3845 |
3846 } else if(mwConversation_supports(conv, mwImSend_HTML)) { | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3847 /* send an HTML message */ |
10977 | 3848 |
12813
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3849 char *ncr; |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3850 ncr = gaim_utf8_ncr_encode(message); |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3851 tmp = gaim_strdup_withhtml(ncr); |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3852 g_free(ncr); |
547c199072c8
[gaim-migrate @ 15161]
Christopher O'Brien <siege@pidgin.im>
parents:
12742
diff
changeset
|
3853 |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3854 ret = mwConversation_send(conv, mwImSend_HTML, tmp); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3855 g_free(tmp); |
10977 | 3856 |
3857 } else { | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3858 /* default to text */ |
12524
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3859 tmp = gaim_markup_strip_html(message); |
12216 | 3860 ret = mwConversation_send(conv, mwImSend_PLAIN, tmp); |
12524
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
3861 g_free(tmp); |
10977 | 3862 } |
3863 | |
3864 return !ret; | |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3865 |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3866 } else { |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3867 |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3868 /* queue up the message safely as plain text */ |
12105
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
3869 char *tmp = gaim_markup_strip_html(message); |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3870 convo_queue(conv, mwImSend_PLAIN, tmp); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3871 g_free(tmp); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3872 |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3873 if(! mwConversation_isPending(conv)) |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3874 mwConversation_open(conv); |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3875 |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
3876 return 1; |
10977 | 3877 } |
3878 } | |
3879 | |
3880 | |
3881 static int mw_prpl_send_typing(GaimConnection *gc, const char *name, | |
3882 int typing) { | |
3883 | |
3884 struct mwGaimPluginData *pd; | |
3885 struct mwIdBlock who = { (char *) name, NULL }; | |
3886 struct mwConversation *conv; | |
3887 | |
3888 gpointer t = GINT_TO_POINTER(!! typing); | |
3889 | |
3890 g_return_val_if_fail(gc != NULL, 0); | |
3891 pd = gc->proto_data; | |
3892 | |
3893 g_return_val_if_fail(pd != NULL, 0); | |
3894 | |
3895 conv = mwServiceIm_getConversation(pd->srvc_im, &who); | |
3896 | |
3897 if(mwConversation_isOpen(conv)) | |
3898 return ! mwConversation_send(conv, mwImSend_TYPING, t); | |
3899 | |
3900 if(typing) { | |
3901 /* let's only open a channel for typing, not for not-typing. | |
3902 Otherwise two users in psychic mode will continually open | |
3903 conversations to each other, never able to get rid of them, as | |
3904 when the other person closes, it psychicaly opens again */ | |
3905 | |
3906 convo_queue(conv, mwImSend_TYPING, t); | |
3907 | |
3908 if(! mwConversation_isPending(conv)) | |
3909 mwConversation_open(conv); | |
3910 } | |
3911 | |
3912 return 1; | |
3913 } | |
3914 | |
3915 | |
12311
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3916 static const char *mw_client_name(guint16 type) { |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3917 switch(type) { |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3918 case mwLogin_LIB: |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3919 return "Lotus Binary Library"; |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3920 |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3921 case mwLogin_JAVA_WEB: |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3922 return "Lotus Java Client Applet"; |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3923 |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3924 case mwLogin_BINARY: |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3925 return "Lotus Sametime Connect"; |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3926 |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3927 case mwLogin_JAVA_APP: |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3928 return "Lotus Java Client Application"; |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3929 |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3930 case mwLogin_LINKS: |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3931 return "Lotus Sametime Links"; |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3932 |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3933 case mwLogin_NOTES_6_5: |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3934 case mwLogin_NOTES_6_5_3: |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3935 case mwLogin_NOTES_7_0_beta: |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3936 case mwLogin_NOTES_7_0: |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3937 return "Lotus Notes Client"; |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3938 |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3939 case mwLogin_ICT: |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3940 case mwLogin_ICT_1_7_8_2: |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3941 case mwLogin_ICT_SIP: |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3942 return "IBM Community Tools"; |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3943 |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3944 case mwLogin_NOTESBUDDY_4_14: |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3945 case mwLogin_NOTESBUDDY_4_15: |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3946 case mwLogin_NOTESBUDDY_4_16: |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3947 return "Alphaworks NotesBuddy"; |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3948 |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3949 case mwLogin_SANITY: |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3950 return "Sanity"; |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3951 |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3952 case mwLogin_ST_PERL: |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3953 return "ST-Send-Message"; |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3954 |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3955 case mwLogin_TRILLIAN: |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3956 case mwLogin_TRILLIAN_IBM: |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3957 return "Trillian"; |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3958 |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3959 case mwLogin_MEANWHILE: |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3960 return "Meanwhile"; |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3961 |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3962 default: |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3963 return NULL; |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3964 } |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3965 } |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3966 |
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
3967 |
10977 | 3968 static void mw_prpl_get_info(GaimConnection *gc, const char *who) { |
3969 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3970 struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3971 |
10977 | 3972 struct mwGaimPluginData *pd; |
3973 GaimAccount *acct; | |
3974 GaimBuddy *b; | |
3975 | |
3976 GString *str; | |
3977 const char *tmp; | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3978 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3979 g_return_if_fail(who != NULL); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3980 g_return_if_fail(*who != '\0'); |
10977 | 3981 |
3982 pd = gc->proto_data; | |
3983 | |
3984 acct = gaim_connection_get_account(gc); | |
3985 b = gaim_find_buddy(acct, who); | |
3986 | |
3987 str = g_string_new(NULL); | |
3988 | |
12166 | 3989 if(gaim_str_has_prefix(who, "@E ")) { |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3990 g_string_append(str, _("<b>External User</b><br>")); |
10977 | 3991 } |
3992 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3993 g_string_append_printf(str, _("<b>User ID:</b> %s<br>"), who); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3994 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3995 if(b) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3996 guint32 type; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3997 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3998 if(b->server_alias) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
3999 g_string_append_printf(str, _("<b>Full Name:</b> %s<br>"), |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4000 b->server_alias); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4001 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4002 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4003 type = gaim_blist_node_get_int((GaimBlistNode *) b, BUDDY_KEY_CLIENT); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4004 if(type) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4005 g_string_append(str, _("<b>Last Known Client:</b> ")); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4006 |
12311
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
4007 tmp = mw_client_name(type); |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4008 if(tmp) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4009 g_string_append(str, tmp); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4010 g_string_append(str, "<br>"); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4011 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4012 } else { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4013 g_string_append_printf(str, _("Unknown (0x%04x)<br>"), type); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4014 } |
10977 | 4015 } |
4016 } | |
4017 | |
4018 tmp = user_supports_text(pd->srvc_aware, who); | |
4019 if(tmp) { | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4020 g_string_append_printf(str, _("<b>Supports:</b> %s<br>"), tmp); |
10977 | 4021 g_free((char *) tmp); |
4022 } | |
4023 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4024 if(b) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4025 tmp = status_text(b); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4026 g_string_append_printf(str, _("<b>Status:</b> %s"), tmp); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4027 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4028 g_string_append(str, "<hr>"); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4029 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4030 tmp = mwServiceAware_getText(pd->srvc_aware, &idb); |
12496
f9d0ab1474ac
[gaim-migrate @ 14808]
Christopher O'Brien <siege@pidgin.im>
parents:
12489
diff
changeset
|
4031 if(tmp) { |
f9d0ab1474ac
[gaim-migrate @ 14808]
Christopher O'Brien <siege@pidgin.im>
parents:
12489
diff
changeset
|
4032 tmp = g_markup_escape_text(tmp, -1); |
f9d0ab1474ac
[gaim-migrate @ 14808]
Christopher O'Brien <siege@pidgin.im>
parents:
12489
diff
changeset
|
4033 g_string_append(str, tmp); |
f9d0ab1474ac
[gaim-migrate @ 14808]
Christopher O'Brien <siege@pidgin.im>
parents:
12489
diff
changeset
|
4034 g_free((char *) tmp); |
f9d0ab1474ac
[gaim-migrate @ 14808]
Christopher O'Brien <siege@pidgin.im>
parents:
12489
diff
changeset
|
4035 } |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4036 } |
10977 | 4037 |
4038 /* @todo emit a signal to allow a plugin to override the display of | |
4039 this notification, so that it can create its own */ | |
4040 | |
11533
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11531
diff
changeset
|
4041 gaim_notify_userinfo(gc, who, str->str, NULL, NULL); |
10977 | 4042 |
4043 g_string_free(str, TRUE); | |
4044 } | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4045 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4046 |
11638 | 4047 static void mw_prpl_set_status(GaimAccount *acct, GaimStatus *status) { |
4048 GaimConnection *gc; | |
4049 const char *state; | |
11641
925c1960af34
[gaim-migrate @ 13918]
Richard Laager <rlaager@wiktel.com>
parents:
11638
diff
changeset
|
4050 char *message = NULL; |
10977 | 4051 struct mwSession *session; |
4052 struct mwUserStatus stat; | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4053 |
10977 | 4054 g_return_if_fail(acct != NULL); |
11638 | 4055 gc = gaim_account_get_connection(acct); |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4056 |
11638 | 4057 state = gaim_status_get_id(status); |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4058 |
12105
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4059 DEBUG_INFO("Set status to %s\n", gaim_status_get_name(status)); |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4060 |
11638 | 4061 g_return_if_fail(gc != NULL); |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4062 |
10977 | 4063 session = gc_to_session(gc); |
4064 g_return_if_fail(session != NULL); | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4065 |
10977 | 4066 /* get a working copy of the current status */ |
4067 mwUserStatus_clone(&stat, mwSession_getUserStatus(session)); | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4068 |
10977 | 4069 /* determine the state */ |
11638 | 4070 if(! strcmp(state, MW_STATE_ACTIVE)) { |
10977 | 4071 stat.status = mwStatus_ACTIVE; |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4072 |
11638 | 4073 } else if(! strcmp(state, MW_STATE_AWAY)) { |
4074 stat.status = mwStatus_AWAY; | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4075 |
11638 | 4076 } else if(! strcmp(state, MW_STATE_BUSY)) { |
4077 stat.status = mwStatus_BUSY; | |
10977 | 4078 } |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4079 |
10977 | 4080 /* determine the message */ |
12105
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4081 message = (char *) gaim_status_get_attr_string(status, MW_STATE_MESSAGE); |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4082 |
10977 | 4083 if(message) { |
4084 /* all the possible non-NULL values of message up to this point | |
4085 are const, so we don't need to free them */ | |
4086 message = gaim_markup_strip_html(message); | |
4087 } | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4088 |
10977 | 4089 /* out with the old */ |
4090 g_free(stat.desc); | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4091 |
10977 | 4092 /* in with the new */ |
4093 stat.desc = (char *) message; | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4094 |
10977 | 4095 mwSession_setUserStatus(session, &stat); |
11638 | 4096 mwUserStatus_clear(&stat); |
10977 | 4097 } |
4098 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4099 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4100 static void mw_prpl_set_idle(GaimConnection *gc, int t) { |
10977 | 4101 struct mwSession *session; |
4102 struct mwUserStatus stat; | |
12105
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4103 |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4104 |
10977 | 4105 session = gc_to_session(gc); |
4106 g_return_if_fail(session != NULL); | |
12105
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4107 |
10977 | 4108 mwUserStatus_clone(&stat, mwSession_getUserStatus(session)); |
4109 | |
12105
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4110 if(t) { |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4111 time_t now = time(NULL); |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4112 stat.time = now - t; |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4113 |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4114 } else { |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4115 stat.time = 0; |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4116 } |
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4117 |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4118 if(t > 0 && stat.status == mwStatus_ACTIVE) { |
12105
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4119 /* we were active and went idle, so change the status to IDLE. */ |
10977 | 4120 stat.status = mwStatus_IDLE; |
12105
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4121 |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4122 } else if(t == 0 && stat.status == mwStatus_IDLE) { |
12105
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4123 /* we only become idle automatically, so change back to ACTIVE */ |
10977 | 4124 stat.status = mwStatus_ACTIVE; |
4125 } | |
12105
d4cd7d443795
[gaim-migrate @ 14402]
Christopher O'Brien <siege@pidgin.im>
parents:
12088
diff
changeset
|
4126 |
10977 | 4127 mwSession_setUserStatus(session, &stat); |
4128 mwUserStatus_clear(&stat); | |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4129 } |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4130 |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4131 |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4132 static void notify_im(GaimConnection *gc, GList *row) { |
10977 | 4133 GaimAccount *acct; |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4134 GaimConversation *conv; |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4135 char *id; |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4136 |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4137 acct = gaim_connection_get_account(gc); |
12631
e8da8f12e694
[gaim-migrate @ 14967]
Christopher O'Brien <siege@pidgin.im>
parents:
12630
diff
changeset
|
4138 id = g_list_nth_data(row, 1); |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4139 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, id, acct); |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4140 if(! conv) conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, acct, id); |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4141 gaim_conversation_present(conv); |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4142 } |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4143 |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4144 |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4145 static void notify_add(GaimConnection *gc, GList *row) { |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4146 gaim_blist_request_add_buddy(gaim_connection_get_account(gc), |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4147 g_list_nth_data(row, 1), NULL, |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4148 g_list_nth_data(row, 0)); |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4149 } |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4150 |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4151 |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4152 static void notify_close(gpointer data) { |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4153 ; |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4154 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4155 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4156 |
10977 | 4157 static void multi_resolved_query(struct mwResolveResult *result, |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4158 GaimConnection *gc) { |
10977 | 4159 GList *l; |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
4160 const char *msgA; |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
4161 const char *msgB; |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
4162 char *msg; |
10977 | 4163 |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4164 GaimNotifySearchResults *sres; |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4165 GaimNotifySearchColumn *scol; |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4166 |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4167 sres = gaim_notify_searchresults_new(); |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4168 |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4169 scol = gaim_notify_searchresults_column_new(_("User Name")); |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4170 gaim_notify_searchresults_column_add(sres, scol); |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4171 |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4172 scol = gaim_notify_searchresults_column_new(_("Sametime ID")); |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4173 gaim_notify_searchresults_column_add(sres, scol); |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4174 |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4175 gaim_notify_searchresults_button_add(sres, GAIM_NOTIFY_BUTTON_IM, |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4176 notify_im); |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4177 |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4178 gaim_notify_searchresults_button_add(sres, GAIM_NOTIFY_BUTTON_ADD, |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4179 notify_add); |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4180 |
10977 | 4181 for(l = result->matches; l; l = l->next) { |
4182 struct mwResolveMatch *match = l->data; | |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4183 GList *row = NULL; |
12524
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4184 |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4185 DEBUG_INFO("multi resolve: %s, %s\n", |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4186 NSTR(match->id), NSTR(match->name)); |
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4187 |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4188 if(!match->id || !match->name) |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4189 continue; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4190 |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4191 row = g_list_append(row, g_strdup(match->name)); |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4192 row = g_list_append(row, g_strdup(match->id)); |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4193 gaim_notify_searchresults_row_add(sres, row); |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4194 } |
10977 | 4195 |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4196 msgA = _("An ambiguous user ID was entered"); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4197 msgB = _("The identifier '%s' may possibly refer to any of the following" |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4198 " users. Please select the correct user from the list below to" |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4199 " add them to your buddy list."); |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
4200 msg = g_strdup_printf(msgB, result->name); |
10977 | 4201 |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4202 gaim_notify_searchresults(gc, _("Select User"), |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
4203 msgA, msg, sres, notify_close, NULL); |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
4204 |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
4205 g_free(msg); |
10977 | 4206 } |
4207 | |
4208 | |
4209 static void add_buddy_resolved(struct mwServiceResolve *srvc, | |
4210 guint32 id, guint32 code, GList *results, | |
4211 gpointer b) { | |
4212 | |
4213 struct mwResolveResult *res = NULL; | |
4214 GaimBuddy *buddy = b; | |
4215 GaimConnection *gc; | |
4216 struct mwGaimPluginData *pd; | |
4217 | |
4218 gc = gaim_account_get_connection(buddy->account); | |
4219 pd = gc->proto_data; | |
4220 | |
4221 if(results) | |
4222 res = results->data; | |
4223 | |
4224 if(!code && res && res->matches) { | |
4225 if(g_list_length(res->matches) == 1) { | |
4226 struct mwResolveMatch *match = res->matches->data; | |
4227 | |
4228 /* only one? that might be the right one! */ | |
4229 if(strcmp(res->name, match->id)) { | |
4230 /* uh oh, the single result isn't identical to the search | |
4231 term, better safe then sorry, so let's make sure it's who | |
4232 the user meant to add */ | |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4233 gaim_blist_remove_buddy(buddy); |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4234 multi_resolved_query(res, gc); |
10977 | 4235 |
4236 } else { | |
12829
3848e5eb7962
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4237 |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4238 /* same person, set the server alias */ |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4239 gaim_blist_server_alias_buddy(buddy, match->name); |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4240 gaim_blist_node_set_string((GaimBlistNode *) buddy, |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4241 BUDDY_KEY_NAME, match->name); |
12829
3848e5eb7962
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4242 |
3848e5eb7962
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4243 /* subscribe to awareness */ |
3848e5eb7962
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4244 buddy_add(pd, buddy); |
3848e5eb7962
[gaim-migrate @ 15177]
Christopher O'Brien <siege@pidgin.im>
parents:
12821
diff
changeset
|
4245 |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4246 blist_schedule(pd); |
10977 | 4247 } |
4248 | |
4249 } else { | |
4250 /* prompt user if more than one match was returned */ | |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4251 gaim_blist_remove_buddy(buddy); |
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
4252 multi_resolved_query(res, gc); |
10977 | 4253 } |
4254 | |
4255 return; | |
4256 } | |
4257 | |
4258 /* fall-through indicates that we couldn't find a matching user in | |
4259 the resolve service (ether error or zero results), so we remove | |
4260 this buddy */ | |
4261 | |
4262 DEBUG_INFO("no such buddy in community\n"); | |
4263 gaim_blist_remove_buddy(buddy); | |
4264 blist_schedule(pd); | |
4265 | |
4266 if(res && res->name) { | |
4267 /* compose and display an error message */ | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
4268 const char *msgA; |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
4269 const char *msgB; |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
4270 char *msg; |
10977 | 4271 |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4272 msgA = _("Unable to add user: user not found"); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4273 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4274 msgB = _("The identifier '%s' did not match any users in your" |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4275 " Sametime community. This entry has been removed from" |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4276 " your buddy list."); |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
4277 msg = g_strdup_printf(msgB, NSTR(res->name)); |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
4278 |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
4279 gaim_notify_error(gc, _("Unable to add user"), msgA, msg); |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
4280 |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
4281 g_free(msg); |
10977 | 4282 } |
4283 } | |
4284 | |
4285 | |
4286 static void mw_prpl_add_buddy(GaimConnection *gc, | |
4287 GaimBuddy *buddy, | |
4288 GaimGroup *group) { | |
4289 | |
4290 struct mwGaimPluginData *pd; | |
4291 struct mwServiceResolve *srvc; | |
4292 GList *query; | |
4293 enum mwResolveFlag flags; | |
4294 guint32 req; | |
4295 | |
4296 pd = gc->proto_data; | |
4297 srvc = pd->srvc_resolve; | |
4298 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4299 /* catch external buddies. They won't be in the resolve service */ |
12524
977ebab0435f
[gaim-migrate @ 14836]
Christopher O'Brien <siege@pidgin.im>
parents:
12496
diff
changeset
|
4300 if(buddy_is_external(buddy)) { |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4301 buddy_add(pd, buddy); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4302 return; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4303 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4304 |
10977 | 4305 query = g_list_prepend(NULL, buddy->name); |
4306 flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; | |
4307 | |
4308 req = mwServiceResolve_resolve(srvc, query, flags, add_buddy_resolved, | |
4309 buddy, NULL); | |
4310 g_list_free(query); | |
4311 | |
4312 if(req == SEARCH_ERROR) { | |
4313 gaim_blist_remove_buddy(buddy); | |
4314 blist_schedule(pd); | |
4315 } | |
4316 } | |
4317 | |
4318 | |
4319 static void foreach_add_buddies(GaimGroup *group, GList *buddies, | |
4320 struct mwGaimPluginData *pd) { | |
4321 struct mwAwareList *list; | |
4322 | |
4323 list = list_ensure(pd, group); | |
4324 mwAwareList_addAware(list, buddies); | |
4325 g_list_free(buddies); | |
4326 } | |
4327 | |
4328 | |
4329 static void mw_prpl_add_buddies(GaimConnection *gc, | |
4330 GList *buddies, | |
4331 GList *groups) { | |
4332 | |
4333 struct mwGaimPluginData *pd; | |
4334 GHashTable *group_sets; | |
4335 struct mwAwareIdBlock *idbs, *idb; | |
4336 | |
4337 pd = gc->proto_data; | |
4338 | |
4339 /* map GaimGroup:GList of mwAwareIdBlock */ | |
4340 group_sets = g_hash_table_new(g_direct_hash, g_direct_equal); | |
4341 | |
4342 /* bunch of mwAwareIdBlock allocated at once, free'd at once */ | |
4343 idb = idbs = g_new(struct mwAwareIdBlock, g_list_length(buddies)); | |
4344 | |
4345 /* first pass collects mwAwareIdBlock lists for each group */ | |
4346 for(; buddies; buddies = buddies->next) { | |
4347 GaimBuddy *b = buddies->data; | |
4348 GaimGroup *g; | |
4349 const char *fn; | |
4350 GList *l; | |
4351 | |
4352 /* nab the saved server alias and stick it on the buddy */ | |
4353 fn = gaim_blist_node_get_string((GaimBlistNode *) b, BUDDY_KEY_NAME); | |
4354 gaim_blist_server_alias_buddy(b, fn); | |
4355 | |
4356 /* convert GaimBuddy into a mwAwareIdBlock */ | |
4357 idb->type = mwAware_USER; | |
4358 idb->user = (char *) b->name; | |
4359 idb->community = NULL; | |
4360 | |
4361 /* put idb into the list associated with the buddy's group */ | |
12088 | 4362 g = gaim_buddy_get_group(b); |
10977 | 4363 l = g_hash_table_lookup(group_sets, g); |
4364 l = g_list_prepend(l, idb++); | |
4365 g_hash_table_insert(group_sets, g, l); | |
4366 } | |
4367 | |
4368 /* each group's buddies get added in one shot, and schedule the blist | |
4369 for saving */ | |
4370 g_hash_table_foreach(group_sets, (GHFunc) foreach_add_buddies, pd); | |
4371 blist_schedule(pd); | |
4372 | |
4373 /* cleanup */ | |
4374 g_hash_table_destroy(group_sets); | |
4375 g_free(idbs); | |
4376 } | |
4377 | |
4378 | |
4379 static void mw_prpl_remove_buddy(GaimConnection *gc, | |
4380 GaimBuddy *buddy, GaimGroup *group) { | |
4381 | |
4382 struct mwGaimPluginData *pd; | |
4383 struct mwAwareIdBlock idb = { mwAware_USER, buddy->name, NULL }; | |
4384 struct mwAwareList *list; | |
4385 | |
4386 GList *rem = g_list_prepend(NULL, &idb); | |
4387 | |
4388 pd = gc->proto_data; | |
12088 | 4389 group = gaim_buddy_get_group(buddy); |
10977 | 4390 list = list_ensure(pd, group); |
4391 | |
4392 mwAwareList_removeAware(list, rem); | |
4393 blist_schedule(pd); | |
4394 | |
4395 g_list_free(rem); | |
4396 } | |
4397 | |
4398 | |
4399 static void privacy_fill(struct mwPrivacyInfo *priv, | |
4400 GSList *members) { | |
4401 | |
4402 struct mwUserItem *u; | |
4403 guint count; | |
4404 | |
4405 count = g_slist_length(members); | |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4406 DEBUG_INFO("privacy_fill: %u members\n", count); |
10977 | 4407 |
4408 priv->count = count; | |
4409 priv->users = g_new0(struct mwUserItem, count); | |
4410 | |
4411 while(count--) { | |
4412 u = priv->users + count; | |
4413 u->id = members->data; | |
4414 members = members->next; | |
4415 } | |
4416 } | |
4417 | |
4418 | |
4419 static void mw_prpl_set_permit_deny(GaimConnection *gc) { | |
4420 GaimAccount *acct; | |
4421 struct mwGaimPluginData *pd; | |
4422 struct mwSession *session; | |
4423 | |
4424 struct mwPrivacyInfo privacy = { | |
4425 .deny = FALSE, | |
4426 .count = 0, | |
4427 .users = NULL, | |
4428 }; | |
4429 | |
4430 g_return_if_fail(gc != NULL); | |
4431 | |
4432 acct = gaim_connection_get_account(gc); | |
4433 g_return_if_fail(acct != NULL); | |
4434 | |
4435 pd = gc->proto_data; | |
4436 g_return_if_fail(pd != NULL); | |
4437 | |
4438 session = pd->session; | |
4439 g_return_if_fail(session != NULL); | |
4440 | |
4441 switch(acct->perm_deny) { | |
4442 case GAIM_PRIVACY_DENY_USERS: | |
4443 DEBUG_INFO("GAIM_PRIVACY_DENY_USERS\n"); | |
4444 privacy_fill(&privacy, acct->deny); | |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4445 privacy.deny = TRUE; |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4446 break; |
10977 | 4447 |
4448 case GAIM_PRIVACY_ALLOW_ALL: | |
4449 DEBUG_INFO("GAIM_PRIVACY_ALLOW_ALL\n"); | |
4450 privacy.deny = TRUE; | |
4451 break; | |
4452 | |
4453 case GAIM_PRIVACY_ALLOW_USERS: | |
4454 DEBUG_INFO("GAIM_PRIVACY_ALLOW_USERS\n"); | |
4455 privacy_fill(&privacy, acct->permit); | |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4456 privacy.deny = FALSE; |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4457 break; |
10977 | 4458 |
4459 case GAIM_PRIVACY_DENY_ALL: | |
4460 DEBUG_INFO("GAIM_PRIVACY_DENY_ALL\n"); | |
4461 privacy.deny = FALSE; | |
4462 break; | |
4463 | |
4464 default: | |
4465 DEBUG_INFO("acct->perm_deny is 0x%x\n", acct->perm_deny); | |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
4466 return; |
10977 | 4467 } |
4468 | |
4469 mwSession_setPrivacyInfo(session, &privacy); | |
4470 g_free(privacy.users); | |
4471 } | |
4472 | |
4473 | |
4474 static void mw_prpl_add_permit(GaimConnection *gc, const char *name) { | |
4475 mw_prpl_set_permit_deny(gc); | |
4476 } | |
4477 | |
4478 | |
4479 static void mw_prpl_add_deny(GaimConnection *gc, const char *name) { | |
4480 mw_prpl_set_permit_deny(gc); | |
4481 } | |
4482 | |
4483 | |
4484 static void mw_prpl_rem_permit(GaimConnection *gc, const char *name) { | |
4485 mw_prpl_set_permit_deny(gc); | |
4486 } | |
4487 | |
4488 | |
4489 static void mw_prpl_rem_deny(GaimConnection *gc, const char *name) { | |
4490 mw_prpl_set_permit_deny(gc); | |
4491 } | |
4492 | |
4493 | |
4494 static struct mwConference *conf_find(struct mwServiceConference *srvc, | |
4495 const char *name) { | |
4496 GList *l, *ll; | |
4497 struct mwConference *conf = NULL; | |
4498 | |
4499 ll = mwServiceConference_getConferences(srvc); | |
4500 for(l = ll; l; l = l->next) { | |
4501 struct mwConference *c = l->data; | |
4502 if(! strcmp(name, mwConference_getName(c))) { | |
4503 conf = c; | |
4504 break; | |
4505 } | |
4506 } | |
4507 g_list_free(ll); | |
4508 | |
4509 return conf; | |
4510 } | |
4511 | |
4512 | |
4513 static void mw_prpl_join_chat(GaimConnection *gc, | |
4514 GHashTable *components) { | |
4515 | |
4516 struct mwGaimPluginData *pd; | |
4517 char *c, *t; | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4518 |
10977 | 4519 pd = gc->proto_data; |
4520 | |
4521 c = g_hash_table_lookup(components, CHAT_KEY_NAME); | |
4522 t = g_hash_table_lookup(components, CHAT_KEY_TOPIC); | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4523 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4524 if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4525 /* use place service */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4526 struct mwServicePlace *srvc; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4527 struct mwPlace *place = NULL; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4528 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4529 srvc = pd->srvc_place; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4530 place = mwPlace_new(srvc, c, t); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4531 mwPlace_open(place); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4532 |
10977 | 4533 } else { |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4534 /* use conference service */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4535 struct mwServiceConference *srvc; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4536 struct mwConference *conf = NULL; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4537 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4538 srvc = pd->srvc_conf; |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4539 if(c) conf = conf_find(srvc, c); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4540 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4541 if(conf) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4542 DEBUG_INFO("accepting conference invitation\n"); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4543 mwConference_accept(conf); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4544 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4545 } else { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4546 DEBUG_INFO("creating new conference\n"); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4547 conf = mwConference_new(srvc, t); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4548 mwConference_open(conf); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4549 } |
10977 | 4550 } |
4551 } | |
4552 | |
4553 | |
4554 static void mw_prpl_reject_chat(GaimConnection *gc, | |
4555 GHashTable *components) { | |
4556 | |
4557 struct mwGaimPluginData *pd; | |
4558 struct mwServiceConference *srvc; | |
4559 char *c; | |
4560 | |
4561 pd = gc->proto_data; | |
4562 srvc = pd->srvc_conf; | |
4563 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4564 if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4565 ; /* nothing needs doing */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4566 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4567 } else { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4568 /* reject conference */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4569 c = g_hash_table_lookup(components, CHAT_KEY_NAME); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4570 if(c) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4571 struct mwConference *conf = conf_find(srvc, c); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4572 if(conf) mwConference_reject(conf, ERR_SUCCESS, "Declined"); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4573 } |
10977 | 4574 } |
4575 } | |
4576 | |
4577 | |
4578 static char *mw_prpl_get_chat_name(GHashTable *components) { | |
4579 return g_hash_table_lookup(components, CHAT_KEY_NAME); | |
4580 } | |
4581 | |
4582 | |
4583 static void mw_prpl_chat_invite(GaimConnection *gc, | |
4584 int id, | |
4585 const char *invitation, | |
4586 const char *who) { | |
4587 | |
4588 struct mwGaimPluginData *pd; | |
4589 struct mwConference *conf; | |
12107
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4590 struct mwPlace *place; |
10977 | 4591 struct mwIdBlock idb = { (char *) who, NULL }; |
4592 | |
4593 pd = gc->proto_data; | |
4594 g_return_if_fail(pd != NULL); | |
12107
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4595 |
10977 | 4596 conf = ID_TO_CONF(pd, id); |
4597 | |
12107
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4598 if(conf) { |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4599 mwConference_invite(conf, &idb, invitation); |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4600 return; |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4601 } |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4602 |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4603 place = ID_TO_PLACE(pd, id); |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4604 g_return_if_fail(place != NULL); |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4605 |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4606 /* @todo: use the IM service for invitation */ |
40724851e95e
[gaim-migrate @ 14405]
Christopher O'Brien <siege@pidgin.im>
parents:
12105
diff
changeset
|
4607 mwPlace_legacyInvite(place, &idb, invitation); |
10977 | 4608 } |
4609 | |
4610 | |
4611 static void mw_prpl_chat_leave(GaimConnection *gc, | |
4612 int id) { | |
4613 | |
4614 struct mwGaimPluginData *pd; | |
4615 struct mwConference *conf; | |
4616 | |
4617 pd = gc->proto_data; | |
4618 | |
4619 g_return_if_fail(pd != NULL); | |
4620 conf = ID_TO_CONF(pd, id); | |
4621 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4622 if(conf) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4623 mwConference_destroy(conf, ERR_SUCCESS, "Leaving"); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4624 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4625 } else { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4626 struct mwPlace *place = ID_TO_PLACE(pd, id); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4627 g_return_if_fail(place != NULL); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4628 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4629 mwPlace_destroy(place, ERR_SUCCESS); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4630 } |
10977 | 4631 } |
4632 | |
4633 | |
4634 static void mw_prpl_chat_whisper(GaimConnection *gc, | |
4635 int id, | |
4636 const char *who, | |
4637 const char *message) { | |
4638 | |
4639 mw_prpl_send_im(gc, who, message, 0); | |
4640 } | |
4641 | |
4642 | |
4643 static int mw_prpl_chat_send(GaimConnection *gc, | |
4644 int id, | |
12216 | 4645 const char *message, |
4646 GaimMessageFlags flags) { | |
10977 | 4647 |
4648 struct mwGaimPluginData *pd; | |
4649 struct mwConference *conf; | |
4650 | |
4651 pd = gc->proto_data; | |
4652 | |
4653 g_return_val_if_fail(pd != NULL, 0); | |
4654 conf = ID_TO_CONF(pd, id); | |
4655 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4656 if(conf) { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4657 return ! mwConference_sendText(conf, message); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4658 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4659 } else { |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4660 struct mwPlace *place = ID_TO_PLACE(pd, id); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4661 g_return_val_if_fail(place != NULL, 0); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4662 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4663 return ! mwPlace_sendText(place, message); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4664 } |
10977 | 4665 } |
4666 | |
4667 | |
4668 static void mw_prpl_keepalive(GaimConnection *gc) { | |
4669 struct mwSession *session; | |
4670 | |
4671 g_return_if_fail(gc != NULL); | |
4672 | |
4673 session = gc_to_session(gc); | |
4674 g_return_if_fail(session != NULL); | |
4675 | |
4676 mwSession_sendKeepalive(session); | |
4677 } | |
4678 | |
4679 | |
4680 static void mw_prpl_alias_buddy(GaimConnection *gc, | |
4681 const char *who, | |
4682 const char *alias) { | |
4683 | |
4684 struct mwGaimPluginData *pd = gc->proto_data; | |
4685 g_return_if_fail(pd != NULL); | |
4686 | |
4687 /* it's a change to the buddy list, so we've gotta reflect that in | |
4688 the server copy */ | |
4689 | |
4690 blist_schedule(pd); | |
4691 } | |
4692 | |
4693 | |
4694 static void mw_prpl_group_buddy(GaimConnection *gc, | |
4695 const char *who, | |
4696 const char *old_group, | |
4697 const char *new_group) { | |
4698 | |
4699 struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; | |
4700 GList *gl = g_list_prepend(NULL, &idb); | |
4701 | |
4702 struct mwGaimPluginData *pd = gc->proto_data; | |
4703 GaimGroup *group; | |
4704 struct mwAwareList *list; | |
4705 | |
4706 /* add who to new_group's aware list */ | |
4707 group = gaim_find_group(new_group); | |
4708 list = list_ensure(pd, group); | |
4709 mwAwareList_addAware(list, gl); | |
4710 | |
4711 /* remove who from old_group's aware list */ | |
4712 group = gaim_find_group(old_group); | |
4713 list = list_ensure(pd, group); | |
4714 mwAwareList_removeAware(list, gl); | |
4715 | |
4716 g_list_free(gl); | |
4717 | |
4718 /* schedule the changes to be saved */ | |
4719 blist_schedule(pd); | |
4720 } | |
4721 | |
4722 | |
4723 static void mw_prpl_rename_group(GaimConnection *gc, | |
4724 const char *old, | |
4725 GaimGroup *group, | |
4726 GList *buddies) { | |
4727 | |
4728 struct mwGaimPluginData *pd = gc->proto_data; | |
4729 g_return_if_fail(pd != NULL); | |
4730 | |
4731 /* it's a change in the buddy list, so we've gotta reflect that in | |
4732 the server copy. Also, having this function should prevent all | |
4733 those buddies from being removed and re-added. We don't really | |
4734 give a crap what the group is named in Gaim other than to record | |
4735 that as the group name/alias */ | |
4736 | |
4737 blist_schedule(pd); | |
4738 } | |
4739 | |
4740 | |
4741 static void mw_prpl_buddy_free(GaimBuddy *buddy) { | |
4742 /* I don't think we have any cleanup for buddies yet */ | |
4743 ; | |
4744 } | |
4745 | |
4746 | |
4747 static void mw_prpl_convo_closed(GaimConnection *gc, const char *who) { | |
4748 struct mwGaimPluginData *pd = gc->proto_data; | |
4749 struct mwServiceIm *srvc; | |
4750 struct mwConversation *conv; | |
4751 struct mwIdBlock idb = { (char *) who, NULL }; | |
4752 | |
4753 g_return_if_fail(pd != NULL); | |
4754 | |
4755 srvc = pd->srvc_im; | |
4756 g_return_if_fail(srvc != NULL); | |
4757 | |
4758 conv = mwServiceIm_findConversation(srvc, &idb); | |
4759 if(! conv) return; | |
4760 | |
4761 if(mwConversation_isOpen(conv)) | |
4762 mwConversation_free(conv); | |
4763 } | |
4764 | |
4765 | |
4766 static const char *mw_prpl_normalize(const GaimAccount *account, | |
4767 const char *id) { | |
4768 | |
4769 /* code elsewhere assumes that the return value points to different | |
4770 memory than the passed value, but it won't free the normalized | |
4771 data. wtf? */ | |
4772 | |
4773 static char buf[BUF_LEN]; | |
4774 strncpy(buf, id, sizeof(buf)); | |
4775 return buf; | |
4776 } | |
4777 | |
4778 | |
4779 static void mw_prpl_remove_group(GaimConnection *gc, GaimGroup *group) { | |
4780 struct mwGaimPluginData *pd; | |
4781 struct mwAwareList *list; | |
4782 | |
4783 pd = gc->proto_data; | |
4784 g_return_if_fail(pd != NULL); | |
4785 g_return_if_fail(pd->group_list_map != NULL); | |
4786 | |
4787 list = g_hash_table_lookup(pd->group_list_map, group); | |
4788 | |
4789 if(list) { | |
4790 g_hash_table_remove(pd->group_list_map, list); | |
4791 g_hash_table_remove(pd->group_list_map, group); | |
4792 mwAwareList_free(list); | |
4793 | |
4794 blist_schedule(pd); | |
4795 } | |
4796 } | |
4797 | |
4798 | |
4799 static gboolean mw_prpl_can_receive_file(GaimConnection *gc, | |
4800 const char *who) { | |
4801 struct mwGaimPluginData *pd; | |
4802 struct mwServiceAware *srvc; | |
4803 GaimAccount *acct; | |
4804 | |
4805 g_return_val_if_fail(gc != NULL, FALSE); | |
4806 | |
4807 pd = gc->proto_data; | |
4808 g_return_val_if_fail(pd != NULL, FALSE); | |
4809 | |
4810 srvc = pd->srvc_aware; | |
4811 g_return_val_if_fail(srvc != NULL, FALSE); | |
4812 | |
4813 acct = gaim_connection_get_account(gc); | |
4814 g_return_val_if_fail(acct != NULL, FALSE); | |
4815 | |
4816 return gaim_find_buddy(acct, who) && | |
4817 user_supports(srvc, who, mwAttribute_FILE_TRANSFER); | |
4818 } | |
4819 | |
4820 | |
4821 static void ft_outgoing_init(GaimXfer *xfer) { | |
4822 GaimAccount *acct; | |
4823 GaimConnection *gc; | |
4824 | |
4825 struct mwGaimPluginData *pd; | |
4826 struct mwServiceFileTransfer *srvc; | |
4827 struct mwFileTransfer *ft; | |
4828 | |
4829 const char *filename; | |
4830 gsize filesize; | |
4831 FILE *fp; | |
4832 | |
4833 struct mwIdBlock idb = { NULL, NULL }; | |
4834 | |
4835 DEBUG_INFO("ft_outgoing_init\n"); | |
4836 | |
4837 acct = gaim_xfer_get_account(xfer); | |
4838 gc = gaim_account_get_connection(acct); | |
4839 pd = gc->proto_data; | |
4840 srvc = pd->srvc_ft; | |
4841 | |
4842 filename = gaim_xfer_get_local_filename(xfer); | |
4843 filesize = gaim_xfer_get_size(xfer); | |
4844 idb.user = xfer->who; | |
4845 | |
4846 /* test that we can actually send the file */ | |
4847 fp = g_fopen(filename, "rb"); | |
4848 if(! fp) { | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4849 char *msg = g_strdup_printf(_("Error reading file %s: \n%s\n"), |
10977 | 4850 filename, strerror(errno)); |
4851 gaim_xfer_error(gaim_xfer_get_type(xfer), acct, xfer->who, msg); | |
4852 g_free(msg); | |
4853 return; | |
4854 } | |
4855 fclose(fp); | |
4856 | |
4857 { | |
4858 char *tmp = strrchr(filename, G_DIR_SEPARATOR); | |
4859 if(tmp++) filename = tmp; | |
4860 } | |
4861 | |
4862 ft = mwFileTransfer_new(srvc, &idb, NULL, filename, filesize); | |
4863 | |
4864 gaim_xfer_ref(xfer); | |
4865 mwFileTransfer_setClientData(ft, xfer, (GDestroyNotify) gaim_xfer_unref); | |
4866 xfer->data = ft; | |
4867 | |
4868 mwFileTransfer_offer(ft); | |
4869 } | |
4870 | |
4871 | |
4872 static void ft_outgoing_cancel(GaimXfer *xfer) { | |
4873 struct mwFileTransfer *ft = xfer->data; | |
4874 if(ft) mwFileTransfer_cancel(ft); | |
4875 } | |
4876 | |
4877 | |
12147 | 4878 static GaimXfer *mw_prpl_new_xfer(GaimConnection *gc, const char *who) { |
10977 | 4879 GaimAccount *acct; |
4880 GaimXfer *xfer; | |
4881 | |
4882 acct = gaim_connection_get_account(gc); | |
4883 | |
4884 xfer = gaim_xfer_new(acct, GAIM_XFER_SEND, who); | |
4885 gaim_xfer_set_init_fnc(xfer, ft_outgoing_init); | |
4886 gaim_xfer_set_cancel_send_fnc(xfer, ft_outgoing_cancel); | |
4887 | |
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12135
diff
changeset
|
4888 return xfer; |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12135
diff
changeset
|
4889 } |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12135
diff
changeset
|
4890 |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12135
diff
changeset
|
4891 static void mw_prpl_send_file(GaimConnection *gc, |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12135
diff
changeset
|
4892 const char *who, const char *file) { |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12135
diff
changeset
|
4893 |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12135
diff
changeset
|
4894 GaimXfer *xfer = mw_prpl_new_xfer(gc, who); |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12135
diff
changeset
|
4895 |
10977 | 4896 if(file) { |
4897 DEBUG_INFO("file != NULL\n"); | |
4898 gaim_xfer_request_accepted(xfer, file); | |
4899 | |
4900 } else { | |
4901 DEBUG_INFO("file == NULL\n"); | |
4902 gaim_xfer_request(xfer); | |
4903 } | |
4904 } | |
4905 | |
4906 | |
4907 static GaimPluginProtocolInfo mw_prpl_info = { | |
4908 .options = OPT_PROTO_IM_IMAGE, | |
4909 .user_splits = NULL, /*< set in mw_plugin_init */ | |
4910 .protocol_options = NULL, /*< set in mw_plugin_init */ | |
4911 .icon_spec = NO_BUDDY_ICONS, | |
4912 .list_icon = mw_prpl_list_icon, | |
4913 .list_emblems = mw_prpl_list_emblems, | |
4914 .status_text = mw_prpl_status_text, | |
4915 .tooltip_text = mw_prpl_tooltip_text, | |
4916 .status_types = mw_prpl_status_types, | |
4917 .blist_node_menu = mw_prpl_blist_node_menu, | |
4918 .chat_info = mw_prpl_chat_info, | |
4919 .chat_info_defaults = mw_prpl_chat_info_defaults, | |
4920 .login = mw_prpl_login, | |
4921 .close = mw_prpl_close, | |
4922 .send_im = mw_prpl_send_im, | |
4923 .set_info = NULL, | |
4924 .send_typing = mw_prpl_send_typing, | |
4925 .get_info = mw_prpl_get_info, | |
11638 | 4926 .set_status = mw_prpl_set_status, |
10977 | 4927 .set_idle = mw_prpl_set_idle, |
4928 .change_passwd = NULL, | |
4929 .add_buddy = mw_prpl_add_buddy, | |
4930 .add_buddies = mw_prpl_add_buddies, | |
4931 .remove_buddy = mw_prpl_remove_buddy, | |
4932 .remove_buddies = NULL, | |
4933 .add_permit = mw_prpl_add_permit, | |
4934 .add_deny = mw_prpl_add_deny, | |
4935 .rem_permit = mw_prpl_rem_permit, | |
4936 .rem_deny = mw_prpl_rem_deny, | |
4937 .set_permit_deny = mw_prpl_set_permit_deny, | |
4938 .join_chat = mw_prpl_join_chat, | |
4939 .reject_chat = mw_prpl_reject_chat, | |
4940 .get_chat_name = mw_prpl_get_chat_name, | |
4941 .chat_invite = mw_prpl_chat_invite, | |
4942 .chat_leave = mw_prpl_chat_leave, | |
4943 .chat_whisper = mw_prpl_chat_whisper, | |
4944 .chat_send = mw_prpl_chat_send, | |
4945 .keepalive = mw_prpl_keepalive, | |
4946 .register_user = NULL, | |
4947 .get_cb_info = NULL, | |
4948 .get_cb_away = NULL, | |
4949 .alias_buddy = mw_prpl_alias_buddy, | |
4950 .group_buddy = mw_prpl_group_buddy, | |
4951 .rename_group = mw_prpl_rename_group, | |
4952 .buddy_free = mw_prpl_buddy_free, | |
4953 .convo_closed = mw_prpl_convo_closed, | |
4954 .normalize = mw_prpl_normalize, | |
4955 .set_buddy_icon = NULL, | |
4956 .remove_group = mw_prpl_remove_group, | |
4957 .get_cb_real_name = NULL, | |
4958 .set_chat_topic = NULL, | |
4959 .find_blist_chat = NULL, | |
4960 .roomlist_get_list = NULL, | |
4961 .roomlist_expand_category = NULL, | |
4962 .can_receive_file = mw_prpl_can_receive_file, | |
4963 .send_file = mw_prpl_send_file, | |
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12135
diff
changeset
|
4964 .new_xfer = mw_prpl_new_xfer, |
12650 | 4965 .offline_message = NULL, |
4966 .whiteboard_prpl_ops = NULL, | |
4967 .media_prpl_ops = NULL, | |
10977 | 4968 }; |
4969 | |
4970 | |
4971 static GaimPluginPrefFrame * | |
4972 mw_plugin_get_plugin_pref_frame(GaimPlugin *plugin) { | |
4973 GaimPluginPrefFrame *frame; | |
4974 GaimPluginPref *pref; | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4975 |
10977 | 4976 frame = gaim_plugin_pref_frame_new(); |
4977 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4978 pref = gaim_plugin_pref_new_with_label(_("Remotely Stored Buddy List")); |
10977 | 4979 gaim_plugin_pref_frame_add(frame, pref); |
4980 | |
4981 | |
4982 pref = gaim_plugin_pref_new_with_name(MW_PRPL_OPT_BLIST_ACTION); | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4983 gaim_plugin_pref_set_label(pref, _("Buddy List Storage Mode")); |
10977 | 4984 |
4985 gaim_plugin_pref_set_type(pref, GAIM_PLUGIN_PREF_CHOICE); | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4986 gaim_plugin_pref_add_choice(pref, _("Local Buddy List Only"), |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4987 GINT_TO_POINTER(blist_choice_LOCAL)); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4988 gaim_plugin_pref_add_choice(pref, _("Merge List from Server"), |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4989 GINT_TO_POINTER(blist_choice_MERGE)); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4990 gaim_plugin_pref_add_choice(pref, _("Merge and Save List to Server"), |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4991 GINT_TO_POINTER(blist_choice_STORE)); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4992 gaim_plugin_pref_add_choice(pref, _("Synchronize List with Server"), |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4993 GINT_TO_POINTER(blist_choice_SYNCH)); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
4994 |
10977 | 4995 gaim_plugin_pref_frame_add(frame, pref); |
4996 | |
4997 return frame; | |
4998 } | |
4999 | |
5000 | |
5001 static GaimPluginUiInfo mw_plugin_ui_info = { | |
5002 .get_plugin_pref_frame = mw_plugin_get_plugin_pref_frame, | |
5003 }; | |
5004 | |
5005 | |
5006 static void st_import_action_cb(GaimConnection *gc, char *filename) { | |
5007 struct mwSametimeList *l; | |
5008 | |
5009 FILE *file; | |
5010 char buf[BUF_LEN]; | |
5011 size_t len; | |
5012 | |
5013 GString *str; | |
5014 | |
13157
3a97c65196d1
[gaim-migrate @ 15520]
Richard Laager <rlaager@wiktel.com>
parents:
13106
diff
changeset
|
5015 file = g_fopen(filename, "r"); |
10977 | 5016 g_return_if_fail(file != NULL); |
5017 | |
5018 str = g_string_new(NULL); | |
5019 while( (len = fread(buf, 1, BUF_LEN, file)) ) { | |
5020 g_string_append_len(str, buf, len); | |
5021 } | |
5022 | |
5023 fclose(file); | |
5024 | |
5025 l = mwSametimeList_load(str->str); | |
5026 g_string_free(str, TRUE); | |
5027 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5028 blist_merge(gc, l); |
10977 | 5029 mwSametimeList_free(l); |
5030 } | |
5031 | |
5032 | |
5033 /** prompts for a file to import blist from */ | |
5034 static void st_import_action(GaimPluginAction *act) { | |
5035 GaimConnection *gc; | |
5036 GaimAccount *account; | |
5037 char *title; | |
5038 | |
5039 gc = act->context; | |
5040 account = gaim_connection_get_account(gc); | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5041 title = g_strdup_printf(_("Import Sametime List for Account %s"), |
10977 | 5042 gaim_account_get_username(account)); |
5043 | |
5044 gaim_request_file(gc, title, NULL, FALSE, | |
5045 G_CALLBACK(st_import_action_cb), NULL, | |
5046 gc); | |
5047 | |
5048 g_free(title); | |
5049 } | |
5050 | |
5051 | |
5052 static void st_export_action_cb(GaimConnection *gc, char *filename) { | |
5053 struct mwSametimeList *l; | |
5054 char *str; | |
5055 FILE *file; | |
5056 | |
13157
3a97c65196d1
[gaim-migrate @ 15520]
Richard Laager <rlaager@wiktel.com>
parents:
13106
diff
changeset
|
5057 file = g_fopen(filename, "w"); |
10977 | 5058 g_return_if_fail(file != NULL); |
5059 | |
5060 l = mwSametimeList_new(); | |
5061 blist_export(gc, l); | |
5062 str = mwSametimeList_store(l); | |
5063 mwSametimeList_free(l); | |
5064 | |
5065 fprintf(file, "%s", str); | |
5066 fclose(file); | |
5067 | |
5068 g_free(str); | |
5069 } | |
5070 | |
5071 | |
5072 /** prompts for a file to export blist to */ | |
5073 static void st_export_action(GaimPluginAction *act) { | |
5074 GaimConnection *gc; | |
5075 GaimAccount *account; | |
5076 char *title; | |
5077 | |
5078 gc = act->context; | |
5079 account = gaim_connection_get_account(gc); | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5080 title = g_strdup_printf(_("Export Sametime List for Account %s"), |
10977 | 5081 gaim_account_get_username(account)); |
5082 | |
5083 gaim_request_file(gc, title, NULL, TRUE, | |
5084 G_CALLBACK(st_export_action_cb), NULL, | |
5085 gc); | |
5086 | |
5087 g_free(title); | |
5088 } | |
5089 | |
5090 | |
5091 static void remote_group_multi_cleanup(gpointer ignore, | |
5092 GaimRequestFields *fields) { | |
5093 | |
5094 GaimRequestField *f; | |
5095 const GList *l; | |
5096 | |
5097 f = gaim_request_fields_get_field(fields, "group"); | |
5098 l = gaim_request_field_list_get_items(f); | |
5099 | |
5100 for(; l; l = l->next) { | |
5101 const char *i = l->data; | |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
5102 struct named_id *res; |
10977 | 5103 |
5104 res = gaim_request_field_list_get_data(f, i); | |
5105 | |
5106 g_free(res->id); | |
5107 g_free(res->name); | |
5108 g_free(res); | |
5109 } | |
5110 } | |
5111 | |
5112 | |
5113 static void remote_group_done(struct mwGaimPluginData *pd, | |
5114 const char *id, const char *name) { | |
5115 GaimConnection *gc; | |
5116 GaimAccount *acct; | |
5117 GaimGroup *group; | |
5118 GaimBlistNode *gn; | |
5119 const char *owner; | |
5120 | |
5121 g_return_if_fail(pd != NULL); | |
5122 | |
5123 gc = pd->gc; | |
5124 acct = gaim_connection_get_account(gc); | |
5125 | |
5126 /* collision checking */ | |
5127 group = gaim_find_group(name); | |
5128 if(group) { | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5129 const char *msgA; |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5130 const char *msgB; |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5131 char *msg; |
10977 | 5132 |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5133 msgA = _("Unable to add group: group exists"); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5134 msgB = _("A group named '%s' already exists in your buddy list."); |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5135 msg = g_strdup_printf(msgB, name); |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5136 |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5137 gaim_notify_error(gc, _("Unable to add group"), msgA, msg); |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5138 |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5139 g_free(msg); |
10977 | 5140 return; |
5141 } | |
5142 | |
5143 group = gaim_group_new(name); | |
5144 gn = (GaimBlistNode *) group; | |
5145 | |
5146 owner = gaim_account_get_username(acct); | |
5147 | |
5148 gaim_blist_node_set_string(gn, GROUP_KEY_NAME, id); | |
5149 gaim_blist_node_set_int(gn, GROUP_KEY_TYPE, mwSametimeGroup_DYNAMIC); | |
5150 gaim_blist_node_set_string(gn, GROUP_KEY_OWNER, owner); | |
5151 gaim_blist_add_group(group, NULL); | |
5152 | |
5153 group_add(pd, group); | |
5154 blist_schedule(pd); | |
5155 } | |
5156 | |
5157 | |
5158 static void remote_group_multi_cb(struct mwGaimPluginData *pd, | |
5159 GaimRequestFields *fields) { | |
5160 GaimRequestField *f; | |
5161 const GList *l; | |
5162 | |
5163 f = gaim_request_fields_get_field(fields, "group"); | |
5164 l = gaim_request_field_list_get_selected(f); | |
5165 | |
5166 if(l) { | |
5167 const char *i = l->data; | |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
5168 struct named_id *res; |
10977 | 5169 |
5170 res = gaim_request_field_list_get_data(f, i); | |
5171 remote_group_done(pd, res->id, res->name); | |
5172 } | |
5173 | |
5174 remote_group_multi_cleanup(NULL, fields); | |
5175 } | |
5176 | |
5177 | |
5178 static void remote_group_multi(struct mwResolveResult *result, | |
5179 struct mwGaimPluginData *pd) { | |
5180 | |
5181 GaimRequestFields *fields; | |
5182 GaimRequestFieldGroup *g; | |
5183 GaimRequestField *f; | |
5184 GList *l; | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5185 const char *msgA; |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5186 const char *msgB; |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5187 char *msg; |
10977 | 5188 |
5189 GaimConnection *gc = pd->gc; | |
5190 | |
5191 fields = gaim_request_fields_new(); | |
5192 | |
5193 g = gaim_request_field_group_new(NULL); | |
5194 gaim_request_fields_add_group(fields, g); | |
5195 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5196 f = gaim_request_field_list_new("group", _("Possible Matches")); |
10977 | 5197 gaim_request_field_list_set_multi_select(f, FALSE); |
5198 gaim_request_field_set_required(f, TRUE); | |
5199 | |
5200 for(l = result->matches; l; l = l->next) { | |
5201 struct mwResolveMatch *match = l->data; | |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12595
diff
changeset
|
5202 struct named_id *res = g_new0(struct named_id, 1); |
10977 | 5203 |
5204 res->id = g_strdup(match->id); | |
5205 res->name = g_strdup(match->name); | |
5206 | |
5207 gaim_request_field_list_add(f, res->name, res); | |
5208 } | |
5209 | |
5210 gaim_request_field_group_add_field(g, f); | |
5211 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5212 msgA = _("Notes Address Book group results"); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5213 msgB = _("The identifier '%s' may possibly refer to any of the following" |
10977 | 5214 " Notes Address Book groups. Please select the correct group from" |
5215 " the list below to add it to your buddy list."); | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5216 msg = g_strdup_printf(msgB, result->name); |
10977 | 5217 |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5218 gaim_request_fields(gc, _("Select Notes Address Book"), |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5219 msgA, msg, fields, |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5220 _("Add Group"), G_CALLBACK(remote_group_multi_cb), |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5221 _("Cancel"), G_CALLBACK(remote_group_multi_cleanup), |
10977 | 5222 pd); |
5223 | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5224 g_free(msg); |
10977 | 5225 } |
5226 | |
5227 | |
5228 static void remote_group_resolved(struct mwServiceResolve *srvc, | |
5229 guint32 id, guint32 code, GList *results, | |
5230 gpointer b) { | |
11133
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
5231 |
1081735edc10
[gaim-migrate @ 13192]
Christopher O'Brien <siege@pidgin.im>
parents:
11132
diff
changeset
|
5232 struct mwResolveResult *res = NULL; |
10977 | 5233 struct mwSession *session; |
5234 struct mwGaimPluginData *pd; | |
5235 GaimConnection *gc; | |
5236 | |
5237 session = mwService_getSession(MW_SERVICE(srvc)); | |
5238 g_return_if_fail(session != NULL); | |
5239 | |
5240 pd = mwSession_getClientData(session); | |
5241 g_return_if_fail(pd != NULL); | |
5242 | |
5243 gc = pd->gc; | |
5244 g_return_if_fail(gc != NULL); | |
5245 | |
5246 if(!code && results) { | |
5247 res = results->data; | |
5248 | |
5249 if(res->matches) { | |
5250 remote_group_multi(res, pd); | |
5251 return; | |
5252 } | |
5253 } | |
5254 | |
5255 if(res && res->name) { | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5256 const char *msgA; |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5257 const char *msgB; |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5258 char *msg; |
10977 | 5259 |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5260 msgA = _("Unable to add group: group not found"); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5261 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5262 msgB = _("The identifier '%s' did not match any Notes Address Book" |
10977 | 5263 " groups in your Sametime community."); |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5264 msg = g_strdup_printf(msgB, res->name); |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5265 |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5266 gaim_notify_error(gc, _("Unable to add group"), msgA, msg); |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5267 |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5268 g_free(msg); |
10977 | 5269 } |
5270 } | |
5271 | |
5272 | |
5273 static void remote_group_action_cb(GaimConnection *gc, const char *name) { | |
5274 struct mwGaimPluginData *pd; | |
5275 struct mwServiceResolve *srvc; | |
5276 GList *query; | |
5277 enum mwResolveFlag flags; | |
5278 guint32 req; | |
5279 | |
5280 pd = gc->proto_data; | |
5281 srvc = pd->srvc_resolve; | |
5282 | |
5283 query = g_list_prepend(NULL, (char *) name); | |
5284 flags = mwResolveFlag_FIRST | mwResolveFlag_GROUPS; | |
5285 | |
5286 req = mwServiceResolve_resolve(srvc, query, flags, remote_group_resolved, | |
5287 NULL, NULL); | |
5288 g_list_free(query); | |
5289 | |
5290 if(req == SEARCH_ERROR) { | |
5291 /** @todo display error */ | |
5292 } | |
5293 } | |
5294 | |
5295 | |
5296 static void remote_group_action(GaimPluginAction *act) { | |
5297 GaimConnection *gc; | |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5298 const char *msgA; |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5299 const char *msgB; |
10977 | 5300 |
5301 gc = act->context; | |
5302 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5303 msgA = _("Notes Address Book Group"); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5304 msgB = _("Enter the name of a Notes Address Book group in the field below" |
10977 | 5305 " to add the group and its members to your buddy list."); |
5306 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5307 gaim_request_input(gc, _("Add Group"), msgA, msgB, NULL, |
10977 | 5308 FALSE, FALSE, NULL, |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5309 _("Add"), G_CALLBACK(remote_group_action_cb), |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5310 _("Cancel"), NULL, |
10977 | 5311 gc); |
5312 } | |
5313 | |
5314 | |
12630
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5315 static void search_notify(struct mwResolveResult *result, |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5316 GaimConnection *gc) { |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5317 GList *l; |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5318 const char *msgA; |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5319 const char *msgB; |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5320 char *msg1; |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5321 char *msg2; |
12630
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5322 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5323 GaimNotifySearchResults *sres; |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5324 GaimNotifySearchColumn *scol; |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5325 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5326 sres = gaim_notify_searchresults_new(); |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5327 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5328 scol = gaim_notify_searchresults_column_new(_("User Name")); |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5329 gaim_notify_searchresults_column_add(sres, scol); |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5330 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5331 scol = gaim_notify_searchresults_column_new(_("Sametime ID")); |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5332 gaim_notify_searchresults_column_add(sres, scol); |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5333 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5334 gaim_notify_searchresults_button_add(sres, GAIM_NOTIFY_BUTTON_IM, |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5335 notify_im); |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5336 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5337 gaim_notify_searchresults_button_add(sres, GAIM_NOTIFY_BUTTON_ADD, |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5338 notify_add); |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5339 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5340 for(l = result->matches; l; l = l->next) { |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5341 struct mwResolveMatch *match = l->data; |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5342 GList *row = NULL; |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5343 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5344 if(!match->id || !match->name) |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5345 continue; |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5346 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5347 row = g_list_append(row, g_strdup(match->name)); |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5348 row = g_list_append(row, g_strdup(match->id)); |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5349 gaim_notify_searchresults_row_add(sres, row); |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5350 } |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5351 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5352 msgA = _("Search results for '%s'"); |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5353 msgB = _("The identifier '%s' may possibly refer to any of the following" |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5354 " users. You may add these users to your buddy list or send them" |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5355 " messages with the action buttons below."); |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5356 |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5357 msg1 = g_strdup_printf(msgA, result->name); |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5358 msg2 = g_strdup_printf(msgB, result->name); |
12630
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5359 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5360 gaim_notify_searchresults(gc, _("Search Results"), |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5361 msg1, msg2, sres, notify_close, NULL); |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5362 |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5363 g_free(msg1); |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5364 g_free(msg2); |
12630
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5365 } |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5366 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5367 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5368 static void search_resolved(struct mwServiceResolve *srvc, |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5369 guint32 id, guint32 code, GList *results, |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5370 gpointer b) { |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5371 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5372 GaimConnection *gc = b; |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5373 struct mwResolveResult *res = NULL; |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5374 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5375 if(results) res = results->data; |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5376 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5377 if(!code && res && res->matches) { |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5378 search_notify(res, gc); |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5379 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5380 } else { |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5381 const char *msgA; |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5382 const char *msgB; |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5383 char *msg; |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5384 |
12630
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5385 msgA = _("No matches"); |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5386 msgB = _("The identifier '%s' did not match and users in your" |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5387 " Sametime community."); |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5388 msg = g_strdup_printf(msgB, NSTR(res->name)); |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5389 |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5390 gaim_notify_error(gc, _("No Matches"), msgA, msg); |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5391 |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5392 g_free(msg); |
12630
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5393 } |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5394 } |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5395 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5396 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5397 static void search_action_cb(GaimConnection *gc, const char *name) { |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5398 struct mwGaimPluginData *pd; |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5399 struct mwServiceResolve *srvc; |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5400 GList *query; |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5401 enum mwResolveFlag flags; |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5402 guint32 req; |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5403 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5404 pd = gc->proto_data; |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5405 srvc = pd->srvc_resolve; |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5406 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5407 query = g_list_prepend(NULL, (char *) name); |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5408 flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5409 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5410 req = mwServiceResolve_resolve(srvc, query, flags, search_resolved, |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5411 gc, NULL); |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5412 g_list_free(query); |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5413 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5414 if(req == SEARCH_ERROR) { |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5415 /** @todo display error */ |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5416 } |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5417 } |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5418 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5419 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5420 static void search_action(GaimPluginAction *act) { |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5421 GaimConnection *gc; |
13106
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5422 const char *msgA; |
a0a4b44239e8
[gaim-migrate @ 15468]
Richard Laager <rlaager@wiktel.com>
parents:
13021
diff
changeset
|
5423 const char *msgB; |
12630
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5424 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5425 gc = act->context; |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5426 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5427 msgA = _("Search for a user"); |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5428 msgB = _("Enter a name or partial ID in the field below to search" |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5429 " for matching users in your Sametime community."); |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5430 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5431 gaim_request_input(gc, _("User Search"), msgA, msgB, NULL, |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5432 FALSE, FALSE, NULL, |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5433 _("Search"), G_CALLBACK(search_action_cb), |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5434 _("Cancel"), NULL, |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5435 gc); |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5436 } |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5437 |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5438 |
10977 | 5439 static GList *mw_plugin_actions(GaimPlugin *plugin, gpointer context) { |
5440 GaimPluginAction *act; | |
5441 GList *l = NULL; | |
5442 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5443 act = gaim_plugin_action_new(_("Import Sametime List..."), |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5444 st_import_action); |
10977 | 5445 l = g_list_append(l, act); |
5446 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5447 act = gaim_plugin_action_new(_("Export Sametime List..."), |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5448 st_export_action); |
10977 | 5449 l = g_list_append(l, act); |
5450 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5451 act = gaim_plugin_action_new(_("Add Notes Address Book Group..."), |
10977 | 5452 remote_group_action); |
5453 l = g_list_append(l, act); | |
5454 | |
12630
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5455 act = gaim_plugin_action_new(_("User Search..."), |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5456 search_action); |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5457 l = g_list_append(l, act); |
97ec28aaae47
[gaim-migrate @ 14966]
Christopher O'Brien <siege@pidgin.im>
parents:
12629
diff
changeset
|
5458 |
10977 | 5459 return l; |
5460 } | |
5461 | |
5462 | |
5463 static gboolean mw_plugin_load(GaimPlugin *plugin) { | |
5464 return TRUE; | |
5465 } | |
5466 | |
5467 | |
5468 static gboolean mw_plugin_unload(GaimPlugin *plugin) { | |
5469 return TRUE; | |
5470 } | |
5471 | |
5472 | |
5473 static void mw_plugin_destroy(GaimPlugin *plugin) { | |
5474 g_log_remove_handler(G_LOG_DOMAIN, log_handler[0]); | |
5475 g_log_remove_handler("meanwhile", log_handler[1]); | |
5476 } | |
5477 | |
5478 | |
5479 static GaimPluginInfo mw_plugin_info = { | |
5480 .magic = GAIM_PLUGIN_MAGIC, | |
5481 .major_version = GAIM_MAJOR_VERSION, | |
5482 .minor_version = GAIM_MINOR_VERSION, | |
5483 .type = GAIM_PLUGIN_PROTOCOL, | |
5484 .ui_requirement = NULL, | |
5485 .flags = 0, | |
5486 .dependencies = NULL, | |
5487 .priority = GAIM_PRIORITY_DEFAULT, | |
5488 .id = PLUGIN_ID, | |
5489 .name = PLUGIN_NAME, | |
5490 .version = VERSION, | |
5491 .summary = PLUGIN_SUMMARY, | |
5492 .description = PLUGIN_DESC, | |
5493 .author = PLUGIN_AUTHOR, | |
5494 .homepage = PLUGIN_HOMEPAGE, | |
5495 .load = mw_plugin_load, | |
5496 .unload = mw_plugin_unload, | |
5497 .destroy = mw_plugin_destroy, | |
5498 .ui_info = NULL, | |
5499 .extra_info = &mw_prpl_info, | |
5500 .prefs_info = &mw_plugin_ui_info, | |
5501 .actions = mw_plugin_actions, | |
5502 }; | |
5503 | |
5504 | |
5505 static void mw_log_handler(const gchar *domain, GLogLevelFlags flags, | |
5506 const gchar *msg, gpointer data) { | |
12005
5b3368008513
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
5507 |
5b3368008513
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
5508 if(! (msg && *msg)) return; |
10977 | 5509 |
5510 /* handle g_log requests via gaim's built-in debug logging */ | |
5511 if(flags & G_LOG_LEVEL_ERROR) { | |
12005
5b3368008513
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
5512 gaim_debug_error(domain, "%s\n", msg); |
10977 | 5513 |
5514 } else if(flags & G_LOG_LEVEL_WARNING) { | |
12005
5b3368008513
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
5515 gaim_debug_warning(domain, "%s\n", msg); |
10977 | 5516 |
5517 } else { | |
12005
5b3368008513
[gaim-migrate @ 14298]
Christopher O'Brien <siege@pidgin.im>
parents:
11953
diff
changeset
|
5518 gaim_debug_info(domain, "%s\n", msg); |
10977 | 5519 } |
5520 } | |
5521 | |
5522 | |
5523 static void mw_plugin_init(GaimPlugin *plugin) { | |
5524 GaimAccountOption *opt; | |
5525 GList *l = NULL; | |
5526 | |
5527 GLogLevelFlags logflags = | |
5528 G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION; | |
5529 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5530 /* set up the preferences */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5531 gaim_prefs_add_none(MW_PRPL_OPT_BASE); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5532 gaim_prefs_add_int(MW_PRPL_OPT_BLIST_ACTION, BLIST_CHOICE_DEFAULT); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5533 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5534 /* remove dead preferences */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5535 gaim_prefs_remove(MW_PRPL_OPT_PSYCHIC); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5536 gaim_prefs_remove(MW_PRPL_OPT_SAVE_DYNAMIC); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5537 |
10977 | 5538 /* host to connect to */ |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5539 opt = gaim_account_option_string_new(_("Server"), MW_KEY_HOST, |
10977 | 5540 MW_PLUGIN_DEFAULT_HOST); |
5541 l = g_list_append(l, opt); | |
5542 | |
5543 /* port to connect to */ | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5544 opt = gaim_account_option_int_new(_("Port"), MW_KEY_PORT, |
10977 | 5545 MW_PLUGIN_DEFAULT_PORT); |
5546 l = g_list_append(l, opt); | |
5547 | |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5548 { /* copy the old force login setting from prefs if it's |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5549 there. Don't delete the preference, since there may be more |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5550 than one account that wants to check for it. */ |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5551 gboolean b = FALSE; |
12489 | 5552 const char *label = _("Force login (ignore server redirects)"); |
11943
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5553 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5554 if(gaim_prefs_exists(MW_PRPL_OPT_FORCE_LOGIN)) |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5555 b = gaim_prefs_get_bool(MW_PRPL_OPT_FORCE_LOGIN); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5556 |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5557 opt = gaim_account_option_bool_new(label, MW_KEY_FORCE, b); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5558 l = g_list_append(l, opt); |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5559 } |
0110fc7c6a8a
[gaim-migrate @ 14234]
Christopher O'Brien <siege@pidgin.im>
parents:
11837
diff
changeset
|
5560 |
12311
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
5561 /* pretend to be Sametime Connect */ |
12489 | 5562 opt = gaim_account_option_bool_new(_("Hide client identity"), |
12311
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
5563 MW_KEY_FAKE_IT, FALSE); |
12312
1c8ea8f3b84e
[gaim-migrate @ 14616]
Christopher O'Brien <siege@pidgin.im>
parents:
12311
diff
changeset
|
5564 l = g_list_append(l, opt); |
12311
a2ebf585d8c6
[gaim-migrate @ 14615]
Christopher O'Brien <siege@pidgin.im>
parents:
12266
diff
changeset
|
5565 |
10977 | 5566 mw_prpl_info.protocol_options = l; |
5567 l = NULL; | |
5568 | |
5569 /* forward all our g_log messages to gaim. Generally all the logging | |
5570 calls are using gaim_log directly, but the g_return macros will | |
5571 get caught here */ | |
5572 log_handler[0] = g_log_set_handler(G_LOG_DOMAIN, logflags, | |
5573 mw_log_handler, NULL); | |
5574 | |
5575 /* redirect meanwhile's logging to gaim's */ | |
5576 log_handler[1] = g_log_set_handler("meanwhile", logflags, | |
5577 mw_log_handler, NULL); | |
5578 } | |
5579 | |
5580 | |
11949
47e1723a89d7
[gaim-migrate @ 14240]
Christopher O'Brien <siege@pidgin.im>
parents:
11943
diff
changeset
|
5581 GAIM_INIT_PLUGIN(sametime, mw_plugin_init, mw_plugin_info); |
10977 | 5582 /* The End. */ |
5583 |