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