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