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