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