Mercurial > pidgin
annotate plugins/zephyr/zephyr.c @ 1865:8d758ff5957e
[gaim-migrate @ 1875]
i got it right this time. no, i don't care.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sun, 20 May 2001 09:09:02 +0000 |
parents | b012f6b9095b |
children | 8de58cd2892f |
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; |
1808
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
37 typedef struct _zephyr_triple zephyr_triple; |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
38 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
39 /* struct I need for zephyr_to_html */ |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
40 struct _zframe { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
41 /* 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
|
42 * the color. */ |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
43 gboolean has_closer; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
44 /* </i>, </font>, </b>, etc. */ |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
45 char *closing; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
46 /* text including the opening html thingie. */ |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
47 GString *text; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
48 struct _zframe *enclosing; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
49 }; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
50 |
1808
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
51 struct _zephyr_triple { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
52 char *class; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
53 char *instance; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
54 char *recipient; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
55 char *name; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
56 gboolean open; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
57 int id; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
58 }; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
59 |
1700 | 60 char *name() |
61 { | |
62 return "Zephyr"; | |
63 } | |
64 | |
65 char *description() | |
66 { | |
67 return "Allows gaim to use the Zephyr protocol"; | |
68 } | |
69 | |
70 static char *zephyr_name() | |
71 { | |
72 return "Zephyr"; | |
73 } | |
74 | |
75 #define z_call(func) if (func != ZERR_NONE)\ | |
76 return; | |
77 #define z_call_r(func) if (func != ZERR_NONE)\ | |
78 return TRUE; | |
79 #define z_call_s(func, err) if (func != ZERR_NONE) {\ | |
80 hide_login_progress(zgc, err);\ | |
81 signoff(zgc);\ | |
82 return;\ | |
83 } | |
84 | |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
85 static char *zephyr_normalize(const char *); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
86 |
1700 | 87 /* this is so bad, and if Zephyr weren't so fucked up to begin with I |
88 * wouldn't do this. but it is so i will. */ | |
89 static guint32 nottimer = 0; | |
90 static guint32 loctimer = 0; | |
91 struct gaim_connection *zgc = NULL; | |
1719
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
92 static GList *pending_zloc_names = NULL; |
1808
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
93 static GSList *subscrips = NULL; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
94 static int last_id = 0; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
95 static GtkWidget *class_entry; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
96 static GtkWidget *inst_entry; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
97 static GtkWidget *recip_entry; |
1700 | 98 |
99 /* just for debugging | |
100 static void handle_unknown(ZNotice_t notice) | |
101 { | |
102 g_print("z_packet: %s\n", notice.z_packet); | |
103 g_print("z_version: %s\n", notice.z_version); | |
104 g_print("z_kind: %d\n", notice.z_kind); | |
105 g_print("z_class: %s\n", notice.z_class); | |
106 g_print("z_class_inst: %s\n", notice.z_class_inst); | |
107 g_print("z_opcode: %s\n", notice.z_opcode); | |
108 g_print("z_sender: %s\n", notice.z_sender); | |
109 g_print("z_recipient: %s\n", notice.z_recipient); | |
110 g_print("z_message: %s\n", notice.z_message); | |
111 g_print("z_message_len: %d\n", notice.z_message_len); | |
112 g_print("\n"); | |
113 } | |
114 */ | |
115 | |
1808
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
116 static zephyr_triple *new_triple(char *c, char *i, char *r) |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
117 { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
118 zephyr_triple *zt; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
119 zt = g_new0(zephyr_triple, 1); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
120 zt->class = g_strdup(c); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
121 zt->instance = g_strdup(i); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
122 zt->recipient = g_strdup(r); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
123 zt->name = g_strdup_printf("%s,%s,%s", c, i, r); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
124 zt->id = ++last_id; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
125 zt->open = FALSE; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
126 return zt; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
127 } |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
128 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
129 static void free_triple(zephyr_triple *zt) |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
130 { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
131 g_free(zt->class); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
132 g_free(zt->instance); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
133 g_free(zt->recipient); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
134 g_free(zt->name); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
135 g_free(zt); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
136 } |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
137 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
138 /* returns true if zt1 is a subset of zt2, i.e. zt2 has the same thing or |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
139 * wildcards in each field of zt1. */ |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
140 static gboolean triple_subset(zephyr_triple *zt1, zephyr_triple *zt2) |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
141 { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
142 if (g_strcasecmp(zt2->class, zt1->class) && |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
143 g_strcasecmp(zt2->class, "*")) { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
144 return FALSE; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
145 } |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
146 if (g_strcasecmp(zt2->instance, zt1->instance) && |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
147 g_strcasecmp(zt2->instance, "*")) { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
148 return FALSE; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
149 } |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
150 if (g_strcasecmp(zt2->recipient, zt1->recipient) && |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
151 g_strcasecmp(zt2->recipient, "*")) { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
152 return FALSE; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
153 } |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
154 return TRUE; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
155 } |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
156 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
157 static zephyr_triple *find_sub_by_triple(zephyr_triple *zt) |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
158 { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
159 zephyr_triple *curr_t; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
160 GSList *curr = subscrips; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
161 while (curr) { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
162 curr_t = curr->data; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
163 if (triple_subset(zt, curr_t)) |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
164 return curr_t; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
165 curr = curr->next; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
166 } |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
167 return NULL; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
168 } |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
169 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
170 static zephyr_triple *find_sub_by_id(int id) |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
171 { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
172 zephyr_triple *zt; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
173 GSList *curr = subscrips; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
174 while (curr) { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
175 zt = curr->data; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
176 if (zt->id == id) |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
177 return zt; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
178 curr = curr->next; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
179 } |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
180 return NULL; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
181 } |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
182 |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
183 /* utility macros that are useful for zephyr_to_html */ |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
184 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
185 #define IS_OPENER(c) ((c == '{') || (c == '[') || (c == '(') || (c == '<')) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
186 #define IS_CLOSER(c) ((c == '}') || (c == ']') || (c == ')') || (c == '>')) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
187 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
188 /* 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
|
189 * you pass in "@{@color(blue)@i(hello)}" you should get out |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
190 * "<font color=blue><i>hello</i></font>". */ |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
191 static char *zephyr_to_html(char *message) |
1719
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
192 { |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
193 int len, cnt; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
194 zframe *frames, *curr; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
195 char *ret; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
196 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
197 frames = g_new(zframe, 1); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
198 frames->text = g_string_new(""); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
199 frames->enclosing = NULL; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
200 frames->closing = ""; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
201 frames->has_closer = FALSE; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
202 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
203 len = strlen(message); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
204 cnt = 0; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
205 while (cnt <= len) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
206 if (message[cnt] == '@') { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
207 zframe *new_f; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
208 char *buf; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
209 int end; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
210 for (end=1; (cnt+end) <= len && |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
211 !IS_OPENER(message[cnt+end]); end++); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
212 buf = g_new0(char, end); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
213 if (end) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
214 g_snprintf(buf, end, "%s", message+cnt+1); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
215 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
216 if (!g_strcasecmp(buf, "italic") || |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
217 !g_strcasecmp(buf, "i")) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
218 new_f = g_new(zframe, 1); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
219 new_f->enclosing = frames; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
220 new_f->text = g_string_new("<i>"); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
221 new_f->closing = "</i>"; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
222 new_f->has_closer = TRUE; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
223 frames = new_f; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
224 cnt += end+1; /* cnt points to char after opener */ |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
225 } else if (!g_strcasecmp(buf, "bold") |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
226 || !g_strcasecmp(buf, "b")) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
227 new_f = g_new(zframe, 1); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
228 new_f->enclosing = frames; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
229 new_f->text = g_string_new("<b>"); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
230 new_f->closing = "</b>"; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
231 new_f->has_closer = TRUE; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
232 frames = new_f; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
233 cnt += end+1; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
234 } else if (!g_strcasecmp(buf, "color")) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
235 cnt += end+1; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
236 new_f = g_new(zframe, 1); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
237 new_f->enclosing = frames; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
238 new_f->text = g_string_new("<font color="); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
239 for (; (cnt <= len) && !IS_CLOSER(message[cnt]); cnt++) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
240 g_string_append_c(new_f->text, message[cnt]); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
241 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
242 cnt++; /* point to char after closer */ |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
243 g_string_append_c(new_f->text, '>'); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
244 new_f->closing = "</font>"; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
245 new_f->has_closer = FALSE; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
246 frames = new_f; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
247 } else if (!g_strcasecmp(buf, "")) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
248 new_f = g_new(zframe, 1); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
249 new_f->enclosing = frames; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
250 new_f->text = g_string_new(""); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
251 new_f->closing = ""; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
252 new_f->has_closer = TRUE; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
253 frames = new_f; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
254 cnt += end+1; /* cnt points to char after opener */ |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
255 } else { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
256 if ((cnt+end) > len) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
257 g_string_append_c(frames->text, '@'); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
258 cnt++; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
259 } else { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
260 /* unrecognized thingie. act like it's not there, but we |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
261 * still need to take care of the corresponding closer, |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
262 * make a frame that does nothing. */ |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
263 new_f = g_new(zframe, 1); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
264 new_f->enclosing = frames; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
265 new_f->text = g_string_new(""); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
266 new_f->closing = ""; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
267 new_f->has_closer = TRUE; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
268 frames = new_f; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
269 cnt += end+1; /* cnt points to char after opener */ |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
270 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
271 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
272 } else if (IS_CLOSER(message[cnt])) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
273 zframe *popped; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
274 gboolean last_had_closer; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
275 if (frames->enclosing) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
276 do { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
277 popped = frames; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
278 frames = frames->enclosing; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
279 g_string_append(frames->text, popped->text->str); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
280 g_string_append(frames->text, popped->closing); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
281 g_string_free(popped->text, TRUE); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
282 last_had_closer = popped->has_closer; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
283 g_free(popped); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
284 } while (frames && frames->enclosing && !last_had_closer); |
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 g_string_append_c(frames->text, message[cnt]); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
287 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
288 cnt++; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
289 } else if (message[cnt] == '\n') { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
290 g_string_append(frames->text, "<br>"); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
291 cnt++; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
292 } else { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
293 g_string_append_c(frames->text, message[cnt++]); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
294 } |
1719
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
295 } |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
296 /* go through all the stuff that they didn't close */ |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
297 while (frames->enclosing) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
298 curr = frames; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
299 g_string_append(frames->enclosing->text, frames->text->str); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
300 g_string_append(frames->enclosing->text, frames->closing); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
301 g_string_free(frames->text, TRUE); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
302 frames = frames->enclosing; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
303 g_free(curr); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
304 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
305 ret = frames->text->str; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
306 g_string_free(frames->text, FALSE); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
307 g_free(frames); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
308 return ret; |
1719
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
309 } |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
310 |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
311 static gboolean pending_zloc(char *who) |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
312 { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
313 GList *curr; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
314 for (curr = pending_zloc_names; curr != NULL; curr = curr->next) { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
315 if (!g_strcasecmp(who, (char*)curr->data)) { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
316 g_free((char*)curr->data); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
317 pending_zloc_names = g_list_remove(pending_zloc_names, curr->data); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
318 return TRUE; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
319 } |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
320 } |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
321 return FALSE; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
322 } |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
323 |
1700 | 324 static void handle_message(ZNotice_t notice, struct sockaddr_in from) |
325 { | |
326 if (!g_strcasecmp(notice.z_class, LOGIN_CLASS)) { | |
327 /* well, we'll be updating in 2 seconds anyway, might as well ignore this. */ | |
328 } else if (!g_strcasecmp(notice.z_class, LOCATE_CLASS)) { | |
329 if (!g_strcasecmp(notice.z_opcode, LOCATE_LOCATE)) { | |
330 int nlocs; | |
331 char *user; | |
332 struct buddy *b; | |
333 | |
334 if (ZParseLocations(¬ice, NULL, &nlocs, &user) != ZERR_NONE) | |
335 return; | |
336 if ((b = find_buddy(zgc, user)) == NULL) { | |
337 char *e = strchr(user, '@'); | |
338 if (e) *e = '\0'; | |
339 b = find_buddy(zgc, user); | |
340 } | |
341 if (!b) { | |
342 free(user); | |
343 return; | |
344 } | |
1719
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
345 if (pending_zloc(b->name)) { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
346 ZLocations_t locs; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
347 int one = 1; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
348 GString *str = g_string_new(""); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
349 g_string_sprintfa(str, "<b>User:</b> %s<br>" |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
350 "<b>Alias:</b> %s<br>", |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
351 b->name, b->show); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
352 if (!nlocs) { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
353 g_string_sprintfa(str, "<br>Hidden or not logged-in"); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
354 } |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
355 for (; nlocs > 0; nlocs--) { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
356 ZGetLocations(&locs, &one); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
357 g_string_sprintfa(str, "<br>At %s since %s", locs.host, |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
358 locs.time); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
359 } |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
360 g_show_info_text(str->str); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
361 g_string_free(str, TRUE); |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
362 } else |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
363 serv_got_update(zgc, b->name, nlocs, 0, 0, 0, 0, 0); |
1700 | 364 |
365 free(user); | |
366 } | |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
367 } else { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
368 char *buf, *buf2; |
1700 | 369 char *ptr = notice.z_message + strlen(notice.z_message) + 1; |
370 int len = notice.z_message_len - (ptr - notice.z_message); | |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
371 int away; |
1700 | 372 if (len > 0) { |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
373 buf = g_malloc(len + 1); |
1700 | 374 g_snprintf(buf, len + 1, "%s", ptr); |
375 g_strchomp(buf); | |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
376 buf2 = zephyr_to_html(buf); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
377 g_free(buf); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
378 if (!g_strcasecmp(notice.z_class, "MESSAGE") && |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
379 !g_strcasecmp(notice.z_class_inst, "PERSONAL")) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
380 if (!g_strcasecmp(notice.z_message, "Automated reply:")) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
381 away = TRUE; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
382 else |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
383 away = FALSE; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
384 len = MAX(BUF_LONG, strlen(buf2)); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
385 buf = g_malloc(len + 1); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
386 g_snprintf(buf, len + 1, "%s", buf2); |
1764 | 387 serv_got_im(zgc, notice.z_sender, buf, 0, time((time_t)NULL)); |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
388 g_free(buf); |
1808
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
389 } else { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
390 zephyr_triple *zt1, *zt2; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
391 zt1 = new_triple(notice.z_class, notice.z_class_inst, |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
392 notice.z_recipient); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
393 zt2 = find_sub_by_triple(zt1); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
394 if (!zt2) { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
395 /* we shouldn't be subscribed to this message. ignore. */ |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
396 } else { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
397 len = MAX(BUF_LONG, strlen(buf2)); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
398 buf = g_malloc(len + 1); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
399 g_snprintf(buf, len + 1, "%s", buf2); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
400 if (!zt2->open) { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
401 zt2->open = TRUE; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
402 serv_got_joined_chat(zgc, zt2->id, zt2->name); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
403 } |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
404 serv_got_chat_in(zgc, zt2->id, notice.z_sender, FALSE, |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
405 buf, time((time_t)NULL)); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
406 g_free(buf); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
407 } |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
408 free_triple(zt1); |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
409 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
410 g_free(buf2); |
1700 | 411 } |
412 } | |
413 } | |
414 | |
415 static gint check_notify(gpointer data) | |
416 { | |
417 while (ZPending()) { | |
418 ZNotice_t notice; | |
419 struct sockaddr_in from; | |
420 z_call_r(ZReceiveNotice(¬ice, &from)); | |
421 | |
422 switch (notice.z_kind) { | |
423 case UNSAFE: | |
424 case UNACKED: | |
425 case ACKED: | |
426 handle_message(notice, from); | |
427 break; | |
428 default: | |
429 /* we'll just ignore things for now */ | |
430 debug_printf("ZEPHYR: Unhandled Notice\n"); | |
431 break; | |
432 } | |
433 | |
434 ZFreeNotice(¬ice); | |
435 } | |
436 | |
437 return TRUE; | |
438 } | |
439 | |
440 static gint check_loc(gpointer data) | |
441 { | |
442 GSList *gr, *m; | |
443 ZAsyncLocateData_t ald; | |
444 | |
445 ald.user = NULL; | |
446 memset(&(ald.uid), 0, sizeof(ZUnique_Id_t)); | |
447 ald.version = NULL; | |
448 | |
449 gr = zgc->groups; | |
450 while (gr) { | |
451 struct group *g = gr->data; | |
452 m = g->members; | |
453 while (m) { | |
454 struct buddy *b = m->data; | |
455 char *chk; | |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
456 chk = zephyr_normalize(b->name); |
1700 | 457 /* doesn't matter if this fails or not; we'll just move on to the next one */ |
458 ZRequestLocations(chk, &ald, UNACKED, ZAUTH); | |
1794
60b3fd819cce
[gaim-migrate @ 1804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1764
diff
changeset
|
459 free(ald.user); |
60b3fd819cce
[gaim-migrate @ 1804]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1764
diff
changeset
|
460 free(ald.version); |
1700 | 461 m = m->next; |
462 } | |
463 gr = gr->next; | |
464 } | |
465 | |
466 return TRUE; | |
467 } | |
468 | |
469 static char *get_exposure_level() | |
470 { | |
471 char *exposure = ZGetVariable("exposure"); | |
472 | |
473 if (!exposure) | |
474 return EXPOSE_REALMVIS; | |
475 if (!g_strcasecmp(exposure, EXPOSE_NONE)) | |
476 return EXPOSE_NONE; | |
477 if (!g_strcasecmp(exposure, EXPOSE_OPSTAFF)) | |
478 return EXPOSE_OPSTAFF; | |
479 if (!g_strcasecmp(exposure, EXPOSE_REALMANN)) | |
480 return EXPOSE_REALMANN; | |
481 if (!g_strcasecmp(exposure, EXPOSE_NETVIS)) | |
482 return EXPOSE_NETVIS; | |
483 if (!g_strcasecmp(exposure, EXPOSE_NETANN)) | |
484 return EXPOSE_NETANN; | |
485 return EXPOSE_REALMVIS; | |
486 } | |
487 | |
488 static void strip_comments(char *str) | |
489 { | |
490 char *tmp = strchr(str, '#'); | |
491 if (tmp) | |
492 *tmp = '\0'; | |
493 g_strchug(str); | |
494 g_strchomp(str); | |
495 } | |
496 | |
1719
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
497 static void process_zsubs() |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
498 { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
499 FILE *f; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
500 gchar *fname; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
501 gchar buff[BUFSIZ]; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
502 |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
503 fname = g_strdup_printf("%s/.zephyr.subs", g_getenv("HOME")); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
504 f = fopen(fname, "r"); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
505 if (f) { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
506 char **triple; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
507 ZSubscription_t sub; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
508 char *recip; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
509 while (fgets(buff, BUFSIZ, f)) { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
510 strip_comments(buff); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
511 if (buff[0]) { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
512 triple = g_strsplit(buff, ",", 3); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
513 if (triple[0] && triple[1] && triple[2]) { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
514 sub.zsub_class = triple[0]; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
515 sub.zsub_classinst = triple[1]; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
516 if (!g_strcasecmp(triple[2], "%me%")) { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
517 recip = g_strdup_printf("%s@%s", g_getenv("USER"), |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
518 ZGetRealm()); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
519 } else if (!g_strcasecmp(triple[2], "*")) { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
520 /* wildcard */ |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
521 recip = g_strdup_printf("@%s", ZGetRealm()); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
522 } else { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
523 recip = g_strdup(triple[2]); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
524 } |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
525 sub.zsub_recipient = recip; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
526 if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
527 debug_printf("Zephyr: Couldn't subscribe to %s, %s, " |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
528 "%s\n", |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
529 sub.zsub_class, |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
530 sub.zsub_classinst, |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
531 sub.zsub_recipient); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
532 } |
1808
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
533 subscrips = g_slist_append(subscrips, |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
534 new_triple(triple[0], triple[1], recip)); |
1812
b012f6b9095b
[gaim-migrate @ 1822]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1808
diff
changeset
|
535 g_free(recip); |
1719
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
536 } |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
537 g_strfreev(triple); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
538 } |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
539 } |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
540 } |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
541 } |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
542 |
1700 | 543 static void process_anyone() |
544 { | |
545 FILE *fd; | |
546 gchar buff[BUFSIZ], *filename; | |
547 | |
548 filename = g_strconcat(g_get_home_dir(), "/.anyone", NULL); | |
549 if ((fd = fopen(filename, "r")) != NULL) { | |
550 while (fgets(buff, BUFSIZ, fd)) { | |
551 strip_comments(buff); | |
552 if (buff[0]) | |
553 add_buddy(zgc, "Anyone", buff, buff); | |
554 } | |
555 fclose(fd); | |
556 } | |
557 g_free(filename); | |
558 } | |
559 | |
560 static void zephyr_login(struct aim_user *user) | |
561 { | |
562 ZSubscription_t sub; | |
563 | |
564 if (zgc) { | |
565 do_error_dialog("Already logged in with Zephyr", "Zephyr"); | |
566 return; | |
567 } | |
568 | |
569 zgc = new_gaim_conn(user); | |
570 | |
571 z_call_s(ZInitialize(), "Couldn't initialize zephyr"); | |
572 z_call_s(ZOpenPort(NULL), "Couldn't open port"); | |
573 z_call_s(ZSetLocation(get_exposure_level()), "Couldn't set location"); | |
574 | |
575 sub.zsub_class = "MESSAGE"; | |
576 sub.zsub_classinst = "PERSONAL"; | |
577 sub.zsub_recipient = ZGetSender(); | |
578 | |
579 /* 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
|
580 if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) { |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
581 debug_printf("Zephyr: Couldn't subscribe to messages!\n"); |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
582 } |
1700 | 583 |
584 account_online(zgc); | |
585 serv_finish_login(zgc); | |
586 | |
587 if (bud_list_cache_exists(zgc)) | |
588 do_import(NULL, zgc); | |
589 process_anyone(); | |
1808
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
590 process_zsubs(); |
1700 | 591 |
592 nottimer = gtk_timeout_add(100, check_notify, NULL); | |
593 loctimer = gtk_timeout_add(2000, check_loc, NULL); | |
594 } | |
595 | |
1808
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
596 static void write_zsubs() |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
597 { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
598 GSList *s = subscrips; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
599 zephyr_triple *zt; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
600 FILE *fd; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
601 char *fname; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
602 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
603 fname = g_strdup_printf("%s/.zephyr.subs", g_get_home_dir()); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
604 fd = fopen(fname, "w"); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
605 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
606 if (!fd) { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
607 g_free(fname); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
608 return; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
609 } |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
610 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
611 while (s) { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
612 zt = s->data; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
613 fprintf(fd, "%s\n", zt->name); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
614 s = s->next; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
615 } |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
616 g_free(fname); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
617 fclose(fd); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
618 } |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
619 |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
620 static void write_anyone() |
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 GSList *gr, *m; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
623 struct group *g; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
624 struct buddy *b; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
625 char *ptr, *fname; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
626 FILE *fd; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
627 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
628 fname = g_strdup_printf("%s/.anyone", g_get_home_dir()); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
629 fd = fopen(fname, "w"); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
630 if (!fd) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
631 g_free(fname); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
632 return; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
633 } |
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 gr = zgc->groups; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
636 while (gr) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
637 g = gr->data; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
638 m = g->members; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
639 while (m) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
640 b = m->data; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
641 if ((ptr = strchr(b->name, '@')) != NULL) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
642 *ptr = '\0'; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
643 fprintf(fd, "%s\n", b->name); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
644 if (ptr) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
645 *ptr = '@'; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
646 m = m->next; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
647 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
648 gr = gr->next; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
649 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
650 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
651 fclose(fd); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
652 g_free(fname); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
653 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
654 |
1700 | 655 static void zephyr_close(struct gaim_connection *gc) |
656 { | |
1808
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
657 GList *l; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
658 GSList *s; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
659 l = pending_zloc_names; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
660 while (l) { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
661 g_free((char*)l->data); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
662 l = l->next; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
663 } |
1719
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
664 g_list_free(pending_zloc_names); |
1808
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
665 |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
666 write_anyone(); |
1808
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
667 write_zsubs(); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
668 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
669 s = subscrips; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
670 while (s) { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
671 free_triple((zephyr_triple*)s->data); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
672 s = s->next; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
673 } |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
674 g_slist_free(subscrips); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
675 |
1700 | 676 if (nottimer) |
677 gtk_timeout_remove(nottimer); | |
678 nottimer = 0; | |
679 if (loctimer) | |
680 gtk_timeout_remove(loctimer); | |
681 loctimer = 0; | |
682 zgc = NULL; | |
683 z_call(ZCancelSubscriptions(0)); | |
684 z_call(ZUnsetLocation()); | |
685 z_call(ZClosePort()); | |
686 } | |
687 | |
688 static void zephyr_add_buddy(struct gaim_connection *gc, char *buddy) { } | |
689 static void zephyr_remove_buddy(struct gaim_connection *gc, char *buddy) { } | |
690 | |
1808
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
691 static void zephyr_chat_send(struct gaim_connection *gc, int id, char *im) |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
692 { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
693 ZNotice_t notice; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
694 zephyr_triple *zt; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
695 char *buf; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
696 char *sig; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
697 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
698 zt = find_sub_by_id(id); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
699 if (!zt) |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
700 /* this should never happen. */ |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
701 return; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
702 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
703 sig = ZGetVariable("zwrite-signature"); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
704 if (!sig) { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
705 sig = g_get_real_name(); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
706 } |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
707 buf = g_strdup_printf("%s%c%s", sig, '\0', im); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
708 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
709 bzero((char *)¬ice, sizeof(notice)); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
710 notice.z_kind = ACKED; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
711 notice.z_port = 0; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
712 notice.z_opcode = ""; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
713 notice.z_class = zt->class; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
714 notice.z_class_inst = zt->instance; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
715 if (!g_strcasecmp(zt->recipient, "*")) |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
716 notice.z_recipient = zephyr_normalize(""); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
717 else |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
718 notice.z_recipient = zephyr_normalize(zt->recipient); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
719 notice.z_sender = 0; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
720 notice.z_default_format = |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
721 "Class $class, Instance $instance:\n" |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
722 "To: @bold($recipient) at $time $date\n" |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
723 "From: @bold($1) <$sender>\n\n$2"; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
724 notice.z_message_len = strlen(im) + strlen(sig) + 4; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
725 notice.z_message = buf; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
726 ZSendNotice(¬ice, ZAUTH); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
727 g_free(buf); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
728 } |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
729 |
1700 | 730 static void zephyr_send_im(struct gaim_connection *gc, char *who, char *im, int away) { |
731 ZNotice_t notice; | |
1719
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
732 char *buf; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
733 char *sig; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
734 |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
735 if (away) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
736 sig = "Automated reply:"; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
737 else { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
738 sig = ZGetVariable("zwrite-signature"); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
739 if (!sig) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
740 sig = g_get_real_name(); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
741 } |
1719
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
742 } |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
743 buf = g_strdup_printf("%s%c%s", sig, '\0', im); |
1700 | 744 |
745 bzero((char *)¬ice, sizeof(notice)); | |
746 notice.z_kind = ACKED; | |
747 notice.z_port = 0; | |
748 notice.z_opcode = ""; | |
749 notice.z_class = "MESSAGE"; | |
750 notice.z_class_inst = "PERSONAL"; | |
751 notice.z_sender = 0; | |
752 notice.z_recipient = who; | |
753 notice.z_default_format = | |
1719
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
754 "Class $class, Instance $instance:\n" |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
755 "To: @bold($recipient) at $time $date\n" |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
756 "From: @bold($1) <$sender>\n\n$2"; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
757 notice.z_message_len = strlen(im) + strlen(sig) + 4; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
758 notice.z_message = buf; |
1700 | 759 ZSendNotice(¬ice, ZAUTH); |
1719
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
760 g_free(buf); |
1700 | 761 } |
762 | |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
763 static char *zephyr_normalize(const char *orig) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
764 { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
765 static char buf[80]; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
766 if (strchr(orig, '@')) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
767 g_snprintf(buf, 80, "%s", orig); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
768 } else { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
769 g_snprintf(buf, 80, "%s@%s", orig, ZGetRealm()); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
770 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
771 return buf; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
772 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
773 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
774 static void zephyr_zloc(struct gaim_connection *gc, char *who) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
775 { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
776 ZAsyncLocateData_t ald; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
777 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
778 if (ZRequestLocations(zephyr_normalize(who), &ald, UNACKED, ZAUTH) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
779 != ZERR_NONE) { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
780 return; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
781 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
782 pending_zloc_names = g_list_append(pending_zloc_names, |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
783 g_strdup(zephyr_normalize(who))); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
784 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
785 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
786 static void info_callback(GtkObject *obj, char *who) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
787 { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
788 zephyr_zloc(gtk_object_get_user_data(obj), who); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
789 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
790 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
791 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
|
792 { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
793 GtkWidget *button; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
794 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
795 button = gtk_menu_item_new_with_label(_("ZLocate")); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
796 gtk_signal_connect(GTK_OBJECT(button), "activate", |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
797 GTK_SIGNAL_FUNC(info_callback), who); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
798 gtk_object_set_user_data(GTK_OBJECT(button), gc); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
799 gtk_menu_append(GTK_MENU(menu), button); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
800 gtk_widget_show(button); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
801 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
802 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
803 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
|
804 { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
805 if (gc->away) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
806 g_free(gc->away); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
807 gc->away = NULL; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
808 if (!g_strcasecmp(state, "Hidden")) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
809 ZSetLocation(EXPOSE_OPSTAFF); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
810 else if (!g_strcasecmp(state, "Online")) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
811 ZSetLocation(get_exposure_level()); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
812 else /* state is GAIM_AWAY_CUSTOM */ if (msg) |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
813 gc->away = g_strdup(msg); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
814 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
815 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
816 static GList *zephyr_away_states() |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
817 { |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
818 GList *m = NULL; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
819 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
820 m = g_list_append(m, "Online"); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
821 m = g_list_append(m, GAIM_AWAY_CUSTOM); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
822 m = g_list_append(m, "Hidden"); |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
823 |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
824 return m; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
825 } |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
826 |
1808
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
827 static void zephyr_draw_jc(struct gaim_connection *gc, GtkWidget *vbox) { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
828 GtkWidget *label; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
829 GtkWidget *rowbox; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
830 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
831 rowbox = gtk_hbox_new(FALSE, 5); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
832 gtk_box_pack_start(GTK_BOX(vbox), rowbox, FALSE, FALSE, 0); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
833 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
834 label = gtk_label_new(_("Class:")); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
835 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 5); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
836 gtk_widget_show(label); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
837 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
838 class_entry = gtk_entry_new(); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
839 gtk_box_pack_end(GTK_BOX(rowbox), class_entry, FALSE, FALSE, 5); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
840 gtk_widget_show(class_entry); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
841 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
842 gtk_widget_show(rowbox); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
843 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
844 rowbox = gtk_hbox_new(FALSE, 5); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
845 gtk_box_pack_start(GTK_BOX(vbox), rowbox, FALSE, FALSE, 0); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
846 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
847 label = gtk_label_new(_("Instance:")); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
848 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 5); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
849 gtk_widget_show(label); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
850 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
851 inst_entry = gtk_entry_new(); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
852 gtk_box_pack_end(GTK_BOX(rowbox), inst_entry, FALSE, FALSE, 5); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
853 gtk_widget_show(inst_entry); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
854 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
855 gtk_widget_show(rowbox); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
856 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
857 rowbox = gtk_hbox_new(FALSE, 5); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
858 gtk_box_pack_start(GTK_BOX(vbox), rowbox, FALSE, FALSE, 0); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
859 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
860 label = gtk_label_new(_("Recipient:")); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
861 gtk_box_pack_start(GTK_BOX(rowbox), label, FALSE, FALSE, 5); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
862 gtk_widget_show(label); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
863 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
864 recip_entry = gtk_entry_new(); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
865 gtk_box_pack_end(GTK_BOX(rowbox), recip_entry, FALSE, FALSE, 5); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
866 gtk_widget_show(recip_entry); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
867 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
868 gtk_widget_show(rowbox); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
869 } |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
870 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
871 static void zephyr_join_chat(struct gaim_connection *gc, int id, char *nm) |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
872 { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
873 ZSubscription_t sub; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
874 zephyr_triple *zt1, *zt2; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
875 char *classname; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
876 char *instname; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
877 char *recip; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
878 char **splitted; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
879 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
880 if (!nm) { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
881 splitted = NULL; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
882 classname = gtk_entry_get_text(GTK_ENTRY(class_entry)); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
883 instname = gtk_entry_get_text(GTK_ENTRY(inst_entry)); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
884 recip = gtk_entry_get_text(GTK_ENTRY(recip_entry)); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
885 if (!g_strcasecmp(recip, "%me%")) |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
886 recip = g_getenv("USER"); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
887 } else { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
888 splitted = g_strsplit(nm, ",", 3); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
889 if (!splitted[0] || !splitted[1] || !splitted[2]) { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
890 g_strfreev(splitted); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
891 return; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
892 } |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
893 classname = g_strstrip(splitted[0]); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
894 instname = g_strstrip(splitted[1]); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
895 recip = g_strstrip(splitted[2]); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
896 } |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
897 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
898 zt1 = new_triple(classname, instname, recip); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
899 if (splitted) |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
900 g_strfreev(splitted); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
901 zt2 = find_sub_by_triple(zt1); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
902 if (zt2) { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
903 free_triple(zt1); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
904 if (!zt2->open) |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
905 serv_got_joined_chat(gc, zt2->id, zt2->name); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
906 return; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
907 } |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
908 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
909 sub.zsub_class = zt1->class; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
910 sub.zsub_classinst = zt1->instance; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
911 sub.zsub_recipient = zt1->recipient; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
912 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
913 if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
914 free_triple(zt1); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
915 return; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
916 } |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
917 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
918 subscrips = g_slist_append(subscrips, zt1); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
919 zt1->open = TRUE; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
920 serv_got_joined_chat(gc, zt1->id, zt1->name); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
921 } |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
922 |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
923 static void zephyr_chat_leave(struct gaim_connection *gc, int id) |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
924 { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
925 zephyr_triple *zt; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
926 zt = find_sub_by_id(id); |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
927 if (zt) { |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
928 zt->open = FALSE; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
929 zt->id = ++last_id; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
930 } |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
931 } |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
932 |
1700 | 933 static struct prpl *my_protocol = NULL; |
934 | |
935 void zephyr_init(struct prpl *ret) | |
936 { | |
937 ret->protocol = PROTO_ZEPHYR; | |
938 ret->name = zephyr_name; | |
939 ret->login = zephyr_login; | |
940 ret->close = zephyr_close; | |
941 ret->add_buddy = zephyr_add_buddy; | |
942 ret->remove_buddy = zephyr_remove_buddy; | |
943 ret->send_im = zephyr_send_im; | |
1719
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
944 ret->get_info = zephyr_zloc; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
945 ret->normalize = zephyr_normalize; |
5800449e7ecc
[gaim-migrate @ 1729]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1700
diff
changeset
|
946 ret->buddy_menu = zephyr_buddy_menu; |
1726
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
947 ret->away_states = zephyr_away_states; |
004725b3a851
[gaim-migrate @ 1736]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1719
diff
changeset
|
948 ret->set_away = zephyr_set_away; |
1808
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
949 ret->draw_join_chat = zephyr_draw_jc; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
950 ret->join_chat = zephyr_join_chat; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
951 ret->chat_send = zephyr_chat_send; |
6a89897c8658
[gaim-migrate @ 1818]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1794
diff
changeset
|
952 ret->chat_leave = zephyr_chat_leave; |
1700 | 953 |
954 my_protocol = ret; | |
955 } | |
956 | |
957 char *gaim_plugin_init(GModule *handle) | |
958 { | |
959 load_protocol(zephyr_init, sizeof(struct prpl)); | |
960 return NULL; | |
961 } | |
962 | |
963 void gaim_plugin_remove() | |
964 { | |
965 struct prpl *p = find_prpl(PROTO_ZEPHYR); | |
966 if (p == my_protocol) | |
967 unload_protocol(p); | |
968 } |