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