Mercurial > pidgin.yaz
annotate src/protocols/zephyr/zephyr.c @ 12645:fc28451f5d96
[gaim-migrate @ 14983]
SF Patch #1314512 from Sadrul (who has a patch for everything)
"This patch introduces a flag for protocol plugins that
support offline messages (like Y!M and ICQ). This was
encouraged by the following conversation:
<sadrul> should offline buddies be listed/enabled in
the send-to menu?
<rekkanoryo> i would think only for protocols that
support offline messaging, if it's indicated that the
buddy is offline
-- <snip> --
<Bleeter> sadrul: personally, I'd like to see a
'supports offline' flag of some description
<Bleeter> one could then redirect (via plugins) through
email or alternative methods
<Bleeter> just a thought
<Paco-Paco> yeah, that sounds like a reasonble thing to have
This patch uses this flag to disable the buddies in the
send-to menu who are offline and the protocol doesn't
support offline messages."
I made this make the label insensitive instead of the whole menuitem. This
should address SimGuy's concerns about inconsistency (i.e. you could create a
conversation with someone via the buddy list that you couldn't create via the
Send To menu). I also hacked up some voodoo to show the label as sensitive when
moused-over, as that looks better (given the label-insensitive thing is itself a
hack). I think this works quite well.
BUG NOTE:
This makes more obvious an existing bug. The Send To menu isn't updated when
buddies sign on or off or change status (at least under some circumstances).
We need to fix that anyway, so I'm not going to let it hold up this commit.
Switching tabs will clear it up. I'm thinking we just might want to build the
contents of that menu when it is selected. That would save us a mess of
inefficient signal callbacks that update the Send To menus in open windows all
the time.
AIM NOTE:
This assumes that AIM can't offline message. That's not strictly true. You can
message invisible users on AIM. However, by design, we can't tell when a user
is invisible without resorting to dirty hackery. In practice, this isn't a
problem, as you can still select the AIM user from the menu. And really, how
often will you be choosing the Invisible contact, rather than the user going
Invisible in the middle of a conversation or IMing you while they're Invisible?
JABBER NOTE:
This assumes that Jabber can always offline message. This isn't strictly true.
Sadrul said:
I have updated Jabber according to this link which seems to
talk about how to determine the existence offline-message
support in a server:
http://www.jabber.org/jeps/jep-0013.html#discover
However, jabber.org doesn't seem to send the required
info. So I am not sure about it.
He later said:
I talked to Nathan and he said offline message support is
mostly assumed for most jabber servers. GTalk doesn't yet
support it, but they are working on it. So I have made
jabber to always return TRUE.
If there is truly no way to detect offline messaging capability, then this is
an acceptable solution. We could special case Google Talk because of its
popularity, and remove that later. It's probably not worth it though.
MSN NOTE:
This assumes that MSN can never offline message. That's effectively true, but
to be technically correct, MSN can offline message if there's already a
switchboard conversation open with a user. We could write an offline_message
function in the MSN prpl to detect that, but it'd be of limited usefulness,
especially given that under most circumstances (where this might matter), the
switchboard connection will be closed almost immediately.
CVS NOTE:
I'm writing to share a tragic little story.
I have a PC that I use for Gaim development. One day, I was writing a commit
message on it, when all of a suddent it went berserk. The screen started
flashing, and the whole commit message just disappeared. All of it. And it was
a good commit message! I had to cram and rewrite it really quickly. Needless to
say, my rushed commit message wasn't nearly as good, and I blame the PC for that.
Seriously, though, what kind of version control system loses your commit
message on a broken connection to the server? Stupid!
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Fri, 23 Dec 2005 19:26:04 +0000 |
parents | 851b0bd7eb52 |
children | a0fd3ebcd6fa |
rev | line source |
---|---|
2086 | 1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ |
2 /* | |
3 * gaim | |
4 * | |
5 * Copyright (C) 1998-2001, Mark Spencer <markster@marko.net> | |
6 * Some code borrowed from GtkZephyr, by | |
7084
0909ebf6fb28
[gaim-migrate @ 7649]
Christian Hammond <chipx86@chipx86.com>
parents:
7070
diff
changeset
|
7 * Jag/Sean Dilda <agrajag@linuxpower.org>/<smdilda@unity.ncsu.edu> |
0909ebf6fb28
[gaim-migrate @ 7649]
Christian Hammond <chipx86@chipx86.com>
parents:
7070
diff
changeset
|
8 * http://gtkzephyr.linuxpower.org/ |
2086 | 9 * |
9896 | 10 * Some code borrowed from kzephyr, by |
11 * Chris Colohan <colohan+@cs.cmu.edu> | |
12 * | |
2086 | 13 * This program is free software; you can redistribute it and/or modify |
14 * it under the terms of the GNU General Public License as published by | |
15 * the Free Software Foundation; either version 2 of the License, or | |
16 * (at your option) any later version. | |
17 * | |
18 * This program is distributed in the hope that it will be useful, | |
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
9896 | 20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2086 | 21 * GNU General Public License for more details. |
22 * | |
23 * You should have received a copy of the GNU General Public License | |
24 * along with this program; if not, write to the Free Software | |
9896 | 25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
2086 | 26 * |
9896 | 27 |
28 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
29 /* XXX eww */ |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
30 #include "src/internal.h" |
2086 | 31 |
8212 | 32 #include "accountopt.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
33 #include "debug.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
34 #include "notify.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
35 #include "prpl.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
36 #include "server.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
37 #include "util.h" |
9434 | 38 #include "cmds.h" |
9896 | 39 #include "privacy.h" |
9943 | 40 #include "version.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
41 |
9896 | 42 #include "zephyr.h" |
9478 | 43 #include "internal.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
44 |
8386 | 45 #include <strings.h> |
46 | |
8560 | 47 #define ZEPHYR_FALLBACK_CHARSET "ISO-8859-1" |
48 | |
9478 | 49 /* these are deliberately high, since most people don't send multiple "PING"s */ |
50 #define ZEPHYR_TYPING_SEND_TIMEOUT 15 | |
51 #define ZEPHYR_TYPING_RECV_TIMEOUT 10 | |
9896 | 52 #define ZEPHYR_FD_READ 0 |
53 #define ZEPHYR_FD_WRITE 1 | |
9478 | 54 |
2086 | 55 extern Code_t ZGetLocations(ZLocations_t *, int *); |
56 extern Code_t ZSetLocation(char *); | |
57 extern Code_t ZUnsetLocation(); | |
9478 | 58 extern Code_t ZGetSubscriptions(ZSubscription_t *, int*); |
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
59 extern char __Zephyr_realm[]; |
2086 | 60 typedef struct _zframe zframe; |
61 typedef struct _zephyr_triple zephyr_triple; | |
9610 | 62 typedef struct _zephyr_account zephyr_account; |
9896 | 63 typedef struct _parse_tree parse_tree; |
2086 | 64 |
9896 | 65 typedef enum { |
66 GAIM_ZEPHYR_NONE, /* Non-kerberized ZEPH0.2 */ | |
67 GAIM_ZEPHYR_KRB4, /* ZEPH0.2 w/ KRB4 support */ | |
68 GAIM_ZEPHYR_TZC, /* tzc executable proxy */ | |
69 GAIM_ZEPHYR_INTERGALACTIC_KRB4, /* Kerberized ZEPH0.3 */ | |
70 } zephyr_connection_type; | |
9610 | 71 |
72 struct _zephyr_account { | |
9896 | 73 GaimAccount* account; |
74 char *username; | |
75 char *realm; | |
76 char *encoding; | |
77 char* galaxy; /* not yet useful */ | |
78 char* krbtkfile; /* not yet useful */ | |
79 guint32 nottimer; | |
80 guint32 loctimer; | |
81 GList *pending_zloc_names; | |
82 GSList *subscrips; | |
83 int last_id; | |
84 unsigned short port; | |
85 char ourhost[HOST_NAME_MAX + 1]; | |
86 char ourhostcanon[HOST_NAME_MAX + 1]; | |
87 zephyr_connection_type connection_type; | |
88 int totzc[2]; | |
89 int fromtzc[2]; | |
90 char *exposure; | |
9986 | 91 pid_t tzc_pid; |
92 gchar *away; | |
9610 | 93 }; |
9478 | 94 |
9896 | 95 #define MAXCHILDREN 20 |
96 | |
97 struct _parse_tree { | |
98 gchar* contents; | |
99 parse_tree *children[MAXCHILDREN]; | |
100 int num_children; | |
101 }; | |
102 | |
103 parse_tree null_parse_tree = { | |
104 "", | |
10116 | 105 {NULL}, |
9896 | 106 0, |
107 }; | |
108 | |
109 #define use_none(zephyr) ((zephyr->connection_type == GAIM_ZEPHYR_NONE)?1:0) | |
110 #define use_krb4(zephyr) ((zephyr->connection_type == GAIM_ZEPHYR_KRB4)?1:0) | |
111 #define use_tzc(zephyr) ((zephyr->connection_type == GAIM_ZEPHYR_TZC)?1:0) | |
112 | |
113 #define use_zeph02(zephyr) ( (zephyr->connection_type == GAIM_ZEPHYR_NONE)?1: ((zephyr->connection_type == GAIM_ZEPHYR_KRB4)?1:0)) | |
114 | |
2086 | 115 /* struct I need for zephyr_to_html */ |
116 struct _zframe { | |
117 /* true for everything but @color, since inside the parens of that one is | |
8644 | 118 * the color. */ |
2086 | 119 gboolean has_closer; |
120 /* </i>, </font>, </b>, etc. */ | |
121 char *closing; | |
122 /* text including the opening html thingie. */ | |
123 GString *text; | |
124 struct _zframe *enclosing; | |
125 }; | |
126 | |
127 struct _zephyr_triple { | |
128 char *class; | |
129 char *instance; | |
130 char *recipient; | |
131 char *name; | |
132 gboolean open; | |
133 int id; | |
134 }; | |
135 | |
136 #define z_call(func) if (func != ZERR_NONE)\ | |
137 return; | |
138 #define z_call_r(func) if (func != ZERR_NONE)\ | |
139 return TRUE; | |
9896 | 140 |
2086 | 141 #define z_call_s(func, err) if (func != ZERR_NONE) {\ |
9610 | 142 gaim_connection_error(gc, err);\ |
2086 | 143 return;\ |
144 } | |
145 | |
10867 | 146 #ifdef WIN32 |
147 extern const char *username; | |
148 #endif | |
9896 | 149 |
12424
7c2e2c4d45a4
[gaim-migrate @ 14731]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
150 static Code_t zephyr_subscribe_to(zephyr_account* zephyr, char* class, char *instance, char *recipient, char* galaxy) { |
9328 | 151 |
9896 | 152 if (use_tzc(zephyr)) { |
153 /* ((tzcfodder . subscribe) ("class" "instance" "recipient")) */ | |
154 gchar *zsubstr = g_strdup_printf("((tzcfodder . subscribe) (\"%s\" \"%s\" \"%s\"))\n",class,instance,recipient); | |
155 write(zephyr->totzc[ZEPHYR_FD_WRITE],zsubstr,strlen(zsubstr)); | |
156 g_free(zsubstr); | |
157 return ZERR_NONE; | |
158 } | |
159 else { | |
160 if (use_zeph02(zephyr)) { | |
161 ZSubscription_t sub; | |
162 sub.zsub_class = class; | |
163 sub.zsub_classinst = instance; | |
164 sub.zsub_recipient = recipient; | |
165 return ZSubscribeTo(&sub,1,0); | |
166 } else { | |
167 /* This should not happen */ | |
168 return -1; | |
169 } | |
170 } | |
171 return -1; | |
172 } | |
173 | |
174 char *local_zephyr_normalize(zephyr_account* zephyr,const char *); | |
175 static void zephyr_chat_set_topic(GaimConnection * gc, int id, const char *topic); | |
176 char* zephyr_tzc_deescape_str(const char *message); | |
177 | |
12424
7c2e2c4d45a4
[gaim-migrate @ 14731]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
178 static char *zephyr_strip_local_realm(zephyr_account* zephyr,const char* user){ |
9896 | 179 /* |
180 Takes in a username of the form username or username@realm | |
181 and returns: | |
182 username, if there is no realm, or the realm is the local realm | |
183 or: | |
184 username@realm if there is a realm and it is foreign | |
185 */ | |
9328 | 186 char *tmp = g_strdup(user); |
187 char *at = strchr(tmp,'@'); | |
9896 | 188 if (at && !g_ascii_strcasecmp(at+1,zephyr->realm)) { |
9328 | 189 /* We're passed in a username of the form user@users-realm */ |
190 char* tmp2; | |
191 *at = '\0'; | |
192 tmp2 = g_strdup(tmp); | |
193 g_free(tmp); | |
194 return tmp2; | |
195 } | |
196 else { | |
197 /* We're passed in a username of the form user or user@foreign-realm */ | |
198 return tmp; | |
199 } | |
200 } | |
2086 | 201 |
202 /* this is so bad, and if Zephyr weren't so fucked up to begin with I | |
203 * wouldn't do this. but it is so i will. */ | |
9610 | 204 |
9328 | 205 /* just for debugging */ |
2086 | 206 static void handle_unknown(ZNotice_t notice) |
207 { | |
10867 | 208 gaim_debug_error("zephyr","z_packet: %s\n", notice.z_packet); |
209 gaim_debug_error("zephyr","z_version: %s\n", notice.z_version); | |
210 gaim_debug_error("zephyr","z_kind: %d\n", (int)(notice.z_kind)); | |
211 gaim_debug_error("zephyr","z_class: %s\n", notice.z_class); | |
212 gaim_debug_error("zephyr","z_class_inst: %s\n", notice.z_class_inst); | |
213 gaim_debug_error("zephyr","z_opcode: %s\n", notice.z_opcode); | |
214 gaim_debug_error("zephyr","z_sender: %s\n", notice.z_sender); | |
215 gaim_debug_error("zephyr","z_recipient: %s\n", notice.z_recipient); | |
216 gaim_debug_error("zephyr","z_message: %s\n", notice.z_message); | |
217 gaim_debug_error("zephyr","z_message_len: %d\n", notice.z_message_len); | |
2086 | 218 } |
9328 | 219 |
2086 | 220 |
9610 | 221 static zephyr_triple *new_triple(zephyr_account *zephyr,const char *c, const char *i, const char *r) |
2086 | 222 { |
223 zephyr_triple *zt; | |
8644 | 224 |
2086 | 225 zt = g_new0(zephyr_triple, 1); |
226 zt->class = g_strdup(c); | |
227 zt->instance = g_strdup(i); | |
228 zt->recipient = g_strdup(r); | |
9610 | 229 zt->name = g_strdup_printf("%s,%s,%s", c, i?i:"", r?r:""); |
230 zt->id = ++(zephyr->last_id); | |
2086 | 231 zt->open = FALSE; |
232 return zt; | |
233 } | |
234 | |
8644 | 235 static void free_triple(zephyr_triple * zt) |
2086 | 236 { |
237 g_free(zt->class); | |
238 g_free(zt->instance); | |
239 g_free(zt->recipient); | |
240 g_free(zt->name); | |
241 g_free(zt); | |
242 } | |
243 | |
9328 | 244 /* returns true if zt1 is a subset of zt2. This function is used to |
245 determine whether a zephyr sent to zt1 should be placed in the chat | |
246 with triple zt2 | |
247 | |
248 zt1 is a subset of zt2 | |
249 iff. the classnames are identical ignoring case | |
250 AND. the instance names are identical (ignoring case), or zt2->instance is *. | |
251 AND. the recipient names are identical | |
252 */ | |
253 | |
8644 | 254 static gboolean triple_subset(zephyr_triple * zt1, zephyr_triple * zt2) |
2086 | 255 { |
9896 | 256 |
257 if (!zt2) | |
258 gaim_debug_error("zephyr","zt2 doesn't exist\n"); | |
259 if (!zt1) | |
260 gaim_debug_error("zephyr","zt1 doesn't exist\n"); | |
261 if (!(zt1->class)) | |
262 gaim_debug_error("zephyr","zt1c doesn't exist\n"); | |
263 if (!(zt1->instance)) | |
264 gaim_debug_error("zephyr","zt1i doesn't exist\n"); | |
265 if (!(zt1->recipient)) | |
266 gaim_debug_error("zephyr","zt1r doesn't exist\n"); | |
267 if (!(zt2->class)) | |
268 gaim_debug_error("zephyr","zt2c doesn't exist\n"); | |
269 if (!(zt2->recipient)) | |
270 gaim_debug_error("zephyr","zt2r doesn't exist\n"); | |
271 if (!(zt2->instance)) | |
272 gaim_debug_error("zephyr","zt2i doesn't exist\n"); | |
273 | |
274 | |
9328 | 275 if (g_ascii_strcasecmp(zt2->class, zt1->class)) { |
2086 | 276 return FALSE; |
277 } | |
8644 | 278 if (g_ascii_strcasecmp(zt2->instance, zt1->instance) && g_ascii_strcasecmp(zt2->instance, "*")) { |
2086 | 279 return FALSE; |
280 } | |
9328 | 281 if (g_ascii_strcasecmp(zt2->recipient, zt1->recipient)) { |
2086 | 282 return FALSE; |
283 } | |
9896 | 284 gaim_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 | 285 return TRUE; |
286 } | |
287 | |
9610 | 288 static zephyr_triple *find_sub_by_triple(zephyr_account *zephyr,zephyr_triple * zt) |
2086 | 289 { |
290 zephyr_triple *curr_t; | |
9610 | 291 GSList *curr = zephyr->subscrips; |
8644 | 292 |
2086 | 293 while (curr) { |
294 curr_t = curr->data; | |
295 if (triple_subset(zt, curr_t)) | |
296 return curr_t; | |
297 curr = curr->next; | |
298 } | |
299 return NULL; | |
300 } | |
301 | |
9610 | 302 static zephyr_triple *find_sub_by_id(zephyr_account *zephyr,int id) |
2086 | 303 { |
304 zephyr_triple *zt; | |
9610 | 305 GSList *curr = zephyr->subscrips; |
8644 | 306 |
2086 | 307 while (curr) { |
308 zt = curr->data; | |
309 if (zt->id == id) | |
310 return zt; | |
311 curr = curr->next; | |
312 } | |
313 return NULL; | |
314 } | |
315 | |
9328 | 316 /* |
9434 | 317 Converts strings to utf-8 if necessary using user specified encoding |
9328 | 318 */ |
319 | |
9610 | 320 static gchar *zephyr_recv_convert(GaimConnection *gc,gchar *string, int len) |
8560 | 321 { |
322 gchar *utf8; | |
323 GError *err = NULL; | |
9896 | 324 zephyr_account *zephyr = gc->proto_data; |
8644 | 325 if (g_utf8_validate(string, len, NULL)) { |
8568 | 326 return g_strdup(string); |
327 } else { | |
9896 | 328 utf8 = g_convert(string, len, "UTF-8", zephyr->encoding, NULL, NULL, &err); |
8568 | 329 if (err) { |
10867 | 330 gaim_debug_error("zephyr", "recv conversion error: %s\n", err->message); |
9896 | 331 utf8 = g_strdup(_("(There was an error converting this message. Check the 'Encoding' option in the Account Editor)")); |
8954 | 332 g_error_free(err); |
8568 | 333 } |
334 | |
335 return utf8; | |
336 } | |
8560 | 337 } |
338 | |
2086 | 339 /* utility macros that are useful for zephyr_to_html */ |
340 | |
341 #define IS_OPENER(c) ((c == '{') || (c == '[') || (c == '(') || (c == '<')) | |
342 #define IS_CLOSER(c) ((c == '}') || (c == ']') || (c == ')') || (c == '>')) | |
343 | |
8451 | 344 /* This parses HTML formatting (put out by one of the gtkimhtml widgets |
345 And converts it to zephyr formatting. | |
346 It currently deals properly with <b>, <br>, <i>, <font face=...>, <font color=...>, | |
347 It ignores <font back=...> | |
348 It does | |
349 <font size = "1 or 2" -> @small | |
350 3 or 4 @medium() | |
351 5,6, or 7 @large() | |
352 <a href is dealt with by ignoring the description and outputting the link | |
353 */ | |
354 | |
355 static char *html_to_zephyr(const char *message) | |
356 { | |
8644 | 357 int len, cnt, retcount; |
358 char *ret; | |
359 | |
360 len = strlen(message); | |
9478 | 361 if (!len) |
362 return g_strdup(""); | |
363 | |
8644 | 364 ret = g_new0(char, len * 3); |
365 | |
366 bzero(ret, len * 3); | |
367 retcount = 0; | |
368 cnt = 0; | |
9896 | 369 gaim_debug_info("zephyr","html received %s\n",message); |
8644 | 370 while (cnt <= len) { |
371 if (message[cnt] == '<') { | |
372 if (!g_ascii_strncasecmp(message + cnt + 1, "i>", 2)) { | |
373 strncpy(ret + retcount, "@i(", 3); | |
374 cnt += 3; | |
375 retcount += 3; | |
376 } else if (!g_ascii_strncasecmp(message + cnt + 1, "b>", 2)) { | |
377 strncpy(ret + retcount, "@b(", 3); | |
378 cnt += 3; | |
379 retcount += 3; | |
380 } else if (!g_ascii_strncasecmp(message + cnt + 1, "br>", 3)) { | |
381 strncpy(ret + retcount, "\n", 1); | |
382 cnt += 4; | |
383 retcount += 1; | |
9896 | 384 } else if (!g_ascii_strncasecmp(message + cnt + 1, "a href=\"mailto:", 15)) { |
385 cnt += 16; | |
11176 | 386 while ((message[cnt] != '\0') && g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) { |
9896 | 387 ret[retcount] = message[cnt]; |
388 retcount++; | |
389 cnt++; | |
390 } | |
11176 | 391 if (message[cnt] != '\0') |
392 cnt += 2; | |
9896 | 393 /* ignore descriptive string */ |
11176 | 394 while ((message[cnt] != '\0') && g_ascii_strncasecmp(message + cnt, "</a>", 4) != 0) { |
9896 | 395 cnt++; |
396 } | |
11176 | 397 if (message[cnt] != '\0') |
398 cnt += 4; | |
8644 | 399 } else if (!g_ascii_strncasecmp(message + cnt + 1, "a href=\"", 8)) { |
400 cnt += 9; | |
11176 | 401 while ((message[cnt] != '\0') && g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) { |
8644 | 402 ret[retcount] = message[cnt]; |
403 retcount++; | |
404 cnt++; | |
405 } | |
11176 | 406 if (message[cnt] != '\0') |
407 cnt += 2; | |
8644 | 408 /* ignore descriptive string */ |
11176 | 409 while ((message[cnt] != '\0') && g_ascii_strncasecmp(message + cnt, "</a>", 4) != 0) { |
8644 | 410 cnt++; |
411 } | |
11176 | 412 if (message[cnt] != '\0') |
413 cnt += 4; | |
8644 | 414 } else if (!g_ascii_strncasecmp(message + cnt + 1, "font", 4)) { |
415 cnt += 5; | |
11176 | 416 while ((message[cnt] != '\0') && (message[cnt] != ' ')) |
8644 | 417 cnt++; |
11176 | 418 if ((message[cnt] != '\0') && !g_ascii_strncasecmp(message + cnt, "color=\"", 7)) { |
8644 | 419 cnt += 7; |
420 strncpy(ret + retcount, "@color(", 7); | |
421 retcount += 7; | |
11176 | 422 while ((message[cnt] != '\0') && g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) { |
8644 | 423 ret[retcount] = message[cnt]; |
424 retcount++; | |
425 cnt++; | |
426 } | |
427 ret[retcount] = ')'; | |
428 retcount++; | |
11176 | 429 if (message[cnt] != '\0') |
430 cnt += 2; | |
8644 | 431 } else if (!g_ascii_strncasecmp(message + cnt, "face=\"", 6)) { |
432 cnt += 6; | |
433 strncpy(ret + retcount, "@font(", 6); | |
434 retcount += 6; | |
11176 | 435 while ((message[cnt] != '\0') && g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) { |
8644 | 436 ret[retcount] = message[cnt]; |
437 retcount++; | |
438 cnt++; | |
439 } | |
440 ret[retcount] = ')'; | |
441 retcount++; | |
11176 | 442 if (message[cnt] != '\0') |
443 cnt += 2; | |
8644 | 444 } else if (!g_ascii_strncasecmp(message + cnt, "size=\"", 6)) { |
445 cnt += 6; | |
446 if ((message[cnt] == '1') || (message[cnt] == '2')) { | |
447 strncpy(ret + retcount, "@small(", 7); | |
448 retcount += 7; | |
449 } else if ((message[cnt] == '3') | |
9896 | 450 || (message[cnt] == '4')) { |
8644 | 451 strncpy(ret + retcount, "@medium(", 8); |
452 retcount += 8; | |
453 } else if ((message[cnt] == '5') | |
9896 | 454 || (message[cnt] == '6') |
455 || (message[cnt] == '7')) { | |
8644 | 456 strncpy(ret + retcount, "@large(", 7); |
457 retcount += 7; | |
458 } | |
459 cnt += 3; | |
460 } else { | |
461 /* Drop all unrecognized/misparsed font tags */ | |
11176 | 462 while ((message[cnt] != '\0') && g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) { |
8644 | 463 cnt++; |
464 } | |
11176 | 465 if (message[cnt] != '\0') |
466 cnt += 2; | |
8644 | 467 } |
468 } else if (!g_ascii_strncasecmp(message + cnt + 1, "/i>", 3) | |
9896 | 469 || !g_ascii_strncasecmp(message + cnt + 1, "/b>", 3)) { |
8644 | 470 cnt += 4; |
471 ret[retcount] = ')'; | |
472 retcount++; | |
473 } else if (!g_ascii_strncasecmp(message + cnt + 1, "/font>", 6)) { | |
474 cnt += 7; | |
475 strncpy(ret + retcount, "@font(fixed)", 12); | |
476 retcount += 12; | |
477 } else { | |
478 /* Catch all for all unrecognized/misparsed <foo> tage */ | |
11176 | 479 while ((message[cnt] != '\0') && (message[cnt] != '>')) { |
8644 | 480 ret[retcount] = message[cnt]; |
481 retcount++; | |
482 cnt++; | |
483 } | |
484 } | |
485 } else { | |
486 /* Duh */ | |
487 ret[retcount] = message[cnt]; | |
488 retcount++; | |
489 cnt++; | |
490 } | |
491 } | |
9896 | 492 gaim_debug_info("zephyr","zephyr outputted %s\n",ret); |
8644 | 493 return ret; |
8451 | 494 } |
495 | |
2086 | 496 /* this parses zephyr formatting and converts it to html. For example, if |
497 * you pass in "@{@color(blue)@i(hello)}" you should get out | |
498 * "<font color=blue><i>hello</i></font>". */ | |
499 static char *zephyr_to_html(char *message) | |
500 { | |
501 int len, cnt; | |
502 zframe *frames, *curr; | |
503 char *ret; | |
504 | |
505 frames = g_new(zframe, 1); | |
506 frames->text = g_string_new(""); | |
507 frames->enclosing = NULL; | |
508 frames->closing = ""; | |
509 frames->has_closer = FALSE; | |
510 | |
511 len = strlen(message); | |
512 cnt = 0; | |
513 while (cnt <= len) { | |
514 if (message[cnt] == '@') { | |
515 zframe *new_f; | |
516 char *buf; | |
517 int end; | |
8644 | 518 |
519 for (end = 1; (cnt + end) <= len && !IS_OPENER(message[cnt + end]) | |
9896 | 520 && !IS_CLOSER(message[cnt + end]); end++); |
2086 | 521 buf = g_new0(char, end); |
8644 | 522 |
2086 | 523 if (end) { |
8644 | 524 g_snprintf(buf, end, "%s", message + cnt + 1); |
2086 | 525 } |
8644 | 526 if (!g_ascii_strcasecmp(buf, "italic") || !g_ascii_strcasecmp(buf, "i")) { |
2086 | 527 new_f = g_new(zframe, 1); |
528 new_f->enclosing = frames; | |
529 new_f->text = g_string_new("<i>"); | |
530 new_f->closing = "</i>"; | |
531 new_f->has_closer = TRUE; | |
532 frames = new_f; | |
8644 | 533 cnt += end + 1; /* cnt points to char after opener */ |
534 } else if (!g_ascii_strcasecmp(buf, "small")) { | |
535 new_f = g_new(zframe, 1); | |
536 new_f->enclosing = frames; | |
537 new_f->text = g_string_new("<font size=\"1\">"); | |
538 new_f->closing = "</font>"; | |
539 frames = new_f; | |
540 cnt += end + 1; | |
541 } else if (!g_ascii_strcasecmp(buf, "medium")) { | |
542 new_f = g_new(zframe, 1); | |
543 new_f->enclosing = frames; | |
544 new_f->text = g_string_new("<font size=\"3\">"); | |
545 new_f->closing = "</font>"; | |
546 frames = new_f; | |
547 cnt += end + 1; | |
548 } else if (!g_ascii_strcasecmp(buf, "large")) { | |
549 new_f = g_new(zframe, 1); | |
550 new_f->enclosing = frames; | |
551 new_f->text = g_string_new("<font size=\"7\">"); | |
552 new_f->closing = "</font>"; | |
553 frames = new_f; | |
554 cnt += end + 1; | |
555 } else if (!g_ascii_strcasecmp(buf, "bold") | |
9896 | 556 || !g_ascii_strcasecmp(buf, "b")) { |
2086 | 557 new_f = g_new(zframe, 1); |
558 new_f->enclosing = frames; | |
559 new_f->text = g_string_new("<b>"); | |
560 new_f->closing = "</b>"; | |
561 new_f->has_closer = TRUE; | |
562 frames = new_f; | |
8644 | 563 cnt += end + 1; |
564 } else if (!g_ascii_strcasecmp(buf, "font")) { | |
565 cnt += end + 1; | |
8451 | 566 new_f = g_new(zframe, 1); |
567 new_f->enclosing = frames; | |
568 new_f->text = g_string_new("<font face="); | |
569 for (; (cnt <= len) && !IS_CLOSER(message[cnt]); cnt++) { | |
570 g_string_append_c(new_f->text, message[cnt]); | |
571 } | |
8644 | 572 cnt++; /* point to char after closer */ |
8451 | 573 g_string_append_c(new_f->text, '>'); |
574 new_f->closing = "</font>"; | |
575 new_f->has_closer = FALSE; | |
576 frames = new_f; | |
8568 | 577 } else if (!g_ascii_strcasecmp(buf, "color")) { |
8644 | 578 cnt += end + 1; |
2086 | 579 new_f = g_new(zframe, 1); |
580 new_f->enclosing = frames; | |
581 new_f->text = g_string_new("<font color="); | |
582 for (; (cnt <= len) && !IS_CLOSER(message[cnt]); cnt++) { | |
583 g_string_append_c(new_f->text, message[cnt]); | |
584 } | |
8644 | 585 cnt++; /* point to char after closer */ |
2086 | 586 g_string_append_c(new_f->text, '>'); |
587 new_f->closing = "</font>"; | |
588 new_f->has_closer = FALSE; | |
589 frames = new_f; | |
4793 | 590 } else if (!g_ascii_strcasecmp(buf, "")) { |
2086 | 591 new_f = g_new(zframe, 1); |
592 new_f->enclosing = frames; | |
593 new_f->text = g_string_new(""); | |
594 new_f->closing = ""; | |
595 new_f->has_closer = TRUE; | |
596 frames = new_f; | |
8644 | 597 cnt += end + 1; /* cnt points to char after opener */ |
2086 | 598 } else { |
8644 | 599 if ((cnt + end) > len) { |
2086 | 600 g_string_append_c(frames->text, '@'); |
601 cnt++; | |
8644 | 602 } else if (IS_CLOSER(message[cnt + end])) { |
603 /* We have @chars..closer . This is | |
604 merely a sequence of chars that isn't a formatting tag | |
9896 | 605 */ |
8644 | 606 int tmp = cnt; |
607 | |
608 while (tmp <= cnt + end) { | |
609 g_string_append_c(frames->text, message[tmp]); | |
610 tmp++; | |
611 } | |
612 cnt += end + 1; | |
613 } else { | |
2086 | 614 /* unrecognized thingie. act like it's not there, but we |
615 * still need to take care of the corresponding closer, | |
616 * make a frame that does nothing. */ | |
617 new_f = g_new(zframe, 1); | |
618 new_f->enclosing = frames; | |
619 new_f->text = g_string_new(""); | |
620 new_f->closing = ""; | |
621 new_f->has_closer = TRUE; | |
622 frames = new_f; | |
8644 | 623 cnt += end + 1; /* cnt points to char after opener */ |
2086 | 624 } |
625 } | |
626 } else if (IS_CLOSER(message[cnt])) { | |
627 zframe *popped; | |
628 gboolean last_had_closer; | |
8644 | 629 |
2086 | 630 if (frames->enclosing) { |
631 do { | |
632 popped = frames; | |
633 frames = frames->enclosing; | |
634 g_string_append(frames->text, popped->text->str); | |
635 g_string_append(frames->text, popped->closing); | |
636 g_string_free(popped->text, TRUE); | |
637 last_had_closer = popped->has_closer; | |
638 g_free(popped); | |
639 } while (frames && frames->enclosing && !last_had_closer); | |
640 } else { | |
641 g_string_append_c(frames->text, message[cnt]); | |
642 } | |
643 cnt++; | |
644 } else if (message[cnt] == '\n') { | |
645 g_string_append(frames->text, "<br>"); | |
646 cnt++; | |
647 } else { | |
648 g_string_append_c(frames->text, message[cnt++]); | |
649 } | |
650 } | |
651 /* go through all the stuff that they didn't close */ | |
652 while (frames->enclosing) { | |
653 curr = frames; | |
654 g_string_append(frames->enclosing->text, frames->text->str); | |
655 g_string_append(frames->enclosing->text, frames->closing); | |
656 g_string_free(frames->text, TRUE); | |
657 frames = frames->enclosing; | |
658 g_free(curr); | |
659 } | |
660 ret = frames->text->str; | |
661 g_string_free(frames->text, FALSE); | |
662 g_free(frames); | |
663 return ret; | |
664 } | |
665 | |
9610 | 666 static gboolean pending_zloc(zephyr_account *zephyr,char *who) |
2086 | 667 { |
668 GList *curr; | |
8644 | 669 |
9610 | 670 for (curr = zephyr->pending_zloc_names; curr != NULL; curr = curr->next) { |
9896 | 671 char* normalized_who = local_zephyr_normalize(zephyr,who); |
9328 | 672 if (!g_ascii_strcasecmp(normalized_who, (char *)curr->data)) { |
8644 | 673 g_free((char *)curr->data); |
9610 | 674 zephyr->pending_zloc_names = g_list_remove(zephyr->pending_zloc_names, curr->data); |
2086 | 675 return TRUE; |
676 } | |
677 } | |
678 return FALSE; | |
679 } | |
680 | |
9328 | 681 /* Called when the server notifies us a message couldn't get sent */ |
682 | |
9610 | 683 static void message_failed(GaimConnection *gc, ZNotice_t notice, struct sockaddr_in from) |
8559 | 684 { |
8644 | 685 if (g_ascii_strcasecmp(notice.z_class, "message")) { |
10690 | 686 gchar* chat_failed = g_strdup_printf(_("Unable to send to chat %s,%s,%s"),notice.z_class,notice.z_class_inst,notice.z_recipient); |
9610 | 687 gaim_notify_error(gc,"",chat_failed,NULL); |
9328 | 688 g_free(chat_failed); |
8644 | 689 } else { |
9610 | 690 gaim_notify_error(gc, notice.z_recipient, _("User is offline"), NULL); |
8644 | 691 } |
8559 | 692 } |
693 | |
10300 | 694 static void handle_message(GaimConnection *gc,ZNotice_t notice) |
2086 | 695 { |
9896 | 696 zephyr_account* zephyr = gc->proto_data; |
697 | |
4793 | 698 if (!g_ascii_strcasecmp(notice.z_class, LOGIN_CLASS)) { |
3277 | 699 /* well, we'll be updating in 20 seconds anyway, might as well ignore this. */ |
4793 | 700 } else if (!g_ascii_strcasecmp(notice.z_class, LOCATE_CLASS)) { |
701 if (!g_ascii_strcasecmp(notice.z_opcode, LOCATE_LOCATE)) { | |
2086 | 702 int nlocs; |
703 char *user; | |
6695 | 704 GaimBuddy *b; |
9478 | 705 /* XXX add real error reporting */ |
2086 | 706 if (ZParseLocations(¬ice, NULL, &nlocs, &user) != ZERR_NONE) |
707 return; | |
8435 | 708 |
9610 | 709 if ((b = gaim_find_buddy(gc->account, user)) == NULL) { |
9986 | 710 char* stripped_user = zephyr_strip_local_realm(zephyr,user); |
711 b = gaim_find_buddy(gc->account,stripped_user); | |
712 g_free(stripped_user); | |
8644 | 713 } |
9896 | 714 if ((b && pending_zloc(zephyr,b->name)) || pending_zloc(zephyr,user)) { |
2086 | 715 ZLocations_t locs; |
716 int one = 1; | |
717 GString *str = g_string_new(""); | |
8644 | 718 |
719 g_string_append_printf(str, _("<b>User:</b> %s<br>"), b ? b->name : user); | |
8435 | 720 if (b && b->alias) |
5132 | 721 g_string_append_printf(str, _("<b>Alias:</b> %s<br>"), b->alias); |
2086 | 722 if (!nlocs) { |
5132 | 723 g_string_append_printf(str, _("<br>Hidden or not logged-in")); |
2086 | 724 } |
725 for (; nlocs > 0; nlocs--) { | |
9478 | 726 /* XXX add real error reporting */ |
2086 | 727 ZGetLocations(&locs, &one); |
8644 | 728 g_string_append_printf(str, _("<br>At %s since %s"), locs.host, locs.time); |
2086 | 729 } |
11533
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11531
diff
changeset
|
730 gaim_notify_userinfo(gc, b ? b->name : user, |
9896 | 731 str->str, NULL, NULL); |
2086 | 732 g_string_free(str, TRUE); |
9986 | 733 } else { |
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
734 if (nlocs>0) |
11638 | 735 gaim_prpl_got_user_status(gc->account,b->name,"available",NULL); |
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
736 else |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
737 gaim_prpl_got_user_status(gc->account,b->name,"offline",NULL); |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
738 } |
2086 | 739 |
9434 | 740 g_free(user); |
2086 | 741 } |
742 } else { | |
8560 | 743 char *buf, *buf2, *buf3; |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
744 char *send_inst; |
8644 | 745 GaimConversation *gconv1; |
746 GaimConvChat *gcc; | |
12624
851b0bd7eb52
[gaim-migrate @ 14960]
Christopher O'Brien <siege@pidgin.im>
parents:
12621
diff
changeset
|
747 char *ptr = (char *) notice.z_message + (strlen(notice.z_message) + 1); |
9478 | 748 int len; |
9896 | 749 char *sendertmp = g_strdup_printf("%s", zephyr->username); |
9478 | 750 int signature_length = strlen(notice.z_message); |
751 int message_has_no_body = 0; | |
12216 | 752 GaimMessageFlags flags = 0; |
9896 | 753 gchar *tmpescape; |
8560 | 754 |
9478 | 755 /* Need to deal with 0 length messages to handle typing notification (OPCODE) ping messages */ |
756 /* One field zephyrs would have caused gaim to crash */ | |
757 if ( (notice.z_message_len == 0) || (signature_length >= notice.z_message_len - 1)) { | |
758 message_has_no_body = 1; | |
759 len = 0; | |
760 gaim_debug_info("zephyr","message_size %d %d %d\n",len,notice.z_message_len,signature_length); | |
761 buf3 = g_strdup(""); | |
762 | |
763 } else { | |
764 len = notice.z_message_len - ( signature_length +1); | |
765 gaim_debug_info("zephyr","message_size %d %d %d\n",len,notice.z_message_len,signature_length); | |
8644 | 766 buf = g_malloc(len + 1); |
767 g_snprintf(buf, len + 1, "%s", ptr); | |
768 g_strchomp(buf); | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10690
diff
changeset
|
769 tmpescape = g_markup_escape_text(buf, -1); |
9478 | 770 g_free(buf); |
8644 | 771 buf2 = zephyr_to_html(tmpescape); |
9610 | 772 buf3 = zephyr_recv_convert(gc,buf2, strlen(buf2)); |
8644 | 773 g_free(buf2); |
774 g_free(tmpescape); | |
9478 | 775 } |
8644 | 776 |
9896 | 777 if (!g_ascii_strcasecmp(notice.z_class, "MESSAGE") && !g_ascii_strcasecmp(notice.z_class_inst, "PERSONAL") |
778 && !g_ascii_strcasecmp(notice.z_recipient,zephyr->username)) { | |
779 gchar* stripped_sender; | |
780 if (!g_ascii_strcasecmp(notice.z_message, "Automated reply:")) | |
12216 | 781 flags |= GAIM_MESSAGE_AUTO_RESP; |
9912 | 782 stripped_sender = zephyr_strip_local_realm(zephyr,notice.z_sender); |
9896 | 783 |
9478 | 784 if (!g_ascii_strcasecmp(notice.z_opcode,"PING")) |
9610 | 785 serv_got_typing(gc,stripped_sender,ZEPHYR_TYPING_RECV_TIMEOUT, GAIM_TYPING); |
9896 | 786 else { |
787 /* Based on the values of | |
788 account->permit_deny, | |
789 account->permit, account>deny , and | |
790 the buddylist */ | |
791 | |
792 GSList* l; | |
793 gboolean in_deny; | |
9478 | 794 |
9896 | 795 switch (gc->account->perm_deny) { |
796 case GAIM_PRIVACY_ALLOW_ALL: | |
797 in_deny = 0; break; | |
798 case GAIM_PRIVACY_DENY_ALL: | |
799 in_deny = 1; break; | |
800 case GAIM_PRIVACY_ALLOW_USERS: /* See if stripped_sender is in gc->account->permit and allow appropriately */ | |
801 in_deny = 1; | |
802 for(l=gc->account->permit;l!=NULL;l=l->next) { | |
803 if (!gaim_utf8_strcasecmp(stripped_sender, gaim_normalize(gc->account, (char *)l->data))) { | |
804 in_deny=0; | |
805 break; | |
806 } | |
807 } | |
808 break; | |
809 case GAIM_PRIVACY_DENY_USERS: /* See if stripped_sender is in gc->account->deny and deny if so */ | |
810 in_deny = 0; | |
811 for(l=gc->account->deny;l!=NULL;l=l->next) { | |
812 if (!gaim_utf8_strcasecmp(stripped_sender, gaim_normalize(gc->account, (char *)l->data))) { | |
813 in_deny=1; | |
814 break; | |
815 } | |
816 } | |
817 break; | |
818 case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
819 in_deny = 1; | |
820 if (gaim_find_buddy(gc->account,stripped_sender)!=NULL) { | |
821 in_deny = 0; | |
822 } | |
823 break; | |
824 default: | |
825 in_deny=0; break; | |
826 } | |
827 | |
828 if (!in_deny) { | |
829 serv_got_im(gc, stripped_sender, buf3, flags, time(NULL)); | |
830 } | |
831 } | |
832 | |
833 g_free(stripped_sender); | |
834 } else { | |
835 zephyr_triple *zt1, *zt2; | |
836 gchar *send_inst_utf8; | |
837 zephyr_account *zephyr = gc->proto_data; | |
838 zt1 = new_triple(gc->proto_data,notice.z_class, notice.z_class_inst, notice.z_recipient); | |
839 zt2 = find_sub_by_triple(gc->proto_data,zt1); | |
840 if (!zt2) { | |
841 /* This is a server supplied subscription */ | |
842 zephyr->subscrips = g_slist_append(zephyr->subscrips, new_triple(zephyr,zt1->class,zt1->instance,zt1->recipient)); | |
9610 | 843 zt2 = find_sub_by_triple(gc->proto_data,zt1); |
9896 | 844 } |
845 | |
846 if (!zt2->open) { | |
847 zt2->open = TRUE; | |
848 serv_got_joined_chat(gc, zt2->id, zt2->name); | |
849 zephyr_chat_set_topic(gc,zt2->id,notice.z_class_inst); | |
850 } | |
851 g_free(sendertmp); /* fix memory leak? */ | |
852 /* If the person is in the default Realm, then strip the | |
853 Realm from the sender field */ | |
9912 | 854 sendertmp = zephyr_strip_local_realm(zephyr,notice.z_sender); |
9896 | 855 send_inst = g_strdup_printf("%s %s",sendertmp,notice.z_class_inst); |
856 send_inst_utf8 = zephyr_recv_convert(gc,send_inst, strlen(send_inst)); | |
857 if (!send_inst_utf8) { | |
10867 | 858 gaim_debug_error("zephyr","send_inst %s became null\n", send_inst); |
9896 | 859 send_inst_utf8 = "malformed instance"; |
2086 | 860 } |
9912 | 861 |
9896 | 862 serv_got_chat_in(gc, zt2->id, send_inst_utf8, 0, buf3, time(NULL)); |
863 g_free(send_inst); | |
11338 | 864 gconv1 = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, |
10246 | 865 zt2->name, gc->account); |
9896 | 866 gcc = gaim_conversation_get_chat_data(gconv1); |
9912 | 867 |
9896 | 868 if (!gaim_conv_chat_find_user(gcc, sendertmp)) { |
869 /* force interpretation in network byte order */ | |
870 unsigned char *addrs = (unsigned char *)&(notice.z_sender_addr.s_addr); | |
871 gchar* ipaddr = g_strdup_printf("%hhd.%hhd.%hhd.%hhd", (unsigned char)addrs[0], | |
872 (unsigned char)addrs[1], (unsigned char)addrs[2], | |
873 (unsigned char) addrs[3]); | |
874 | |
875 gaim_conv_chat_add_user(gcc, sendertmp, ipaddr, GAIM_CBFLAGS_NONE, TRUE); | |
876 g_free(ipaddr); /* fix memory leak? */ | |
877 | |
878 } | |
879 g_free(sendertmp); | |
880 g_free(send_inst_utf8); | |
881 | |
882 free_triple(zt1); | |
883 } | |
884 g_free(buf3); | |
9478 | 885 |
2086 | 886 } |
887 } | |
12424
7c2e2c4d45a4
[gaim-migrate @ 14731]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
888 |
7c2e2c4d45a4
[gaim-migrate @ 14731]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
889 static int free_parse_tree(parse_tree* tree) { |
9896 | 890 if (!tree) { |
891 return 0; | |
892 } | |
893 else { | |
894 int i; | |
895 if (tree->children) { | |
896 for(i=0;i<tree->num_children;i++){ | |
897 if (tree->children[i]) { | |
898 free_parse_tree(tree->children[i]); | |
899 g_free(tree->children[i]); | |
900 } | |
901 } | |
902 } | |
903 if ((tree != &null_parse_tree) && (tree->contents != NULL)) | |
904 g_free(tree->contents); | |
2086 | 905 |
9896 | 906 } |
907 return 0; | |
908 } | |
909 | |
12424
7c2e2c4d45a4
[gaim-migrate @ 14731]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
910 static parse_tree *tree_child(parse_tree* tree,int index) { |
9896 | 911 if (index < tree->num_children) { |
912 return tree->children[index]; | |
913 } else { | |
914 return &null_parse_tree; | |
915 } | |
916 } | |
917 | |
12424
7c2e2c4d45a4
[gaim-migrate @ 14731]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
918 static parse_tree *find_node(parse_tree* ptree,gchar* key) |
9896 | 919 { |
920 gchar* tc = tree_child(ptree,0)->contents; | |
921 | |
922 if (!ptree || ! key) | |
923 return &null_parse_tree; | |
924 | |
925 if (ptree->num_children > 0 && tc && !strcasecmp(tc, key)) { | |
926 return ptree; | |
927 } else { | |
928 parse_tree *result = &null_parse_tree; | |
929 int i; | |
930 for(i = 0; i < ptree->num_children; i++) { | |
931 result = find_node(ptree->children[i],key); | |
932 if(result != &null_parse_tree) { | |
933 break; | |
934 } | |
935 } | |
936 return result; | |
937 } | |
938 } | |
939 | |
12424
7c2e2c4d45a4
[gaim-migrate @ 14731]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
940 static parse_tree *parse_buffer(gchar* source, gboolean do_parse) { |
9896 | 941 |
942 parse_tree *ptree = g_new0(parse_tree,1); | |
943 ptree->contents = NULL; | |
944 ptree->num_children=0; | |
945 if (do_parse) { | |
946 unsigned int p = 0; | |
947 while(p < strlen(source)) { | |
948 unsigned int end; | |
9986 | 949 gchar *newstr; |
9896 | 950 |
951 /* Eat white space: */ | |
952 if(g_ascii_isspace(source[p]) || source[p] == '\001') { | |
953 p++; | |
954 continue; | |
955 } | |
956 | |
957 /* Skip comments */ | |
958 if(source[p] == ';') { | |
959 while(source[p] != '\n' && p < strlen(source)) { | |
960 p++; | |
961 } | |
962 continue; | |
963 } | |
964 | |
965 if(source[p] == '(') { | |
966 int nesting = 0; | |
967 gboolean in_quote = FALSE; | |
968 gboolean escape_next = FALSE; | |
969 p++; | |
970 end = p; | |
971 while(!(source[end] == ')' && nesting == 0 && !in_quote) && end < strlen(source)) { | |
972 if(!escape_next) { | |
973 if(source[end] == '\\') { | |
974 escape_next = TRUE; | |
975 } | |
976 if(!in_quote) { | |
977 if(source[end] == '(') { | |
978 nesting++; | |
979 } | |
980 if(source[end] == ')') { | |
981 nesting--; | |
982 } | |
983 } | |
984 if(source[end] == '"') { | |
985 in_quote = !in_quote; | |
986 } | |
987 } else { | |
988 escape_next = FALSE; | |
989 } | |
990 end++; | |
991 } | |
992 do_parse = TRUE; | |
993 | |
994 } else { | |
995 gchar end_char; | |
996 if(source[p] == '"') { | |
997 end_char = '"'; | |
998 p++; | |
999 } else { | |
1000 end_char = ' '; | |
1001 } | |
1002 do_parse = FALSE; | |
1003 | |
1004 end = p; | |
1005 while(source[end] != end_char && end < strlen(source)) { | |
1006 if(source[end] == '\\') | |
1007 end++; | |
1008 end++; | |
1009 } | |
1010 } | |
1011 newstr = g_new0(gchar, end+1-p); | |
1012 strncpy(newstr,source+p,end-p); | |
1013 if (ptree->num_children < MAXCHILDREN) { | |
1014 /* In case we surpass maxchildren, ignore this */ | |
1015 ptree->children[ptree->num_children++] = parse_buffer( newstr, do_parse); | |
1016 } else { | |
1017 gaim_debug_error("zephyr","too many children in tzc output. skipping\n"); | |
1018 } | |
1019 g_free(newstr); | |
1020 p = end + 1; | |
1021 } | |
1022 return ptree; | |
1023 } else { | |
1024 /* XXX does this have to be strdup'd */ | |
1025 ptree->contents = g_strdup(source); | |
1026 return ptree; | |
1027 } | |
1028 } | |
1029 | |
12424
7c2e2c4d45a4
[gaim-migrate @ 14731]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1030 static parse_tree *read_from_tzc(zephyr_account* zephyr){ |
9896 | 1031 struct timeval tv; |
1032 fd_set rfds; | |
1033 int bufsize = 2048; | |
1034 char *buf = (char *)calloc(bufsize, 1); | |
1035 char *bufcur = buf; | |
1036 int selected = 0; | |
9986 | 1037 parse_tree *incoming_msg; |
9896 | 1038 |
1039 FD_ZERO(&rfds); | |
1040 FD_SET(zephyr->fromtzc[ZEPHYR_FD_READ], &rfds); | |
1041 tv.tv_sec = 0; | |
1042 tv.tv_usec = 0; | |
9986 | 1043 incoming_msg=NULL; |
9896 | 1044 |
1045 while (select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, &tv)) { | |
1046 selected = 1; | |
1047 read(zephyr->fromtzc[ZEPHYR_FD_READ], bufcur, 1); | |
1048 bufcur++; | |
1049 if ((bufcur - buf) > (bufsize - 1)) { | |
1050 if ((buf = realloc(buf, bufsize * 2)) == NULL) { | |
1051 gaim_debug_error("zephyr","Ran out of memory"); | |
1052 exit(-1); | |
1053 } else { | |
1054 bufcur = buf + bufsize; | |
1055 bufsize *= 2; | |
1056 } | |
1057 } | |
1058 } | |
1059 *bufcur = '\0'; | |
1060 | |
1061 if (selected) { | |
1062 incoming_msg = parse_buffer(buf,TRUE); | |
1063 } | |
1064 free(buf); | |
1065 return incoming_msg; | |
1066 } | |
1067 | |
1068 static gint check_notify_tzc(gpointer data) | |
1069 { | |
1070 GaimConnection *gc = (GaimConnection *)data; | |
1071 zephyr_account* zephyr = gc->proto_data; | |
1072 parse_tree *newparsetree = read_from_tzc(zephyr); | |
1073 if (newparsetree != NULL) { | |
1074 gchar *spewtype; | |
1075 if ( (spewtype = tree_child(find_node(newparsetree,"tzcspew"),2)->contents) ) { | |
1076 if (!g_ascii_strncasecmp(spewtype,"message",7)) { | |
1077 ZNotice_t notice; | |
1078 parse_tree *msgnode = tree_child(find_node(newparsetree,"message"),2); | |
1079 parse_tree *bodynode = tree_child(msgnode,1); | |
1080 /* char *zsig = g_strdup(" "); */ /* gaim doesn't care about zsigs */ | |
1081 char *msg = zephyr_tzc_deescape_str(bodynode->contents); | |
1082 size_t bufsize = strlen(msg) + 3; | |
1083 char *buf = g_new0(char,bufsize); | |
1084 g_snprintf(buf,1+strlen(msg)+2," %c%s",'\0',msg); | |
1085 bzero((char *)¬ice, sizeof(notice)); | |
1086 notice.z_kind = ACKED; | |
1087 notice.z_port = 0; | |
1088 notice.z_opcode = tree_child(find_node(newparsetree,"opcode"),2)->contents; | |
1089 notice.z_class = zephyr_tzc_deescape_str(tree_child(find_node(newparsetree,"class"),2)->contents); | |
1090 notice.z_class_inst = tree_child(find_node(newparsetree,"instance"),2)->contents; | |
1091 notice.z_recipient = local_zephyr_normalize(zephyr,tree_child(find_node(newparsetree,"recipient"),2)->contents); | |
1092 notice.z_sender = local_zephyr_normalize(zephyr,tree_child(find_node(newparsetree,"sender"),2)->contents); | |
1093 notice.z_default_format = "Class $class, Instance $instance:\n" "To: @bold($recipient) at $time $date\n" "From: @bold($1) <$sender>\n\n$2"; | |
1094 notice.z_message_len = strlen(msg) + 3; | |
1095 notice.z_message = buf; | |
10300 | 1096 handle_message(gc, notice); |
9896 | 1097 g_free(msg); |
1098 /* g_free(zsig); */ | |
1099 g_free(buf); | |
1100 /* free_parse_tree(msgnode); | |
1101 free_parse_tree(bodynode); | |
1102 g_free(msg); | |
1103 g_free(zsig); | |
1104 g_free(buf); | |
1105 */ | |
1106 } | |
1107 else if (!g_ascii_strncasecmp(spewtype,"zlocation",9)) { | |
1108 /* check_loc or zephyr_zloc respectively */ | |
1109 /* XXX fix */ | |
1110 char *user; | |
1111 GaimBuddy *b; | |
1112 int nlocs = 0; | |
9912 | 1113 parse_tree *locations; |
1114 gchar *locval; | |
9896 | 1115 user = tree_child(find_node(newparsetree,"user"),2)->contents; |
1116 | |
1117 if ((b = gaim_find_buddy(gc->account, user)) == NULL) { | |
9986 | 1118 gchar *stripped_user = zephyr_strip_local_realm(zephyr,user); |
9912 | 1119 b = gaim_find_buddy(gc->account, stripped_user); |
9986 | 1120 g_free(stripped_user); |
9896 | 1121 } |
1122 locations = find_node(newparsetree,"locations"); | |
1123 locval = tree_child(tree_child(tree_child(tree_child(locations,2),0),0),2)->contents; | |
1124 | |
1125 if (!locval || !g_ascii_strcasecmp(locval," ") || (strlen(locval) == 0)) { | |
1126 nlocs = 0; | |
1127 } else { | |
1128 nlocs = 1; | |
1129 } | |
1130 | |
1131 if ((b && pending_zloc(zephyr,b->name)) || pending_zloc(zephyr,user) || pending_zloc(zephyr,local_zephyr_normalize(zephyr,user))){ | |
1132 GString *str = g_string_new(""); | |
1133 | |
1134 g_string_append_printf(str, _("<b>User:</b> %s<br>"), b ? b->name : user); | |
1135 if (b && b->alias) | |
1136 g_string_append_printf(str, _("<b>Alias:</b> %s<br>"), b->alias); | |
1137 | |
1138 if (!nlocs) { | |
1139 g_string_append_printf(str, _("<br>Hidden or not logged-in")); | |
1140 } else { | |
1141 g_string_append_printf(str, _("<br>At %s since %s"), | |
1142 tree_child(tree_child(tree_child(tree_child(locations,2),0),0),2)->contents, | |
1143 tree_child(tree_child(tree_child(tree_child(locations,2),0),2),2)->contents); | |
1144 } | |
1145 | |
11533
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11531
diff
changeset
|
1146 gaim_notify_userinfo(gc, b ? b->name : user, |
9896 | 1147 str->str, NULL, NULL); |
1148 g_string_free(str, TRUE); | |
1149 } else { | |
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1150 if (nlocs>0) |
11638 | 1151 gaim_prpl_got_user_status(gc->account,b->name,"available",NULL); |
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1152 else |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1153 gaim_prpl_got_user_status(gc->account,b->name,"offline",NULL); |
9896 | 1154 } |
1155 } | |
1156 else if (!g_ascii_strncasecmp(spewtype,"subscribed",10)) { | |
1157 } | |
1158 else if (!g_ascii_strncasecmp(spewtype,"start",5)) { | |
1159 } | |
1160 else if (!g_ascii_strncasecmp(spewtype,"error",5)) { | |
1161 /* XXX handle */ | |
1162 } | |
1163 } else { | |
1164 } | |
1165 } else { | |
1166 } | |
1167 | |
1168 free_parse_tree(newparsetree); | |
1169 return TRUE; | |
1170 } | |
1171 | |
1172 static gint check_notify_zeph02(gpointer data) | |
2086 | 1173 { |
9478 | 1174 /* XXX add real error reporting */ |
9896 | 1175 GaimConnection *gc = (GaimConnection*) data; |
2086 | 1176 while (ZPending()) { |
1177 ZNotice_t notice; | |
1178 struct sockaddr_in from; | |
9478 | 1179 /* XXX add real error reporting */ |
8644 | 1180 |
2086 | 1181 z_call_r(ZReceiveNotice(¬ice, &from)); |
1182 | |
1183 switch (notice.z_kind) { | |
1184 case UNSAFE: | |
1185 case UNACKED: | |
1186 case ACKED: | |
10300 | 1187 handle_message(gc,notice); |
2086 | 1188 break; |
8644 | 1189 case SERVACK: |
1190 if (!(g_ascii_strcasecmp(notice.z_message, ZSRVACK_NOTSENT))) { | |
9610 | 1191 message_failed(gc,notice, from); |
8644 | 1192 } |
1193 break; | |
9328 | 1194 case CLIENTACK: |
9478 | 1195 gaim_debug_error("zephyr", "Client ack received\n"); |
2086 | 1196 default: |
1197 /* we'll just ignore things for now */ | |
9328 | 1198 handle_unknown(notice); |
9478 | 1199 gaim_debug_error("zephyr", "Unhandled notice.\n"); |
2086 | 1200 break; |
1201 } | |
9478 | 1202 /* XXX add real error reporting */ |
2086 | 1203 ZFreeNotice(¬ice); |
1204 } | |
1205 | |
1206 return TRUE; | |
1207 } | |
1208 | |
10867 | 1209 #ifdef WIN32 |
1210 | |
1211 static gint check_loc(gpointer_data) | |
1212 { | |
1213 GaimBlistNode *gnode, *cnode, *bnode; | |
1214 ZLocations_t locations; | |
1215 int numlocs; | |
1216 int one = 1; | |
1217 | |
1218 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { | |
1219 if (!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
1220 continue; | |
1221 for (cnode = gnode->child; cnode; cnode = cnode->next) { | |
1222 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
1223 continue; | |
1224 for (bnode = cnode->child; bnode; bnode = bnode->next) { | |
1225 GaimBuddy *b = (GaimBuddy *) bnode; | |
1226 | |
1227 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
1228 continue; | |
1229 if (b->account->gc == zgc) { | |
1230 char *chk; | |
1231 chk = local_zephyr_normalize(b->name); | |
1232 ZLocateUser(chk,&numlocs, ZAUTH); | |
1233 if (numlocs) { | |
1234 int i; | |
1235 for(i=0;i<numlocs;i++) { | |
1236 ZGetLocations(&locations,&one); | |
1237 serv_got_update(zgc,b->name,1,0,0,0,0); | |
1238 } | |
1239 } | |
1240 } | |
1241 } | |
1242 } | |
1243 } | |
1244 return TRUE; | |
1245 } | |
1246 | |
1247 #else | |
1248 | |
2086 | 1249 static gint check_loc(gpointer data) |
1250 { | |
6695 | 1251 GaimBlistNode *gnode, *cnode, *bnode; |
2086 | 1252 ZAsyncLocateData_t ald; |
9896 | 1253 GaimConnection *gc = (GaimConnection *)data; |
1254 zephyr_account *zephyr = gc->proto_data; | |
2086 | 1255 |
9896 | 1256 if (use_zeph02(zephyr)) { |
1257 ald.user = NULL; | |
1258 memset(&(ald.uid), 0, sizeof(ZUnique_Id_t)); | |
1259 ald.version = NULL; | |
1260 } | |
2086 | 1261 |
8644 | 1262 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
1263 if (!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
4785 | 1264 continue; |
8644 | 1265 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
1266 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 1267 continue; |
8644 | 1268 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
1269 GaimBuddy *b = (GaimBuddy *) bnode; | |
1270 | |
1271 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
6695 | 1272 continue; |
9610 | 1273 if (b->account->gc == gc) { |
7261 | 1274 const char *chk; |
8644 | 1275 |
9896 | 1276 chk = local_zephyr_normalize(zephyr,b->name); |
1277 gaim_debug_info("zephyr","chk: %s b->name %s\n",chk,b->name); | |
9478 | 1278 /* XXX add real error reporting */ |
6695 | 1279 /* doesn't matter if this fails or not; we'll just move on to the next one */ |
9896 | 1280 if (use_zeph02(zephyr)) { |
1281 #ifdef WIN32 | |
9986 | 1282 int numlocs; |
1283 int one=1; | |
1284 ZLocateUser(chk,&numlocs,ZAUTH); | |
1285 if (numlocs) { | |
1286 int i; | |
1287 for(i=0;i<numlocs;i++) { | |
1288 ZGetLocations(&locations,&one); | |
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1289 if (nlocs>0) |
11638 | 1290 gaim_prpl_got_user_status(gc->account,b->name,"available",NULL); |
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1291 else |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1292 gaim_prpl_got_user_status(gc->account,b->name,"offline",NULL); |
9986 | 1293 } |
1294 } | |
9896 | 1295 #else |
1296 ZRequestLocations(chk, &ald, UNACKED, ZAUTH); | |
1297 g_free(ald.user); | |
1298 g_free(ald.version); | |
1299 #endif /* WIN32 */ | |
1300 } else | |
1301 if (use_tzc(zephyr)) { | |
1302 gchar *zlocstr = g_strdup_printf("((tzcfodder . zlocate) \"%s\")\n",chk); | |
1303 write(zephyr->totzc[ZEPHYR_FD_WRITE],zlocstr,strlen(zlocstr)); | |
1304 g_free(zlocstr); | |
1305 } | |
6695 | 1306 } |
4349 | 1307 } |
2086 | 1308 } |
1309 } | |
9896 | 1310 |
2086 | 1311 return TRUE; |
1312 } | |
1313 | |
10867 | 1314 #endif /* WIN32 */ |
1315 | |
2086 | 1316 static char *get_exposure_level() |
1317 { | |
9478 | 1318 /* XXX add real error reporting */ |
2086 | 1319 char *exposure = ZGetVariable("exposure"); |
1320 | |
1321 if (!exposure) | |
1322 return EXPOSE_REALMVIS; | |
4793 | 1323 if (!g_ascii_strcasecmp(exposure, EXPOSE_NONE)) |
2086 | 1324 return EXPOSE_NONE; |
4793 | 1325 if (!g_ascii_strcasecmp(exposure, EXPOSE_OPSTAFF)) |
2086 | 1326 return EXPOSE_OPSTAFF; |
4793 | 1327 if (!g_ascii_strcasecmp(exposure, EXPOSE_REALMANN)) |
2086 | 1328 return EXPOSE_REALMANN; |
4793 | 1329 if (!g_ascii_strcasecmp(exposure, EXPOSE_NETVIS)) |
2086 | 1330 return EXPOSE_NETVIS; |
4793 | 1331 if (!g_ascii_strcasecmp(exposure, EXPOSE_NETANN)) |
2086 | 1332 return EXPOSE_NETANN; |
1333 return EXPOSE_REALMVIS; | |
1334 } | |
1335 | |
1336 static void strip_comments(char *str) | |
1337 { | |
1338 char *tmp = strchr(str, '#'); | |
8644 | 1339 |
2086 | 1340 if (tmp) |
1341 *tmp = '\0'; | |
1342 g_strchug(str); | |
1343 g_strchomp(str); | |
1344 } | |
1345 | |
9896 | 1346 static void zephyr_inithosts(zephyr_account *zephyr) |
9478 | 1347 { |
1348 /* XXX This code may not be Win32 clean */ | |
1349 struct hostent *hent; | |
1350 | |
9802 | 1351 if (gethostname(zephyr->ourhost, sizeof(zephyr->ourhost)) == -1) { |
10867 | 1352 gaim_debug_error("zephyr", "unable to retrieve hostname, %%host%% and %%canon%% will be wrong in subscriptions and have been set to unknown\n"); |
9802 | 1353 g_strlcpy(zephyr->ourhost, "unknown", sizeof(zephyr->ourhost)); |
9803 | 1354 g_strlcpy(zephyr->ourhostcanon, "unknown", sizeof(zephyr->ourhostcanon)); |
9478 | 1355 return; |
1356 } | |
1357 | |
9610 | 1358 if (!(hent = gethostbyname(zephyr->ourhost))) { |
10867 | 1359 gaim_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 | 1360 g_strlcpy(zephyr->ourhostcanon, zephyr->ourhost, sizeof(zephyr->ourhostcanon)); |
9478 | 1361 return; |
1362 } | |
9802 | 1363 |
1364 g_strlcpy(zephyr->ourhostcanon, hent->h_name, sizeof(zephyr->ourhostcanon)); | |
1365 | |
9478 | 1366 return; |
1367 } | |
1368 | |
9610 | 1369 static void process_zsubs(zephyr_account *zephyr) |
2086 | 1370 { |
9802 | 1371 /* Loads zephyr chats "(subscriptions) from ~/.zephyr.subs, and |
1372 registers (subscribes to) them on the server */ | |
9434 | 1373 |
9802 | 1374 /* XXX deal with unsubscriptions */ |
1375 /* XXX deal with punts */ | |
9434 | 1376 |
2086 | 1377 FILE *f; |
1378 gchar *fname; | |
1379 gchar buff[BUFSIZ]; | |
8644 | 1380 |
3630 | 1381 fname = g_strdup_printf("%s/.zephyr.subs", gaim_home_dir()); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10401
diff
changeset
|
1382 f = g_fopen(fname, "r"); |
2086 | 1383 if (f) { |
1384 char **triple; | |
1385 char *recip; | |
9478 | 1386 char *z_class; |
1387 char *z_instance; | |
9896 | 1388 char *z_galaxy = NULL; |
8644 | 1389 |
2086 | 1390 while (fgets(buff, BUFSIZ, f)) { |
1391 strip_comments(buff); | |
1392 if (buff[0]) { | |
1393 triple = g_strsplit(buff, ",", 3); | |
8644 | 1394 if (triple[0] && triple[1]) { |
9896 | 1395 char *tmp = g_strdup_printf("%s", zephyr->username); |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1396 char *atptr; |
8644 | 1397 |
9896 | 1398 z_class = triple[0]; |
1399 z_instance = triple[1]; | |
8644 | 1400 if (triple[2] == NULL) { |
3277 | 1401 recip = g_malloc0(1); |
4793 | 1402 } else if (!g_ascii_strcasecmp(triple[2], "%me%")) { |
9896 | 1403 recip = g_strdup_printf("%s", zephyr->username); |
4793 | 1404 } else if (!g_ascii_strcasecmp(triple[2], "*")) { |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1405 /* wildcard |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1406 * form of class,instance,* */ |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1407 recip = g_malloc0(1); |
4793 | 1408 } else if (!g_ascii_strcasecmp(triple[2], tmp)) { |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1409 /* form of class,instance,aatharuv@ATHENA.MIT.EDU */ |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1410 recip = g_strdup(triple[2]); |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1411 } else if ((atptr = strchr(triple[2], '@')) != NULL) { |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1412 /* form of class,instance,*@ANDREW.CMU.EDU |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1413 * class,instance,@ANDREW.CMU.EDU |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1414 * If realm is local realm, blank recipient, else |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1415 * @REALM-NAME |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1416 */ |
9896 | 1417 char *realmat = g_strdup_printf("@%s",zephyr->realm); |
8644 | 1418 |
4793 | 1419 if (!g_ascii_strcasecmp(atptr, realmat)) |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1420 recip = g_malloc0(1); |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1421 else |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1422 recip = g_strdup(atptr); |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1423 g_free(realmat); |
2086 | 1424 } else { |
1425 recip = g_strdup(triple[2]); | |
1426 } | |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
1427 g_free(tmp); |
9478 | 1428 |
1429 if (!g_ascii_strcasecmp(triple[0],"%host%")) { | |
9610 | 1430 z_class = g_strdup(zephyr->ourhost); |
9478 | 1431 } else if (!g_ascii_strcasecmp(triple[0],"%canon%")) { |
9610 | 1432 z_class = g_strdup(zephyr->ourhostcanon); |
9478 | 1433 } else { |
1434 z_class = g_strdup(triple[0]); | |
1435 } | |
1436 | |
1437 if (!g_ascii_strcasecmp(triple[1],"%host%")) { | |
9610 | 1438 z_instance = g_strdup(zephyr->ourhost); |
9478 | 1439 } else if (!g_ascii_strcasecmp(triple[1],"%canon%")) { |
9610 | 1440 z_instance = g_strdup(zephyr->ourhostcanon); |
9478 | 1441 } else { |
1442 z_instance = g_strdup(triple[1]); | |
1443 } | |
1444 | |
1445 /* There should be some sort of error report listing classes that couldn't be subbed to. | |
1446 Not important right now though */ | |
1447 | |
9896 | 1448 if (zephyr_subscribe_to(zephyr,z_class, z_instance, recip,z_galaxy) != ZERR_NONE) { |
9478 | 1449 |
10867 | 1450 gaim_debug_error("zephyr", "Couldn't subscribe to %s, %s, %s\n", z_class,z_instance,recip); |
2086 | 1451 } |
9478 | 1452 |
9896 | 1453 zephyr->subscrips = g_slist_append(zephyr->subscrips, new_triple(zephyr,z_class,z_instance,recip)); |
9478 | 1454 /* g_hash_table_destroy(sub_hash_table); */ |
1455 g_free(z_instance); | |
1456 g_free(z_class); | |
2086 | 1457 g_free(recip); |
1458 } | |
1459 g_strfreev(triple); | |
1460 } | |
1461 } | |
1462 } | |
1463 } | |
1464 | |
9610 | 1465 static void process_anyone(GaimConnection *gc) |
2086 | 1466 { |
1467 FILE *fd; | |
1468 gchar buff[BUFSIZ], *filename; | |
6695 | 1469 GaimGroup *g; |
1470 GaimBuddy *b; | |
4775 | 1471 |
1472 if (!(g = gaim_find_group(_("Anyone")))) { | |
1473 g = gaim_group_new(_("Anyone")); | |
1474 gaim_blist_add_group(g, NULL); | |
1475 } | |
6695 | 1476 |
3630 | 1477 filename = g_strconcat(gaim_home_dir(), "/.anyone", NULL); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10401
diff
changeset
|
1478 if ((fd = g_fopen(filename, "r")) != NULL) { |
2086 | 1479 while (fgets(buff, BUFSIZ, fd)) { |
1480 strip_comments(buff); | |
4687 | 1481 if (buff[0]) { |
9610 | 1482 if (!(b = gaim_find_buddy(gc->account, buff))) { |
9986 | 1483 char *stripped_user = zephyr_strip_local_realm(gc->proto_data,buff); |
1484 gaim_debug_info("zephyr","stripped_user %s\n",stripped_user); | |
1485 if (!(b = gaim_find_buddy(gc->account,stripped_user))){ | |
1486 b = gaim_buddy_new(gc->account, stripped_user, NULL); | |
1487 gaim_blist_add_buddy(b, NULL, g, NULL); | |
1488 } | |
1489 g_free(stripped_user); | |
8644 | 1490 } |
1491 } | |
2086 | 1492 } |
1493 fclose(fd); | |
1494 } | |
1495 g_free(filename); | |
1496 } | |
1497 | |
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1498 static char* normalize_zephyr_exposure(const char* exposure) { |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1499 char *exp2 = g_strstrip(g_ascii_strup(exposure,-1)); |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1500 |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1501 if (!exp2) |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1502 return EXPOSE_REALMVIS; |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1503 if (!g_ascii_strcasecmp(exp2, EXPOSE_NONE)) |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1504 return EXPOSE_NONE; |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1505 if (!g_ascii_strcasecmp(exp2, EXPOSE_OPSTAFF)) |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1506 return EXPOSE_OPSTAFF; |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1507 if (!g_ascii_strcasecmp(exp2, EXPOSE_REALMANN)) |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1508 return EXPOSE_REALMANN; |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1509 if (!g_ascii_strcasecmp(exp2, EXPOSE_NETVIS)) |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1510 return EXPOSE_NETVIS; |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1511 if (!g_ascii_strcasecmp(exp2, EXPOSE_NETANN)) |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1512 return EXPOSE_NETANN; |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1513 return EXPOSE_REALMVIS; |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1514 } |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1515 |
11837 | 1516 static void zephyr_login(GaimAccount * account) |
2086 | 1517 { |
9896 | 1518 GaimConnection *gc; |
1519 zephyr_account *zephyr; | |
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1520 gboolean read_anyone; |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1521 gboolean read_zsubs; |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1522 gchar *exposure; |
9427 | 1523 |
9610 | 1524 gc = gaim_account_get_connection(account); |
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1525 read_anyone = gaim_account_get_bool(gc->account,"read_anyone",TRUE); |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1526 read_zsubs = gaim_account_get_bool(gc->account,"read_zsubs",TRUE); |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1527 exposure = (gchar *)gaim_account_get_string(gc->account, "exposure_level", EXPOSE_REALMVIS); |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1528 |
10867 | 1529 #ifdef WIN32 |
1530 username = gaim_account_get_username(account); | |
1531 #endif | |
9610 | 1532 gc->flags |= GAIM_CONNECTION_HTML | GAIM_CONNECTION_NO_BGCOLOR | GAIM_CONNECTION_NO_URLDESC; |
9896 | 1533 gc->proto_data = zephyr=g_new0(zephyr_account,1); |
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1534 |
9896 | 1535 zephyr->account = account; |
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1536 |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1537 /* Make sure that the exposure (visibility) is set to a sane value */ |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1538 zephyr->exposure=g_strdup(normalize_zephyr_exposure(exposure)); |
2086 | 1539 |
9896 | 1540 if (gaim_account_get_bool(gc->account,"use_tzc",0)) { |
1541 zephyr->connection_type = GAIM_ZEPHYR_TZC; | |
1542 } else { | |
1543 zephyr->connection_type = GAIM_ZEPHYR_KRB4; | |
1544 } | |
1545 | |
1546 zephyr->encoding = (char *)gaim_account_get_string(gc->account, "encoding", ZEPHYR_FALLBACK_CHARSET); | |
9610 | 1547 gaim_connection_update_progress(gc, _("Connecting"), 0, 8); |
9478 | 1548 |
1549 /* XXX z_call_s should actually try to report the com_err determined error */ | |
9896 | 1550 if (use_tzc(zephyr)) { |
1551 pid_t pid; | |
1552 /* gaim_connection_error(gc,"tzc not supported yet"); */ | |
1553 if ((pipe(zephyr->totzc) != 0) || (pipe(zephyr->fromtzc) != 0)) { | |
1554 gaim_debug_error("zephyr", "pipe creation failed. killing\n"); | |
1555 exit(-1); | |
1556 } | |
1557 | |
1558 pid = fork(); | |
1559 | |
1560 if (pid == -1) { | |
1561 gaim_debug_error("zephyr", "forking failed\n"); | |
1562 exit(-1); | |
1563 } | |
1564 if (pid == 0) { | |
1565 unsigned int i=0; | |
1566 gboolean found_ps = FALSE; | |
1567 gchar ** tzc_cmd_array = g_strsplit(gaim_account_get_string(gc->account,"tzc_command","/usr/bin/tzc -e %s")," ",0); | |
1568 if (close(1) == -1) { | |
1569 gaim_debug_error("zephyr", "stdout couldn't be closed. dying\n"); | |
1570 exit(-1); | |
1571 } | |
1572 if (dup2(zephyr->fromtzc[1], 1) == -1) { | |
1573 gaim_debug_error("zephyr", "dup2 of stdout failed \n"); | |
1574 exit(-1); | |
1575 } | |
1576 if (close(zephyr->fromtzc[1]) == -1) { | |
1577 gaim_debug_error("zephyr", "closing of piped stdout failed\n"); | |
1578 exit(-1); | |
1579 } | |
1580 if (close(0) == -1) { | |
1581 gaim_debug_error("zephyr", "stdin couldn't be closed. dying\n"); | |
1582 exit(-1); | |
1583 } | |
1584 if (dup2(zephyr->totzc[0], 0) == -1) { | |
1585 gaim_debug_error("zephyr", "dup2 of stdin failed \n"); | |
1586 exit(-1); | |
1587 } | |
1588 if (close(zephyr->totzc[0]) == -1) { | |
1589 gaim_debug_error("zephyr", "closing of piped stdin failed\n"); | |
1590 exit(-1); | |
1591 } | |
1592 /* tzc_command should really be of the form | |
1593 path/to/tzc -e %s | |
1594 or | |
1595 ssh username@hostname pathtotzc -e %s | |
1596 -- this should not require a password, and ideally should be kerberized ssh -- | |
1597 or | |
1598 fsh username@hostname pathtotzc -e %s | |
1599 */ | |
1600 while(tzc_cmd_array[i] != NULL){ | |
12621 | 1601 if (!g_ascii_strncasecmp(tzc_cmd_array[i],"%s",2)) { |
9986 | 1602 /* fprintf(stderr,"replacing %%s with %s\n",zephyr->exposure); */ |
9896 | 1603 tzc_cmd_array[i] = g_strdup(zephyr->exposure); |
1604 found_ps = TRUE; | |
1605 | |
1606 } else { | |
9986 | 1607 /* fprintf(stderr,"keeping %s\n",tzc_cmd_array[i]); */ |
9896 | 1608 } |
1609 i++; | |
1610 } | |
8645 | 1611 |
9896 | 1612 if (!found_ps) { |
1613 gaim_connection_error(gc,"Tzc command needs %s to set the exposure\n"); | |
1614 return; | |
1615 } | |
1616 | |
1617 execvp(tzc_cmd_array[0], tzc_cmd_array); | |
1618 } | |
1619 else { | |
1620 fd_set rfds; | |
1621 int bufsize = 2048; | |
1622 char *buf = (char *)calloc(bufsize, 1); | |
1623 char *bufcur = buf; | |
1624 struct timeval tv; | |
1625 char *ptr; | |
1626 int parenlevel=0; | |
1627 char* tempstr; | |
1628 int tempstridx; | |
1629 | |
9986 | 1630 zephyr->tzc_pid = pid; |
9896 | 1631 /* wait till we have data to read from ssh */ |
1632 FD_ZERO(&rfds); | |
1633 FD_SET(zephyr->fromtzc[ZEPHYR_FD_READ], &rfds); | |
1634 | |
1635 tv.tv_sec = 10; | |
1636 tv.tv_usec = 0; | |
1637 | |
1638 gaim_debug_info("zephyr", "about to read from tzc\n"); | |
1639 | |
1640 select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, NULL); | |
1641 | |
1642 FD_ZERO(&rfds); | |
1643 FD_SET(zephyr->fromtzc[ZEPHYR_FD_READ], &rfds); | |
1644 while (select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, &tv)) { | |
1645 read(zephyr->fromtzc[ZEPHYR_FD_READ], bufcur, 1); | |
1646 bufcur++; | |
1647 if ((bufcur - buf) > (bufsize - 1)) { | |
1648 if ((buf = realloc(buf, bufsize * 2)) == NULL) { | |
1649 exit(-1); | |
1650 } else { | |
1651 bufcur = buf + bufsize; | |
1652 bufsize *= 2; | |
1653 } | |
1654 } | |
1655 FD_ZERO(&rfds); | |
1656 FD_SET(zephyr->fromtzc[ZEPHYR_FD_READ], &rfds); | |
1657 tv.tv_sec = 10; | |
1658 tv.tv_usec = 0; | |
2086 | 1659 |
9896 | 1660 } |
9986 | 1661 /* fprintf(stderr, "read from tzc\n"); */ |
9896 | 1662 *bufcur = '\0'; |
1663 ptr = buf; | |
1664 | |
1665 /* ignore all tzcoutput till we've received the first (*/ | |
1666 while (ptr < bufcur && (*ptr !='(')) { | |
1667 ptr++; | |
1668 } | |
1669 if (ptr >=bufcur) { | |
1670 gaim_connection_error(gc,"invalid output by tzc (or bad parsing code)"); | |
1671 return; | |
1672 } | |
9427 | 1673 |
9896 | 1674 while(ptr < bufcur) { |
1675 if (*ptr == '(') { | |
1676 parenlevel++; | |
1677 } | |
1678 else if (*ptr == ')') { | |
1679 parenlevel--; | |
1680 } | |
1681 gaim_debug_info("zephyr","tzc parenlevel is %d\n",parenlevel); | |
1682 switch (parenlevel) { | |
1683 case 0: | |
1684 break; | |
1685 case 1: | |
1686 /* Search for next beginning (, or for the ending */ | |
1687 ptr++; | |
1688 while((*ptr != '(') && (*ptr != ')') && (ptr <bufcur)) | |
1689 ptr++; | |
1690 if (ptr >= bufcur) | |
1691 gaim_debug_error("zephyr","tzc parsing error\n"); | |
1692 break; | |
1693 case 2: | |
1694 /* You are probably at | |
1695 (foo . bar ) or (foo . "bar") or (foo . chars) or (foo . numbers) or (foo . () ) | |
1696 Parse all the data between the first and last f, and move past ) | |
1697 */ | |
1698 tempstr = g_malloc0(20000); | |
1699 tempstridx=0; | |
1700 while(parenlevel >1) { | |
1701 ptr++; | |
1702 if (*ptr == '(') | |
1703 parenlevel++; | |
1704 if (*ptr == ')') | |
1705 parenlevel--; | |
1706 if (parenlevel > 1) { | |
1707 tempstr[tempstridx++]=*ptr; | |
1708 } else { | |
1709 ptr++; | |
1710 } | |
1711 } | |
1712 gaim_debug_info("zephyr","tempstr parsed\n"); | |
1713 /* tempstr should now be a tempstridx length string containing all characters | |
1714 from that after the first ( to the one before the last paren ). */ | |
1715 /* We should have the following possible lisp strings but we don't care | |
1716 (tzcspew . start) (version . "something") (pid . number)*/ | |
1717 /* We care about 'zephyrid . "username@REALM.NAME"' and 'exposure . "SOMETHING"' */ | |
1718 tempstridx=0; | |
1719 if (!g_ascii_strncasecmp(tempstr,"zephyrid",8)) { | |
1720 gchar* username = g_malloc0(100); | |
1721 int username_idx=0; | |
1722 char *realm; | |
1723 gaim_debug_info("zephyr","zephyrid found\n"); | |
1724 tempstridx+=8; | |
1725 while(tempstr[tempstridx] !='"' && tempstridx < 20000) | |
1726 tempstridx++; | |
1727 tempstridx++; | |
1728 while(tempstr[tempstridx] !='"' && tempstridx < 20000) | |
1729 username[username_idx++]=tempstr[tempstridx++]; | |
1730 | |
1731 zephyr->username = g_strdup_printf("%s",username); | |
1732 if ((realm = strchr(username,'@'))) | |
1733 zephyr->realm = g_strdup_printf("%s",realm+1); | |
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1734 else { |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1735 realm = (gchar *)gaim_account_get_string(gc->account,"realm",""); |
12621 | 1736 if (!*realm) { |
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1737 realm = "local-realm"; |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1738 } |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1739 zephyr->realm = g_strdup(realm); |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1740 g_strlcpy(__Zephyr_realm, (const char*)zephyr->realm, REALM_SZ-1); |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1741 } |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1742 /* else { |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1743 zephyr->realm = g_strdup("local-realm"); |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1744 }*/ |
9896 | 1745 |
1746 g_free(username); | |
1747 } else { | |
1748 gaim_debug_info("zephyr", "something that's not zephyr id found %s\n",tempstr); | |
1749 } | |
1750 | |
1751 /* We don't care about anything else yet */ | |
1752 g_free(tempstr); | |
1753 break; | |
1754 default: | |
1755 gaim_debug_info("zephyr","parenlevel is not 1 or 2\n"); | |
1756 /* This shouldn't be happening */ | |
1757 break; | |
1758 } | |
1759 if (parenlevel==0) | |
1760 break; | |
1761 } /* while (ptr < bufcur) { */ | |
1762 gaim_debug_info("zephyr", "tzc startup done\n"); | |
1763 } | |
1764 } | |
1765 else if ( use_zeph02(zephyr)) { | |
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1766 gchar* realm; |
9896 | 1767 z_call_s(ZInitialize(), "Couldn't initialize zephyr"); |
1768 z_call_s(ZOpenPort(&(zephyr->port)), "Couldn't open port"); | |
1769 z_call_s(ZSetLocation((char *)zephyr->exposure), "Couldn't set location"); | |
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1770 |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1771 realm = (gchar *)gaim_account_get_string(gc->account,"realm",""); |
12621 | 1772 if (!*realm) { |
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1773 realm = ZGetRealm(); |
12621 | 1774 } |
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1775 zephyr->realm = g_strdup(realm); |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1776 g_strlcpy(__Zephyr_realm, (const char*)zephyr->realm, REALM_SZ-1); |
9896 | 1777 zephyr->username = g_strdup(ZGetSender()); |
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1778 |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1779 /* zephyr->realm = g_strdup(ZGetRealm()); */ |
9896 | 1780 gaim_debug_info("zephyr","realm: %s\n",zephyr->realm); |
12621 | 1781 } |
9896 | 1782 else { |
1783 gaim_connection_error(gc,"Only ZEPH0.2 supported currently"); | |
1784 return; | |
1785 } | |
1786 gaim_debug_info("zephyr","does it get here\n"); | |
1787 gaim_debug_info("zephyr"," realm: %s username:%s\n", zephyr->realm, zephyr->username); | |
1788 | |
1789 /* For now */ | |
1790 zephyr->galaxy = NULL; | |
1791 zephyr->krbtkfile = NULL; | |
1792 zephyr_inithosts(zephyr); | |
1793 | |
1794 if (zephyr_subscribe_to(zephyr,"MESSAGE","PERSONAL",zephyr->username,NULL) != ZERR_NONE) { | |
9478 | 1795 /* XXX don't translate this yet. It could be written better */ |
1796 /* XXX error messages could be handled with more detail */ | |
1797 gaim_notify_error(account->gc, NULL, | |
1798 "Unable to subscribe to messages", "Unable to subscribe to initial messages"); | |
1799 return; | |
2086 | 1800 } |
1801 | |
9610 | 1802 gaim_connection_set_state(gc, GAIM_CONNECTED); |
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1803 |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1804 if (read_anyone) |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1805 process_anyone(gc); |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1806 if (read_zsubs) |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1807 process_zsubs(zephyr); |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1808 |
9896 | 1809 if (use_zeph02(zephyr)) { |
1810 zephyr->nottimer = gaim_timeout_add(100, check_notify_zeph02, gc); | |
1811 } else if (use_tzc(zephyr)) { | |
1812 zephyr->nottimer = gaim_timeout_add(100, check_notify_tzc, gc); | |
1813 } | |
1814 zephyr->loctimer = gaim_timeout_add(20000, check_loc, gc); | |
2086 | 1815 |
1816 } | |
1817 | |
9610 | 1818 static void write_zsubs(zephyr_account *zephyr) |
2086 | 1819 { |
9896 | 1820 /* Exports subscription (chat) list back to |
1821 * .zephyr.subs | |
1822 * XXX deal with %host%, %canon%, unsubscriptions, and negative subscriptions (punts?) | |
1823 */ | |
9434 | 1824 |
9610 | 1825 GSList *s = zephyr->subscrips; |
2086 | 1826 zephyr_triple *zt; |
1827 FILE *fd; | |
1828 char *fname; | |
1829 | |
8644 | 1830 char **triple; |
1831 | |
3630 | 1832 fname = g_strdup_printf("%s/.zephyr.subs", gaim_home_dir()); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10401
diff
changeset
|
1833 fd = g_fopen(fname, "w"); |
8644 | 1834 |
2086 | 1835 if (!fd) { |
1836 g_free(fname); | |
1837 return; | |
1838 } | |
8644 | 1839 |
2086 | 1840 while (s) { |
9478 | 1841 char *zclass, *zinst, *zrecip; |
2086 | 1842 zt = s->data; |
8644 | 1843 triple = g_strsplit(zt->name, ",", 3); |
9478 | 1844 |
1845 /* deal with classes */ | |
9610 | 1846 if (!g_ascii_strcasecmp(triple[0],zephyr->ourhost)) { |
9775 | 1847 zclass = g_strdup("%host%"); |
9610 | 1848 } else if (!g_ascii_strcasecmp(triple[0],zephyr->ourhostcanon)) { |
9775 | 1849 zclass = g_strdup("%canon%"); |
9478 | 1850 } else { |
1851 zclass = g_strdup(triple[0]); | |
1852 } | |
1853 | |
1854 /* deal with instances */ | |
1855 | |
9610 | 1856 if (!g_ascii_strcasecmp(triple[1],zephyr->ourhost)) { |
9775 | 1857 zinst = g_strdup("%host%"); |
9610 | 1858 } else if (!g_ascii_strcasecmp(triple[1],zephyr->ourhostcanon)) { |
9896 | 1859 zinst = g_strdup("%canon%");; |
1860 } else { | |
9478 | 1861 zinst = g_strdup(triple[1]); |
9896 | 1862 } |
9478 | 1863 |
1864 /* deal with recipients */ | |
1865 if (triple[2] == NULL) { | |
1866 zrecip = g_strdup("*"); | |
1867 } else if (!g_ascii_strcasecmp(triple[2],"")){ | |
1868 zrecip = g_strdup("*"); | |
9896 | 1869 } else if (!g_ascii_strcasecmp(triple[2], zephyr->username)) { |
9478 | 1870 zrecip = g_strdup("%me%"); |
3277 | 1871 } else { |
9478 | 1872 zrecip = g_strdup(triple[2]); |
3277 | 1873 } |
9478 | 1874 |
1875 fprintf(fd, "%s,%s,%s\n",zclass,zinst,zrecip); | |
1876 | |
1877 g_free(zclass); | |
1878 g_free(zinst); | |
1879 g_free(zrecip); | |
3277 | 1880 g_free(triple); |
2086 | 1881 s = s->next; |
1882 } | |
1883 g_free(fname); | |
1884 fclose(fd); | |
1885 } | |
1886 | |
9610 | 1887 static void write_anyone(GaimConnection *gc) |
2086 | 1888 { |
6695 | 1889 GaimBlistNode *gnode, *cnode, *bnode; |
1890 GaimBuddy *b; | |
9912 | 1891 char *fname; |
2086 | 1892 FILE *fd; |
9896 | 1893 zephyr_account* zephyr = gc->proto_data; |
3630 | 1894 fname = g_strdup_printf("%s/.anyone", gaim_home_dir()); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10401
diff
changeset
|
1895 fd = g_fopen(fname, "w"); |
2086 | 1896 if (!fd) { |
1897 g_free(fname); | |
1898 return; | |
1899 } | |
1900 | |
8644 | 1901 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
1902 if (!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
4785 | 1903 continue; |
8644 | 1904 for (cnode = gnode->child; cnode; cnode = cnode->next) { |
1905 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 1906 continue; |
8644 | 1907 for (bnode = cnode->child; bnode; bnode = bnode->next) { |
1908 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
6695 | 1909 continue; |
8644 | 1910 b = (GaimBuddy *) bnode; |
9610 | 1911 if (b->account == gc->account) { |
9986 | 1912 gchar *stripped_user = zephyr_strip_local_realm(zephyr,b->name); |
9912 | 1913 fprintf(fd, "%s\n", stripped_user); |
9986 | 1914 g_free(stripped_user); |
3277 | 1915 } |
1916 } | |
2086 | 1917 } |
1918 } | |
1919 | |
1920 fclose(fd); | |
1921 g_free(fname); | |
1922 } | |
1923 | |
8644 | 1924 static void zephyr_close(GaimConnection * gc) |
2086 | 1925 { |
1926 GList *l; | |
1927 GSList *s; | |
9896 | 1928 zephyr_account *zephyr = gc->proto_data; |
9986 | 1929 pid_t tzc_pid = zephyr->tzc_pid; |
8644 | 1930 |
9610 | 1931 l = zephyr->pending_zloc_names; |
2086 | 1932 while (l) { |
8644 | 1933 g_free((char *)l->data); |
2086 | 1934 l = l->next; |
1935 } | |
9610 | 1936 g_list_free(zephyr->pending_zloc_names); |
8644 | 1937 |
9610 | 1938 if (gaim_account_get_bool(gc->account, "write_anyone", FALSE)) |
1939 write_anyone(gc); | |
8644 | 1940 |
9610 | 1941 if (gaim_account_get_bool(gc->account, "write_zsubs", FALSE)) |
1942 write_zsubs(gc->proto_data); | |
8644 | 1943 |
9610 | 1944 s = zephyr->subscrips; |
2086 | 1945 while (s) { |
8644 | 1946 free_triple((zephyr_triple *) s->data); |
2086 | 1947 s = s->next; |
1948 } | |
9610 | 1949 g_slist_free(zephyr->subscrips); |
8644 | 1950 |
9610 | 1951 if (zephyr->nottimer) |
1952 gaim_timeout_remove(zephyr->nottimer); | |
1953 zephyr->nottimer = 0; | |
1954 if (zephyr->loctimer) | |
1955 gaim_timeout_remove(zephyr->loctimer); | |
1956 zephyr->loctimer = 0; | |
1957 gc = NULL; | |
9896 | 1958 if (use_zeph02(zephyr)) { |
1959 z_call(ZCancelSubscriptions(0)); | |
1960 z_call(ZUnsetLocation()); | |
1961 z_call(ZClosePort()); | |
1962 } else { | |
1963 /* assume tzc */ | |
9986 | 1964 if (kill(tzc_pid,SIGTERM) == -1) { |
1965 int err=errno; | |
1966 if (err==EINVAL) { | |
1967 gaim_debug_error("zephyr","An invalid signal was specified when killing tzc\n"); | |
1968 } | |
1969 else if (err==ESRCH) { | |
1970 gaim_debug_error("zephyr","Tzc's pid didn't exist while killing tzc\n"); | |
1971 } | |
1972 else if (err==EPERM) { | |
1973 gaim_debug_error("zephyr","gaim didn't have permission to kill tzc\n"); | |
1974 } | |
1975 else { | |
1976 gaim_debug_error("zephyr","miscellaneous error while attempting to close tzc\n"); | |
1977 } | |
1978 } | |
9896 | 1979 } |
2086 | 1980 } |
1981 | |
9896 | 1982 static int zephyr_send_message(zephyr_account *zephyr,char* zclass, char* instance, char* recipient, const char *im, |
9478 | 1983 const char *sig, char *opcode) ; |
9434 | 1984 |
12424
7c2e2c4d45a4
[gaim-migrate @ 14731]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1985 static const char * zephyr_get_signature() |
9434 | 1986 { |
9478 | 1987 /* XXX add zephyr error reporting */ |
1988 const char * sig =ZGetVariable("zwrite-signature"); | |
9896 | 1989 if (!sig) { |
1990 sig = g_get_real_name(); | |
1991 } | |
1992 return sig; | |
9434 | 1993 } |
1994 | |
12216 | 1995 static int zephyr_chat_send(GaimConnection * gc, int id, const char *im, GaimMessageFlags flags) |
2086 | 1996 { |
1997 zephyr_triple *zt; | |
1998 const char *sig; | |
8644 | 1999 GaimConversation *gconv1; |
2000 GaimConvChat *gcc; | |
2001 char *inst; | |
9896 | 2002 char *recipient; |
2003 zephyr_account *zephyr = gc->proto_data; | |
2086 | 2004 |
9610 | 2005 zt = find_sub_by_id(gc->proto_data,id); |
2086 | 2006 if (!zt) |
2007 /* this should never happen. */ | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2008 return -EINVAL; |
8644 | 2009 |
9896 | 2010 sig = zephyr_get_signature(); |
2086 | 2011 |
11338 | 2012 gconv1 = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, zt->name, |
10246 | 2013 gc->account); |
8644 | 2014 gcc = gaim_conversation_get_chat_data(gconv1); |
8212 | 2015 |
8644 | 2016 if (!(inst = (char *)gaim_conv_chat_get_topic(gcc))) |
9434 | 2017 inst = g_strdup("PERSONAL"); |
8644 | 2018 |
4793 | 2019 if (!g_ascii_strcasecmp(zt->recipient, "*")) |
9896 | 2020 recipient = local_zephyr_normalize(zephyr,""); |
2086 | 2021 else |
9896 | 2022 recipient = local_zephyr_normalize(zephyr,zt->recipient); |
8451 | 2023 |
9896 | 2024 zephyr_send_message(zephyr,zt->class,inst,recipient,im,sig,""); |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
2025 return 0; |
2086 | 2026 } |
2027 | |
9434 | 2028 |
12216 | 2029 static int zephyr_send_im(GaimConnection * gc, const char *who, const char *im, GaimMessageFlags flags) |
8644 | 2030 { |
2086 | 2031 const char *sig; |
9896 | 2032 zephyr_account *zephyr = gc->proto_data; |
12216 | 2033 if (flags & GAIM_MESSAGE_AUTO_RESP) |
2086 | 2034 sig = "Automated reply:"; |
2035 else { | |
9434 | 2036 sig = zephyr_get_signature(); |
2086 | 2037 } |
9896 | 2038 zephyr_send_message(zephyr,"MESSAGE","PERSONAL",local_zephyr_normalize(zephyr,who),im,sig,""); |
9434 | 2039 |
2040 return 1; | |
2041 } | |
2086 | 2042 |
9896 | 2043 /* Munge the outgoing zephyr so that any quotes or backslashes are |
2044 escaped and do not confuse tzc: */ | |
2045 | |
12424
7c2e2c4d45a4
[gaim-migrate @ 14731]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
2046 static char* zephyr_tzc_escape_msg(const char *message) |
9896 | 2047 { |
2048 int pos = 0; | |
2049 int pos2 = 0; | |
2050 char *newmsg; | |
2051 | |
2052 if (message && (strlen(message) > 0)) { | |
2053 newmsg = g_new0(char,1+strlen(message)*2); | |
2054 while(pos < strlen(message)) { | |
2055 if (message[pos]=='\\') { | |
2056 newmsg[pos2]='\\'; | |
2057 newmsg[pos2+1]='\\'; | |
2058 pos2+=2; | |
2059 } | |
2060 else if (message[pos]=='"') { | |
2061 newmsg[pos2]='\\'; | |
2062 newmsg[pos2+1]='"'; | |
2063 pos2+=2; | |
2064 } | |
2065 else { | |
2066 newmsg[pos2] = message[pos]; | |
2067 pos2++; | |
2068 } | |
2069 pos++; | |
2070 } | |
2071 } else { | |
2072 newmsg = g_strdup(""); | |
2073 } | |
9986 | 2074 /* fprintf(stderr,"newmsg %s message %s\n",newmsg,message); */ |
9896 | 2075 return newmsg; |
2076 } | |
2077 | |
2078 char* zephyr_tzc_deescape_str(const char *message) | |
2079 { | |
2080 int pos = 0; | |
2081 int pos2 = 0; | |
2082 char *newmsg; | |
2083 | |
2084 if (message && (strlen(message) > 0)) { | |
2085 newmsg = g_new0(char,strlen(message)+1); | |
2086 while(pos < strlen(message)) { | |
2087 if (message[pos]=='\\') { | |
2088 pos++; | |
2089 } | |
2090 newmsg[pos2] = message[pos]; | |
2091 pos++;pos2++; | |
2092 } | |
2093 newmsg[pos2]='\0'; | |
2094 } else { | |
2095 newmsg = g_strdup(""); | |
2096 } | |
2097 | |
2098 return newmsg; | |
2099 } | |
2100 | |
2101 static int zephyr_send_message(zephyr_account *zephyr,char* zclass, char* instance, char* recipient, const char *im, | |
9478 | 2102 const char *sig, char *opcode) |
9434 | 2103 { |
8451 | 2104 |
9896 | 2105 /* (From the tzc source) |
2106 * emacs sends something of the form: | |
2107 * ((class . "MESSAGE") | |
2108 * (auth . t) | |
2109 * (recipients ("PERSONAL" . "bovik") ("test" . "")) | |
2110 * (sender . "bovik") | |
2111 * (message . ("Harry Bovik" "my zgram")) | |
2112 * ) | |
2113 */ | |
2114 char *html_buf; | |
2115 char *html_buf2; | |
2116 html_buf = html_to_zephyr(im); | |
2117 html_buf2 = gaim_unescape_html(html_buf); | |
9434 | 2118 |
9896 | 2119 if(use_tzc(zephyr)) { |
2120 char* zsendstr; | |
2121 /* CMU cclub tzc doesn't grok opcodes for now */ | |
2122 char* tzc_sig = zephyr_tzc_escape_msg(sig); | |
2123 char *tzc_body = zephyr_tzc_escape_msg(html_buf2); | |
2124 zsendstr = g_strdup_printf("((tzcfodder . send) (class . \"%s\") (auth . t) (recipients (\"%s\" . \"%s\")) (message . (\"%s\" \"%s\")) ) \n", | |
9986 | 2125 zclass, instance, recipient, tzc_sig, tzc_body); |
2126 /* fprintf(stderr,"zsendstr = %s\n",zsendstr); */ | |
9896 | 2127 write(zephyr->totzc[ZEPHYR_FD_WRITE],zsendstr,strlen(zsendstr)); |
2128 g_free(zsendstr); | |
2129 } else if (use_zeph02(zephyr)) { | |
2130 ZNotice_t notice; | |
2131 char *buf = g_strdup_printf("%s%c%s", sig, '\0', html_buf2); | |
2132 bzero((char *)¬ice, sizeof(notice)); | |
2133 | |
2134 notice.z_kind = ACKED; | |
2135 notice.z_port = 0; | |
2136 notice.z_opcode = ""; | |
2137 notice.z_class = zclass; | |
2138 notice.z_class_inst = instance; | |
2139 notice.z_recipient = recipient; | |
2140 notice.z_sender = 0; | |
2141 notice.z_default_format = "Class $class, Instance $instance:\n" "To: @bold($recipient) at $time $date\n" "From: @bold($1) <$sender>\n\n$2"; | |
2142 notice.z_message_len = strlen(html_buf2) + strlen(sig) + 2; | |
2143 notice.z_message = buf; | |
2144 notice.z_opcode = g_strdup(opcode); | |
2145 gaim_debug_info("zephyr","About to send notice"); | |
2146 if (! ZSendNotice(¬ice, ZAUTH) == ZERR_NONE) { | |
2147 /* XXX handle errors here */ | |
2148 return 0; | |
2149 } | |
2150 gaim_debug_info("zephyr","notice sent"); | |
2151 g_free(buf); | |
9478 | 2152 } |
2153 | |
8644 | 2154 g_free(html_buf2); |
2155 g_free(html_buf); | |
8451 | 2156 |
9896 | 2157 return 1; |
2086 | 2158 } |
2159 | |
9896 | 2160 char *local_zephyr_normalize(zephyr_account *zephyr,const char *orig) |
8354 | 2161 { |
9328 | 2162 /* |
9912 | 2163 Basically the inverse of zephyr_strip_local_realm |
9896 | 2164 */ |
2165 char* buf; | |
2166 | |
8354 | 2167 if (!g_ascii_strcasecmp(orig, "")) { |
9896 | 2168 return g_strdup(""); |
7126 | 2169 } |
8644 | 2170 |
9896 | 2171 if (strchr(orig,'@')) { |
2172 buf = g_strdup_printf("%s",orig); | |
2086 | 2173 } else { |
9896 | 2174 buf = g_strdup_printf("%s@%s",orig,zephyr->realm); |
2175 } | |
2086 | 2176 return buf; |
2177 } | |
2178 | |
9030 | 2179 static void zephyr_zloc(GaimConnection *gc, const char *who) |
2086 | 2180 { |
2181 ZAsyncLocateData_t ald; | |
9896 | 2182 zephyr_account *zephyr = gc->proto_data; |
2183 gchar* normalized_who = local_zephyr_normalize(zephyr,who); | |
2184 | |
2185 if (use_zeph02(zephyr)) { | |
2186 if (ZRequestLocations(normalized_who, &ald, UNACKED, ZAUTH) == ZERR_NONE) { | |
2187 zephyr->pending_zloc_names = g_list_append(zephyr->pending_zloc_names, | |
2188 g_strdup(normalized_who)); | |
2189 } else { | |
2190 /* XXX deal with errors somehow */ | |
2191 } | |
2192 } else if (use_tzc(zephyr)) { | |
2193 char* zlocstr = g_strdup_printf("((tzcfodder . zlocate) \"%s\")\n",normalized_who); | |
2194 zephyr->pending_zloc_names = g_list_append(zephyr->pending_zloc_names, g_strdup(normalized_who)); | |
2195 write(zephyr->totzc[ZEPHYR_FD_WRITE],zlocstr,strlen(zlocstr)); | |
2196 g_free(zlocstr); | |
2086 | 2197 } |
2198 } | |
2199 | |
9986 | 2200 static void zephyr_set_status(GaimAccount *account, GaimStatus *status) { |
2201 zephyr_account *zephyr = gaim_account_get_connection(account)->proto_data; | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12467
diff
changeset
|
2202 GaimStatusPrimitive primitive = gaim_status_type_get_primitive(gaim_status_get_type(status)); |
9986 | 2203 |
2204 if (zephyr->away) { | |
2205 g_free(zephyr->away); | |
2206 zephyr->away=NULL; | |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
2207 } |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
2208 |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12467
diff
changeset
|
2209 if (primitive == GAIM_STATUS_AWAY) { |
9986 | 2210 zephyr->away = g_strdup(gaim_status_get_attr_string(status,"message")); |
2211 } | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12467
diff
changeset
|
2212 else if (primitive == GAIM_STATUS_AVAILABLE) { |
9986 | 2213 if (use_zeph02(zephyr)) { |
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2214 ZSetLocation(zephyr->exposure); |
9986 | 2215 } |
2216 else { | |
2217 char *zexpstr = g_strdup_printf("((tzcfodder . set-location) (hostname . \"%s\") (exposure . \"%s\"))\n",zephyr->ourhost,zephyr->exposure); | |
2218 write(zephyr->totzc[ZEPHYR_FD_WRITE],zexpstr,strlen(zexpstr)); | |
2219 g_free(zexpstr); | |
2220 } | |
2221 } | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12467
diff
changeset
|
2222 else if (primitive == GAIM_STATUS_INVISIBLE) { |
9478 | 2223 /* XXX handle errors */ |
9896 | 2224 if (use_zeph02(zephyr)) { |
2225 ZSetLocation(EXPOSE_OPSTAFF); | |
2226 } else { | |
2227 char *zexpstr = g_strdup_printf("((tzcfodder . set-location) (hostname . \"%s\") (exposure . \"%s\"))\n",zephyr->ourhost,EXPOSE_OPSTAFF); | |
2228 write(zephyr->totzc[ZEPHYR_FD_WRITE],zexpstr,strlen(zexpstr)); | |
2229 g_free(zexpstr); | |
2230 } | |
9478 | 2231 } |
2086 | 2232 } |
2233 | |
9986 | 2234 static GList *zephyr_status_types(GaimAccount *account) |
2086 | 2235 { |
9986 | 2236 GaimStatusType *type; |
2237 GList *types = NULL; | |
2238 | |
2239 /* zephyr has several exposures | |
2240 NONE (where you are hidden, and zephyrs to you are in practice silently dropped -- yes this is wrong) | |
2241 OPSTAFF "hidden" | |
2242 REALM-VISIBLE visible to people in local realm | |
2243 REALM-ANNOUNCED REALM-VISIBLE+ plus your logins/logouts are announced to <login,username,*> | |
2244 NET-VISIBLE REALM-ANNOUNCED, plus visible to people in foreign realm | |
2245 NET-ANNOUNCED NET-VISIBLE, plus logins/logouts are announced to <login,username,*> | |
2246 | |
2247 Online will set the user to the exposure they have in their options (defaulting to REALM-VISIBLE), | |
2248 Hidden, will set the user's exposure to OPSTAFF | |
2086 | 2249 |
9986 | 2250 Away won't change their exposure but will set an auto away message (for IMs only) |
2251 */ | |
2252 | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12467
diff
changeset
|
2253 type = gaim_status_type_new(GAIM_STATUS_AVAILABLE, NULL, NULL, FALSE); |
9986 | 2254 types = g_list_append(types,type); |
2086 | 2255 |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12467
diff
changeset
|
2256 type = gaim_status_type_new(GAIM_STATUS_INVISIBLE, NULL, NULL, FALSE); |
9986 | 2257 types = g_list_append(types,type); |
2258 | |
2259 type = gaim_status_type_new_with_attrs( | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12467
diff
changeset
|
2260 GAIM_STATUS_AWAY, NULL, NULL, TRUE, TRUE, FALSE, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12467
diff
changeset
|
2261 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12467
diff
changeset
|
2262 NULL); |
9986 | 2263 types = g_list_append(types, type); |
2264 | |
2265 return types; | |
2086 | 2266 } |
2267 | |
8644 | 2268 static GList *zephyr_chat_info(GaimConnection * gc) |
2269 { | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
2270 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
2271 struct proto_chat_entry *pce; |
2086 | 2272 |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
2273 pce = g_new0(struct proto_chat_entry, 1); |
8644 | 2274 |
7841 | 2275 pce->label = _("_Class:"); |
5234 | 2276 pce->identifier = "class"; |
3158 | 2277 m = g_list_append(m, pce); |
2086 | 2278 |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
2279 pce = g_new0(struct proto_chat_entry, 1); |
8644 | 2280 |
7841 | 2281 pce->label = _("_Instance:"); |
5234 | 2282 pce->identifier = "instance"; |
3158 | 2283 m = g_list_append(m, pce); |
2086 | 2284 |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
2285 pce = g_new0(struct proto_chat_entry, 1); |
8644 | 2286 |
7841 | 2287 pce->label = _("_Recipient:"); |
5234 | 2288 pce->identifier = "recipient"; |
3158 | 2289 m = g_list_append(m, pce); |
2086 | 2290 |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
2291 return m; |
2086 | 2292 } |
2293 | |
9478 | 2294 /* Called when the server notifies us a message couldn't get sent */ |
2295 | |
9896 | 2296 static void zephyr_subscribe_failed(GaimConnection *gc,char * z_class, char *z_instance, char * z_recipient, char* z_galaxy) |
9478 | 2297 { |
9896 | 2298 gchar* subscribe_failed = g_strdup_printf(_("Attempt to subscribe to %s,%s,%s failed"), z_class, z_instance,z_recipient); |
9610 | 2299 gaim_notify_error(gc,"", subscribe_failed, NULL); |
9478 | 2300 g_free(subscribe_failed); |
2301 } | |
2302 | |
9921 | 2303 static char *zephyr_get_chat_name(GHashTable *data) { |
9922 | 2304 gchar* zclass = g_hash_table_lookup(data,"class"); |
2305 gchar* inst = g_hash_table_lookup(data,"instance"); | |
2306 gchar* recipient = g_hash_table_lookup(data, "recipient"); | |
2307 if (!zclass) /* This should never happen */ | |
2308 zclass = ""; | |
2309 if (!inst) | |
2310 inst = "*"; | |
2311 if (!recipient) | |
2312 recipient = ""; | |
2313 return g_strdup_printf("%s,%s,%s",zclass,inst,recipient); | |
9917 | 2314 } |
2315 | |
9922 | 2316 |
8644 | 2317 static void zephyr_join_chat(GaimConnection * gc, GHashTable * data) |
2086 | 2318 { |
9896 | 2319 /* ZSubscription_t sub; */ |
2086 | 2320 zephyr_triple *zt1, *zt2; |
2321 const char *classname; | |
2322 const char *instname; | |
2323 const char *recip; | |
9896 | 2324 zephyr_account *zephyr=gc->proto_data; |
5234 | 2325 classname = g_hash_table_lookup(data, "class"); |
2326 instname = g_hash_table_lookup(data, "instance"); | |
2327 recip = g_hash_table_lookup(data, "recipient"); | |
2328 | |
9478 | 2329 |
9328 | 2330 if (!classname) |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
2331 return; |
9478 | 2332 |
2333 if (!g_ascii_strcasecmp(classname,"%host%")) | |
9896 | 2334 classname = g_strdup(zephyr->ourhost); |
9478 | 2335 if (!g_ascii_strcasecmp(classname,"%canon%")) |
9896 | 2336 classname = g_strdup(zephyr->ourhostcanon); |
9478 | 2337 |
9328 | 2338 if (!instname || !strlen(instname)) |
2339 instname = "*"; | |
9478 | 2340 |
2341 if (!g_ascii_strcasecmp(instname,"%host%")) | |
9896 | 2342 instname = g_strdup(zephyr->ourhost); |
9478 | 2343 if (!g_ascii_strcasecmp(instname,"%canon%")) |
9896 | 2344 instname = g_strdup(zephyr->ourhostcanon); |
9478 | 2345 |
9328 | 2346 if (!recip || (*recip == '*')) |
2347 recip = ""; | |
4793 | 2348 if (!g_ascii_strcasecmp(recip, "%me%")) |
9896 | 2349 recip = zephyr->username; |
2086 | 2350 |
9610 | 2351 zt1 = new_triple(gc->proto_data,classname, instname, recip); |
2352 zt2 = find_sub_by_triple(gc->proto_data,zt1); | |
2086 | 2353 if (zt2) { |
2354 free_triple(zt1); | |
9328 | 2355 if (!zt2->open) { |
2356 if (!g_ascii_strcasecmp(instname,"*")) | |
2357 instname = "PERSONAL"; | |
9434 | 2358 serv_got_joined_chat(gc, zt2->id, zt2->name); |
9896 | 2359 zephyr_chat_set_topic(gc,zt2->id,instname); |
9328 | 2360 zt2->open = TRUE; |
2361 } | |
2086 | 2362 return; |
2363 } | |
9896 | 2364 |
2365 /* sub.zsub_class = zt1->class; | |
2366 sub.zsub_classinst = zt1->instance; | |
2367 sub.zsub_recipient = zt1->recipient; */ | |
2368 | |
2369 if (zephyr_subscribe_to(zephyr,zt1->class,zt1->instance,zt1->recipient,NULL) != ZERR_NONE) { | |
9478 | 2370 /* XXX output better subscription information */ |
9896 | 2371 zephyr_subscribe_failed(gc,zt1->class,zt1->instance,zt1->recipient,NULL); |
2086 | 2372 free_triple(zt1); |
2373 return; | |
2374 } | |
2375 | |
9610 | 2376 zephyr->subscrips = g_slist_append(zephyr->subscrips, zt1); |
2086 | 2377 zt1->open = TRUE; |
2378 serv_got_joined_chat(gc, zt1->id, zt1->name); | |
9328 | 2379 if (!g_ascii_strcasecmp(instname,"*")) |
2380 instname = "PERSONAL"; | |
9896 | 2381 zephyr_chat_set_topic(gc,zt1->id,instname); |
2086 | 2382 } |
2383 | |
8644 | 2384 static void zephyr_chat_leave(GaimConnection * gc, int id) |
2086 | 2385 { |
2386 zephyr_triple *zt; | |
9896 | 2387 zephyr_account *zephyr = gc->proto_data; |
9610 | 2388 zt = find_sub_by_id(zephyr,id); |
9896 | 2389 |
2086 | 2390 if (zt) { |
2391 zt->open = FALSE; | |
9610 | 2392 zt->id = ++(zephyr->last_id); |
2086 | 2393 } |
2394 } | |
2395 | |
9478 | 2396 static GaimChat *zephyr_find_blist_chat(GaimAccount *account, const char *name) |
2397 { | |
2398 GaimBlistNode *gnode, *cnode; | |
2399 | |
2400 /* XXX needs to be %host%,%canon%, and %me% clean */ | |
2401 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { | |
2402 for(cnode = gnode->child; cnode; cnode = cnode->next) { | |
2403 GaimChat *chat = (GaimChat*)cnode; | |
2404 char *zclass, *inst, *recip; | |
2405 char** triple; | |
2406 if(!GAIM_BLIST_NODE_IS_CHAT(cnode)) | |
2407 continue; | |
2408 if(chat->account !=account) | |
2409 continue; | |
2410 if(!(zclass = g_hash_table_lookup(chat->components, "class"))) | |
2411 continue; | |
2412 if(!(inst = g_hash_table_lookup(chat->components, "instance"))) | |
2413 inst = g_strdup(""); | |
2414 if(!(recip = g_hash_table_lookup(chat->components, "recipient"))) | |
2415 recip = g_strdup(""); | |
9896 | 2416 /* gaim_debug_info("zephyr","in zephyr_find_blist_chat name: %s\n",name?name:""); */ |
9478 | 2417 triple = g_strsplit(name,",",3); |
2418 if (!g_ascii_strcasecmp(triple[0],zclass) && !g_ascii_strcasecmp(triple[1],inst) && !g_ascii_strcasecmp(triple[2],recip)) | |
2419 return chat; | |
2420 | |
2421 } | |
2422 } | |
2423 return NULL; | |
2424 } | |
8644 | 2425 static const char *zephyr_list_icon(GaimAccount * a, GaimBuddy * b) |
5202 | 2426 { |
2427 return "zephyr"; | |
2428 } | |
2429 | |
9478 | 2430 static int zephyr_send_typing(GaimConnection *gc, const char *who, int typing) { |
2431 gchar *recipient; | |
9896 | 2432 zephyr_account *zephyr = gc->proto_data; |
2433 if (use_tzc(zephyr)) | |
2434 return 0; | |
2435 | |
9478 | 2436 if (!typing) |
2437 return 0; | |
2438 /* XXX We probably should care if this fails. Or maybe we don't want to */ | |
2439 if (!who) { | |
2440 gaim_debug_info("zephyr", "who is null\n"); | |
9896 | 2441 recipient = local_zephyr_normalize(zephyr,""); |
9478 | 2442 } else { |
10111 | 2443 char *comma = strrchr(who, ','); |
9896 | 2444 /* Don't ping broadcast (chat) recipients */ |
2445 /* The strrchr case finds a realm-stripped broadcast subscription | |
2446 e.g. comma is the last character in the string */ | |
10111 | 2447 if (comma && ( (*(comma+1) == '\0') || (*(comma+1) == '@'))) |
9896 | 2448 return 0; |
10111 | 2449 |
9896 | 2450 recipient = local_zephyr_normalize(zephyr,who); |
9478 | 2451 } |
2452 | |
9896 | 2453 gaim_debug_info("zephyr","about to send typing notification to %s\n",recipient); |
2454 zephyr_send_message(zephyr,"MESSAGE","PERSONAL",recipient,"","","PING"); | |
2455 gaim_debug_info("zephyr","sent typing notification\n"); | |
9478 | 2456 return ZEPHYR_TYPING_SEND_TIMEOUT; |
2457 } | |
8212 | 2458 |
9434 | 2459 |
2460 | |
8644 | 2461 static void zephyr_chat_set_topic(GaimConnection * gc, int id, const char *topic) |
2462 { | |
2463 zephyr_triple *zt; | |
2464 GaimConversation *gconv; | |
2465 GaimConvChat *gcc; | |
9896 | 2466 gchar *topic_utf8; |
2467 zephyr_account* zephyr = gc->proto_data; | |
2468 char *sender = (char *)zephyr->username; | |
8212 | 2469 |
9610 | 2470 zt = find_sub_by_id(gc->proto_data,id); |
9986 | 2471 /* find_sub_by_id can return NULL */ |
2472 if (!zt) | |
2473 return; | |
11338 | 2474 gconv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, zt->name, |
10246 | 2475 gc->account); |
8644 | 2476 gcc = gaim_conversation_get_chat_data(gconv); |
9434 | 2477 |
9896 | 2478 topic_utf8 = zephyr_recv_convert(gc,(gchar *)topic,strlen(topic)); |
2479 gaim_conv_chat_set_topic(gcc,sender,topic_utf8); | |
2480 g_free(topic_utf8); | |
2481 return; | |
9434 | 2482 } |
2483 | |
2484 /* commands */ | |
2485 | |
2486 static GaimCmdRet zephyr_gaim_cmd_msg(GaimConversation *conv, | |
9896 | 2487 const char *cmd, char **args, char **error, void *data) |
9434 | 2488 { |
9896 | 2489 char *recipient; |
2490 zephyr_account *zephyr = gaim_conversation_get_gc(conv)->proto_data; | |
2491 if (!g_ascii_strcasecmp(args[0],"*")) | |
2492 return GAIM_CMD_RET_FAILED; /* "*" is not a valid argument */ | |
2493 else | |
2494 recipient = local_zephyr_normalize(zephyr,args[0]); | |
9434 | 2495 |
9896 | 2496 if (strlen(recipient) < 1) |
2497 return GAIM_CMD_RET_FAILED; /* a null recipient is a chat message, not an IM */ | |
9478 | 2498 |
9896 | 2499 if (zephyr_send_message(zephyr,"MESSAGE","PERSONAL",recipient,args[1],zephyr_get_signature(),"")) |
2500 return GAIM_CMD_RET_OK; | |
2501 else | |
2502 return GAIM_CMD_RET_FAILED; | |
9434 | 2503 } |
2504 | |
2505 static GaimCmdRet zephyr_gaim_cmd_zlocate(GaimConversation *conv, | |
9896 | 2506 const char *cmd, char **args, char **error, void *data) |
9434 | 2507 { |
9896 | 2508 zephyr_zloc(gaim_conversation_get_gc(conv),args[0]); |
2509 return GAIM_CMD_RET_OK; | |
9434 | 2510 } |
2511 | |
2512 static GaimCmdRet zephyr_gaim_cmd_instance(GaimConversation *conv, | |
9896 | 2513 const char *cmd, char **args, char **error, void *data) |
9434 | 2514 { |
9896 | 2515 /* Currently it sets the instance with leading spaces and |
2516 * all. This might not be the best thing to do, though having | |
2517 * one word isn't ideal either. */ | |
9434 | 2518 |
9896 | 2519 GaimConvChat *gcc = gaim_conversation_get_chat_data(conv); |
2520 int id = gcc->id; | |
2521 const char* instance = args[0]; | |
2522 zephyr_chat_set_topic(gaim_conversation_get_gc(conv),id,instance); | |
2523 return GAIM_CMD_RET_OK; | |
9434 | 2524 } |
2525 | |
2526 static GaimCmdRet zephyr_gaim_cmd_joinchat_cir(GaimConversation *conv, | |
9896 | 2527 const char *cmd, char **args, char **error, void *data) |
9434 | 2528 { |
9896 | 2529 /* Join a new zephyr chat */ |
2530 GHashTable *triple = g_hash_table_new(NULL,NULL); | |
2531 g_hash_table_insert(triple,"class",args[0]); | |
2532 g_hash_table_insert(triple,"instance",args[1]); | |
2533 g_hash_table_insert(triple,"recipient",args[2]); | |
2534 zephyr_join_chat(gaim_conversation_get_gc(conv),triple); | |
2535 return GAIM_CMD_RET_OK; | |
9434 | 2536 } |
2537 | |
2538 static GaimCmdRet zephyr_gaim_cmd_zi(GaimConversation *conv, | |
9896 | 2539 const char *cmd, char **args, char **error, void *data) |
9434 | 2540 { |
9896 | 2541 /* args = instance, message */ |
2542 zephyr_account *zephyr = gaim_conversation_get_gc(conv)->proto_data; | |
2543 if ( zephyr_send_message(zephyr,"message",args[0],"",args[1],zephyr_get_signature(),"")) | |
2544 return GAIM_CMD_RET_OK; | |
2545 else | |
2546 return GAIM_CMD_RET_FAILED; | |
9434 | 2547 } |
2548 | |
2549 static GaimCmdRet zephyr_gaim_cmd_zci(GaimConversation *conv, | |
9896 | 2550 const char *cmd, char **args, char **error, void *data) |
9434 | 2551 { |
9896 | 2552 /* args = class, instance, message */ |
2553 zephyr_account *zephyr = gaim_conversation_get_gc(conv)->proto_data; | |
2554 if ( zephyr_send_message(zephyr,args[0],args[1],"",args[2],zephyr_get_signature(),"")) | |
2555 return GAIM_CMD_RET_OK; | |
2556 else | |
2557 return GAIM_CMD_RET_FAILED; | |
9434 | 2558 } |
8644 | 2559 |
9434 | 2560 static GaimCmdRet zephyr_gaim_cmd_zcir(GaimConversation *conv, |
9896 | 2561 const char *cmd, char **args, char **error, void *data) |
9434 | 2562 { |
9896 | 2563 /* args = class, instance, recipient, message */ |
2564 zephyr_account *zephyr = gaim_conversation_get_gc(conv)->proto_data; | |
2565 if ( zephyr_send_message(zephyr,args[0],args[1],args[2],args[3],zephyr_get_signature(),"")) | |
2566 return GAIM_CMD_RET_OK; | |
2567 else | |
2568 return GAIM_CMD_RET_FAILED; | |
8212 | 2569 } |
2570 | |
9434 | 2571 static GaimCmdRet zephyr_gaim_cmd_zir(GaimConversation *conv, |
9896 | 2572 const char *cmd, char **args, char **error, void *data) |
9434 | 2573 { |
9896 | 2574 /* args = instance, recipient, message */ |
2575 zephyr_account *zephyr = gaim_conversation_get_gc(conv)->proto_data; | |
2576 if ( zephyr_send_message(zephyr,"message",args[0],args[1],args[2],zephyr_get_signature(),"")) | |
2577 return GAIM_CMD_RET_OK; | |
2578 else | |
2579 return GAIM_CMD_RET_FAILED; | |
9434 | 2580 } |
2581 | |
2582 static GaimCmdRet zephyr_gaim_cmd_zc(GaimConversation *conv, | |
9896 | 2583 const char *cmd, char **args, char **error, void *data) |
9434 | 2584 { |
9896 | 2585 /* args = class, message */ |
2586 zephyr_account *zephyr = gaim_conversation_get_gc(conv)->proto_data; | |
2587 if ( zephyr_send_message(zephyr,args[0],"PERSONAL","",args[1],zephyr_get_signature(),"")) | |
2588 return GAIM_CMD_RET_OK; | |
2589 else | |
2590 return GAIM_CMD_RET_FAILED; | |
9434 | 2591 } |
2592 | |
9597 | 2593 static void zephyr_register_slash_commands() |
9434 | 2594 { |
2595 | |
9896 | 2596 gaim_cmd_register("msg","ws", GAIM_CMD_P_PRPL, |
2597 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
2598 "prpl-zephyr", | |
2599 zephyr_gaim_cmd_msg, _("msg <nick> <message>: Send a private message to a user"), NULL); | |
9434 | 2600 |
9896 | 2601 gaim_cmd_register("zlocate","w", GAIM_CMD_P_PRPL, |
2602 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
2603 "prpl-zephyr", | |
2604 zephyr_gaim_cmd_zlocate, _("zlocate <nick>: Locate user"), NULL); | |
9434 | 2605 |
9896 | 2606 gaim_cmd_register("zl","w", GAIM_CMD_P_PRPL, |
2607 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
2608 "prpl-zephyr", | |
2609 zephyr_gaim_cmd_zlocate, _("zl <nick>: Locate user"), NULL); | |
9434 | 2610 |
9896 | 2611 gaim_cmd_register("instance","s", GAIM_CMD_P_PRPL, |
2612 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
2613 "prpl-zephyr", | |
2614 zephyr_gaim_cmd_instance, _("instance <instance>: Set the instance to be used on this class"), NULL); | |
9434 | 2615 |
9896 | 2616 gaim_cmd_register("inst","s", GAIM_CMD_P_PRPL, |
2617 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
2618 "prpl-zephyr", | |
2619 zephyr_gaim_cmd_instance, _("inst <instance>: Set the instance to be used on this class"), NULL); | |
9434 | 2620 |
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2621 gaim_cmd_register("topic","s", GAIM_CMD_P_PRPL, |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2622 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2623 "prpl-zephyr", |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2624 zephyr_gaim_cmd_instance, _("topic <instance>: Set the instance to be used on this class"), NULL); |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2625 |
9896 | 2626 gaim_cmd_register("sub", "www", GAIM_CMD_P_PRPL, |
2627 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
2628 "prpl-zephyr", | |
2629 zephyr_gaim_cmd_joinchat_cir, | |
2630 _("sub <class> <instance> <recipient>: Join a new chat"), NULL); | |
9434 | 2631 |
9896 | 2632 gaim_cmd_register("zi","ws", GAIM_CMD_P_PRPL, |
2633 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
2634 "prpl-zephyr", | |
2635 zephyr_gaim_cmd_zi, _("zi <instance>: Send a message to <message,<i>instance</i>,*>"), NULL); | |
9434 | 2636 |
9896 | 2637 gaim_cmd_register("zci","wws",GAIM_CMD_P_PRPL, |
2638 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
2639 "prpl-zephyr", | |
2640 zephyr_gaim_cmd_zci, | |
2641 _("zci <class> <instance>: Send a message to <<i>class</i>,<i>instance</i>,*>"), NULL); | |
9434 | 2642 |
9896 | 2643 gaim_cmd_register("zcir","wwws",GAIM_CMD_P_PRPL, |
2644 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
2645 "prpl-zephyr", | |
2646 zephyr_gaim_cmd_zcir, | |
2647 _("zcir <class> <instance> <recipient>: Send a message to <<i>class</i>,<i>instance</i>,<i>recipient</i>>"), NULL); | |
9434 | 2648 |
9896 | 2649 gaim_cmd_register("zir","wws",GAIM_CMD_P_PRPL, |
2650 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
2651 "prpl-zephyr", | |
2652 zephyr_gaim_cmd_zir, | |
2653 _("zir <instance> <recipient>: Send a message to <MESSAGE,<i>instance</i>,<i>recipient</i>>"), NULL); | |
9434 | 2654 |
9896 | 2655 gaim_cmd_register("zc","ws", GAIM_CMD_P_PRPL, |
2656 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, | |
2657 "prpl-zephyr", | |
2658 zephyr_gaim_cmd_zc, _("zc <class>: Send a message to <<i>class</i>,PERSONAL,*>"), NULL); | |
9597 | 2659 |
9434 | 2660 } |
2661 | |
2662 | |
9896 | 2663 static void |
2664 zephyr_add_deny(GaimConnection *gc, const char *who) | |
2665 { | |
2666 gaim_privacy_deny_add(gc->account,who,1); | |
2667 } | |
2668 | |
2669 static void | |
2670 zephyr_remove_deny(GaimConnection *gc, const char *who) | |
2671 { | |
2672 gaim_privacy_deny_remove(gc->account,who,1); | |
2673 } | |
2674 | |
2675 static void | |
2676 zephyr_add_permit(GaimConnection *gc, const char *who) | |
2677 { | |
2678 gaim_privacy_permit_add(gc->account,who,1); | |
2679 } | |
2680 | |
2681 static void | |
2682 zephyr_remove_permit(GaimConnection *gc, const char *who) | |
2683 { | |
2684 gaim_privacy_permit_remove(gc->account,who,1); | |
2685 } | |
2686 | |
2687 static void | |
2688 zephyr_set_permit_deny(GaimConnection *gc) | |
2689 { | |
2690 /* This doesn't have to do anything, since really, we can just check account->perm_deny when deciding whether to di */ | |
2691 return; | |
2692 } | |
9427 | 2693 static int zephyr_resubscribe(GaimConnection *gc) |
2694 { | |
9896 | 2695 /* Resubscribe to the in-memory list of subscriptions and also |
2696 unsubscriptions*/ | |
2697 zephyr_account *zephyr = gc->proto_data; | |
2698 GSList *s = zephyr->subscrips; | |
2699 zephyr_triple *zt; | |
2700 while (s) { | |
2701 zt = s->data; | |
2702 /* XXX We really should care if this fails */ | |
2703 zephyr_subscribe_to(zephyr,zt->class,zt->instance,zt->recipient,NULL); | |
2704 s = s->next; | |
2705 } | |
2706 /* XXX handle unsubscriptions */ | |
2707 return 1; | |
9427 | 2708 } |
2709 | |
9434 | 2710 |
9427 | 2711 static void zephyr_action_resubscribe(GaimPluginAction *action) |
2712 { | |
2713 | |
9896 | 2714 GaimConnection *gc = (GaimConnection *) action->context; |
2715 zephyr_resubscribe(gc); | |
9427 | 2716 } |
2717 | |
2718 | |
9478 | 2719 static void zephyr_action_get_subs_from_server(GaimPluginAction *action) |
2720 { | |
2721 GaimConnection *gc = (GaimConnection *) action->context; | |
9896 | 2722 zephyr_account *zephyr = gc->proto_data; |
9478 | 2723 gchar *title; |
2724 int retval, nsubs, one,i; | |
2725 ZSubscription_t subs; | |
9896 | 2726 if (use_zeph02(zephyr)) { |
2727 GString* subout = g_string_new("Subscription list<br>"); | |
2728 | |
2729 title = g_strdup_printf("Server subscriptions for %s", zephyr->username); | |
2730 | |
2731 if (zephyr->port == 0) { | |
10867 | 2732 gaim_debug_error("zephyr", "error while retrieving port"); |
9896 | 2733 return; |
2734 } | |
2735 if ((retval = ZRetrieveSubscriptions(zephyr->port,&nsubs)) != ZERR_NONE) { | |
9478 | 2736 /* XXX better error handling */ |
10867 | 2737 gaim_debug_error("zephyr", "error while retrieving subscriptions from server"); |
9478 | 2738 return; |
2739 } | |
9896 | 2740 for(i=0;i<nsubs;i++) { |
2741 one = 1; | |
2742 if ((retval = ZGetSubscriptions(&subs,&one)) != ZERR_NONE) { | |
2743 /* XXX better error handling */ | |
10867 | 2744 gaim_debug_error("zephyr", "error while retrieving individual subscription"); |
9896 | 2745 return; |
2746 } | |
2747 g_string_append_printf(subout, "Class %s Instance %s Recipient %s<br>", | |
2748 subs.zsub_class, subs.zsub_classinst, | |
2749 subs.zsub_recipient); | |
2750 } | |
2751 gaim_notify_formatted(gc, title, title, NULL, subout->str, NULL, NULL); | |
2752 } else { | |
2753 /* XXX fix */ | |
2754 gaim_notify_error(gc,"","tzc doesn't support this action",NULL); | |
9478 | 2755 } |
2756 } | |
2757 | |
2758 | |
9427 | 2759 static GList *zephyr_actions(GaimPlugin *plugin, gpointer context) |
2760 { | |
2761 GList *list = NULL; | |
2762 GaimPluginAction *act = NULL; | |
2763 | |
2764 act = gaim_plugin_action_new(_("Resubscribe"), zephyr_action_resubscribe); | |
2765 list = g_list_append(list, act); | |
2766 | |
9478 | 2767 act = gaim_plugin_action_new(_("Retrieve subscriptions from server"), zephyr_action_get_subs_from_server); |
2768 list = g_list_append(list,act); | |
2769 | |
9427 | 2770 return list; |
2771 } | |
2772 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
2773 static GaimPlugin *my_protocol = NULL; |
2086 | 2774 |
8644 | 2775 static GaimPluginProtocolInfo prpl_info = { |
2776 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_NO_PASSWORD, | |
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11837
diff
changeset
|
2777 NULL, /* ??? user_splits */ |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11837
diff
changeset
|
2778 NULL, /* ??? protocol_options */ |
9478 | 2779 NO_BUDDY_ICONS, |
2780 zephyr_list_icon, | |
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11837
diff
changeset
|
2781 NULL, /* ??? list_emblems */ |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11837
diff
changeset
|
2782 NULL, /* ??? status_text */ |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11837
diff
changeset
|
2783 NULL, /* ??? tooltip_text */ |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11837
diff
changeset
|
2784 zephyr_status_types, /* status_types */ |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11837
diff
changeset
|
2785 NULL, /* ??? blist_node_menu - probably all useful actions are already handled*/ |
9475 | 2786 zephyr_chat_info, /* chat_info */ |
9754 | 2787 NULL, /* chat_info_defaults */ |
9475 | 2788 zephyr_login, /* login */ |
2789 zephyr_close, /* close */ | |
2790 zephyr_send_im, /* send_im */ | |
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11837
diff
changeset
|
2791 NULL, /* XXX set info (Location?) */ |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11837
diff
changeset
|
2792 zephyr_send_typing, /* send_typing */ |
9475 | 2793 zephyr_zloc, /* get_info */ |
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11837
diff
changeset
|
2794 zephyr_set_status, /* set_status */ |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11837
diff
changeset
|
2795 NULL, /* ??? set idle */ |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11837
diff
changeset
|
2796 NULL, /* change password */ |
9475 | 2797 NULL, /* add_buddy */ |
2798 NULL, /* add_buddies */ | |
2799 NULL, /* remove_buddy */ | |
2800 NULL, /* remove_buddies */ | |
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11837
diff
changeset
|
2801 zephyr_add_permit, /* add_permit */ |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11837
diff
changeset
|
2802 zephyr_add_deny, /* add_deny */ |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11837
diff
changeset
|
2803 zephyr_remove_permit, /* remove_permit */ |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11837
diff
changeset
|
2804 zephyr_remove_deny, /* remove_deny */ |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11837
diff
changeset
|
2805 zephyr_set_permit_deny, /* set_permit_deny */ |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11837
diff
changeset
|
2806 zephyr_join_chat, /* join_chat */ |
9896 | 2807 NULL, /* reject_chat -- No chat invites*/ |
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11837
diff
changeset
|
2808 zephyr_get_chat_name, /* get_chat_name */ |
9896 | 2809 NULL, /* chat_invite -- No chat invites*/ |
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11837
diff
changeset
|
2810 zephyr_chat_leave, /* chat_leave */ |
9896 | 2811 NULL, /* chat_whisper -- No "whispering"*/ |
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11837
diff
changeset
|
2812 zephyr_chat_send, /* chat_send */ |
9896 | 2813 NULL, /* keepalive -- Not necessary*/ |
2814 NULL, /* register_user -- Not supported*/ | |
2815 NULL, /* XXX get_cb_info */ | |
9475 | 2816 NULL, /* get_cb_away */ |
2817 NULL, /* alias_buddy */ | |
2818 NULL, /* group_buddy */ | |
2819 NULL, /* rename_group */ | |
9896 | 2820 NULL, /* buddy_free */ |
9475 | 2821 NULL, /* convo_closed */ |
11151 | 2822 NULL, /* normalize */ |
9896 | 2823 NULL, /* XXX set_buddy_icon */ |
9475 | 2824 NULL, /* remove_group */ |
9896 | 2825 NULL, /* XXX get_cb_real_name */ |
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11837
diff
changeset
|
2826 zephyr_chat_set_topic, /* set_chat_topic */ |
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11837
diff
changeset
|
2827 zephyr_find_blist_chat, /* find_blist_chat */ |
9475 | 2828 NULL, /* roomlist_get_list */ |
2829 NULL, /* roomlist_cancel */ | |
9896 | 2830 NULL, /* roomlist_expand_category */ |
9475 | 2831 NULL, /* can_receive_file */ |
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
11837
diff
changeset
|
2832 NULL, /* send_file */ |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12595
diff
changeset
|
2833 NULL, /* new_xfer */ |
12645
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12624
diff
changeset
|
2834 NULL, /* offline_message */ |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12595
diff
changeset
|
2835 NULL, /* whiteboard_prpl_ops */ |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12595
diff
changeset
|
2836 NULL, /* media_prpl_ops */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
2837 }; |
2086 | 2838 |
8644 | 2839 static GaimPluginInfo info = { |
9943 | 2840 GAIM_PLUGIN_MAGIC, |
2841 GAIM_MAJOR_VERSION, | |
2842 GAIM_MINOR_VERSION, | |
9896 | 2843 GAIM_PLUGIN_PROTOCOL, /**< type */ |
8644 | 2844 NULL, /**< ui_requirement */ |
9896 | 2845 0, /**< flags */ |
8644 | 2846 NULL, /**< dependencies */ |
9896 | 2847 GAIM_PRIORITY_DEFAULT, /**< priority */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
2848 |
9896 | 2849 "prpl-zephyr", /**< id */ |
2850 "Zephyr", /**< name */ | |
2851 VERSION, /**< version */ | |
2852 /** summary */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
2853 N_("Zephyr Protocol Plugin"), |
9896 | 2854 /** description */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
2855 N_("Zephyr Protocol Plugin"), |
9896 | 2856 NULL, /**< author */ |
2857 GAIM_WEBSITE, /**< homepage */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
2858 |
9896 | 2859 NULL, /**< load */ |
2860 NULL, /**< unload */ | |
2861 NULL, /**< destroy */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
2862 |
9896 | 2863 NULL, /**< ui_info */ |
8993 | 2864 &prpl_info, /**< extra_info */ |
2865 NULL, | |
9427 | 2866 zephyr_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
2867 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
2868 |
8644 | 2869 static void init_plugin(GaimPlugin * plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
2870 { |
8212 | 2871 GaimAccountOption *option; |
8644 | 2872 char *tmp = get_exposure_level(); |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10867
diff
changeset
|
2873 |
9896 | 2874 option = gaim_account_option_bool_new("Use tzc", "use_tzc", FALSE); |
2875 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
2876 | |
2877 option = gaim_account_option_string_new("tzc command", "tzc_command", "/usr/bin/tzc -e %s"); | |
2878 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
2879 | |
8644 | 2880 option = gaim_account_option_bool_new(_("Export to .anyone"), "write_anyone", FALSE); |
2881 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
8212 | 2882 |
8644 | 2883 option = gaim_account_option_bool_new(_("Export to .zephyr.subs"), "write_zsubs", FALSE); |
2884 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
8212 | 2885 |
10038
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2886 option = gaim_account_option_bool_new(_("Import from .anyone"), "read_anyone", TRUE); |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2887 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2888 |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2889 option = gaim_account_option_bool_new(_("Import from .zephyr.subs"), "read_zsubs", TRUE); |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2890 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2891 |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2892 option = gaim_account_option_string_new(_("Realm"), "realm", ""); |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2893 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2894 |
eb8ccdd6f5f2
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
2895 option = gaim_account_option_string_new(_("Exposure"), "exposure_level", tmp?tmp: EXPOSE_REALMVIS); |
8644 | 2896 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
8212 | 2897 |
8644 | 2898 option = gaim_account_option_string_new(_("Encoding"), "encoding", ZEPHYR_FALLBACK_CHARSET); |
2899 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
8560 | 2900 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
2901 my_protocol = plugin; |
9896 | 2902 zephyr_register_slash_commands(); |
2086 | 2903 } |
2904 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
2905 GAIM_INIT_PLUGIN(zephyr, init_plugin, info); |