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