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