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