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