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