Mercurial > pidgin
annotate src/protocols/zephyr/zephyr.c @ 9478:0efa260e384f
[gaim-migrate @ 10303]
" This patch adds the following features for zephyr, in order
of usefulness :-)
Protocol action (Retrieve subscriptions from server) to
list user's subscriptions (chats) in a popup window.
Typing notification - (both sending and receiving --
using zephyrs with opcode ping).
Correct interpretation of %host% and %canon% entries in
.zephyr.subs . These are often used to subscribe to
system messages concerning a specific machine (by
hostname and canonical hostname, respectively).
An updated .todo list." --Arun A Tharuvai
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Wed, 07 Jul 2004 21:56:57 +0000 |
parents | 7a65fdba750f |
children | 8b2451878e26 |
rev | line source |
---|---|
2086 | 1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ |
2 /* | |
3 * gaim | |
4 * | |
5 * Copyright (C) 1998-2001, Mark Spencer <markster@marko.net> | |
6 * Some code borrowed from GtkZephyr, by | |
7084
0909ebf6fb28
[gaim-migrate @ 7649]
Christian Hammond <chipx86@chipx86.com>
parents:
7070
diff
changeset
|
7 * Jag/Sean Dilda <agrajag@linuxpower.org>/<smdilda@unity.ncsu.edu> |
0909ebf6fb28
[gaim-migrate @ 7649]
Christian Hammond <chipx86@chipx86.com>
parents:
7070
diff
changeset
|
8 * http://gtkzephyr.linuxpower.org/ |
2086 | 9 * |
10 * This program is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
12 * the Free Software Foundation; either version 2 of the License, or | |
13 * (at your option) any later version. | |
14 * | |
15 * This program is distributed in the hope that it will be useful, | |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 * GNU General Public License for more details. | |
19 * | |
20 * You should have received a copy of the GNU General Public License | |
21 * along with this program; if not, write to the Free Software | |
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
23 * | |
24 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
25 /* XXX eww */ |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
26 #include "src/internal.h" |
2086 | 27 |
8212 | 28 #include "accountopt.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
29 #include "debug.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
30 #include "multi.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
31 #include "notify.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
32 #include "prpl.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
33 #include "server.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
34 #include "util.h" |
9434 | 35 #include "cmds.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
36 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
37 #include "zephyr/zephyr.h" |
9478 | 38 #include "internal.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
39 |
8386 | 40 #include <strings.h> |
41 | |
8560 | 42 #define ZEPHYR_FALLBACK_CHARSET "ISO-8859-1" |
43 | |
9478 | 44 /* these are deliberately high, since most people don't send multiple "PING"s */ |
45 #define ZEPHYR_TYPING_SEND_TIMEOUT 15 | |
46 #define ZEPHYR_TYPING_RECV_TIMEOUT 10 | |
47 | |
2086 | 48 extern Code_t ZGetLocations(ZLocations_t *, int *); |
49 extern Code_t ZSetLocation(char *); | |
50 extern Code_t ZUnsetLocation(); | |
9478 | 51 extern Code_t ZGetSubscriptions(ZSubscription_t *, int*); |
2086 | 52 |
53 typedef struct _zframe zframe; | |
54 typedef struct _zephyr_triple zephyr_triple; | |
55 | |
9478 | 56 char ourhost[MAXHOSTNAMELEN]; |
57 char ourhostcanon[MAXHOSTNAMELEN]; | |
58 | |
2086 | 59 /* struct I need for zephyr_to_html */ |
60 struct _zframe { | |
61 /* true for everything but @color, since inside the parens of that one is | |
8644 | 62 * the color. */ |
2086 | 63 gboolean has_closer; |
64 /* </i>, </font>, </b>, etc. */ | |
65 char *closing; | |
66 /* text including the opening html thingie. */ | |
67 GString *text; | |
68 struct _zframe *enclosing; | |
69 }; | |
70 | |
71 struct _zephyr_triple { | |
72 char *class; | |
73 char *instance; | |
74 char *recipient; | |
75 char *name; | |
76 gboolean open; | |
77 int id; | |
78 }; | |
79 | |
80 #define z_call(func) if (func != ZERR_NONE)\ | |
81 return; | |
82 #define z_call_r(func) if (func != ZERR_NONE)\ | |
83 return TRUE; | |
84 #define z_call_s(func, err) if (func != ZERR_NONE) {\ | |
5606 | 85 gaim_connection_error(zgc, err);\ |
2086 | 86 return;\ |
87 } | |
88 | |
9328 | 89 char *local_zephyr_normalize(const char *); |
7322 | 90 static const char *zephyr_normalize(const GaimAccount *, const char *); |
9328 | 91 static const char *gaim_zephyr_get_realm(); |
9434 | 92 static void zephyr_chat_set_topic(GaimConnection * gc, int id, const char *topic); |
9328 | 93 |
94 char *zephyr_strip_foreign_realm(const char* user){ | |
95 /* | |
96 Takes in a username of the form username or username@realm | |
97 and returns: | |
98 username, if there is no realm, or the realm is the local realm | |
99 or: | |
100 username@realm if there is a realm and it is foreign | |
101 */ | |
102 char *tmp = g_strdup(user); | |
103 char *at = strchr(tmp,'@'); | |
104 if (at && !g_ascii_strcasecmp(at+1,gaim_zephyr_get_realm())) { | |
105 /* We're passed in a username of the form user@users-realm */ | |
106 char* tmp2; | |
107 *at = '\0'; | |
108 tmp2 = g_strdup(tmp); | |
109 g_free(tmp); | |
110 return tmp2; | |
111 } | |
112 else { | |
113 /* We're passed in a username of the form user or user@foreign-realm */ | |
114 return tmp; | |
115 } | |
116 } | |
2086 | 117 |
118 /* this is so bad, and if Zephyr weren't so fucked up to begin with I | |
119 * wouldn't do this. but it is so i will. */ | |
120 static guint32 nottimer = 0; | |
121 static guint32 loctimer = 0; | |
5606 | 122 GaimConnection *zgc = NULL; |
2086 | 123 static GList *pending_zloc_names = NULL; |
124 static GSList *subscrips = NULL; | |
125 static int last_id = 0; | |
9478 | 126 unsigned short zephyr_port; |
9328 | 127 /* just for debugging */ |
2086 | 128 static void handle_unknown(ZNotice_t notice) |
129 { | |
9328 | 130 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_packet: %s\n", notice.z_packet); |
131 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_version: %s\n", notice.z_version); | |
132 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_kind: %d\n", (int)(notice.z_kind)); | |
133 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_class: %s\n", notice.z_class); | |
134 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_class_inst: %s\n", notice.z_class_inst); | |
135 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_opcode: %s\n", notice.z_opcode); | |
136 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_sender: %s\n", notice.z_sender); | |
137 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_recipient: %s\n", notice.z_recipient); | |
138 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_message: %s\n", notice.z_message); | |
139 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_message_len: %d\n", notice.z_message_len); | |
2086 | 140 } |
9328 | 141 |
2086 | 142 |
143 static zephyr_triple *new_triple(const char *c, const char *i, const char *r) | |
144 { | |
145 zephyr_triple *zt; | |
8644 | 146 |
2086 | 147 zt = g_new0(zephyr_triple, 1); |
148 zt->class = g_strdup(c); | |
149 zt->instance = g_strdup(i); | |
150 zt->recipient = g_strdup(r); | |
151 zt->name = g_strdup_printf("%s,%s,%s", c, i, r); | |
152 zt->id = ++last_id; | |
153 zt->open = FALSE; | |
154 return zt; | |
155 } | |
156 | |
8644 | 157 static void free_triple(zephyr_triple * zt) |
2086 | 158 { |
159 g_free(zt->class); | |
160 g_free(zt->instance); | |
161 g_free(zt->recipient); | |
162 g_free(zt->name); | |
163 g_free(zt); | |
164 } | |
165 | |
9478 | 166 static gchar *gaim_zephyr_get_sender() |
8644 | 167 { |
8568 | 168 /* will be useful once this plugin can use a backend other |
169 than libzephyr */ | |
9478 | 170 /* XXX add zephyr error reporting */ |
171 gchar *sender; | |
172 sender = ZGetSender(); | |
173 if (!sender || !g_ascii_strcasecmp(sender,"")) { | |
174 sender = ""; | |
175 } | |
176 return sender; | |
8354 | 177 } |
178 | |
8644 | 179 static const char *gaim_zephyr_get_realm() |
180 { | |
8568 | 181 /* will be useful once this plugin can use a backend other |
182 than libzephyr */ | |
9478 | 183 gchar *realm=NULL; |
184 /* XXX add zephyr error reporting */ | |
185 realm= ZGetRealm(); | |
186 return realm; | |
8354 | 187 } |
188 | |
9328 | 189 /* returns true if zt1 is a subset of zt2. This function is used to |
190 determine whether a zephyr sent to zt1 should be placed in the chat | |
191 with triple zt2 | |
192 | |
193 zt1 is a subset of zt2 | |
194 iff. the classnames are identical ignoring case | |
195 AND. the instance names are identical (ignoring case), or zt2->instance is *. | |
196 AND. the recipient names are identical | |
197 */ | |
198 | |
8644 | 199 static gboolean triple_subset(zephyr_triple * zt1, zephyr_triple * zt2) |
2086 | 200 { |
9328 | 201 if (g_ascii_strcasecmp(zt2->class, zt1->class)) { |
2086 | 202 return FALSE; |
203 } | |
8644 | 204 if (g_ascii_strcasecmp(zt2->instance, zt1->instance) && g_ascii_strcasecmp(zt2->instance, "*")) { |
2086 | 205 return FALSE; |
206 } | |
9328 | 207 if (g_ascii_strcasecmp(zt2->recipient, zt1->recipient)) { |
2086 | 208 return FALSE; |
209 } | |
210 return TRUE; | |
211 } | |
212 | |
8644 | 213 static zephyr_triple *find_sub_by_triple(zephyr_triple * zt) |
2086 | 214 { |
215 zephyr_triple *curr_t; | |
216 GSList *curr = subscrips; | |
8644 | 217 |
2086 | 218 while (curr) { |
219 curr_t = curr->data; | |
220 if (triple_subset(zt, curr_t)) | |
221 return curr_t; | |
222 curr = curr->next; | |
223 } | |
224 return NULL; | |
225 } | |
226 | |
227 static zephyr_triple *find_sub_by_id(int id) | |
228 { | |
229 zephyr_triple *zt; | |
230 GSList *curr = subscrips; | |
8644 | 231 |
2086 | 232 while (curr) { |
233 zt = curr->data; | |
234 if (zt->id == id) | |
235 return zt; | |
236 curr = curr->next; | |
237 } | |
238 return NULL; | |
239 } | |
240 | |
9328 | 241 /* |
9434 | 242 Converts strings to utf-8 if necessary using user specified encoding |
9328 | 243 */ |
244 | |
9434 | 245 static gchar *zephyr_recv_convert(gchar *string, int len) |
8560 | 246 { |
247 gchar *utf8; | |
248 GError *err = NULL; | |
8644 | 249 |
250 if (g_utf8_validate(string, len, NULL)) { | |
8568 | 251 return g_strdup(string); |
252 } else { | |
8644 | 253 utf8 = g_convert(string, len, "UTF-8", gaim_account_get_string(zgc->account, "encoding", ZEPHYR_FALLBACK_CHARSET), NULL, NULL, &err); |
8568 | 254 if (err) { |
255 gaim_debug(GAIM_DEBUG_ERROR, "zephyr", "recv conversion error: %s\n", err->message); | |
256 utf8 = g_strdup(_("(There was an error converting this message. Check the 'Encoding' option in the Account Editor)")); | |
8954 | 257 g_error_free(err); |
8568 | 258 } |
259 | |
260 return utf8; | |
261 } | |
8560 | 262 } |
263 | |
2086 | 264 /* utility macros that are useful for zephyr_to_html */ |
265 | |
266 #define IS_OPENER(c) ((c == '{') || (c == '[') || (c == '(') || (c == '<')) | |
267 #define IS_CLOSER(c) ((c == '}') || (c == ']') || (c == ')') || (c == '>')) | |
268 | |
8451 | 269 /* This parses HTML formatting (put out by one of the gtkimhtml widgets |
270 And converts it to zephyr formatting. | |
271 It currently deals properly with <b>, <br>, <i>, <font face=...>, <font color=...>, | |
272 It ignores <font back=...> | |
273 It does | |
274 <font size = "1 or 2" -> @small | |
275 3 or 4 @medium() | |
276 5,6, or 7 @large() | |
277 <a href is dealt with by ignoring the description and outputting the link | |
278 */ | |
279 | |
280 static char *html_to_zephyr(const char *message) | |
281 { | |
8644 | 282 int len, cnt, retcount; |
283 char *ret; | |
284 | |
285 len = strlen(message); | |
9478 | 286 if (!len) |
287 return g_strdup(""); | |
288 | |
8644 | 289 ret = g_new0(char, len * 3); |
290 | |
291 bzero(ret, len * 3); | |
292 retcount = 0; | |
293 cnt = 0; | |
294 while (cnt <= len) { | |
295 if (message[cnt] == '<') { | |
296 if (!g_ascii_strncasecmp(message + cnt + 1, "i>", 2)) { | |
297 strncpy(ret + retcount, "@i(", 3); | |
298 cnt += 3; | |
299 retcount += 3; | |
300 } else if (!g_ascii_strncasecmp(message + cnt + 1, "b>", 2)) { | |
301 strncpy(ret + retcount, "@b(", 3); | |
302 cnt += 3; | |
303 retcount += 3; | |
304 } else if (!g_ascii_strncasecmp(message + cnt + 1, "br>", 3)) { | |
305 strncpy(ret + retcount, "\n", 1); | |
306 cnt += 4; | |
307 retcount += 1; | |
308 } else if (!g_ascii_strncasecmp(message + cnt + 1, "a href=\"", 8)) { | |
309 cnt += 9; | |
310 while (g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) { | |
311 ret[retcount] = message[cnt]; | |
312 retcount++; | |
313 cnt++; | |
314 } | |
315 cnt += 2; | |
316 /* ignore descriptive string */ | |
317 while (g_ascii_strncasecmp(message + cnt, "</a>", 4) != 0) { | |
318 cnt++; | |
319 } | |
320 cnt += 4; | |
321 } else if (!g_ascii_strncasecmp(message + cnt + 1, "font", 4)) { | |
322 cnt += 5; | |
323 while (!g_ascii_strncasecmp(message + cnt, " ", 1)) | |
324 cnt++; | |
325 if (!g_ascii_strncasecmp(message + cnt, "color=\"", 7)) { | |
326 cnt += 7; | |
327 strncpy(ret + retcount, "@color(", 7); | |
328 retcount += 7; | |
329 while (g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) { | |
330 ret[retcount] = message[cnt]; | |
331 retcount++; | |
332 cnt++; | |
333 } | |
334 ret[retcount] = ')'; | |
335 retcount++; | |
336 cnt += 2; | |
337 } else if (!g_ascii_strncasecmp(message + cnt, "face=\"", 6)) { | |
338 cnt += 6; | |
339 strncpy(ret + retcount, "@font(", 6); | |
340 retcount += 6; | |
341 while (g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) { | |
342 ret[retcount] = message[cnt]; | |
343 retcount++; | |
344 cnt++; | |
345 } | |
346 ret[retcount] = ')'; | |
347 retcount++; | |
348 cnt += 2; | |
349 } else if (!g_ascii_strncasecmp(message + cnt, "size=\"", 6)) { | |
350 cnt += 6; | |
351 if ((message[cnt] == '1') || (message[cnt] == '2')) { | |
352 strncpy(ret + retcount, "@small(", 7); | |
353 retcount += 7; | |
354 } else if ((message[cnt] == '3') | |
355 || (message[cnt] == '4')) { | |
356 strncpy(ret + retcount, "@medium(", 8); | |
357 retcount += 8; | |
358 } else if ((message[cnt] == '5') | |
359 || (message[cnt] == '6') | |
360 || (message[cnt] == '7')) { | |
361 strncpy(ret + retcount, "@large(", 7); | |
362 retcount += 7; | |
363 } | |
364 cnt += 3; | |
365 } else { | |
366 /* Drop all unrecognized/misparsed font tags */ | |
367 while (g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) { | |
368 cnt++; | |
369 } | |
370 cnt += 2; | |
371 } | |
372 } else if (!g_ascii_strncasecmp(message + cnt + 1, "/i>", 3) | |
373 || !g_ascii_strncasecmp(message + cnt + 1, "/b>", 3)) { | |
374 cnt += 4; | |
375 ret[retcount] = ')'; | |
376 retcount++; | |
377 } else if (!g_ascii_strncasecmp(message + cnt + 1, "/font>", 6)) { | |
378 cnt += 7; | |
379 strncpy(ret + retcount, "@font(fixed)", 12); | |
380 retcount += 12; | |
381 } else { | |
382 /* Catch all for all unrecognized/misparsed <foo> tage */ | |
383 while (g_ascii_strncasecmp(message + cnt, ">", 1) != 0) { | |
384 ret[retcount] = message[cnt]; | |
385 retcount++; | |
386 cnt++; | |
387 } | |
388 } | |
389 } else { | |
390 /* Duh */ | |
391 ret[retcount] = message[cnt]; | |
392 retcount++; | |
393 cnt++; | |
394 } | |
395 } | |
396 return ret; | |
8451 | 397 } |
398 | |
2086 | 399 /* this parses zephyr formatting and converts it to html. For example, if |
400 * you pass in "@{@color(blue)@i(hello)}" you should get out | |
401 * "<font color=blue><i>hello</i></font>". */ | |
402 static char *zephyr_to_html(char *message) | |
403 { | |
404 int len, cnt; | |
405 zframe *frames, *curr; | |
406 char *ret; | |
407 | |
408 frames = g_new(zframe, 1); | |
409 frames->text = g_string_new(""); | |
410 frames->enclosing = NULL; | |
411 frames->closing = ""; | |
412 frames->has_closer = FALSE; | |
413 | |
414 len = strlen(message); | |
415 cnt = 0; | |
416 while (cnt <= len) { | |
417 if (message[cnt] == '@') { | |
418 zframe *new_f; | |
419 char *buf; | |
420 int end; | |
8644 | 421 |
422 for (end = 1; (cnt + end) <= len && !IS_OPENER(message[cnt + end]) | |
423 && !IS_CLOSER(message[cnt + end]); end++); | |
2086 | 424 buf = g_new0(char, end); |
8644 | 425 |
2086 | 426 if (end) { |
8644 | 427 g_snprintf(buf, end, "%s", message + cnt + 1); |
2086 | 428 } |
8644 | 429 if (!g_ascii_strcasecmp(buf, "italic") || !g_ascii_strcasecmp(buf, "i")) { |
2086 | 430 new_f = g_new(zframe, 1); |
431 new_f->enclosing = frames; | |
432 new_f->text = g_string_new("<i>"); | |
433 new_f->closing = "</i>"; | |
434 new_f->has_closer = TRUE; | |
435 frames = new_f; | |
8644 | 436 cnt += end + 1; /* cnt points to char after opener */ |
437 } else if (!g_ascii_strcasecmp(buf, "small")) { | |
438 new_f = g_new(zframe, 1); | |
439 new_f->enclosing = frames; | |
440 new_f->text = g_string_new("<font size=\"1\">"); | |
441 new_f->closing = "</font>"; | |
442 frames = new_f; | |
443 cnt += end + 1; | |
444 } else if (!g_ascii_strcasecmp(buf, "medium")) { | |
445 new_f = g_new(zframe, 1); | |
446 new_f->enclosing = frames; | |
447 new_f->text = g_string_new("<font size=\"3\">"); | |
448 new_f->closing = "</font>"; | |
449 frames = new_f; | |
450 cnt += end + 1; | |
451 } else if (!g_ascii_strcasecmp(buf, "large")) { | |
452 new_f = g_new(zframe, 1); | |
453 new_f->enclosing = frames; | |
454 new_f->text = g_string_new("<font size=\"7\">"); | |
455 new_f->closing = "</font>"; | |
456 frames = new_f; | |
457 cnt += end + 1; | |
458 } else if (!g_ascii_strcasecmp(buf, "bold") | |
459 || !g_ascii_strcasecmp(buf, "b")) { | |
2086 | 460 new_f = g_new(zframe, 1); |
461 new_f->enclosing = frames; | |
462 new_f->text = g_string_new("<b>"); | |
463 new_f->closing = "</b>"; | |
464 new_f->has_closer = TRUE; | |
465 frames = new_f; | |
8644 | 466 cnt += end + 1; |
467 } else if (!g_ascii_strcasecmp(buf, "font")) { | |
468 cnt += end + 1; | |
8451 | 469 new_f = g_new(zframe, 1); |
470 new_f->enclosing = frames; | |
471 new_f->text = g_string_new("<font face="); | |
472 for (; (cnt <= len) && !IS_CLOSER(message[cnt]); cnt++) { | |
473 g_string_append_c(new_f->text, message[cnt]); | |
474 } | |
8644 | 475 cnt++; /* point to char after closer */ |
8451 | 476 g_string_append_c(new_f->text, '>'); |
477 new_f->closing = "</font>"; | |
478 new_f->has_closer = FALSE; | |
479 frames = new_f; | |
8568 | 480 } else if (!g_ascii_strcasecmp(buf, "color")) { |
8644 | 481 cnt += end + 1; |
2086 | 482 new_f = g_new(zframe, 1); |
483 new_f->enclosing = frames; | |
484 new_f->text = g_string_new("<font color="); | |
485 for (; (cnt <= len) && !IS_CLOSER(message[cnt]); cnt++) { | |
486 g_string_append_c(new_f->text, message[cnt]); | |
487 } | |
8644 | 488 cnt++; /* point to char after closer */ |
2086 | 489 g_string_append_c(new_f->text, '>'); |
490 new_f->closing = "</font>"; | |
491 new_f->has_closer = FALSE; | |
492 frames = new_f; | |
4793 | 493 } else if (!g_ascii_strcasecmp(buf, "")) { |
2086 | 494 new_f = g_new(zframe, 1); |
495 new_f->enclosing = frames; | |
496 new_f->text = g_string_new(""); | |
497 new_f->closing = ""; | |
498 new_f->has_closer = TRUE; | |
499 frames = new_f; | |
8644 | 500 cnt += end + 1; /* cnt points to char after opener */ |
2086 | 501 } else { |
8644 | 502 if ((cnt + end) > len) { |
2086 | 503 g_string_append_c(frames->text, '@'); |
504 cnt++; | |
8644 | 505 } else if (IS_CLOSER(message[cnt + end])) { |
506 /* We have @chars..closer . This is | |
507 merely a sequence of chars that isn't a formatting tag | |
508 */ | |
509 int tmp = cnt; | |
510 | |
511 while (tmp <= cnt + end) { | |
512 g_string_append_c(frames->text, message[tmp]); | |
513 tmp++; | |
514 } | |
515 cnt += end + 1; | |
516 } else { | |
2086 | 517 /* unrecognized thingie. act like it's not there, but we |
518 * still need to take care of the corresponding closer, | |
519 * make a frame that does nothing. */ | |
520 new_f = g_new(zframe, 1); | |
521 new_f->enclosing = frames; | |
522 new_f->text = g_string_new(""); | |
523 new_f->closing = ""; | |
524 new_f->has_closer = TRUE; | |
525 frames = new_f; | |
8644 | 526 cnt += end + 1; /* cnt points to char after opener */ |
2086 | 527 } |
528 } | |
529 } else if (IS_CLOSER(message[cnt])) { | |
530 zframe *popped; | |
531 gboolean last_had_closer; | |
8644 | 532 |
2086 | 533 if (frames->enclosing) { |
534 do { | |
535 popped = frames; | |
536 frames = frames->enclosing; | |
537 g_string_append(frames->text, popped->text->str); | |
538 g_string_append(frames->text, popped->closing); | |
539 g_string_free(popped->text, TRUE); | |
540 last_had_closer = popped->has_closer; | |
541 g_free(popped); | |
542 } while (frames && frames->enclosing && !last_had_closer); | |
543 } else { | |
544 g_string_append_c(frames->text, message[cnt]); | |
545 } | |
546 cnt++; | |
547 } else if (message[cnt] == '\n') { | |
548 g_string_append(frames->text, "<br>"); | |
549 cnt++; | |
550 } else { | |
551 g_string_append_c(frames->text, message[cnt++]); | |
552 } | |
553 } | |
554 /* go through all the stuff that they didn't close */ | |
555 while (frames->enclosing) { | |
556 curr = frames; | |
557 g_string_append(frames->enclosing->text, frames->text->str); | |
558 g_string_append(frames->enclosing->text, frames->closing); | |
559 g_string_free(frames->text, TRUE); | |
560 frames = frames->enclosing; | |
561 g_free(curr); | |
562 } | |
563 ret = frames->text->str; | |
564 g_string_free(frames->text, FALSE); | |
565 g_free(frames); | |
566 return ret; | |
567 } | |
568 | |
569 static gboolean pending_zloc(char *who) | |
570 { | |
571 GList *curr; | |
8644 | 572 |
2086 | 573 for (curr = pending_zloc_names; curr != NULL; curr = curr->next) { |
9328 | 574 char* normalized_who = local_zephyr_normalize(who); |
575 if (!g_ascii_strcasecmp(normalized_who, (char *)curr->data)) { | |
8644 | 576 g_free((char *)curr->data); |
2086 | 577 pending_zloc_names = g_list_remove(pending_zloc_names, curr->data); |
578 return TRUE; | |
579 } | |
580 } | |
581 return FALSE; | |
582 } | |
583 | |
9328 | 584 /* Called when the server notifies us a message couldn't get sent */ |
585 | |
8559 | 586 static void message_failed(ZNotice_t notice, struct sockaddr_in from) |
587 { | |
8644 | 588 if (g_ascii_strcasecmp(notice.z_class, "message")) { |
9328 | 589 gchar* chat_failed = g_strdup_printf(_("Unable send to chat %s,%s,%s"),notice.z_class,notice.z_class_inst,notice.z_recipient); |
590 gaim_notify_error(zgc,"",chat_failed,NULL); | |
591 g_free(chat_failed); | |
8644 | 592 } else { |
593 gaim_notify_error(zgc, notice.z_recipient, _("User is offline"), NULL); | |
594 } | |
8559 | 595 } |
596 | |
2086 | 597 static void handle_message(ZNotice_t notice, struct sockaddr_in from) |
598 { | |
4793 | 599 if (!g_ascii_strcasecmp(notice.z_class, LOGIN_CLASS)) { |
3277 | 600 /* well, we'll be updating in 20 seconds anyway, might as well ignore this. */ |
4793 | 601 } else if (!g_ascii_strcasecmp(notice.z_class, LOCATE_CLASS)) { |
602 if (!g_ascii_strcasecmp(notice.z_opcode, LOCATE_LOCATE)) { | |
2086 | 603 int nlocs; |
604 char *user; | |
6695 | 605 GaimBuddy *b; |
2086 | 606 |
9478 | 607 /* XXX add real error reporting */ |
2086 | 608 if (ZParseLocations(¬ice, NULL, &nlocs, &user) != ZERR_NONE) |
609 return; | |
8435 | 610 |
8644 | 611 if ((b = gaim_find_buddy(zgc->account, user)) == NULL) { |
2086 | 612 char *e = strchr(user, '@'); |
8644 | 613 |
614 if (e && !g_ascii_strcasecmp(e + 1, gaim_zephyr_get_realm())) { | |
615 *e = '\0'; | |
616 } | |
4687 | 617 b = gaim_find_buddy(zgc->account, user); |
8644 | 618 } |
619 if ((b && pending_zloc(b->name)) || pending_zloc(user)) { | |
2086 | 620 ZLocations_t locs; |
621 int one = 1; | |
622 GString *str = g_string_new(""); | |
8644 | 623 |
624 g_string_append_printf(str, _("<b>User:</b> %s<br>"), b ? b->name : user); | |
8435 | 625 if (b && b->alias) |
5132 | 626 g_string_append_printf(str, _("<b>Alias:</b> %s<br>"), b->alias); |
2086 | 627 if (!nlocs) { |
5132 | 628 g_string_append_printf(str, _("<br>Hidden or not logged-in")); |
2086 | 629 } |
630 for (; nlocs > 0; nlocs--) { | |
9478 | 631 /* XXX add real error reporting */ |
2086 | 632 ZGetLocations(&locs, &one); |
8644 | 633 g_string_append_printf(str, _("<br>At %s since %s"), locs.host, locs.time); |
2086 | 634 } |
8644 | 635 gaim_notify_formatted(zgc, NULL, _("Buddy Information"), NULL, str->str, NULL, NULL); |
2086 | 636 g_string_free(str, TRUE); |
637 } else | |
4732 | 638 serv_got_update(zgc, b->name, nlocs, 0, 0, 0, 0); |
2086 | 639 |
9434 | 640 g_free(user); |
2086 | 641 } |
642 } else { | |
8560 | 643 char *buf, *buf2, *buf3; |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
644 char *send_inst; |
8644 | 645 GaimConversation *gconv1; |
646 GaimConvChat *gcc; | |
2086 | 647 char *ptr = notice.z_message + strlen(notice.z_message) + 1; |
9478 | 648 int len; |
8644 | 649 char *sendertmp = g_strdup_printf("%s", gaim_zephyr_get_sender()); |
9478 | 650 int signature_length = strlen(notice.z_message); |
651 int message_has_no_body = 0; | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7084
diff
changeset
|
652 GaimConvImFlags flags = 0; |
8644 | 653 gchar *tmpescape; |
8560 | 654 |
9478 | 655 /* Need to deal with 0 length messages to handle typing notification (OPCODE) ping messages */ |
656 /* One field zephyrs would have caused gaim to crash */ | |
657 if ( (notice.z_message_len == 0) || (signature_length >= notice.z_message_len - 1)) { | |
658 message_has_no_body = 1; | |
659 len = 0; | |
660 gaim_debug_info("zephyr","message_size %d %d %d\n",len,notice.z_message_len,signature_length); | |
661 buf3 = g_strdup(""); | |
662 | |
663 } else { | |
664 len = notice.z_message_len - ( signature_length +1); | |
665 gaim_debug_info("zephyr","message_size %d %d %d\n",len,notice.z_message_len,signature_length); | |
8644 | 666 buf = g_malloc(len + 1); |
667 g_snprintf(buf, len + 1, "%s", ptr); | |
668 g_strchomp(buf); | |
669 tmpescape = gaim_escape_html(buf); | |
9478 | 670 g_free(buf); |
8644 | 671 buf2 = zephyr_to_html(tmpescape); |
672 buf3 = zephyr_recv_convert(buf2, strlen(buf2)); | |
673 g_free(buf2); | |
674 g_free(tmpescape); | |
9478 | 675 } |
8644 | 676 |
9328 | 677 if (!g_ascii_strcasecmp(notice.z_class, "MESSAGE") && !g_ascii_strcasecmp(notice.z_class_inst, "PERSONAL") |
678 && !g_ascii_strcasecmp(notice.z_recipient,gaim_zephyr_get_sender())) { | |
679 gchar* stripped_sender; | |
4793 | 680 if (!g_ascii_strcasecmp(notice.z_message, "Automated reply:")) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7084
diff
changeset
|
681 flags |= GAIM_CONV_IM_AUTO_RESP; |
9328 | 682 stripped_sender = zephyr_strip_foreign_realm(notice.z_sender); |
9478 | 683 |
684 if (!g_ascii_strcasecmp(notice.z_opcode,"PING")) | |
685 serv_got_typing(zgc,stripped_sender,ZEPHYR_TYPING_RECV_TIMEOUT, GAIM_TYPING); | |
686 else | |
9328 | 687 serv_got_im(zgc, stripped_sender, buf3, flags, time(NULL)); |
9478 | 688 |
9328 | 689 g_free(stripped_sender); |
2086 | 690 } else { |
691 zephyr_triple *zt1, *zt2; | |
9437 | 692 GList *gltmp; |
693 int found = 0; | |
694 gchar *send_inst_utf8; | |
695 | |
8644 | 696 zt1 = new_triple(notice.z_class, notice.z_class_inst, notice.z_recipient); |
2086 | 697 zt2 = find_sub_by_triple(zt1); |
698 if (!zt2) { | |
9434 | 699 /* This is a server supplied subscription */ |
700 subscrips = g_slist_append(subscrips, zt1); | |
701 zt2 = find_sub_by_triple(zt1); | |
702 } | |
703 | |
9437 | 704 if (!zt2->open) { |
705 zt2->open = TRUE; | |
706 serv_got_joined_chat(zgc, zt2->id, zt2->name); | |
707 zephyr_chat_set_topic(zgc,zt2->id,notice.z_class_inst); | |
708 } | |
709 g_free(sendertmp); /* fix memory leak? */ | |
710 /* If the person is in the default Realm, then strip the | |
711 Realm from the sender field */ | |
712 sendertmp = zephyr_strip_foreign_realm(notice.z_sender); | |
713 send_inst = g_strdup_printf("%s %s",sendertmp,notice.z_class_inst); | |
714 send_inst_utf8 = zephyr_recv_convert(send_inst, strlen(send_inst)); | |
715 if (!send_inst_utf8) { | |
716 gaim_debug(GAIM_DEBUG_ERROR, "zephyr","send_inst %s became null\n", send_inst); | |
717 send_inst_utf8 = "malformed instance"; | |
718 } | |
719 | |
720 serv_got_chat_in(zgc, zt2->id, send_inst_utf8, FALSE, buf3, time(NULL)); | |
721 g_free(send_inst); | |
722 gconv1 = gaim_find_conversation_with_account(zt2->name, zgc->account); | |
723 gcc = gaim_conversation_get_chat_data(gconv1); | |
724 | |
725 for (gltmp = gaim_conv_chat_get_users(gcc); gltmp; gltmp = gltmp->next) { | |
726 if (!g_ascii_strcasecmp(gltmp->data, sendertmp)) | |
727 found = 1; | |
728 } | |
729 if (!found) { | |
730 /* force interpretation in network byte order */ | |
731 unsigned char *addrs = (unsigned char *)&(notice.z_sender_addr.s_addr); | |
732 gchar* ipaddr = g_strdup_printf("%hhd.%hhd.%hhd.%hhd", (unsigned char)addrs[0], | |
733 (unsigned char)addrs[1], (unsigned char)addrs[2], | |
734 (unsigned char) addrs[3]); | |
735 | |
736 gaim_conv_chat_add_user(gcc, sendertmp, ipaddr); | |
737 g_free(ipaddr); /* fix memory leak? */ | |
738 | |
739 } | |
740 g_free(sendertmp); | |
741 g_free(send_inst_utf8); | |
742 | |
2086 | 743 free_triple(zt1); |
744 } | |
8560 | 745 g_free(buf3); |
9478 | 746 |
2086 | 747 } |
748 } | |
749 | |
750 static gint check_notify(gpointer data) | |
751 { | |
9478 | 752 /* XXX add real error reporting */ |
753 | |
2086 | 754 while (ZPending()) { |
755 ZNotice_t notice; | |
756 struct sockaddr_in from; | |
9478 | 757 /* XXX add real error reporting */ |
8644 | 758 |
2086 | 759 z_call_r(ZReceiveNotice(¬ice, &from)); |
760 | |
761 switch (notice.z_kind) { | |
762 case UNSAFE: | |
763 case UNACKED: | |
764 case ACKED: | |
765 handle_message(notice, from); | |
766 break; | |
8644 | 767 case SERVACK: |
768 if (!(g_ascii_strcasecmp(notice.z_message, ZSRVACK_NOTSENT))) { | |
769 message_failed(notice, from); | |
770 } | |
771 break; | |
9328 | 772 case CLIENTACK: |
9478 | 773 gaim_debug_error("zephyr", "Client ack received\n"); |
2086 | 774 default: |
775 /* we'll just ignore things for now */ | |
9328 | 776 handle_unknown(notice); |
9478 | 777 gaim_debug_error("zephyr", "Unhandled notice.\n"); |
2086 | 778 break; |
779 } | |
9478 | 780 /* XXX add real error reporting */ |
2086 | 781 ZFreeNotice(¬ice); |
782 } | |
783 | |
784 return TRUE; | |
785 } | |
786 | |
787 static gint check_loc(gpointer data) | |
788 { | |
6695 | 789 GaimBlistNode *gnode, *cnode, *bnode; |
2086 | 790 ZAsyncLocateData_t ald; |
791 | |
792 ald.user = NULL; | |
793 memset(&(ald.uid), 0, sizeof(ZUnique_Id_t)); | |
794 ald.version = NULL; | |
795 | |
8644 | 796 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
797 if (!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
4785 | 798 continue; |
8644 | 799 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
800 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 801 continue; |
8644 | 802 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
803 GaimBuddy *b = (GaimBuddy *) bnode; | |
804 | |
805 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
6695 | 806 continue; |
8644 | 807 if (b->account->gc == zgc) { |
7261 | 808 const char *chk; |
8644 | 809 |
8354 | 810 chk = local_zephyr_normalize(b->name); |
9478 | 811 /* XXX add real error reporting */ |
6695 | 812 /* doesn't matter if this fails or not; we'll just move on to the next one */ |
813 ZRequestLocations(chk, &ald, UNACKED, ZAUTH); | |
9434 | 814 g_free(ald.user); |
815 g_free(ald.version); | |
6695 | 816 } |
4349 | 817 } |
2086 | 818 } |
819 } | |
820 | |
821 return TRUE; | |
822 } | |
823 | |
824 static char *get_exposure_level() | |
825 { | |
9478 | 826 /* XXX add real error reporting */ |
2086 | 827 char *exposure = ZGetVariable("exposure"); |
828 | |
829 if (!exposure) | |
830 return EXPOSE_REALMVIS; | |
4793 | 831 if (!g_ascii_strcasecmp(exposure, EXPOSE_NONE)) |
2086 | 832 return EXPOSE_NONE; |
4793 | 833 if (!g_ascii_strcasecmp(exposure, EXPOSE_OPSTAFF)) |
2086 | 834 return EXPOSE_OPSTAFF; |
4793 | 835 if (!g_ascii_strcasecmp(exposure, EXPOSE_REALMANN)) |
2086 | 836 return EXPOSE_REALMANN; |
4793 | 837 if (!g_ascii_strcasecmp(exposure, EXPOSE_NETVIS)) |
2086 | 838 return EXPOSE_NETVIS; |
4793 | 839 if (!g_ascii_strcasecmp(exposure, EXPOSE_NETANN)) |
2086 | 840 return EXPOSE_NETANN; |
841 return EXPOSE_REALMVIS; | |
842 } | |
843 | |
844 static void strip_comments(char *str) | |
845 { | |
846 char *tmp = strchr(str, '#'); | |
8644 | 847 |
2086 | 848 if (tmp) |
849 *tmp = '\0'; | |
850 g_strchug(str); | |
851 g_strchomp(str); | |
852 } | |
853 | |
9478 | 854 static void zephyr_inithosts() |
855 { | |
856 /* XXX This code may not be Win32 clean */ | |
857 struct hostent *hent; | |
858 | |
859 if (gethostname(ourhost, sizeof(ourhost)-1) == -1) { | |
860 gaim_debug(GAIM_DEBUG_ERROR, "zephyr", "unable to retrieve hostname, %%host%% and %%canon%% will be wrong in subscriptions and have been set to unknown\n"); | |
861 g_stpcpy(ourhost,"unknown"); | |
862 g_stpcpy(ourhostcanon,"unknown"); | |
863 return; | |
864 } | |
865 | |
866 if (!(hent = gethostbyname(ourhost))) { | |
867 gaim_debug(GAIM_DEBUG_ERROR,"zephyr", "unable to resolve hostname, %%canon%% will be wrong in subscriptions.and has been set to the value of %%host%%, %s\n",ourhost); | |
868 g_stpcpy(ourhostcanon,ourhost); | |
869 return; | |
870 } | |
871 g_stpcpy(ourhostcanon,hent->h_name); | |
872 return; | |
873 } | |
874 | |
2086 | 875 static void process_zsubs() |
876 { | |
9434 | 877 /* Loads zephyr chats "(subscriptions) from ~/.zephyr.subs, and |
878 registers (subscribes to) them on the server */ | |
879 | |
880 /* XXX deal with unsubscriptions */ | |
881 /* XXX deal with punts */ | |
882 | |
2086 | 883 FILE *f; |
884 gchar *fname; | |
885 gchar buff[BUFSIZ]; | |
8644 | 886 |
9478 | 887 zephyr_inithosts(); |
3630 | 888 fname = g_strdup_printf("%s/.zephyr.subs", gaim_home_dir()); |
2086 | 889 f = fopen(fname, "r"); |
890 if (f) { | |
891 char **triple; | |
892 ZSubscription_t sub; | |
893 char *recip; | |
9478 | 894 char *z_class; |
895 char *z_instance; | |
8644 | 896 |
2086 | 897 while (fgets(buff, BUFSIZ, f)) { |
898 strip_comments(buff); | |
899 if (buff[0]) { | |
900 triple = g_strsplit(buff, ",", 3); | |
8644 | 901 if (triple[0] && triple[1]) { |
902 char *tmp = g_strdup_printf("%s", gaim_zephyr_get_sender()); | |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
903 char *atptr; |
8644 | 904 |
2086 | 905 sub.zsub_class = triple[0]; |
906 sub.zsub_classinst = triple[1]; | |
8644 | 907 if (triple[2] == NULL) { |
3277 | 908 recip = g_malloc0(1); |
4793 | 909 } else if (!g_ascii_strcasecmp(triple[2], "%me%")) { |
8644 | 910 recip = g_strdup_printf("%s", gaim_zephyr_get_sender()); |
4793 | 911 } else if (!g_ascii_strcasecmp(triple[2], "*")) { |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
912 /* wildcard |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
913 * form of class,instance,* */ |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
914 recip = g_malloc0(1); |
4793 | 915 } else if (!g_ascii_strcasecmp(triple[2], tmp)) { |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
916 /* form of class,instance,aatharuv@ATHENA.MIT.EDU */ |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
917 recip = g_strdup(triple[2]); |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
918 } else if ((atptr = strchr(triple[2], '@')) != NULL) { |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
919 /* form of class,instance,*@ANDREW.CMU.EDU |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
920 * class,instance,@ANDREW.CMU.EDU |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
921 * If realm is local realm, blank recipient, else |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
922 * @REALM-NAME |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
923 */ |
8644 | 924 char *realmat = g_strdup_printf("@%s", |
925 gaim_zephyr_get_realm()); | |
926 | |
4793 | 927 if (!g_ascii_strcasecmp(atptr, realmat)) |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
928 recip = g_malloc0(1); |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
929 else |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
930 recip = g_strdup(atptr); |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
931 g_free(realmat); |
2086 | 932 } else { |
933 recip = g_strdup(triple[2]); | |
934 } | |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
935 g_free(tmp); |
2086 | 936 sub.zsub_recipient = recip; |
9478 | 937 |
938 if (!g_ascii_strcasecmp(triple[0],"%host%")) { | |
939 z_class = g_strdup(ourhost); | |
940 } else if (!g_ascii_strcasecmp(triple[0],"%canon%")) { | |
941 z_class = g_strdup(ourhostcanon); | |
942 } else { | |
943 z_class = g_strdup(triple[0]); | |
944 } | |
945 sub.zsub_class = z_class; | |
946 | |
947 if (!g_ascii_strcasecmp(triple[1],"%host%")) { | |
948 z_instance = g_strdup(ourhost); | |
949 } else if (!g_ascii_strcasecmp(triple[1],"%canon%")) { | |
950 z_instance = g_strdup(ourhostcanon); | |
951 } else { | |
952 z_instance = g_strdup(triple[1]); | |
953 } | |
954 sub.zsub_classinst = z_instance; | |
955 | |
956 /* There should be some sort of error report listing classes that couldn't be subbed to. | |
957 Not important right now though */ | |
958 | |
2086 | 959 if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) { |
9478 | 960 |
8644 | 961 gaim_debug(GAIM_DEBUG_ERROR, "zephyr", "Couldn't subscribe to %s, %s, %s\n", sub.zsub_class, sub.zsub_classinst, sub.zsub_recipient); |
2086 | 962 } |
9478 | 963 |
964 subscrips = g_slist_append(subscrips, new_triple(sub.zsub_class,sub.zsub_classinst,sub.zsub_recipient)); | |
965 /* g_hash_table_destroy(sub_hash_table); */ | |
966 g_free(z_instance); | |
967 g_free(z_class); | |
2086 | 968 g_free(recip); |
969 } | |
970 g_strfreev(triple); | |
971 } | |
972 } | |
973 } | |
974 } | |
975 | |
976 static void process_anyone() | |
977 { | |
978 FILE *fd; | |
979 gchar buff[BUFSIZ], *filename; | |
6695 | 980 GaimGroup *g; |
981 GaimBuddy *b; | |
4775 | 982 |
983 if (!(g = gaim_find_group(_("Anyone")))) { | |
984 g = gaim_group_new(_("Anyone")); | |
985 gaim_blist_add_group(g, NULL); | |
986 } | |
6695 | 987 |
3630 | 988 filename = g_strconcat(gaim_home_dir(), "/.anyone", NULL); |
2086 | 989 if ((fd = fopen(filename, "r")) != NULL) { |
990 while (fgets(buff, BUFSIZ, fd)) { | |
991 strip_comments(buff); | |
4687 | 992 if (buff[0]) { |
8644 | 993 if (!(b = gaim_find_buddy(zgc->account, buff))) { |
994 b = gaim_buddy_new(zgc->account, buff, NULL); | |
995 gaim_blist_add_buddy(b, NULL, g, NULL); | |
996 } | |
997 } | |
2086 | 998 } |
999 fclose(fd); | |
1000 } | |
1001 g_free(filename); | |
1002 } | |
1003 | |
8644 | 1004 static void zephyr_login(GaimAccount * account) |
2086 | 1005 { |
1006 ZSubscription_t sub; | |
9427 | 1007 |
9478 | 1008 /* This needs to fixed to deal with multiple accounts somehow */ |
2086 | 1009 if (zgc) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
1010 gaim_notify_error(account->gc, NULL, |
8644 | 1011 _("Already logged in with Zephyr"), _("Because Zephyr uses your system username, you " "are unable to have multiple accounts on it " "when logged in as the same user.")); |
2086 | 1012 return; |
1013 } | |
1014 | |
5606 | 1015 zgc = gaim_account_get_connection(account); |
9478 | 1016 zgc->flags |= GAIM_CONNECTION_HTML | GAIM_CONNECTION_NO_BGCOLOR | GAIM_CONNECTION_NO_URLDESC; |
1017 gaim_connection_update_progress(zgc, _("Connecting"), 0, 8); | |
1018 | |
1019 /* XXX z_call_s should actually try to report the com_err determined error */ | |
8645 | 1020 |
2086 | 1021 z_call_s(ZInitialize(), "Couldn't initialize zephyr"); |
9478 | 1022 z_call_s(ZOpenPort(&zephyr_port), "Couldn't open port"); |
8644 | 1023 z_call_s(ZSetLocation((char *) |
1024 gaim_account_get_string(zgc->account, "exposure_level", EXPOSE_REALMVIS)), "Couldn't set location"); | |
2086 | 1025 |
1026 sub.zsub_class = "MESSAGE"; | |
1027 sub.zsub_classinst = "PERSONAL"; | |
8354 | 1028 sub.zsub_recipient = (char *)gaim_zephyr_get_sender(); |
9427 | 1029 |
2086 | 1030 if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) { |
9478 | 1031 /* XXX don't translate this yet. It could be written better */ |
1032 /* XXX error messages could be handled with more detail */ | |
1033 gaim_notify_error(account->gc, NULL, | |
1034 "Unable to subscribe to messages", "Unable to subscribe to initial messages"); | |
1035 return; | |
2086 | 1036 } |
1037 | |
5606 | 1038 gaim_connection_set_state(zgc, GAIM_CONNECTED); |
2086 | 1039 serv_finish_login(zgc); |
1040 | |
1041 process_anyone(); | |
1042 process_zsubs(); | |
1043 | |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8212
diff
changeset
|
1044 nottimer = gaim_timeout_add(100, check_notify, NULL); |
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8212
diff
changeset
|
1045 loctimer = gaim_timeout_add(20000, check_loc, NULL); |
2086 | 1046 } |
1047 | |
1048 static void write_zsubs() | |
1049 { | |
9434 | 1050 /* Exports subscription (chat) list back to |
1051 * .zephyr.subs | |
1052 * XXX deal with %host%, %canon%, unsubscriptions, and negative subscriptions (punts?) | |
1053 */ | |
1054 | |
2086 | 1055 GSList *s = subscrips; |
1056 zephyr_triple *zt; | |
1057 FILE *fd; | |
1058 char *fname; | |
1059 | |
8644 | 1060 char **triple; |
1061 | |
3630 | 1062 fname = g_strdup_printf("%s/.zephyr.subs", gaim_home_dir()); |
2086 | 1063 fd = fopen(fname, "w"); |
8644 | 1064 |
2086 | 1065 if (!fd) { |
1066 g_free(fname); | |
1067 return; | |
1068 } | |
8644 | 1069 |
2086 | 1070 while (s) { |
9478 | 1071 char *zclass, *zinst, *zrecip; |
2086 | 1072 zt = s->data; |
8644 | 1073 triple = g_strsplit(zt->name, ",", 3); |
9478 | 1074 |
1075 /* deal with classes */ | |
1076 if (!g_ascii_strcasecmp(triple[0],ourhost)) { | |
1077 zclass = g_strdup("%host%");; | |
1078 } else if (!g_ascii_strcasecmp(triple[0],ourhostcanon)) { | |
1079 zclass = g_strdup("%canon%");; | |
1080 } else { | |
1081 zclass = g_strdup(triple[0]); | |
1082 } | |
1083 | |
1084 /* deal with instances */ | |
1085 | |
1086 if (!g_ascii_strcasecmp(triple[1],ourhost)) { | |
1087 zinst = g_strdup("%host%");; | |
1088 } else if (!g_ascii_strcasecmp(triple[1],ourhostcanon)) { | |
1089 zinst = g_strdup("%canon%");; | |
3277 | 1090 } else { |
9478 | 1091 zinst = g_strdup(triple[1]); |
3277 | 1092 } |
9478 | 1093 |
1094 /* deal with recipients */ | |
1095 if (triple[2] == NULL) { | |
1096 zrecip = g_strdup("*"); | |
1097 } else if (!g_ascii_strcasecmp(triple[2],"")){ | |
1098 zrecip = g_strdup("*"); | |
1099 } else if (!g_ascii_strcasecmp(triple[2], gaim_zephyr_get_sender())) { | |
1100 zrecip = g_strdup("%me%"); | |
3277 | 1101 } else { |
9478 | 1102 zrecip = g_strdup(triple[2]); |
3277 | 1103 } |
9478 | 1104 |
1105 fprintf(fd, "%s,%s,%s\n",zclass,zinst,zrecip); | |
1106 | |
1107 g_free(zclass); | |
1108 g_free(zinst); | |
1109 g_free(zrecip); | |
3277 | 1110 g_free(triple); |
2086 | 1111 s = s->next; |
1112 } | |
1113 g_free(fname); | |
1114 fclose(fd); | |
1115 } | |
1116 | |
1117 static void write_anyone() | |
1118 { | |
6695 | 1119 GaimBlistNode *gnode, *cnode, *bnode; |
1120 GaimBuddy *b; | |
3277 | 1121 char *ptr, *fname, *ptr2; |
2086 | 1122 FILE *fd; |
1123 | |
3630 | 1124 fname = g_strdup_printf("%s/.anyone", gaim_home_dir()); |
2086 | 1125 fd = fopen(fname, "w"); |
1126 if (!fd) { | |
1127 g_free(fname); | |
1128 return; | |
1129 } | |
1130 | |
8644 | 1131 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
1132 if (!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
4785 | 1133 continue; |
8644 | 1134 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
1135 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 1136 continue; |
8644 | 1137 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
1138 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
6695 | 1139 continue; |
8644 | 1140 b = (GaimBuddy *) bnode; |
1141 if (b->account == zgc->account) { | |
6695 | 1142 if ((ptr = strchr(b->name, '@')) != NULL) { |
1143 ptr2 = ptr + 1; | |
1144 /* We should only strip the realm name if the principal | |
1145 is in the user's realm | |
8644 | 1146 */ |
1147 if (!g_ascii_strcasecmp(ptr2, gaim_zephyr_get_realm())) { | |
6695 | 1148 *ptr = '\0'; |
1149 } | |
4349 | 1150 } |
6695 | 1151 fprintf(fd, "%s\n", b->name); |
1152 if (ptr) | |
1153 *ptr = '@'; | |
3277 | 1154 } |
1155 } | |
2086 | 1156 } |
1157 } | |
1158 | |
1159 fclose(fd); | |
1160 g_free(fname); | |
1161 } | |
1162 | |
8644 | 1163 static void zephyr_close(GaimConnection * gc) |
2086 | 1164 { |
1165 GList *l; | |
1166 GSList *s; | |
8644 | 1167 |
2086 | 1168 l = pending_zloc_names; |
1169 while (l) { | |
8644 | 1170 g_free((char *)l->data); |
2086 | 1171 l = l->next; |
1172 } | |
1173 g_list_free(pending_zloc_names); | |
8644 | 1174 |
1175 if (gaim_account_get_bool(zgc->account, "write_anyone", FALSE)) | |
8212 | 1176 write_anyone(); |
8644 | 1177 |
1178 if (gaim_account_get_bool(zgc->account, "write_zsubs", FALSE)) | |
8212 | 1179 write_zsubs(); |
8644 | 1180 |
2086 | 1181 s = subscrips; |
1182 while (s) { | |
8644 | 1183 free_triple((zephyr_triple *) s->data); |
2086 | 1184 s = s->next; |
1185 } | |
1186 g_slist_free(subscrips); | |
8644 | 1187 |
2086 | 1188 if (nottimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1189 gaim_timeout_remove(nottimer); |
2086 | 1190 nottimer = 0; |
1191 if (loctimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1192 gaim_timeout_remove(loctimer); |
2086 | 1193 loctimer = 0; |
1194 zgc = NULL; | |
1195 z_call(ZCancelSubscriptions(0)); | |
1196 z_call(ZUnsetLocation()); | |
1197 z_call(ZClosePort()); | |
1198 } | |
1199 | |
9434 | 1200 static int zephyr_send_message(char* zclass, char* instance, char* recipient, const char *im, |
9478 | 1201 const char *sig, char *opcode) ; |
9434 | 1202 |
1203 const char * zephyr_get_signature() | |
1204 { | |
9478 | 1205 /* XXX add zephyr error reporting */ |
1206 const char * sig =ZGetVariable("zwrite-signature"); | |
9434 | 1207 if (!sig) { |
1208 sig = g_get_real_name(); | |
1209 } | |
1210 return sig; | |
1211 } | |
1212 | |
8644 | 1213 static int zephyr_chat_send(GaimConnection * gc, int id, const char *im) |
2086 | 1214 { |
1215 zephyr_triple *zt; | |
1216 const char *sig; | |
8644 | 1217 GaimConversation *gconv1; |
1218 GaimConvChat *gcc; | |
1219 char *inst; | |
9434 | 1220 char *recipient; |
2086 | 1221 |
1222 zt = find_sub_by_id(id); | |
1223 if (!zt) | |
1224 /* this should never happen. */ | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1225 return -EINVAL; |
8644 | 1226 |
9434 | 1227 sig = zephyr_get_signature(); |
2086 | 1228 |
8644 | 1229 gconv1 = gaim_find_conversation_with_account(zt->name, zgc->account); |
1230 gcc = gaim_conversation_get_chat_data(gconv1); | |
8212 | 1231 |
8644 | 1232 if (!(inst = (char *)gaim_conv_chat_get_topic(gcc))) |
9434 | 1233 inst = g_strdup("PERSONAL"); |
8644 | 1234 |
4793 | 1235 if (!g_ascii_strcasecmp(zt->recipient, "*")) |
9434 | 1236 recipient = local_zephyr_normalize(""); |
2086 | 1237 else |
9434 | 1238 recipient = local_zephyr_normalize(zt->recipient); |
8451 | 1239 |
9478 | 1240 zephyr_send_message(zt->class,inst,recipient,im,sig,""); |
9434 | 1241 /* g_free(inst); */ |
1242 /* g_free(recipient); */ | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1243 return 0; |
2086 | 1244 } |
1245 | |
9434 | 1246 |
8644 | 1247 static int zephyr_send_im(GaimConnection * gc, const char *who, const char *im, GaimConvImFlags flags) |
1248 { | |
2086 | 1249 const char *sig; |
8644 | 1250 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7084
diff
changeset
|
1251 if (flags & GAIM_CONV_IM_AUTO_RESP) |
2086 | 1252 sig = "Automated reply:"; |
1253 else { | |
9434 | 1254 sig = zephyr_get_signature(); |
2086 | 1255 } |
9478 | 1256 zephyr_send_message("MESSAGE","PERSONAL",local_zephyr_normalize(who),im,sig,""); |
9434 | 1257 |
1258 return 1; | |
1259 } | |
2086 | 1260 |
9434 | 1261 static int zephyr_send_message(char* zclass, char* instance, char* recipient, const char *im, |
9478 | 1262 const char *sig, char *opcode) |
9434 | 1263 { |
1264 char *html_buf; | |
1265 char *html_buf2; | |
1266 char *buf; | |
1267 ZNotice_t notice; | |
8451 | 1268 |
9434 | 1269 html_buf = html_to_zephyr(im); |
1270 html_buf2 = gaim_unescape_html(html_buf); | |
1271 | |
1272 buf = g_strdup_printf("%s%c%s", sig, '\0', html_buf2); | |
2086 | 1273 bzero((char *)¬ice, sizeof(notice)); |
9434 | 1274 |
2086 | 1275 notice.z_kind = ACKED; |
1276 notice.z_port = 0; | |
1277 notice.z_opcode = ""; | |
9434 | 1278 notice.z_class = zclass; |
1279 notice.z_class_inst = instance; | |
1280 notice.z_recipient = recipient; | |
1281 notice.z_sender = 0; | |
1282 notice.z_default_format = "Class $class, Instance $instance:\n" "To: @bold($recipient) at $time $date\n" "From: @bold($1) <$sender>\n\n$2"; | |
8451 | 1283 notice.z_message_len = strlen(html_buf2) + strlen(sig) + 2; |
2086 | 1284 notice.z_message = buf; |
9478 | 1285 notice.z_opcode = g_strdup(opcode); |
1286 gaim_debug_info("zephyr","About to send notice"); | |
1287 if (! ZSendNotice(¬ice, ZAUTH) == ZERR_NONE) { | |
1288 /* XXX handle errors here */ | |
1289 return 0; | |
1290 } | |
1291 gaim_debug_info("zephyr","notice sent"); | |
1292 g_free(buf); | |
1293 | |
8644 | 1294 g_free(html_buf2); |
1295 g_free(html_buf); | |
8451 | 1296 |
9434 | 1297 return 1; |
2086 | 1298 } |
1299 | |
8644 | 1300 static const char *zephyr_normalize(const GaimAccount * account, const char *orig) |
2086 | 1301 { |
9328 | 1302 /* returns the string you gave it. Maybe this function shouldn't be here */ |
2086 | 1303 static char buf[80]; |
8644 | 1304 |
7126 | 1305 if (!g_ascii_strcasecmp(orig, "")) { |
1306 buf[0] = '\0'; | |
1307 return buf; | |
8354 | 1308 } else { |
8644 | 1309 g_snprintf(buf, 80, "%s", orig); |
1310 } | |
1311 return buf; | |
8354 | 1312 } |
1313 | |
1314 | |
9328 | 1315 char *local_zephyr_normalize(const char *orig) |
8354 | 1316 { |
9328 | 1317 /* |
1318 Basically the inverse of zephyr_strip_foreign_realm | |
1319 */ | |
8644 | 1320 static char buf[80]; |
1321 | |
8354 | 1322 if (!g_ascii_strcasecmp(orig, "")) { |
1323 buf[0] = '\0'; | |
1324 return buf; | |
7126 | 1325 } |
8644 | 1326 |
2086 | 1327 if (strchr(orig, '@')) { |
1328 g_snprintf(buf, 80, "%s", orig); | |
1329 } else { | |
8644 | 1330 g_snprintf(buf, 80, "%s@%s", orig, gaim_zephyr_get_realm()); |
2086 | 1331 } |
1332 return buf; | |
1333 } | |
1334 | |
9030 | 1335 static void zephyr_zloc(GaimConnection *gc, const char *who) |
2086 | 1336 { |
1337 ZAsyncLocateData_t ald; | |
9328 | 1338 gchar* normalized_who = local_zephyr_normalize(who); |
7261 | 1339 |
9328 | 1340 if (ZRequestLocations(normalized_who, &ald, UNACKED, ZAUTH) == ZERR_NONE) { |
9030 | 1341 pending_zloc_names = g_list_append(pending_zloc_names, |
9328 | 1342 g_strdup(normalized_who)); |
9478 | 1343 } else { |
1344 /* XXX deal with errors somehow */ | |
2086 | 1345 } |
1346 } | |
1347 | |
8644 | 1348 static void zephyr_set_away(GaimConnection * gc, const char *state, const char *msg) |
2086 | 1349 { |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
1350 if (gc->away) { |
2086 | 1351 g_free(gc->away); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
1352 gc->away = NULL; |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
1353 } |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
1354 |
5132 | 1355 if (!g_ascii_strcasecmp(state, _("Hidden"))) { |
9478 | 1356 /* XXX handle errors */ |
2086 | 1357 ZSetLocation(EXPOSE_OPSTAFF); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
1358 gc->away = g_strdup(""); |
9478 | 1359 } |
1360 else if (!g_ascii_strcasecmp(state, _("Online"))) { | |
1361 /* XXX handle errors */ | |
2086 | 1362 ZSetLocation(get_exposure_level()); |
9478 | 1363 } |
2086 | 1364 else /* state is GAIM_AWAY_CUSTOM */ if (msg) |
1365 gc->away = g_strdup(msg); | |
1366 } | |
1367 | |
8644 | 1368 static GList *zephyr_away_states(GaimConnection * gc) |
2086 | 1369 { |
1370 GList *m = NULL; | |
1371 | |
5132 | 1372 m = g_list_append(m, _("Online")); |
2086 | 1373 m = g_list_append(m, GAIM_AWAY_CUSTOM); |
5132 | 1374 m = g_list_append(m, _("Hidden")); |
2086 | 1375 |
1376 return m; | |
1377 } | |
1378 | |
8644 | 1379 static GList *zephyr_chat_info(GaimConnection * gc) |
1380 { | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1381 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1382 struct proto_chat_entry *pce; |
2086 | 1383 |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1384 pce = g_new0(struct proto_chat_entry, 1); |
8644 | 1385 |
7841 | 1386 pce->label = _("_Class:"); |
5234 | 1387 pce->identifier = "class"; |
3158 | 1388 m = g_list_append(m, pce); |
2086 | 1389 |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1390 pce = g_new0(struct proto_chat_entry, 1); |
8644 | 1391 |
7841 | 1392 pce->label = _("_Instance:"); |
5234 | 1393 pce->identifier = "instance"; |
3158 | 1394 m = g_list_append(m, pce); |
2086 | 1395 |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1396 pce = g_new0(struct proto_chat_entry, 1); |
8644 | 1397 |
7841 | 1398 pce->label = _("_Recipient:"); |
5234 | 1399 pce->identifier = "recipient"; |
3158 | 1400 m = g_list_append(m, pce); |
2086 | 1401 |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1402 return m; |
2086 | 1403 } |
1404 | |
9478 | 1405 /* Called when the server notifies us a message couldn't get sent */ |
1406 | |
1407 static void zephyr_subscribe_failed(ZSubscription_t *sub) | |
1408 { | |
1409 gchar* subscribe_failed = g_strdup_printf(_("Attempt to subscribe to %s,%s,%s failed"), sub->zsub_class, sub->zsub_classinst,sub->zsub_recipient); | |
1410 gaim_notify_error(zgc,"", subscribe_failed, NULL); | |
1411 g_free(subscribe_failed); | |
1412 } | |
1413 | |
8644 | 1414 static void zephyr_join_chat(GaimConnection * gc, GHashTable * data) |
2086 | 1415 { |
1416 ZSubscription_t sub; | |
1417 zephyr_triple *zt1, *zt2; | |
1418 const char *classname; | |
1419 const char *instname; | |
1420 const char *recip; | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1421 |
5234 | 1422 classname = g_hash_table_lookup(data, "class"); |
1423 instname = g_hash_table_lookup(data, "instance"); | |
1424 recip = g_hash_table_lookup(data, "recipient"); | |
1425 | |
9478 | 1426 |
9328 | 1427 if (!classname) |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1428 return; |
9478 | 1429 |
1430 if (!g_ascii_strcasecmp(classname,"%host%")) | |
1431 classname = g_strdup(ourhost); | |
1432 if (!g_ascii_strcasecmp(classname,"%canon%")) | |
1433 classname = g_strdup(ourhostcanon); | |
1434 | |
9328 | 1435 if (!instname || !strlen(instname)) |
1436 instname = "*"; | |
9478 | 1437 |
1438 if (!g_ascii_strcasecmp(instname,"%host%")) | |
1439 instname = g_strdup(ourhost); | |
1440 if (!g_ascii_strcasecmp(instname,"%canon%")) | |
1441 instname = g_strdup(ourhostcanon); | |
1442 | |
9328 | 1443 if (!recip || (*recip == '*')) |
1444 recip = ""; | |
4793 | 1445 if (!g_ascii_strcasecmp(recip, "%me%")) |
8354 | 1446 recip = gaim_zephyr_get_sender(); |
2086 | 1447 |
1448 zt1 = new_triple(classname, instname, recip); | |
1449 zt2 = find_sub_by_triple(zt1); | |
1450 if (zt2) { | |
1451 free_triple(zt1); | |
9328 | 1452 if (!zt2->open) { |
1453 if (!g_ascii_strcasecmp(instname,"*")) | |
1454 instname = "PERSONAL"; | |
9434 | 1455 serv_got_joined_chat(gc, zt2->id, zt2->name); |
1456 zephyr_chat_set_topic(zgc,zt2->id,instname); | |
9328 | 1457 zt2->open = TRUE; |
1458 } | |
2086 | 1459 return; |
1460 } | |
9434 | 1461 |
2086 | 1462 sub.zsub_class = zt1->class; |
1463 sub.zsub_classinst = zt1->instance; | |
1464 sub.zsub_recipient = zt1->recipient; | |
9434 | 1465 |
2086 | 1466 if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) { |
9478 | 1467 /* XXX output better subscription information */ |
1468 zephyr_subscribe_failed(&sub); | |
2086 | 1469 free_triple(zt1); |
1470 return; | |
1471 } | |
1472 | |
1473 subscrips = g_slist_append(subscrips, zt1); | |
1474 zt1->open = TRUE; | |
1475 serv_got_joined_chat(gc, zt1->id, zt1->name); | |
9328 | 1476 if (!g_ascii_strcasecmp(instname,"*")) |
1477 instname = "PERSONAL"; | |
9434 | 1478 zephyr_chat_set_topic(zgc,zt1->id,instname); |
2086 | 1479 } |
1480 | |
8644 | 1481 static void zephyr_chat_leave(GaimConnection * gc, int id) |
2086 | 1482 { |
1483 zephyr_triple *zt; | |
8644 | 1484 |
2086 | 1485 zt = find_sub_by_id(id); |
1486 if (zt) { | |
1487 zt->open = FALSE; | |
1488 zt->id = ++last_id; | |
1489 } | |
1490 } | |
1491 | |
9478 | 1492 static GaimChat *zephyr_find_blist_chat(GaimAccount *account, const char *name) |
1493 { | |
1494 GaimBlistNode *gnode, *cnode; | |
1495 | |
1496 /* XXX needs to be %host%,%canon%, and %me% clean */ | |
1497 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { | |
1498 for(cnode = gnode->child; cnode; cnode = cnode->next) { | |
1499 GaimChat *chat = (GaimChat*)cnode; | |
1500 char *zclass, *inst, *recip; | |
1501 char** triple; | |
1502 if(!GAIM_BLIST_NODE_IS_CHAT(cnode)) | |
1503 continue; | |
1504 if(chat->account !=account) | |
1505 continue; | |
1506 if(!(zclass = g_hash_table_lookup(chat->components, "class"))) | |
1507 continue; | |
1508 if(!(inst = g_hash_table_lookup(chat->components, "instance"))) | |
1509 inst = g_strdup(""); | |
1510 if(!(recip = g_hash_table_lookup(chat->components, "recipient"))) | |
1511 recip = g_strdup(""); | |
1512 triple = g_strsplit(name,",",3); | |
1513 if (!g_ascii_strcasecmp(triple[0],zclass) && !g_ascii_strcasecmp(triple[1],inst) && !g_ascii_strcasecmp(triple[2],recip)) | |
1514 return chat; | |
1515 | |
1516 } | |
1517 } | |
1518 return NULL; | |
1519 } | |
8644 | 1520 static const char *zephyr_list_icon(GaimAccount * a, GaimBuddy * b) |
5202 | 1521 { |
1522 return "zephyr"; | |
1523 } | |
1524 | |
9478 | 1525 static int zephyr_send_typing(GaimConnection *gc, const char *who, int typing) { |
1526 gchar *recipient; | |
1527 if (!typing) | |
1528 return 0; | |
1529 /* XXX We probably should care if this fails. Or maybe we don't want to */ | |
1530 if (!who) { | |
1531 gaim_debug_info("zephyr", "who is null\n"); | |
1532 recipient = local_zephyr_normalize(""); | |
1533 } else { | |
1534 recipient = local_zephyr_normalize(who); | |
1535 } | |
1536 | |
1537 gaim_debug_info("zephyr","about to send typing notification to %s",recipient); | |
1538 zephyr_send_message("MESSAGE","PERSONAL",recipient,"","","PING"); | |
1539 gaim_debug_info("zephyr","sent typing notification"); | |
1540 return ZEPHYR_TYPING_SEND_TIMEOUT; | |
1541 } | |
8212 | 1542 |
9434 | 1543 |
1544 | |
8644 | 1545 static void zephyr_chat_set_topic(GaimConnection * gc, int id, const char *topic) |
1546 { | |
1547 zephyr_triple *zt; | |
1548 GaimConversation *gconv; | |
1549 GaimConvChat *gcc; | |
9434 | 1550 gchar *topic_utf8; |
8644 | 1551 char *sender = (char *)gaim_zephyr_get_sender(); |
8212 | 1552 |
8644 | 1553 zt = find_sub_by_id(id); |
1554 gconv = gaim_find_conversation_with_account(zt->name, zgc->account); | |
1555 gcc = gaim_conversation_get_chat_data(gconv); | |
9434 | 1556 |
1557 topic_utf8 = zephyr_recv_convert((gchar *)topic,strlen(topic)); | |
1558 gaim_conv_chat_set_topic(gcc,sender,topic_utf8); | |
1559 g_free(topic_utf8); | |
1560 return; | |
1561 } | |
1562 | |
1563 /* commands */ | |
1564 | |
1565 static GaimCmdRet zephyr_gaim_cmd_msg(GaimConversation *conv, | |
1566 const char *cmd, char **args, char **error) | |
1567 { | |
1568 char *recipient; | |
9478 | 1569 |
9434 | 1570 if (!g_ascii_strcasecmp(args[0],"*")) |
9478 | 1571 return GAIM_CMD_RET_FAILED; /* "*" is not a valid argument */ |
9434 | 1572 else |
1573 recipient = local_zephyr_normalize(args[0]); | |
1574 | |
9478 | 1575 if (strlen(recipient) < 1) |
1576 return GAIM_CMD_RET_FAILED; /* a null recipient is a chat message, not an IM */ | |
1577 | |
1578 if (zephyr_send_message("MESSAGE","PERSONAL",recipient,args[1],zephyr_get_signature(),"")) | |
9434 | 1579 return GAIM_CMD_RET_OK; |
1580 else | |
1581 return GAIM_CMD_RET_FAILED; | |
1582 } | |
1583 | |
1584 static GaimCmdRet zephyr_gaim_cmd_zlocate(GaimConversation *conv, | |
1585 const char *cmd, char **args, char **error) | |
1586 { | |
1587 zephyr_zloc(zgc,args[0]); | |
1588 return GAIM_CMD_RET_OK; | |
1589 } | |
1590 | |
1591 static GaimCmdRet zephyr_gaim_cmd_instance(GaimConversation *conv, | |
1592 const char *cmd, char **args, char **error) | |
1593 { | |
1594 /* Currently it sets the instance with leading spaces and | |
1595 * all. This might not be the best thing to do, though having | |
1596 * one word isn't ideal either. */ | |
1597 | |
1598 GaimConvChat *gc = gaim_conversation_get_chat_data(conv); | |
1599 int id = gc->id; | |
1600 const char* instance = args[0]; | |
1601 zephyr_chat_set_topic(zgc,id,instance); | |
1602 return GAIM_CMD_RET_OK; | |
1603 } | |
1604 | |
1605 static GaimCmdRet zephyr_gaim_cmd_joinchat_cir(GaimConversation *conv, | |
1606 const char *cmd, char **args, char **error) | |
1607 { | |
1608 /* Join a new zephyr chat */ | |
1609 GHashTable *triple = g_hash_table_new(NULL,NULL); | |
1610 g_hash_table_insert(triple,"class",args[0]); | |
1611 g_hash_table_insert(triple,"instance",args[1]); | |
1612 g_hash_table_insert(triple,"recipient",args[2]); | |
1613 zephyr_join_chat(zgc,triple); | |
1614 return GAIM_CMD_RET_OK; | |
1615 } | |
1616 | |
1617 static GaimCmdRet zephyr_gaim_cmd_zi(GaimConversation *conv, | |
1618 const char *cmd, char **args, char **error) | |
1619 { | |
1620 /* args = instance, message */ | |
9478 | 1621 if ( zephyr_send_message("message",args[0],"",args[1],zephyr_get_signature(),"")) |
9434 | 1622 return GAIM_CMD_RET_OK; |
1623 else | |
1624 return GAIM_CMD_RET_FAILED; | |
1625 } | |
1626 | |
1627 static GaimCmdRet zephyr_gaim_cmd_zci(GaimConversation *conv, | |
1628 const char *cmd, char **args, char **error) | |
1629 { | |
1630 /* args = class, instance, message */ | |
9478 | 1631 if ( zephyr_send_message(args[0],args[1],"",args[2],zephyr_get_signature(),"")) |
9434 | 1632 return GAIM_CMD_RET_OK; |
1633 else | |
1634 return GAIM_CMD_RET_FAILED; | |
1635 } | |
8644 | 1636 |
9434 | 1637 static GaimCmdRet zephyr_gaim_cmd_zcir(GaimConversation *conv, |
1638 const char *cmd, char **args, char **error) | |
1639 { | |
1640 /* args = class, instance, recipient, message */ | |
9478 | 1641 if ( zephyr_send_message(args[0],args[1],args[2],args[3],zephyr_get_signature(),"")) |
9434 | 1642 return GAIM_CMD_RET_OK; |
1643 else | |
1644 return GAIM_CMD_RET_FAILED; | |
8212 | 1645 } |
1646 | |
9434 | 1647 static GaimCmdRet zephyr_gaim_cmd_zir(GaimConversation *conv, |
1648 const char *cmd, char **args, char **error) | |
1649 { | |
1650 /* args = instance, recipient, message */ | |
9478 | 1651 if ( zephyr_send_message("message",args[0],args[1],args[2],zephyr_get_signature(),"")) |
9434 | 1652 return GAIM_CMD_RET_OK; |
1653 else | |
1654 return GAIM_CMD_RET_FAILED; | |
1655 } | |
1656 | |
1657 static GaimCmdRet zephyr_gaim_cmd_zc(GaimConversation *conv, | |
1658 const char *cmd, char **args, char **error) | |
1659 { | |
1660 /* args = class, message */ | |
9478 | 1661 if ( zephyr_send_message(args[0],"PERSONAL","",args[1],zephyr_get_signature(),"")) |
9434 | 1662 return GAIM_CMD_RET_OK; |
1663 else | |
1664 return GAIM_CMD_RET_FAILED; | |
1665 } | |
1666 | |
1667 static void zephyr_register_slash_commands() | |
1668 { | |
1669 | |
1670 gaim_cmd_register("msg","ws", GAIM_CMD_P_PRPL, | |
1671 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1672 "prpl-zephyr", | |
1673 zephyr_gaim_cmd_msg, _("msg <nick> <message>: Send a private message to a user")); | |
1674 | |
1675 gaim_cmd_register("zlocate","w", GAIM_CMD_P_PRPL, | |
1676 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1677 "prpl-zephyr", | |
1678 zephyr_gaim_cmd_zlocate, _("zlocate <nick>: Locate user")); | |
1679 | |
1680 gaim_cmd_register("zl","w", GAIM_CMD_P_PRPL, | |
1681 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1682 "prpl-zephyr", | |
1683 zephyr_gaim_cmd_zlocate, _("zl <nick>: Locate user")); | |
1684 | |
1685 gaim_cmd_register("instance","s", GAIM_CMD_P_PRPL, | |
1686 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1687 "prpl-zephyr", | |
9437 | 1688 zephyr_gaim_cmd_instance, _("instance <instance>: Set the instance to be used on this class")); |
9434 | 1689 |
1690 gaim_cmd_register("inst","s", GAIM_CMD_P_PRPL, | |
1691 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1692 "prpl-zephyr", | |
9437 | 1693 zephyr_gaim_cmd_instance, _("inst <instance>: Set the instance to be used on this class")); |
9434 | 1694 |
1695 gaim_cmd_register("sub", "www", GAIM_CMD_P_PRPL, | |
1696 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1697 "prpl-zephyr", | |
1698 zephyr_gaim_cmd_joinchat_cir, | |
1699 _("sub <class> <instance> <recipient>: Join a new chat")); | |
1700 | |
1701 gaim_cmd_register("zi","ws", GAIM_CMD_P_PRPL, | |
1702 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1703 "prpl-zephyr", | |
1704 zephyr_gaim_cmd_zi, _("zi <instance>: Send a message to <message,<i>instance</i>,*>")); | |
1705 | |
1706 gaim_cmd_register("zci","wws",GAIM_CMD_P_PRPL, | |
1707 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1708 "prpl-zephyr", | |
1709 zephyr_gaim_cmd_zci, | |
1710 _("zci <class> <instance>: Send a message to <<i>class</i>,<i>instance</i>,*>")); | |
1711 | |
1712 gaim_cmd_register("zcir","wwws",GAIM_CMD_P_PRPL, | |
1713 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1714 "prpl-zephyr", | |
1715 zephyr_gaim_cmd_zcir, | |
1716 _("zcir <class> <instance> <recipient>: Send a message to <<i>class</i>,<i>instance</i>,<i>recipient</i>>")); | |
1717 | |
1718 gaim_cmd_register("zir","wws",GAIM_CMD_P_PRPL, | |
1719 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1720 "prpl-zephyr", | |
1721 zephyr_gaim_cmd_zir, | |
1722 _("zir <instance> <recipient>: Send a message to <MESSAGE,<i>instance</i>,<i>recipient</i>>")); | |
1723 | |
1724 gaim_cmd_register("zc","ws", GAIM_CMD_P_PRPL, | |
1725 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
1726 "prpl-zephyr", | |
1727 zephyr_gaim_cmd_zc, _("zc <class>: Send a message to <<i>class</i>,PERSONAL,*>")); | |
1728 | |
1729 } | |
1730 | |
1731 | |
9427 | 1732 static int zephyr_resubscribe(GaimConnection *gc) |
1733 { | |
1734 /* Resubscribe to the in-memory list of subscriptions and also | |
1735 unsubscriptions*/ | |
1736 | |
1737 GSList *s = subscrips; | |
1738 zephyr_triple *zt; | |
1739 ZSubscription_t zst; | |
1740 while (s) { | |
1741 zt = s->data; | |
1742 zst.zsub_class = zt->class; | |
1743 zst.zsub_classinst = zt->instance; | |
1744 zst.zsub_recipient = zt->recipient; | |
1745 /* XXX We really should care if this fails */ | |
9478 | 1746 ZSubscribeTo(&zst, 1, 0); |
9427 | 1747 s = s->next; |
1748 } | |
1749 /* XXX handle unsubscriptions */ | |
1750 return 1; | |
1751 } | |
1752 | |
9434 | 1753 |
9427 | 1754 static void zephyr_action_resubscribe(GaimPluginAction *action) |
1755 { | |
1756 | |
1757 GaimConnection *gc = (GaimConnection *) action->context; | |
1758 zephyr_resubscribe(gc); | |
1759 } | |
1760 | |
1761 | |
9478 | 1762 static void zephyr_action_get_subs_from_server(GaimPluginAction *action) |
1763 { | |
1764 GaimConnection *gc = (GaimConnection *) action->context; | |
1765 gchar *title; | |
1766 int retval, nsubs, one,i; | |
1767 ZSubscription_t subs; | |
1768 GString* subout = g_string_new("Subscription list<br>"); | |
1769 | |
1770 title = g_strdup_printf("Server subscriptions for %s", gaim_zephyr_get_sender()); | |
1771 | |
1772 if (zephyr_port == 0) { | |
1773 gaim_debug(GAIM_DEBUG_ERROR,"zephyr", "error while retrieving port"); | |
1774 return; | |
1775 } | |
1776 if ((retval = ZRetrieveSubscriptions(zephyr_port,&nsubs)) != ZERR_NONE) { | |
1777 /* XXX better error handling */ | |
1778 gaim_debug(GAIM_DEBUG_ERROR,"zephyr", "error while retrieving subscriptions from server"); | |
1779 return; | |
1780 } | |
1781 g_string_append_printf(subout,"Subscription list <br>"); | |
1782 for(i=0;i<nsubs;i++) { | |
1783 one = 1; | |
1784 if ((retval = ZGetSubscriptions(&subs,&one)) != ZERR_NONE) { | |
1785 /* XXX better error handling */ | |
1786 gaim_debug(GAIM_DEBUG_ERROR,"zephyr", "error while retrieving individual subscription"); | |
1787 return; | |
1788 } | |
1789 g_string_append_printf(subout, "Class %s Instance %s Recipient %s<br>", | |
1790 subs.zsub_class, subs.zsub_classinst, | |
1791 subs.zsub_recipient); | |
1792 } | |
1793 gaim_notify_formatted(gc, title, title, NULL, subout->str, NULL, NULL); | |
1794 } | |
1795 | |
1796 | |
9427 | 1797 static GList *zephyr_actions(GaimPlugin *plugin, gpointer context) |
1798 { | |
1799 GList *list = NULL; | |
1800 GaimPluginAction *act = NULL; | |
1801 | |
1802 act = gaim_plugin_action_new(_("Resubscribe"), zephyr_action_resubscribe); | |
1803 list = g_list_append(list, act); | |
1804 | |
9478 | 1805 act = gaim_plugin_action_new(_("Retrieve subscriptions from server"), zephyr_action_get_subs_from_server); |
1806 list = g_list_append(list,act); | |
1807 | |
9427 | 1808 return list; |
1809 } | |
1810 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1811 static GaimPlugin *my_protocol = NULL; |
2086 | 1812 |
8644 | 1813 static GaimPluginProtocolInfo prpl_info = { |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8713
diff
changeset
|
1814 GAIM_PRPL_API_VERSION, |
8644 | 1815 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_NO_PASSWORD, |
9478 | 1816 NULL, /* ??? user_splits */ |
1817 NULL, /* ??? protocol_options */ | |
1818 NO_BUDDY_ICONS, | |
1819 zephyr_list_icon, | |
1820 NULL, /* ??? list_emblems */ | |
1821 NULL, /* ??? status_text */ | |
1822 NULL, /* ??? tooltip_text */ | |
9475 | 1823 zephyr_away_states, /* away_states */ |
9478 | 1824 NULL, /* ??? blist_node_menu - probably all useful actions are already handled*/ |
9475 | 1825 zephyr_chat_info, /* chat_info */ |
1826 zephyr_login, /* login */ | |
1827 zephyr_close, /* close */ | |
1828 zephyr_send_im, /* send_im */ | |
9478 | 1829 NULL, /* XXX set info (Location?) */ |
1830 zephyr_send_typing, /* send_typing */ | |
9475 | 1831 zephyr_zloc, /* get_info */ |
9478 | 1832 zephyr_set_away, /* XXX set_away need to fix */ |
1833 NULL, /* ??? set idle */ | |
1834 NULL, /* change password */ | |
9475 | 1835 NULL, /* add_buddy */ |
1836 NULL, /* add_buddies */ | |
1837 NULL, /* remove_buddy */ | |
1838 NULL, /* remove_buddies */ | |
9478 | 1839 NULL, /* add_permit -- not useful, since anyone can zephyr you by default*/ |
1840 NULL, /* XXX add deny -- maybe put an auto "I'm ignoring your zephyrs*/ | |
1841 NULL, /* remove_permit -- not useful, see add permit */ | |
1842 NULL, /* XXX remove deny -- remove above deny, */ | |
1843 NULL, /* ??? set permit deny */ | |
1844 NULL, /* --- warn */ | |
9475 | 1845 zephyr_join_chat, /* join_chat */ |
1846 NULL, /* reject_chat */ | |
1847 NULL, /* chat_invite */ | |
1848 zephyr_chat_leave, /* chat_leave */ | |
1849 NULL, /* chat_whisper */ | |
1850 zephyr_chat_send, /* chat_send */ | |
1851 NULL, /* keepalive */ | |
1852 NULL, /* register_user */ | |
9478 | 1853 NULL, /* XXX get_cb_info get chat buddy info */ |
9475 | 1854 NULL, /* get_cb_away */ |
1855 NULL, /* alias_buddy */ | |
1856 NULL, /* group_buddy */ | |
1857 NULL, /* rename_group */ | |
9478 | 1858 NULL, /* ??? buddy_free */ |
9475 | 1859 NULL, /* convo_closed */ |
1860 zephyr_normalize, /* normalize */ | |
9478 | 1861 NULL, /* XXX set_buddy_icon */ |
9475 | 1862 NULL, /* remove_group */ |
9478 | 1863 NULL, /* XXX get_cb_real_name */ |
9475 | 1864 zephyr_chat_set_topic, /* set_chat_topic */ |
9478 | 1865 zephyr_find_blist_chat, /* find_blist_chat */ |
9475 | 1866 NULL, /* roomlist_get_list */ |
1867 NULL, /* roomlist_cancel */ | |
9478 | 1868 NULL, /* roomlist_expand_category */ |
9475 | 1869 NULL, /* can_receive_file */ |
1870 NULL /* send_file */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1871 }; |
2086 | 1872 |
8644 | 1873 static GaimPluginInfo info = { |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8713
diff
changeset
|
1874 GAIM_PLUGIN_API_VERSION, /**< api_version */ |
8644 | 1875 GAIM_PLUGIN_PROTOCOL, /**< type */ |
1876 NULL, /**< ui_requirement */ | |
1877 0, /**< flags */ | |
1878 NULL, /**< dependencies */ | |
1879 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1880 |
8644 | 1881 "prpl-zephyr", /**< id */ |
1882 "Zephyr", /**< name */ | |
1883 VERSION, /**< version */ | |
1884 /** summary */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1885 N_("Zephyr Protocol Plugin"), |
8644 | 1886 /** description */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1887 N_("Zephyr Protocol Plugin"), |
8644 | 1888 NULL, /**< author */ |
1889 GAIM_WEBSITE, /**< homepage */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1890 |
8644 | 1891 NULL, /**< load */ |
1892 NULL, /**< unload */ | |
1893 NULL, /**< destroy */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1894 |
8644 | 1895 NULL, /**< ui_info */ |
8993 | 1896 &prpl_info, /**< extra_info */ |
1897 NULL, | |
9427 | 1898 zephyr_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1899 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1900 |
8644 | 1901 static void init_plugin(GaimPlugin * plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1902 { |
8212 | 1903 GaimAccountOption *option; |
8644 | 1904 char *tmp = get_exposure_level(); |
1905 | |
1906 option = gaim_account_option_bool_new(_("Export to .anyone"), "write_anyone", FALSE); | |
1907 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
8212 | 1908 |
8644 | 1909 option = gaim_account_option_bool_new(_("Export to .zephyr.subs"), "write_zsubs", FALSE); |
1910 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
8212 | 1911 |
8644 | 1912 option = gaim_account_option_string_new(_("Exposure"), "exposure_level", tmp ? tmp : EXPOSE_REALMVIS); |
1913 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
8212 | 1914 |
8644 | 1915 option = gaim_account_option_string_new(_("Encoding"), "encoding", ZEPHYR_FALLBACK_CHARSET); |
1916 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
8560 | 1917 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1918 my_protocol = plugin; |
9434 | 1919 zephyr_register_slash_commands(); |
2086 | 1920 } |
1921 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1922 GAIM_INIT_PLUGIN(zephyr, init_plugin, info); |