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