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