Mercurial > pidgin
annotate src/protocols/zephyr/zephyr.c @ 8449:4ae3eb203615
[gaim-migrate @ 9179]
aatharuv is the man: marv requests, he delivers. in this case is html
entity handling that marv's previous patch suggested would require work in
zepher.
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Mon, 15 Mar 2004 05:20:37 +0000 |
parents | 6bd8bc8f07bb |
children | 6b7b5b10cd8a |
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 * |
10 * This program is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
12 * the Free Software Foundation; either version 2 of the License, or | |
13 * (at your option) any later version. | |
14 * | |
15 * This program is distributed in the hope that it will be useful, | |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 * GNU General Public License for more details. | |
19 * | |
20 * You should have received a copy of the GNU General Public License | |
21 * along with this program; if not, write to the Free Software | |
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
23 * | |
24 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
25 /* XXX eww */ |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
26 #include "src/internal.h" |
2086 | 27 |
8212 | 28 #include "accountopt.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
29 #include "debug.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
30 #include "multi.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
31 #include "notify.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
32 #include "prpl.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
33 #include "server.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
34 #include "util.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
35 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
36 #include "zephyr/zephyr.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
37 |
8386 | 38 #include <strings.h> |
39 | |
2086 | 40 extern Code_t ZGetLocations(ZLocations_t *, int *); |
41 extern Code_t ZSetLocation(char *); | |
42 extern Code_t ZUnsetLocation(); | |
43 | |
44 typedef struct _zframe zframe; | |
45 typedef struct _zephyr_triple zephyr_triple; | |
46 | |
47 /* struct I need for zephyr_to_html */ | |
48 struct _zframe { | |
49 /* true for everything but @color, since inside the parens of that one is | |
50 * the color. */ | |
51 gboolean has_closer; | |
52 /* </i>, </font>, </b>, etc. */ | |
53 char *closing; | |
54 /* text including the opening html thingie. */ | |
55 GString *text; | |
56 struct _zframe *enclosing; | |
57 }; | |
58 | |
59 struct _zephyr_triple { | |
60 char *class; | |
61 char *instance; | |
62 char *recipient; | |
63 char *name; | |
64 gboolean open; | |
65 int id; | |
66 }; | |
67 | |
68 #define z_call(func) if (func != ZERR_NONE)\ | |
69 return; | |
70 #define z_call_r(func) if (func != ZERR_NONE)\ | |
71 return TRUE; | |
72 #define z_call_s(func, err) if (func != ZERR_NONE) {\ | |
5606 | 73 gaim_connection_error(zgc, err);\ |
2086 | 74 return;\ |
75 } | |
76 | |
8354 | 77 static const char *local_zephyr_normalize(const char *); |
7322 | 78 static const char *zephyr_normalize(const GaimAccount *, const char *); |
2086 | 79 |
80 /* this is so bad, and if Zephyr weren't so fucked up to begin with I | |
81 * wouldn't do this. but it is so i will. */ | |
82 static guint32 nottimer = 0; | |
83 static guint32 loctimer = 0; | |
5606 | 84 GaimConnection *zgc = NULL; |
2086 | 85 static GList *pending_zloc_names = NULL; |
86 static GSList *subscrips = NULL; | |
87 static int last_id = 0; | |
88 | |
89 /* just for debugging | |
90 static void handle_unknown(ZNotice_t notice) | |
91 { | |
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
92 gaim_debug(GAIM_DEBUG_MISC, "z_packet: %s\n", notice.z_packet); |
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
93 gaim_debug(GAIM_DEBUG_MISC, "z_version: %s\n", notice.z_version); |
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
94 gaim_debug(GAIM_DEBUG_MISC, "z_kind: %d\n", notice.z_kind); |
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
95 gaim_debug(GAIM_DEBUG_MISC, "z_class: %s\n", notice.z_class); |
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
96 gaim_debug(GAIM_DEBUG_MISC, "z_class_inst: %s\n", notice.z_class_inst); |
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
97 gaim_debug(GAIM_DEBUG_MISC, "z_opcode: %s\n", notice.z_opcode); |
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
98 gaim_debug(GAIM_DEBUG_MISC, "z_sender: %s\n", notice.z_sender); |
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
99 gaim_debug(GAIM_DEBUG_MISC, "z_recipient: %s\n", notice.z_recipient); |
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
100 gaim_debug(GAIM_DEBUG_MISC, "z_message: %s\n", notice.z_message); |
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
101 gaim_debug(GAIM_DEBUG_MISC, "z_message_len: %d\n", notice.z_message_len); |
2086 | 102 } |
103 */ | |
104 | |
105 static zephyr_triple *new_triple(const char *c, const char *i, const char *r) | |
106 { | |
107 zephyr_triple *zt; | |
108 zt = g_new0(zephyr_triple, 1); | |
109 zt->class = g_strdup(c); | |
110 zt->instance = g_strdup(i); | |
111 zt->recipient = g_strdup(r); | |
112 zt->name = g_strdup_printf("%s,%s,%s", c, i, r); | |
113 zt->id = ++last_id; | |
114 zt->open = FALSE; | |
115 return zt; | |
116 } | |
117 | |
118 static void free_triple(zephyr_triple *zt) | |
119 { | |
120 g_free(zt->class); | |
121 g_free(zt->instance); | |
122 g_free(zt->recipient); | |
123 g_free(zt->name); | |
124 g_free(zt); | |
125 } | |
126 | |
8354 | 127 static const char* gaim_zephyr_get_sender() { |
128 /* will be useful once this plugin can use a backend other | |
129 than libzephyr */ | |
130 return ZGetSender(); | |
131 } | |
132 | |
133 static const char* gaim_zephyr_get_realm() { | |
134 /* will be useful once this plugin can use a backend other | |
135 than libzephyr */ | |
136 return ZGetRealm(); | |
137 } | |
138 | |
2086 | 139 /* returns true if zt1 is a subset of zt2, i.e. zt2 has the same thing or |
140 * wildcards in each field of zt1. */ | |
141 static gboolean triple_subset(zephyr_triple *zt1, zephyr_triple *zt2) | |
142 { | |
4793 | 143 if (g_ascii_strcasecmp(zt2->class, zt1->class) && |
144 g_ascii_strcasecmp(zt2->class, "*")) { | |
2086 | 145 return FALSE; |
146 } | |
4793 | 147 if (g_ascii_strcasecmp(zt2->instance, zt1->instance) && |
148 g_ascii_strcasecmp(zt2->instance, "*")) { | |
2086 | 149 return FALSE; |
150 } | |
4793 | 151 if (g_ascii_strcasecmp(zt2->recipient, zt1->recipient) && |
152 g_ascii_strcasecmp(zt2->recipient, "*")) { | |
2086 | 153 return FALSE; |
154 } | |
155 return TRUE; | |
156 } | |
157 | |
158 static zephyr_triple *find_sub_by_triple(zephyr_triple *zt) | |
159 { | |
160 zephyr_triple *curr_t; | |
161 GSList *curr = subscrips; | |
162 while (curr) { | |
163 curr_t = curr->data; | |
164 if (triple_subset(zt, curr_t)) | |
165 return curr_t; | |
166 curr = curr->next; | |
167 } | |
168 return NULL; | |
169 } | |
170 | |
171 static zephyr_triple *find_sub_by_id(int id) | |
172 { | |
173 zephyr_triple *zt; | |
174 GSList *curr = subscrips; | |
175 while (curr) { | |
176 zt = curr->data; | |
177 if (zt->id == id) | |
178 return zt; | |
179 curr = curr->next; | |
180 } | |
181 return NULL; | |
182 } | |
183 | |
184 /* utility macros that are useful for zephyr_to_html */ | |
185 | |
186 #define IS_OPENER(c) ((c == '{') || (c == '[') || (c == '(') || (c == '<')) | |
187 #define IS_CLOSER(c) ((c == '}') || (c == ']') || (c == ')') || (c == '>')) | |
188 | |
189 /* this parses zephyr formatting and converts it to html. For example, if | |
190 * you pass in "@{@color(blue)@i(hello)}" you should get out | |
191 * "<font color=blue><i>hello</i></font>". */ | |
192 static char *zephyr_to_html(char *message) | |
193 { | |
194 int len, cnt; | |
195 zframe *frames, *curr; | |
196 char *ret; | |
197 | |
198 frames = g_new(zframe, 1); | |
199 frames->text = g_string_new(""); | |
200 frames->enclosing = NULL; | |
201 frames->closing = ""; | |
202 frames->has_closer = FALSE; | |
203 | |
204 len = strlen(message); | |
205 cnt = 0; | |
206 while (cnt <= len) { | |
207 if (message[cnt] == '@') { | |
208 zframe *new_f; | |
209 char *buf; | |
210 int end; | |
211 for (end=1; (cnt+end) <= len && | |
7070 | 212 !IS_OPENER(message[cnt+end]) && !IS_CLOSER(message[cnt+end]); end++); |
2086 | 213 buf = g_new0(char, end); |
214 if (end) { | |
215 g_snprintf(buf, end, "%s", message+cnt+1); | |
216 } | |
4793 | 217 if (!g_ascii_strcasecmp(buf, "italic") || |
218 !g_ascii_strcasecmp(buf, "i")) { | |
2086 | 219 new_f = g_new(zframe, 1); |
220 new_f->enclosing = frames; | |
221 new_f->text = g_string_new("<i>"); | |
222 new_f->closing = "</i>"; | |
223 new_f->has_closer = TRUE; | |
224 frames = new_f; | |
225 cnt += end+1; /* cnt points to char after opener */ | |
8212 | 226 } else if (!g_ascii_strcasecmp(buf,"small")) { |
227 new_f = g_new(zframe,1); | |
228 new_f->enclosing = frames; | |
229 new_f->text = g_string_new("<font size=\"1\">"); | |
230 new_f->closing ="</font>"; | |
231 frames = new_f; | |
232 cnt+= end+1; | |
233 } else if (!g_ascii_strcasecmp(buf,"normal")) { | |
234 new_f = g_new(zframe,1); | |
235 new_f->enclosing = frames; | |
236 new_f->text = g_string_new("<font size=\"3\">"); | |
237 new_f->closing ="</font>"; | |
238 frames = new_f; | |
239 cnt+= end+1; | |
240 } else if (!g_ascii_strcasecmp(buf,"large")) { | |
241 new_f = g_new(zframe,1); | |
242 new_f->enclosing = frames; | |
243 new_f->text = g_string_new("<font size=\"5\">"); | |
244 new_f->closing ="</font>"; | |
245 frames = new_f; | |
246 cnt+= end+1; | |
247 } else if (!g_ascii_strcasecmp(buf, "bold") | |
248 || !g_ascii_strcasecmp(buf, "b")) { | |
2086 | 249 new_f = g_new(zframe, 1); |
250 new_f->enclosing = frames; | |
251 new_f->text = g_string_new("<b>"); | |
252 new_f->closing = "</b>"; | |
253 new_f->has_closer = TRUE; | |
254 frames = new_f; | |
255 cnt += end+1; | |
4793 | 256 } else if (!g_ascii_strcasecmp(buf, "color")) { |
2086 | 257 cnt += end+1; |
258 new_f = g_new(zframe, 1); | |
259 new_f->enclosing = frames; | |
260 new_f->text = g_string_new("<font color="); | |
261 for (; (cnt <= len) && !IS_CLOSER(message[cnt]); cnt++) { | |
262 g_string_append_c(new_f->text, message[cnt]); | |
263 } | |
264 cnt++; /* point to char after closer */ | |
265 g_string_append_c(new_f->text, '>'); | |
266 new_f->closing = "</font>"; | |
267 new_f->has_closer = FALSE; | |
268 frames = new_f; | |
4793 | 269 } else if (!g_ascii_strcasecmp(buf, "")) { |
2086 | 270 new_f = g_new(zframe, 1); |
271 new_f->enclosing = frames; | |
272 new_f->text = g_string_new(""); | |
273 new_f->closing = ""; | |
274 new_f->has_closer = TRUE; | |
275 frames = new_f; | |
276 cnt += end+1; /* cnt points to char after opener */ | |
277 } else { | |
278 if ((cnt+end) > len) { | |
279 g_string_append_c(frames->text, '@'); | |
280 cnt++; | |
7070 | 281 } else if (IS_CLOSER(message[cnt+end])) { |
282 /* We have @chars..closer . This is | |
283 merely a sequence of chars that isn't a formatting tag | |
284 */ | |
285 int tmp=cnt; | |
286 while (tmp<=cnt+end) { | |
287 g_string_append_c(frames->text,message[tmp]); | |
288 tmp++; | |
289 } | |
290 cnt+=end+1; | |
291 } else { | |
2086 | 292 /* unrecognized thingie. act like it's not there, but we |
293 * still need to take care of the corresponding closer, | |
294 * make a frame that does nothing. */ | |
295 new_f = g_new(zframe, 1); | |
296 new_f->enclosing = frames; | |
297 new_f->text = g_string_new(""); | |
298 new_f->closing = ""; | |
299 new_f->has_closer = TRUE; | |
300 frames = new_f; | |
301 cnt += end+1; /* cnt points to char after opener */ | |
302 } | |
303 } | |
304 } else if (IS_CLOSER(message[cnt])) { | |
305 zframe *popped; | |
306 gboolean last_had_closer; | |
307 if (frames->enclosing) { | |
308 do { | |
309 popped = frames; | |
310 frames = frames->enclosing; | |
311 g_string_append(frames->text, popped->text->str); | |
312 g_string_append(frames->text, popped->closing); | |
313 g_string_free(popped->text, TRUE); | |
314 last_had_closer = popped->has_closer; | |
315 g_free(popped); | |
316 } while (frames && frames->enclosing && !last_had_closer); | |
317 } else { | |
318 g_string_append_c(frames->text, message[cnt]); | |
319 } | |
320 cnt++; | |
321 } else if (message[cnt] == '\n') { | |
322 g_string_append(frames->text, "<br>"); | |
323 cnt++; | |
324 } else { | |
325 g_string_append_c(frames->text, message[cnt++]); | |
326 } | |
327 } | |
328 /* go through all the stuff that they didn't close */ | |
329 while (frames->enclosing) { | |
330 curr = frames; | |
331 g_string_append(frames->enclosing->text, frames->text->str); | |
332 g_string_append(frames->enclosing->text, frames->closing); | |
333 g_string_free(frames->text, TRUE); | |
334 frames = frames->enclosing; | |
335 g_free(curr); | |
336 } | |
337 ret = frames->text->str; | |
338 g_string_free(frames->text, FALSE); | |
339 g_free(frames); | |
340 return ret; | |
341 } | |
342 | |
343 static gboolean pending_zloc(char *who) | |
344 { | |
345 GList *curr; | |
346 for (curr = pending_zloc_names; curr != NULL; curr = curr->next) { | |
8354 | 347 if (!g_ascii_strcasecmp(local_zephyr_normalize(who), (char*)curr->data)) { |
2086 | 348 g_free((char*)curr->data); |
349 pending_zloc_names = g_list_remove(pending_zloc_names, curr->data); | |
350 return TRUE; | |
351 } | |
352 } | |
353 return FALSE; | |
354 } | |
355 | |
356 static void handle_message(ZNotice_t notice, struct sockaddr_in from) | |
357 { | |
4793 | 358 if (!g_ascii_strcasecmp(notice.z_class, LOGIN_CLASS)) { |
3277 | 359 /* well, we'll be updating in 20 seconds anyway, might as well ignore this. */ |
4793 | 360 } else if (!g_ascii_strcasecmp(notice.z_class, LOCATE_CLASS)) { |
361 if (!g_ascii_strcasecmp(notice.z_opcode, LOCATE_LOCATE)) { | |
2086 | 362 int nlocs; |
363 char *user; | |
6695 | 364 GaimBuddy *b; |
2086 | 365 |
366 if (ZParseLocations(¬ice, NULL, &nlocs, &user) != ZERR_NONE) | |
367 return; | |
8435 | 368 |
369 if ((b = gaim_find_buddy(zgc->account, user)) == NULL) { | |
2086 | 370 char *e = strchr(user, '@'); |
8435 | 371 if(e && !g_ascii_strcasecmp(e+1,gaim_zephyr_get_realm()) ) { |
372 *e = '\0'; | |
373 } | |
4687 | 374 b = gaim_find_buddy(zgc->account, user); |
8435 | 375 } |
376 if ((b && pending_zloc(b->name)) || pending_zloc(user) ) { | |
2086 | 377 ZLocations_t locs; |
378 int one = 1; | |
379 GString *str = g_string_new(""); | |
8435 | 380 g_string_append_printf(str, _("<b>User:</b> %s<br>"), b?b->name:user); |
381 if (b && b->alias) | |
5132 | 382 g_string_append_printf(str, _("<b>Alias:</b> %s<br>"), b->alias); |
2086 | 383 if (!nlocs) { |
5132 | 384 g_string_append_printf(str, _("<br>Hidden or not logged-in")); |
2086 | 385 } |
386 for (; nlocs > 0; nlocs--) { | |
387 ZGetLocations(&locs, &one); | |
5132 | 388 g_string_append_printf(str, _("<br>At %s since %s"), locs.host, |
2086 | 389 locs.time); |
390 } | |
7062
86ed8b2aa665
[gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
391 gaim_notify_formatted(zgc, NULL, _("Buddy Information"), |
86ed8b2aa665
[gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
392 NULL, str->str, NULL, NULL); |
2086 | 393 g_string_free(str, TRUE); |
394 } else | |
4732 | 395 serv_got_update(zgc, b->name, nlocs, 0, 0, 0, 0); |
2086 | 396 |
397 free(user); | |
398 } | |
399 } else { | |
400 char *buf, *buf2; | |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
401 char *send_inst; |
3277 | 402 char *realmptr; |
8212 | 403 GaimConversation *gconv1; |
404 GaimConvChat *gcc; | |
2086 | 405 char *ptr = notice.z_message + strlen(notice.z_message) + 1; |
7475 | 406 int len = notice.z_message_len - ((int)ptr - (int)notice.z_message); |
8354 | 407 char *sendertmp = g_strdup_printf("%s",gaim_zephyr_get_sender()); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7084
diff
changeset
|
408 GaimConvImFlags flags = 0; |
2086 | 409 if (len > 0) { |
8449 | 410 gchar* tmpescape; |
2086 | 411 buf = g_malloc(len + 1); |
412 g_snprintf(buf, len + 1, "%s", ptr); | |
413 g_strchomp(buf); | |
8449 | 414 tmpescape = gaim_escape_html(buf); |
415 buf2 = zephyr_to_html(tmpescape); | |
2086 | 416 g_free(buf); |
8449 | 417 g_free(tmpescape); |
4793 | 418 if (!g_ascii_strcasecmp(notice.z_class, "MESSAGE") && |
419 !g_ascii_strcasecmp(notice.z_class_inst, "PERSONAL")) { | |
420 if (!g_ascii_strcasecmp(notice.z_message, "Automated reply:")) | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7084
diff
changeset
|
421 flags |= GAIM_CONV_IM_AUTO_RESP; |
6982 | 422 serv_got_im(zgc, notice.z_sender, buf2, flags, time(NULL)); |
2086 | 423 } else { |
424 zephyr_triple *zt1, *zt2; | |
425 zt1 = new_triple(notice.z_class, notice.z_class_inst, | |
4687 | 426 notice.z_recipient); |
2086 | 427 zt2 = find_sub_by_triple(zt1); |
428 if (!zt2) { | |
429 /* we shouldn't be subscribed to this message. ignore. */ | |
430 } else { | |
8212 | 431 GList *gltmp; |
432 int found=0; | |
2086 | 433 if (!zt2->open) { |
434 zt2->open = TRUE; | |
435 serv_got_joined_chat(zgc, zt2->id, zt2->name); | |
8212 | 436 gconv1 = gaim_find_conversation_with_account(zt2->name,zgc->account); |
437 gcc = gaim_conversation_get_chat_data(gconv1); | |
438 gaim_conv_chat_set_topic(gcc,sendertmp,notice.z_class_inst); | |
439 | |
2086 | 440 } |
3277 | 441 /* If the person is in the default Realm, then strip the |
442 Realm from the sender field */ | |
443 sendertmp = g_strdup_printf("%s",notice.z_sender); | |
4682 | 444 if ((realmptr = strchr(sendertmp,'@')) != NULL) { |
4588 | 445 realmptr++; |
8354 | 446 if (!g_ascii_strcasecmp(realmptr,gaim_zephyr_get_realm())) { |
4588 | 447 realmptr--; |
448 sprintf(realmptr,"%c",'\0'); | |
449 send_inst = g_strdup_printf("%s %s",sendertmp, | |
450 notice.z_class_inst); | |
451 } else { | |
452 send_inst = g_strdup_printf("%s %s",notice.z_sender, | |
453 notice.z_class_inst); | |
454 } | |
3277 | 455 } else { |
4588 | 456 send_inst = g_strdup_printf("%s %s",sendertmp,notice.z_class_inst); |
3277 | 457 } |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
458 serv_got_chat_in(zgc, zt2->id, send_inst, FALSE, |
4687 | 459 buf2, time(NULL)); |
8212 | 460 |
461 gconv1 = gaim_find_conversation_with_account(zt2->name,zgc->account); | |
462 gcc = gaim_conversation_get_chat_data(gconv1); | |
8354 | 463 /* gaim_conv_chat_set_topic(gcc,sendertmp,notice.z_class_inst); */ |
8212 | 464 for(gltmp = gaim_conv_chat_get_users(gcc);gltmp;gltmp=gltmp->next) { |
465 if (!g_ascii_strcasecmp(gltmp->data,sendertmp) ) | |
466 found = 1; | |
467 } | |
468 if (!found) { | |
469 /* force interpretation in network byte order */ | |
470 unsigned char* addrs = (unsigned char *)&(notice.z_sender_addr.s_addr); | |
471 gaim_conv_chat_add_user(gcc,sendertmp,g_strdup_printf("%hhd.%hhd.%hhd.%hhd", | |
472 (unsigned char)addrs[0], | |
473 (unsigned char)addrs[1], | |
474 (unsigned char)addrs[2], | |
475 (unsigned char)addrs[3])); | |
476 | |
477 } | |
3277 | 478 g_free(sendertmp); |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
479 g_free(send_inst); |
2086 | 480 } |
481 free_triple(zt1); | |
482 } | |
483 g_free(buf2); | |
484 } | |
485 } | |
486 } | |
487 | |
488 static gint check_notify(gpointer data) | |
489 { | |
490 while (ZPending()) { | |
491 ZNotice_t notice; | |
492 struct sockaddr_in from; | |
493 z_call_r(ZReceiveNotice(¬ice, &from)); | |
494 | |
495 switch (notice.z_kind) { | |
496 case UNSAFE: | |
497 case UNACKED: | |
498 case ACKED: | |
499 handle_message(notice, from); | |
500 break; | |
501 default: | |
502 /* we'll just ignore things for now */ | |
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
503 gaim_debug(GAIM_DEBUG_WARNING, "zephyr", "Unhandled notice.\n"); |
2086 | 504 break; |
505 } | |
506 | |
507 ZFreeNotice(¬ice); | |
508 } | |
509 | |
510 return TRUE; | |
511 } | |
512 | |
513 static gint check_loc(gpointer data) | |
514 { | |
6695 | 515 GaimBlistNode *gnode, *cnode, *bnode; |
2086 | 516 ZAsyncLocateData_t ald; |
517 | |
518 ald.user = NULL; | |
519 memset(&(ald.uid), 0, sizeof(ZUnique_Id_t)); | |
520 ald.version = NULL; | |
521 | |
4785 | 522 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
523 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
524 continue; | |
6695 | 525 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
526 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 527 continue; |
6935 | 528 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
6695 | 529 GaimBuddy *b = (GaimBuddy *)bnode; |
530 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
531 continue; | |
532 if(b->account->gc == zgc) { | |
7261 | 533 const char *chk; |
8354 | 534 chk = local_zephyr_normalize(b->name); |
6695 | 535 /* doesn't matter if this fails or not; we'll just move on to the next one */ |
536 ZRequestLocations(chk, &ald, UNACKED, ZAUTH); | |
537 free(ald.user); | |
538 free(ald.version); | |
539 } | |
4349 | 540 } |
2086 | 541 } |
542 } | |
543 | |
544 return TRUE; | |
545 } | |
546 | |
547 static char *get_exposure_level() | |
548 { | |
549 char *exposure = ZGetVariable("exposure"); | |
550 | |
551 if (!exposure) | |
552 return EXPOSE_REALMVIS; | |
4793 | 553 if (!g_ascii_strcasecmp(exposure, EXPOSE_NONE)) |
2086 | 554 return EXPOSE_NONE; |
4793 | 555 if (!g_ascii_strcasecmp(exposure, EXPOSE_OPSTAFF)) |
2086 | 556 return EXPOSE_OPSTAFF; |
4793 | 557 if (!g_ascii_strcasecmp(exposure, EXPOSE_REALMANN)) |
2086 | 558 return EXPOSE_REALMANN; |
4793 | 559 if (!g_ascii_strcasecmp(exposure, EXPOSE_NETVIS)) |
2086 | 560 return EXPOSE_NETVIS; |
4793 | 561 if (!g_ascii_strcasecmp(exposure, EXPOSE_NETANN)) |
2086 | 562 return EXPOSE_NETANN; |
563 return EXPOSE_REALMVIS; | |
564 } | |
565 | |
566 static void strip_comments(char *str) | |
567 { | |
568 char *tmp = strchr(str, '#'); | |
569 if (tmp) | |
570 *tmp = '\0'; | |
571 g_strchug(str); | |
572 g_strchomp(str); | |
573 } | |
574 | |
575 static void process_zsubs() | |
576 { | |
577 FILE *f; | |
578 gchar *fname; | |
579 gchar buff[BUFSIZ]; | |
580 | |
3630 | 581 fname = g_strdup_printf("%s/.zephyr.subs", gaim_home_dir()); |
2086 | 582 f = fopen(fname, "r"); |
583 if (f) { | |
584 char **triple; | |
585 ZSubscription_t sub; | |
586 char *recip; | |
587 while (fgets(buff, BUFSIZ, f)) { | |
588 strip_comments(buff); | |
589 if (buff[0]) { | |
590 triple = g_strsplit(buff, ",", 3); | |
3277 | 591 if (triple[0] && triple[1] ) { |
8354 | 592 char *tmp = g_strdup_printf("%s",gaim_zephyr_get_sender()); |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
593 char *atptr; |
2086 | 594 sub.zsub_class = triple[0]; |
595 sub.zsub_classinst = triple[1]; | |
3277 | 596 if(triple[2] == NULL) { |
597 recip = g_malloc0(1); | |
4793 | 598 } else if (!g_ascii_strcasecmp(triple[2], "%me%")) { |
8354 | 599 recip = g_strdup_printf("%s",gaim_zephyr_get_sender()); |
4793 | 600 } else if (!g_ascii_strcasecmp(triple[2], "*")) { |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
601 /* wildcard |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
602 * form of class,instance,* */ |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
603 recip = g_malloc0(1); |
4793 | 604 } else if (!g_ascii_strcasecmp(triple[2], tmp)) { |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
605 /* form of class,instance,aatharuv@ATHENA.MIT.EDU */ |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
606 recip = g_strdup(triple[2]); |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
607 } else if ((atptr = strchr(triple[2], '@')) != NULL) { |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
608 /* form of class,instance,*@ANDREW.CMU.EDU |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
609 * class,instance,@ANDREW.CMU.EDU |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
610 * If realm is local realm, blank recipient, else |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
611 * @REALM-NAME |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
612 */ |
8354 | 613 char *realmat = g_strdup_printf("@%s", gaim_zephyr_get_realm()); |
4793 | 614 if (!g_ascii_strcasecmp(atptr, realmat)) |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
615 recip = g_malloc0(1); |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
616 else |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
617 recip = g_strdup(atptr); |
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
618 g_free(realmat); |
2086 | 619 } else { |
620 recip = g_strdup(triple[2]); | |
621 } | |
2804
1648c703ddc2
[gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2791
diff
changeset
|
622 g_free(tmp); |
2086 | 623 sub.zsub_recipient = recip; |
624 if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) { | |
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
625 gaim_debug(GAIM_DEBUG_ERROR, "zephyr", |
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
626 "Couldn't subscribe to %s, %s, %s\n", |
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
627 sub.zsub_class, |
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
628 sub.zsub_classinst, |
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
629 sub.zsub_recipient); |
2086 | 630 } |
631 subscrips = g_slist_append(subscrips, | |
632 new_triple(triple[0], triple[1], recip)); | |
633 g_free(recip); | |
634 } | |
635 g_strfreev(triple); | |
636 } | |
637 } | |
638 } | |
639 } | |
640 | |
641 static void process_anyone() | |
642 { | |
643 FILE *fd; | |
644 gchar buff[BUFSIZ], *filename; | |
6695 | 645 GaimGroup *g; |
646 GaimBuddy *b; | |
4775 | 647 |
648 if (!(g = gaim_find_group(_("Anyone")))) { | |
649 g = gaim_group_new(_("Anyone")); | |
650 gaim_blist_add_group(g, NULL); | |
651 } | |
6695 | 652 |
3630 | 653 filename = g_strconcat(gaim_home_dir(), "/.anyone", NULL); |
2086 | 654 if ((fd = fopen(filename, "r")) != NULL) { |
655 while (fgets(buff, BUFSIZ, fd)) { | |
656 strip_comments(buff); | |
4687 | 657 if (buff[0]) { |
8212 | 658 if(! (b=gaim_find_buddy(zgc->account,buff))) { |
659 b = gaim_buddy_new(zgc->account, buff, NULL); | |
660 gaim_blist_add_buddy(b, NULL, g, NULL); | |
661 } | |
4687 | 662 } |
2086 | 663 } |
664 fclose(fd); | |
665 } | |
666 g_free(filename); | |
667 } | |
668 | |
5606 | 669 static void zephyr_login(GaimAccount *account) |
2086 | 670 { |
671 ZSubscription_t sub; | |
672 | |
673 if (zgc) { | |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
674 gaim_notify_error(account->gc, NULL, |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
675 _("Already logged in with Zephyr"), |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
676 _("Because Zephyr uses your system username, you " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
677 "are unable to have multiple accounts on it " |
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5234
diff
changeset
|
678 "when logged in as the same user.")); |
2086 | 679 return; |
680 } | |
681 | |
5606 | 682 zgc = gaim_account_get_connection(account); |
2086 | 683 |
684 z_call_s(ZInitialize(), "Couldn't initialize zephyr"); | |
685 z_call_s(ZOpenPort(NULL), "Couldn't open port"); | |
8354 | 686 z_call_s(ZSetLocation((char *)gaim_account_get_string(zgc->account,"exposure_level",EXPOSE_REALMVIS)), "Couldn't set location"); |
2086 | 687 |
688 sub.zsub_class = "MESSAGE"; | |
689 sub.zsub_classinst = "PERSONAL"; | |
8354 | 690 sub.zsub_recipient = (char *)gaim_zephyr_get_sender(); |
2086 | 691 |
692 /* we don't care if this fails. i'm lying right now. */ | |
693 if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) { | |
6484
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
694 gaim_debug(GAIM_DEBUG_ERROR, "zephyr", |
5ced8e111473
[gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
695 "Couldn't subscribe to messages!\n"); |
2086 | 696 } |
697 | |
5606 | 698 gaim_connection_set_state(zgc, GAIM_CONNECTED); |
2086 | 699 serv_finish_login(zgc); |
700 | |
701 process_anyone(); | |
702 process_zsubs(); | |
703 | |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8212
diff
changeset
|
704 nottimer = gaim_timeout_add(100, check_notify, NULL); |
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8212
diff
changeset
|
705 loctimer = gaim_timeout_add(20000, check_loc, NULL); |
2086 | 706 } |
707 | |
708 static void write_zsubs() | |
709 { | |
710 GSList *s = subscrips; | |
711 zephyr_triple *zt; | |
712 FILE *fd; | |
713 char *fname; | |
714 | |
3277 | 715 char** triple; |
3630 | 716 fname = g_strdup_printf("%s/.zephyr.subs", gaim_home_dir()); |
2086 | 717 fd = fopen(fname, "w"); |
718 | |
719 if (!fd) { | |
720 g_free(fname); | |
721 return; | |
722 } | |
723 | |
724 while (s) { | |
725 zt = s->data; | |
3277 | 726 triple = g_strsplit(zt->name,",",3); |
727 if (triple[2] != NULL) { | |
4793 | 728 if (!g_ascii_strcasecmp(triple[2], "")) { |
3277 | 729 fprintf(fd, "%s,%s,*\n", triple[0], triple[1]); |
8354 | 730 } else if (!g_ascii_strcasecmp(triple[2], gaim_zephyr_get_sender())) { |
3277 | 731 fprintf(fd, "%s,%s,%%me%%\n",triple[0],triple[1]); |
732 } else { | |
733 fprintf(fd, "%s\n", zt->name); | |
734 } | |
735 } else { | |
736 fprintf(fd, "%s,%s,*\n",triple[0], triple[1]); | |
737 } | |
738 g_free(triple); | |
2086 | 739 s = s->next; |
740 } | |
741 g_free(fname); | |
742 fclose(fd); | |
743 } | |
744 | |
745 static void write_anyone() | |
746 { | |
6695 | 747 GaimBlistNode *gnode, *cnode, *bnode; |
748 GaimBuddy *b; | |
3277 | 749 char *ptr, *fname, *ptr2; |
2086 | 750 FILE *fd; |
751 | |
3630 | 752 fname = g_strdup_printf("%s/.anyone", gaim_home_dir()); |
2086 | 753 fd = fopen(fname, "w"); |
754 if (!fd) { | |
755 g_free(fname); | |
756 return; | |
757 } | |
758 | |
4785 | 759 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
760 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
761 continue; | |
6695 | 762 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
763 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 764 continue; |
8212 | 765 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
6695 | 766 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
767 continue; | |
768 b = (GaimBuddy *)bnode; | |
8212 | 769 if(b->account == zgc->account) { |
6695 | 770 if ((ptr = strchr(b->name, '@')) != NULL) { |
771 ptr2 = ptr + 1; | |
772 /* We should only strip the realm name if the principal | |
773 is in the user's realm | |
774 */ | |
8354 | 775 if (!g_ascii_strcasecmp(ptr2,gaim_zephyr_get_realm())) { |
6695 | 776 *ptr = '\0'; |
777 } | |
4349 | 778 } |
6695 | 779 fprintf(fd, "%s\n", b->name); |
780 if (ptr) | |
781 *ptr = '@'; | |
3277 | 782 } |
783 } | |
2086 | 784 } |
785 } | |
786 | |
787 fclose(fd); | |
788 g_free(fname); | |
789 } | |
790 | |
5606 | 791 static void zephyr_close(GaimConnection *gc) |
2086 | 792 { |
793 GList *l; | |
794 GSList *s; | |
795 l = pending_zloc_names; | |
796 while (l) { | |
797 g_free((char*)l->data); | |
798 l = l->next; | |
799 } | |
800 g_list_free(pending_zloc_names); | |
801 | |
8212 | 802 if (gaim_account_get_bool(zgc->account,"write_anyone",FALSE)) |
803 write_anyone(); | |
804 | |
805 if (gaim_account_get_bool(zgc->account,"write_zsubs",FALSE)) | |
806 write_zsubs(); | |
2086 | 807 |
808 s = subscrips; | |
809 while (s) { | |
810 free_triple((zephyr_triple*)s->data); | |
811 s = s->next; | |
812 } | |
813 g_slist_free(subscrips); | |
814 | |
815 if (nottimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
816 gaim_timeout_remove(nottimer); |
2086 | 817 nottimer = 0; |
818 if (loctimer) | |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
819 gaim_timeout_remove(loctimer); |
2086 | 820 loctimer = 0; |
821 zgc = NULL; | |
822 z_call(ZCancelSubscriptions(0)); | |
823 z_call(ZUnsetLocation()); | |
824 z_call(ZClosePort()); | |
825 } | |
826 | |
8212 | 827 static void zephyr_add_buddy(GaimConnection *gc, const char *buddy, GaimGroup *group) { |
828 GaimBuddy *b; | |
829 if(! (b=gaim_find_buddy(zgc->account,buddy))) { | |
830 b = gaim_buddy_new(zgc->account, buddy, NULL); | |
831 gaim_blist_add_buddy(b, NULL, group, NULL); | |
832 } | |
8354 | 833 } |
834 | |
835 static void zephyr_add_buddies(GaimConnection *gc, GList* buddies) { | |
836 GaimGroup *group; | |
837 if (!(group = gaim_find_group(_("Anyone")))) { | |
838 group = gaim_group_new(_("Anyone")); | |
839 gaim_blist_add_group(group, NULL); | |
840 } | |
841 while (buddies) { | |
842 zephyr_add_buddy(gc, buddies->data, group); | |
843 buddies = buddies->next; | |
844 } | |
8212 | 845 } |
846 | |
847 static void zephyr_remove_buddy(GaimConnection *gc, const char *buddy, const char *group) { | |
848 GaimBuddy *b; | |
849 fprintf(stderr,"In zephyr_remove_buddy\n"); | |
850 if ((b=gaim_find_buddy(zgc->account,buddy))) | |
851 gaim_blist_remove_buddy(b); | |
852 else | |
853 fprintf(stderr,"attempt to remove non-existent buddy %s\n",buddy); | |
854 } | |
2086 | 855 |
8354 | 856 static void zephyr_remove_buddies(GaimConnection *gc, GList *buddies, const char *group) { |
857 GaimBuddy *b; | |
858 while(buddies) { | |
859 if ((b=gaim_find_buddy(zgc->account,buddies->data))) { | |
860 gaim_blist_remove_buddy(b); | |
861 } else { | |
862 fprintf(stderr,"attempt to remove non-existent buddy %s\n",(char *)buddies->data); | |
863 } | |
864 } | |
865 } | |
866 | |
6059 | 867 static int zephyr_chat_send(GaimConnection *gc, int id, const char *im) |
2086 | 868 { |
869 ZNotice_t notice; | |
870 zephyr_triple *zt; | |
871 char *buf; | |
872 const char *sig; | |
8212 | 873 GaimConversation * gconv1; |
874 GaimConvChat* gcc; | |
875 char * inst; | |
2086 | 876 |
877 zt = find_sub_by_id(id); | |
878 if (!zt) | |
879 /* this should never happen. */ | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
880 return -EINVAL; |
2086 | 881 |
882 sig = ZGetVariable("zwrite-signature"); | |
883 if (!sig) { | |
884 sig = g_get_real_name(); | |
885 } | |
886 buf = g_strdup_printf("%s%c%s", sig, '\0', im); | |
887 | |
8212 | 888 gconv1 = gaim_find_conversation_with_account(zt->name,zgc->account); |
889 gcc = gaim_conversation_get_chat_data(gconv1); | |
890 | |
8354 | 891 if(!(inst = (char *)gaim_conv_chat_get_topic(gcc))) |
892 inst = (char *)notice.z_class_inst; | |
8212 | 893 |
2086 | 894 bzero((char *)¬ice, sizeof(notice)); |
895 notice.z_kind = ACKED; | |
896 notice.z_port = 0; | |
897 notice.z_opcode = ""; | |
898 notice.z_class = zt->class; | |
8212 | 899 notice.z_class_inst = inst; |
4793 | 900 if (!g_ascii_strcasecmp(zt->recipient, "*")) |
8354 | 901 notice.z_recipient = local_zephyr_normalize(""); |
2086 | 902 else |
8354 | 903 notice.z_recipient = local_zephyr_normalize(zt->recipient); |
2086 | 904 notice.z_sender = 0; |
905 notice.z_default_format = | |
906 "Class $class, Instance $instance:\n" | |
907 "To: @bold($recipient) at $time $date\n" | |
908 "From: @bold($1) <$sender>\n\n$2"; | |
8212 | 909 notice.z_message_len = strlen(im) + strlen(sig) + 2; |
2086 | 910 notice.z_message = buf; |
911 ZSendNotice(¬ice, ZAUTH); | |
912 g_free(buf); | |
2167
edf8c5a70e5b
[gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2162
diff
changeset
|
913 return 0; |
2086 | 914 } |
915 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7084
diff
changeset
|
916 static int zephyr_send_im(GaimConnection *gc, const char *who, const char *im, GaimConvImFlags flags) { |
2086 | 917 ZNotice_t notice; |
918 char *buf; | |
919 const char *sig; | |
920 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7084
diff
changeset
|
921 if (flags & GAIM_CONV_IM_AUTO_RESP) |
2086 | 922 sig = "Automated reply:"; |
923 else { | |
924 sig = ZGetVariable("zwrite-signature"); | |
925 if (!sig) { | |
926 sig = g_get_real_name(); | |
927 } | |
928 } | |
929 buf = g_strdup_printf("%s%c%s", sig, '\0', im); | |
930 | |
931 bzero((char *)¬ice, sizeof(notice)); | |
932 notice.z_kind = ACKED; | |
933 notice.z_port = 0; | |
934 notice.z_opcode = ""; | |
935 notice.z_class = "MESSAGE"; | |
936 notice.z_class_inst = "PERSONAL"; | |
937 notice.z_sender = 0; | |
938 notice.z_recipient = who; | |
939 notice.z_default_format = | |
940 "Class $class, Instance $instance:\n" | |
941 "To: @bold($recipient) at $time $date\n" | |
942 "From: @bold($1) <$sender>\n\n$2"; | |
8212 | 943 notice.z_message_len = strlen(im) + strlen(sig) + 2; |
2086 | 944 notice.z_message = buf; |
6904 | 945 ZSendNotice(¬ice, ZAUTH); |
2086 | 946 g_free(buf); |
2303
f5bf315e6104
[gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2231
diff
changeset
|
947 return 1; |
2086 | 948 } |
949 | |
7322 | 950 static const char *zephyr_normalize(const GaimAccount *account,const char *orig) |
2086 | 951 { |
952 static char buf[80]; | |
7126 | 953 if (!g_ascii_strcasecmp(orig, "")) { |
954 buf[0] = '\0'; | |
955 return buf; | |
8354 | 956 } else { |
957 g_snprintf(buf,80,"%s",orig); | |
958 } | |
959 return buf; | |
960 } | |
961 | |
962 | |
963 static const char *local_zephyr_normalize(const char *orig) | |
964 { | |
965 static char buf[80]; | |
966 if (!g_ascii_strcasecmp(orig, "")) { | |
967 buf[0] = '\0'; | |
968 return buf; | |
7126 | 969 } |
8354 | 970 |
2086 | 971 if (strchr(orig, '@')) { |
972 g_snprintf(buf, 80, "%s", orig); | |
973 } else { | |
8354 | 974 g_snprintf(buf,80,"%s@%s",orig,gaim_zephyr_get_realm()); |
2086 | 975 } |
976 return buf; | |
977 } | |
978 | |
5606 | 979 static void zephyr_zloc(GaimConnection *gc, const char *who) |
2086 | 980 { |
981 ZAsyncLocateData_t ald; | |
7261 | 982 |
8354 | 983 if (ZRequestLocations(local_zephyr_normalize(who), &ald, UNACKED, ZAUTH) |
2086 | 984 != ZERR_NONE) { |
985 return; | |
986 } | |
987 pending_zloc_names = g_list_append(pending_zloc_names, | |
8354 | 988 g_strdup(local_zephyr_normalize(who))); |
2086 | 989 } |
990 | |
5606 | 991 static GList *zephyr_buddy_menu(GaimConnection *gc, const char *who) |
2086 | 992 { |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
993 GList *m = NULL; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
994 struct proto_buddy_menu *pbm; |
2086 | 995 |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
996 pbm = g_new0(struct proto_buddy_menu, 1); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
997 pbm->label = _("ZLocate"); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
998 pbm->callback = zephyr_zloc; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
999 pbm->gc = gc; |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1000 m = g_list_append(m, pbm); |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1001 |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
1002 return m; |
2086 | 1003 } |
1004 | |
6059 | 1005 static void zephyr_set_away(GaimConnection *gc, const char *state, const char *msg) |
2086 | 1006 { |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
1007 if (gc->away) { |
2086 | 1008 g_free(gc->away); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
1009 gc->away = NULL; |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
1010 } |
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
1011 |
5132 | 1012 if (!g_ascii_strcasecmp(state, _("Hidden"))) { |
2086 | 1013 ZSetLocation(EXPOSE_OPSTAFF); |
4111
ee884f1d7ae3
[gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents:
3867
diff
changeset
|
1014 gc->away = g_strdup(""); |
5132 | 1015 } else if (!g_ascii_strcasecmp(state, _("Online"))) |
2086 | 1016 ZSetLocation(get_exposure_level()); |
1017 else /* state is GAIM_AWAY_CUSTOM */ if (msg) | |
1018 gc->away = g_strdup(msg); | |
1019 } | |
1020 | |
5606 | 1021 static GList *zephyr_away_states(GaimConnection *gc) |
2086 | 1022 { |
1023 GList *m = NULL; | |
1024 | |
5132 | 1025 m = g_list_append(m, _("Online")); |
2086 | 1026 m = g_list_append(m, GAIM_AWAY_CUSTOM); |
5132 | 1027 m = g_list_append(m, _("Hidden")); |
2086 | 1028 |
1029 return m; | |
1030 } | |
1031 | |
5606 | 1032 static GList *zephyr_chat_info(GaimConnection *gc) { |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1033 GList *m = NULL; |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1034 struct proto_chat_entry *pce; |
2086 | 1035 |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1036 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 1037 pce->label = _("_Class:"); |
5234 | 1038 pce->identifier = "class"; |
3158 | 1039 m = g_list_append(m, pce); |
2086 | 1040 |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1041 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 1042 pce->label = _("_Instance:"); |
5234 | 1043 pce->identifier = "instance"; |
3158 | 1044 m = g_list_append(m, pce); |
2086 | 1045 |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1046 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 1047 pce->label = _("_Recipient:"); |
5234 | 1048 pce->identifier = "recipient"; |
3158 | 1049 m = g_list_append(m, pce); |
2086 | 1050 |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1051 return m; |
2086 | 1052 } |
1053 | |
5606 | 1054 static void zephyr_join_chat(GaimConnection *gc, GHashTable *data) |
2086 | 1055 { |
1056 ZSubscription_t sub; | |
1057 zephyr_triple *zt1, *zt2; | |
1058 const char *classname; | |
1059 const char *instname; | |
1060 const char *recip; | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1061 |
5234 | 1062 classname = g_hash_table_lookup(data, "class"); |
1063 instname = g_hash_table_lookup(data, "instance"); | |
1064 recip = g_hash_table_lookup(data, "recipient"); | |
1065 | |
1066 if (!classname || !instname || !recip) | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
1067 return; |
2086 | 1068 |
4793 | 1069 if (!g_ascii_strcasecmp(recip, "%me%")) |
8354 | 1070 recip = gaim_zephyr_get_sender(); |
2086 | 1071 |
1072 zt1 = new_triple(classname, instname, recip); | |
1073 zt2 = find_sub_by_triple(zt1); | |
1074 if (zt2) { | |
1075 free_triple(zt1); | |
1076 if (!zt2->open) | |
1077 serv_got_joined_chat(gc, zt2->id, zt2->name); | |
1078 return; | |
1079 } | |
1080 | |
1081 sub.zsub_class = zt1->class; | |
1082 sub.zsub_classinst = zt1->instance; | |
1083 sub.zsub_recipient = zt1->recipient; | |
1084 | |
1085 if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) { | |
1086 free_triple(zt1); | |
1087 return; | |
1088 } | |
1089 | |
1090 subscrips = g_slist_append(subscrips, zt1); | |
1091 zt1->open = TRUE; | |
1092 serv_got_joined_chat(gc, zt1->id, zt1->name); | |
1093 } | |
1094 | |
5606 | 1095 static void zephyr_chat_leave(GaimConnection *gc, int id) |
2086 | 1096 { |
1097 zephyr_triple *zt; | |
1098 zt = find_sub_by_id(id); | |
1099 if (zt) { | |
1100 zt->open = FALSE; | |
1101 zt->id = ++last_id; | |
1102 } | |
1103 } | |
1104 | |
6695 | 1105 static const char *zephyr_list_icon(GaimAccount *a, GaimBuddy *b) |
5202 | 1106 { |
1107 return "zephyr"; | |
1108 } | |
1109 | |
8212 | 1110 |
1111 static void zephyr_chat_set_topic(GaimConnection *gc, int id, const char *topic) { | |
1112 zephyr_triple *zt; | |
1113 GaimConversation *gconv; | |
1114 GaimConvChat* gcc; | |
8354 | 1115 char* sender = (char *)gaim_zephyr_get_sender(); |
8212 | 1116 |
1117 zt = find_sub_by_id(id); | |
1118 gconv = gaim_find_conversation_with_account(zt->name,zgc->account); | |
1119 gcc = gaim_conversation_get_chat_data(gconv); | |
1120 gaim_conv_chat_set_topic(gcc,sender,topic); | |
1121 | |
1122 } | |
1123 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1124 static GaimPlugin *my_protocol = NULL; |
2086 | 1125 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1126 static GaimPluginProtocolInfo prpl_info = |
2086 | 1127 { |
8212 | 1128 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_NO_PASSWORD, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1129 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1130 NULL, |
8170 | 1131 NULL, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1132 zephyr_list_icon, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1133 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1134 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1135 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1136 zephyr_away_states, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1137 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1138 zephyr_buddy_menu, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1139 zephyr_chat_info, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1140 zephyr_login, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1141 zephyr_close, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1142 zephyr_send_im, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1143 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1144 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1145 zephyr_zloc, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1146 zephyr_set_away, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1147 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1148 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1149 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1150 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1151 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1152 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1153 zephyr_add_buddy, |
8354 | 1154 zephyr_add_buddies, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1155 zephyr_remove_buddy, |
8354 | 1156 zephyr_remove_buddies, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1157 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1158 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1159 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1160 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1161 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1162 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1163 zephyr_join_chat, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1164 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1165 zephyr_chat_leave, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1166 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1167 zephyr_chat_send, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1168 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1169 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1170 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1171 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1172 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1173 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1174 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1175 NULL, |
8212 | 1176 NULL, |
1177 zephyr_normalize, | |
1178 NULL, | |
1179 NULL, | |
1180 NULL, | |
1181 zephyr_chat_set_topic | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1182 }; |
2086 | 1183 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1184 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1185 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1186 2, /**< api_version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1187 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1188 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1189 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1190 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1191 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1192 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1193 "prpl-zephyr", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1194 "Zephyr", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1195 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1196 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1197 N_("Zephyr Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1198 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1199 N_("Zephyr Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1200 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6059
diff
changeset
|
1201 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1202 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1203 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1204 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1205 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1206 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1207 NULL, /**< ui_info */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1208 &prpl_info /**< extra_info */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1209 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1210 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1211 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1212 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1213 { |
8212 | 1214 GaimAccountOption *option; |
1215 char* tmp = get_exposure_level(); | |
1216 option = gaim_account_option_bool_new(_("Export to .anyone"),"write_anyone",FALSE); | |
1217 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,option); | |
1218 | |
1219 option = gaim_account_option_bool_new(_("Export to .zephyr.subs"),"write_zsubs",FALSE); | |
1220 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,option); | |
1221 | |
1222 option = gaim_account_option_string_new(_("Exposure"),"exposure_level",tmp?tmp:EXPOSE_REALMVIS); | |
1223 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,option); | |
1224 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1225 my_protocol = plugin; |
2086 | 1226 } |
1227 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
1228 GAIM_INIT_PLUGIN(zephyr, init_plugin, info); |