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