Mercurial > pidgin
annotate src/protocols/zephyr/zephyr.c @ 5641:5e9babc828c4
[gaim-migrate @ 6054]
The Modify Account dialog shows, but don't expect it to be functional in
any way :) I had to get this out of the way to fix something else.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Sun, 01 Jun 2003 20:27:35 +0000 |
parents | 328dde25685a |
children | 1d140b31d4b3 |
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 | |
7 * Jag/Sean Dilda <agrajag@linuxpower.org>/<smdilda@unity.ncsu.edu> | |
8 * http://gtkzephyr.linuxpower.org/ | |
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 */ | |
25 | |
26 #ifdef HAVE_CONFIG_H | |
27 #include "config.h" | |
28 #endif | |
29 | |
30 #include <string.h> | |
31 #include <stdlib.h> | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
32 #include <errno.h> |
2086 | 33 #include "gaim.h" |
34 #include "prpl.h" | |
35 #include "zephyr/zephyr.h" | |
36 | |
37 extern Code_t ZGetLocations(ZLocations_t *, int *); | |
38 extern Code_t ZSetLocation(char *); | |
39 extern Code_t ZUnsetLocation(); | |
40 | |
41 typedef struct _zframe zframe; | |
42 typedef struct _zephyr_triple zephyr_triple; | |
43 | |
44 /* struct I need for zephyr_to_html */ | |
45 struct _zframe { | |
46 /* true for everything but @color, since inside the parens of that one is | |
47 * the color. */ | |
48 gboolean has_closer; | |
49 /* </i>, </font>, </b>, etc. */ | |
50 char *closing; | |
51 /* text including the opening html thingie. */ | |
52 GString *text; | |
53 struct _zframe *enclosing; | |
54 }; | |
55 | |
56 struct _zephyr_triple { | |
57 char *class; | |
58 char *instance; | |
59 char *recipient; | |
60 char *name; | |
61 gboolean open; | |
62 int id; | |
63 }; | |
64 | |
65 #define z_call(func) if (func != ZERR_NONE)\ | |
66 return; | |
67 #define z_call_r(func) if (func != ZERR_NONE)\ | |
68 return TRUE; | |
69 #define z_call_s(func, err) if (func != ZERR_NONE) {\ | |
5606 | 70 gaim_connection_error(zgc, err);\ |
2086 | 71 return;\ |
72 } | |
73 | |
74 static char *zephyr_normalize(const char *); | |
75 | |
76 /* this is so bad, and if Zephyr weren't so fucked up to begin with I | |
77 * wouldn't do this. but it is so i will. */ | |
78 static guint32 nottimer = 0; | |
79 static guint32 loctimer = 0; | |
5606 | 80 GaimConnection *zgc = NULL; |
2086 | 81 static GList *pending_zloc_names = NULL; |
82 static GSList *subscrips = NULL; | |
83 static int last_id = 0; | |
84 | |
85 /* just for debugging | |
86 static void handle_unknown(ZNotice_t notice) | |
87 { | |
3630 | 88 debug_printf("z_packet: %s\n", notice.z_packet); |
89 debug_printf("z_version: %s\n", notice.z_version); | |
90 debug_printf("z_kind: %d\n", notice.z_kind); | |
91 debug_printf("z_class: %s\n", notice.z_class); | |
92 debug_printf("z_class_inst: %s\n", notice.z_class_inst); | |
93 debug_printf("z_opcode: %s\n", notice.z_opcode); | |
94 debug_printf("z_sender: %s\n", notice.z_sender); | |
95 debug_printf("z_recipient: %s\n", notice.z_recipient); | |
96 debug_printf("z_message: %s\n", notice.z_message); | |
97 debug_printf("z_message_len: %d\n", notice.z_message_len); | |
98 debug_printf("\n"); | |
2086 | 99 } |
100 */ | |
101 | |
102 static zephyr_triple *new_triple(const char *c, const char *i, const char *r) | |
103 { | |
104 zephyr_triple *zt; | |
105 zt = g_new0(zephyr_triple, 1); | |
106 zt->class = g_strdup(c); | |
107 zt->instance = g_strdup(i); | |
108 zt->recipient = g_strdup(r); | |
109 zt->name = g_strdup_printf("%s,%s,%s", c, i, r); | |
110 zt->id = ++last_id; | |
111 zt->open = FALSE; | |
112 return zt; | |
113 } | |
114 | |
115 static void free_triple(zephyr_triple *zt) | |
116 { | |
117 g_free(zt->class); | |
118 g_free(zt->instance); | |
119 g_free(zt->recipient); | |
120 g_free(zt->name); | |
121 g_free(zt); | |
122 } | |
123 | |
124 /* returns true if zt1 is a subset of zt2, i.e. zt2 has the same thing or | |
125 * wildcards in each field of zt1. */ | |
126 static gboolean triple_subset(zephyr_triple *zt1, zephyr_triple *zt2) | |
127 { | |
4793 | 128 if (g_ascii_strcasecmp(zt2->class, zt1->class) && |
129 g_ascii_strcasecmp(zt2->class, "*")) { | |
2086 | 130 return FALSE; |
131 } | |
4793 | 132 if (g_ascii_strcasecmp(zt2->instance, zt1->instance) && |
133 g_ascii_strcasecmp(zt2->instance, "*")) { | |
2086 | 134 return FALSE; |
135 } | |
4793 | 136 if (g_ascii_strcasecmp(zt2->recipient, zt1->recipient) && |
137 g_ascii_strcasecmp(zt2->recipient, "*")) { | |
2086 | 138 return FALSE; |
139 } | |
140 return TRUE; | |
141 } | |
142 | |
143 static zephyr_triple *find_sub_by_triple(zephyr_triple *zt) | |
144 { | |
145 zephyr_triple *curr_t; | |
146 GSList *curr = subscrips; | |
147 while (curr) { | |
148 curr_t = curr->data; | |
149 if (triple_subset(zt, curr_t)) | |
150 return curr_t; | |
151 curr = curr->next; | |
152 } | |
153 return NULL; | |
154 } | |
155 | |
156 static zephyr_triple *find_sub_by_id(int id) | |
157 { | |
158 zephyr_triple *zt; | |
159 GSList *curr = subscrips; | |
160 while (curr) { | |
161 zt = curr->data; | |
162 if (zt->id == id) | |
163 return zt; | |
164 curr = curr->next; | |
165 } | |
166 return NULL; | |
167 } | |
168 | |
169 /* utility macros that are useful for zephyr_to_html */ | |
170 | |
171 #define IS_OPENER(c) ((c == '{') || (c == '[') || (c == '(') || (c == '<')) | |
172 #define IS_CLOSER(c) ((c == '}') || (c == ']') || (c == ')') || (c == '>')) | |
173 | |
174 /* this parses zephyr formatting and converts it to html. For example, if | |
175 * you pass in "@{@color(blue)@i(hello)}" you should get out | |
176 * "<font color=blue><i>hello</i></font>". */ | |
177 static char *zephyr_to_html(char *message) | |
178 { | |
179 int len, cnt; | |
180 zframe *frames, *curr; | |
181 char *ret; | |
182 | |
183 frames = g_new(zframe, 1); | |
184 frames->text = g_string_new(""); | |
185 frames->enclosing = NULL; | |
186 frames->closing = ""; | |
187 frames->has_closer = FALSE; | |
188 | |
189 len = strlen(message); | |
190 cnt = 0; | |
191 while (cnt <= len) { | |
192 if (message[cnt] == '@') { | |
193 zframe *new_f; | |
194 char *buf; | |
195 int end; | |
196 for (end=1; (cnt+end) <= len && | |
197 !IS_OPENER(message[cnt+end]); end++); | |
198 buf = g_new0(char, end); | |
199 if (end) { | |
200 g_snprintf(buf, end, "%s", message+cnt+1); | |
201 } | |
4793 | 202 if (!g_ascii_strcasecmp(buf, "italic") || |
203 !g_ascii_strcasecmp(buf, "i")) { | |
2086 | 204 new_f = g_new(zframe, 1); |
205 new_f->enclosing = frames; | |
206 new_f->text = g_string_new("<i>"); | |
207 new_f->closing = "</i>"; | |
208 new_f->has_closer = TRUE; | |
209 frames = new_f; | |
210 cnt += end+1; /* cnt points to char after opener */ | |
4793 | 211 } else if (!g_ascii_strcasecmp(buf, "bold") |
212 || !g_ascii_strcasecmp(buf, "b")) { | |
2086 | 213 new_f = g_new(zframe, 1); |
214 new_f->enclosing = frames; | |
215 new_f->text = g_string_new("<b>"); | |
216 new_f->closing = "</b>"; | |
217 new_f->has_closer = TRUE; | |
218 frames = new_f; | |
219 cnt += end+1; | |
4793 | 220 } else if (!g_ascii_strcasecmp(buf, "color")) { |
2086 | 221 cnt += end+1; |
222 new_f = g_new(zframe, 1); | |
223 new_f->enclosing = frames; | |
224 new_f->text = g_string_new("<font color="); | |
225 for (; (cnt <= len) && !IS_CLOSER(message[cnt]); cnt++) { | |
226 g_string_append_c(new_f->text, message[cnt]); | |
227 } | |
228 cnt++; /* point to char after closer */ | |
229 g_string_append_c(new_f->text, '>'); | |
230 new_f->closing = "</font>"; | |
231 new_f->has_closer = FALSE; | |
232 frames = new_f; | |
4793 | 233 } else if (!g_ascii_strcasecmp(buf, "")) { |
2086 | 234 new_f = g_new(zframe, 1); |
235 new_f->enclosing = frames; | |
236 new_f->text = g_string_new(""); | |
237 new_f->closing = ""; | |
238 new_f->has_closer = TRUE; | |
239 frames = new_f; | |
240 cnt += end+1; /* cnt points to char after opener */ | |
241 } else { | |
242 if ((cnt+end) > len) { | |
243 g_string_append_c(frames->text, '@'); | |
244 cnt++; | |
245 } else { | |
246 /* unrecognized thingie. act like it's not there, but we | |
247 * still need to take care of the corresponding closer, | |
248 * make a frame that does nothing. */ | |
249 new_f = g_new(zframe, 1); | |
250 new_f->enclosing = frames; | |
251 new_f->text = g_string_new(""); | |
252 new_f->closing = ""; | |
253 new_f->has_closer = TRUE; | |
254 frames = new_f; | |
255 cnt += end+1; /* cnt points to char after opener */ | |
256 } | |
257 } | |
258 } else if (IS_CLOSER(message[cnt])) { | |
259 zframe *popped; | |
260 gboolean last_had_closer; | |
261 if (frames->enclosing) { | |
262 do { | |
263 popped = frames; | |
264 frames = frames->enclosing; | |
265 g_string_append(frames->text, popped->text->str); | |
266 g_string_append(frames->text, popped->closing); | |
267 g_string_free(popped->text, TRUE); | |
268 last_had_closer = popped->has_closer; | |
269 g_free(popped); | |
270 } while (frames && frames->enclosing && !last_had_closer); | |
271 } else { | |
272 g_string_append_c(frames->text, message[cnt]); | |
273 } | |
274 cnt++; | |
275 } else if (message[cnt] == '\n') { | |
276 g_string_append(frames->text, "<br>"); | |
277 cnt++; | |
278 } else { | |
279 g_string_append_c(frames->text, message[cnt++]); | |
280 } | |
281 } | |
282 /* go through all the stuff that they didn't close */ | |
283 while (frames->enclosing) { | |
284 curr = frames; | |
285 g_string_append(frames->enclosing->text, frames->text->str); | |
286 g_string_append(frames->enclosing->text, frames->closing); | |
287 g_string_free(frames->text, TRUE); | |
288 frames = frames->enclosing; | |
289 g_free(curr); | |
290 } | |
291 ret = frames->text->str; | |
292 g_string_free(frames->text, FALSE); | |
293 g_free(frames); | |
294 return ret; | |
295 } | |
296 | |
297 static gboolean pending_zloc(char *who) | |
298 { | |
299 GList *curr; | |
300 for (curr = pending_zloc_names; curr != NULL; curr = curr->next) { | |
4793 | 301 if (!g_ascii_strcasecmp(who, (char*)curr->data)) { |
2086 | 302 g_free((char*)curr->data); |
303 pending_zloc_names = g_list_remove(pending_zloc_names, curr->data); | |
304 return TRUE; | |
305 } | |
306 } | |
307 return FALSE; | |
308 } | |
309 | |
310 static void handle_message(ZNotice_t notice, struct sockaddr_in from) | |
311 { | |
4793 | 312 if (!g_ascii_strcasecmp(notice.z_class, LOGIN_CLASS)) { |
3277 | 313 /* well, we'll be updating in 20 seconds anyway, might as well ignore this. */ |
4793 | 314 } else if (!g_ascii_strcasecmp(notice.z_class, LOCATE_CLASS)) { |
315 if (!g_ascii_strcasecmp(notice.z_opcode, LOCATE_LOCATE)) { | |
2086 | 316 int nlocs; |
317 char *user; | |
318 struct buddy *b; | |
319 | |
320 if (ZParseLocations(¬ice, NULL, &nlocs, &user) != ZERR_NONE) | |
321 return; | |
4687 | 322 if ((b = gaim_find_buddy(zgc->account, user)) == NULL) { |
2086 | 323 char *e = strchr(user, '@'); |
324 if (e) *e = '\0'; | |
4687 | 325 b = gaim_find_buddy(zgc->account, user); |
2086 | 326 } |
327 if (!b) { | |
328 free(user); | |
329 return; | |
330 } | |
331 if (pending_zloc(b->name)) { | |
332 ZLocations_t locs; | |
333 int one = 1; | |
334 GString *str = g_string_new(""); | |
5132 | 335 g_string_append_printf(str, _("<b>User:</b> %s<br>"), b->name); |
336 if (b->alias) | |
337 g_string_append_printf(str, _("<b>Alias:</b> %s<br>"), b->alias); | |
2086 | 338 if (!nlocs) { |
5132 | 339 g_string_append_printf(str, _("<br>Hidden or not logged-in")); |
2086 | 340 } |
341 for (; nlocs > 0; nlocs--) { | |
342 ZGetLocations(&locs, &one); | |
5132 | 343 g_string_append_printf(str, _("<br>At %s since %s"), locs.host, |
2086 | 344 locs.time); |
345 } | |
2791
8f6365332a05
[gaim-migrate @ 2804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2773
diff
changeset
|
346 g_show_info_text(NULL, NULL, 2, str->str, NULL); |
2086 | 347 g_string_free(str, TRUE); |
348 } else | |
4732 | 349 serv_got_update(zgc, b->name, nlocs, 0, 0, 0, 0); |
2086 | 350 |
351 free(user); | |
352 } | |
353 } else { | |
354 char *buf, *buf2; | |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
355 char *send_inst; |
3277 | 356 char *realmptr; |
357 char *sendertmp; | |
2086 | 358 char *ptr = notice.z_message + strlen(notice.z_message) + 1; |
359 int len = notice.z_message_len - (ptr - notice.z_message); | |
360 int away; | |
361 if (len > 0) { | |
362 buf = g_malloc(len + 1); | |
363 g_snprintf(buf, len + 1, "%s", ptr); | |
364 g_strchomp(buf); | |
365 buf2 = zephyr_to_html(buf); | |
366 g_free(buf); | |
4793 | 367 if (!g_ascii_strcasecmp(notice.z_class, "MESSAGE") && |
368 !g_ascii_strcasecmp(notice.z_class_inst, "PERSONAL")) { | |
369 if (!g_ascii_strcasecmp(notice.z_message, "Automated reply:")) | |
2086 | 370 away = TRUE; |
371 else | |
372 away = FALSE; | |
2856
b1e300a85678
[gaim-migrate @ 2869]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2804
diff
changeset
|
373 serv_got_im(zgc, notice.z_sender, buf2, 0, time(NULL), -1); |
2086 | 374 } else { |
375 zephyr_triple *zt1, *zt2; | |
376 zt1 = new_triple(notice.z_class, notice.z_class_inst, | |
4687 | 377 notice.z_recipient); |
2086 | 378 zt2 = find_sub_by_triple(zt1); |
379 if (!zt2) { | |
380 /* we shouldn't be subscribed to this message. ignore. */ | |
381 } else { | |
382 if (!zt2->open) { | |
383 zt2->open = TRUE; | |
384 serv_got_joined_chat(zgc, zt2->id, zt2->name); | |
385 } | |
3277 | 386 /* If the person is in the default Realm, then strip the |
387 Realm from the sender field */ | |
388 sendertmp = g_strdup_printf("%s",notice.z_sender); | |
4682 | 389 if ((realmptr = strchr(sendertmp,'@')) != NULL) { |
4588 | 390 realmptr++; |
4793 | 391 if (!g_ascii_strcasecmp(realmptr,ZGetRealm())) { |
4588 | 392 realmptr--; |
393 sprintf(realmptr,"%c",'\0'); | |
394 send_inst = g_strdup_printf("%s %s",sendertmp, | |
395 notice.z_class_inst); | |
396 } else { | |
397 send_inst = g_strdup_printf("%s %s",notice.z_sender, | |
398 notice.z_class_inst); | |
399 } | |
3277 | 400 } else { |
4588 | 401 send_inst = g_strdup_printf("%s %s",sendertmp,notice.z_class_inst); |
3277 | 402 } |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
403 serv_got_chat_in(zgc, zt2->id, send_inst, FALSE, |
4687 | 404 buf2, time(NULL)); |
3277 | 405 g_free(sendertmp); |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
406 g_free(send_inst); |
2086 | 407 } |
408 free_triple(zt1); | |
409 } | |
410 g_free(buf2); | |
411 } | |
412 } | |
413 } | |
414 | |
415 static gint check_notify(gpointer data) | |
416 { | |
417 while (ZPending()) { | |
418 ZNotice_t notice; | |
419 struct sockaddr_in from; | |
420 z_call_r(ZReceiveNotice(¬ice, &from)); | |
421 | |
422 switch (notice.z_kind) { | |
423 case UNSAFE: | |
424 case UNACKED: | |
425 case ACKED: | |
426 handle_message(notice, from); | |
427 break; | |
428 default: | |
429 /* we'll just ignore things for now */ | |
430 debug_printf("ZEPHYR: Unhandled Notice\n"); | |
431 break; | |
432 } | |
433 | |
434 ZFreeNotice(¬ice); | |
435 } | |
436 | |
437 return TRUE; | |
438 } | |
439 | |
440 static gint check_loc(gpointer data) | |
441 { | |
4785 | 442 GaimBlistNode *gnode,*bnode; |
2086 | 443 ZAsyncLocateData_t ald; |
444 | |
445 ald.user = NULL; | |
446 memset(&(ald.uid), 0, sizeof(ZUnique_Id_t)); | |
447 ald.version = NULL; | |
448 | |
4785 | 449 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
450 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
451 continue; | |
452 for(bnode = gnode->child; bnode; bnode = bnode->next) { | |
453 struct buddy *b = (struct buddy *)bnode; | |
454 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
455 continue; | |
4491 | 456 if(b->account->gc == zgc) { |
4349 | 457 char *chk; |
458 chk = zephyr_normalize(b->name); | |
459 /* doesn't matter if this fails or not; we'll just move on to the next one */ | |
460 ZRequestLocations(chk, &ald, UNACKED, ZAUTH); | |
461 free(ald.user); | |
462 free(ald.version); | |
463 } | |
2086 | 464 } |
465 } | |
466 | |
467 return TRUE; | |
468 } | |
469 | |
470 static char *get_exposure_level() | |
471 { | |
472 char *exposure = ZGetVariable("exposure"); | |
473 | |
474 if (!exposure) | |
475 return EXPOSE_REALMVIS; | |
4793 | 476 if (!g_ascii_strcasecmp(exposure, EXPOSE_NONE)) |
2086 | 477 return EXPOSE_NONE; |
4793 | 478 if (!g_ascii_strcasecmp(exposure, EXPOSE_OPSTAFF)) |
2086 | 479 return EXPOSE_OPSTAFF; |
4793 | 480 if (!g_ascii_strcasecmp(exposure, EXPOSE_REALMANN)) |
2086 | 481 return EXPOSE_REALMANN; |
4793 | 482 if (!g_ascii_strcasecmp(exposure, EXPOSE_NETVIS)) |
2086 | 483 return EXPOSE_NETVIS; |
4793 | 484 if (!g_ascii_strcasecmp(exposure, EXPOSE_NETANN)) |
2086 | 485 return EXPOSE_NETANN; |
486 return EXPOSE_REALMVIS; | |
487 } | |
488 | |
489 static void strip_comments(char *str) | |
490 { | |
491 char *tmp = strchr(str, '#'); | |
492 if (tmp) | |
493 *tmp = '\0'; | |
494 g_strchug(str); | |
495 g_strchomp(str); | |
496 } | |
497 | |
498 static void process_zsubs() | |
499 { | |
500 FILE *f; | |
501 gchar *fname; | |
502 gchar buff[BUFSIZ]; | |
503 | |
3630 | 504 fname = g_strdup_printf("%s/.zephyr.subs", gaim_home_dir()); |
2086 | 505 f = fopen(fname, "r"); |
506 if (f) { | |
507 char **triple; | |
508 ZSubscription_t sub; | |
509 char *recip; | |
510 while (fgets(buff, BUFSIZ, f)) { | |
511 strip_comments(buff); | |
512 if (buff[0]) { | |
513 triple = g_strsplit(buff, ",", 3); | |
3277 | 514 if (triple[0] && triple[1] ) { |
5132 | 515 /* char *tmp = g_strdup_printf("%s@%s", g_getenv("USER"), ZGetRealm()); */ |
4588 | 516 char *tmp = g_strdup_printf("%s",ZGetSender()); |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
517 char *atptr; |
2086 | 518 sub.zsub_class = triple[0]; |
519 sub.zsub_classinst = triple[1]; | |
3277 | 520 if(triple[2] == NULL) { |
521 recip = g_malloc0(1); | |
4793 | 522 } else if (!g_ascii_strcasecmp(triple[2], "%me%")) { |
4588 | 523 recip = g_strdup_printf("%s",ZGetSender()); |
4793 | 524 } else if (!g_ascii_strcasecmp(triple[2], "*")) { |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
525 /* wildcard |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
526 * form of class,instance,* */ |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
527 recip = g_malloc0(1); |
4793 | 528 } else if (!g_ascii_strcasecmp(triple[2], tmp)) { |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
529 /* form of class,instance,aatharuv@ATHENA.MIT.EDU */ |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
530 recip = g_strdup(triple[2]); |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
531 } else if ((atptr = strchr(triple[2], '@')) != NULL) { |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
532 /* form of class,instance,*@ANDREW.CMU.EDU |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
533 * class,instance,@ANDREW.CMU.EDU |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
534 * If realm is local realm, blank recipient, else |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
535 * @REALM-NAME |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
536 */ |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
537 char *realmat = g_strdup_printf("@%s", ZGetRealm()); |
4793 | 538 if (!g_ascii_strcasecmp(atptr, realmat)) |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
539 recip = g_malloc0(1); |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
540 else |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
541 recip = g_strdup(atptr); |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
542 g_free(realmat); |
2086 | 543 } else { |
544 recip = g_strdup(triple[2]); | |
545 } | |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
546 g_free(tmp); |
2086 | 547 sub.zsub_recipient = recip; |
548 if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) { | |
549 debug_printf("Zephyr: Couldn't subscribe to %s, %s, " | |
550 "%s\n", | |
551 sub.zsub_class, | |
552 sub.zsub_classinst, | |
553 sub.zsub_recipient); | |
554 } | |
555 subscrips = g_slist_append(subscrips, | |
556 new_triple(triple[0], triple[1], recip)); | |
557 g_free(recip); | |
558 } | |
559 g_strfreev(triple); | |
560 } | |
561 } | |
562 } | |
563 } | |
564 | |
565 static void process_anyone() | |
566 { | |
567 FILE *fd; | |
568 gchar buff[BUFSIZ], *filename; | |
4775 | 569 struct group *g; |
4687 | 570 struct buddy *b; |
4775 | 571 |
572 if (!(g = gaim_find_group(_("Anyone")))) { | |
573 g = gaim_group_new(_("Anyone")); | |
574 gaim_blist_add_group(g, NULL); | |
575 } | |
4687 | 576 |
3630 | 577 filename = g_strconcat(gaim_home_dir(), "/.anyone", NULL); |
2086 | 578 if ((fd = fopen(filename, "r")) != NULL) { |
579 while (fgets(buff, BUFSIZ, fd)) { | |
580 strip_comments(buff); | |
4687 | 581 if (buff[0]) { |
582 b = gaim_buddy_new(zgc->account, buff, NULL); | |
583 gaim_blist_add_buddy(b, g, NULL); | |
584 } | |
2086 | 585 } |
586 fclose(fd); | |
587 } | |
588 g_free(filename); | |
589 } | |
590 | |
5606 | 591 static void zephyr_login(GaimAccount *account) |
2086 | 592 { |
593 ZSubscription_t sub; | |
594 | |
595 if (zgc) { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
596 gaim_notify_error(account->gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
597 _("Already logged in with Zephyr"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
598 _("Because Zephyr uses your system username, you " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
599 "are unable to have multiple accounts on it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
600 "when logged in as the same user.")); |
2086 | 601 return; |
602 } | |
603 | |
5606 | 604 zgc = gaim_account_get_connection(account); |
2086 | 605 |
606 z_call_s(ZInitialize(), "Couldn't initialize zephyr"); | |
607 z_call_s(ZOpenPort(NULL), "Couldn't open port"); | |
608 z_call_s(ZSetLocation(get_exposure_level()), "Couldn't set location"); | |
609 | |
610 sub.zsub_class = "MESSAGE"; | |
611 sub.zsub_classinst = "PERSONAL"; | |
612 sub.zsub_recipient = ZGetSender(); | |
613 | |
614 /* we don't care if this fails. i'm lying right now. */ | |
615 if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) { | |
616 debug_printf("Zephyr: Couldn't subscribe to messages!\n"); | |
617 } | |
618 | |
5606 | 619 gaim_connection_set_state(zgc, GAIM_CONNECTED); |
2086 | 620 serv_finish_login(zgc); |
621 | |
622 process_anyone(); | |
623 process_zsubs(); | |
624 | |
2131
acc11216ec5d
[gaim-migrate @ 2141]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2123
diff
changeset
|
625 nottimer = g_timeout_add(100, check_notify, NULL); |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
626 loctimer = g_timeout_add(20000, check_loc, NULL); |
2086 | 627 } |
628 | |
629 static void write_zsubs() | |
630 { | |
631 GSList *s = subscrips; | |
632 zephyr_triple *zt; | |
633 FILE *fd; | |
634 char *fname; | |
635 | |
3277 | 636 char** triple; |
3630 | 637 fname = g_strdup_printf("%s/.zephyr.subs", gaim_home_dir()); |
2086 | 638 fd = fopen(fname, "w"); |
639 | |
640 if (!fd) { | |
641 g_free(fname); | |
642 return; | |
643 } | |
644 | |
645 while (s) { | |
646 zt = s->data; | |
3277 | 647 triple = g_strsplit(zt->name,",",3); |
648 if (triple[2] != NULL) { | |
4793 | 649 if (!g_ascii_strcasecmp(triple[2], "")) { |
3277 | 650 fprintf(fd, "%s,%s,*\n", triple[0], triple[1]); |
4793 | 651 } else if (!g_ascii_strcasecmp(triple[2], ZGetSender())) { |
3277 | 652 fprintf(fd, "%s,%s,%%me%%\n",triple[0],triple[1]); |
653 } else { | |
654 fprintf(fd, "%s\n", zt->name); | |
655 } | |
656 } else { | |
657 fprintf(fd, "%s,%s,*\n",triple[0], triple[1]); | |
658 } | |
659 g_free(triple); | |
2086 | 660 s = s->next; |
661 } | |
662 g_free(fname); | |
663 fclose(fd); | |
664 } | |
665 | |
666 static void write_anyone() | |
667 { | |
4785 | 668 GaimBlistNode *gnode,*bnode; |
2086 | 669 struct buddy *b; |
3277 | 670 char *ptr, *fname, *ptr2; |
2086 | 671 FILE *fd; |
672 | |
3630 | 673 fname = g_strdup_printf("%s/.anyone", gaim_home_dir()); |
2086 | 674 fd = fopen(fname, "w"); |
675 if (!fd) { | |
676 g_free(fname); | |
677 return; | |
678 } | |
679 | |
4785 | 680 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
681 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
682 continue; | |
683 for(bnode = gnode->child; bnode; bnode = bnode->next) { | |
684 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
685 continue; | |
686 b = (struct buddy *)bnode; | |
4491 | 687 if(b->account->gc == zgc) { |
4349 | 688 if ((ptr = strchr(b->name, '@')) != NULL) { |
689 ptr2 = ptr + 1; | |
690 /* We should only strip the realm name if the principal | |
691 is in the user's realm | |
692 */ | |
4793 | 693 if (!g_ascii_strcasecmp(ptr2,ZGetRealm())) { |
4349 | 694 *ptr = '\0'; |
695 } | |
3277 | 696 } |
4349 | 697 fprintf(fd, "%s\n", b->name); |
698 if (ptr) | |
699 *ptr = '@'; | |
3277 | 700 } |
2086 | 701 } |
702 } | |
703 | |
704 fclose(fd); | |
705 g_free(fname); | |
706 } | |
707 | |
5606 | 708 static void zephyr_close(GaimConnection *gc) |
2086 | 709 { |
710 GList *l; | |
711 GSList *s; | |
712 l = pending_zloc_names; | |
713 while (l) { | |
714 g_free((char*)l->data); | |
715 l = l->next; | |
716 } | |
717 g_list_free(pending_zloc_names); | |
718 | |
719 write_anyone(); | |
720 write_zsubs(); | |
721 | |
722 s = subscrips; | |
723 while (s) { | |
724 free_triple((zephyr_triple*)s->data); | |
725 s = s->next; | |
726 } | |
727 g_slist_free(subscrips); | |
728 | |
729 if (nottimer) | |
2131
acc11216ec5d
[gaim-migrate @ 2141]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2123
diff
changeset
|
730 g_source_remove(nottimer); |
2086 | 731 nottimer = 0; |
732 if (loctimer) | |
2131
acc11216ec5d
[gaim-migrate @ 2141]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2123
diff
changeset
|
733 g_source_remove(loctimer); |
2086 | 734 loctimer = 0; |
735 zgc = NULL; | |
736 z_call(ZCancelSubscriptions(0)); | |
737 z_call(ZUnsetLocation()); | |
738 z_call(ZClosePort()); | |
739 } | |
740 | |
5606 | 741 static void zephyr_add_buddy(GaimConnection *gc, const char *buddy) { } |
742 static void zephyr_remove_buddy(GaimConnection *gc, char *buddy, char *group) { } | |
2086 | 743 |
5606 | 744 static int zephyr_chat_send(GaimConnection *gc, int id, char *im) |
2086 | 745 { |
746 ZNotice_t notice; | |
747 zephyr_triple *zt; | |
748 char *buf; | |
749 const char *sig; | |
750 | |
751 zt = find_sub_by_id(id); | |
752 if (!zt) | |
753 /* this should never happen. */ | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
754 return -EINVAL; |
2086 | 755 |
756 sig = ZGetVariable("zwrite-signature"); | |
757 if (!sig) { | |
758 sig = g_get_real_name(); | |
759 } | |
760 buf = g_strdup_printf("%s%c%s", sig, '\0', im); | |
761 | |
762 bzero((char *)¬ice, sizeof(notice)); | |
763 notice.z_kind = ACKED; | |
764 notice.z_port = 0; | |
765 notice.z_opcode = ""; | |
766 notice.z_class = zt->class; | |
767 notice.z_class_inst = zt->instance; | |
4793 | 768 if (!g_ascii_strcasecmp(zt->recipient, "*")) |
2086 | 769 notice.z_recipient = zephyr_normalize(""); |
770 else | |
771 notice.z_recipient = zephyr_normalize(zt->recipient); | |
772 notice.z_sender = 0; | |
773 notice.z_default_format = | |
774 "Class $class, Instance $instance:\n" | |
775 "To: @bold($recipient) at $time $date\n" | |
776 "From: @bold($1) <$sender>\n\n$2"; | |
777 notice.z_message_len = strlen(im) + strlen(sig) + 4; | |
778 notice.z_message = buf; | |
779 ZSendNotice(¬ice, ZAUTH); | |
780 g_free(buf); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
781 return 0; |
2086 | 782 } |
783 | |
5606 | 784 static int zephyr_send_im(GaimConnection *gc, const char *who, const char *im, int len, int flags) { |
2086 | 785 ZNotice_t notice; |
786 char *buf; | |
787 const char *sig; | |
788 | |
2231
8c4ff1a368bd
[gaim-migrate @ 2241]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2205
diff
changeset
|
789 if (flags & IM_FLAG_AWAY) |
2086 | 790 sig = "Automated reply:"; |
791 else { | |
792 sig = ZGetVariable("zwrite-signature"); | |
793 if (!sig) { | |
794 sig = g_get_real_name(); | |
795 } | |
796 } | |
797 buf = g_strdup_printf("%s%c%s", sig, '\0', im); | |
798 | |
799 bzero((char *)¬ice, sizeof(notice)); | |
800 notice.z_kind = ACKED; | |
801 notice.z_port = 0; | |
802 notice.z_opcode = ""; | |
803 notice.z_class = "MESSAGE"; | |
804 notice.z_class_inst = "PERSONAL"; | |
805 notice.z_sender = 0; | |
806 notice.z_recipient = who; | |
807 notice.z_default_format = | |
808 "Class $class, Instance $instance:\n" | |
809 "To: @bold($recipient) at $time $date\n" | |
810 "From: @bold($1) <$sender>\n\n$2"; | |
811 notice.z_message_len = strlen(im) + strlen(sig) + 4; | |
812 notice.z_message = buf; | |
813 g_free(buf); | |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
814 return 1; |
2086 | 815 } |
816 | |
817 static char *zephyr_normalize(const char *orig) | |
818 { | |
819 static char buf[80]; | |
820 if (strchr(orig, '@')) { | |
821 g_snprintf(buf, 80, "%s", orig); | |
822 } else { | |
823 g_snprintf(buf, 80, "%s@%s", orig, ZGetRealm()); | |
824 } | |
825 return buf; | |
826 } | |
827 | |
5606 | 828 static void zephyr_zloc(GaimConnection *gc, const char *who) |
2086 | 829 { |
830 ZAsyncLocateData_t ald; | |
831 | |
832 if (ZRequestLocations(zephyr_normalize(who), &ald, UNACKED, ZAUTH) | |
833 != ZERR_NONE) { | |
834 return; | |
835 } | |
836 pending_zloc_names = g_list_append(pending_zloc_names, | |
837 g_strdup(zephyr_normalize(who))); | |
838 } | |
839 | |
5606 | 840 static GList *zephyr_buddy_menu(GaimConnection *gc, const char *who) |
2086 | 841 { |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
842 GList *m = NULL; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
843 struct proto_buddy_menu *pbm; |
2086 | 844 |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
845 pbm = g_new0(struct proto_buddy_menu, 1); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
846 pbm->label = _("ZLocate"); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
847 pbm->callback = zephyr_zloc; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
848 pbm->gc = gc; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
849 m = g_list_append(m, pbm); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
850 |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
851 return m; |
2086 | 852 } |
853 | |
5606 | 854 static void zephyr_set_away(GaimConnection *gc, char *state, char *msg) |
2086 | 855 { |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
856 if (gc->away) { |
2086 | 857 g_free(gc->away); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
858 gc->away = NULL; |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
859 } |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
860 |
5132 | 861 if (!g_ascii_strcasecmp(state, _("Hidden"))) { |
2086 | 862 ZSetLocation(EXPOSE_OPSTAFF); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
863 gc->away = g_strdup(""); |
5132 | 864 } else if (!g_ascii_strcasecmp(state, _("Online"))) |
2086 | 865 ZSetLocation(get_exposure_level()); |
866 else /* state is GAIM_AWAY_CUSTOM */ if (msg) | |
867 gc->away = g_strdup(msg); | |
868 } | |
869 | |
5606 | 870 static GList *zephyr_away_states(GaimConnection *gc) |
2086 | 871 { |
872 GList *m = NULL; | |
873 | |
5132 | 874 m = g_list_append(m, _("Online")); |
2086 | 875 m = g_list_append(m, GAIM_AWAY_CUSTOM); |
5132 | 876 m = g_list_append(m, _("Hidden")); |
2086 | 877 |
878 return m; | |
879 } | |
880 | |
5606 | 881 static GList *zephyr_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
882 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
883 struct proto_chat_entry *pce; |
2086 | 884 |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
885 pce = g_new0(struct proto_chat_entry, 1); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
886 pce->label = _("Class:"); |
5234 | 887 pce->identifier = "class"; |
3158 | 888 m = g_list_append(m, pce); |
2086 | 889 |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
890 pce = g_new0(struct proto_chat_entry, 1); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
891 pce->label = _("Instance:"); |
5234 | 892 pce->identifier = "instance"; |
3158 | 893 m = g_list_append(m, pce); |
2086 | 894 |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
895 pce = g_new0(struct proto_chat_entry, 1); |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
896 pce->label = _("Recipient:"); |
5234 | 897 pce->identifier = "recipient"; |
3158 | 898 m = g_list_append(m, pce); |
2086 | 899 |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
900 return m; |
2086 | 901 } |
902 | |
5606 | 903 static void zephyr_join_chat(GaimConnection *gc, GHashTable *data) |
2086 | 904 { |
905 ZSubscription_t sub; | |
906 zephyr_triple *zt1, *zt2; | |
907 const char *classname; | |
908 const char *instname; | |
909 const char *recip; | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
910 |
5234 | 911 classname = g_hash_table_lookup(data, "class"); |
912 instname = g_hash_table_lookup(data, "instance"); | |
913 recip = g_hash_table_lookup(data, "recipient"); | |
914 | |
915 if (!classname || !instname || !recip) | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
916 return; |
2086 | 917 |
4793 | 918 if (!g_ascii_strcasecmp(recip, "%me%")) |
4588 | 919 recip = ZGetSender(); |
2086 | 920 |
921 zt1 = new_triple(classname, instname, recip); | |
922 zt2 = find_sub_by_triple(zt1); | |
923 if (zt2) { | |
924 free_triple(zt1); | |
925 if (!zt2->open) | |
926 serv_got_joined_chat(gc, zt2->id, zt2->name); | |
927 return; | |
928 } | |
929 | |
930 sub.zsub_class = zt1->class; | |
931 sub.zsub_classinst = zt1->instance; | |
932 sub.zsub_recipient = zt1->recipient; | |
933 | |
934 if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) { | |
935 free_triple(zt1); | |
936 return; | |
937 } | |
938 | |
939 subscrips = g_slist_append(subscrips, zt1); | |
940 zt1->open = TRUE; | |
941 serv_got_joined_chat(gc, zt1->id, zt1->name); | |
942 } | |
943 | |
5606 | 944 static void zephyr_chat_leave(GaimConnection *gc, int id) |
2086 | 945 { |
946 zephyr_triple *zt; | |
947 zt = find_sub_by_id(id); | |
948 if (zt) { | |
949 zt->open = FALSE; | |
950 zt->id = ++last_id; | |
951 } | |
952 } | |
953 | |
5606 | 954 static const char *zephyr_list_icon(GaimAccount *a, struct buddy *b) |
5202 | 955 { |
956 return "zephyr"; | |
957 } | |
958 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
959 static GaimPlugin *my_protocol = NULL; |
2086 | 960 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
961 static GaimPluginProtocolInfo prpl_info = |
2086 | 962 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
963 GAIM_PROTO_ZEPHYR, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
964 OPT_PROTO_NO_PASSWORD, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
965 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
966 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
967 zephyr_list_icon, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
968 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
969 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
970 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
971 zephyr_away_states, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
972 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
973 zephyr_buddy_menu, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
974 zephyr_chat_info, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
975 zephyr_login, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
976 zephyr_close, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
977 zephyr_send_im, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
978 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
979 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
980 zephyr_zloc, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
981 zephyr_set_away, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
982 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
983 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
984 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
985 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
986 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
987 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
988 zephyr_add_buddy, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
989 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
990 zephyr_remove_buddy, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
991 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
992 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
993 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
994 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
995 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
996 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
997 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
998 zephyr_join_chat, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
999 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1000 zephyr_chat_leave, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1001 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1002 zephyr_chat_send, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1003 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1004 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1005 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1006 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1007 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1008 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1009 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1010 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1011 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1012 zephyr_normalize |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1013 }; |
2086 | 1014 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1015 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1016 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1017 2, /**< api_version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1018 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1019 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1020 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1021 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1022 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1023 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1024 "prpl-zephyr", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1025 "Zephyr", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1026 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1027 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1028 N_("Zephyr Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1029 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1030 N_("Zephyr Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1031 NULL, /**< author */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1032 WEBSITE, /**< homepage */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1033 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1034 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1035 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1036 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1037 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1038 NULL, /**< ui_info */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1039 &prpl_info /**< extra_info */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1040 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1041 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1042 static void |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1043 __init_plugin(GaimPlugin *plugin) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1044 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1045 my_protocol = plugin; |
2086 | 1046 } |
1047 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1048 GAIM_INIT_PLUGIN(zephyr, __init_plugin, info); |