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