Mercurial > pidgin
annotate src/protocols/zephyr/zephyr.c @ 10261:d4e9ff2edc4e
[gaim-migrate @ 11405]
This should fix segfault bug 1072604. Oops.
committer: Tailor Script <tailor@pidgin.im>
| author | Tim Ringenbach <marv@pidgin.im> |
|---|---|
| date | Thu, 25 Nov 2004 18:35:26 +0000 |
| parents | a66cf83552dc |
| children | cfd119bd3caf |
| 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 * |
| 9896 | 10 * Some code borrowed from kzephyr, by |
| 11 * Chris Colohan <colohan+@cs.cmu.edu> | |
| 12 * | |
| 2086 | 13 * This program is free software; you can redistribute it and/or modify |
| 14 * it under the terms of the GNU General Public License as published by | |
| 15 * the Free Software Foundation; either version 2 of the License, or | |
| 16 * (at your option) any later version. | |
| 17 * | |
| 18 * This program is distributed in the hope that it will be useful, | |
| 19 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 9896 | 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 2086 | 21 * GNU General Public License for more details. |
| 22 * | |
| 23 * You should have received a copy of the GNU General Public License | |
| 24 * along with this program; if not, write to the Free Software | |
| 9896 | 25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 2086 | 26 * |
| 9896 | 27 |
| 28 */ | |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
29 /* XXX eww */ |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
30 #include "src/internal.h" |
| 2086 | 31 |
| 8212 | 32 #include "accountopt.h" |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
33 #include "debug.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
34 #include "notify.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
35 #include "prpl.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
36 #include "server.h" |
|
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
37 #include "util.h" |
| 9434 | 38 #include "cmds.h" |
| 9896 | 39 #include "privacy.h" |
| 9943 | 40 #include "version.h" |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
41 |
| 9896 | 42 #include "zephyr.h" |
| 9478 | 43 #include "internal.h" |
|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
44 |
| 8386 | 45 #include <strings.h> |
| 46 | |
| 8560 | 47 #define ZEPHYR_FALLBACK_CHARSET "ISO-8859-1" |
| 48 | |
| 9478 | 49 /* these are deliberately high, since most people don't send multiple "PING"s */ |
| 50 #define ZEPHYR_TYPING_SEND_TIMEOUT 15 | |
| 51 #define ZEPHYR_TYPING_RECV_TIMEOUT 10 | |
| 9896 | 52 #define ZEPHYR_FD_READ 0 |
| 53 #define ZEPHYR_FD_WRITE 1 | |
| 9478 | 54 |
| 2086 | 55 extern Code_t ZGetLocations(ZLocations_t *, int *); |
| 56 extern Code_t ZSetLocation(char *); | |
| 57 extern Code_t ZUnsetLocation(); | |
| 9478 | 58 extern Code_t ZGetSubscriptions(ZSubscription_t *, int*); |
|
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
59 extern char __Zephyr_realm[]; |
| 2086 | 60 typedef struct _zframe zframe; |
| 61 typedef struct _zephyr_triple zephyr_triple; | |
| 9610 | 62 typedef struct _zephyr_account zephyr_account; |
| 9896 | 63 typedef struct _parse_tree parse_tree; |
| 2086 | 64 |
| 9896 | 65 typedef enum { |
| 66 GAIM_ZEPHYR_NONE, /* Non-kerberized ZEPH0.2 */ | |
| 67 GAIM_ZEPHYR_KRB4, /* ZEPH0.2 w/ KRB4 support */ | |
| 68 GAIM_ZEPHYR_TZC, /* tzc executable proxy */ | |
| 69 GAIM_ZEPHYR_INTERGALACTIC_KRB4, /* Kerberized ZEPH0.3 */ | |
| 70 } zephyr_connection_type; | |
| 9610 | 71 |
| 72 struct _zephyr_account { | |
| 9896 | 73 GaimAccount* account; |
| 74 char *username; | |
| 75 char *realm; | |
| 76 char *encoding; | |
| 77 char* galaxy; /* not yet useful */ | |
| 78 char* krbtkfile; /* not yet useful */ | |
| 79 guint32 nottimer; | |
| 80 guint32 loctimer; | |
| 81 GList *pending_zloc_names; | |
| 82 GSList *subscrips; | |
| 83 int last_id; | |
| 84 unsigned short port; | |
| 85 char ourhost[HOST_NAME_MAX + 1]; | |
| 86 char ourhostcanon[HOST_NAME_MAX + 1]; | |
| 87 zephyr_connection_type connection_type; | |
| 88 int totzc[2]; | |
| 89 int fromtzc[2]; | |
| 90 char *exposure; | |
| 9986 | 91 pid_t tzc_pid; |
| 92 gchar *away; | |
| 9610 | 93 }; |
| 9478 | 94 |
| 9896 | 95 #define MAXCHILDREN 20 |
| 96 | |
| 97 struct _parse_tree { | |
| 98 gchar* contents; | |
| 99 parse_tree *children[MAXCHILDREN]; | |
| 100 int num_children; | |
| 101 }; | |
| 102 | |
| 103 parse_tree null_parse_tree = { | |
| 104 "", | |
| 10116 | 105 {NULL}, |
| 9896 | 106 0, |
| 107 }; | |
| 108 | |
| 109 #define use_none(zephyr) ((zephyr->connection_type == GAIM_ZEPHYR_NONE)?1:0) | |
| 110 #define use_krb4(zephyr) ((zephyr->connection_type == GAIM_ZEPHYR_KRB4)?1:0) | |
| 111 #define use_tzc(zephyr) ((zephyr->connection_type == GAIM_ZEPHYR_TZC)?1:0) | |
| 112 | |
| 113 #define use_zeph02(zephyr) ( (zephyr->connection_type == GAIM_ZEPHYR_NONE)?1: ((zephyr->connection_type == GAIM_ZEPHYR_KRB4)?1:0)) | |
| 114 | |
| 2086 | 115 /* struct I need for zephyr_to_html */ |
| 116 struct _zframe { | |
| 117 /* true for everything but @color, since inside the parens of that one is | |
| 8644 | 118 * the color. */ |
| 2086 | 119 gboolean has_closer; |
| 120 /* </i>, </font>, </b>, etc. */ | |
| 121 char *closing; | |
| 122 /* text including the opening html thingie. */ | |
| 123 GString *text; | |
| 124 struct _zframe *enclosing; | |
| 125 }; | |
| 126 | |
| 127 struct _zephyr_triple { | |
| 128 char *class; | |
| 129 char *instance; | |
| 130 char *recipient; | |
| 131 char *name; | |
| 132 gboolean open; | |
| 133 int id; | |
| 134 }; | |
| 135 | |
| 136 #define z_call(func) if (func != ZERR_NONE)\ | |
| 137 return; | |
| 138 #define z_call_r(func) if (func != ZERR_NONE)\ | |
| 139 return TRUE; | |
| 9896 | 140 |
| 2086 | 141 #define z_call_s(func, err) if (func != ZERR_NONE) {\ |
| 9610 | 142 gaim_connection_error(gc, err);\ |
| 2086 | 143 return;\ |
| 144 } | |
| 145 | |
| 9896 | 146 |
| 147 Code_t zephyr_subscribe_to(zephyr_account* zephyr, char* class, char *instance, char *recipient, char* galaxy) { | |
| 9328 | 148 |
| 9896 | 149 if (use_tzc(zephyr)) { |
| 150 /* ((tzcfodder . subscribe) ("class" "instance" "recipient")) */ | |
| 151 gchar *zsubstr = g_strdup_printf("((tzcfodder . subscribe) (\"%s\" \"%s\" \"%s\"))\n",class,instance,recipient); | |
| 152 write(zephyr->totzc[ZEPHYR_FD_WRITE],zsubstr,strlen(zsubstr)); | |
| 153 g_free(zsubstr); | |
| 154 return ZERR_NONE; | |
| 155 } | |
| 156 else { | |
| 157 if (use_zeph02(zephyr)) { | |
| 158 ZSubscription_t sub; | |
| 159 sub.zsub_class = class; | |
| 160 sub.zsub_classinst = instance; | |
| 161 sub.zsub_recipient = recipient; | |
| 162 return ZSubscribeTo(&sub,1,0); | |
| 163 } else { | |
| 164 /* This should not happen */ | |
| 165 return -1; | |
| 166 } | |
| 167 } | |
| 168 return -1; | |
| 169 } | |
| 170 | |
| 171 char *local_zephyr_normalize(zephyr_account* zephyr,const char *); | |
| 172 static const char *zephyr_normalize(const GaimAccount *, const char *); | |
| 173 static void zephyr_chat_set_topic(GaimConnection * gc, int id, const char *topic); | |
| 174 char* zephyr_tzc_deescape_str(const char *message); | |
| 175 | |
| 9912 | 176 char *zephyr_strip_local_realm(zephyr_account* zephyr,const char* user){ |
| 9896 | 177 /* |
| 178 Takes in a username of the form username or username@realm | |
| 179 and returns: | |
| 180 username, if there is no realm, or the realm is the local realm | |
| 181 or: | |
| 182 username@realm if there is a realm and it is foreign | |
| 183 */ | |
| 9328 | 184 char *tmp = g_strdup(user); |
| 185 char *at = strchr(tmp,'@'); | |
| 9896 | 186 if (at && !g_ascii_strcasecmp(at+1,zephyr->realm)) { |
| 9328 | 187 /* We're passed in a username of the form user@users-realm */ |
| 188 char* tmp2; | |
| 189 *at = '\0'; | |
| 190 tmp2 = g_strdup(tmp); | |
| 191 g_free(tmp); | |
| 192 return tmp2; | |
| 193 } | |
| 194 else { | |
| 195 /* We're passed in a username of the form user or user@foreign-realm */ | |
| 196 return tmp; | |
| 197 } | |
| 198 } | |
| 2086 | 199 |
| 200 /* this is so bad, and if Zephyr weren't so fucked up to begin with I | |
| 201 * wouldn't do this. but it is so i will. */ | |
| 9610 | 202 |
| 9328 | 203 /* just for debugging */ |
| 2086 | 204 static void handle_unknown(ZNotice_t notice) |
| 205 { | |
| 9328 | 206 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_packet: %s\n", notice.z_packet); |
| 207 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_version: %s\n", notice.z_version); | |
| 208 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_kind: %d\n", (int)(notice.z_kind)); | |
| 209 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_class: %s\n", notice.z_class); | |
| 210 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_class_inst: %s\n", notice.z_class_inst); | |
| 211 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_opcode: %s\n", notice.z_opcode); | |
| 212 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_sender: %s\n", notice.z_sender); | |
| 213 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_recipient: %s\n", notice.z_recipient); | |
| 214 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_message: %s\n", notice.z_message); | |
| 215 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_message_len: %d\n", notice.z_message_len); | |
| 2086 | 216 } |
| 9328 | 217 |
| 2086 | 218 |
| 9610 | 219 static zephyr_triple *new_triple(zephyr_account *zephyr,const char *c, const char *i, const char *r) |
| 2086 | 220 { |
| 221 zephyr_triple *zt; | |
| 8644 | 222 |
| 2086 | 223 zt = g_new0(zephyr_triple, 1); |
| 224 zt->class = g_strdup(c); | |
| 225 zt->instance = g_strdup(i); | |
| 226 zt->recipient = g_strdup(r); | |
| 9610 | 227 zt->name = g_strdup_printf("%s,%s,%s", c, i?i:"", r?r:""); |
| 228 zt->id = ++(zephyr->last_id); | |
| 2086 | 229 zt->open = FALSE; |
| 230 return zt; | |
| 231 } | |
| 232 | |
| 8644 | 233 static void free_triple(zephyr_triple * zt) |
| 2086 | 234 { |
| 235 g_free(zt->class); | |
| 236 g_free(zt->instance); | |
| 237 g_free(zt->recipient); | |
| 238 g_free(zt->name); | |
| 239 g_free(zt); | |
| 240 } | |
| 241 | |
| 9328 | 242 /* returns true if zt1 is a subset of zt2. This function is used to |
| 243 determine whether a zephyr sent to zt1 should be placed in the chat | |
| 244 with triple zt2 | |
| 245 | |
| 246 zt1 is a subset of zt2 | |
| 247 iff. the classnames are identical ignoring case | |
| 248 AND. the instance names are identical (ignoring case), or zt2->instance is *. | |
| 249 AND. the recipient names are identical | |
| 250 */ | |
| 251 | |
| 8644 | 252 static gboolean triple_subset(zephyr_triple * zt1, zephyr_triple * zt2) |
| 2086 | 253 { |
| 9896 | 254 |
| 255 if (!zt2) | |
| 256 gaim_debug_error("zephyr","zt2 doesn't exist\n"); | |
| 257 if (!zt1) | |
| 258 gaim_debug_error("zephyr","zt1 doesn't exist\n"); | |
| 259 if (!(zt1->class)) | |
| 260 gaim_debug_error("zephyr","zt1c doesn't exist\n"); | |
| 261 if (!(zt1->instance)) | |
| 262 gaim_debug_error("zephyr","zt1i doesn't exist\n"); | |
| 263 if (!(zt1->recipient)) | |
| 264 gaim_debug_error("zephyr","zt1r doesn't exist\n"); | |
| 265 if (!(zt2->class)) | |
| 266 gaim_debug_error("zephyr","zt2c doesn't exist\n"); | |
| 267 if (!(zt2->recipient)) | |
| 268 gaim_debug_error("zephyr","zt2r doesn't exist\n"); | |
| 269 if (!(zt2->instance)) | |
| 270 gaim_debug_error("zephyr","zt2i doesn't exist\n"); | |
| 271 | |
| 272 | |
| 9328 | 273 if (g_ascii_strcasecmp(zt2->class, zt1->class)) { |
| 2086 | 274 return FALSE; |
| 275 } | |
| 8644 | 276 if (g_ascii_strcasecmp(zt2->instance, zt1->instance) && g_ascii_strcasecmp(zt2->instance, "*")) { |
| 2086 | 277 return FALSE; |
| 278 } | |
| 9328 | 279 if (g_ascii_strcasecmp(zt2->recipient, zt1->recipient)) { |
| 2086 | 280 return FALSE; |
| 281 } | |
| 9896 | 282 gaim_debug_info("zephyr","<%s,%s,%s> is in <%s,%s,%s>\n",zt1->class,zt1->instance,zt1->recipient,zt2->class,zt2->instance,zt2->recipient); |
| 2086 | 283 return TRUE; |
| 284 } | |
| 285 | |
| 9610 | 286 static zephyr_triple *find_sub_by_triple(zephyr_account *zephyr,zephyr_triple * zt) |
| 2086 | 287 { |
| 288 zephyr_triple *curr_t; | |
| 9610 | 289 GSList *curr = zephyr->subscrips; |
| 8644 | 290 |
| 2086 | 291 while (curr) { |
| 292 curr_t = curr->data; | |
| 293 if (triple_subset(zt, curr_t)) | |
| 294 return curr_t; | |
| 295 curr = curr->next; | |
| 296 } | |
| 297 return NULL; | |
| 298 } | |
| 299 | |
| 9610 | 300 static zephyr_triple *find_sub_by_id(zephyr_account *zephyr,int id) |
| 2086 | 301 { |
| 302 zephyr_triple *zt; | |
| 9610 | 303 GSList *curr = zephyr->subscrips; |
| 8644 | 304 |
| 2086 | 305 while (curr) { |
| 306 zt = curr->data; | |
| 307 if (zt->id == id) | |
| 308 return zt; | |
| 309 curr = curr->next; | |
| 310 } | |
| 311 return NULL; | |
| 312 } | |
| 313 | |
| 9328 | 314 /* |
| 9434 | 315 Converts strings to utf-8 if necessary using user specified encoding |
| 9328 | 316 */ |
| 317 | |
| 9610 | 318 static gchar *zephyr_recv_convert(GaimConnection *gc,gchar *string, int len) |
| 8560 | 319 { |
| 320 gchar *utf8; | |
| 321 GError *err = NULL; | |
| 9896 | 322 zephyr_account *zephyr = gc->proto_data; |
| 8644 | 323 if (g_utf8_validate(string, len, NULL)) { |
| 8568 | 324 return g_strdup(string); |
| 325 } else { | |
| 9896 | 326 utf8 = g_convert(string, len, "UTF-8", zephyr->encoding, NULL, NULL, &err); |
| 8568 | 327 if (err) { |
| 328 gaim_debug(GAIM_DEBUG_ERROR, "zephyr", "recv conversion error: %s\n", err->message); | |
| 9896 | 329 utf8 = g_strdup(_("(There was an error converting this message. Check the 'Encoding' option in the Account Editor)")); |
| 8954 | 330 g_error_free(err); |
| 8568 | 331 } |
| 332 | |
| 333 return utf8; | |
| 334 } | |
| 8560 | 335 } |
| 336 | |
| 2086 | 337 /* utility macros that are useful for zephyr_to_html */ |
| 338 | |
| 339 #define IS_OPENER(c) ((c == '{') || (c == '[') || (c == '(') || (c == '<')) | |
| 340 #define IS_CLOSER(c) ((c == '}') || (c == ']') || (c == ')') || (c == '>')) | |
| 341 | |
| 8451 | 342 /* This parses HTML formatting (put out by one of the gtkimhtml widgets |
| 343 And converts it to zephyr formatting. | |
| 344 It currently deals properly with <b>, <br>, <i>, <font face=...>, <font color=...>, | |
| 345 It ignores <font back=...> | |
| 346 It does | |
| 347 <font size = "1 or 2" -> @small | |
| 348 3 or 4 @medium() | |
| 349 5,6, or 7 @large() | |
| 350 <a href is dealt with by ignoring the description and outputting the link | |
| 351 */ | |
| 352 | |
| 353 static char *html_to_zephyr(const char *message) | |
| 354 { | |
| 8644 | 355 int len, cnt, retcount; |
| 356 char *ret; | |
| 357 | |
| 358 len = strlen(message); | |
| 9478 | 359 if (!len) |
| 360 return g_strdup(""); | |
| 361 | |
| 8644 | 362 ret = g_new0(char, len * 3); |
| 363 | |
| 364 bzero(ret, len * 3); | |
| 365 retcount = 0; | |
| 366 cnt = 0; | |
| 9896 | 367 gaim_debug_info("zephyr","html received %s\n",message); |
| 8644 | 368 while (cnt <= len) { |
| 369 if (message[cnt] == '<') { | |
| 370 if (!g_ascii_strncasecmp(message + cnt + 1, "i>", 2)) { | |
| 371 strncpy(ret + retcount, "@i(", 3); | |
| 372 cnt += 3; | |
| 373 retcount += 3; | |
| 374 } else if (!g_ascii_strncasecmp(message + cnt + 1, "b>", 2)) { | |
| 375 strncpy(ret + retcount, "@b(", 3); | |
| 376 cnt += 3; | |
| 377 retcount += 3; | |
| 378 } else if (!g_ascii_strncasecmp(message + cnt + 1, "br>", 3)) { | |
| 379 strncpy(ret + retcount, "\n", 1); | |
| 380 cnt += 4; | |
| 381 retcount += 1; | |
| 9896 | 382 } else if (!g_ascii_strncasecmp(message + cnt + 1, "a href=\"mailto:", 15)) { |
| 383 cnt += 16; | |
| 384 while (g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) { | |
| 385 ret[retcount] = message[cnt]; | |
| 386 retcount++; | |
| 387 cnt++; | |
| 388 } | |
| 389 cnt += 2; | |
| 390 /* ignore descriptive string */ | |
| 391 while (g_ascii_strncasecmp(message + cnt, "</a>", 4) != 0) { | |
| 392 cnt++; | |
| 393 } | |
| 394 cnt += 4; | |
| 8644 | 395 } else if (!g_ascii_strncasecmp(message + cnt + 1, "a href=\"", 8)) { |
| 396 cnt += 9; | |
| 397 while (g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) { | |
| 398 ret[retcount] = message[cnt]; | |
| 399 retcount++; | |
| 400 cnt++; | |
| 401 } | |
| 402 cnt += 2; | |
| 403 /* ignore descriptive string */ | |
| 404 while (g_ascii_strncasecmp(message + cnt, "</a>", 4) != 0) { | |
| 405 cnt++; | |
| 406 } | |
| 407 cnt += 4; | |
| 408 } else if (!g_ascii_strncasecmp(message + cnt + 1, "font", 4)) { | |
| 409 cnt += 5; | |
| 410 while (!g_ascii_strncasecmp(message + cnt, " ", 1)) | |
| 411 cnt++; | |
| 412 if (!g_ascii_strncasecmp(message + cnt, "color=\"", 7)) { | |
| 413 cnt += 7; | |
| 414 strncpy(ret + retcount, "@color(", 7); | |
| 415 retcount += 7; | |
| 416 while (g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) { | |
| 417 ret[retcount] = message[cnt]; | |
| 418 retcount++; | |
| 419 cnt++; | |
| 420 } | |
| 421 ret[retcount] = ')'; | |
| 422 retcount++; | |
| 423 cnt += 2; | |
| 424 } else if (!g_ascii_strncasecmp(message + cnt, "face=\"", 6)) { | |
| 425 cnt += 6; | |
| 426 strncpy(ret + retcount, "@font(", 6); | |
| 427 retcount += 6; | |
| 428 while (g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) { | |
| 429 ret[retcount] = message[cnt]; | |
| 430 retcount++; | |
| 431 cnt++; | |
| 432 } | |
| 433 ret[retcount] = ')'; | |
| 434 retcount++; | |
| 435 cnt += 2; | |
| 436 } else if (!g_ascii_strncasecmp(message + cnt, "size=\"", 6)) { | |
| 437 cnt += 6; | |
| 438 if ((message[cnt] == '1') || (message[cnt] == '2')) { | |
| 439 strncpy(ret + retcount, "@small(", 7); | |
| 440 retcount += 7; | |
| 441 } else if ((message[cnt] == '3') | |
| 9896 | 442 || (message[cnt] == '4')) { |
| 8644 | 443 strncpy(ret + retcount, "@medium(", 8); |
| 444 retcount += 8; | |
| 445 } else if ((message[cnt] == '5') | |
| 9896 | 446 || (message[cnt] == '6') |
| 447 || (message[cnt] == '7')) { | |
| 8644 | 448 strncpy(ret + retcount, "@large(", 7); |
| 449 retcount += 7; | |
| 450 } | |
| 451 cnt += 3; | |
| 452 } else { | |
| 453 /* Drop all unrecognized/misparsed font tags */ | |
| 454 while (g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) { | |
| 455 cnt++; | |
| 456 } | |
| 457 cnt += 2; | |
| 458 } | |
| 459 } else if (!g_ascii_strncasecmp(message + cnt + 1, "/i>", 3) | |
| 9896 | 460 || !g_ascii_strncasecmp(message + cnt + 1, "/b>", 3)) { |
| 8644 | 461 cnt += 4; |
| 462 ret[retcount] = ')'; | |
| 463 retcount++; | |
| 464 } else if (!g_ascii_strncasecmp(message + cnt + 1, "/font>", 6)) { | |
| 465 cnt += 7; | |
| 466 strncpy(ret + retcount, "@font(fixed)", 12); | |
| 467 retcount += 12; | |
| 468 } else { | |
| 469 /* Catch all for all unrecognized/misparsed <foo> tage */ | |
| 470 while (g_ascii_strncasecmp(message + cnt, ">", 1) != 0) { | |
| 471 ret[retcount] = message[cnt]; | |
| 472 retcount++; | |
| 473 cnt++; | |
| 474 } | |
| 475 } | |
| 476 } else { | |
| 477 /* Duh */ | |
| 478 ret[retcount] = message[cnt]; | |
| 479 retcount++; | |
| 480 cnt++; | |
| 481 } | |
| 482 } | |
| 9896 | 483 gaim_debug_info("zephyr","zephyr outputted %s\n",ret); |
| 8644 | 484 return ret; |
| 8451 | 485 } |
| 486 | |
| 2086 | 487 /* this parses zephyr formatting and converts it to html. For example, if |
| 488 * you pass in "@{@color(blue)@i(hello)}" you should get out | |
| 489 * "<font color=blue><i>hello</i></font>". */ | |
| 490 static char *zephyr_to_html(char *message) | |
| 491 { | |
| 492 int len, cnt; | |
| 493 zframe *frames, *curr; | |
| 494 char *ret; | |
| 495 | |
| 496 frames = g_new(zframe, 1); | |
| 497 frames->text = g_string_new(""); | |
| 498 frames->enclosing = NULL; | |
| 499 frames->closing = ""; | |
| 500 frames->has_closer = FALSE; | |
| 501 | |
| 502 len = strlen(message); | |
| 503 cnt = 0; | |
| 504 while (cnt <= len) { | |
| 505 if (message[cnt] == '@') { | |
| 506 zframe *new_f; | |
| 507 char *buf; | |
| 508 int end; | |
| 8644 | 509 |
| 510 for (end = 1; (cnt + end) <= len && !IS_OPENER(message[cnt + end]) | |
| 9896 | 511 && !IS_CLOSER(message[cnt + end]); end++); |
| 2086 | 512 buf = g_new0(char, end); |
| 8644 | 513 |
| 2086 | 514 if (end) { |
| 8644 | 515 g_snprintf(buf, end, "%s", message + cnt + 1); |
| 2086 | 516 } |
| 8644 | 517 if (!g_ascii_strcasecmp(buf, "italic") || !g_ascii_strcasecmp(buf, "i")) { |
| 2086 | 518 new_f = g_new(zframe, 1); |
| 519 new_f->enclosing = frames; | |
| 520 new_f->text = g_string_new("<i>"); | |
| 521 new_f->closing = "</i>"; | |
| 522 new_f->has_closer = TRUE; | |
| 523 frames = new_f; | |
| 8644 | 524 cnt += end + 1; /* cnt points to char after opener */ |
| 525 } else if (!g_ascii_strcasecmp(buf, "small")) { | |
| 526 new_f = g_new(zframe, 1); | |
| 527 new_f->enclosing = frames; | |
| 528 new_f->text = g_string_new("<font size=\"1\">"); | |
| 529 new_f->closing = "</font>"; | |
| 530 frames = new_f; | |
| 531 cnt += end + 1; | |
| 532 } else if (!g_ascii_strcasecmp(buf, "medium")) { | |
| 533 new_f = g_new(zframe, 1); | |
| 534 new_f->enclosing = frames; | |
| 535 new_f->text = g_string_new("<font size=\"3\">"); | |
| 536 new_f->closing = "</font>"; | |
| 537 frames = new_f; | |
| 538 cnt += end + 1; | |
| 539 } else if (!g_ascii_strcasecmp(buf, "large")) { | |
| 540 new_f = g_new(zframe, 1); | |
| 541 new_f->enclosing = frames; | |
| 542 new_f->text = g_string_new("<font size=\"7\">"); | |
| 543 new_f->closing = "</font>"; | |
| 544 frames = new_f; | |
| 545 cnt += end + 1; | |
| 546 } else if (!g_ascii_strcasecmp(buf, "bold") | |
| 9896 | 547 || !g_ascii_strcasecmp(buf, "b")) { |
| 2086 | 548 new_f = g_new(zframe, 1); |
| 549 new_f->enclosing = frames; | |
| 550 new_f->text = g_string_new("<b>"); | |
| 551 new_f->closing = "</b>"; | |
| 552 new_f->has_closer = TRUE; | |
| 553 frames = new_f; | |
| 8644 | 554 cnt += end + 1; |
| 555 } else if (!g_ascii_strcasecmp(buf, "font")) { | |
| 556 cnt += end + 1; | |
| 8451 | 557 new_f = g_new(zframe, 1); |
| 558 new_f->enclosing = frames; | |
| 559 new_f->text = g_string_new("<font face="); | |
| 560 for (; (cnt <= len) && !IS_CLOSER(message[cnt]); cnt++) { | |
| 561 g_string_append_c(new_f->text, message[cnt]); | |
| 562 } | |
| 8644 | 563 cnt++; /* point to char after closer */ |
| 8451 | 564 g_string_append_c(new_f->text, '>'); |
| 565 new_f->closing = "</font>"; | |
| 566 new_f->has_closer = FALSE; | |
| 567 frames = new_f; | |
| 8568 | 568 } else if (!g_ascii_strcasecmp(buf, "color")) { |
| 8644 | 569 cnt += end + 1; |
| 2086 | 570 new_f = g_new(zframe, 1); |
| 571 new_f->enclosing = frames; | |
| 572 new_f->text = g_string_new("<font color="); | |
| 573 for (; (cnt <= len) && !IS_CLOSER(message[cnt]); cnt++) { | |
| 574 g_string_append_c(new_f->text, message[cnt]); | |
| 575 } | |
| 8644 | 576 cnt++; /* point to char after closer */ |
| 2086 | 577 g_string_append_c(new_f->text, '>'); |
| 578 new_f->closing = "</font>"; | |
| 579 new_f->has_closer = FALSE; | |
| 580 frames = new_f; | |
| 4793 | 581 } else if (!g_ascii_strcasecmp(buf, "")) { |
| 2086 | 582 new_f = g_new(zframe, 1); |
| 583 new_f->enclosing = frames; | |
| 584 new_f->text = g_string_new(""); | |
| 585 new_f->closing = ""; | |
| 586 new_f->has_closer = TRUE; | |
| 587 frames = new_f; | |
| 8644 | 588 cnt += end + 1; /* cnt points to char after opener */ |
| 2086 | 589 } else { |
| 8644 | 590 if ((cnt + end) > len) { |
| 2086 | 591 g_string_append_c(frames->text, '@'); |
| 592 cnt++; | |
| 8644 | 593 } else if (IS_CLOSER(message[cnt + end])) { |
| 594 /* We have @chars..closer . This is | |
| 595 merely a sequence of chars that isn't a formatting tag | |
| 9896 | 596 */ |
| 8644 | 597 int tmp = cnt; |
| 598 | |
| 599 while (tmp <= cnt + end) { | |
| 600 g_string_append_c(frames->text, message[tmp]); | |
| 601 tmp++; | |
| 602 } | |
| 603 cnt += end + 1; | |
| 604 } else { | |
| 2086 | 605 /* unrecognized thingie. act like it's not there, but we |
| 606 * still need to take care of the corresponding closer, | |
| 607 * make a frame that does nothing. */ | |
| 608 new_f = g_new(zframe, 1); | |
| 609 new_f->enclosing = frames; | |
| 610 new_f->text = g_string_new(""); | |
| 611 new_f->closing = ""; | |
| 612 new_f->has_closer = TRUE; | |
| 613 frames = new_f; | |
| 8644 | 614 cnt += end + 1; /* cnt points to char after opener */ |
| 2086 | 615 } |
| 616 } | |
| 617 } else if (IS_CLOSER(message[cnt])) { | |
| 618 zframe *popped; | |
| 619 gboolean last_had_closer; | |
| 8644 | 620 |
| 2086 | 621 if (frames->enclosing) { |
| 622 do { | |
| 623 popped = frames; | |
| 624 frames = frames->enclosing; | |
| 625 g_string_append(frames->text, popped->text->str); | |
| 626 g_string_append(frames->text, popped->closing); | |
| 627 g_string_free(popped->text, TRUE); | |
| 628 last_had_closer = popped->has_closer; | |
| 629 g_free(popped); | |
| 630 } while (frames && frames->enclosing && !last_had_closer); | |
| 631 } else { | |
| 632 g_string_append_c(frames->text, message[cnt]); | |
| 633 } | |
| 634 cnt++; | |
| 635 } else if (message[cnt] == '\n') { | |
| 636 g_string_append(frames->text, "<br>"); | |
| 637 cnt++; | |
| 638 } else { | |
| 639 g_string_append_c(frames->text, message[cnt++]); | |
| 640 } | |
| 641 } | |
| 642 /* go through all the stuff that they didn't close */ | |
| 643 while (frames->enclosing) { | |
| 644 curr = frames; | |
| 645 g_string_append(frames->enclosing->text, frames->text->str); | |
| 646 g_string_append(frames->enclosing->text, frames->closing); | |
| 647 g_string_free(frames->text, TRUE); | |
| 648 frames = frames->enclosing; | |
| 649 g_free(curr); | |
| 650 } | |
| 651 ret = frames->text->str; | |
| 652 g_string_free(frames->text, FALSE); | |
| 653 g_free(frames); | |
| 654 return ret; | |
| 655 } | |
| 656 | |
| 9610 | 657 static gboolean pending_zloc(zephyr_account *zephyr,char *who) |
| 2086 | 658 { |
| 659 GList *curr; | |
| 8644 | 660 |
| 9610 | 661 for (curr = zephyr->pending_zloc_names; curr != NULL; curr = curr->next) { |
| 9896 | 662 char* normalized_who = local_zephyr_normalize(zephyr,who); |
| 9328 | 663 if (!g_ascii_strcasecmp(normalized_who, (char *)curr->data)) { |
| 8644 | 664 g_free((char *)curr->data); |
| 9610 | 665 zephyr->pending_zloc_names = g_list_remove(zephyr->pending_zloc_names, curr->data); |
| 2086 | 666 return TRUE; |
| 667 } | |
| 668 } | |
| 669 return FALSE; | |
| 670 } | |
| 671 | |
| 9328 | 672 /* Called when the server notifies us a message couldn't get sent */ |
| 673 | |
| 9610 | 674 static void message_failed(GaimConnection *gc, ZNotice_t notice, struct sockaddr_in from) |
| 8559 | 675 { |
| 8644 | 676 if (g_ascii_strcasecmp(notice.z_class, "message")) { |
| 9328 | 677 gchar* chat_failed = g_strdup_printf(_("Unable send to chat %s,%s,%s"),notice.z_class,notice.z_class_inst,notice.z_recipient); |
| 9610 | 678 gaim_notify_error(gc,"",chat_failed,NULL); |
| 9328 | 679 g_free(chat_failed); |
| 8644 | 680 } else { |
| 9610 | 681 gaim_notify_error(gc, notice.z_recipient, _("User is offline"), NULL); |
| 8644 | 682 } |
| 8559 | 683 } |
| 684 | |
| 9610 | 685 static void handle_message(GaimConnection *gc,ZNotice_t notice, struct sockaddr_in from) |
| 2086 | 686 { |
| 9896 | 687 zephyr_account* zephyr = gc->proto_data; |
| 688 | |
| 4793 | 689 if (!g_ascii_strcasecmp(notice.z_class, LOGIN_CLASS)) { |
| 3277 | 690 /* well, we'll be updating in 20 seconds anyway, might as well ignore this. */ |
| 4793 | 691 } else if (!g_ascii_strcasecmp(notice.z_class, LOCATE_CLASS)) { |
| 692 if (!g_ascii_strcasecmp(notice.z_opcode, LOCATE_LOCATE)) { | |
| 2086 | 693 int nlocs; |
| 694 char *user; | |
| 6695 | 695 GaimBuddy *b; |
| 9478 | 696 /* XXX add real error reporting */ |
| 2086 | 697 if (ZParseLocations(¬ice, NULL, &nlocs, &user) != ZERR_NONE) |
| 698 return; | |
| 8435 | 699 |
| 9610 | 700 if ((b = gaim_find_buddy(gc->account, user)) == NULL) { |
| 9986 | 701 char* stripped_user = zephyr_strip_local_realm(zephyr,user); |
| 702 b = gaim_find_buddy(gc->account,stripped_user); | |
| 703 g_free(stripped_user); | |
| 8644 | 704 } |
| 9896 | 705 if ((b && pending_zloc(zephyr,b->name)) || pending_zloc(zephyr,user)) { |
| 2086 | 706 ZLocations_t locs; |
| 707 int one = 1; | |
| 708 GString *str = g_string_new(""); | |
| 8644 | 709 |
| 710 g_string_append_printf(str, _("<b>User:</b> %s<br>"), b ? b->name : user); | |
| 8435 | 711 if (b && b->alias) |
| 5132 | 712 g_string_append_printf(str, _("<b>Alias:</b> %s<br>"), b->alias); |
| 2086 | 713 if (!nlocs) { |
| 5132 | 714 g_string_append_printf(str, _("<br>Hidden or not logged-in")); |
| 2086 | 715 } |
| 716 for (; nlocs > 0; nlocs--) { | |
| 9478 | 717 /* XXX add real error reporting */ |
| 2086 | 718 ZGetLocations(&locs, &one); |
| 8644 | 719 g_string_append_printf(str, _("<br>At %s since %s"), locs.host, locs.time); |
| 2086 | 720 } |
| 9797 | 721 gaim_notify_userinfo(gc, b ? b->name : user, NULL, _("Buddy Information"), NULL, |
| 9896 | 722 str->str, NULL, NULL); |
| 2086 | 723 g_string_free(str, TRUE); |
| 9986 | 724 } else { |
|
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
725 if (nlocs>0) |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
726 gaim_prpl_got_user_status(gc->account,b->name,"online",NULL); |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
727 else |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
728 gaim_prpl_got_user_status(gc->account,b->name,"offline",NULL); |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
729 } |
| 2086 | 730 |
| 9434 | 731 g_free(user); |
| 2086 | 732 } |
| 733 } else { | |
| 8560 | 734 char *buf, *buf2, *buf3; |
|
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
735 char *send_inst; |
| 8644 | 736 GaimConversation *gconv1; |
| 737 GaimConvChat *gcc; | |
| 2086 | 738 char *ptr = notice.z_message + strlen(notice.z_message) + 1; |
| 9478 | 739 int len; |
| 9896 | 740 char *sendertmp = g_strdup_printf("%s", zephyr->username); |
| 9478 | 741 int signature_length = strlen(notice.z_message); |
| 742 int message_has_no_body = 0; | |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7084
diff
changeset
|
743 GaimConvImFlags flags = 0; |
| 9896 | 744 gchar *tmpescape; |
| 8560 | 745 |
| 9478 | 746 /* Need to deal with 0 length messages to handle typing notification (OPCODE) ping messages */ |
| 747 /* One field zephyrs would have caused gaim to crash */ | |
| 748 if ( (notice.z_message_len == 0) || (signature_length >= notice.z_message_len - 1)) { | |
| 749 message_has_no_body = 1; | |
| 750 len = 0; | |
| 751 gaim_debug_info("zephyr","message_size %d %d %d\n",len,notice.z_message_len,signature_length); | |
| 752 buf3 = g_strdup(""); | |
| 753 | |
| 754 } else { | |
| 755 len = notice.z_message_len - ( signature_length +1); | |
| 756 gaim_debug_info("zephyr","message_size %d %d %d\n",len,notice.z_message_len,signature_length); | |
| 8644 | 757 buf = g_malloc(len + 1); |
| 758 g_snprintf(buf, len + 1, "%s", ptr); | |
| 759 g_strchomp(buf); | |
| 760 tmpescape = gaim_escape_html(buf); | |
| 9478 | 761 g_free(buf); |
| 8644 | 762 buf2 = zephyr_to_html(tmpescape); |
| 9610 | 763 buf3 = zephyr_recv_convert(gc,buf2, strlen(buf2)); |
| 8644 | 764 g_free(buf2); |
| 765 g_free(tmpescape); | |
| 9478 | 766 } |
| 8644 | 767 |
| 9896 | 768 if (!g_ascii_strcasecmp(notice.z_class, "MESSAGE") && !g_ascii_strcasecmp(notice.z_class_inst, "PERSONAL") |
| 769 && !g_ascii_strcasecmp(notice.z_recipient,zephyr->username)) { | |
| 770 gchar* stripped_sender; | |
| 771 if (!g_ascii_strcasecmp(notice.z_message, "Automated reply:")) | |
| 772 flags |= GAIM_CONV_IM_AUTO_RESP; | |
| 9912 | 773 stripped_sender = zephyr_strip_local_realm(zephyr,notice.z_sender); |
| 9896 | 774 |
| 9478 | 775 if (!g_ascii_strcasecmp(notice.z_opcode,"PING")) |
| 9610 | 776 serv_got_typing(gc,stripped_sender,ZEPHYR_TYPING_RECV_TIMEOUT, GAIM_TYPING); |
| 9896 | 777 else { |
| 778 /* Based on the values of | |
| 779 account->permit_deny, | |
| 780 account->permit, account>deny , and | |
| 781 the buddylist */ | |
| 782 | |
| 783 GSList* l; | |
| 784 gboolean in_deny; | |
| 9478 | 785 |
| 9896 | 786 switch (gc->account->perm_deny) { |
| 787 case GAIM_PRIVACY_ALLOW_ALL: | |
| 788 in_deny = 0; break; | |
| 789 case GAIM_PRIVACY_DENY_ALL: | |
| 790 in_deny = 1; break; | |
| 791 case GAIM_PRIVACY_ALLOW_USERS: /* See if stripped_sender is in gc->account->permit and allow appropriately */ | |
| 792 in_deny = 1; | |
| 793 for(l=gc->account->permit;l!=NULL;l=l->next) { | |
| 794 if (!gaim_utf8_strcasecmp(stripped_sender, gaim_normalize(gc->account, (char *)l->data))) { | |
| 795 in_deny=0; | |
| 796 break; | |
| 797 } | |
| 798 } | |
| 799 break; | |
| 800 case GAIM_PRIVACY_DENY_USERS: /* See if stripped_sender is in gc->account->deny and deny if so */ | |
| 801 in_deny = 0; | |
| 802 for(l=gc->account->deny;l!=NULL;l=l->next) { | |
| 803 if (!gaim_utf8_strcasecmp(stripped_sender, gaim_normalize(gc->account, (char *)l->data))) { | |
| 804 in_deny=1; | |
| 805 break; | |
| 806 } | |
| 807 } | |
| 808 break; | |
| 809 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
| 810 in_deny = 1; | |
| 811 if (gaim_find_buddy(gc->account,stripped_sender)!=NULL) { | |
| 812 in_deny = 0; | |
| 813 } | |
| 814 break; | |
| 815 default: | |
| 816 in_deny=0; break; | |
| 817 } | |
| 818 | |
| 819 if (!in_deny) { | |
| 820 serv_got_im(gc, stripped_sender, buf3, flags, time(NULL)); | |
| 821 } | |
| 822 } | |
| 823 | |
| 824 g_free(stripped_sender); | |
| 825 } else { | |
| 826 zephyr_triple *zt1, *zt2; | |
| 827 gchar *send_inst_utf8; | |
| 828 zephyr_account *zephyr = gc->proto_data; | |
| 829 zt1 = new_triple(gc->proto_data,notice.z_class, notice.z_class_inst, notice.z_recipient); | |
| 830 zt2 = find_sub_by_triple(gc->proto_data,zt1); | |
| 831 if (!zt2) { | |
| 832 /* This is a server supplied subscription */ | |
| 833 zephyr->subscrips = g_slist_append(zephyr->subscrips, new_triple(zephyr,zt1->class,zt1->instance,zt1->recipient)); | |
| 9610 | 834 zt2 = find_sub_by_triple(gc->proto_data,zt1); |
| 9896 | 835 } |
| 836 | |
| 837 if (!zt2->open) { | |
| 838 zt2->open = TRUE; | |
| 839 serv_got_joined_chat(gc, zt2->id, zt2->name); | |
| 840 zephyr_chat_set_topic(gc,zt2->id,notice.z_class_inst); | |
| 841 } | |
| 842 g_free(sendertmp); /* fix memory leak? */ | |
| 843 /* If the person is in the default Realm, then strip the | |
| 844 Realm from the sender field */ | |
| 9912 | 845 sendertmp = zephyr_strip_local_realm(zephyr,notice.z_sender); |
| 9896 | 846 send_inst = g_strdup_printf("%s %s",sendertmp,notice.z_class_inst); |
| 847 send_inst_utf8 = zephyr_recv_convert(gc,send_inst, strlen(send_inst)); | |
| 848 if (!send_inst_utf8) { | |
| 849 gaim_debug(GAIM_DEBUG_ERROR, "zephyr","send_inst %s became null\n", send_inst); | |
| 850 send_inst_utf8 = "malformed instance"; | |
| 2086 | 851 } |
| 9912 | 852 |
| 9896 | 853 serv_got_chat_in(gc, zt2->id, send_inst_utf8, 0, buf3, time(NULL)); |
| 854 g_free(send_inst); | |
| 10246 | 855 gconv1 = gaim_find_conversation_with_account(GAIM_CONV_CHAT, |
| 856 zt2->name, gc->account); | |
| 9896 | 857 gcc = gaim_conversation_get_chat_data(gconv1); |
| 9912 | 858 |
| 9896 | 859 if (!gaim_conv_chat_find_user(gcc, sendertmp)) { |
| 860 /* force interpretation in network byte order */ | |
| 861 unsigned char *addrs = (unsigned char *)&(notice.z_sender_addr.s_addr); | |
| 862 gchar* ipaddr = g_strdup_printf("%hhd.%hhd.%hhd.%hhd", (unsigned char)addrs[0], | |
| 863 (unsigned char)addrs[1], (unsigned char)addrs[2], | |
| 864 (unsigned char) addrs[3]); | |
| 865 | |
| 866 gaim_conv_chat_add_user(gcc, sendertmp, ipaddr, GAIM_CBFLAGS_NONE, TRUE); | |
| 867 g_free(ipaddr); /* fix memory leak? */ | |
| 868 | |
| 869 } | |
| 870 g_free(sendertmp); | |
| 871 g_free(send_inst_utf8); | |
| 872 | |
| 873 free_triple(zt1); | |
| 874 } | |
| 875 g_free(buf3); | |
| 9478 | 876 |
| 2086 | 877 } |
| 878 } | |
| 9896 | 879 int free_parse_tree(parse_tree* tree) { |
| 880 if (!tree) { | |
| 881 return 0; | |
| 882 } | |
| 883 else { | |
| 884 int i; | |
| 885 if (tree->children) { | |
| 886 for(i=0;i<tree->num_children;i++){ | |
| 887 if (tree->children[i]) { | |
| 888 free_parse_tree(tree->children[i]); | |
| 889 g_free(tree->children[i]); | |
| 890 } | |
| 891 } | |
| 892 } | |
| 893 if ((tree != &null_parse_tree) && (tree->contents != NULL)) | |
| 894 g_free(tree->contents); | |
| 2086 | 895 |
| 9896 | 896 } |
| 897 return 0; | |
| 898 } | |
| 899 | |
| 900 parse_tree *tree_child(parse_tree* tree,int index) { | |
| 901 if (index < tree->num_children) { | |
| 902 return tree->children[index]; | |
| 903 } else { | |
| 904 return &null_parse_tree; | |
| 905 } | |
| 906 } | |
| 907 | |
| 908 parse_tree *find_node(parse_tree* ptree,gchar* key) | |
| 909 { | |
| 910 gchar* tc = tree_child(ptree,0)->contents; | |
| 911 | |
| 912 if (!ptree || ! key) | |
| 913 return &null_parse_tree; | |
| 914 | |
| 915 if (ptree->num_children > 0 && tc && !strcasecmp(tc, key)) { | |
| 916 return ptree; | |
| 917 } else { | |
| 918 parse_tree *result = &null_parse_tree; | |
| 919 int i; | |
| 920 for(i = 0; i < ptree->num_children; i++) { | |
| 921 result = find_node(ptree->children[i],key); | |
| 922 if(result != &null_parse_tree) { | |
| 923 break; | |
| 924 } | |
| 925 } | |
| 926 return result; | |
| 927 } | |
| 928 } | |
| 929 | |
| 930 parse_tree *parse_buffer(gchar* source, gboolean do_parse) { | |
| 931 | |
| 932 parse_tree *ptree = g_new0(parse_tree,1); | |
| 933 ptree->contents = NULL; | |
| 934 ptree->num_children=0; | |
| 935 if (do_parse) { | |
| 936 unsigned int p = 0; | |
| 937 while(p < strlen(source)) { | |
| 938 unsigned int end; | |
| 9986 | 939 gchar *newstr; |
| 9896 | 940 |
| 941 /* Eat white space: */ | |
| 942 if(g_ascii_isspace(source[p]) || source[p] == '\001') { | |
| 943 p++; | |
| 944 continue; | |
| 945 } | |
| 946 | |
| 947 /* Skip comments */ | |
| 948 if(source[p] == ';') { | |
| 949 while(source[p] != '\n' && p < strlen(source)) { | |
| 950 p++; | |
| 951 } | |
| 952 continue; | |
| 953 } | |
| 954 | |
| 955 if(source[p] == '(') { | |
| 956 int nesting = 0; | |
| 957 gboolean in_quote = FALSE; | |
| 958 gboolean escape_next = FALSE; | |
| 959 p++; | |
| 960 end = p; | |
| 961 while(!(source[end] == ')' && nesting == 0 && !in_quote) && end < strlen(source)) { | |
| 962 if(!escape_next) { | |
| 963 if(source[end] == '\\') { | |
| 964 escape_next = TRUE; | |
| 965 } | |
| 966 if(!in_quote) { | |
| 967 if(source[end] == '(') { | |
| 968 nesting++; | |
| 969 } | |
| 970 if(source[end] == ')') { | |
| 971 nesting--; | |
| 972 } | |
| 973 } | |
| 974 if(source[end] == '"') { | |
| 975 in_quote = !in_quote; | |
| 976 } | |
| 977 } else { | |
| 978 escape_next = FALSE; | |
| 979 } | |
| 980 end++; | |
| 981 } | |
| 982 do_parse = TRUE; | |
| 983 | |
| 984 } else { | |
| 985 gchar end_char; | |
| 986 if(source[p] == '"') { | |
| 987 end_char = '"'; | |
| 988 p++; | |
| 989 } else { | |
| 990 end_char = ' '; | |
| 991 } | |
| 992 do_parse = FALSE; | |
| 993 | |
| 994 end = p; | |
| 995 while(source[end] != end_char && end < strlen(source)) { | |
| 996 if(source[end] == '\\') | |
| 997 end++; | |
| 998 end++; | |
| 999 } | |
| 1000 } | |
| 1001 newstr = g_new0(gchar, end+1-p); | |
| 1002 strncpy(newstr,source+p,end-p); | |
| 1003 if (ptree->num_children < MAXCHILDREN) { | |
| 1004 /* In case we surpass maxchildren, ignore this */ | |
| 1005 ptree->children[ptree->num_children++] = parse_buffer( newstr, do_parse); | |
| 1006 } else { | |
| 1007 gaim_debug_error("zephyr","too many children in tzc output. skipping\n"); | |
| 1008 } | |
| 1009 g_free(newstr); | |
| 1010 p = end + 1; | |
| 1011 } | |
| 1012 return ptree; | |
| 1013 } else { | |
| 1014 /* XXX does this have to be strdup'd */ | |
| 1015 ptree->contents = g_strdup(source); | |
| 1016 return ptree; | |
| 1017 } | |
| 1018 } | |
| 1019 | |
| 1020 parse_tree *read_from_tzc(zephyr_account* zephyr){ | |
| 1021 struct timeval tv; | |
| 1022 fd_set rfds; | |
| 1023 int bufsize = 2048; | |
| 1024 char *buf = (char *)calloc(bufsize, 1); | |
| 1025 char *bufcur = buf; | |
| 1026 int selected = 0; | |
| 9986 | 1027 parse_tree *incoming_msg; |
| 9896 | 1028 |
| 1029 FD_ZERO(&rfds); | |
| 1030 FD_SET(zephyr->fromtzc[ZEPHYR_FD_READ], &rfds); | |
| 1031 tv.tv_sec = 0; | |
| 1032 tv.tv_usec = 0; | |
| 9986 | 1033 incoming_msg=NULL; |
| 9896 | 1034 |
| 1035 while (select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, &tv)) { | |
| 1036 selected = 1; | |
| 1037 read(zephyr->fromtzc[ZEPHYR_FD_READ], bufcur, 1); | |
| 1038 bufcur++; | |
| 1039 if ((bufcur - buf) > (bufsize - 1)) { | |
| 1040 if ((buf = realloc(buf, bufsize * 2)) == NULL) { | |
| 1041 gaim_debug_error("zephyr","Ran out of memory"); | |
| 1042 exit(-1); | |
| 1043 } else { | |
| 1044 bufcur = buf + bufsize; | |
| 1045 bufsize *= 2; | |
| 1046 } | |
| 1047 } | |
| 1048 } | |
| 1049 *bufcur = '\0'; | |
| 1050 | |
| 1051 if (selected) { | |
| 1052 incoming_msg = parse_buffer(buf,TRUE); | |
| 1053 } | |
| 1054 free(buf); | |
| 1055 return incoming_msg; | |
| 1056 } | |
| 1057 | |
| 1058 static gint check_notify_tzc(gpointer data) | |
| 1059 { | |
| 1060 GaimConnection *gc = (GaimConnection *)data; | |
| 1061 zephyr_account* zephyr = gc->proto_data; | |
| 1062 parse_tree *newparsetree = read_from_tzc(zephyr); | |
| 1063 struct sockaddr_in from; | |
| 1064 if (newparsetree != NULL) { | |
| 1065 gchar *spewtype; | |
| 1066 if ( (spewtype = tree_child(find_node(newparsetree,"tzcspew"),2)->contents) ) { | |
| 1067 if (!g_ascii_strncasecmp(spewtype,"message",7)) { | |
| 1068 ZNotice_t notice; | |
| 1069 parse_tree *msgnode = tree_child(find_node(newparsetree,"message"),2); | |
| 1070 parse_tree *bodynode = tree_child(msgnode,1); | |
| 1071 /* char *zsig = g_strdup(" "); */ /* gaim doesn't care about zsigs */ | |
| 1072 char *msg = zephyr_tzc_deescape_str(bodynode->contents); | |
| 1073 size_t bufsize = strlen(msg) + 3; | |
| 1074 char *buf = g_new0(char,bufsize); | |
| 1075 g_snprintf(buf,1+strlen(msg)+2," %c%s",'\0',msg); | |
| 1076 bzero((char *)¬ice, sizeof(notice)); | |
| 1077 notice.z_kind = ACKED; | |
| 1078 notice.z_port = 0; | |
| 1079 notice.z_opcode = tree_child(find_node(newparsetree,"opcode"),2)->contents; | |
| 1080 notice.z_class = zephyr_tzc_deescape_str(tree_child(find_node(newparsetree,"class"),2)->contents); | |
| 1081 notice.z_class_inst = tree_child(find_node(newparsetree,"instance"),2)->contents; | |
| 1082 notice.z_recipient = local_zephyr_normalize(zephyr,tree_child(find_node(newparsetree,"recipient"),2)->contents); | |
| 1083 notice.z_sender = local_zephyr_normalize(zephyr,tree_child(find_node(newparsetree,"sender"),2)->contents); | |
| 1084 notice.z_default_format = "Class $class, Instance $instance:\n" "To: @bold($recipient) at $time $date\n" "From: @bold($1) <$sender>\n\n$2"; | |
| 1085 notice.z_message_len = strlen(msg) + 3; | |
| 1086 notice.z_message = buf; | |
| 1087 handle_message(gc,notice,from); | |
| 1088 g_free(msg); | |
| 1089 /* g_free(zsig); */ | |
| 1090 g_free(buf); | |
| 1091 /* free_parse_tree(msgnode); | |
| 1092 free_parse_tree(bodynode); | |
| 1093 g_free(msg); | |
| 1094 g_free(zsig); | |
| 1095 g_free(buf); | |
| 1096 */ | |
| 1097 } | |
| 1098 else if (!g_ascii_strncasecmp(spewtype,"zlocation",9)) { | |
| 1099 /* check_loc or zephyr_zloc respectively */ | |
| 1100 /* XXX fix */ | |
| 1101 char *user; | |
| 1102 GaimBuddy *b; | |
| 1103 int nlocs = 0; | |
| 9912 | 1104 parse_tree *locations; |
| 1105 gchar *locval; | |
| 9896 | 1106 user = tree_child(find_node(newparsetree,"user"),2)->contents; |
| 1107 | |
| 1108 if ((b = gaim_find_buddy(gc->account, user)) == NULL) { | |
| 9986 | 1109 gchar *stripped_user = zephyr_strip_local_realm(zephyr,user); |
| 9912 | 1110 b = gaim_find_buddy(gc->account, stripped_user); |
| 9986 | 1111 g_free(stripped_user); |
| 9896 | 1112 } |
| 1113 locations = find_node(newparsetree,"locations"); | |
| 1114 locval = tree_child(tree_child(tree_child(tree_child(locations,2),0),0),2)->contents; | |
| 1115 | |
| 1116 if (!locval || !g_ascii_strcasecmp(locval," ") || (strlen(locval) == 0)) { | |
| 1117 nlocs = 0; | |
| 1118 } else { | |
| 1119 nlocs = 1; | |
| 1120 } | |
| 1121 | |
| 1122 if ((b && pending_zloc(zephyr,b->name)) || pending_zloc(zephyr,user) || pending_zloc(zephyr,local_zephyr_normalize(zephyr,user))){ | |
| 1123 GString *str = g_string_new(""); | |
| 1124 | |
| 1125 g_string_append_printf(str, _("<b>User:</b> %s<br>"), b ? b->name : user); | |
| 1126 if (b && b->alias) | |
| 1127 g_string_append_printf(str, _("<b>Alias:</b> %s<br>"), b->alias); | |
| 1128 | |
| 1129 if (!nlocs) { | |
| 1130 g_string_append_printf(str, _("<br>Hidden or not logged-in")); | |
| 1131 } else { | |
| 1132 g_string_append_printf(str, _("<br>At %s since %s"), | |
| 1133 tree_child(tree_child(tree_child(tree_child(locations,2),0),0),2)->contents, | |
| 1134 tree_child(tree_child(tree_child(tree_child(locations,2),0),2),2)->contents); | |
| 1135 } | |
| 1136 | |
| 1137 gaim_notify_userinfo(gc, b ? b->name : user, NULL, _("Buddy Information"), NULL, | |
| 1138 str->str, NULL, NULL); | |
| 1139 g_string_free(str, TRUE); | |
| 1140 } else { | |
|
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1141 if (nlocs>0) |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1142 gaim_prpl_got_user_status(gc->account,b->name,"online",NULL); |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1143 else |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1144 gaim_prpl_got_user_status(gc->account,b->name,"offline",NULL); |
| 9896 | 1145 } |
| 1146 } | |
| 1147 else if (!g_ascii_strncasecmp(spewtype,"subscribed",10)) { | |
| 1148 } | |
| 1149 else if (!g_ascii_strncasecmp(spewtype,"start",5)) { | |
| 1150 } | |
| 1151 else if (!g_ascii_strncasecmp(spewtype,"error",5)) { | |
| 1152 /* XXX handle */ | |
| 1153 } | |
| 1154 } else { | |
| 1155 } | |
| 1156 } else { | |
| 1157 } | |
| 1158 | |
| 1159 free_parse_tree(newparsetree); | |
| 1160 return TRUE; | |
| 1161 } | |
| 1162 | |
| 1163 static gint check_notify_zeph02(gpointer data) | |
| 2086 | 1164 { |
| 9478 | 1165 /* XXX add real error reporting */ |
| 9896 | 1166 GaimConnection *gc = (GaimConnection*) data; |
| 2086 | 1167 while (ZPending()) { |
| 1168 ZNotice_t notice; | |
| 1169 struct sockaddr_in from; | |
| 9478 | 1170 /* XXX add real error reporting */ |
| 8644 | 1171 |
| 2086 | 1172 z_call_r(ZReceiveNotice(¬ice, &from)); |
| 1173 | |
| 1174 switch (notice.z_kind) { | |
| 1175 case UNSAFE: | |
| 1176 case UNACKED: | |
| 1177 case ACKED: | |
| 9610 | 1178 handle_message(gc,notice, from); |
| 2086 | 1179 break; |
| 8644 | 1180 case SERVACK: |
| 1181 if (!(g_ascii_strcasecmp(notice.z_message, ZSRVACK_NOTSENT))) { | |
| 9610 | 1182 message_failed(gc,notice, from); |
| 8644 | 1183 } |
| 1184 break; | |
| 9328 | 1185 case CLIENTACK: |
| 9478 | 1186 gaim_debug_error("zephyr", "Client ack received\n"); |
| 2086 | 1187 default: |
| 1188 /* we'll just ignore things for now */ | |
| 9328 | 1189 handle_unknown(notice); |
| 9478 | 1190 gaim_debug_error("zephyr", "Unhandled notice.\n"); |
| 2086 | 1191 break; |
| 1192 } | |
| 9478 | 1193 /* XXX add real error reporting */ |
| 2086 | 1194 ZFreeNotice(¬ice); |
| 1195 } | |
| 1196 | |
| 1197 return TRUE; | |
| 1198 } | |
| 1199 | |
| 1200 static gint check_loc(gpointer data) | |
| 1201 { | |
| 6695 | 1202 GaimBlistNode *gnode, *cnode, *bnode; |
| 2086 | 1203 ZAsyncLocateData_t ald; |
| 9896 | 1204 GaimConnection *gc = (GaimConnection *)data; |
| 1205 zephyr_account *zephyr = gc->proto_data; | |
| 2086 | 1206 |
| 9896 | 1207 if (use_zeph02(zephyr)) { |
| 1208 ald.user = NULL; | |
| 1209 memset(&(ald.uid), 0, sizeof(ZUnique_Id_t)); | |
| 1210 ald.version = NULL; | |
| 1211 } | |
| 2086 | 1212 |
| 8644 | 1213 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
| 1214 if (!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
| 4785 | 1215 continue; |
| 8644 | 1216 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
| 1217 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
| 4785 | 1218 continue; |
| 8644 | 1219 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
| 1220 GaimBuddy *b = (GaimBuddy *) bnode; | |
| 1221 | |
| 1222 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
| 6695 | 1223 continue; |
| 9610 | 1224 if (b->account->gc == gc) { |
| 7261 | 1225 const char *chk; |
| 8644 | 1226 |
| 9896 | 1227 chk = local_zephyr_normalize(zephyr,b->name); |
| 1228 gaim_debug_info("zephyr","chk: %s b->name %s\n",chk,b->name); | |
| 9478 | 1229 /* XXX add real error reporting */ |
| 6695 | 1230 /* doesn't matter if this fails or not; we'll just move on to the next one */ |
| 9896 | 1231 if (use_zeph02(zephyr)) { |
| 1232 #ifdef WIN32 | |
| 9986 | 1233 int numlocs; |
| 1234 int one=1; | |
| 1235 ZLocateUser(chk,&numlocs,ZAUTH); | |
| 1236 if (numlocs) { | |
| 1237 int i; | |
| 1238 for(i=0;i<numlocs;i++) { | |
| 1239 ZGetLocations(&locations,&one); | |
|
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1240 if (nlocs>0) |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1241 gaim_prpl_got_user_status(gc->account,b->name,"online",NULL); |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1242 else |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1243 gaim_prpl_got_user_status(gc->account,b->name,"offline",NULL); |
| 9986 | 1244 } |
| 1245 } | |
| 9896 | 1246 #else |
| 1247 ZRequestLocations(chk, &ald, UNACKED, ZAUTH); | |
| 1248 g_free(ald.user); | |
| 1249 g_free(ald.version); | |
| 1250 #endif /* WIN32 */ | |
| 1251 } else | |
| 1252 if (use_tzc(zephyr)) { | |
| 1253 gchar *zlocstr = g_strdup_printf("((tzcfodder . zlocate) \"%s\")\n",chk); | |
| 1254 write(zephyr->totzc[ZEPHYR_FD_WRITE],zlocstr,strlen(zlocstr)); | |
| 1255 g_free(zlocstr); | |
| 1256 } | |
| 6695 | 1257 } |
| 4349 | 1258 } |
| 2086 | 1259 } |
| 1260 } | |
| 9896 | 1261 |
| 2086 | 1262 return TRUE; |
| 1263 } | |
| 1264 | |
| 1265 static char *get_exposure_level() | |
| 1266 { | |
| 9478 | 1267 /* XXX add real error reporting */ |
| 2086 | 1268 char *exposure = ZGetVariable("exposure"); |
| 1269 | |
| 1270 if (!exposure) | |
| 1271 return EXPOSE_REALMVIS; | |
| 4793 | 1272 if (!g_ascii_strcasecmp(exposure, EXPOSE_NONE)) |
| 2086 | 1273 return EXPOSE_NONE; |
| 4793 | 1274 if (!g_ascii_strcasecmp(exposure, EXPOSE_OPSTAFF)) |
| 2086 | 1275 return EXPOSE_OPSTAFF; |
| 4793 | 1276 if (!g_ascii_strcasecmp(exposure, EXPOSE_REALMANN)) |
| 2086 | 1277 return EXPOSE_REALMANN; |
| 4793 | 1278 if (!g_ascii_strcasecmp(exposure, EXPOSE_NETVIS)) |
| 2086 | 1279 return EXPOSE_NETVIS; |
| 4793 | 1280 if (!g_ascii_strcasecmp(exposure, EXPOSE_NETANN)) |
| 2086 | 1281 return EXPOSE_NETANN; |
| 1282 return EXPOSE_REALMVIS; | |
| 1283 } | |
| 1284 | |
| 1285 static void strip_comments(char *str) | |
| 1286 { | |
| 1287 char *tmp = strchr(str, '#'); | |
| 8644 | 1288 |
| 2086 | 1289 if (tmp) |
| 1290 *tmp = '\0'; | |
| 1291 g_strchug(str); | |
| 1292 g_strchomp(str); | |
| 1293 } | |
| 1294 | |
| 9896 | 1295 static void zephyr_inithosts(zephyr_account *zephyr) |
| 9478 | 1296 { |
| 1297 /* XXX This code may not be Win32 clean */ | |
| 1298 struct hostent *hent; | |
| 1299 | |
| 9802 | 1300 if (gethostname(zephyr->ourhost, sizeof(zephyr->ourhost)) == -1) { |
| 9478 | 1301 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"); |
| 9802 | 1302 g_strlcpy(zephyr->ourhost, "unknown", sizeof(zephyr->ourhost)); |
| 9803 | 1303 g_strlcpy(zephyr->ourhostcanon, "unknown", sizeof(zephyr->ourhostcanon)); |
| 9478 | 1304 return; |
| 1305 } | |
| 1306 | |
| 9610 | 1307 if (!(hent = gethostbyname(zephyr->ourhost))) { |
| 1308 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); | |
| 9803 | 1309 g_strlcpy(zephyr->ourhostcanon, zephyr->ourhost, sizeof(zephyr->ourhostcanon)); |
| 9478 | 1310 return; |
| 1311 } | |
| 9802 | 1312 |
| 1313 g_strlcpy(zephyr->ourhostcanon, hent->h_name, sizeof(zephyr->ourhostcanon)); | |
| 1314 | |
| 9478 | 1315 return; |
| 1316 } | |
| 1317 | |
| 9610 | 1318 static void process_zsubs(zephyr_account *zephyr) |
| 2086 | 1319 { |
| 9802 | 1320 /* Loads zephyr chats "(subscriptions) from ~/.zephyr.subs, and |
| 1321 registers (subscribes to) them on the server */ | |
| 9434 | 1322 |
| 9802 | 1323 /* XXX deal with unsubscriptions */ |
| 1324 /* XXX deal with punts */ | |
| 9434 | 1325 |
| 2086 | 1326 FILE *f; |
| 1327 gchar *fname; | |
| 1328 gchar buff[BUFSIZ]; | |
| 8644 | 1329 |
| 3630 | 1330 fname = g_strdup_printf("%s/.zephyr.subs", gaim_home_dir()); |
| 2086 | 1331 f = fopen(fname, "r"); |
| 1332 if (f) { | |
| 1333 char **triple; | |
| 1334 char *recip; | |
| 9478 | 1335 char *z_class; |
| 1336 char *z_instance; | |
| 9896 | 1337 char *z_galaxy = NULL; |
| 8644 | 1338 |
| 2086 | 1339 while (fgets(buff, BUFSIZ, f)) { |
| 1340 strip_comments(buff); | |
| 1341 if (buff[0]) { | |
| 1342 triple = g_strsplit(buff, ",", 3); | |
| 8644 | 1343 if (triple[0] && triple[1]) { |
| 9896 | 1344 char *tmp = g_strdup_printf("%s", zephyr->username); |
|
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1345 char *atptr; |
| 8644 | 1346 |
| 9896 | 1347 z_class = triple[0]; |
| 1348 z_instance = triple[1]; | |
| 8644 | 1349 if (triple[2] == NULL) { |
| 3277 | 1350 recip = g_malloc0(1); |
| 4793 | 1351 } else if (!g_ascii_strcasecmp(triple[2], "%me%")) { |
| 9896 | 1352 recip = g_strdup_printf("%s", zephyr->username); |
| 4793 | 1353 } else if (!g_ascii_strcasecmp(triple[2], "*")) { |
|
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1354 /* wildcard |
|
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1355 * form of class,instance,* */ |
|
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1356 recip = g_malloc0(1); |
| 4793 | 1357 } else if (!g_ascii_strcasecmp(triple[2], tmp)) { |
|
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1358 /* form of class,instance,aatharuv@ATHENA.MIT.EDU */ |
|
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1359 recip = g_strdup(triple[2]); |
|
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1360 } else if ((atptr = strchr(triple[2], '@')) != NULL) { |
|
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1361 /* form of class,instance,*@ANDREW.CMU.EDU |
|
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1362 * class,instance,@ANDREW.CMU.EDU |
|
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1363 * If realm is local realm, blank recipient, else |
|
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1364 * @REALM-NAME |
|
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1365 */ |
| 9896 | 1366 char *realmat = g_strdup_printf("@%s",zephyr->realm); |
| 8644 | 1367 |
| 4793 | 1368 if (!g_ascii_strcasecmp(atptr, realmat)) |
|
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1369 recip = g_malloc0(1); |
|
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1370 else |
|
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1371 recip = g_strdup(atptr); |
|
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1372 g_free(realmat); |
| 2086 | 1373 } else { |
| 1374 recip = g_strdup(triple[2]); | |
| 1375 } | |
|
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1376 g_free(tmp); |
| 9478 | 1377 |
| 1378 if (!g_ascii_strcasecmp(triple[0],"%host%")) { | |
| 9610 | 1379 z_class = g_strdup(zephyr->ourhost); |
| 9478 | 1380 } else if (!g_ascii_strcasecmp(triple[0],"%canon%")) { |
| 9610 | 1381 z_class = g_strdup(zephyr->ourhostcanon); |
| 9478 | 1382 } else { |
| 1383 z_class = g_strdup(triple[0]); | |
| 1384 } | |
| 1385 | |
| 1386 if (!g_ascii_strcasecmp(triple[1],"%host%")) { | |
| 9610 | 1387 z_instance = g_strdup(zephyr->ourhost); |
| 9478 | 1388 } else if (!g_ascii_strcasecmp(triple[1],"%canon%")) { |
| 9610 | 1389 z_instance = g_strdup(zephyr->ourhostcanon); |
| 9478 | 1390 } else { |
| 1391 z_instance = g_strdup(triple[1]); | |
| 1392 } | |
| 1393 | |
| 1394 /* There should be some sort of error report listing classes that couldn't be subbed to. | |
| 1395 Not important right now though */ | |
| 1396 | |
| 9896 | 1397 if (zephyr_subscribe_to(zephyr,z_class, z_instance, recip,z_galaxy) != ZERR_NONE) { |
| 9478 | 1398 |
| 9896 | 1399 gaim_debug(GAIM_DEBUG_ERROR, "zephyr", "Couldn't subscribe to %s, %s, %s\n", z_class,z_instance,recip); |
| 2086 | 1400 } |
| 9478 | 1401 |
| 9896 | 1402 zephyr->subscrips = g_slist_append(zephyr->subscrips, new_triple(zephyr,z_class,z_instance,recip)); |
| 9478 | 1403 /* g_hash_table_destroy(sub_hash_table); */ |
| 1404 g_free(z_instance); | |
| 1405 g_free(z_class); | |
| 2086 | 1406 g_free(recip); |
| 1407 } | |
| 1408 g_strfreev(triple); | |
| 1409 } | |
| 1410 } | |
| 1411 } | |
| 1412 } | |
| 1413 | |
| 9610 | 1414 static void process_anyone(GaimConnection *gc) |
| 2086 | 1415 { |
| 1416 FILE *fd; | |
| 1417 gchar buff[BUFSIZ], *filename; | |
| 6695 | 1418 GaimGroup *g; |
| 1419 GaimBuddy *b; | |
| 4775 | 1420 |
| 1421 if (!(g = gaim_find_group(_("Anyone")))) { | |
| 1422 g = gaim_group_new(_("Anyone")); | |
| 1423 gaim_blist_add_group(g, NULL); | |
| 1424 } | |
| 6695 | 1425 |
| 3630 | 1426 filename = g_strconcat(gaim_home_dir(), "/.anyone", NULL); |
| 2086 | 1427 if ((fd = fopen(filename, "r")) != NULL) { |
| 1428 while (fgets(buff, BUFSIZ, fd)) { | |
| 1429 strip_comments(buff); | |
| 4687 | 1430 if (buff[0]) { |
| 9610 | 1431 if (!(b = gaim_find_buddy(gc->account, buff))) { |
| 9986 | 1432 char *stripped_user = zephyr_strip_local_realm(gc->proto_data,buff); |
| 1433 gaim_debug_info("zephyr","stripped_user %s\n",stripped_user); | |
| 1434 if (!(b = gaim_find_buddy(gc->account,stripped_user))){ | |
| 1435 b = gaim_buddy_new(gc->account, stripped_user, NULL); | |
| 1436 gaim_blist_add_buddy(b, NULL, g, NULL); | |
| 1437 } | |
| 1438 g_free(stripped_user); | |
| 8644 | 1439 } |
| 1440 } | |
| 2086 | 1441 } |
| 1442 fclose(fd); | |
| 1443 } | |
| 1444 g_free(filename); | |
| 1445 } | |
| 1446 | |
|
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1447 static char* normalize_zephyr_exposure(const char* exposure) { |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1448 char *exp2 = g_strstrip(g_ascii_strup(exposure,-1)); |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1449 |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1450 if (!exp2) |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1451 return EXPOSE_REALMVIS; |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1452 if (!g_ascii_strcasecmp(exp2, EXPOSE_NONE)) |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1453 return EXPOSE_NONE; |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1454 if (!g_ascii_strcasecmp(exp2, EXPOSE_OPSTAFF)) |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1455 return EXPOSE_OPSTAFF; |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1456 if (!g_ascii_strcasecmp(exp2, EXPOSE_REALMANN)) |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1457 return EXPOSE_REALMANN; |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1458 if (!g_ascii_strcasecmp(exp2, EXPOSE_NETVIS)) |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1459 return EXPOSE_NETVIS; |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1460 if (!g_ascii_strcasecmp(exp2, EXPOSE_NETANN)) |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1461 return EXPOSE_NETANN; |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1462 return EXPOSE_REALMVIS; |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1463 } |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1464 |
| 8644 | 1465 static void zephyr_login(GaimAccount * account) |
| 2086 | 1466 { |
| 9896 | 1467 GaimConnection *gc; |
| 1468 zephyr_account *zephyr; | |
|
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1469 gboolean read_anyone; |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1470 gboolean read_zsubs; |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1471 gchar *exposure; |
| 9427 | 1472 |
| 9610 | 1473 gc = gaim_account_get_connection(account); |
|
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1474 read_anyone = gaim_account_get_bool(gc->account,"read_anyone",TRUE); |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1475 read_zsubs = gaim_account_get_bool(gc->account,"read_zsubs",TRUE); |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1476 exposure = (gchar *)gaim_account_get_string(gc->account, "exposure_level", EXPOSE_REALMVIS); |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1477 |
| 9610 | 1478 gc->flags |= GAIM_CONNECTION_HTML | GAIM_CONNECTION_NO_BGCOLOR | GAIM_CONNECTION_NO_URLDESC; |
| 9896 | 1479 gc->proto_data = zephyr=g_new0(zephyr_account,1); |
|
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1480 |
| 9896 | 1481 zephyr->account = account; |
|
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1482 |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1483 /* Make sure that the exposure (visibility) is set to a sane value */ |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1484 zephyr->exposure=g_strdup(normalize_zephyr_exposure(exposure)); |
| 2086 | 1485 |
| 9896 | 1486 if (gaim_account_get_bool(gc->account,"use_tzc",0)) { |
| 1487 zephyr->connection_type = GAIM_ZEPHYR_TZC; | |
| 1488 } else { | |
| 1489 zephyr->connection_type = GAIM_ZEPHYR_KRB4; | |
| 1490 } | |
| 1491 | |
| 1492 zephyr->encoding = (char *)gaim_account_get_string(gc->account, "encoding", ZEPHYR_FALLBACK_CHARSET); | |
| 9610 | 1493 gaim_connection_update_progress(gc, _("Connecting"), 0, 8); |
| 9478 | 1494 |
| 1495 /* XXX z_call_s should actually try to report the com_err determined error */ | |
| 9896 | 1496 if (use_tzc(zephyr)) { |
| 1497 pid_t pid; | |
| 1498 /* gaim_connection_error(gc,"tzc not supported yet"); */ | |
| 1499 if ((pipe(zephyr->totzc) != 0) || (pipe(zephyr->fromtzc) != 0)) { | |
| 1500 gaim_debug_error("zephyr", "pipe creation failed. killing\n"); | |
| 1501 exit(-1); | |
| 1502 } | |
| 1503 | |
| 1504 pid = fork(); | |
| 1505 | |
| 1506 if (pid == -1) { | |
| 1507 gaim_debug_error("zephyr", "forking failed\n"); | |
| 1508 exit(-1); | |
| 1509 } | |
| 1510 if (pid == 0) { | |
| 1511 unsigned int i=0; | |
| 1512 gboolean found_ps = FALSE; | |
| 1513 gchar ** tzc_cmd_array = g_strsplit(gaim_account_get_string(gc->account,"tzc_command","/usr/bin/tzc -e %s")," ",0); | |
| 1514 if (close(1) == -1) { | |
| 1515 gaim_debug_error("zephyr", "stdout couldn't be closed. dying\n"); | |
| 1516 exit(-1); | |
| 1517 } | |
| 1518 if (dup2(zephyr->fromtzc[1], 1) == -1) { | |
| 1519 gaim_debug_error("zephyr", "dup2 of stdout failed \n"); | |
| 1520 exit(-1); | |
| 1521 } | |
| 1522 if (close(zephyr->fromtzc[1]) == -1) { | |
| 1523 gaim_debug_error("zephyr", "closing of piped stdout failed\n"); | |
| 1524 exit(-1); | |
| 1525 } | |
| 1526 if (close(0) == -1) { | |
| 1527 gaim_debug_error("zephyr", "stdin couldn't be closed. dying\n"); | |
| 1528 exit(-1); | |
| 1529 } | |
| 1530 if (dup2(zephyr->totzc[0], 0) == -1) { | |
| 1531 gaim_debug_error("zephyr", "dup2 of stdin failed \n"); | |
| 1532 exit(-1); | |
| 1533 } | |
| 1534 if (close(zephyr->totzc[0]) == -1) { | |
| 1535 gaim_debug_error("zephyr", "closing of piped stdin failed\n"); | |
| 1536 exit(-1); | |
| 1537 } | |
| 1538 /* tzc_command should really be of the form | |
| 1539 path/to/tzc -e %s | |
| 1540 or | |
| 1541 ssh username@hostname pathtotzc -e %s | |
| 1542 -- this should not require a password, and ideally should be kerberized ssh -- | |
| 1543 or | |
| 1544 fsh username@hostname pathtotzc -e %s | |
| 1545 */ | |
| 1546 while(tzc_cmd_array[i] != NULL){ | |
| 1547 if (!g_strncasecmp(tzc_cmd_array[i],"%s",2)) { | |
| 9986 | 1548 /* fprintf(stderr,"replacing %%s with %s\n",zephyr->exposure); */ |
| 9896 | 1549 tzc_cmd_array[i] = g_strdup(zephyr->exposure); |
| 1550 found_ps = TRUE; | |
| 1551 | |
| 1552 } else { | |
| 9986 | 1553 /* fprintf(stderr,"keeping %s\n",tzc_cmd_array[i]); */ |
| 9896 | 1554 } |
| 1555 i++; | |
| 1556 } | |
| 8645 | 1557 |
| 9896 | 1558 if (!found_ps) { |
| 1559 gaim_connection_error(gc,"Tzc command needs %s to set the exposure\n"); | |
| 1560 return; | |
| 1561 } | |
| 1562 | |
| 1563 execvp(tzc_cmd_array[0], tzc_cmd_array); | |
| 1564 } | |
| 1565 else { | |
| 1566 fd_set rfds; | |
| 1567 int bufsize = 2048; | |
| 1568 char *buf = (char *)calloc(bufsize, 1); | |
| 1569 char *bufcur = buf; | |
| 1570 struct timeval tv; | |
| 1571 char *ptr; | |
| 1572 int parenlevel=0; | |
| 1573 char* tempstr; | |
| 1574 int tempstridx; | |
| 1575 | |
| 9986 | 1576 zephyr->tzc_pid = pid; |
| 9896 | 1577 /* wait till we have data to read from ssh */ |
| 1578 FD_ZERO(&rfds); | |
| 1579 FD_SET(zephyr->fromtzc[ZEPHYR_FD_READ], &rfds); | |
| 1580 | |
| 1581 tv.tv_sec = 10; | |
| 1582 tv.tv_usec = 0; | |
| 1583 | |
| 1584 gaim_debug_info("zephyr", "about to read from tzc\n"); | |
| 1585 | |
| 1586 select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, NULL); | |
| 1587 | |
| 1588 FD_ZERO(&rfds); | |
| 1589 FD_SET(zephyr->fromtzc[ZEPHYR_FD_READ], &rfds); | |
| 1590 while (select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, &tv)) { | |
| 1591 read(zephyr->fromtzc[ZEPHYR_FD_READ], bufcur, 1); | |
| 1592 bufcur++; | |
| 1593 if ((bufcur - buf) > (bufsize - 1)) { | |
| 1594 if ((buf = realloc(buf, bufsize * 2)) == NULL) { | |
| 1595 exit(-1); | |
| 1596 } else { | |
| 1597 bufcur = buf + bufsize; | |
| 1598 bufsize *= 2; | |
| 1599 } | |
| 1600 } | |
| 1601 FD_ZERO(&rfds); | |
| 1602 FD_SET(zephyr->fromtzc[ZEPHYR_FD_READ], &rfds); | |
| 1603 tv.tv_sec = 10; | |
| 1604 tv.tv_usec = 0; | |
| 2086 | 1605 |
| 9896 | 1606 } |
| 9986 | 1607 /* fprintf(stderr, "read from tzc\n"); */ |
| 9896 | 1608 *bufcur = '\0'; |
| 1609 ptr = buf; | |
| 1610 | |
| 1611 /* ignore all tzcoutput till we've received the first (*/ | |
| 1612 while (ptr < bufcur && (*ptr !='(')) { | |
| 1613 ptr++; | |
| 1614 } | |
| 1615 if (ptr >=bufcur) { | |
| 1616 gaim_connection_error(gc,"invalid output by tzc (or bad parsing code)"); | |
| 1617 return; | |
| 1618 } | |
| 9427 | 1619 |
| 9896 | 1620 while(ptr < bufcur) { |
| 1621 if (*ptr == '(') { | |
| 1622 parenlevel++; | |
| 1623 } | |
| 1624 else if (*ptr == ')') { | |
| 1625 parenlevel--; | |
| 1626 } | |
| 1627 gaim_debug_info("zephyr","tzc parenlevel is %d\n",parenlevel); | |
| 1628 switch (parenlevel) { | |
| 1629 case 0: | |
| 1630 break; | |
| 1631 case 1: | |
| 1632 /* Search for next beginning (, or for the ending */ | |
| 1633 ptr++; | |
| 1634 while((*ptr != '(') && (*ptr != ')') && (ptr <bufcur)) | |
| 1635 ptr++; | |
| 1636 if (ptr >= bufcur) | |
| 1637 gaim_debug_error("zephyr","tzc parsing error\n"); | |
| 1638 break; | |
| 1639 case 2: | |
| 1640 /* You are probably at | |
| 1641 (foo . bar ) or (foo . "bar") or (foo . chars) or (foo . numbers) or (foo . () ) | |
| 1642 Parse all the data between the first and last f, and move past ) | |
| 1643 */ | |
| 1644 tempstr = g_malloc0(20000); | |
| 1645 tempstridx=0; | |
| 1646 while(parenlevel >1) { | |
| 1647 ptr++; | |
| 1648 if (*ptr == '(') | |
| 1649 parenlevel++; | |
| 1650 if (*ptr == ')') | |
| 1651 parenlevel--; | |
| 1652 if (parenlevel > 1) { | |
| 1653 tempstr[tempstridx++]=*ptr; | |
| 1654 } else { | |
| 1655 ptr++; | |
| 1656 } | |
| 1657 } | |
| 1658 gaim_debug_info("zephyr","tempstr parsed\n"); | |
| 1659 /* tempstr should now be a tempstridx length string containing all characters | |
| 1660 from that after the first ( to the one before the last paren ). */ | |
| 1661 /* We should have the following possible lisp strings but we don't care | |
| 1662 (tzcspew . start) (version . "something") (pid . number)*/ | |
| 1663 /* We care about 'zephyrid . "username@REALM.NAME"' and 'exposure . "SOMETHING"' */ | |
| 1664 tempstridx=0; | |
| 1665 if (!g_ascii_strncasecmp(tempstr,"zephyrid",8)) { | |
| 1666 gchar* username = g_malloc0(100); | |
| 1667 int username_idx=0; | |
| 1668 char *realm; | |
| 1669 gaim_debug_info("zephyr","zephyrid found\n"); | |
| 1670 tempstridx+=8; | |
| 1671 while(tempstr[tempstridx] !='"' && tempstridx < 20000) | |
| 1672 tempstridx++; | |
| 1673 tempstridx++; | |
| 1674 while(tempstr[tempstridx] !='"' && tempstridx < 20000) | |
| 1675 username[username_idx++]=tempstr[tempstridx++]; | |
| 1676 | |
| 1677 zephyr->username = g_strdup_printf("%s",username); | |
| 1678 if ((realm = strchr(username,'@'))) | |
| 1679 zephyr->realm = g_strdup_printf("%s",realm+1); | |
|
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1680 else { |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1681 realm = (gchar *)gaim_account_get_string(gc->account,"realm",""); |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1682 if (!g_strcasecmp(realm,"")) { |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1683 realm = "local-realm"; |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1684 } |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1685 zephyr->realm = g_strdup(realm); |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1686 g_strlcpy(__Zephyr_realm, (const char*)zephyr->realm, REALM_SZ-1); |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1687 } |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1688 /* else { |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1689 zephyr->realm = g_strdup("local-realm"); |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1690 }*/ |
| 9896 | 1691 |
| 1692 g_free(username); | |
| 1693 } else { | |
| 1694 gaim_debug_info("zephyr", "something that's not zephyr id found %s\n",tempstr); | |
| 1695 } | |
| 1696 | |
| 1697 /* We don't care about anything else yet */ | |
| 1698 g_free(tempstr); | |
| 1699 break; | |
| 1700 default: | |
| 1701 gaim_debug_info("zephyr","parenlevel is not 1 or 2\n"); | |
| 1702 /* This shouldn't be happening */ | |
| 1703 break; | |
| 1704 } | |
| 1705 if (parenlevel==0) | |
| 1706 break; | |
| 1707 } /* while (ptr < bufcur) { */ | |
| 1708 gaim_debug_info("zephyr", "tzc startup done\n"); | |
| 1709 } | |
| 1710 } | |
| 1711 else if ( use_zeph02(zephyr)) { | |
|
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1712 gchar* realm; |
| 9896 | 1713 z_call_s(ZInitialize(), "Couldn't initialize zephyr"); |
| 1714 z_call_s(ZOpenPort(&(zephyr->port)), "Couldn't open port"); | |
| 1715 z_call_s(ZSetLocation((char *)zephyr->exposure), "Couldn't set location"); | |
|
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1716 |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1717 realm = (gchar *)gaim_account_get_string(gc->account,"realm",""); |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1718 if (!g_strcasecmp(realm,"")) { |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1719 realm = ZGetRealm(); |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1720 } |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1721 zephyr->realm = g_strdup(realm); |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1722 g_strlcpy(__Zephyr_realm, (const char*)zephyr->realm, REALM_SZ-1); |
| 9896 | 1723 zephyr->username = g_strdup(ZGetSender()); |
|
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1724 |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1725 /* zephyr->realm = g_strdup(ZGetRealm()); */ |
| 9896 | 1726 gaim_debug_info("zephyr","realm: %s\n",zephyr->realm); |
| 1727 } | |
| 1728 else { | |
| 1729 gaim_connection_error(gc,"Only ZEPH0.2 supported currently"); | |
| 1730 return; | |
| 1731 } | |
| 1732 gaim_debug_info("zephyr","does it get here\n"); | |
| 1733 gaim_debug_info("zephyr"," realm: %s username:%s\n", zephyr->realm, zephyr->username); | |
| 1734 | |
| 1735 /* For now */ | |
| 1736 zephyr->galaxy = NULL; | |
| 1737 zephyr->krbtkfile = NULL; | |
| 1738 zephyr_inithosts(zephyr); | |
| 1739 | |
| 1740 if (zephyr_subscribe_to(zephyr,"MESSAGE","PERSONAL",zephyr->username,NULL) != ZERR_NONE) { | |
| 9478 | 1741 /* XXX don't translate this yet. It could be written better */ |
| 1742 /* XXX error messages could be handled with more detail */ | |
| 1743 gaim_notify_error(account->gc, NULL, | |
| 1744 "Unable to subscribe to messages", "Unable to subscribe to initial messages"); | |
| 1745 return; | |
| 2086 | 1746 } |
| 1747 | |
| 9610 | 1748 gaim_connection_set_state(gc, GAIM_CONNECTED); |
|
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1749 |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1750 if (read_anyone) |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1751 process_anyone(gc); |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1752 if (read_zsubs) |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1753 process_zsubs(zephyr); |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1754 |
| 9610 | 1755 serv_finish_login(gc); |
| 2086 | 1756 |
| 9896 | 1757 if (use_zeph02(zephyr)) { |
| 1758 zephyr->nottimer = gaim_timeout_add(100, check_notify_zeph02, gc); | |
| 1759 } else if (use_tzc(zephyr)) { | |
| 1760 zephyr->nottimer = gaim_timeout_add(100, check_notify_tzc, gc); | |
| 1761 } | |
| 1762 zephyr->loctimer = gaim_timeout_add(20000, check_loc, gc); | |
| 2086 | 1763 |
| 1764 } | |
| 1765 | |
| 9610 | 1766 static void write_zsubs(zephyr_account *zephyr) |
| 2086 | 1767 { |
| 9896 | 1768 /* Exports subscription (chat) list back to |
| 1769 * .zephyr.subs | |
| 1770 * XXX deal with %host%, %canon%, unsubscriptions, and negative subscriptions (punts?) | |
| 1771 */ | |
| 9434 | 1772 |
| 9610 | 1773 GSList *s = zephyr->subscrips; |
| 2086 | 1774 zephyr_triple *zt; |
| 1775 FILE *fd; | |
| 1776 char *fname; | |
| 1777 | |
| 8644 | 1778 char **triple; |
| 1779 | |
| 3630 | 1780 fname = g_strdup_printf("%s/.zephyr.subs", gaim_home_dir()); |
| 2086 | 1781 fd = fopen(fname, "w"); |
| 8644 | 1782 |
| 2086 | 1783 if (!fd) { |
| 1784 g_free(fname); | |
| 1785 return; | |
| 1786 } | |
| 8644 | 1787 |
| 2086 | 1788 while (s) { |
| 9478 | 1789 char *zclass, *zinst, *zrecip; |
| 2086 | 1790 zt = s->data; |
| 8644 | 1791 triple = g_strsplit(zt->name, ",", 3); |
| 9478 | 1792 |
| 1793 /* deal with classes */ | |
| 9610 | 1794 if (!g_ascii_strcasecmp(triple[0],zephyr->ourhost)) { |
| 9775 | 1795 zclass = g_strdup("%host%"); |
| 9610 | 1796 } else if (!g_ascii_strcasecmp(triple[0],zephyr->ourhostcanon)) { |
| 9775 | 1797 zclass = g_strdup("%canon%"); |
| 9478 | 1798 } else { |
| 1799 zclass = g_strdup(triple[0]); | |
| 1800 } | |
| 1801 | |
| 1802 /* deal with instances */ | |
| 1803 | |
| 9610 | 1804 if (!g_ascii_strcasecmp(triple[1],zephyr->ourhost)) { |
| 9775 | 1805 zinst = g_strdup("%host%"); |
| 9610 | 1806 } else if (!g_ascii_strcasecmp(triple[1],zephyr->ourhostcanon)) { |
| 9896 | 1807 zinst = g_strdup("%canon%");; |
| 1808 } else { | |
| 9478 | 1809 zinst = g_strdup(triple[1]); |
| 9896 | 1810 } |
| 9478 | 1811 |
| 1812 /* deal with recipients */ | |
| 1813 if (triple[2] == NULL) { | |
| 1814 zrecip = g_strdup("*"); | |
| 1815 } else if (!g_ascii_strcasecmp(triple[2],"")){ | |
| 1816 zrecip = g_strdup("*"); | |
| 9896 | 1817 } else if (!g_ascii_strcasecmp(triple[2], zephyr->username)) { |
| 9478 | 1818 zrecip = g_strdup("%me%"); |
| 3277 | 1819 } else { |
| 9478 | 1820 zrecip = g_strdup(triple[2]); |
| 3277 | 1821 } |
| 9478 | 1822 |
| 1823 fprintf(fd, "%s,%s,%s\n",zclass,zinst,zrecip); | |
| 1824 | |
| 1825 g_free(zclass); | |
| 1826 g_free(zinst); | |
| 1827 g_free(zrecip); | |
| 3277 | 1828 g_free(triple); |
| 2086 | 1829 s = s->next; |
| 1830 } | |
| 1831 g_free(fname); | |
| 1832 fclose(fd); | |
| 1833 } | |
| 1834 | |
| 9610 | 1835 static void write_anyone(GaimConnection *gc) |
| 2086 | 1836 { |
| 6695 | 1837 GaimBlistNode *gnode, *cnode, *bnode; |
| 1838 GaimBuddy *b; | |
| 9912 | 1839 char *fname; |
| 2086 | 1840 FILE *fd; |
| 9896 | 1841 zephyr_account* zephyr = gc->proto_data; |
| 3630 | 1842 fname = g_strdup_printf("%s/.anyone", gaim_home_dir()); |
| 2086 | 1843 fd = fopen(fname, "w"); |
| 1844 if (!fd) { | |
| 1845 g_free(fname); | |
| 1846 return; | |
| 1847 } | |
| 1848 | |
| 8644 | 1849 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
| 1850 if (!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
| 4785 | 1851 continue; |
| 8644 | 1852 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
| 1853 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
| 4785 | 1854 continue; |
| 8644 | 1855 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
| 1856 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
| 6695 | 1857 continue; |
| 8644 | 1858 b = (GaimBuddy *) bnode; |
| 9610 | 1859 if (b->account == gc->account) { |
| 9986 | 1860 gchar *stripped_user = zephyr_strip_local_realm(zephyr,b->name); |
| 9912 | 1861 fprintf(fd, "%s\n", stripped_user); |
| 9986 | 1862 g_free(stripped_user); |
| 3277 | 1863 } |
| 1864 } | |
| 2086 | 1865 } |
| 1866 } | |
| 1867 | |
| 1868 fclose(fd); | |
| 1869 g_free(fname); | |
| 1870 } | |
| 1871 | |
| 8644 | 1872 static void zephyr_close(GaimConnection * gc) |
| 2086 | 1873 { |
| 1874 GList *l; | |
| 1875 GSList *s; | |
| 9896 | 1876 zephyr_account *zephyr = gc->proto_data; |
| 9986 | 1877 pid_t tzc_pid = zephyr->tzc_pid; |
| 8644 | 1878 |
| 9610 | 1879 l = zephyr->pending_zloc_names; |
| 2086 | 1880 while (l) { |
| 8644 | 1881 g_free((char *)l->data); |
| 2086 | 1882 l = l->next; |
| 1883 } | |
| 9610 | 1884 g_list_free(zephyr->pending_zloc_names); |
| 8644 | 1885 |
| 9610 | 1886 if (gaim_account_get_bool(gc->account, "write_anyone", FALSE)) |
| 1887 write_anyone(gc); | |
| 8644 | 1888 |
| 9610 | 1889 if (gaim_account_get_bool(gc->account, "write_zsubs", FALSE)) |
| 1890 write_zsubs(gc->proto_data); | |
| 8644 | 1891 |
| 9610 | 1892 s = zephyr->subscrips; |
| 2086 | 1893 while (s) { |
| 8644 | 1894 free_triple((zephyr_triple *) s->data); |
| 2086 | 1895 s = s->next; |
| 1896 } | |
| 9610 | 1897 g_slist_free(zephyr->subscrips); |
| 8644 | 1898 |
| 9610 | 1899 if (zephyr->nottimer) |
| 1900 gaim_timeout_remove(zephyr->nottimer); | |
| 1901 zephyr->nottimer = 0; | |
| 1902 if (zephyr->loctimer) | |
| 1903 gaim_timeout_remove(zephyr->loctimer); | |
| 1904 zephyr->loctimer = 0; | |
| 1905 gc = NULL; | |
| 9896 | 1906 if (use_zeph02(zephyr)) { |
| 1907 z_call(ZCancelSubscriptions(0)); | |
| 1908 z_call(ZUnsetLocation()); | |
| 1909 z_call(ZClosePort()); | |
| 1910 } else { | |
| 1911 /* assume tzc */ | |
| 9986 | 1912 if (kill(tzc_pid,SIGTERM) == -1) { |
| 1913 int err=errno; | |
| 1914 if (err==EINVAL) { | |
| 1915 gaim_debug_error("zephyr","An invalid signal was specified when killing tzc\n"); | |
| 1916 } | |
| 1917 else if (err==ESRCH) { | |
| 1918 gaim_debug_error("zephyr","Tzc's pid didn't exist while killing tzc\n"); | |
| 1919 } | |
| 1920 else if (err==EPERM) { | |
| 1921 gaim_debug_error("zephyr","gaim didn't have permission to kill tzc\n"); | |
| 1922 } | |
| 1923 else { | |
| 1924 gaim_debug_error("zephyr","miscellaneous error while attempting to close tzc\n"); | |
| 1925 } | |
| 1926 } | |
| 9896 | 1927 } |
| 2086 | 1928 } |
| 1929 | |
| 9896 | 1930 static int zephyr_send_message(zephyr_account *zephyr,char* zclass, char* instance, char* recipient, const char *im, |
| 9478 | 1931 const char *sig, char *opcode) ; |
| 9434 | 1932 |
| 1933 const char * zephyr_get_signature() | |
| 1934 { | |
| 9478 | 1935 /* XXX add zephyr error reporting */ |
| 1936 const char * sig =ZGetVariable("zwrite-signature"); | |
| 9896 | 1937 if (!sig) { |
| 1938 sig = g_get_real_name(); | |
| 1939 } | |
| 1940 return sig; | |
| 9434 | 1941 } |
| 1942 | |
| 8644 | 1943 static int zephyr_chat_send(GaimConnection * gc, int id, const char *im) |
| 2086 | 1944 { |
| 1945 zephyr_triple *zt; | |
| 1946 const char *sig; | |
| 8644 | 1947 GaimConversation *gconv1; |
| 1948 GaimConvChat *gcc; | |
| 1949 char *inst; | |
| 9896 | 1950 char *recipient; |
| 1951 zephyr_account *zephyr = gc->proto_data; | |
| 2086 | 1952 |
| 9610 | 1953 zt = find_sub_by_id(gc->proto_data,id); |
| 2086 | 1954 if (!zt) |
| 1955 /* this should never happen. */ | |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1956 return -EINVAL; |
| 8644 | 1957 |
| 9896 | 1958 sig = zephyr_get_signature(); |
| 2086 | 1959 |
| 10246 | 1960 gconv1 = gaim_find_conversation_with_account(GAIM_CONV_CHAT, zt->name, |
| 1961 gc->account); | |
| 8644 | 1962 gcc = gaim_conversation_get_chat_data(gconv1); |
| 8212 | 1963 |
| 8644 | 1964 if (!(inst = (char *)gaim_conv_chat_get_topic(gcc))) |
| 9434 | 1965 inst = g_strdup("PERSONAL"); |
| 8644 | 1966 |
| 4793 | 1967 if (!g_ascii_strcasecmp(zt->recipient, "*")) |
| 9896 | 1968 recipient = local_zephyr_normalize(zephyr,""); |
| 2086 | 1969 else |
| 9896 | 1970 recipient = local_zephyr_normalize(zephyr,zt->recipient); |
| 8451 | 1971 |
| 9896 | 1972 zephyr_send_message(zephyr,zt->class,inst,recipient,im,sig,""); |
|
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
1973 return 0; |
| 2086 | 1974 } |
| 1975 | |
| 9434 | 1976 |
| 8644 | 1977 static int zephyr_send_im(GaimConnection * gc, const char *who, const char *im, GaimConvImFlags flags) |
| 1978 { | |
| 2086 | 1979 const char *sig; |
| 9896 | 1980 zephyr_account *zephyr = gc->proto_data; |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7084
diff
changeset
|
1981 if (flags & GAIM_CONV_IM_AUTO_RESP) |
| 2086 | 1982 sig = "Automated reply:"; |
| 1983 else { | |
| 9434 | 1984 sig = zephyr_get_signature(); |
| 2086 | 1985 } |
| 9896 | 1986 zephyr_send_message(zephyr,"MESSAGE","PERSONAL",local_zephyr_normalize(zephyr,who),im,sig,""); |
| 9434 | 1987 |
| 1988 return 1; | |
| 1989 } | |
| 2086 | 1990 |
| 9896 | 1991 /* Munge the outgoing zephyr so that any quotes or backslashes are |
| 1992 escaped and do not confuse tzc: */ | |
| 1993 | |
| 1994 char* zephyr_tzc_escape_msg(const char *message) | |
| 1995 { | |
| 1996 int pos = 0; | |
| 1997 int pos2 = 0; | |
| 1998 char *newmsg; | |
| 1999 | |
| 2000 if (message && (strlen(message) > 0)) { | |
| 2001 newmsg = g_new0(char,1+strlen(message)*2); | |
| 2002 while(pos < strlen(message)) { | |
| 2003 if (message[pos]=='\\') { | |
| 2004 newmsg[pos2]='\\'; | |
| 2005 newmsg[pos2+1]='\\'; | |
| 2006 pos2+=2; | |
| 2007 } | |
| 2008 else if (message[pos]=='"') { | |
| 2009 newmsg[pos2]='\\'; | |
| 2010 newmsg[pos2+1]='"'; | |
| 2011 pos2+=2; | |
| 2012 } | |
| 2013 else { | |
| 2014 newmsg[pos2] = message[pos]; | |
| 2015 pos2++; | |
| 2016 } | |
| 2017 pos++; | |
| 2018 } | |
| 2019 } else { | |
| 2020 newmsg = g_strdup(""); | |
| 2021 } | |
| 9986 | 2022 /* fprintf(stderr,"newmsg %s message %s\n",newmsg,message); */ |
| 9896 | 2023 return newmsg; |
| 2024 } | |
| 2025 | |
| 2026 char* zephyr_tzc_deescape_str(const char *message) | |
| 2027 { | |
| 2028 int pos = 0; | |
| 2029 int pos2 = 0; | |
| 2030 char *newmsg; | |
| 2031 | |
| 2032 if (message && (strlen(message) > 0)) { | |
| 2033 newmsg = g_new0(char,strlen(message)+1); | |
| 2034 while(pos < strlen(message)) { | |
| 2035 if (message[pos]=='\\') { | |
| 2036 pos++; | |
| 2037 } | |
| 2038 newmsg[pos2] = message[pos]; | |
| 2039 pos++;pos2++; | |
| 2040 } | |
| 2041 newmsg[pos2]='\0'; | |
| 2042 } else { | |
| 2043 newmsg = g_strdup(""); | |
| 2044 } | |
| 2045 | |
| 2046 return newmsg; | |
| 2047 } | |
| 2048 | |
| 2049 static int zephyr_send_message(zephyr_account *zephyr,char* zclass, char* instance, char* recipient, const char *im, | |
| 9478 | 2050 const char *sig, char *opcode) |
| 9434 | 2051 { |
| 8451 | 2052 |
| 9896 | 2053 /* (From the tzc source) |
| 2054 * emacs sends something of the form: | |
| 2055 * ((class . "MESSAGE") | |
| 2056 * (auth . t) | |
| 2057 * (recipients ("PERSONAL" . "bovik") ("test" . "")) | |
| 2058 * (sender . "bovik") | |
| 2059 * (message . ("Harry Bovik" "my zgram")) | |
| 2060 * ) | |
| 2061 */ | |
| 2062 char *html_buf; | |
| 2063 char *html_buf2; | |
| 2064 html_buf = html_to_zephyr(im); | |
| 2065 html_buf2 = gaim_unescape_html(html_buf); | |
| 9434 | 2066 |
| 9896 | 2067 if(use_tzc(zephyr)) { |
| 2068 char* zsendstr; | |
| 2069 /* CMU cclub tzc doesn't grok opcodes for now */ | |
| 2070 char* tzc_sig = zephyr_tzc_escape_msg(sig); | |
| 2071 char *tzc_body = zephyr_tzc_escape_msg(html_buf2); | |
| 2072 zsendstr = g_strdup_printf("((tzcfodder . send) (class . \"%s\") (auth . t) (recipients (\"%s\" . \"%s\")) (message . (\"%s\" \"%s\")) ) \n", | |
| 9986 | 2073 zclass, instance, recipient, tzc_sig, tzc_body); |
| 2074 /* fprintf(stderr,"zsendstr = %s\n",zsendstr); */ | |
| 9896 | 2075 write(zephyr->totzc[ZEPHYR_FD_WRITE],zsendstr,strlen(zsendstr)); |
| 2076 g_free(zsendstr); | |
| 2077 } else if (use_zeph02(zephyr)) { | |
| 2078 ZNotice_t notice; | |
| 2079 char *buf = g_strdup_printf("%s%c%s", sig, '\0', html_buf2); | |
| 2080 bzero((char *)¬ice, sizeof(notice)); | |
| 2081 | |
| 2082 notice.z_kind = ACKED; | |
| 2083 notice.z_port = 0; | |
| 2084 notice.z_opcode = ""; | |
| 2085 notice.z_class = zclass; | |
| 2086 notice.z_class_inst = instance; | |
| 2087 notice.z_recipient = recipient; | |
| 2088 notice.z_sender = 0; | |
| 2089 notice.z_default_format = "Class $class, Instance $instance:\n" "To: @bold($recipient) at $time $date\n" "From: @bold($1) <$sender>\n\n$2"; | |
| 2090 notice.z_message_len = strlen(html_buf2) + strlen(sig) + 2; | |
| 2091 notice.z_message = buf; | |
| 2092 notice.z_opcode = g_strdup(opcode); | |
| 2093 gaim_debug_info("zephyr","About to send notice"); | |
| 2094 if (! ZSendNotice(¬ice, ZAUTH) == ZERR_NONE) { | |
| 2095 /* XXX handle errors here */ | |
| 2096 return 0; | |
| 2097 } | |
| 2098 gaim_debug_info("zephyr","notice sent"); | |
| 2099 g_free(buf); | |
| 9478 | 2100 } |
| 2101 | |
| 8644 | 2102 g_free(html_buf2); |
| 2103 g_free(html_buf); | |
| 8451 | 2104 |
| 9896 | 2105 return 1; |
| 2086 | 2106 } |
| 2107 | |
| 8644 | 2108 static const char *zephyr_normalize(const GaimAccount * account, const char *orig) |
| 2086 | 2109 { |
| 9328 | 2110 /* returns the string you gave it. Maybe this function shouldn't be here */ |
| 9896 | 2111 char * buf = g_malloc0(80); |
| 2112 /* gaim_debug_error("zephyr","entering zephyr_normalize\n"); */ | |
| 8644 | 2113 |
| 7126 | 2114 if (!g_ascii_strcasecmp(orig, "")) { |
| 2115 buf[0] = '\0'; | |
| 2116 return buf; | |
| 8354 | 2117 } else { |
| 8644 | 2118 g_snprintf(buf, 80, "%s", orig); |
| 2119 } | |
| 9896 | 2120 /* gaim_debug_error("zephyr","leaving zephyr_normalize\n"); */ |
| 2121 | |
| 8644 | 2122 return buf; |
| 8354 | 2123 } |
| 2124 | |
| 2125 | |
| 9896 | 2126 char *local_zephyr_normalize(zephyr_account *zephyr,const char *orig) |
| 8354 | 2127 { |
| 9328 | 2128 /* |
| 9912 | 2129 Basically the inverse of zephyr_strip_local_realm |
| 9896 | 2130 */ |
| 2131 char* buf; | |
| 2132 | |
| 8354 | 2133 if (!g_ascii_strcasecmp(orig, "")) { |
| 9896 | 2134 return g_strdup(""); |
| 7126 | 2135 } |
| 8644 | 2136 |
| 9896 | 2137 if (strchr(orig,'@')) { |
| 2138 buf = g_strdup_printf("%s",orig); | |
| 2086 | 2139 } else { |
| 9896 | 2140 buf = g_strdup_printf("%s@%s",orig,zephyr->realm); |
| 2141 } | |
| 2086 | 2142 return buf; |
| 2143 } | |
| 2144 | |
| 9030 | 2145 static void zephyr_zloc(GaimConnection *gc, const char *who) |
| 2086 | 2146 { |
| 2147 ZAsyncLocateData_t ald; | |
| 9896 | 2148 zephyr_account *zephyr = gc->proto_data; |
| 2149 gchar* normalized_who = local_zephyr_normalize(zephyr,who); | |
| 2150 | |
| 2151 if (use_zeph02(zephyr)) { | |
| 2152 if (ZRequestLocations(normalized_who, &ald, UNACKED, ZAUTH) == ZERR_NONE) { | |
| 2153 zephyr->pending_zloc_names = g_list_append(zephyr->pending_zloc_names, | |
| 2154 g_strdup(normalized_who)); | |
| 2155 } else { | |
| 2156 /* XXX deal with errors somehow */ | |
| 2157 } | |
| 2158 } else if (use_tzc(zephyr)) { | |
| 2159 char* zlocstr = g_strdup_printf("((tzcfodder . zlocate) \"%s\")\n",normalized_who); | |
| 2160 zephyr->pending_zloc_names = g_list_append(zephyr->pending_zloc_names, g_strdup(normalized_who)); | |
| 2161 write(zephyr->totzc[ZEPHYR_FD_WRITE],zlocstr,strlen(zlocstr)); | |
| 2162 g_free(zlocstr); | |
| 2086 | 2163 } |
| 2164 } | |
| 2165 | |
| 9986 | 2166 static void zephyr_set_status(GaimAccount *account, GaimStatus *status) { |
| 2167 zephyr_account *zephyr = gaim_account_get_connection(account)->proto_data; | |
| 2168 const char *status_id = gaim_status_get_id(status); | |
| 2169 | |
| 2170 if (zephyr->away) { | |
| 2171 g_free(zephyr->away); | |
| 2172 zephyr->away=NULL; | |
|
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
2173 } |
|
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
2174 |
| 9986 | 2175 if (!strcmp(status_id,"away")) { |
| 2176 zephyr->away = g_strdup(gaim_status_get_attr_string(status,"message")); | |
| 2177 } | |
| 2178 else if (!strcmp(status_id,"online")) { | |
| 2179 if (use_zeph02(zephyr)) { | |
|
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2180 ZSetLocation(zephyr->exposure); |
| 9986 | 2181 } |
| 2182 else { | |
| 2183 char *zexpstr = g_strdup_printf("((tzcfodder . set-location) (hostname . \"%s\") (exposure . \"%s\"))\n",zephyr->ourhost,zephyr->exposure); | |
| 2184 write(zephyr->totzc[ZEPHYR_FD_WRITE],zexpstr,strlen(zexpstr)); | |
| 2185 g_free(zexpstr); | |
| 2186 } | |
| 2187 } | |
| 2188 else if (!strcmp(status_id,"hidden")) { | |
| 9478 | 2189 /* XXX handle errors */ |
| 9896 | 2190 if (use_zeph02(zephyr)) { |
| 2191 ZSetLocation(EXPOSE_OPSTAFF); | |
| 2192 } else { | |
| 2193 char *zexpstr = g_strdup_printf("((tzcfodder . set-location) (hostname . \"%s\") (exposure . \"%s\"))\n",zephyr->ourhost,EXPOSE_OPSTAFF); | |
| 2194 write(zephyr->totzc[ZEPHYR_FD_WRITE],zexpstr,strlen(zexpstr)); | |
| 2195 g_free(zexpstr); | |
| 2196 } | |
| 9478 | 2197 } |
| 2086 | 2198 } |
| 2199 | |
| 9986 | 2200 static GList *zephyr_status_types(GaimAccount *account) |
| 2086 | 2201 { |
| 9986 | 2202 GaimStatusType *type; |
| 2203 GList *types = NULL; | |
| 2204 | |
| 2205 /* zephyr has several exposures | |
| 2206 NONE (where you are hidden, and zephyrs to you are in practice silently dropped -- yes this is wrong) | |
| 2207 OPSTAFF "hidden" | |
| 2208 REALM-VISIBLE visible to people in local realm | |
| 2209 REALM-ANNOUNCED REALM-VISIBLE+ plus your logins/logouts are announced to <login,username,*> | |
| 2210 NET-VISIBLE REALM-ANNOUNCED, plus visible to people in foreign realm | |
| 2211 NET-ANNOUNCED NET-VISIBLE, plus logins/logouts are announced to <login,username,*> | |
| 2212 | |
| 2213 Online will set the user to the exposure they have in their options (defaulting to REALM-VISIBLE), | |
| 2214 Hidden, will set the user's exposure to OPSTAFF | |
| 2086 | 2215 |
| 9986 | 2216 Away won't change their exposure but will set an auto away message (for IMs only) |
| 2217 */ | |
| 2218 | |
| 2219 type = gaim_status_type_new(GAIM_STATUS_ONLINE, "online", _("Online"), FALSE); | |
| 2220 types = g_list_append(types,type); | |
| 2086 | 2221 |
| 9986 | 2222 type = gaim_status_type_new(GAIM_STATUS_HIDDEN, "hidden", _("Hidden"), FALSE); |
| 2223 types = g_list_append(types,type); | |
| 2224 | |
| 2225 type = gaim_status_type_new_with_attrs( | |
| 2226 GAIM_STATUS_AWAY, "away", _("Away"), TRUE, TRUE, FALSE, | |
| 10009 | 2227 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), NULL); |
| 9986 | 2228 types = g_list_append(types, type); |
| 2229 | |
| 2230 return types; | |
| 2086 | 2231 } |
| 2232 | |
| 8644 | 2233 static GList *zephyr_chat_info(GaimConnection * gc) |
| 2234 { | |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
2235 GList *m = NULL; |
|
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
2236 struct proto_chat_entry *pce; |
| 2086 | 2237 |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
2238 pce = g_new0(struct proto_chat_entry, 1); |
| 8644 | 2239 |
| 7841 | 2240 pce->label = _("_Class:"); |
| 5234 | 2241 pce->identifier = "class"; |
| 3158 | 2242 m = g_list_append(m, pce); |
| 2086 | 2243 |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
2244 pce = g_new0(struct proto_chat_entry, 1); |
| 8644 | 2245 |
| 7841 | 2246 pce->label = _("_Instance:"); |
| 5234 | 2247 pce->identifier = "instance"; |
| 3158 | 2248 m = g_list_append(m, pce); |
| 2086 | 2249 |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
2250 pce = g_new0(struct proto_chat_entry, 1); |
| 8644 | 2251 |
| 7841 | 2252 pce->label = _("_Recipient:"); |
| 5234 | 2253 pce->identifier = "recipient"; |
| 3158 | 2254 m = g_list_append(m, pce); |
| 2086 | 2255 |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
2256 return m; |
| 2086 | 2257 } |
| 2258 | |
| 9478 | 2259 /* Called when the server notifies us a message couldn't get sent */ |
| 2260 | |
| 9896 | 2261 static void zephyr_subscribe_failed(GaimConnection *gc,char * z_class, char *z_instance, char * z_recipient, char* z_galaxy) |
| 9478 | 2262 { |
| 9896 | 2263 gchar* subscribe_failed = g_strdup_printf(_("Attempt to subscribe to %s,%s,%s failed"), z_class, z_instance,z_recipient); |
| 9610 | 2264 gaim_notify_error(gc,"", subscribe_failed, NULL); |
| 9478 | 2265 g_free(subscribe_failed); |
| 2266 } | |
| 2267 | |
| 9921 | 2268 static char *zephyr_get_chat_name(GHashTable *data) { |
| 9922 | 2269 gchar* zclass = g_hash_table_lookup(data,"class"); |
| 2270 gchar* inst = g_hash_table_lookup(data,"instance"); | |
| 2271 gchar* recipient = g_hash_table_lookup(data, "recipient"); | |
| 2272 if (!zclass) /* This should never happen */ | |
| 2273 zclass = ""; | |
| 2274 if (!inst) | |
| 2275 inst = "*"; | |
| 2276 if (!recipient) | |
| 2277 recipient = ""; | |
| 2278 return g_strdup_printf("%s,%s,%s",zclass,inst,recipient); | |
| 9917 | 2279 } |
| 2280 | |
| 9922 | 2281 |
| 8644 | 2282 static void zephyr_join_chat(GaimConnection * gc, GHashTable * data) |
| 2086 | 2283 { |
| 9896 | 2284 /* ZSubscription_t sub; */ |
| 2086 | 2285 zephyr_triple *zt1, *zt2; |
| 2286 const char *classname; | |
| 2287 const char *instname; | |
| 2288 const char *recip; | |
| 9896 | 2289 zephyr_account *zephyr=gc->proto_data; |
| 5234 | 2290 classname = g_hash_table_lookup(data, "class"); |
| 2291 instname = g_hash_table_lookup(data, "instance"); | |
| 2292 recip = g_hash_table_lookup(data, "recipient"); | |
| 2293 | |
| 9478 | 2294 |
| 9328 | 2295 if (!classname) |
|
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
2296 return; |
| 9478 | 2297 |
| 2298 if (!g_ascii_strcasecmp(classname,"%host%")) | |
| 9896 | 2299 classname = g_strdup(zephyr->ourhost); |
| 9478 | 2300 if (!g_ascii_strcasecmp(classname,"%canon%")) |
| 9896 | 2301 classname = g_strdup(zephyr->ourhostcanon); |
| 9478 | 2302 |
| 9328 | 2303 if (!instname || !strlen(instname)) |
| 2304 instname = "*"; | |
| 9478 | 2305 |
| 2306 if (!g_ascii_strcasecmp(instname,"%host%")) | |
| 9896 | 2307 instname = g_strdup(zephyr->ourhost); |
| 9478 | 2308 if (!g_ascii_strcasecmp(instname,"%canon%")) |
| 9896 | 2309 instname = g_strdup(zephyr->ourhostcanon); |
| 9478 | 2310 |
| 9328 | 2311 if (!recip || (*recip == '*')) |
| 2312 recip = ""; | |
| 4793 | 2313 if (!g_ascii_strcasecmp(recip, "%me%")) |
| 9896 | 2314 recip = zephyr->username; |
| 2086 | 2315 |
| 9610 | 2316 zt1 = new_triple(gc->proto_data,classname, instname, recip); |
| 2317 zt2 = find_sub_by_triple(gc->proto_data,zt1); | |
| 2086 | 2318 if (zt2) { |
| 2319 free_triple(zt1); | |
| 9328 | 2320 if (!zt2->open) { |
| 2321 if (!g_ascii_strcasecmp(instname,"*")) | |
| 2322 instname = "PERSONAL"; | |
| 9434 | 2323 serv_got_joined_chat(gc, zt2->id, zt2->name); |
| 9896 | 2324 zephyr_chat_set_topic(gc,zt2->id,instname); |
| 9328 | 2325 zt2->open = TRUE; |
| 2326 } | |
| 2086 | 2327 return; |
| 2328 } | |
| 9896 | 2329 |
| 2330 /* sub.zsub_class = zt1->class; | |
| 2331 sub.zsub_classinst = zt1->instance; | |
| 2332 sub.zsub_recipient = zt1->recipient; */ | |
| 2333 | |
| 2334 if (zephyr_subscribe_to(zephyr,zt1->class,zt1->instance,zt1->recipient,NULL) != ZERR_NONE) { | |
| 9478 | 2335 /* XXX output better subscription information */ |
| 9896 | 2336 zephyr_subscribe_failed(gc,zt1->class,zt1->instance,zt1->recipient,NULL); |
| 2086 | 2337 free_triple(zt1); |
| 2338 return; | |
| 2339 } | |
| 2340 | |
| 9610 | 2341 zephyr->subscrips = g_slist_append(zephyr->subscrips, zt1); |
| 2086 | 2342 zt1->open = TRUE; |
| 2343 serv_got_joined_chat(gc, zt1->id, zt1->name); | |
| 9328 | 2344 if (!g_ascii_strcasecmp(instname,"*")) |
| 2345 instname = "PERSONAL"; | |
| 9896 | 2346 zephyr_chat_set_topic(gc,zt1->id,instname); |
| 2086 | 2347 } |
| 2348 | |
| 8644 | 2349 static void zephyr_chat_leave(GaimConnection * gc, int id) |
| 2086 | 2350 { |
| 2351 zephyr_triple *zt; | |
| 9896 | 2352 zephyr_account *zephyr = gc->proto_data; |
| 9610 | 2353 zt = find_sub_by_id(zephyr,id); |
| 9896 | 2354 |
| 2086 | 2355 if (zt) { |
| 2356 zt->open = FALSE; | |
| 9610 | 2357 zt->id = ++(zephyr->last_id); |
| 2086 | 2358 } |
| 2359 } | |
| 2360 | |
| 9478 | 2361 static GaimChat *zephyr_find_blist_chat(GaimAccount *account, const char *name) |
| 2362 { | |
| 2363 GaimBlistNode *gnode, *cnode; | |
| 2364 | |
| 2365 /* XXX needs to be %host%,%canon%, and %me% clean */ | |
| 2366 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { | |
| 2367 for(cnode = gnode->child; cnode; cnode = cnode->next) { | |
| 2368 GaimChat *chat = (GaimChat*)cnode; | |
| 2369 char *zclass, *inst, *recip; | |
| 2370 char** triple; | |
| 2371 if(!GAIM_BLIST_NODE_IS_CHAT(cnode)) | |
| 2372 continue; | |
| 2373 if(chat->account !=account) | |
| 2374 continue; | |
| 2375 if(!(zclass = g_hash_table_lookup(chat->components, "class"))) | |
| 2376 continue; | |
| 2377 if(!(inst = g_hash_table_lookup(chat->components, "instance"))) | |
| 2378 inst = g_strdup(""); | |
| 2379 if(!(recip = g_hash_table_lookup(chat->components, "recipient"))) | |
| 2380 recip = g_strdup(""); | |
| 9896 | 2381 /* gaim_debug_info("zephyr","in zephyr_find_blist_chat name: %s\n",name?name:""); */ |
| 9478 | 2382 triple = g_strsplit(name,",",3); |
| 2383 if (!g_ascii_strcasecmp(triple[0],zclass) && !g_ascii_strcasecmp(triple[1],inst) && !g_ascii_strcasecmp(triple[2],recip)) | |
| 2384 return chat; | |
| 2385 | |
| 2386 } | |
| 2387 } | |
| 2388 return NULL; | |
| 2389 } | |
| 8644 | 2390 static const char *zephyr_list_icon(GaimAccount * a, GaimBuddy * b) |
| 5202 | 2391 { |
| 2392 return "zephyr"; | |
| 2393 } | |
| 2394 | |
| 9478 | 2395 static int zephyr_send_typing(GaimConnection *gc, const char *who, int typing) { |
| 2396 gchar *recipient; | |
| 9896 | 2397 zephyr_account *zephyr = gc->proto_data; |
| 2398 if (use_tzc(zephyr)) | |
| 2399 return 0; | |
| 2400 | |
| 9478 | 2401 if (!typing) |
| 2402 return 0; | |
| 2403 /* XXX We probably should care if this fails. Or maybe we don't want to */ | |
| 2404 if (!who) { | |
| 2405 gaim_debug_info("zephyr", "who is null\n"); | |
| 9896 | 2406 recipient = local_zephyr_normalize(zephyr,""); |
| 9478 | 2407 } else { |
| 10111 | 2408 char *comma = strrchr(who, ','); |
| 9896 | 2409 /* Don't ping broadcast (chat) recipients */ |
| 2410 /* The strrchr case finds a realm-stripped broadcast subscription | |
| 2411 e.g. comma is the last character in the string */ | |
| 10111 | 2412 if (comma && ( (*(comma+1) == '\0') || (*(comma+1) == '@'))) |
| 9896 | 2413 return 0; |
| 10111 | 2414 |
| 9896 | 2415 recipient = local_zephyr_normalize(zephyr,who); |
| 9478 | 2416 } |
| 2417 | |
| 9896 | 2418 gaim_debug_info("zephyr","about to send typing notification to %s\n",recipient); |
| 2419 zephyr_send_message(zephyr,"MESSAGE","PERSONAL",recipient,"","","PING"); | |
| 2420 gaim_debug_info("zephyr","sent typing notification\n"); | |
| 9478 | 2421 return ZEPHYR_TYPING_SEND_TIMEOUT; |
| 2422 } | |
| 8212 | 2423 |
| 9434 | 2424 |
| 2425 | |
| 8644 | 2426 static void zephyr_chat_set_topic(GaimConnection * gc, int id, const char *topic) |
| 2427 { | |
| 2428 zephyr_triple *zt; | |
| 2429 GaimConversation *gconv; | |
| 2430 GaimConvChat *gcc; | |
| 9896 | 2431 gchar *topic_utf8; |
| 2432 zephyr_account* zephyr = gc->proto_data; | |
| 2433 char *sender = (char *)zephyr->username; | |
| 8212 | 2434 |
| 9610 | 2435 zt = find_sub_by_id(gc->proto_data,id); |
| 9986 | 2436 /* find_sub_by_id can return NULL */ |
| 2437 if (!zt) | |
| 2438 return; | |
| 10246 | 2439 gconv = gaim_find_conversation_with_account(GAIM_CONV_CHAT, zt->name, |
| 2440 gc->account); | |
| 8644 | 2441 gcc = gaim_conversation_get_chat_data(gconv); |
| 9434 | 2442 |
| 9896 | 2443 topic_utf8 = zephyr_recv_convert(gc,(gchar *)topic,strlen(topic)); |
| 2444 gaim_conv_chat_set_topic(gcc,sender,topic_utf8); | |
| 2445 g_free(topic_utf8); | |
| 2446 return; | |
| 9434 | 2447 } |
| 2448 | |
| 2449 /* commands */ | |
| 2450 | |
| 2451 static GaimCmdRet zephyr_gaim_cmd_msg(GaimConversation *conv, | |
| 9896 | 2452 const char *cmd, char **args, char **error, void *data) |
| 9434 | 2453 { |
| 9896 | 2454 char *recipient; |
| 2455 zephyr_account *zephyr = gaim_conversation_get_gc(conv)->proto_data; | |
| 2456 if (!g_ascii_strcasecmp(args[0],"*")) | |
| 2457 return GAIM_CMD_RET_FAILED; /* "*" is not a valid argument */ | |
| 2458 else | |
| 2459 recipient = local_zephyr_normalize(zephyr,args[0]); | |
| 9434 | 2460 |
| 9896 | 2461 if (strlen(recipient) < 1) |
| 2462 return GAIM_CMD_RET_FAILED; /* a null recipient is a chat message, not an IM */ | |
| 9478 | 2463 |
| 9896 | 2464 if (zephyr_send_message(zephyr,"MESSAGE","PERSONAL",recipient,args[1],zephyr_get_signature(),"")) |
| 2465 return GAIM_CMD_RET_OK; | |
| 2466 else | |
| 2467 return GAIM_CMD_RET_FAILED; | |
| 9434 | 2468 } |
| 2469 | |
| 2470 static GaimCmdRet zephyr_gaim_cmd_zlocate(GaimConversation *conv, | |
| 9896 | 2471 const char *cmd, char **args, char **error, void *data) |
| 9434 | 2472 { |
| 9896 | 2473 zephyr_zloc(gaim_conversation_get_gc(conv),args[0]); |
| 2474 return GAIM_CMD_RET_OK; | |
| 9434 | 2475 } |
| 2476 | |
| 2477 static GaimCmdRet zephyr_gaim_cmd_instance(GaimConversation *conv, | |
| 9896 | 2478 const char *cmd, char **args, char **error, void *data) |
| 9434 | 2479 { |
| 9896 | 2480 /* Currently it sets the instance with leading spaces and |
| 2481 * all. This might not be the best thing to do, though having | |
| 2482 * one word isn't ideal either. */ | |
| 9434 | 2483 |
| 9896 | 2484 GaimConvChat *gcc = gaim_conversation_get_chat_data(conv); |
| 2485 int id = gcc->id; | |
| 2486 const char* instance = args[0]; | |
| 2487 zephyr_chat_set_topic(gaim_conversation_get_gc(conv),id,instance); | |
| 2488 return GAIM_CMD_RET_OK; | |
| 9434 | 2489 } |
| 2490 | |
| 2491 static GaimCmdRet zephyr_gaim_cmd_joinchat_cir(GaimConversation *conv, | |
| 9896 | 2492 const char *cmd, char **args, char **error, void *data) |
| 9434 | 2493 { |
| 9896 | 2494 /* Join a new zephyr chat */ |
| 2495 GHashTable *triple = g_hash_table_new(NULL,NULL); | |
| 2496 g_hash_table_insert(triple,"class",args[0]); | |
| 2497 g_hash_table_insert(triple,"instance",args[1]); | |
| 2498 g_hash_table_insert(triple,"recipient",args[2]); | |
| 2499 zephyr_join_chat(gaim_conversation_get_gc(conv),triple); | |
| 2500 return GAIM_CMD_RET_OK; | |
| 9434 | 2501 } |
| 2502 | |
| 2503 static GaimCmdRet zephyr_gaim_cmd_zi(GaimConversation *conv, | |
| 9896 | 2504 const char *cmd, char **args, char **error, void *data) |
| 9434 | 2505 { |
| 9896 | 2506 /* args = instance, message */ |
| 2507 zephyr_account *zephyr = gaim_conversation_get_gc(conv)->proto_data; | |
| 2508 if ( zephyr_send_message(zephyr,"message",args[0],"",args[1],zephyr_get_signature(),"")) | |
| 2509 return GAIM_CMD_RET_OK; | |
| 2510 else | |
| 2511 return GAIM_CMD_RET_FAILED; | |
| 9434 | 2512 } |
| 2513 | |
| 2514 static GaimCmdRet zephyr_gaim_cmd_zci(GaimConversation *conv, | |
| 9896 | 2515 const char *cmd, char **args, char **error, void *data) |
| 9434 | 2516 { |
| 9896 | 2517 /* args = class, instance, message */ |
| 2518 zephyr_account *zephyr = gaim_conversation_get_gc(conv)->proto_data; | |
| 2519 if ( zephyr_send_message(zephyr,args[0],args[1],"",args[2],zephyr_get_signature(),"")) | |
| 2520 return GAIM_CMD_RET_OK; | |
| 2521 else | |
| 2522 return GAIM_CMD_RET_FAILED; | |
| 9434 | 2523 } |
| 8644 | 2524 |
| 9434 | 2525 static GaimCmdRet zephyr_gaim_cmd_zcir(GaimConversation *conv, |
| 9896 | 2526 const char *cmd, char **args, char **error, void *data) |
| 9434 | 2527 { |
| 9896 | 2528 /* args = class, instance, recipient, message */ |
| 2529 zephyr_account *zephyr = gaim_conversation_get_gc(conv)->proto_data; | |
| 2530 if ( zephyr_send_message(zephyr,args[0],args[1],args[2],args[3],zephyr_get_signature(),"")) | |
| 2531 return GAIM_CMD_RET_OK; | |
| 2532 else | |
| 2533 return GAIM_CMD_RET_FAILED; | |
| 8212 | 2534 } |
| 2535 | |
| 9434 | 2536 static GaimCmdRet zephyr_gaim_cmd_zir(GaimConversation *conv, |
| 9896 | 2537 const char *cmd, char **args, char **error, void *data) |
| 9434 | 2538 { |
| 9896 | 2539 /* args = instance, recipient, message */ |
| 2540 zephyr_account *zephyr = gaim_conversation_get_gc(conv)->proto_data; | |
| 2541 if ( zephyr_send_message(zephyr,"message",args[0],args[1],args[2],zephyr_get_signature(),"")) | |
| 2542 return GAIM_CMD_RET_OK; | |
| 2543 else | |
| 2544 return GAIM_CMD_RET_FAILED; | |
| 9434 | 2545 } |
| 2546 | |
| 2547 static GaimCmdRet zephyr_gaim_cmd_zc(GaimConversation *conv, | |
| 9896 | 2548 const char *cmd, char **args, char **error, void *data) |
| 9434 | 2549 { |
| 9896 | 2550 /* args = class, message */ |
| 2551 zephyr_account *zephyr = gaim_conversation_get_gc(conv)->proto_data; | |
| 2552 if ( zephyr_send_message(zephyr,args[0],"PERSONAL","",args[1],zephyr_get_signature(),"")) | |
| 2553 return GAIM_CMD_RET_OK; | |
| 2554 else | |
| 2555 return GAIM_CMD_RET_FAILED; | |
| 9434 | 2556 } |
| 2557 | |
| 9597 | 2558 static void zephyr_register_slash_commands() |
| 9434 | 2559 { |
| 2560 | |
| 9896 | 2561 gaim_cmd_register("msg","ws", GAIM_CMD_P_PRPL, |
| 2562 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
| 2563 "prpl-zephyr", | |
| 2564 zephyr_gaim_cmd_msg, _("msg <nick> <message>: Send a private message to a user"), NULL); | |
| 9434 | 2565 |
| 9896 | 2566 gaim_cmd_register("zlocate","w", GAIM_CMD_P_PRPL, |
| 2567 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
| 2568 "prpl-zephyr", | |
| 2569 zephyr_gaim_cmd_zlocate, _("zlocate <nick>: Locate user"), NULL); | |
| 9434 | 2570 |
| 9896 | 2571 gaim_cmd_register("zl","w", GAIM_CMD_P_PRPL, |
| 2572 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
| 2573 "prpl-zephyr", | |
| 2574 zephyr_gaim_cmd_zlocate, _("zl <nick>: Locate user"), NULL); | |
| 9434 | 2575 |
| 9896 | 2576 gaim_cmd_register("instance","s", GAIM_CMD_P_PRPL, |
| 2577 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
| 2578 "prpl-zephyr", | |
| 2579 zephyr_gaim_cmd_instance, _("instance <instance>: Set the instance to be used on this class"), NULL); | |
| 9434 | 2580 |
| 9896 | 2581 gaim_cmd_register("inst","s", GAIM_CMD_P_PRPL, |
| 2582 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
| 2583 "prpl-zephyr", | |
| 2584 zephyr_gaim_cmd_instance, _("inst <instance>: Set the instance to be used on this class"), NULL); | |
| 9434 | 2585 |
|
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2586 gaim_cmd_register("topic","s", GAIM_CMD_P_PRPL, |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2587 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2588 "prpl-zephyr", |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2589 zephyr_gaim_cmd_instance, _("topic <instance>: Set the instance to be used on this class"), NULL); |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2590 |
| 9896 | 2591 gaim_cmd_register("sub", "www", GAIM_CMD_P_PRPL, |
| 2592 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
| 2593 "prpl-zephyr", | |
| 2594 zephyr_gaim_cmd_joinchat_cir, | |
| 2595 _("sub <class> <instance> <recipient>: Join a new chat"), NULL); | |
| 9434 | 2596 |
| 9896 | 2597 gaim_cmd_register("zi","ws", GAIM_CMD_P_PRPL, |
| 2598 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
| 2599 "prpl-zephyr", | |
| 2600 zephyr_gaim_cmd_zi, _("zi <instance>: Send a message to <message,<i>instance</i>,*>"), NULL); | |
| 9434 | 2601 |
| 9896 | 2602 gaim_cmd_register("zci","wws",GAIM_CMD_P_PRPL, |
| 2603 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
| 2604 "prpl-zephyr", | |
| 2605 zephyr_gaim_cmd_zci, | |
| 2606 _("zci <class> <instance>: Send a message to <<i>class</i>,<i>instance</i>,*>"), NULL); | |
| 9434 | 2607 |
| 9896 | 2608 gaim_cmd_register("zcir","wwws",GAIM_CMD_P_PRPL, |
| 2609 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
| 2610 "prpl-zephyr", | |
| 2611 zephyr_gaim_cmd_zcir, | |
| 2612 _("zcir <class> <instance> <recipient>: Send a message to <<i>class</i>,<i>instance</i>,<i>recipient</i>>"), NULL); | |
| 9434 | 2613 |
| 9896 | 2614 gaim_cmd_register("zir","wws",GAIM_CMD_P_PRPL, |
| 2615 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
| 2616 "prpl-zephyr", | |
| 2617 zephyr_gaim_cmd_zir, | |
| 2618 _("zir <instance> <recipient>: Send a message to <MESSAGE,<i>instance</i>,<i>recipient</i>>"), NULL); | |
| 9434 | 2619 |
| 9896 | 2620 gaim_cmd_register("zc","ws", GAIM_CMD_P_PRPL, |
| 2621 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
| 2622 "prpl-zephyr", | |
| 2623 zephyr_gaim_cmd_zc, _("zc <class>: Send a message to <<i>class</i>,PERSONAL,*>"), NULL); | |
| 9597 | 2624 |
| 9434 | 2625 } |
| 2626 | |
| 2627 | |
| 9896 | 2628 static void |
| 2629 zephyr_add_deny(GaimConnection *gc, const char *who) | |
| 2630 { | |
| 2631 gaim_privacy_deny_add(gc->account,who,1); | |
| 2632 } | |
| 2633 | |
| 2634 static void | |
| 2635 zephyr_remove_deny(GaimConnection *gc, const char *who) | |
| 2636 { | |
| 2637 gaim_privacy_deny_remove(gc->account,who,1); | |
| 2638 } | |
| 2639 | |
| 2640 static void | |
| 2641 zephyr_add_permit(GaimConnection *gc, const char *who) | |
| 2642 { | |
| 2643 gaim_privacy_permit_add(gc->account,who,1); | |
| 2644 } | |
| 2645 | |
| 2646 static void | |
| 2647 zephyr_remove_permit(GaimConnection *gc, const char *who) | |
| 2648 { | |
| 2649 gaim_privacy_permit_remove(gc->account,who,1); | |
| 2650 } | |
| 2651 | |
| 2652 static void | |
| 2653 zephyr_set_permit_deny(GaimConnection *gc) | |
| 2654 { | |
| 2655 /* This doesn't have to do anything, since really, we can just check account->perm_deny when deciding whether to di */ | |
| 2656 return; | |
| 2657 } | |
| 9427 | 2658 static int zephyr_resubscribe(GaimConnection *gc) |
| 2659 { | |
| 9896 | 2660 /* Resubscribe to the in-memory list of subscriptions and also |
| 2661 unsubscriptions*/ | |
| 2662 zephyr_account *zephyr = gc->proto_data; | |
| 2663 GSList *s = zephyr->subscrips; | |
| 2664 zephyr_triple *zt; | |
| 2665 while (s) { | |
| 2666 zt = s->data; | |
| 2667 /* XXX We really should care if this fails */ | |
| 2668 zephyr_subscribe_to(zephyr,zt->class,zt->instance,zt->recipient,NULL); | |
| 2669 s = s->next; | |
| 2670 } | |
| 2671 /* XXX handle unsubscriptions */ | |
| 2672 return 1; | |
| 9427 | 2673 } |
| 2674 | |
| 9434 | 2675 |
| 9427 | 2676 static void zephyr_action_resubscribe(GaimPluginAction *action) |
| 2677 { | |
| 2678 | |
| 9896 | 2679 GaimConnection *gc = (GaimConnection *) action->context; |
| 2680 zephyr_resubscribe(gc); | |
| 9427 | 2681 } |
| 2682 | |
| 2683 | |
| 9478 | 2684 static void zephyr_action_get_subs_from_server(GaimPluginAction *action) |
| 2685 { | |
| 2686 GaimConnection *gc = (GaimConnection *) action->context; | |
| 9896 | 2687 zephyr_account *zephyr = gc->proto_data; |
| 9478 | 2688 gchar *title; |
| 2689 int retval, nsubs, one,i; | |
| 2690 ZSubscription_t subs; | |
| 9896 | 2691 if (use_zeph02(zephyr)) { |
| 2692 GString* subout = g_string_new("Subscription list<br>"); | |
| 2693 | |
| 2694 title = g_strdup_printf("Server subscriptions for %s", zephyr->username); | |
| 2695 | |
| 2696 if (zephyr->port == 0) { | |
| 2697 gaim_debug(GAIM_DEBUG_ERROR,"zephyr", "error while retrieving port"); | |
| 2698 return; | |
| 2699 } | |
| 2700 if ((retval = ZRetrieveSubscriptions(zephyr->port,&nsubs)) != ZERR_NONE) { | |
| 9478 | 2701 /* XXX better error handling */ |
| 9896 | 2702 gaim_debug(GAIM_DEBUG_ERROR,"zephyr", "error while retrieving subscriptions from server"); |
| 9478 | 2703 return; |
| 2704 } | |
| 9896 | 2705 for(i=0;i<nsubs;i++) { |
| 2706 one = 1; | |
| 2707 if ((retval = ZGetSubscriptions(&subs,&one)) != ZERR_NONE) { | |
| 2708 /* XXX better error handling */ | |
| 2709 gaim_debug(GAIM_DEBUG_ERROR,"zephyr", "error while retrieving individual subscription"); | |
| 2710 return; | |
| 2711 } | |
| 2712 g_string_append_printf(subout, "Class %s Instance %s Recipient %s<br>", | |
| 2713 subs.zsub_class, subs.zsub_classinst, | |
| 2714 subs.zsub_recipient); | |
| 2715 } | |
| 2716 gaim_notify_formatted(gc, title, title, NULL, subout->str, NULL, NULL); | |
| 2717 } else { | |
| 2718 /* XXX fix */ | |
| 2719 gaim_notify_error(gc,"","tzc doesn't support this action",NULL); | |
| 9478 | 2720 } |
| 2721 } | |
| 2722 | |
| 2723 | |
| 9427 | 2724 static GList *zephyr_actions(GaimPlugin *plugin, gpointer context) |
| 2725 { | |
| 2726 GList *list = NULL; | |
| 2727 GaimPluginAction *act = NULL; | |
| 2728 | |
| 2729 act = gaim_plugin_action_new(_("Resubscribe"), zephyr_action_resubscribe); | |
| 2730 list = g_list_append(list, act); | |
| 2731 | |
| 9478 | 2732 act = gaim_plugin_action_new(_("Retrieve subscriptions from server"), zephyr_action_get_subs_from_server); |
| 2733 list = g_list_append(list,act); | |
| 2734 | |
| 9427 | 2735 return list; |
| 2736 } | |
| 2737 | |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
2738 static GaimPlugin *my_protocol = NULL; |
| 2086 | 2739 |
| 8644 | 2740 static GaimPluginProtocolInfo prpl_info = { |
| 2741 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_NO_PASSWORD, | |
| 9478 | 2742 NULL, /* ??? user_splits */ |
| 2743 NULL, /* ??? protocol_options */ | |
| 2744 NO_BUDDY_ICONS, | |
| 2745 zephyr_list_icon, | |
| 2746 NULL, /* ??? list_emblems */ | |
| 2747 NULL, /* ??? status_text */ | |
| 2748 NULL, /* ??? tooltip_text */ | |
| 9986 | 2749 zephyr_status_types, /* status_types */ |
| 9478 | 2750 NULL, /* ??? blist_node_menu - probably all useful actions are already handled*/ |
| 9475 | 2751 zephyr_chat_info, /* chat_info */ |
| 9754 | 2752 NULL, /* chat_info_defaults */ |
| 9475 | 2753 zephyr_login, /* login */ |
| 2754 zephyr_close, /* close */ | |
| 2755 zephyr_send_im, /* send_im */ | |
| 9478 | 2756 NULL, /* XXX set info (Location?) */ |
| 2757 zephyr_send_typing, /* send_typing */ | |
| 9475 | 2758 zephyr_zloc, /* get_info */ |
| 9986 | 2759 zephyr_set_status, /* set_status */ |
| 9478 | 2760 NULL, /* ??? set idle */ |
| 2761 NULL, /* change password */ | |
| 9475 | 2762 NULL, /* add_buddy */ |
| 2763 NULL, /* add_buddies */ | |
| 2764 NULL, /* remove_buddy */ | |
| 2765 NULL, /* remove_buddies */ | |
| 9896 | 2766 zephyr_add_permit, /* add_permit */ |
| 2767 zephyr_add_deny, /* add_deny */ | |
| 2768 zephyr_remove_permit, /* remove_permit */ | |
| 2769 zephyr_remove_deny, /* remove_deny */ | |
| 2770 zephyr_set_permit_deny, /* set_permit_deny */ | |
| 2771 NULL, /* warn -- not supported in zephyr */ | |
| 2772 zephyr_join_chat, /* join_chat */ | |
| 2773 NULL, /* reject_chat -- No chat invites*/ | |
| 9917 | 2774 zephyr_get_chat_name, /* get_chat_name */ |
| 9896 | 2775 NULL, /* chat_invite -- No chat invites*/ |
| 2776 zephyr_chat_leave, /* chat_leave */ | |
| 2777 NULL, /* chat_whisper -- No "whispering"*/ | |
| 2778 zephyr_chat_send, /* chat_send */ | |
| 2779 NULL, /* keepalive -- Not necessary*/ | |
| 2780 NULL, /* register_user -- Not supported*/ | |
| 2781 NULL, /* XXX get_cb_info */ | |
| 9475 | 2782 NULL, /* get_cb_away */ |
| 2783 NULL, /* alias_buddy */ | |
| 2784 NULL, /* group_buddy */ | |
| 2785 NULL, /* rename_group */ | |
| 9896 | 2786 NULL, /* buddy_free */ |
| 9475 | 2787 NULL, /* convo_closed */ |
| 9896 | 2788 zephyr_normalize, /* normalize */ |
| 2789 NULL, /* XXX set_buddy_icon */ | |
| 9475 | 2790 NULL, /* remove_group */ |
| 9896 | 2791 NULL, /* XXX get_cb_real_name */ |
| 2792 zephyr_chat_set_topic, /* set_chat_topic */ | |
| 2793 zephyr_find_blist_chat, /* find_blist_chat */ | |
| 9475 | 2794 NULL, /* roomlist_get_list */ |
| 2795 NULL, /* roomlist_cancel */ | |
| 9896 | 2796 NULL, /* roomlist_expand_category */ |
| 9475 | 2797 NULL, /* can_receive_file */ |
| 2798 NULL /* send_file */ | |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
2799 }; |
| 2086 | 2800 |
| 8644 | 2801 static GaimPluginInfo info = { |
| 9943 | 2802 GAIM_PLUGIN_MAGIC, |
| 2803 GAIM_MAJOR_VERSION, | |
| 2804 GAIM_MINOR_VERSION, | |
| 9896 | 2805 GAIM_PLUGIN_PROTOCOL, /**< type */ |
| 8644 | 2806 NULL, /**< ui_requirement */ |
| 9896 | 2807 0, /**< flags */ |
| 8644 | 2808 NULL, /**< dependencies */ |
| 9896 | 2809 GAIM_PRIORITY_DEFAULT, /**< priority */ |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
2810 |
| 9896 | 2811 "prpl-zephyr", /**< id */ |
| 2812 "Zephyr", /**< name */ | |
| 2813 VERSION, /**< version */ | |
| 2814 /** summary */ | |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
2815 N_("Zephyr Protocol Plugin"), |
| 9896 | 2816 /** description */ |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
2817 N_("Zephyr Protocol Plugin"), |
| 9896 | 2818 NULL, /**< author */ |
| 2819 GAIM_WEBSITE, /**< homepage */ | |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
2820 |
| 9896 | 2821 NULL, /**< load */ |
| 2822 NULL, /**< unload */ | |
| 2823 NULL, /**< destroy */ | |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
2824 |
| 9896 | 2825 NULL, /**< ui_info */ |
| 8993 | 2826 &prpl_info, /**< extra_info */ |
| 2827 NULL, | |
| 9427 | 2828 zephyr_actions |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
2829 }; |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
2830 |
| 8644 | 2831 static void init_plugin(GaimPlugin * plugin) |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
2832 { |
| 8212 | 2833 GaimAccountOption *option; |
| 8644 | 2834 char *tmp = get_exposure_level(); |
|
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2835 |
| 9896 | 2836 option = gaim_account_option_bool_new("Use tzc", "use_tzc", FALSE); |
| 2837 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 2838 | |
| 2839 option = gaim_account_option_string_new("tzc command", "tzc_command", "/usr/bin/tzc -e %s"); | |
| 2840 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 2841 | |
| 8644 | 2842 option = gaim_account_option_bool_new(_("Export to .anyone"), "write_anyone", FALSE); |
| 2843 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 8212 | 2844 |
| 8644 | 2845 option = gaim_account_option_bool_new(_("Export to .zephyr.subs"), "write_zsubs", FALSE); |
| 2846 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 8212 | 2847 |
|
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2848 option = gaim_account_option_bool_new(_("Import from .anyone"), "read_anyone", TRUE); |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2849 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2850 |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2851 option = gaim_account_option_bool_new(_("Import from .zephyr.subs"), "read_zsubs", TRUE); |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2852 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2853 |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2854 option = gaim_account_option_string_new(_("Realm"), "realm", ""); |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2855 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2856 |
|
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2857 option = gaim_account_option_string_new(_("Exposure"), "exposure_level", tmp?tmp: EXPOSE_REALMVIS); |
| 8644 | 2858 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
| 8212 | 2859 |
| 8644 | 2860 option = gaim_account_option_string_new(_("Encoding"), "encoding", ZEPHYR_FALLBACK_CHARSET); |
| 2861 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 8560 | 2862 |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
2863 my_protocol = plugin; |
| 9896 | 2864 zephyr_register_slash_commands(); |
| 2086 | 2865 } |
| 2866 | |
|
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
2867 GAIM_INIT_PLUGIN(zephyr, init_plugin, info); |
