Sat, 29 Sep 2001 00:18:50 +0000
[gaim-migrate @ 2402]
handle new versions better.
| 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
cbb558585911
[gaim-migrate @ 2177]
Eric Warmenhoven <warmenhoven@yahoo.com>
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 | static char *zephyr_name() | |
| 66 | { | |
| 67 | return "Zephyr"; | |
| 68 | } | |
| 69 | ||
| 70 | #define z_call(func) if (func != ZERR_NONE)\ | |
| 71 | return; | |
| 72 | #define z_call_r(func) if (func != ZERR_NONE)\ | |
| 73 | return TRUE; | |
| 74 | #define z_call_s(func, err) if (func != ZERR_NONE) {\ | |
| 75 | hide_login_progress(zgc, err);\ | |
| 76 | signoff(zgc);\ | |
| 77 | return;\ | |
| 78 | } | |
| 79 | ||
| 80 | static char *zephyr_normalize(const char *); | |
| 81 | ||
| 82 | /* this is so bad, and if Zephyr weren't so fucked up to begin with I | |
| 83 | * wouldn't do this. but it is so i will. */ | |
| 84 | static guint32 nottimer = 0; | |
| 85 | static guint32 loctimer = 0; | |
| 86 | struct gaim_connection *zgc = NULL; | |
| 87 | static GList *pending_zloc_names = NULL; | |
| 88 | static GSList *subscrips = NULL; | |
| 89 | static int last_id = 0; | |
| 90 | ||
| 91 | /* just for debugging | |
| 92 | static void handle_unknown(ZNotice_t notice) | |
| 93 | { | |
| 94 | g_print("z_packet: %s\n", notice.z_packet); | |
| 95 | g_print("z_version: %s\n", notice.z_version); | |
| 96 | g_print("z_kind: %d\n", notice.z_kind); | |
| 97 | g_print("z_class: %s\n", notice.z_class); | |
| 98 | g_print("z_class_inst: %s\n", notice.z_class_inst); | |
| 99 | g_print("z_opcode: %s\n", notice.z_opcode); | |
| 100 | g_print("z_sender: %s\n", notice.z_sender); | |
| 101 | g_print("z_recipient: %s\n", notice.z_recipient); | |
| 102 | g_print("z_message: %s\n", notice.z_message); | |
| 103 | g_print("z_message_len: %d\n", notice.z_message_len); | |
| 104 | g_print("\n"); | |
| 105 | } | |
| 106 | */ | |
| 107 | ||
| 108 | static zephyr_triple *new_triple(const char *c, const char *i, const char *r) | |
| 109 | { | |
| 110 | zephyr_triple *zt; | |
| 111 | zt = g_new0(zephyr_triple, 1); | |
| 112 | zt->class = g_strdup(c); | |
| 113 | zt->instance = g_strdup(i); | |
| 114 | zt->recipient = g_strdup(r); | |
| 115 | zt->name = g_strdup_printf("%s,%s,%s", c, i, r); | |
| 116 | zt->id = ++last_id; | |
| 117 | zt->open = FALSE; | |
| 118 | return zt; | |
| 119 | } | |
| 120 | ||
| 121 | static void free_triple(zephyr_triple *zt) | |
| 122 | { | |
| 123 | g_free(zt->class); | |
| 124 | g_free(zt->instance); | |
| 125 | g_free(zt->recipient); | |
| 126 | g_free(zt->name); | |
| 127 | g_free(zt); | |
| 128 | } | |
| 129 | ||
| 130 | /* returns true if zt1 is a subset of zt2, i.e. zt2 has the same thing or | |
| 131 | * wildcards in each field of zt1. */ | |
| 132 | static gboolean triple_subset(zephyr_triple *zt1, zephyr_triple *zt2) | |
| 133 | { | |
| 134 | if (g_strcasecmp(zt2->class, zt1->class) && | |
| 135 | g_strcasecmp(zt2->class, "*")) { | |
| 136 | return FALSE; | |
| 137 | } | |
| 138 | if (g_strcasecmp(zt2->instance, zt1->instance) && | |
| 139 | g_strcasecmp(zt2->instance, "*")) { | |
| 140 | return FALSE; | |
| 141 | } | |
| 142 | if (g_strcasecmp(zt2->recipient, zt1->recipient) && | |
| 143 | g_strcasecmp(zt2->recipient, "*")) { | |
| 144 | return FALSE; | |
| 145 | } | |
| 146 | return TRUE; | |
| 147 | } | |
| 148 | ||
| 149 | static zephyr_triple *find_sub_by_triple(zephyr_triple *zt) | |
| 150 | { | |
| 151 | zephyr_triple *curr_t; | |
| 152 | GSList *curr = subscrips; | |
| 153 | while (curr) { | |
| 154 | curr_t = curr->data; | |
| 155 | if (triple_subset(zt, curr_t)) | |
| 156 | return curr_t; | |
| 157 | curr = curr->next; | |
| 158 | } | |
| 159 | return NULL; | |
| 160 | } | |
| 161 | ||
| 162 | static zephyr_triple *find_sub_by_id(int id) | |
| 163 | { | |
| 164 | zephyr_triple *zt; | |
| 165 | GSList *curr = subscrips; | |
| 166 | while (curr) { | |
| 167 | zt = curr->data; | |
| 168 | if (zt->id == id) | |
| 169 | return zt; | |
| 170 | curr = curr->next; | |
| 171 | } | |
| 172 | return NULL; | |
| 173 | } | |
| 174 | ||
| 175 | /* utility macros that are useful for zephyr_to_html */ | |
| 176 | ||
| 177 | #define IS_OPENER(c) ((c == '{') || (c == '[') || (c == '(') || (c == '<')) | |
| 178 | #define IS_CLOSER(c) ((c == '}') || (c == ']') || (c == ')') || (c == '>')) | |
| 179 | ||
| 180 | /* this parses zephyr formatting and converts it to html. For example, if | |
| 181 | * you pass in "@{@color(blue)@i(hello)}" you should get out | |
| 182 | * "<font color=blue><i>hello</i></font>". */ | |
| 183 | static char *zephyr_to_html(char *message) | |
| 184 | { | |
| 185 | int len, cnt; | |
| 186 | zframe *frames, *curr; | |
| 187 | char *ret; | |
| 188 | ||
| 189 | frames = g_new(zframe, 1); | |
| 190 | frames->text = g_string_new(""); | |
| 191 | frames->enclosing = NULL; | |
| 192 | frames->closing = ""; | |
| 193 | frames->has_closer = FALSE; | |
| 194 | ||
| 195 | len = strlen(message); | |
| 196 | cnt = 0; | |
| 197 | while (cnt <= len) { | |
| 198 | if (message[cnt] == '@') { | |
| 199 | zframe *new_f; | |
| 200 | char *buf; | |
| 201 | int end; | |
| 202 | for (end=1; (cnt+end) <= len && | |
| 203 | !IS_OPENER(message[cnt+end]); end++); | |
| 204 | buf = g_new0(char, end); | |
| 205 | if (end) { | |
| 206 | g_snprintf(buf, end, "%s", message+cnt+1); | |
| 207 | } | |
| 208 | if (!g_strcasecmp(buf, "italic") || | |
| 209 | !g_strcasecmp(buf, "i")) { | |
| 210 | new_f = g_new(zframe, 1); | |
| 211 | new_f->enclosing = frames; | |
| 212 | new_f->text = g_string_new("<i>"); | |
| 213 | new_f->closing = "</i>"; | |
| 214 | new_f->has_closer = TRUE; | |
| 215 | frames = new_f; | |
| 216 | cnt += end+1; /* cnt points to char after opener */ | |
| 217 | } else if (!g_strcasecmp(buf, "bold") | |
| 218 | || !g_strcasecmp(buf, "b")) { | |
| 219 | new_f = g_new(zframe, 1); | |
| 220 | new_f->enclosing = frames; | |
| 221 | new_f->text = g_string_new("<b>"); | |
| 222 | new_f->closing = "</b>"; | |
| 223 | new_f->has_closer = TRUE; | |
| 224 | frames = new_f; | |
| 225 | cnt += end+1; | |
| 226 | } else if (!g_strcasecmp(buf, "color")) { | |
| 227 | cnt += end+1; | |
| 228 | new_f = g_new(zframe, 1); | |
| 229 | new_f->enclosing = frames; | |
| 230 | new_f->text = g_string_new("<font color="); | |
| 231 | for (; (cnt <= len) && !IS_CLOSER(message[cnt]); cnt++) { | |
| 232 | g_string_append_c(new_f->text, message[cnt]); | |
| 233 | } | |
| 234 | cnt++; /* point to char after closer */ | |
| 235 | g_string_append_c(new_f->text, '>'); | |
| 236 | new_f->closing = "</font>"; | |
| 237 | new_f->has_closer = FALSE; | |
| 238 | frames = new_f; | |
| 239 | } else if (!g_strcasecmp(buf, "")) { | |
| 240 | new_f = g_new(zframe, 1); | |
| 241 | new_f->enclosing = frames; | |
| 242 | new_f->text = g_string_new(""); | |
| 243 | new_f->closing = ""; | |
| 244 | new_f->has_closer = TRUE; | |
| 245 | frames = new_f; | |
| 246 | cnt += end+1; /* cnt points to char after opener */ | |
| 247 | } else { | |
| 248 | if ((cnt+end) > len) { | |
| 249 | g_string_append_c(frames->text, '@'); | |
| 250 | cnt++; | |
| 251 | } else { | |
| 252 | /* unrecognized thingie. act like it's not there, but we | |
| 253 | * still need to take care of the corresponding closer, | |
| 254 | * make a frame that does nothing. */ | |
| 255 | new_f = g_new(zframe, 1); | |
| 256 | new_f->enclosing = frames; | |
| 257 | new_f->text = g_string_new(""); | |
| 258 | new_f->closing = ""; | |
| 259 | new_f->has_closer = TRUE; | |
| 260 | frames = new_f; | |
| 261 | cnt += end+1; /* cnt points to char after opener */ | |
| 262 | } | |
| 263 | } | |
| 264 | } else if (IS_CLOSER(message[cnt])) { | |
| 265 | zframe *popped; | |
| 266 | gboolean last_had_closer; | |
| 267 | if (frames->enclosing) { | |
| 268 | do { | |
| 269 | popped = frames; | |
| 270 | frames = frames->enclosing; | |
| 271 | g_string_append(frames->text, popped->text->str); | |
| 272 | g_string_append(frames->text, popped->closing); | |
| 273 | g_string_free(popped->text, TRUE); | |
| 274 | last_had_closer = popped->has_closer; | |
| 275 | g_free(popped); | |
| 276 | } while (frames && frames->enclosing && !last_had_closer); | |
| 277 | } else { | |
| 278 | g_string_append_c(frames->text, message[cnt]); | |
| 279 | } | |
| 280 | cnt++; | |
| 281 | } else if (message[cnt] == '\n') { | |
| 282 | g_string_append(frames->text, "<br>"); | |
| 283 | cnt++; | |
| 284 | } else { | |
| 285 | g_string_append_c(frames->text, message[cnt++]); | |
| 286 | } | |
| 287 | } | |
| 288 | /* go through all the stuff that they didn't close */ | |
| 289 | while (frames->enclosing) { | |
| 290 | curr = frames; | |
| 291 | g_string_append(frames->enclosing->text, frames->text->str); | |
| 292 | g_string_append(frames->enclosing->text, frames->closing); | |
| 293 | g_string_free(frames->text, TRUE); | |
| 294 | frames = frames->enclosing; | |
| 295 | g_free(curr); | |
| 296 | } | |
| 297 | ret = frames->text->str; | |
| 298 | g_string_free(frames->text, FALSE); | |
| 299 | g_free(frames); | |
| 300 | return ret; | |
| 301 | } | |
| 302 | ||
| 303 | static gboolean pending_zloc(char *who) | |
| 304 | { | |
| 305 | GList *curr; | |
| 306 | for (curr = pending_zloc_names; curr != NULL; curr = curr->next) { | |
| 307 | if (!g_strcasecmp(who, (char*)curr->data)) { | |
| 308 | g_free((char*)curr->data); | |
| 309 | pending_zloc_names = g_list_remove(pending_zloc_names, curr->data); | |
| 310 | return TRUE; | |
| 311 | } | |
| 312 | } | |
| 313 | return FALSE; | |
| 314 | } | |
| 315 | ||
| 316 | static void handle_message(ZNotice_t notice, struct sockaddr_in from) | |
| 317 | { | |
| 318 | if (!g_strcasecmp(notice.z_class, LOGIN_CLASS)) { | |
| 319 | /* well, we'll be updating in 2 seconds anyway, might as well ignore this. */ | |
| 320 | } else if (!g_strcasecmp(notice.z_class, LOCATE_CLASS)) { | |
| 321 | if (!g_strcasecmp(notice.z_opcode, LOCATE_LOCATE)) { | |
| 322 | int nlocs; | |
| 323 | char *user; | |
| 324 | struct buddy *b; | |
| 325 | ||
| 326 | if (ZParseLocations(¬ice, NULL, &nlocs, &user) != ZERR_NONE) | |
| 327 | return; | |
| 328 | if ((b = find_buddy(zgc, user)) == NULL) { | |
| 329 | char *e = strchr(user, '@'); | |
| 330 | if (e) *e = '\0'; | |
| 331 | b = find_buddy(zgc, user); | |
| 332 | } | |
| 333 | if (!b) { | |
| 334 | free(user); | |
| 335 | return; | |
| 336 | } | |
| 337 | if (pending_zloc(b->name)) { | |
| 338 | ZLocations_t locs; | |
| 339 | int one = 1; | |
| 340 | GString *str = g_string_new(""); | |
| 341 | g_string_sprintfa(str, "<b>User:</b> %s<br>" | |
| 342 | "<b>Alias:</b> %s<br>", | |
| 343 | b->name, b->show); | |
| 344 | if (!nlocs) { | |
| 345 | g_string_sprintfa(str, "<br>Hidden or not logged-in"); | |
| 346 | } | |
| 347 | for (; nlocs > 0; nlocs--) { | |
| 348 | ZGetLocations(&locs, &one); | |
| 349 | g_string_sprintfa(str, "<br>At %s since %s", locs.host, | |
| 350 | locs.time); | |
| 351 | } | |
|
2137
b0c18ea1dee8
[gaim-migrate @ 2147]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2131
diff
changeset
|
352 | g_show_info_text(str->str, NULL); |
| 2086 | 353 | g_string_free(str, TRUE); |
| 354 | } else | |
| 355 | serv_got_update(zgc, b->name, nlocs, 0, 0, 0, 0, 0); | |
| 356 | ||
| 357 | free(user); | |
| 358 | } | |
| 359 | } else { | |
| 360 | char *buf, *buf2; | |
| 361 | char *ptr = notice.z_message + strlen(notice.z_message) + 1; | |
| 362 | int len = notice.z_message_len - (ptr - notice.z_message); | |
| 363 | int away; | |
| 364 | if (len > 0) { | |
| 365 | buf = g_malloc(len + 1); | |
| 366 | g_snprintf(buf, len + 1, "%s", ptr); | |
| 367 | g_strchomp(buf); | |
| 368 | buf2 = zephyr_to_html(buf); | |
| 369 | g_free(buf); | |
| 370 | if (!g_strcasecmp(notice.z_class, "MESSAGE") && | |
| 371 | !g_strcasecmp(notice.z_class_inst, "PERSONAL")) { | |
| 372 | if (!g_strcasecmp(notice.z_message, "Automated reply:")) | |
| 373 | away = TRUE; | |
| 374 | else | |
| 375 | away = FALSE; | |
| 376 | len = MAX(BUF_LONG, strlen(buf2)); | |
| 377 | buf = g_malloc(len + 1); | |
| 378 | g_snprintf(buf, len + 1, "%s", buf2); | |
| 379 | serv_got_im(zgc, notice.z_sender, buf, 0, time((time_t)NULL)); | |
| 380 | g_free(buf); | |
| 381 | } else { | |
| 382 | zephyr_triple *zt1, *zt2; | |
| 383 | zt1 = new_triple(notice.z_class, notice.z_class_inst, | |
| 384 | notice.z_recipient); | |
| 385 | zt2 = find_sub_by_triple(zt1); | |
| 386 | if (!zt2) { | |
| 387 | /* we shouldn't be subscribed to this message. ignore. */ | |
| 388 | } else { | |
| 389 | len = MAX(BUF_LONG, strlen(buf2)); | |
| 390 | buf = g_malloc(len + 1); | |
| 391 | g_snprintf(buf, len + 1, "%s", buf2); | |
| 392 | if (!zt2->open) { | |
| 393 | zt2->open = TRUE; | |
| 394 | serv_got_joined_chat(zgc, zt2->id, zt2->name); | |
| 395 | } | |
| 396 | serv_got_chat_in(zgc, zt2->id, notice.z_sender, FALSE, | |
| 397 | buf, time((time_t)NULL)); | |
| 398 | g_free(buf); | |
| 399 | } | |
| 400 | free_triple(zt1); | |
| 401 | } | |
| 402 | g_free(buf2); | |
| 403 | } | |
| 404 | } | |
| 405 | } | |
| 406 | ||
| 407 | static gint check_notify(gpointer data) | |
| 408 | { | |
| 409 | while (ZPending()) { | |
| 410 | ZNotice_t notice; | |
| 411 | struct sockaddr_in from; | |
| 412 | z_call_r(ZReceiveNotice(¬ice, &from)); | |
| 413 | ||
| 414 | switch (notice.z_kind) { | |
| 415 | case UNSAFE: | |
| 416 | case UNACKED: | |
| 417 | case ACKED: | |
| 418 | handle_message(notice, from); | |
| 419 | break; | |
| 420 | default: | |
| 421 | /* we'll just ignore things for now */ | |
| 422 | debug_printf("ZEPHYR: Unhandled Notice\n"); | |
| 423 | break; | |
| 424 | } | |
| 425 | ||
| 426 | ZFreeNotice(¬ice); | |
| 427 | } | |
| 428 | ||
| 429 | return TRUE; | |
| 430 | } | |
| 431 | ||
| 432 | static gint check_loc(gpointer data) | |
| 433 | { | |
| 434 | GSList *gr, *m; | |
| 435 | ZAsyncLocateData_t ald; | |
| 436 | ||
| 437 | ald.user = NULL; | |
| 438 | memset(&(ald.uid), 0, sizeof(ZUnique_Id_t)); | |
| 439 | ald.version = NULL; | |
| 440 | ||
| 441 | gr = zgc->groups; | |
| 442 | while (gr) { | |
| 443 | struct group *g = gr->data; | |
| 444 | m = g->members; | |
| 445 | while (m) { | |
| 446 | struct buddy *b = m->data; | |
| 447 | char *chk; | |
| 448 | chk = zephyr_normalize(b->name); | |
| 449 | /* doesn't matter if this fails or not; we'll just move on to the next one */ | |
| 450 | ZRequestLocations(chk, &ald, UNACKED, ZAUTH); | |
| 451 | free(ald.user); | |
| 452 | free(ald.version); | |
| 453 | m = m->next; | |
| 454 | } | |
| 455 | gr = gr->next; | |
| 456 | } | |
| 457 | ||
| 458 | return TRUE; | |
| 459 | } | |
| 460 | ||
| 461 | static char *get_exposure_level() | |
| 462 | { | |
| 463 | char *exposure = ZGetVariable("exposure"); | |
| 464 | ||
| 465 | if (!exposure) | |
| 466 | return EXPOSE_REALMVIS; | |
| 467 | if (!g_strcasecmp(exposure, EXPOSE_NONE)) | |
| 468 | return EXPOSE_NONE; | |
| 469 | if (!g_strcasecmp(exposure, EXPOSE_OPSTAFF)) | |
| 470 | return EXPOSE_OPSTAFF; | |
| 471 | if (!g_strcasecmp(exposure, EXPOSE_REALMANN)) | |
| 472 | return EXPOSE_REALMANN; | |
| 473 | if (!g_strcasecmp(exposure, EXPOSE_NETVIS)) | |
| 474 | return EXPOSE_NETVIS; | |
| 475 | if (!g_strcasecmp(exposure, EXPOSE_NETANN)) | |
| 476 | return EXPOSE_NETANN; | |
| 477 | return EXPOSE_REALMVIS; | |
| 478 | } | |
| 479 | ||
| 480 | static void strip_comments(char *str) | |
| 481 | { | |
| 482 | char *tmp = strchr(str, '#'); | |
| 483 | if (tmp) | |
| 484 | *tmp = '\0'; | |
| 485 | g_strchug(str); | |
| 486 | g_strchomp(str); | |
| 487 | } | |
| 488 | ||
| 489 | static void process_zsubs() | |
| 490 | { | |
| 491 | FILE *f; | |
| 492 | gchar *fname; | |
| 493 | gchar buff[BUFSIZ]; | |
| 494 | ||
| 495 | fname = g_strdup_printf("%s/.zephyr.subs", g_getenv("HOME")); | |
| 496 | f = fopen(fname, "r"); | |
| 497 | if (f) { | |
| 498 | char **triple; | |
| 499 | ZSubscription_t sub; | |
| 500 | char *recip; | |
| 501 | while (fgets(buff, BUFSIZ, f)) { | |
| 502 | strip_comments(buff); | |
| 503 | if (buff[0]) { | |
| 504 | triple = g_strsplit(buff, ",", 3); | |
| 505 | if (triple[0] && triple[1] && triple[2]) { | |
| 506 | sub.zsub_class = triple[0]; | |
| 507 | sub.zsub_classinst = triple[1]; | |
| 508 | if (!g_strcasecmp(triple[2], "%me%")) { | |
| 509 | recip = g_strdup_printf("%s@%s", g_getenv("USER"), | |
| 510 | ZGetRealm()); | |
| 511 | } else if (!g_strcasecmp(triple[2], "*")) { | |
| 512 | /* wildcard */ | |
| 513 | recip = g_strdup_printf("@%s", ZGetRealm()); | |
| 514 | } else { | |
| 515 | recip = g_strdup(triple[2]); | |
| 516 | } | |
| 517 | sub.zsub_recipient = recip; | |
| 518 | if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) { | |
| 519 | debug_printf("Zephyr: Couldn't subscribe to %s, %s, " | |
| 520 | "%s\n", | |
| 521 | sub.zsub_class, | |
| 522 | sub.zsub_classinst, | |
| 523 | sub.zsub_recipient); | |
| 524 | } | |
| 525 | subscrips = g_slist_append(subscrips, | |
| 526 | new_triple(triple[0], triple[1], recip)); | |
| 527 | g_free(recip); | |
| 528 | } | |
| 529 | g_strfreev(triple); | |
| 530 | } | |
| 531 | } | |
| 532 | } | |
| 533 | } | |
| 534 | ||
| 535 | static void process_anyone() | |
| 536 | { | |
| 537 | FILE *fd; | |
| 538 | gchar buff[BUFSIZ], *filename; | |
| 539 | ||
| 540 | filename = g_strconcat(g_get_home_dir(), "/.anyone", NULL); | |
| 541 | if ((fd = fopen(filename, "r")) != NULL) { | |
| 542 | while (fgets(buff, BUFSIZ, fd)) { | |
| 543 | strip_comments(buff); | |
| 544 | if (buff[0]) | |
| 545 | add_buddy(zgc, "Anyone", buff, buff); | |
| 546 | } | |
| 547 | fclose(fd); | |
| 548 | } | |
| 549 | g_free(filename); | |
| 550 | } | |
| 551 | ||
| 552 | static void zephyr_login(struct aim_user *user) | |
| 553 | { | |
| 554 | ZSubscription_t sub; | |
| 555 | ||
| 556 | if (zgc) { | |
| 557 | do_error_dialog("Already logged in with Zephyr", "Zephyr"); | |
| 558 | return; | |
| 559 | } | |
| 560 | ||
| 561 | zgc = new_gaim_conn(user); | |
| 562 | ||
| 563 | z_call_s(ZInitialize(), "Couldn't initialize zephyr"); | |
| 564 | z_call_s(ZOpenPort(NULL), "Couldn't open port"); | |
| 565 | z_call_s(ZSetLocation(get_exposure_level()), "Couldn't set location"); | |
| 566 | ||
| 567 | sub.zsub_class = "MESSAGE"; | |
| 568 | sub.zsub_classinst = "PERSONAL"; | |
| 569 | sub.zsub_recipient = ZGetSender(); | |
| 570 | ||
| 571 | /* we don't care if this fails. i'm lying right now. */ | |
| 572 | if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) { | |
| 573 | debug_printf("Zephyr: Couldn't subscribe to messages!\n"); | |
| 574 | } | |
| 575 | ||
| 576 | account_online(zgc); | |
| 577 | serv_finish_login(zgc); | |
| 578 | ||
| 579 | if (bud_list_cache_exists(zgc)) | |
|
2382
69a4e3665132
[gaim-migrate @ 2395]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2303
diff
changeset
|
580 | do_import(zgc, NULL); |
| 2086 | 581 | process_anyone(); |
| 582 | process_zsubs(); | |
| 583 | ||
|
2131
ef072ae1b2b8
[gaim-migrate @ 2141]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2123
diff
changeset
|
584 | nottimer = g_timeout_add(100, check_notify, NULL); |
|
ef072ae1b2b8
[gaim-migrate @ 2141]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2123
diff
changeset
|
585 | loctimer = g_timeout_add(2000, check_loc, NULL); |
| 2086 | 586 | } |
| 587 | ||
| 588 | static void write_zsubs() | |
| 589 | { | |
| 590 | GSList *s = subscrips; | |
| 591 | zephyr_triple *zt; | |
| 592 | FILE *fd; | |
| 593 | char *fname; | |
| 594 | ||
| 595 | fname = g_strdup_printf("%s/.zephyr.subs", g_get_home_dir()); | |
| 596 | fd = fopen(fname, "w"); | |
| 597 | ||
| 598 | if (!fd) { | |
| 599 | g_free(fname); | |
| 600 | return; | |
| 601 | } | |
| 602 | ||
| 603 | while (s) { | |
| 604 | zt = s->data; | |
| 605 | fprintf(fd, "%s\n", zt->name); | |
| 606 | s = s->next; | |
| 607 | } | |
| 608 | g_free(fname); | |
| 609 | fclose(fd); | |
| 610 | } | |
| 611 | ||
| 612 | static void write_anyone() | |
| 613 | { | |
| 614 | GSList *gr, *m; | |
| 615 | struct group *g; | |
| 616 | struct buddy *b; | |
| 617 | char *ptr, *fname; | |
| 618 | FILE *fd; | |
| 619 | ||
| 620 | fname = g_strdup_printf("%s/.anyone", g_get_home_dir()); | |
| 621 | fd = fopen(fname, "w"); | |
| 622 | if (!fd) { | |
| 623 | g_free(fname); | |
| 624 | return; | |
| 625 | } | |
| 626 | ||
| 627 | gr = zgc->groups; | |
| 628 | while (gr) { | |
| 629 | g = gr->data; | |
| 630 | m = g->members; | |
| 631 | while (m) { | |
| 632 | b = m->data; | |
| 633 | if ((ptr = strchr(b->name, '@')) != NULL) | |
| 634 | *ptr = '\0'; | |
| 635 | fprintf(fd, "%s\n", b->name); | |
| 636 | if (ptr) | |
| 637 | *ptr = '@'; | |
| 638 | m = m->next; | |
| 639 | } | |
| 640 | gr = gr->next; | |
| 641 | } | |
| 642 | ||
| 643 | fclose(fd); | |
| 644 | g_free(fname); | |
| 645 | } | |
| 646 | ||
| 647 | static void zephyr_close(struct gaim_connection *gc) | |
| 648 | { | |
| 649 | GList *l; | |
| 650 | GSList *s; | |
| 651 | l = pending_zloc_names; | |
| 652 | while (l) { | |
| 653 | g_free((char*)l->data); | |
| 654 | l = l->next; | |
| 655 | } | |
| 656 | g_list_free(pending_zloc_names); | |
| 657 | ||
| 658 | write_anyone(); | |
| 659 | write_zsubs(); | |
| 660 | ||
| 661 | s = subscrips; | |
| 662 | while (s) { | |
| 663 | free_triple((zephyr_triple*)s->data); | |
| 664 | s = s->next; | |
| 665 | } | |
| 666 | g_slist_free(subscrips); | |
| 667 | ||
| 668 | if (nottimer) | |
|
2131
ef072ae1b2b8
[gaim-migrate @ 2141]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2123
diff
changeset
|
669 | g_source_remove(nottimer); |
| 2086 | 670 | nottimer = 0; |
| 671 | if (loctimer) | |
|
2131
ef072ae1b2b8
[gaim-migrate @ 2141]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2123
diff
changeset
|
672 | g_source_remove(loctimer); |
| 2086 | 673 | loctimer = 0; |
| 674 | zgc = NULL; | |
| 675 | z_call(ZCancelSubscriptions(0)); | |
| 676 | z_call(ZUnsetLocation()); | |
| 677 | z_call(ZClosePort()); | |
| 678 | } | |
| 679 | ||
| 680 | static void zephyr_add_buddy(struct gaim_connection *gc, char *buddy) { } | |
| 681 | static void zephyr_remove_buddy(struct gaim_connection *gc, char *buddy) { } | |
| 682 | ||
|
2167
cbb558585911
[gaim-migrate @ 2177]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2162
diff
changeset
|
683 | static int zephyr_chat_send(struct gaim_connection *gc, int id, char *im) |
| 2086 | 684 | { |
| 685 | ZNotice_t notice; | |
| 686 | zephyr_triple *zt; | |
| 687 | char *buf; | |
| 688 | const char *sig; | |
| 689 | ||
| 690 | zt = find_sub_by_id(id); | |
| 691 | if (!zt) | |
| 692 | /* this should never happen. */ | |
|
2167
cbb558585911
[gaim-migrate @ 2177]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2162
diff
changeset
|
693 | return -EINVAL; |
| 2086 | 694 | |
| 695 | sig = ZGetVariable("zwrite-signature"); | |
| 696 | if (!sig) { | |
| 697 | sig = g_get_real_name(); | |
| 698 | } | |
| 699 | buf = g_strdup_printf("%s%c%s", sig, '\0', im); | |
| 700 | ||
| 701 | bzero((char *)¬ice, sizeof(notice)); | |
| 702 | notice.z_kind = ACKED; | |
| 703 | notice.z_port = 0; | |
| 704 | notice.z_opcode = ""; | |
| 705 | notice.z_class = zt->class; | |
| 706 | notice.z_class_inst = zt->instance; | |
| 707 | if (!g_strcasecmp(zt->recipient, "*")) | |
| 708 | notice.z_recipient = zephyr_normalize(""); | |
| 709 | else | |
| 710 | notice.z_recipient = zephyr_normalize(zt->recipient); | |
| 711 | notice.z_sender = 0; | |
| 712 | notice.z_default_format = | |
| 713 | "Class $class, Instance $instance:\n" | |
| 714 | "To: @bold($recipient) at $time $date\n" | |
| 715 | "From: @bold($1) <$sender>\n\n$2"; | |
| 716 | notice.z_message_len = strlen(im) + strlen(sig) + 4; | |
| 717 | notice.z_message = buf; | |
| 718 | ZSendNotice(¬ice, ZAUTH); | |
| 719 | g_free(buf); | |
|
2167
cbb558585911
[gaim-migrate @ 2177]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2162
diff
changeset
|
720 | return 0; |
| 2086 | 721 | } |
| 722 | ||
|
2231
9d8593ab093e
[gaim-migrate @ 2241]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2205
diff
changeset
|
723 | static int zephyr_send_im(struct gaim_connection *gc, char *who, char *im, int flags) { |
| 2086 | 724 | ZNotice_t notice; |
| 725 | char *buf; | |
| 726 | const char *sig; | |
| 727 | ||
|
2231
9d8593ab093e
[gaim-migrate @ 2241]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2205
diff
changeset
|
728 | if (flags & IM_FLAG_AWAY) |
| 2086 | 729 | sig = "Automated reply:"; |
| 730 | else { | |
| 731 | sig = ZGetVariable("zwrite-signature"); | |
| 732 | if (!sig) { | |
| 733 | sig = g_get_real_name(); | |
| 734 | } | |
| 735 | } | |
| 736 | buf = g_strdup_printf("%s%c%s", sig, '\0', im); | |
| 737 | ||
| 738 | bzero((char *)¬ice, sizeof(notice)); | |
| 739 | notice.z_kind = ACKED; | |
| 740 | notice.z_port = 0; | |
| 741 | notice.z_opcode = ""; | |
| 742 | notice.z_class = "MESSAGE"; | |
| 743 | notice.z_class_inst = "PERSONAL"; | |
| 744 | notice.z_sender = 0; | |
| 745 | notice.z_recipient = who; | |
| 746 | notice.z_default_format = | |
| 747 | "Class $class, Instance $instance:\n" | |
| 748 | "To: @bold($recipient) at $time $date\n" | |
| 749 | "From: @bold($1) <$sender>\n\n$2"; | |
| 750 | notice.z_message_len = strlen(im) + strlen(sig) + 4; | |
| 751 | notice.z_message = buf; | |
| 752 | ZSendNotice(¬ice, ZAUTH); | |
| 753 | g_free(buf); | |
|
2303
18171aa8cd37
[gaim-migrate @ 2313]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2231
diff
changeset
|
754 | return 1; |
| 2086 | 755 | } |
| 756 | ||
| 757 | static char *zephyr_normalize(const char *orig) | |
| 758 | { | |
| 759 | static char buf[80]; | |
| 760 | if (strchr(orig, '@')) { | |
| 761 | g_snprintf(buf, 80, "%s", orig); | |
| 762 | } else { | |
| 763 | g_snprintf(buf, 80, "%s@%s", orig, ZGetRealm()); | |
| 764 | } | |
| 765 | return buf; | |
| 766 | } | |
| 767 | ||
| 768 | static void zephyr_zloc(struct gaim_connection *gc, char *who) | |
| 769 | { | |
| 770 | ZAsyncLocateData_t ald; | |
| 771 | ||
| 772 | if (ZRequestLocations(zephyr_normalize(who), &ald, UNACKED, ZAUTH) | |
| 773 | != ZERR_NONE) { | |
| 774 | return; | |
| 775 | } | |
| 776 | pending_zloc_names = g_list_append(pending_zloc_names, | |
| 777 | g_strdup(zephyr_normalize(who))); | |
| 778 | } | |
| 779 | ||
|
2170
5c93594ff522
[gaim-migrate @ 2180]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2167
diff
changeset
|
780 | static GList *zephyr_buddy_menu(struct gaim_connection *gc, char *who) |
| 2086 | 781 | { |
|
2170
5c93594ff522
[gaim-migrate @ 2180]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2167
diff
changeset
|
782 | GList *m = NULL; |
|
5c93594ff522
[gaim-migrate @ 2180]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2167
diff
changeset
|
783 | struct proto_buddy_menu *pbm; |
| 2086 | 784 | |
|
2170
5c93594ff522
[gaim-migrate @ 2180]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2167
diff
changeset
|
785 | pbm = g_new0(struct proto_buddy_menu, 1); |
|
5c93594ff522
[gaim-migrate @ 2180]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2167
diff
changeset
|
786 | pbm->label = _("ZLocate"); |
|
5c93594ff522
[gaim-migrate @ 2180]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2167
diff
changeset
|
787 | pbm->callback = zephyr_zloc; |
|
5c93594ff522
[gaim-migrate @ 2180]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2167
diff
changeset
|
788 | pbm->gc = gc; |
|
5c93594ff522
[gaim-migrate @ 2180]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2167
diff
changeset
|
789 | m = g_list_append(m, pbm); |
|
5c93594ff522
[gaim-migrate @ 2180]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2167
diff
changeset
|
790 | |
|
5c93594ff522
[gaim-migrate @ 2180]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2167
diff
changeset
|
791 | return m; |
| 2086 | 792 | } |
| 793 | ||
| 794 | static void zephyr_set_away(struct gaim_connection *gc, char *state, char *msg) | |
| 795 | { | |
| 796 | if (gc->away) | |
| 797 | g_free(gc->away); | |
| 798 | gc->away = NULL; | |
| 799 | if (!g_strcasecmp(state, "Hidden")) | |
| 800 | ZSetLocation(EXPOSE_OPSTAFF); | |
| 801 | else if (!g_strcasecmp(state, "Online")) | |
| 802 | ZSetLocation(get_exposure_level()); | |
| 803 | else /* state is GAIM_AWAY_CUSTOM */ if (msg) | |
| 804 | gc->away = g_strdup(msg); | |
| 805 | } | |
| 806 | ||
| 807 | static GList *zephyr_away_states() | |
| 808 | { | |
| 809 | GList *m = NULL; | |
| 810 | ||
| 811 | m = g_list_append(m, "Online"); | |
| 812 | m = g_list_append(m, GAIM_AWAY_CUSTOM); | |
| 813 | m = g_list_append(m, "Hidden"); | |
| 814 | ||
| 815 | return m; | |
| 816 | } | |
| 817 | ||
|
2205
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
818 | static GList *zephyr_chat_info(struct gaim_connection *gc) { |
|
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
819 | GList *m = NULL; |
|
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
820 | struct proto_chat_entry *pce; |
| 2086 | 821 | |
|
2205
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
822 | pce = g_new0(struct proto_chat_entry, 1); |
|
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
823 | pce->label = _("Class:"); |
|
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
824 | m = g_list_append(m, NULL); |
| 2086 | 825 | |
|
2205
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
826 | pce = g_new0(struct proto_chat_entry, 1); |
|
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
827 | pce->label = _("Instance:"); |
|
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
828 | m = g_list_append(m, NULL); |
| 2086 | 829 | |
|
2205
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
830 | pce = g_new0(struct proto_chat_entry, 1); |
|
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
831 | pce->label = _("Recipient:"); |
|
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
832 | m = g_list_append(m, NULL); |
| 2086 | 833 | |
|
2205
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
834 | return m; |
| 2086 | 835 | } |
| 836 | ||
|
2205
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
837 | static void zephyr_join_chat(struct gaim_connection *gc, GList *data) |
| 2086 | 838 | { |
| 839 | ZSubscription_t sub; | |
| 840 | zephyr_triple *zt1, *zt2; | |
| 841 | const char *classname; | |
| 842 | const char *instname; | |
| 843 | const char *recip; | |
|
2205
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
844 | |
|
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
845 | if (!data || !data->next || !data->next->next) |
|
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
846 | return; |
| 2086 | 847 | |
|
2205
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
848 | classname = data->data; |
|
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
849 | instname = data->next->data; |
|
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
850 | recip = data->next->next->data; |
|
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
851 | if (!g_strcasecmp(recip, "%me%")) |
|
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
852 | recip = g_getenv("USER"); |
| 2086 | 853 | |
| 854 | zt1 = new_triple(classname, instname, recip); | |
| 855 | zt2 = find_sub_by_triple(zt1); | |
| 856 | if (zt2) { | |
| 857 | free_triple(zt1); | |
| 858 | if (!zt2->open) | |
| 859 | serv_got_joined_chat(gc, zt2->id, zt2->name); | |
| 860 | return; | |
| 861 | } | |
| 862 | ||
| 863 | sub.zsub_class = zt1->class; | |
| 864 | sub.zsub_classinst = zt1->instance; | |
| 865 | sub.zsub_recipient = zt1->recipient; | |
| 866 | ||
| 867 | if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) { | |
| 868 | free_triple(zt1); | |
| 869 | return; | |
| 870 | } | |
| 871 | ||
| 872 | subscrips = g_slist_append(subscrips, zt1); | |
| 873 | zt1->open = TRUE; | |
| 874 | serv_got_joined_chat(gc, zt1->id, zt1->name); | |
| 875 | } | |
| 876 | ||
| 877 | static void zephyr_chat_leave(struct gaim_connection *gc, int id) | |
| 878 | { | |
| 879 | zephyr_triple *zt; | |
| 880 | zt = find_sub_by_id(id); | |
| 881 | if (zt) { | |
| 882 | zt->open = FALSE; | |
| 883 | zt->id = ++last_id; | |
| 884 | } | |
| 885 | } | |
| 886 | ||
| 887 | static struct prpl *my_protocol = NULL; | |
| 888 | ||
| 889 | void zephyr_init(struct prpl *ret) | |
| 890 | { | |
| 891 | ret->protocol = PROTO_ZEPHYR; | |
|
2100
58ebaa769cb2
[gaim-migrate @ 2110]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2086
diff
changeset
|
892 | ret->options = OPT_PROTO_NO_PASSWORD; |
| 2086 | 893 | ret->name = zephyr_name; |
| 894 | ret->login = zephyr_login; | |
| 895 | ret->close = zephyr_close; | |
| 896 | ret->add_buddy = zephyr_add_buddy; | |
| 897 | ret->remove_buddy = zephyr_remove_buddy; | |
| 898 | ret->send_im = zephyr_send_im; | |
| 899 | ret->get_info = zephyr_zloc; | |
| 900 | ret->normalize = zephyr_normalize; | |
| 901 | ret->buddy_menu = zephyr_buddy_menu; | |
| 902 | ret->away_states = zephyr_away_states; | |
| 903 | ret->set_away = zephyr_set_away; | |
|
2205
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
904 | ret->chat_info = zephyr_chat_info; |
| 2086 | 905 | ret->join_chat = zephyr_join_chat; |
| 906 | ret->chat_send = zephyr_chat_send; | |
| 907 | ret->chat_leave = zephyr_chat_leave; | |
| 908 | ||
| 909 | my_protocol = ret; | |
| 910 | } | |
| 911 | ||
| 912 | #ifndef STATIC | |
| 913 | ||
| 914 | char *gaim_plugin_init(GModule *handle) | |
| 915 | { | |
| 916 | load_protocol(zephyr_init, sizeof(struct prpl)); | |
| 917 | return NULL; | |
| 918 | } | |
| 919 | ||
| 920 | void gaim_plugin_remove() | |
| 921 | { | |
| 922 | struct prpl *p = find_prpl(PROTO_ZEPHYR); | |
| 923 | if (p == my_protocol) | |
| 924 | unload_protocol(p); | |
| 925 | } | |
| 926 | ||
| 927 | char *name() | |
| 928 | { | |
| 929 | return "Zephyr"; | |
| 930 | } | |
| 931 | ||
| 932 | char *description() | |
| 933 | { | |
|
2162
2a9f076b0af9
[gaim-migrate @ 2172]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2137
diff
changeset
|
934 | return PRPL_DESC("Zephyr"); |
| 2086 | 935 | } |
| 936 | ||
| 937 | #endif |