Mercurial > pidgin.yaz
annotate src/protocols/zephyr/zephyr.c @ 9426:dfee44a581a4
[gaim-migrate @ 10244]
" This patch causes gaim to write out a file containing
an ascii representation of the big-endian version of
the port number which gaim listens in on for incoming
zephyrs, of the form "gaimwgXXXXXX". It will be useful
for debugging occasional problems with zephyr loss of
subscriptions (chats).
I've made some changes in util.c to allow the creation
of temporary files with arbitrary templates:
I've renamed gaim_mkstemp to gaim_mkstemp_template,
modifying it to take a second argument, template, and
use that instead of gaim_mkstemp_templ.
A new gaim_mkstemp which is a wrapper around
gaim_mkstemp_template has been put in place for
compatibility with all the existing code using this
function." --Arun A Tharuvai
"The patch I submitted causes the wgfile to always be written
out, because it would be useful for endusers too, and also
to try to keep it consistent with the standard zephyr
distribution." --Arun A Tharuvai
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Tue, 29 Jun 2004 17:23:08 +0000 |
parents | 33e6b2b92cfe |
children | 66b3f54527e6 |
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" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
35 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
36 #include "zephyr/zephyr.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
37 |
8386 | 38 #include <strings.h> |
39 | |
8560 | 40 #define ZEPHYR_FALLBACK_CHARSET "ISO-8859-1" |
41 | |
2086 | 42 extern Code_t ZGetLocations(ZLocations_t *, int *); |
43 extern Code_t ZSetLocation(char *); | |
44 extern Code_t ZUnsetLocation(); | |
45 | |
46 typedef struct _zframe zframe; | |
47 typedef struct _zephyr_triple zephyr_triple; | |
48 | |
49 /* struct I need for zephyr_to_html */ | |
50 struct _zframe { | |
51 /* true for everything but @color, since inside the parens of that one is | |
8644 | 52 * the color. */ |
2086 | 53 gboolean has_closer; |
54 /* </i>, </font>, </b>, etc. */ | |
55 char *closing; | |
56 /* text including the opening html thingie. */ | |
57 GString *text; | |
58 struct _zframe *enclosing; | |
59 }; | |
60 | |
61 struct _zephyr_triple { | |
62 char *class; | |
63 char *instance; | |
64 char *recipient; | |
65 char *name; | |
66 gboolean open; | |
67 int id; | |
68 }; | |
69 | |
70 #define z_call(func) if (func != ZERR_NONE)\ | |
71 return; | |
72 #define z_call_r(func) if (func != ZERR_NONE)\ | |
73 return TRUE; | |
74 #define z_call_s(func, err) if (func != ZERR_NONE) {\ | |
5606 | 75 gaim_connection_error(zgc, err);\ |
2086 | 76 return;\ |
77 } | |
78 | |
9328 | 79 char *local_zephyr_normalize(const char *); |
7322 | 80 static const char *zephyr_normalize(const GaimAccount *, const char *); |
9328 | 81 static const char *gaim_zephyr_get_realm(); |
82 | |
83 char *zephyr_strip_foreign_realm(const char* user){ | |
84 /* | |
85 Takes in a username of the form username or username@realm | |
86 and returns: | |
87 username, if there is no realm, or the realm is the local realm | |
88 or: | |
89 username@realm if there is a realm and it is foreign | |
90 */ | |
91 char *tmp = g_strdup(user); | |
92 char *at = strchr(tmp,'@'); | |
93 if (at && !g_ascii_strcasecmp(at+1,gaim_zephyr_get_realm())) { | |
94 /* We're passed in a username of the form user@users-realm */ | |
95 char* tmp2; | |
96 *at = '\0'; | |
97 tmp2 = g_strdup(tmp); | |
98 g_free(tmp); | |
99 return tmp2; | |
100 } | |
101 else { | |
102 /* We're passed in a username of the form user or user@foreign-realm */ | |
103 return tmp; | |
104 } | |
105 } | |
2086 | 106 |
107 /* this is so bad, and if Zephyr weren't so fucked up to begin with I | |
108 * wouldn't do this. but it is so i will. */ | |
109 static guint32 nottimer = 0; | |
110 static guint32 loctimer = 0; | |
5606 | 111 GaimConnection *zgc = NULL; |
2086 | 112 static GList *pending_zloc_names = NULL; |
113 static GSList *subscrips = NULL; | |
114 static int last_id = 0; | |
115 | |
9328 | 116 /* just for debugging */ |
2086 | 117 static void handle_unknown(ZNotice_t notice) |
118 { | |
9328 | 119 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_packet: %s\n", notice.z_packet); |
120 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_version: %s\n", notice.z_version); | |
121 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_kind: %d\n", (int)(notice.z_kind)); | |
122 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_class: %s\n", notice.z_class); | |
123 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_class_inst: %s\n", notice.z_class_inst); | |
124 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_opcode: %s\n", notice.z_opcode); | |
125 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_sender: %s\n", notice.z_sender); | |
126 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_recipient: %s\n", notice.z_recipient); | |
127 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_message: %s\n", notice.z_message); | |
128 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_message_len: %d\n", notice.z_message_len); | |
2086 | 129 } |
9328 | 130 |
2086 | 131 |
132 static zephyr_triple *new_triple(const char *c, const char *i, const char *r) | |
133 { | |
134 zephyr_triple *zt; | |
8644 | 135 |
2086 | 136 zt = g_new0(zephyr_triple, 1); |
137 zt->class = g_strdup(c); | |
138 zt->instance = g_strdup(i); | |
139 zt->recipient = g_strdup(r); | |
140 zt->name = g_strdup_printf("%s,%s,%s", c, i, r); | |
141 zt->id = ++last_id; | |
142 zt->open = FALSE; | |
143 return zt; | |
144 } | |
145 | |
8644 | 146 static void free_triple(zephyr_triple * zt) |
2086 | 147 { |
148 g_free(zt->class); | |
149 g_free(zt->instance); | |
150 g_free(zt->recipient); | |
151 g_free(zt->name); | |
152 g_free(zt); | |
153 } | |
154 | |
8644 | 155 static const char *gaim_zephyr_get_sender() |
156 { | |
8568 | 157 /* will be useful once this plugin can use a backend other |
158 than libzephyr */ | |
159 return ZGetSender(); | |
8354 | 160 } |
161 | |
8644 | 162 static const char *gaim_zephyr_get_realm() |
163 { | |
8568 | 164 /* will be useful once this plugin can use a backend other |
165 than libzephyr */ | |
166 return ZGetRealm(); | |
8354 | 167 } |
168 | |
9328 | 169 /* returns true if zt1 is a subset of zt2. This function is used to |
170 determine whether a zephyr sent to zt1 should be placed in the chat | |
171 with triple zt2 | |
172 | |
173 zt1 is a subset of zt2 | |
174 iff. the classnames are identical ignoring case | |
175 AND. the instance names are identical (ignoring case), or zt2->instance is *. | |
176 AND. the recipient names are identical | |
177 */ | |
178 | |
8644 | 179 static gboolean triple_subset(zephyr_triple * zt1, zephyr_triple * zt2) |
2086 | 180 { |
9328 | 181 if (g_ascii_strcasecmp(zt2->class, zt1->class)) { |
2086 | 182 return FALSE; |
183 } | |
8644 | 184 if (g_ascii_strcasecmp(zt2->instance, zt1->instance) && g_ascii_strcasecmp(zt2->instance, "*")) { |
2086 | 185 return FALSE; |
186 } | |
9328 | 187 if (g_ascii_strcasecmp(zt2->recipient, zt1->recipient)) { |
2086 | 188 return FALSE; |
189 } | |
190 return TRUE; | |
191 } | |
192 | |
8644 | 193 static zephyr_triple *find_sub_by_triple(zephyr_triple * zt) |
2086 | 194 { |
195 zephyr_triple *curr_t; | |
196 GSList *curr = subscrips; | |
8644 | 197 |
2086 | 198 while (curr) { |
199 curr_t = curr->data; | |
200 if (triple_subset(zt, curr_t)) | |
201 return curr_t; | |
202 curr = curr->next; | |
203 } | |
204 return NULL; | |
205 } | |
206 | |
207 static zephyr_triple *find_sub_by_id(int id) | |
208 { | |
209 zephyr_triple *zt; | |
210 GSList *curr = subscrips; | |
8644 | 211 |
2086 | 212 while (curr) { |
213 zt = curr->data; | |
214 if (zt->id == id) | |
215 return zt; | |
216 curr = curr->next; | |
217 } | |
218 return NULL; | |
219 } | |
220 | |
9328 | 221 /* |
222 Convert incoming zephyr to utf-8 if necessary using user specified encoding | |
223 */ | |
224 | |
8560 | 225 static gchar *zephyr_recv_convert(char *string, int len) |
226 { | |
227 gchar *utf8; | |
228 GError *err = NULL; | |
8644 | 229 |
230 if (g_utf8_validate(string, len, NULL)) { | |
8568 | 231 return g_strdup(string); |
232 } else { | |
8644 | 233 utf8 = g_convert(string, len, "UTF-8", gaim_account_get_string(zgc->account, "encoding", ZEPHYR_FALLBACK_CHARSET), NULL, NULL, &err); |
8568 | 234 if (err) { |
235 gaim_debug(GAIM_DEBUG_ERROR, "zephyr", "recv conversion error: %s\n", err->message); | |
236 utf8 = g_strdup(_("(There was an error converting this message. Check the 'Encoding' option in the Account Editor)")); | |
8954 | 237 g_error_free(err); |
8568 | 238 } |
239 | |
240 return utf8; | |
241 } | |
8560 | 242 } |
243 | |
2086 | 244 /* utility macros that are useful for zephyr_to_html */ |
245 | |
246 #define IS_OPENER(c) ((c == '{') || (c == '[') || (c == '(') || (c == '<')) | |
247 #define IS_CLOSER(c) ((c == '}') || (c == ']') || (c == ')') || (c == '>')) | |
248 | |
8451 | 249 /* This parses HTML formatting (put out by one of the gtkimhtml widgets |
250 And converts it to zephyr formatting. | |
251 It currently deals properly with <b>, <br>, <i>, <font face=...>, <font color=...>, | |
252 It ignores <font back=...> | |
253 It does | |
254 <font size = "1 or 2" -> @small | |
255 3 or 4 @medium() | |
256 5,6, or 7 @large() | |
257 <a href is dealt with by ignoring the description and outputting the link | |
258 */ | |
259 | |
260 static char *html_to_zephyr(const char *message) | |
261 { | |
8644 | 262 int len, cnt, retcount; |
263 char *ret; | |
264 | |
265 len = strlen(message); | |
266 ret = g_new0(char, len * 3); | |
267 | |
268 bzero(ret, len * 3); | |
269 retcount = 0; | |
270 cnt = 0; | |
271 while (cnt <= len) { | |
272 if (message[cnt] == '<') { | |
273 if (!g_ascii_strncasecmp(message + cnt + 1, "i>", 2)) { | |
274 strncpy(ret + retcount, "@i(", 3); | |
275 cnt += 3; | |
276 retcount += 3; | |
277 } else if (!g_ascii_strncasecmp(message + cnt + 1, "b>", 2)) { | |
278 strncpy(ret + retcount, "@b(", 3); | |
279 cnt += 3; | |
280 retcount += 3; | |
281 } else if (!g_ascii_strncasecmp(message + cnt + 1, "br>", 3)) { | |
282 strncpy(ret + retcount, "\n", 1); | |
283 cnt += 4; | |
284 retcount += 1; | |
285 } else if (!g_ascii_strncasecmp(message + cnt + 1, "a href=\"", 8)) { | |
286 cnt += 9; | |
287 while (g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) { | |
288 ret[retcount] = message[cnt]; | |
289 retcount++; | |
290 cnt++; | |
291 } | |
292 cnt += 2; | |
293 /* ignore descriptive string */ | |
294 while (g_ascii_strncasecmp(message + cnt, "</a>", 4) != 0) { | |
295 cnt++; | |
296 } | |
297 cnt += 4; | |
298 } else if (!g_ascii_strncasecmp(message + cnt + 1, "font", 4)) { | |
299 cnt += 5; | |
300 while (!g_ascii_strncasecmp(message + cnt, " ", 1)) | |
301 cnt++; | |
302 if (!g_ascii_strncasecmp(message + cnt, "color=\"", 7)) { | |
303 cnt += 7; | |
304 strncpy(ret + retcount, "@color(", 7); | |
305 retcount += 7; | |
306 while (g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) { | |
307 ret[retcount] = message[cnt]; | |
308 retcount++; | |
309 cnt++; | |
310 } | |
311 ret[retcount] = ')'; | |
312 retcount++; | |
313 cnt += 2; | |
314 } else if (!g_ascii_strncasecmp(message + cnt, "face=\"", 6)) { | |
315 cnt += 6; | |
316 strncpy(ret + retcount, "@font(", 6); | |
317 retcount += 6; | |
318 while (g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) { | |
319 ret[retcount] = message[cnt]; | |
320 retcount++; | |
321 cnt++; | |
322 } | |
323 ret[retcount] = ')'; | |
324 retcount++; | |
325 cnt += 2; | |
326 } else if (!g_ascii_strncasecmp(message + cnt, "size=\"", 6)) { | |
327 cnt += 6; | |
328 if ((message[cnt] == '1') || (message[cnt] == '2')) { | |
329 strncpy(ret + retcount, "@small(", 7); | |
330 retcount += 7; | |
331 } else if ((message[cnt] == '3') | |
332 || (message[cnt] == '4')) { | |
333 strncpy(ret + retcount, "@medium(", 8); | |
334 retcount += 8; | |
335 } else if ((message[cnt] == '5') | |
336 || (message[cnt] == '6') | |
337 || (message[cnt] == '7')) { | |
338 strncpy(ret + retcount, "@large(", 7); | |
339 retcount += 7; | |
340 } | |
341 cnt += 3; | |
342 } else { | |
343 /* Drop all unrecognized/misparsed font tags */ | |
344 while (g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) { | |
345 cnt++; | |
346 } | |
347 cnt += 2; | |
348 } | |
349 } else if (!g_ascii_strncasecmp(message + cnt + 1, "/i>", 3) | |
350 || !g_ascii_strncasecmp(message + cnt + 1, "/b>", 3)) { | |
351 cnt += 4; | |
352 ret[retcount] = ')'; | |
353 retcount++; | |
354 } else if (!g_ascii_strncasecmp(message + cnt + 1, "/font>", 6)) { | |
355 cnt += 7; | |
356 strncpy(ret + retcount, "@font(fixed)", 12); | |
357 retcount += 12; | |
358 } else { | |
359 /* Catch all for all unrecognized/misparsed <foo> tage */ | |
360 while (g_ascii_strncasecmp(message + cnt, ">", 1) != 0) { | |
361 ret[retcount] = message[cnt]; | |
362 retcount++; | |
363 cnt++; | |
364 } | |
365 } | |
366 } else { | |
367 /* Duh */ | |
368 ret[retcount] = message[cnt]; | |
369 retcount++; | |
370 cnt++; | |
371 } | |
372 } | |
373 return ret; | |
8451 | 374 } |
375 | |
2086 | 376 /* this parses zephyr formatting and converts it to html. For example, if |
377 * you pass in "@{@color(blue)@i(hello)}" you should get out | |
378 * "<font color=blue><i>hello</i></font>". */ | |
379 static char *zephyr_to_html(char *message) | |
380 { | |
381 int len, cnt; | |
382 zframe *frames, *curr; | |
383 char *ret; | |
384 | |
385 frames = g_new(zframe, 1); | |
386 frames->text = g_string_new(""); | |
387 frames->enclosing = NULL; | |
388 frames->closing = ""; | |
389 frames->has_closer = FALSE; | |
390 | |
391 len = strlen(message); | |
392 cnt = 0; | |
393 while (cnt <= len) { | |
394 if (message[cnt] == '@') { | |
395 zframe *new_f; | |
396 char *buf; | |
397 int end; | |
8644 | 398 |
399 for (end = 1; (cnt + end) <= len && !IS_OPENER(message[cnt + end]) | |
400 && !IS_CLOSER(message[cnt + end]); end++); | |
2086 | 401 buf = g_new0(char, end); |
8644 | 402 |
2086 | 403 if (end) { |
8644 | 404 g_snprintf(buf, end, "%s", message + cnt + 1); |
2086 | 405 } |
8644 | 406 if (!g_ascii_strcasecmp(buf, "italic") || !g_ascii_strcasecmp(buf, "i")) { |
2086 | 407 new_f = g_new(zframe, 1); |
408 new_f->enclosing = frames; | |
409 new_f->text = g_string_new("<i>"); | |
410 new_f->closing = "</i>"; | |
411 new_f->has_closer = TRUE; | |
412 frames = new_f; | |
8644 | 413 cnt += end + 1; /* cnt points to char after opener */ |
414 } else if (!g_ascii_strcasecmp(buf, "small")) { | |
415 new_f = g_new(zframe, 1); | |
416 new_f->enclosing = frames; | |
417 new_f->text = g_string_new("<font size=\"1\">"); | |
418 new_f->closing = "</font>"; | |
419 frames = new_f; | |
420 cnt += end + 1; | |
421 } else if (!g_ascii_strcasecmp(buf, "medium")) { | |
422 new_f = g_new(zframe, 1); | |
423 new_f->enclosing = frames; | |
424 new_f->text = g_string_new("<font size=\"3\">"); | |
425 new_f->closing = "</font>"; | |
426 frames = new_f; | |
427 cnt += end + 1; | |
428 } else if (!g_ascii_strcasecmp(buf, "large")) { | |
429 new_f = g_new(zframe, 1); | |
430 new_f->enclosing = frames; | |
431 new_f->text = g_string_new("<font size=\"7\">"); | |
432 new_f->closing = "</font>"; | |
433 frames = new_f; | |
434 cnt += end + 1; | |
435 } else if (!g_ascii_strcasecmp(buf, "bold") | |
436 || !g_ascii_strcasecmp(buf, "b")) { | |
2086 | 437 new_f = g_new(zframe, 1); |
438 new_f->enclosing = frames; | |
439 new_f->text = g_string_new("<b>"); | |
440 new_f->closing = "</b>"; | |
441 new_f->has_closer = TRUE; | |
442 frames = new_f; | |
8644 | 443 cnt += end + 1; |
444 } else if (!g_ascii_strcasecmp(buf, "font")) { | |
445 cnt += end + 1; | |
8451 | 446 new_f = g_new(zframe, 1); |
447 new_f->enclosing = frames; | |
448 new_f->text = g_string_new("<font face="); | |
449 for (; (cnt <= len) && !IS_CLOSER(message[cnt]); cnt++) { | |
450 g_string_append_c(new_f->text, message[cnt]); | |
451 } | |
8644 | 452 cnt++; /* point to char after closer */ |
8451 | 453 g_string_append_c(new_f->text, '>'); |
454 new_f->closing = "</font>"; | |
455 new_f->has_closer = FALSE; | |
456 frames = new_f; | |
8568 | 457 } else if (!g_ascii_strcasecmp(buf, "color")) { |
8644 | 458 cnt += end + 1; |
2086 | 459 new_f = g_new(zframe, 1); |
460 new_f->enclosing = frames; | |
461 new_f->text = g_string_new("<font color="); | |
462 for (; (cnt <= len) && !IS_CLOSER(message[cnt]); cnt++) { | |
463 g_string_append_c(new_f->text, message[cnt]); | |
464 } | |
8644 | 465 cnt++; /* point to char after closer */ |
2086 | 466 g_string_append_c(new_f->text, '>'); |
467 new_f->closing = "</font>"; | |
468 new_f->has_closer = FALSE; | |
469 frames = new_f; | |
4793 | 470 } else if (!g_ascii_strcasecmp(buf, "")) { |
2086 | 471 new_f = g_new(zframe, 1); |
472 new_f->enclosing = frames; | |
473 new_f->text = g_string_new(""); | |
474 new_f->closing = ""; | |
475 new_f->has_closer = TRUE; | |
476 frames = new_f; | |
8644 | 477 cnt += end + 1; /* cnt points to char after opener */ |
2086 | 478 } else { |
8644 | 479 if ((cnt + end) > len) { |
2086 | 480 g_string_append_c(frames->text, '@'); |
481 cnt++; | |
8644 | 482 } else if (IS_CLOSER(message[cnt + end])) { |
483 /* We have @chars..closer . This is | |
484 merely a sequence of chars that isn't a formatting tag | |
485 */ | |
486 int tmp = cnt; | |
487 | |
488 while (tmp <= cnt + end) { | |
489 g_string_append_c(frames->text, message[tmp]); | |
490 tmp++; | |
491 } | |
492 cnt += end + 1; | |
493 } else { | |
2086 | 494 /* unrecognized thingie. act like it's not there, but we |
495 * still need to take care of the corresponding closer, | |
496 * make a frame that does nothing. */ | |
497 new_f = g_new(zframe, 1); | |
498 new_f->enclosing = frames; | |
499 new_f->text = g_string_new(""); | |
500 new_f->closing = ""; | |
501 new_f->has_closer = TRUE; | |
502 frames = new_f; | |
8644 | 503 cnt += end + 1; /* cnt points to char after opener */ |
2086 | 504 } |
505 } | |
506 } else if (IS_CLOSER(message[cnt])) { | |
507 zframe *popped; | |
508 gboolean last_had_closer; | |
8644 | 509 |
2086 | 510 if (frames->enclosing) { |
511 do { | |
512 popped = frames; | |
513 frames = frames->enclosing; | |
514 g_string_append(frames->text, popped->text->str); | |
515 g_string_append(frames->text, popped->closing); | |
516 g_string_free(popped->text, TRUE); | |
517 last_had_closer = popped->has_closer; | |
518 g_free(popped); | |
519 } while (frames && frames->enclosing && !last_had_closer); | |
520 } else { | |
521 g_string_append_c(frames->text, message[cnt]); | |
522 } | |
523 cnt++; | |
524 } else if (message[cnt] == '\n') { | |
525 g_string_append(frames->text, "<br>"); | |
526 cnt++; | |
527 } else { | |
528 g_string_append_c(frames->text, message[cnt++]); | |
529 } | |
530 } | |
531 /* go through all the stuff that they didn't close */ | |
532 while (frames->enclosing) { | |
533 curr = frames; | |
534 g_string_append(frames->enclosing->text, frames->text->str); | |
535 g_string_append(frames->enclosing->text, frames->closing); | |
536 g_string_free(frames->text, TRUE); | |
537 frames = frames->enclosing; | |
538 g_free(curr); | |
539 } | |
540 ret = frames->text->str; | |
541 g_string_free(frames->text, FALSE); | |
542 g_free(frames); | |
543 return ret; | |
544 } | |
545 | |
546 static gboolean pending_zloc(char *who) | |
547 { | |
548 GList *curr; | |
8644 | 549 |
2086 | 550 for (curr = pending_zloc_names; curr != NULL; curr = curr->next) { |
9328 | 551 char* normalized_who = local_zephyr_normalize(who); |
552 if (!g_ascii_strcasecmp(normalized_who, (char *)curr->data)) { | |
8644 | 553 g_free((char *)curr->data); |
2086 | 554 pending_zloc_names = g_list_remove(pending_zloc_names, curr->data); |
555 return TRUE; | |
556 } | |
557 } | |
558 return FALSE; | |
559 } | |
560 | |
9328 | 561 /* Called when the server notifies us a message couldn't get sent */ |
562 | |
8559 | 563 static void message_failed(ZNotice_t notice, struct sockaddr_in from) |
564 { | |
8644 | 565 if (g_ascii_strcasecmp(notice.z_class, "message")) { |
9328 | 566 gchar* chat_failed = g_strdup_printf(_("Unable send to chat %s,%s,%s"),notice.z_class,notice.z_class_inst,notice.z_recipient); |
567 gaim_notify_error(zgc,"",chat_failed,NULL); | |
568 g_free(chat_failed); | |
8644 | 569 } else { |
570 gaim_notify_error(zgc, notice.z_recipient, _("User is offline"), NULL); | |
571 } | |
8559 | 572 } |
573 | |
2086 | 574 static void handle_message(ZNotice_t notice, struct sockaddr_in from) |
575 { | |
4793 | 576 if (!g_ascii_strcasecmp(notice.z_class, LOGIN_CLASS)) { |
3277 | 577 /* well, we'll be updating in 20 seconds anyway, might as well ignore this. */ |
4793 | 578 } else if (!g_ascii_strcasecmp(notice.z_class, LOCATE_CLASS)) { |
579 if (!g_ascii_strcasecmp(notice.z_opcode, LOCATE_LOCATE)) { | |
2086 | 580 int nlocs; |
581 char *user; | |
6695 | 582 GaimBuddy *b; |
2086 | 583 |
584 if (ZParseLocations(¬ice, NULL, &nlocs, &user) != ZERR_NONE) | |
585 return; | |
8435 | 586 |
8644 | 587 if ((b = gaim_find_buddy(zgc->account, user)) == NULL) { |
2086 | 588 char *e = strchr(user, '@'); |
8644 | 589 |
590 if (e && !g_ascii_strcasecmp(e + 1, gaim_zephyr_get_realm())) { | |
591 *e = '\0'; | |
592 } | |
4687 | 593 b = gaim_find_buddy(zgc->account, user); |
8644 | 594 } |
595 if ((b && pending_zloc(b->name)) || pending_zloc(user)) { | |
2086 | 596 ZLocations_t locs; |
597 int one = 1; | |
598 GString *str = g_string_new(""); | |
8644 | 599 |
600 g_string_append_printf(str, _("<b>User:</b> %s<br>"), b ? b->name : user); | |
8435 | 601 if (b && b->alias) |
5132 | 602 g_string_append_printf(str, _("<b>Alias:</b> %s<br>"), b->alias); |
2086 | 603 if (!nlocs) { |
5132 | 604 g_string_append_printf(str, _("<br>Hidden or not logged-in")); |
2086 | 605 } |
606 for (; nlocs > 0; nlocs--) { | |
607 ZGetLocations(&locs, &one); | |
8644 | 608 g_string_append_printf(str, _("<br>At %s since %s"), locs.host, locs.time); |
2086 | 609 } |
8644 | 610 gaim_notify_formatted(zgc, NULL, _("Buddy Information"), NULL, str->str, NULL, NULL); |
2086 | 611 g_string_free(str, TRUE); |
612 } else | |
4732 | 613 serv_got_update(zgc, b->name, nlocs, 0, 0, 0, 0); |
2086 | 614 |
615 free(user); | |
616 } | |
617 } else { | |
8560 | 618 char *buf, *buf2, *buf3; |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
619 char *send_inst; |
8644 | 620 GaimConversation *gconv1; |
621 GaimConvChat *gcc; | |
2086 | 622 char *ptr = notice.z_message + strlen(notice.z_message) + 1; |
8876 | 623 int len = notice.z_message_len - (strlen(notice.z_message) +1); |
8644 | 624 char *sendertmp = g_strdup_printf("%s", gaim_zephyr_get_sender()); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7084
diff
changeset
|
625 GaimConvImFlags flags = 0; |
8644 | 626 |
2086 | 627 if (len > 0) { |
8644 | 628 gchar *tmpescape; |
8560 | 629 |
8644 | 630 buf = g_malloc(len + 1); |
631 g_snprintf(buf, len + 1, "%s", ptr); | |
632 g_strchomp(buf); | |
633 tmpescape = gaim_escape_html(buf); | |
634 buf2 = zephyr_to_html(tmpescape); | |
635 buf3 = zephyr_recv_convert(buf2, strlen(buf2)); | |
636 g_free(buf2); | |
637 g_free(buf); | |
638 g_free(tmpescape); | |
639 | |
9328 | 640 if (!g_ascii_strcasecmp(notice.z_class, "MESSAGE") && !g_ascii_strcasecmp(notice.z_class_inst, "PERSONAL") |
641 && !g_ascii_strcasecmp(notice.z_recipient,gaim_zephyr_get_sender())) { | |
642 gchar* stripped_sender; | |
4793 | 643 if (!g_ascii_strcasecmp(notice.z_message, "Automated reply:")) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7084
diff
changeset
|
644 flags |= GAIM_CONV_IM_AUTO_RESP; |
9328 | 645 stripped_sender = zephyr_strip_foreign_realm(notice.z_sender); |
646 serv_got_im(zgc, stripped_sender, buf3, flags, time(NULL)); | |
647 g_free(stripped_sender); | |
2086 | 648 } else { |
649 zephyr_triple *zt1, *zt2; | |
8644 | 650 |
651 zt1 = new_triple(notice.z_class, notice.z_class_inst, notice.z_recipient); | |
2086 | 652 zt2 = find_sub_by_triple(zt1); |
653 if (!zt2) { | |
654 /* we shouldn't be subscribed to this message. ignore. */ | |
655 } else { | |
8644 | 656 GList *gltmp; |
657 int found = 0; | |
658 | |
2086 | 659 if (!zt2->open) { |
660 zt2->open = TRUE; | |
661 serv_got_joined_chat(zgc, zt2->id, zt2->name); | |
8644 | 662 gconv1 = gaim_find_conversation_with_account(zt2->name, zgc->account); |
663 gcc = gaim_conversation_get_chat_data(gconv1); | |
664 gaim_conv_chat_set_topic(gcc, sendertmp, notice.z_class_inst); | |
8212 | 665 |
2086 | 666 } |
9328 | 667 g_free(sendertmp); /* fix memory leak? */ |
3277 | 668 /* If the person is in the default Realm, then strip the |
669 Realm from the sender field */ | |
9328 | 670 sendertmp = zephyr_strip_foreign_realm(notice.z_sender); |
671 send_inst = g_strdup_printf("%s %s",sendertmp,notice.z_class_inst); | |
8644 | 672 serv_got_chat_in(zgc, zt2->id, send_inst, FALSE, buf3, time(NULL)); |
8212 | 673 |
8644 | 674 gconv1 = gaim_find_conversation_with_account(zt2->name, zgc->account); |
675 gcc = gaim_conversation_get_chat_data(gconv1); | |
676 /* gaim_conv_chat_set_topic(gcc,sendertmp,notice.z_class_inst); */ | |
677 for (gltmp = gaim_conv_chat_get_users(gcc); gltmp; gltmp = gltmp->next) { | |
678 if (!g_ascii_strcasecmp(gltmp->data, sendertmp)) | |
679 found = 1; | |
680 } | |
681 if (!found) { | |
682 /* force interpretation in network byte order */ | |
683 unsigned char *addrs = (unsigned char *)&(notice.z_sender_addr.s_addr); | |
9328 | 684 gchar* ipaddr = g_strdup_printf("%hhd.%hhd.%hhd.%hhd", (unsigned char)addrs[0], |
685 (unsigned char)addrs[1], (unsigned char)addrs[2], | |
686 (unsigned char) addrs[3]); | |
8644 | 687 |
9328 | 688 gaim_conv_chat_add_user(gcc, sendertmp, ipaddr); |
689 g_free(ipaddr); /* fix memory leak? */ | |
8644 | 690 |
691 } | |
3277 | 692 g_free(sendertmp); |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
693 g_free(send_inst); |
2086 | 694 } |
695 free_triple(zt1); | |
696 } | |
8560 | 697 g_free(buf3); |
2086 | 698 } |
699 } | |
700 } | |
701 | |
702 static gint check_notify(gpointer data) | |
703 { | |
704 while (ZPending()) { | |
705 ZNotice_t notice; | |
706 struct sockaddr_in from; | |
8644 | 707 |
2086 | 708 z_call_r(ZReceiveNotice(¬ice, &from)); |
709 | |
710 switch (notice.z_kind) { | |
711 case UNSAFE: | |
712 case UNACKED: | |
713 case ACKED: | |
714 handle_message(notice, from); | |
715 break; | |
8644 | 716 case SERVACK: |
717 if (!(g_ascii_strcasecmp(notice.z_message, ZSRVACK_NOTSENT))) { | |
718 message_failed(notice, from); | |
719 } | |
720 break; | |
9328 | 721 case CLIENTACK: |
722 gaim_debug(GAIM_DEBUG_ERROR,"zephyr", "Client ack received\n"); | |
2086 | 723 default: |
724 /* we'll just ignore things for now */ | |
9328 | 725 handle_unknown(notice); |
726 gaim_debug(GAIM_DEBUG_ERROR, "zephyr", "Unhandled notice.\n"); | |
2086 | 727 break; |
728 } | |
729 | |
730 ZFreeNotice(¬ice); | |
731 } | |
732 | |
733 return TRUE; | |
734 } | |
735 | |
736 static gint check_loc(gpointer data) | |
737 { | |
6695 | 738 GaimBlistNode *gnode, *cnode, *bnode; |
2086 | 739 ZAsyncLocateData_t ald; |
740 | |
741 ald.user = NULL; | |
742 memset(&(ald.uid), 0, sizeof(ZUnique_Id_t)); | |
743 ald.version = NULL; | |
744 | |
8644 | 745 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
746 if (!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
4785 | 747 continue; |
8644 | 748 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
749 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 750 continue; |
8644 | 751 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
752 GaimBuddy *b = (GaimBuddy *) bnode; | |
753 | |
754 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
6695 | 755 continue; |
8644 | 756 if (b->account->gc == zgc) { |
7261 | 757 const char *chk; |
8644 | 758 |
8354 | 759 chk = local_zephyr_normalize(b->name); |
6695 | 760 /* doesn't matter if this fails or not; we'll just move on to the next one */ |
761 ZRequestLocations(chk, &ald, UNACKED, ZAUTH); | |
762 free(ald.user); | |
763 free(ald.version); | |
764 } | |
4349 | 765 } |
2086 | 766 } |
767 } | |
768 | |
769 return TRUE; | |
770 } | |
771 | |
772 static char *get_exposure_level() | |
773 { | |
774 char *exposure = ZGetVariable("exposure"); | |
775 | |
776 if (!exposure) | |
777 return EXPOSE_REALMVIS; | |
4793 | 778 if (!g_ascii_strcasecmp(exposure, EXPOSE_NONE)) |
2086 | 779 return EXPOSE_NONE; |
4793 | 780 if (!g_ascii_strcasecmp(exposure, EXPOSE_OPSTAFF)) |
2086 | 781 return EXPOSE_OPSTAFF; |
4793 | 782 if (!g_ascii_strcasecmp(exposure, EXPOSE_REALMANN)) |
2086 | 783 return EXPOSE_REALMANN; |
4793 | 784 if (!g_ascii_strcasecmp(exposure, EXPOSE_NETVIS)) |
2086 | 785 return EXPOSE_NETVIS; |
4793 | 786 if (!g_ascii_strcasecmp(exposure, EXPOSE_NETANN)) |
2086 | 787 return EXPOSE_NETANN; |
788 return EXPOSE_REALMVIS; | |
789 } | |
790 | |
791 static void strip_comments(char *str) | |
792 { | |
793 char *tmp = strchr(str, '#'); | |
8644 | 794 |
2086 | 795 if (tmp) |
796 *tmp = '\0'; | |
797 g_strchug(str); | |
798 g_strchomp(str); | |
799 } | |
800 | |
801 static void process_zsubs() | |
802 { | |
803 FILE *f; | |
804 gchar *fname; | |
805 gchar buff[BUFSIZ]; | |
8644 | 806 |
3630 | 807 fname = g_strdup_printf("%s/.zephyr.subs", gaim_home_dir()); |
2086 | 808 f = fopen(fname, "r"); |
809 if (f) { | |
810 char **triple; | |
811 ZSubscription_t sub; | |
812 char *recip; | |
8644 | 813 |
2086 | 814 while (fgets(buff, BUFSIZ, f)) { |
815 strip_comments(buff); | |
816 if (buff[0]) { | |
817 triple = g_strsplit(buff, ",", 3); | |
8644 | 818 if (triple[0] && triple[1]) { |
819 char *tmp = g_strdup_printf("%s", gaim_zephyr_get_sender()); | |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
820 char *atptr; |
8644 | 821 |
2086 | 822 sub.zsub_class = triple[0]; |
823 sub.zsub_classinst = triple[1]; | |
8644 | 824 if (triple[2] == NULL) { |
3277 | 825 recip = g_malloc0(1); |
4793 | 826 } else if (!g_ascii_strcasecmp(triple[2], "%me%")) { |
8644 | 827 recip = g_strdup_printf("%s", gaim_zephyr_get_sender()); |
4793 | 828 } else if (!g_ascii_strcasecmp(triple[2], "*")) { |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
829 /* wildcard |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
830 * form of class,instance,* */ |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
831 recip = g_malloc0(1); |
4793 | 832 } else if (!g_ascii_strcasecmp(triple[2], tmp)) { |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
833 /* form of class,instance,aatharuv@ATHENA.MIT.EDU */ |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
834 recip = g_strdup(triple[2]); |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
835 } else if ((atptr = strchr(triple[2], '@')) != NULL) { |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
836 /* form of class,instance,*@ANDREW.CMU.EDU |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
837 * class,instance,@ANDREW.CMU.EDU |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
838 * If realm is local realm, blank recipient, else |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
839 * @REALM-NAME |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
840 */ |
8644 | 841 char *realmat = g_strdup_printf("@%s", |
842 gaim_zephyr_get_realm()); | |
843 | |
4793 | 844 if (!g_ascii_strcasecmp(atptr, realmat)) |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
845 recip = g_malloc0(1); |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
846 else |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
847 recip = g_strdup(atptr); |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
848 g_free(realmat); |
2086 | 849 } else { |
850 recip = g_strdup(triple[2]); | |
851 } | |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
852 g_free(tmp); |
2086 | 853 sub.zsub_recipient = recip; |
854 if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) { | |
8644 | 855 gaim_debug(GAIM_DEBUG_ERROR, "zephyr", "Couldn't subscribe to %s, %s, %s\n", sub.zsub_class, sub.zsub_classinst, sub.zsub_recipient); |
2086 | 856 } |
8644 | 857 subscrips = g_slist_append(subscrips, new_triple(triple[0], triple[1], recip)); |
2086 | 858 g_free(recip); |
859 } | |
860 g_strfreev(triple); | |
861 } | |
862 } | |
863 } | |
864 } | |
865 | |
866 static void process_anyone() | |
867 { | |
868 FILE *fd; | |
869 gchar buff[BUFSIZ], *filename; | |
6695 | 870 GaimGroup *g; |
871 GaimBuddy *b; | |
4775 | 872 |
873 if (!(g = gaim_find_group(_("Anyone")))) { | |
874 g = gaim_group_new(_("Anyone")); | |
875 gaim_blist_add_group(g, NULL); | |
876 } | |
6695 | 877 |
3630 | 878 filename = g_strconcat(gaim_home_dir(), "/.anyone", NULL); |
2086 | 879 if ((fd = fopen(filename, "r")) != NULL) { |
880 while (fgets(buff, BUFSIZ, fd)) { | |
881 strip_comments(buff); | |
4687 | 882 if (buff[0]) { |
8644 | 883 if (!(b = gaim_find_buddy(zgc->account, buff))) { |
884 b = gaim_buddy_new(zgc->account, buff, NULL); | |
885 gaim_blist_add_buddy(b, NULL, g, NULL); | |
886 } | |
887 } | |
2086 | 888 } |
889 fclose(fd); | |
890 } | |
891 g_free(filename); | |
892 } | |
893 | |
8644 | 894 static void zephyr_login(GaimAccount * account) |
2086 | 895 { |
896 ZSubscription_t sub; | |
9426 | 897 unsigned short port = 0; |
898 FILE* wgfile; | |
899 char* wgfilename; | |
2086 | 900 if (zgc) { |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
901 gaim_notify_error(account->gc, NULL, |
8644 | 902 _("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 | 903 return; |
904 } | |
905 | |
5606 | 906 zgc = gaim_account_get_connection(account); |
8644 | 907 zgc->flags |= GAIM_CONNECTION_HTML; |
8645 | 908 gaim_connection_update_progress(zgc, _("Connecting"), 0, 2); |
909 | |
2086 | 910 z_call_s(ZInitialize(), "Couldn't initialize zephyr"); |
9426 | 911 z_call_s(ZOpenPort(&port), "Couldn't open port"); |
8644 | 912 z_call_s(ZSetLocation((char *) |
913 gaim_account_get_string(zgc->account, "exposure_level", EXPOSE_REALMVIS)), "Couldn't set location"); | |
2086 | 914 |
915 sub.zsub_class = "MESSAGE"; | |
916 sub.zsub_classinst = "PERSONAL"; | |
8354 | 917 sub.zsub_recipient = (char *)gaim_zephyr_get_sender(); |
9426 | 918 |
2086 | 919 /* we don't care if this fails. i'm lying right now. */ |
920 if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) { | |
8644 | 921 gaim_debug(GAIM_DEBUG_ERROR, "zephyr", "Couldn't subscribe to messages!\n"); |
2086 | 922 } |
923 | |
9426 | 924 wgfile = gaim_mkstemp_template(&wgfilename,"gaimwgXXXXXX"); |
925 if (wgfile) { | |
926 fprintf(wgfile,"%d\n",port); | |
927 fclose(wgfile); | |
928 } | |
5606 | 929 gaim_connection_set_state(zgc, GAIM_CONNECTED); |
2086 | 930 serv_finish_login(zgc); |
931 | |
932 process_anyone(); | |
933 process_zsubs(); | |
934 | |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8212
diff
changeset
|
935 nottimer = gaim_timeout_add(100, check_notify, NULL); |
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8212
diff
changeset
|
936 loctimer = gaim_timeout_add(20000, check_loc, NULL); |
2086 | 937 } |
938 | |
939 static void write_zsubs() | |
940 { | |
941 GSList *s = subscrips; | |
942 zephyr_triple *zt; | |
943 FILE *fd; | |
944 char *fname; | |
945 | |
8644 | 946 char **triple; |
947 | |
3630 | 948 fname = g_strdup_printf("%s/.zephyr.subs", gaim_home_dir()); |
2086 | 949 fd = fopen(fname, "w"); |
8644 | 950 |
2086 | 951 if (!fd) { |
952 g_free(fname); | |
953 return; | |
954 } | |
8644 | 955 |
2086 | 956 while (s) { |
957 zt = s->data; | |
8644 | 958 triple = g_strsplit(zt->name, ",", 3); |
3277 | 959 if (triple[2] != NULL) { |
4793 | 960 if (!g_ascii_strcasecmp(triple[2], "")) { |
3277 | 961 fprintf(fd, "%s,%s,*\n", triple[0], triple[1]); |
8354 | 962 } else if (!g_ascii_strcasecmp(triple[2], gaim_zephyr_get_sender())) { |
8644 | 963 fprintf(fd, "%s,%s,%%me%%\n", triple[0], triple[1]); |
3277 | 964 } else { |
965 fprintf(fd, "%s\n", zt->name); | |
966 } | |
967 } else { | |
8644 | 968 fprintf(fd, "%s,%s,*\n", triple[0], triple[1]); |
3277 | 969 } |
970 g_free(triple); | |
2086 | 971 s = s->next; |
972 } | |
973 g_free(fname); | |
974 fclose(fd); | |
975 } | |
976 | |
977 static void write_anyone() | |
978 { | |
6695 | 979 GaimBlistNode *gnode, *cnode, *bnode; |
980 GaimBuddy *b; | |
3277 | 981 char *ptr, *fname, *ptr2; |
2086 | 982 FILE *fd; |
983 | |
3630 | 984 fname = g_strdup_printf("%s/.anyone", gaim_home_dir()); |
2086 | 985 fd = fopen(fname, "w"); |
986 if (!fd) { | |
987 g_free(fname); | |
988 return; | |
989 } | |
990 | |
8644 | 991 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
992 if (!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
4785 | 993 continue; |
8644 | 994 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
995 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 996 continue; |
8644 | 997 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
998 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
6695 | 999 continue; |
8644 | 1000 b = (GaimBuddy *) bnode; |
1001 if (b->account == zgc->account) { | |
6695 | 1002 if ((ptr = strchr(b->name, '@')) != NULL) { |
1003 ptr2 = ptr + 1; | |
1004 /* We should only strip the realm name if the principal | |
1005 is in the user's realm | |
8644 | 1006 */ |
1007 if (!g_ascii_strcasecmp(ptr2, gaim_zephyr_get_realm())) { | |
6695 | 1008 *ptr = '\0'; |
1009 } | |
4349 | 1010 } |
6695 | 1011 fprintf(fd, "%s\n", b->name); |
1012 if (ptr) | |
1013 *ptr = '@'; | |
3277 | 1014 } |
1015 } | |
2086 | 1016 } |
1017 } | |
1018 | |
1019 fclose(fd); | |
1020 g_free(fname); | |
1021 } | |
1022 | |
8644 | 1023 static void zephyr_close(GaimConnection * gc) |
2086 | 1024 { |
1025 GList *l; | |
1026 GSList *s; | |
8644 | 1027 |
2086 | 1028 l = pending_zloc_names; |
1029 while (l) { | |
8644 | 1030 g_free((char *)l->data); |
2086 | 1031 l = l->next; |
1032 } | |
1033 g_list_free(pending_zloc_names); | |
8644 | 1034 |
1035 if (gaim_account_get_bool(zgc->account, "write_anyone", FALSE)) | |
8212 | 1036 write_anyone(); |
8644 | 1037 |
1038 if (gaim_account_get_bool(zgc->account, "write_zsubs", FALSE)) | |
8212 | 1039 write_zsubs(); |
8644 | 1040 |
2086 | 1041 s = subscrips; |
1042 while (s) { | |
8644 | 1043 free_triple((zephyr_triple *) s->data); |
2086 | 1044 s = s->next; |
1045 } | |
1046 g_slist_free(subscrips); | |
8644 | 1047 |
2086 | 1048 if (nottimer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1049 gaim_timeout_remove(nottimer); |
2086 | 1050 nottimer = 0; |
1051 if (loctimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
1052 gaim_timeout_remove(loctimer); |
2086 | 1053 loctimer = 0; |
1054 zgc = NULL; | |
1055 z_call(ZCancelSubscriptions(0)); | |
1056 z_call(ZUnsetLocation()); | |
1057 z_call(ZClosePort()); | |
1058 } | |
1059 | |
8644 | 1060 static int zephyr_chat_send(GaimConnection * gc, int id, const char *im) |
2086 | 1061 { |
1062 ZNotice_t notice; | |
1063 zephyr_triple *zt; | |
1064 char *buf; | |
1065 const char *sig; | |
8644 | 1066 GaimConversation *gconv1; |
1067 GaimConvChat *gcc; | |
1068 char *inst; | |
1069 char *html_buf; | |
1070 char *html_buf2; | |
2086 | 1071 |
1072 zt = find_sub_by_id(id); | |
1073 if (!zt) | |
1074 /* this should never happen. */ | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1075 return -EINVAL; |
8644 | 1076 |
2086 | 1077 sig = ZGetVariable("zwrite-signature"); |
1078 if (!sig) { | |
1079 sig = g_get_real_name(); | |
1080 } | |
8451 | 1081 |
8644 | 1082 html_buf = html_to_zephyr(im); |
1083 html_buf2 = gaim_unescape_html(html_buf); | |
8451 | 1084 |
1085 buf = g_strdup_printf("%s%c%s", sig, '\0', html_buf2); | |
2086 | 1086 |
8644 | 1087 gconv1 = gaim_find_conversation_with_account(zt->name, zgc->account); |
1088 gcc = gaim_conversation_get_chat_data(gconv1); | |
9328 | 1089 |
1090 /* Woops. Setting instance to "PERSONAL" which is the default | |
1091 sending instance if no instance is set */ | |
8212 | 1092 |
8644 | 1093 if (!(inst = (char *)gaim_conv_chat_get_topic(gcc))) |
9328 | 1094 inst = "PERSONAL"; |
8644 | 1095 |
2086 | 1096 bzero((char *)¬ice, sizeof(notice)); |
1097 notice.z_kind = ACKED; | |
1098 notice.z_port = 0; | |
1099 notice.z_opcode = ""; | |
1100 notice.z_class = zt->class; | |
8212 | 1101 notice.z_class_inst = inst; |
4793 | 1102 if (!g_ascii_strcasecmp(zt->recipient, "*")) |
8354 | 1103 notice.z_recipient = local_zephyr_normalize(""); |
2086 | 1104 else |
8354 | 1105 notice.z_recipient = local_zephyr_normalize(zt->recipient); |
2086 | 1106 notice.z_sender = 0; |
8644 | 1107 notice.z_default_format = "Class $class, Instance $instance:\n" "To: @bold($recipient) at $time $date\n" "From: @bold($1) <$sender>\n\n$2"; |
8451 | 1108 notice.z_message_len = strlen(html_buf2) + strlen(sig) + 2; |
2086 | 1109 notice.z_message = buf; |
8644 | 1110 g_free(html_buf); |
1111 g_free(html_buf2); | |
8451 | 1112 |
2086 | 1113 ZSendNotice(¬ice, ZAUTH); |
1114 g_free(buf); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1115 return 0; |
2086 | 1116 } |
1117 | |
8644 | 1118 static int zephyr_send_im(GaimConnection * gc, const char *who, const char *im, GaimConvImFlags flags) |
1119 { | |
2086 | 1120 ZNotice_t notice; |
1121 char *buf; | |
1122 const char *sig; | |
8644 | 1123 char *html_buf; |
1124 char *html_buf2; | |
1125 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7084
diff
changeset
|
1126 if (flags & GAIM_CONV_IM_AUTO_RESP) |
2086 | 1127 sig = "Automated reply:"; |
1128 else { | |
1129 sig = ZGetVariable("zwrite-signature"); | |
1130 if (!sig) { | |
1131 sig = g_get_real_name(); | |
1132 } | |
1133 } | |
1134 | |
8644 | 1135 html_buf = html_to_zephyr(im); |
1136 html_buf2 = gaim_unescape_html(html_buf); | |
8451 | 1137 |
1138 buf = g_strdup_printf("%s%c%s", sig, '\0', html_buf2); | |
2086 | 1139 bzero((char *)¬ice, sizeof(notice)); |
1140 notice.z_kind = ACKED; | |
1141 notice.z_port = 0; | |
1142 notice.z_opcode = ""; | |
1143 notice.z_class = "MESSAGE"; | |
1144 notice.z_class_inst = "PERSONAL"; | |
1145 notice.z_sender = 0; | |
9328 | 1146 notice.z_recipient = local_zephyr_normalize(who); |
8644 | 1147 notice.z_default_format = "Class $class, Instance $instance:\n" "To: @bold($recipient) at $time $date\n" "From: @bold($1) <$sender>\n\n$2"; |
8451 | 1148 notice.z_message_len = strlen(html_buf2) + strlen(sig) + 2; |
2086 | 1149 notice.z_message = buf; |
8644 | 1150 g_free(html_buf2); |
1151 g_free(html_buf); | |
8451 | 1152 |
6904 | 1153 ZSendNotice(¬ice, ZAUTH); |
2086 | 1154 g_free(buf); |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
1155 return 1; |
2086 | 1156 } |
1157 | |
8644 | 1158 static const char *zephyr_normalize(const GaimAccount * account, const char *orig) |
2086 | 1159 { |
9328 | 1160 /* returns the string you gave it. Maybe this function shouldn't be here */ |
2086 | 1161 static char buf[80]; |
8644 | 1162 |
7126 | 1163 if (!g_ascii_strcasecmp(orig, "")) { |
1164 buf[0] = '\0'; | |
1165 return buf; | |
8354 | 1166 } else { |
8644 | 1167 g_snprintf(buf, 80, "%s", orig); |
1168 } | |
1169 return buf; | |
8354 | 1170 } |
1171 | |
1172 | |
9328 | 1173 char *local_zephyr_normalize(const char *orig) |
8354 | 1174 { |
9328 | 1175 /* |
1176 Basically the inverse of zephyr_strip_foreign_realm | |
1177 | |
1178 */ | |
8644 | 1179 static char buf[80]; |
1180 | |
8354 | 1181 if (!g_ascii_strcasecmp(orig, "")) { |
1182 buf[0] = '\0'; | |
1183 return buf; | |
7126 | 1184 } |
8644 | 1185 |
2086 | 1186 if (strchr(orig, '@')) { |
1187 g_snprintf(buf, 80, "%s", orig); | |
1188 } else { | |
8644 | 1189 g_snprintf(buf, 80, "%s@%s", orig, gaim_zephyr_get_realm()); |
2086 | 1190 } |
1191 return buf; | |
1192 } | |
1193 | |
9030 | 1194 static void zephyr_zloc(GaimConnection *gc, const char *who) |
2086 | 1195 { |
1196 ZAsyncLocateData_t ald; | |
9328 | 1197 gchar* normalized_who = local_zephyr_normalize(who); |
7261 | 1198 |
9328 | 1199 if (ZRequestLocations(normalized_who, &ald, UNACKED, ZAUTH) == ZERR_NONE) { |
9030 | 1200 pending_zloc_names = g_list_append(pending_zloc_names, |
9328 | 1201 g_strdup(normalized_who)); |
2086 | 1202 } |
1203 } | |
1204 | |
8644 | 1205 static void zephyr_set_away(GaimConnection * gc, const char *state, const char *msg) |
2086 | 1206 { |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
1207 if (gc->away) { |
2086 | 1208 g_free(gc->away); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
1209 gc->away = NULL; |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
1210 } |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
1211 |
5132 | 1212 if (!g_ascii_strcasecmp(state, _("Hidden"))) { |
2086 | 1213 ZSetLocation(EXPOSE_OPSTAFF); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
1214 gc->away = g_strdup(""); |
5132 | 1215 } else if (!g_ascii_strcasecmp(state, _("Online"))) |
2086 | 1216 ZSetLocation(get_exposure_level()); |
1217 else /* state is GAIM_AWAY_CUSTOM */ if (msg) | |
1218 gc->away = g_strdup(msg); | |
1219 } | |
1220 | |
8644 | 1221 static GList *zephyr_away_states(GaimConnection * gc) |
2086 | 1222 { |
1223 GList *m = NULL; | |
1224 | |
5132 | 1225 m = g_list_append(m, _("Online")); |
2086 | 1226 m = g_list_append(m, GAIM_AWAY_CUSTOM); |
5132 | 1227 m = g_list_append(m, _("Hidden")); |
2086 | 1228 |
1229 return m; | |
1230 } | |
1231 | |
8644 | 1232 static GList *zephyr_chat_info(GaimConnection * gc) |
1233 { | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1234 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1235 struct proto_chat_entry *pce; |
2086 | 1236 |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1237 pce = g_new0(struct proto_chat_entry, 1); |
8644 | 1238 |
7841 | 1239 pce->label = _("_Class:"); |
5234 | 1240 pce->identifier = "class"; |
3158 | 1241 m = g_list_append(m, pce); |
2086 | 1242 |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1243 pce = g_new0(struct proto_chat_entry, 1); |
8644 | 1244 |
7841 | 1245 pce->label = _("_Instance:"); |
5234 | 1246 pce->identifier = "instance"; |
3158 | 1247 m = g_list_append(m, pce); |
2086 | 1248 |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1249 pce = g_new0(struct proto_chat_entry, 1); |
8644 | 1250 |
7841 | 1251 pce->label = _("_Recipient:"); |
5234 | 1252 pce->identifier = "recipient"; |
3158 | 1253 m = g_list_append(m, pce); |
2086 | 1254 |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1255 return m; |
2086 | 1256 } |
1257 | |
8644 | 1258 static void zephyr_join_chat(GaimConnection * gc, GHashTable * data) |
2086 | 1259 { |
1260 ZSubscription_t sub; | |
1261 zephyr_triple *zt1, *zt2; | |
1262 const char *classname; | |
1263 const char *instname; | |
1264 const char *recip; | |
9328 | 1265 GaimConversation *gconv; |
1266 GaimConvChat *gcc; | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1267 |
5234 | 1268 classname = g_hash_table_lookup(data, "class"); |
1269 instname = g_hash_table_lookup(data, "instance"); | |
1270 recip = g_hash_table_lookup(data, "recipient"); | |
1271 | |
9328 | 1272 if (!classname) |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1273 return; |
9328 | 1274 if (!instname || !strlen(instname)) |
1275 instname = "*"; | |
1276 if (!recip || (*recip == '*')) | |
1277 recip = ""; | |
4793 | 1278 if (!g_ascii_strcasecmp(recip, "%me%")) |
8354 | 1279 recip = gaim_zephyr_get_sender(); |
2086 | 1280 |
1281 zt1 = new_triple(classname, instname, recip); | |
1282 zt2 = find_sub_by_triple(zt1); | |
1283 if (zt2) { | |
1284 free_triple(zt1); | |
9328 | 1285 if (!zt2->open) { |
2086 | 1286 serv_got_joined_chat(gc, zt2->id, zt2->name); |
9328 | 1287 gconv = gaim_find_conversation_with_account(zt2->name, zgc->account); |
1288 gcc = gaim_conversation_get_chat_data(gconv); | |
1289 if (!g_ascii_strcasecmp(instname,"*")) | |
1290 instname = "PERSONAL"; | |
1291 gaim_conv_chat_set_topic(gcc, gaim_zephyr_get_sender(), instname); | |
1292 zt2->open = TRUE; | |
1293 } | |
2086 | 1294 return; |
1295 } | |
1296 | |
1297 sub.zsub_class = zt1->class; | |
1298 sub.zsub_classinst = zt1->instance; | |
1299 sub.zsub_recipient = zt1->recipient; | |
1300 | |
1301 if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) { | |
1302 free_triple(zt1); | |
1303 return; | |
1304 } | |
1305 | |
1306 subscrips = g_slist_append(subscrips, zt1); | |
1307 zt1->open = TRUE; | |
1308 serv_got_joined_chat(gc, zt1->id, zt1->name); | |
9328 | 1309 gconv = gaim_find_conversation_with_account(zt1->name, zgc->account); |
1310 gcc = gaim_conversation_get_chat_data(gconv); | |
1311 if (!g_ascii_strcasecmp(instname,"*")) | |
1312 instname = "PERSONAL"; | |
1313 gaim_conv_chat_set_topic(gcc, gaim_zephyr_get_sender(), instname); | |
2086 | 1314 } |
1315 | |
8644 | 1316 static void zephyr_chat_leave(GaimConnection * gc, int id) |
2086 | 1317 { |
1318 zephyr_triple *zt; | |
8644 | 1319 |
2086 | 1320 zt = find_sub_by_id(id); |
1321 if (zt) { | |
1322 zt->open = FALSE; | |
1323 zt->id = ++last_id; | |
1324 } | |
1325 } | |
1326 | |
8644 | 1327 static const char *zephyr_list_icon(GaimAccount * a, GaimBuddy * b) |
5202 | 1328 { |
1329 return "zephyr"; | |
1330 } | |
1331 | |
8212 | 1332 |
8644 | 1333 static void zephyr_chat_set_topic(GaimConnection * gc, int id, const char *topic) |
1334 { | |
1335 zephyr_triple *zt; | |
1336 GaimConversation *gconv; | |
1337 GaimConvChat *gcc; | |
1338 char *sender = (char *)gaim_zephyr_get_sender(); | |
8212 | 1339 |
8644 | 1340 zt = find_sub_by_id(id); |
1341 gconv = gaim_find_conversation_with_account(zt->name, zgc->account); | |
1342 gcc = gaim_conversation_get_chat_data(gconv); | |
1343 gaim_conv_chat_set_topic(gcc, sender, topic); | |
1344 | |
8212 | 1345 } |
1346 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1347 static GaimPlugin *my_protocol = NULL; |
2086 | 1348 |
8644 | 1349 static GaimPluginProtocolInfo prpl_info = { |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8713
diff
changeset
|
1350 GAIM_PRPL_API_VERSION, |
8644 | 1351 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_NO_PASSWORD, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1352 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1353 NULL, |
9308 | 1354 NO_BUDDY_ICONS, |
1355 zephyr_list_icon, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1356 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1357 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1358 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1359 zephyr_away_states, |
9030 | 1360 NULL, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1361 zephyr_chat_info, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1362 zephyr_login, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1363 zephyr_close, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1364 zephyr_send_im, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1365 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1366 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1367 zephyr_zloc, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1368 zephyr_set_away, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1369 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1370 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1371 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1372 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1373 NULL, |
8644 | 1374 NULL, |
1375 NULL, | |
1376 NULL, | |
1377 NULL, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1378 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1379 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1380 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1381 zephyr_join_chat, |
8644 | 1382 NULL, /* reject chat invite */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1383 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1384 zephyr_chat_leave, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1385 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1386 zephyr_chat_send, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1387 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1388 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1389 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1390 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1391 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1392 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1393 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1394 NULL, |
8568 | 1395 NULL, |
8212 | 1396 zephyr_normalize, |
8568 | 1397 NULL, |
1398 NULL, | |
1399 NULL, | |
8586 | 1400 zephyr_chat_set_topic, |
8644 | 1401 NULL, |
1402 NULL, | |
1403 NULL, | |
1404 NULL | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1405 }; |
2086 | 1406 |
8644 | 1407 static GaimPluginInfo info = { |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
8713
diff
changeset
|
1408 GAIM_PLUGIN_API_VERSION, /**< api_version */ |
8644 | 1409 GAIM_PLUGIN_PROTOCOL, /**< type */ |
1410 NULL, /**< ui_requirement */ | |
1411 0, /**< flags */ | |
1412 NULL, /**< dependencies */ | |
1413 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1414 |
8644 | 1415 "prpl-zephyr", /**< id */ |
1416 "Zephyr", /**< name */ | |
1417 VERSION, /**< version */ | |
1418 /** summary */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1419 N_("Zephyr Protocol Plugin"), |
8644 | 1420 /** description */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1421 N_("Zephyr Protocol Plugin"), |
8644 | 1422 NULL, /**< author */ |
1423 GAIM_WEBSITE, /**< homepage */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1424 |
8644 | 1425 NULL, /**< load */ |
1426 NULL, /**< unload */ | |
1427 NULL, /**< destroy */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1428 |
8644 | 1429 NULL, /**< ui_info */ |
8993 | 1430 &prpl_info, /**< extra_info */ |
1431 NULL, | |
1432 NULL | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1433 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1434 |
8644 | 1435 static void init_plugin(GaimPlugin * plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1436 { |
8212 | 1437 GaimAccountOption *option; |
8644 | 1438 char *tmp = get_exposure_level(); |
1439 | |
1440 option = gaim_account_option_bool_new(_("Export to .anyone"), "write_anyone", FALSE); | |
1441 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
8212 | 1442 |
8644 | 1443 option = gaim_account_option_bool_new(_("Export to .zephyr.subs"), "write_zsubs", FALSE); |
1444 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
8212 | 1445 |
8644 | 1446 option = gaim_account_option_string_new(_("Exposure"), "exposure_level", tmp ? tmp : EXPOSE_REALMVIS); |
1447 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
8212 | 1448 |
8644 | 1449 option = gaim_account_option_string_new(_("Encoding"), "encoding", ZEPHYR_FALLBACK_CHARSET); |
1450 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
8560 | 1451 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1452 my_protocol = plugin; |
2086 | 1453 } |
1454 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1455 GAIM_INIT_PLUGIN(zephyr, init_plugin, info); |