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