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