Mercurial > pidgin.yaz
annotate plugins/zephyr/zephyr.c @ 1727:02653161cbce
[gaim-migrate @ 1737]
bleh. this should be handled by write_to_conv.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Thu, 19 Apr 2001 03:53:23 +0000 |
parents | 004725b3a851 |
children | 1e0613d9526b |
rev | line source |
---|---|
1700 | 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 | |
7 * Jag/Sean Dilda <agrajag@linuxpower.org>/<smdilda@unity.ncsu.edu> | |
8 * http://gtkzephyr.linuxpower.org/ | |
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 */ | |
25 | |
26 #ifdef HAVE_CONFIG_H | |
27 #include "config.h" | |
28 #endif | |
29 | |
30 #include <gtk/gtk.h> | |
31 #include <string.h> | |
32 #include "gaim.h" | |
33 #include "prpl.h" | |
34 #include "zephyr/zephyr.h" | |
35 | |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
36 typedef struct _zframe zframe; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
37 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
38 /* struct I need for zephyr_to_html */ |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
39 struct _zframe { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
40 /* true for everything but @color, since inside the parens of that one is |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
41 * the color. */ |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
42 gboolean has_closer; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
43 /* </i>, </font>, </b>, etc. */ |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
44 char *closing; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
45 /* text including the opening html thingie. */ |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
46 GString *text; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
47 struct _zframe *enclosing; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
48 }; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
49 |
1700 | 50 char *name() |
51 { | |
52 return "Zephyr"; | |
53 } | |
54 | |
55 char *description() | |
56 { | |
57 return "Allows gaim to use the Zephyr protocol"; | |
58 } | |
59 | |
60 static char *zephyr_name() | |
61 { | |
62 return "Zephyr"; | |
63 } | |
64 | |
65 #define z_call(func) if (func != ZERR_NONE)\ | |
66 return; | |
67 #define z_call_r(func) if (func != ZERR_NONE)\ | |
68 return TRUE; | |
69 #define z_call_s(func, err) if (func != ZERR_NONE) {\ | |
70 hide_login_progress(zgc, err);\ | |
71 signoff(zgc);\ | |
72 return;\ | |
73 } | |
74 | |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
75 static char *zephyr_normalize(const char *); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
76 |
1700 | 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; | |
81 struct gaim_connection *zgc = NULL; | |
1719
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
82 static GList *pending_zloc_names = NULL; |
1700 | 83 |
84 /* just for debugging | |
85 static void handle_unknown(ZNotice_t notice) | |
86 { | |
87 g_print("z_packet: %s\n", notice.z_packet); | |
88 g_print("z_version: %s\n", notice.z_version); | |
89 g_print("z_kind: %d\n", notice.z_kind); | |
90 g_print("z_class: %s\n", notice.z_class); | |
91 g_print("z_class_inst: %s\n", notice.z_class_inst); | |
92 g_print("z_opcode: %s\n", notice.z_opcode); | |
93 g_print("z_sender: %s\n", notice.z_sender); | |
94 g_print("z_recipient: %s\n", notice.z_recipient); | |
95 g_print("z_message: %s\n", notice.z_message); | |
96 g_print("z_message_len: %d\n", notice.z_message_len); | |
97 g_print("\n"); | |
98 } | |
99 */ | |
100 | |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
101 /* utility macros that are useful for zephyr_to_html */ |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
102 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
103 #define IS_OPENER(c) ((c == '{') || (c == '[') || (c == '(') || (c == '<')) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
104 #define IS_CLOSER(c) ((c == '}') || (c == ']') || (c == ')') || (c == '>')) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
105 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
106 /* this parses zephyr formatting and converts it to html. For example, if |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
107 * you pass in "@{@color(blue)@i(hello)}" you should get out |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
108 * "<font color=blue><i>hello</i></font>". */ |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
109 static char *zephyr_to_html(char *message) |
1719
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
110 { |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
111 int len, cnt; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
112 zframe *frames, *curr; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
113 char *ret; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
114 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
115 frames = g_new(zframe, 1); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
116 frames->text = g_string_new(""); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
117 frames->enclosing = NULL; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
118 frames->closing = ""; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
119 frames->has_closer = FALSE; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
120 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
121 len = strlen(message); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
122 cnt = 0; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
123 while (cnt <= len) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
124 if (message[cnt] == '@') { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
125 zframe *new_f; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
126 char *buf; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
127 int end; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
128 for (end=1; (cnt+end) <= len && |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
129 !IS_OPENER(message[cnt+end]); end++); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
130 buf = g_new0(char, end); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
131 if (end) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
132 g_snprintf(buf, end, "%s", message+cnt+1); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
133 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
134 if (!g_strcasecmp(buf, "italic") || |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
135 !g_strcasecmp(buf, "i")) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
136 new_f = g_new(zframe, 1); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
137 new_f->enclosing = frames; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
138 new_f->text = g_string_new("<i>"); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
139 new_f->closing = "</i>"; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
140 new_f->has_closer = TRUE; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
141 frames = new_f; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
142 cnt += end+1; /* cnt points to char after opener */ |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
143 } else if (!g_strcasecmp(buf, "bold") |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
144 || !g_strcasecmp(buf, "b")) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
145 new_f = g_new(zframe, 1); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
146 new_f->enclosing = frames; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
147 new_f->text = g_string_new("<b>"); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
148 new_f->closing = "</b>"; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
149 new_f->has_closer = TRUE; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
150 frames = new_f; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
151 cnt += end+1; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
152 } else if (!g_strcasecmp(buf, "color")) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
153 cnt += end+1; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
154 new_f = g_new(zframe, 1); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
155 new_f->enclosing = frames; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
156 new_f->text = g_string_new("<font color="); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
157 for (; (cnt <= len) && !IS_CLOSER(message[cnt]); cnt++) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
158 g_string_append_c(new_f->text, message[cnt]); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
159 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
160 cnt++; /* point to char after closer */ |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
161 g_string_append_c(new_f->text, '>'); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
162 new_f->closing = "</font>"; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
163 new_f->has_closer = FALSE; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
164 frames = new_f; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
165 } else if (!g_strcasecmp(buf, "")) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
166 new_f = g_new(zframe, 1); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
167 new_f->enclosing = frames; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
168 new_f->text = g_string_new(""); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
169 new_f->closing = ""; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
170 new_f->has_closer = TRUE; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
171 frames = new_f; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
172 cnt += end+1; /* cnt points to char after opener */ |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
173 } else { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
174 if ((cnt+end) > len) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
175 g_string_append_c(frames->text, '@'); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
176 cnt++; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
177 } else { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
178 /* unrecognized thingie. act like it's not there, but we |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
179 * still need to take care of the corresponding closer, |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
180 * make a frame that does nothing. */ |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
181 new_f = g_new(zframe, 1); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
182 new_f->enclosing = frames; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
183 new_f->text = g_string_new(""); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
184 new_f->closing = ""; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
185 new_f->has_closer = TRUE; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
186 frames = new_f; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
187 cnt += end+1; /* cnt points to char after opener */ |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
188 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
189 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
190 } else if (IS_CLOSER(message[cnt])) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
191 zframe *popped; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
192 gboolean last_had_closer; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
193 if (frames->enclosing) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
194 do { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
195 popped = frames; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
196 frames = frames->enclosing; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
197 g_string_append(frames->text, popped->text->str); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
198 g_string_append(frames->text, popped->closing); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
199 g_string_free(popped->text, TRUE); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
200 last_had_closer = popped->has_closer; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
201 g_free(popped); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
202 } while (frames && frames->enclosing && !last_had_closer); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
203 } else { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
204 g_string_append_c(frames->text, message[cnt]); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
205 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
206 cnt++; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
207 } else if (message[cnt] == '\n') { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
208 g_string_append(frames->text, "<br>"); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
209 cnt++; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
210 } else { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
211 g_string_append_c(frames->text, message[cnt++]); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
212 } |
1719
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
213 } |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
214 /* go through all the stuff that they didn't close */ |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
215 while (frames->enclosing) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
216 curr = frames; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
217 g_string_append(frames->enclosing->text, frames->text->str); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
218 g_string_append(frames->enclosing->text, frames->closing); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
219 g_string_free(frames->text, TRUE); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
220 frames = frames->enclosing; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
221 g_free(curr); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
222 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
223 ret = frames->text->str; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
224 g_string_free(frames->text, FALSE); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
225 g_free(frames); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
226 return ret; |
1719
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
227 } |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
228 |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
229 static gboolean pending_zloc(char *who) |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
230 { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
231 GList *curr; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
232 for (curr = pending_zloc_names; curr != NULL; curr = curr->next) { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
233 if (!g_strcasecmp(who, (char*)curr->data)) { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
234 g_free((char*)curr->data); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
235 pending_zloc_names = g_list_remove(pending_zloc_names, curr->data); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
236 return TRUE; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
237 } |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
238 } |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
239 return FALSE; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
240 } |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
241 |
1700 | 242 static void handle_message(ZNotice_t notice, struct sockaddr_in from) |
243 { | |
244 if (!g_strcasecmp(notice.z_class, LOGIN_CLASS)) { | |
245 /* well, we'll be updating in 2 seconds anyway, might as well ignore this. */ | |
246 } else if (!g_strcasecmp(notice.z_class, LOCATE_CLASS)) { | |
247 if (!g_strcasecmp(notice.z_opcode, LOCATE_LOCATE)) { | |
248 int nlocs; | |
249 char *user; | |
250 struct buddy *b; | |
251 | |
252 if (ZParseLocations(¬ice, NULL, &nlocs, &user) != ZERR_NONE) | |
253 return; | |
254 if ((b = find_buddy(zgc, user)) == NULL) { | |
255 char *e = strchr(user, '@'); | |
256 if (e) *e = '\0'; | |
257 b = find_buddy(zgc, user); | |
258 } | |
259 if (!b) { | |
260 free(user); | |
261 return; | |
262 } | |
1719
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
263 if (pending_zloc(b->name)) { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
264 ZLocations_t locs; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
265 int one = 1; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
266 GString *str = g_string_new(""); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
267 g_string_sprintfa(str, "<b>User:</b> %s<br>" |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
268 "<b>Alias:</b> %s<br>", |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
269 b->name, b->show); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
270 if (!nlocs) { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
271 g_string_sprintfa(str, "<br>Hidden or not logged-in"); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
272 } |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
273 for (; nlocs > 0; nlocs--) { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
274 ZGetLocations(&locs, &one); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
275 g_string_sprintfa(str, "<br>At %s since %s", locs.host, |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
276 locs.time); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
277 } |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
278 g_show_info_text(str->str); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
279 g_string_free(str, TRUE); |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
280 } else |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
281 serv_got_update(zgc, b->name, nlocs, 0, 0, 0, 0, 0); |
1700 | 282 |
283 free(user); | |
284 } | |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
285 } else { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
286 char *buf, *buf2; |
1700 | 287 char *ptr = notice.z_message + strlen(notice.z_message) + 1; |
288 int len = notice.z_message_len - (ptr - notice.z_message); | |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
289 int away; |
1700 | 290 if (len > 0) { |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
291 buf = g_malloc(len + 1); |
1700 | 292 g_snprintf(buf, len + 1, "%s", ptr); |
293 g_strchomp(buf); | |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
294 buf2 = zephyr_to_html(buf); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
295 g_free(buf); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
296 if (!g_strcasecmp(notice.z_class, "MESSAGE") && |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
297 !g_strcasecmp(notice.z_class_inst, "PERSONAL")) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
298 if (!g_strcasecmp(notice.z_message, "Automated reply:")) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
299 away = TRUE; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
300 else |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
301 away = FALSE; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
302 len = MAX(BUF_LONG, strlen(buf2)); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
303 buf = g_malloc(len + 1); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
304 g_snprintf(buf, len + 1, "%s", buf2); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
305 serv_got_im(zgc, notice.z_sender, buf, 0); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
306 g_free(buf); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
307 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
308 g_free(buf2); |
1700 | 309 } |
310 } | |
311 } | |
312 | |
313 static gint check_notify(gpointer data) | |
314 { | |
315 while (ZPending()) { | |
316 ZNotice_t notice; | |
317 struct sockaddr_in from; | |
318 z_call_r(ZReceiveNotice(¬ice, &from)); | |
319 | |
320 switch (notice.z_kind) { | |
321 case UNSAFE: | |
322 case UNACKED: | |
323 case ACKED: | |
324 handle_message(notice, from); | |
325 break; | |
326 default: | |
327 /* we'll just ignore things for now */ | |
328 debug_printf("ZEPHYR: Unhandled Notice\n"); | |
329 break; | |
330 } | |
331 | |
332 ZFreeNotice(¬ice); | |
333 } | |
334 | |
335 return TRUE; | |
336 } | |
337 | |
338 static gint check_loc(gpointer data) | |
339 { | |
340 GSList *gr, *m; | |
341 ZAsyncLocateData_t ald; | |
342 | |
343 ald.user = NULL; | |
344 memset(&(ald.uid), 0, sizeof(ZUnique_Id_t)); | |
345 ald.version = NULL; | |
346 | |
347 gr = zgc->groups; | |
348 while (gr) { | |
349 struct group *g = gr->data; | |
350 m = g->members; | |
351 while (m) { | |
352 struct buddy *b = m->data; | |
353 char *chk; | |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
354 chk = zephyr_normalize(b->name); |
1700 | 355 /* doesn't matter if this fails or not; we'll just move on to the next one */ |
356 ZRequestLocations(chk, &ald, UNACKED, ZAUTH); | |
357 m = m->next; | |
358 } | |
359 gr = gr->next; | |
360 } | |
361 | |
362 return TRUE; | |
363 } | |
364 | |
365 static char *get_exposure_level() | |
366 { | |
367 char *exposure = ZGetVariable("exposure"); | |
368 | |
369 if (!exposure) | |
370 return EXPOSE_REALMVIS; | |
371 if (!g_strcasecmp(exposure, EXPOSE_NONE)) | |
372 return EXPOSE_NONE; | |
373 if (!g_strcasecmp(exposure, EXPOSE_OPSTAFF)) | |
374 return EXPOSE_OPSTAFF; | |
375 if (!g_strcasecmp(exposure, EXPOSE_REALMANN)) | |
376 return EXPOSE_REALMANN; | |
377 if (!g_strcasecmp(exposure, EXPOSE_NETVIS)) | |
378 return EXPOSE_NETVIS; | |
379 if (!g_strcasecmp(exposure, EXPOSE_NETANN)) | |
380 return EXPOSE_NETANN; | |
381 return EXPOSE_REALMVIS; | |
382 } | |
383 | |
384 static void strip_comments(char *str) | |
385 { | |
386 char *tmp = strchr(str, '#'); | |
387 if (tmp) | |
388 *tmp = '\0'; | |
389 g_strchug(str); | |
390 g_strchomp(str); | |
391 } | |
392 | |
1719
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
393 static void process_zsubs() |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
394 { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
395 FILE *f; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
396 gchar *fname; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
397 gchar buff[BUFSIZ]; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
398 |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
399 fname = g_strdup_printf("%s/.zephyr.subs", g_getenv("HOME")); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
400 f = fopen(fname, "r"); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
401 if (f) { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
402 char **triple; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
403 ZSubscription_t sub; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
404 char *recip; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
405 while (fgets(buff, BUFSIZ, f)) { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
406 strip_comments(buff); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
407 if (buff[0]) { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
408 triple = g_strsplit(buff, ",", 3); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
409 if (triple[0] && triple[1] && triple[2]) { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
410 sub.zsub_class = triple[0]; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
411 sub.zsub_classinst = triple[1]; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
412 if (!g_strcasecmp(triple[2], "%me%")) { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
413 recip = g_strdup_printf("%s@%s", g_getenv("USER"), |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
414 ZGetRealm()); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
415 } else if (!g_strcasecmp(triple[2], "*")) { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
416 /* wildcard */ |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
417 recip = g_strdup_printf("@%s", ZGetRealm()); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
418 } else { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
419 recip = g_strdup(triple[2]); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
420 } |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
421 sub.zsub_recipient = recip; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
422 if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
423 debug_printf("Zephyr: Couldn't subscribe to %s, %s, " |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
424 "%s\n", |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
425 sub.zsub_class, |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
426 sub.zsub_classinst, |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
427 sub.zsub_recipient); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
428 } |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
429 g_free(recip); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
430 } |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
431 g_strfreev(triple); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
432 } |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
433 } |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
434 } |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
435 } |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
436 |
1700 | 437 static void process_anyone() |
438 { | |
439 FILE *fd; | |
440 gchar buff[BUFSIZ], *filename; | |
441 | |
442 filename = g_strconcat(g_get_home_dir(), "/.anyone", NULL); | |
443 if ((fd = fopen(filename, "r")) != NULL) { | |
444 while (fgets(buff, BUFSIZ, fd)) { | |
445 strip_comments(buff); | |
446 if (buff[0]) | |
447 add_buddy(zgc, "Anyone", buff, buff); | |
448 } | |
449 fclose(fd); | |
450 } | |
451 g_free(filename); | |
452 } | |
453 | |
454 static void zephyr_login(struct aim_user *user) | |
455 { | |
456 ZSubscription_t sub; | |
457 | |
458 if (zgc) { | |
459 do_error_dialog("Already logged in with Zephyr", "Zephyr"); | |
460 return; | |
461 } | |
462 | |
463 zgc = new_gaim_conn(user); | |
464 | |
465 z_call_s(ZInitialize(), "Couldn't initialize zephyr"); | |
466 z_call_s(ZOpenPort(NULL), "Couldn't open port"); | |
467 z_call_s(ZSetLocation(get_exposure_level()), "Couldn't set location"); | |
468 | |
469 sub.zsub_class = "MESSAGE"; | |
470 sub.zsub_classinst = "PERSONAL"; | |
471 sub.zsub_recipient = ZGetSender(); | |
472 | |
473 /* we don't care if this fails. i'm lying right now. */ | |
1719
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
474 if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
475 debug_printf("Zephyr: Couldn't subscribe to messages!\n"); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
476 } |
1700 | 477 |
478 account_online(zgc); | |
479 serv_finish_login(zgc); | |
480 | |
481 if (bud_list_cache_exists(zgc)) | |
482 do_import(NULL, zgc); | |
483 process_anyone(); | |
1719
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
484 /* call process_zsubs to subscribe. still commented out since I don't know |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
485 * how you want to handle incoming msgs from subs. |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
486 process_zsubs(); */ |
1700 | 487 |
488 nottimer = gtk_timeout_add(100, check_notify, NULL); | |
489 loctimer = gtk_timeout_add(2000, check_loc, NULL); | |
490 } | |
491 | |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
492 static void write_anyone() |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
493 { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
494 GSList *gr, *m; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
495 struct group *g; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
496 struct buddy *b; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
497 char *ptr, *fname; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
498 FILE *fd; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
499 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
500 fname = g_strdup_printf("%s/.anyone", g_get_home_dir()); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
501 fd = fopen(fname, "w"); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
502 if (!fd) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
503 g_free(fname); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
504 return; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
505 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
506 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
507 gr = zgc->groups; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
508 while (gr) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
509 g = gr->data; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
510 m = g->members; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
511 while (m) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
512 b = m->data; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
513 if ((ptr = strchr(b->name, '@')) != NULL) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
514 *ptr = '\0'; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
515 fprintf(fd, "%s\n", b->name); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
516 if (ptr) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
517 *ptr = '@'; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
518 m = m->next; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
519 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
520 gr = gr->next; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
521 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
522 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
523 fclose(fd); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
524 g_free(fname); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
525 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
526 |
1700 | 527 static void zephyr_close(struct gaim_connection *gc) |
528 { | |
1719
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
529 g_list_foreach(pending_zloc_names, (GFunc)g_free, NULL); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
530 g_list_free(pending_zloc_names); |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
531 write_anyone(); |
1700 | 532 if (nottimer) |
533 gtk_timeout_remove(nottimer); | |
534 nottimer = 0; | |
535 if (loctimer) | |
536 gtk_timeout_remove(loctimer); | |
537 loctimer = 0; | |
538 zgc = NULL; | |
539 z_call(ZCancelSubscriptions(0)); | |
540 z_call(ZUnsetLocation()); | |
541 z_call(ZClosePort()); | |
542 } | |
543 | |
544 static void zephyr_add_buddy(struct gaim_connection *gc, char *buddy) { } | |
545 static void zephyr_remove_buddy(struct gaim_connection *gc, char *buddy) { } | |
546 | |
547 static void zephyr_send_im(struct gaim_connection *gc, char *who, char *im, int away) { | |
548 ZNotice_t notice; | |
1719
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
549 char *buf; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
550 char *sig; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
551 |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
552 if (away) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
553 sig = "Automated reply:"; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
554 else { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
555 sig = ZGetVariable("zwrite-signature"); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
556 if (!sig) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
557 sig = g_get_real_name(); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
558 } |
1719
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
559 } |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
560 buf = g_strdup_printf("%s%c%s", sig, '\0', im); |
1700 | 561 |
562 bzero((char *)¬ice, sizeof(notice)); | |
563 notice.z_kind = ACKED; | |
564 notice.z_port = 0; | |
565 notice.z_opcode = ""; | |
566 notice.z_class = "MESSAGE"; | |
567 notice.z_class_inst = "PERSONAL"; | |
568 notice.z_sender = 0; | |
569 notice.z_recipient = who; | |
570 notice.z_default_format = | |
1719
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
571 "Class $class, Instance $instance:\n" |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
572 "To: @bold($recipient) at $time $date\n" |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
573 "From: @bold($1) <$sender>\n\n$2"; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
574 notice.z_message_len = strlen(im) + strlen(sig) + 4; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
575 notice.z_message = buf; |
1700 | 576 ZSendNotice(¬ice, ZAUTH); |
1719
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
577 g_free(buf); |
1700 | 578 } |
579 | |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
580 static char *zephyr_normalize(const char *orig) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
581 { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
582 static char buf[80]; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
583 if (strchr(orig, '@')) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
584 g_snprintf(buf, 80, "%s", orig); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
585 } else { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
586 g_snprintf(buf, 80, "%s@%s", orig, ZGetRealm()); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
587 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
588 return buf; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
589 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
590 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
591 static void zephyr_zloc(struct gaim_connection *gc, char *who) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
592 { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
593 ZAsyncLocateData_t ald; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
594 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
595 if (ZRequestLocations(zephyr_normalize(who), &ald, UNACKED, ZAUTH) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
596 != ZERR_NONE) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
597 return; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
598 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
599 pending_zloc_names = g_list_append(pending_zloc_names, |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
600 g_strdup(zephyr_normalize(who))); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
601 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
602 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
603 static void info_callback(GtkObject *obj, char *who) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
604 { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
605 zephyr_zloc(gtk_object_get_user_data(obj), who); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
606 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
607 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
608 static void zephyr_buddy_menu(GtkWidget *menu, struct gaim_connection *gc, char *who) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
609 { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
610 GtkWidget *button; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
611 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
612 button = gtk_menu_item_new_with_label(_("ZLocate")); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
613 gtk_signal_connect(GTK_OBJECT(button), "activate", |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
614 GTK_SIGNAL_FUNC(info_callback), who); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
615 gtk_object_set_user_data(GTK_OBJECT(button), gc); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
616 gtk_menu_append(GTK_MENU(menu), button); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
617 gtk_widget_show(button); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
618 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
619 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
620 static void zephyr_set_away(struct gaim_connection *gc, char *state, char *msg) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
621 { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
622 if (gc->away) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
623 g_free(gc->away); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
624 gc->away = NULL; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
625 if (!g_strcasecmp(state, "Hidden")) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
626 ZSetLocation(EXPOSE_OPSTAFF); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
627 else if (!g_strcasecmp(state, "Online")) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
628 ZSetLocation(get_exposure_level()); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
629 else /* state is GAIM_AWAY_CUSTOM */ if (msg) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
630 gc->away = g_strdup(msg); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
631 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
632 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
633 static GList *zephyr_away_states() |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
634 { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
635 GList *m = NULL; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
636 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
637 m = g_list_append(m, "Online"); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
638 m = g_list_append(m, GAIM_AWAY_CUSTOM); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
639 m = g_list_append(m, "Hidden"); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
640 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
641 return m; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
642 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
643 |
1700 | 644 static struct prpl *my_protocol = NULL; |
645 | |
646 void zephyr_init(struct prpl *ret) | |
647 { | |
648 ret->protocol = PROTO_ZEPHYR; | |
649 ret->name = zephyr_name; | |
650 ret->login = zephyr_login; | |
651 ret->close = zephyr_close; | |
652 ret->add_buddy = zephyr_add_buddy; | |
653 ret->remove_buddy = zephyr_remove_buddy; | |
654 ret->send_im = zephyr_send_im; | |
1719
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
655 ret->get_info = zephyr_zloc; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
656 ret->normalize = zephyr_normalize; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
657 ret->buddy_menu = zephyr_buddy_menu; |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
658 ret->away_states = zephyr_away_states; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
659 ret->set_away = zephyr_set_away; |
1700 | 660 |
661 my_protocol = ret; | |
662 } | |
663 | |
664 char *gaim_plugin_init(GModule *handle) | |
665 { | |
666 load_protocol(zephyr_init, sizeof(struct prpl)); | |
667 return NULL; | |
668 } | |
669 | |
670 void gaim_plugin_remove() | |
671 { | |
672 struct prpl *p = find_prpl(PROTO_ZEPHYR); | |
673 if (p == my_protocol) | |
674 unload_protocol(p); | |
675 } |