Mercurial > pidgin
annotate src/server.c @ 303:1943ddaf8240
[gaim-migrate @ 313]
Changes
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Thu, 01 Jun 2000 17:08:39 +0000 |
parents | 61894ab8c47e |
children | 3069be4c291e |
rev | line source |
---|---|
1 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
21 | |
22 #include <time.h> | |
23 #include <stdio.h> | |
24 #include <string.h> | |
25 #include <sys/types.h> | |
26 #include <sys/stat.h> | |
27 #include <sys/time.h> | |
28 #include <unistd.h> | |
29 #include <gtk/gtk.h> | |
30 #ifdef USE_OSCAR | |
283
0f14e6d8a51b
[gaim-migrate @ 293]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
281
diff
changeset
|
31 #include <aim.h> |
276
9e6fc62490cd
[gaim-migrate @ 286]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
273
diff
changeset
|
32 extern int gaim_caps; |
1 | 33 #endif |
34 #include "gaim.h" | |
35 | |
36 static int idle_timer = -1; | |
37 static time_t lastsent = 0; | |
38 static time_t login_time = 0; | |
39 static struct timeval lag_tv; | |
40 static int is_idle = 0; | |
41 | |
42 int correction_time = 0; | |
43 | |
44 int serv_login(char *username, char *password) | |
45 { | |
46 #ifndef USE_OSCAR | |
47 return toc_login(username, password); | |
48 #else | |
49 return oscar_login(username, password); | |
50 #endif | |
51 } | |
52 | |
53 void serv_close() | |
54 { | |
55 #ifndef USE_OSCAR | |
56 toc_close(); | |
242
14fc16f579c8
[gaim-migrate @ 252]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
57 #else |
14fc16f579c8
[gaim-migrate @ 252]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
58 oscar_close(); |
1 | 59 #endif |
60 gtk_timeout_remove(idle_timer); | |
61 idle_timer = -1; | |
62 } | |
63 | |
64 | |
65 void serv_touch_idle() | |
66 { | |
67 /* Are we idle? If so, not anymore */ | |
68 if (is_idle > 0) { | |
69 is_idle = 0; | |
70 serv_set_idle(0); | |
71 } | |
72 time(&lastsent); | |
73 } | |
74 | |
75 | |
76 static gint check_idle() | |
77 { | |
78 time_t t; | |
79 | |
80 /* Not idle, really... :) */ | |
81 update_all_buddies(); | |
82 | |
83 time(&t); | |
84 | |
85 gettimeofday(&lag_tv, NULL); | |
171
789c792ed14b
[gaim-migrate @ 181]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
145
diff
changeset
|
86 if (general_options & OPT_GEN_SHOW_LAGMETER) |
181
f2d631f867a3
[gaim-migrate @ 191]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
171
diff
changeset
|
87 serv_send_im(current_user->username, LAGOMETER_STR, 1); |
1 | 88 |
89 if (report_idle != IDLE_GAIM) | |
90 return TRUE; | |
91 | |
92 | |
93 if (is_idle) | |
94 return TRUE; | |
95 | |
96 if ((t - lastsent) > 600) { /* 15 minutes! */ | |
97 serv_set_idle((int)t - lastsent); | |
98 is_idle = 1; | |
99 } | |
100 | |
115
890cfb7d8fdb
[gaim-migrate @ 125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
101
diff
changeset
|
101 #ifdef GAIM_PLUGINS |
890cfb7d8fdb
[gaim-migrate @ 125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
101
diff
changeset
|
102 { |
890cfb7d8fdb
[gaim-migrate @ 125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
101
diff
changeset
|
103 GList *c = callbacks; |
890cfb7d8fdb
[gaim-migrate @ 125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
101
diff
changeset
|
104 struct gaim_callback *g; |
890cfb7d8fdb
[gaim-migrate @ 125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
101
diff
changeset
|
105 void (*function)(void *); |
890cfb7d8fdb
[gaim-migrate @ 125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
101
diff
changeset
|
106 while (c) { |
890cfb7d8fdb
[gaim-migrate @ 125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
101
diff
changeset
|
107 g = (struct gaim_callback *)c->data; |
890cfb7d8fdb
[gaim-migrate @ 125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
101
diff
changeset
|
108 if (g->event == event_blist_update && |
890cfb7d8fdb
[gaim-migrate @ 125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
101
diff
changeset
|
109 g->function != NULL) { |
890cfb7d8fdb
[gaim-migrate @ 125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
101
diff
changeset
|
110 function = g->function; |
890cfb7d8fdb
[gaim-migrate @ 125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
101
diff
changeset
|
111 (*function)(g->data); |
890cfb7d8fdb
[gaim-migrate @ 125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
101
diff
changeset
|
112 } |
890cfb7d8fdb
[gaim-migrate @ 125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
101
diff
changeset
|
113 c = c->next; |
890cfb7d8fdb
[gaim-migrate @ 125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
101
diff
changeset
|
114 } |
890cfb7d8fdb
[gaim-migrate @ 125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
101
diff
changeset
|
115 } |
890cfb7d8fdb
[gaim-migrate @ 125]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
101
diff
changeset
|
116 #endif |
1 | 117 |
118 return TRUE; | |
119 | |
120 } | |
121 | |
122 | |
123 void serv_finish_login() | |
124 { | |
125 char *buf; | |
126 | |
127 if (strlen(current_user->user_info)) { | |
79 | 128 buf = g_malloc(strlen(current_user->user_info) * 4); |
1 | 129 strcpy(buf, current_user->user_info); |
130 escape_text(buf); | |
131 serv_set_info(buf); | |
132 g_free(buf); | |
133 } | |
134 | |
135 if (idle_timer != -1) | |
136 gtk_timeout_remove(idle_timer); | |
137 | |
138 idle_timer = gtk_timeout_add(20000, (GtkFunction)check_idle, NULL); | |
139 serv_touch_idle(); | |
140 | |
141 time(&login_time); | |
142 | |
143 serv_add_buddy(current_user->username); | |
144 | |
145 if (!(general_options & OPT_GEN_REGISTERED)) | |
146 { | |
147 show_register_dialog(); | |
148 save_prefs(); | |
149 } | |
150 } | |
151 | |
152 | |
153 | |
154 void serv_send_im(char *name, char *message, int away) | |
155 { | |
273
4c6c213646a3
[gaim-migrate @ 283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
270
diff
changeset
|
156 #ifndef USE_OSCAR |
1 | 157 char buf[MSG_LEN - 7]; |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
79
diff
changeset
|
158 |
1 | 159 g_snprintf(buf, MSG_LEN - 8, "toc_send_im %s \"%s\"%s", normalize(name), |
160 message, ((away) ? " auto" : "")); | |
161 sflap_send(buf, strlen(buf), TYPE_DATA); | |
162 #else | |
302
61894ab8c47e
[gaim-migrate @ 312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
163 if (away) |
61894ab8c47e
[gaim-migrate @ 312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
164 aim_send_im(gaim_sess, gaim_conn, name, AIM_IMFLAGS_AWAY, message); |
61894ab8c47e
[gaim-migrate @ 312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
165 else |
61894ab8c47e
[gaim-migrate @ 312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
166 aim_send_im(gaim_sess, gaim_conn, name, 0, message); |
1 | 167 #endif |
168 if (!away) | |
169 serv_touch_idle(); | |
170 } | |
171 | |
172 void serv_get_info(char *name) | |
173 { | |
273
4c6c213646a3
[gaim-migrate @ 283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
270
diff
changeset
|
174 #ifndef USE_OSCAR |
237
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
175 char buf[MSG_LEN]; |
1 | 176 g_snprintf(buf, MSG_LEN, "toc_get_info %s", normalize(name)); |
177 sflap_send(buf, -1, TYPE_DATA); | |
243
3414ff74cb0f
[gaim-migrate @ 253]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
242
diff
changeset
|
178 #else |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
248
diff
changeset
|
179 aim_getinfo(gaim_sess, gaim_conn, name, AIM_GETINFO_GENERALINFO); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
248
diff
changeset
|
180 #endif |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
248
diff
changeset
|
181 } |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
248
diff
changeset
|
182 |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
248
diff
changeset
|
183 void serv_get_away_msg(char *name) |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
248
diff
changeset
|
184 { |
273
4c6c213646a3
[gaim-migrate @ 283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
270
diff
changeset
|
185 #ifndef USE_OSCAR |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
248
diff
changeset
|
186 char buf[MSG_LEN]; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
248
diff
changeset
|
187 /* HAHA! TOC doesn't have this yet */ |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
248
diff
changeset
|
188 #else |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
248
diff
changeset
|
189 aim_getinfo(gaim_sess, gaim_conn, name, AIM_GETINFO_AWAYMESSAGE); |
1 | 190 #endif |
191 } | |
192 | |
193 void serv_get_dir(char *name) | |
194 { | |
273
4c6c213646a3
[gaim-migrate @ 283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
270
diff
changeset
|
195 #ifndef USE_OSCAR |
237
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
196 char buf[MSG_LEN]; |
1 | 197 g_snprintf(buf, MSG_LEN, "toc_get_dir %s", normalize(name)); |
198 sflap_send(buf, -1, TYPE_DATA); | |
199 #endif | |
200 } | |
201 | |
202 void serv_set_dir(char *first, char *middle, char *last, char *maiden, | |
203 char *city, char *state, char *country, int web) | |
204 { | |
273
4c6c213646a3
[gaim-migrate @ 283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
270
diff
changeset
|
205 #ifndef USE_OSCAR |
237
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
206 char buf2[BUF_LEN*4], buf[BUF_LEN]; |
1 | 207 g_snprintf(buf2, sizeof(buf2), "%s:%s:%s:%s:%s:%s:%s:%s", first, |
208 middle, last, maiden, city, state, country, | |
209 (web == 1) ? "Y" : ""); | |
210 escape_text(buf2); | |
211 g_snprintf(buf, sizeof(buf), "toc_set_dir %s", buf2); | |
212 sflap_send(buf, -1, TYPE_DATA); | |
213 #endif | |
214 } | |
215 | |
216 void serv_dir_search(char *first, char *middle, char *last, char *maiden, | |
217 char *city, char *state, char *country, char *email) | |
218 { | |
273
4c6c213646a3
[gaim-migrate @ 283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
270
diff
changeset
|
219 #ifndef USE_OSCAR |
237
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
220 char buf[BUF_LONG]; |
1 | 221 g_snprintf(buf, sizeof(buf)/2, "toc_dir_search %s:%s:%s:%s:%s:%s:%s:%s", first, middle, last, maiden, city, state, country, email); |
222 sprintf(debug_buff,"Searching for: %s,%s,%s,%s,%s,%s,%s\n", first, middle, last, maiden, city, state, country); | |
223 debug_print(debug_buff); | |
224 sflap_send(buf, -1, TYPE_DATA); | |
243
3414ff74cb0f
[gaim-migrate @ 253]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
242
diff
changeset
|
225 #else |
3414ff74cb0f
[gaim-migrate @ 253]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
242
diff
changeset
|
226 if (strlen(email)) |
3414ff74cb0f
[gaim-migrate @ 253]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
242
diff
changeset
|
227 aim_usersearch_address(gaim_sess, gaim_conn, email); |
1 | 228 #endif |
229 } | |
230 | |
231 | |
232 void serv_set_away(char *message) | |
233 { | |
273
4c6c213646a3
[gaim-migrate @ 283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
270
diff
changeset
|
234 #ifndef USE_OSCAR |
237
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
235 char buf[MSG_LEN]; |
1 | 236 if (message) |
237 g_snprintf(buf, MSG_LEN, "toc_set_away \"%s\"", message); | |
238 else | |
200
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
181
diff
changeset
|
239 g_snprintf(buf, MSG_LEN, "toc_set_away \"\""); |
1 | 240 sflap_send(buf, -1, TYPE_DATA); |
243
3414ff74cb0f
[gaim-migrate @ 253]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
242
diff
changeset
|
241 #else |
3414ff74cb0f
[gaim-migrate @ 253]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
242
diff
changeset
|
242 aim_bos_setprofile(gaim_sess, gaim_conn, current_user->user_info, |
276
9e6fc62490cd
[gaim-migrate @ 286]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
273
diff
changeset
|
243 message, gaim_caps); |
1 | 244 #endif |
245 } | |
246 | |
247 void serv_set_info(char *info) | |
248 { | |
273
4c6c213646a3
[gaim-migrate @ 283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
270
diff
changeset
|
249 #ifndef USE_OSCAR |
1 | 250 char buf[MSG_LEN]; |
251 g_snprintf(buf, sizeof(buf), "toc_set_info \"%s\n\"", info); | |
252 sflap_send(buf, -1, TYPE_DATA); | |
243
3414ff74cb0f
[gaim-migrate @ 253]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
242
diff
changeset
|
253 #else |
3414ff74cb0f
[gaim-migrate @ 253]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
242
diff
changeset
|
254 if (awaymessage) |
3414ff74cb0f
[gaim-migrate @ 253]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
242
diff
changeset
|
255 aim_bos_setprofile(gaim_sess, gaim_conn, info, |
276
9e6fc62490cd
[gaim-migrate @ 286]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
273
diff
changeset
|
256 awaymessage->message, gaim_caps); |
243
3414ff74cb0f
[gaim-migrate @ 253]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
242
diff
changeset
|
257 else |
3414ff74cb0f
[gaim-migrate @ 253]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
242
diff
changeset
|
258 aim_bos_setprofile(gaim_sess, gaim_conn, info, |
276
9e6fc62490cd
[gaim-migrate @ 286]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
273
diff
changeset
|
259 NULL, gaim_caps); |
237
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
260 #endif |
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
261 } |
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
262 |
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
263 void serv_change_passwd(char *orig, char *new) { |
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
264 #ifndef USE_OSCAR |
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
265 char *buf = g_malloc(BUF_LONG); |
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
266 g_snprintf(buf, BUF_LONG, "toc_change_passwd %s %s", orig, new); |
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
267 sflap_send(buf, strlen(buf), TYPE_DATA); |
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
268 g_free(buf); |
1 | 269 #endif |
270 } | |
271 | |
272 void serv_add_buddy(char *name) | |
273 { | |
273
4c6c213646a3
[gaim-migrate @ 283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
270
diff
changeset
|
274 #ifndef USE_OSCAR |
237
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
275 char buf[1024]; |
1 | 276 g_snprintf(buf, sizeof(buf), "toc_add_buddy %s", normalize(name)); |
277 sflap_send(buf, -1, TYPE_DATA); | |
242
14fc16f579c8
[gaim-migrate @ 252]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
278 #else |
14fc16f579c8
[gaim-migrate @ 252]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
279 aim_add_buddy(gaim_sess, gaim_conn, name); |
1 | 280 #endif |
281 } | |
282 | |
283 void serv_add_buddies(GList *buddies) | |
284 { | |
273
4c6c213646a3
[gaim-migrate @ 283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
270
diff
changeset
|
285 #ifndef USE_OSCAR |
1 | 286 char buf[MSG_LEN]; |
287 int n, num = 0; | |
237
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
288 |
1 | 289 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); |
290 while(buddies) { | |
291 if (num == 20) { | |
292 sflap_send(buf, -1, TYPE_DATA); | |
293 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); | |
294 num = 0; | |
295 } | |
296 ++num; | |
297 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", normalize(buddies->data)); | |
298 buddies = buddies->next; | |
299 } | |
300 sflap_send(buf, -1, TYPE_DATA); | |
242
14fc16f579c8
[gaim-migrate @ 252]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
301 #else |
14fc16f579c8
[gaim-migrate @ 252]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
302 /* oscar you have to add them one name at a time, except at login */ |
14fc16f579c8
[gaim-migrate @ 252]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
303 while(buddies) { |
14fc16f579c8
[gaim-migrate @ 252]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
304 serv_add_buddy((char *)buddies->data); |
14fc16f579c8
[gaim-migrate @ 252]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
305 buddies = buddies->next; |
14fc16f579c8
[gaim-migrate @ 252]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
306 } |
1 | 307 #endif |
308 } | |
309 | |
310 | |
311 void serv_remove_buddy(char *name) | |
312 { | |
273
4c6c213646a3
[gaim-migrate @ 283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
270
diff
changeset
|
313 #ifndef USE_OSCAR |
237
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
314 char buf[1024]; |
1 | 315 g_snprintf(buf, sizeof(buf), "toc_remove_buddy %s", normalize(name)); |
316 sflap_send(buf, -1, TYPE_DATA); | |
242
14fc16f579c8
[gaim-migrate @ 252]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
317 #else |
14fc16f579c8
[gaim-migrate @ 252]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
318 aim_remove_buddy(gaim_sess, gaim_conn, name); |
1 | 319 #endif |
320 } | |
321 | |
322 void serv_add_permit(char *name) | |
323 { | |
273
4c6c213646a3
[gaim-migrate @ 283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
270
diff
changeset
|
324 #ifndef USE_OSCAR |
237
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
325 char buf[1024]; |
1 | 326 g_snprintf(buf, sizeof(buf), "toc_add_permit %s", normalize(name)); |
327 sflap_send(buf, -1, TYPE_DATA); | |
247
f6e8ea29b24f
[gaim-migrate @ 257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
243
diff
changeset
|
328 #else |
f6e8ea29b24f
[gaim-migrate @ 257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
243
diff
changeset
|
329 serv_set_permit_deny(); |
1 | 330 #endif |
331 } | |
332 | |
333 | |
334 | |
335 void serv_add_deny(char *name) | |
336 { | |
273
4c6c213646a3
[gaim-migrate @ 283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
270
diff
changeset
|
337 #ifndef USE_OSCAR |
237
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
338 char buf[1024]; |
1 | 339 g_snprintf(buf, sizeof(buf), "toc_add_deny %s", normalize(name)); |
340 sflap_send(buf, -1, TYPE_DATA); | |
247
f6e8ea29b24f
[gaim-migrate @ 257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
243
diff
changeset
|
341 #else |
f6e8ea29b24f
[gaim-migrate @ 257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
243
diff
changeset
|
342 serv_set_permit_deny(); |
1 | 343 #endif |
344 } | |
345 | |
346 | |
347 | |
348 void serv_set_permit_deny() | |
349 { | |
281
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
350 #ifndef USE_OSCAR |
1 | 351 char buf[MSG_LEN]; |
352 int at; | |
353 GList *list; | |
237
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
354 |
1 | 355 /* FIXME! We flash here. */ |
356 if (permdeny == 1 || permdeny == 3) { | |
357 g_snprintf(buf, sizeof(buf), "toc_add_permit"); | |
358 sflap_send(buf, -1, TYPE_DATA); | |
359 } else { | |
360 g_snprintf(buf, sizeof(buf), "toc_add_deny"); | |
361 sflap_send(buf, -1, TYPE_DATA); | |
362 } | |
363 | |
364 | |
365 at = g_snprintf(buf, sizeof(buf), "toc_add_permit"); | |
366 list = permit; | |
367 while(list) { | |
368 at += g_snprintf(&buf[at], sizeof(buf) - at, " %s", normalize(list->data)); | |
369 list = list->next; | |
370 } | |
371 buf[at] = 0; | |
372 sflap_send(buf, -1, TYPE_DATA); | |
373 | |
374 at = g_snprintf(buf, sizeof(buf), "toc_add_deny"); | |
375 list = deny; | |
376 while(list) { | |
377 at += g_snprintf(&buf[at], sizeof(buf) - at, " %s", normalize(list->data)); | |
378 list = list->next; | |
379 } | |
380 buf[at] = 0; | |
381 sflap_send(buf, -1, TYPE_DATA); | |
247
f6e8ea29b24f
[gaim-migrate @ 257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
243
diff
changeset
|
382 #else |
f6e8ea29b24f
[gaim-migrate @ 257]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
243
diff
changeset
|
383 /* oscar requires us to do everyone at once (?) */ |
265
59f1748b09a6
[gaim-migrate @ 275]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
263
diff
changeset
|
384 /* I think this code is OK now. */ |
281
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
385 char buf[BUF_LONG]; int at; GList *list, *grp, *bud; |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
386 if (permdeny == 3) { /* Permit Some : Only people on buddy list and |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
387 on permit list */ |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
388 struct group *g; struct buddy *b; |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
389 at = 0; list = permit; grp = groups; |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
390 debug_print("Setting permit list...\n"); |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
391 while (grp) { |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
392 g = (struct group *)grp->data; |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
393 bud = g->members; |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
394 while (bud) { |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
395 b = (struct buddy *)bud->data; |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
396 at += g_snprintf(&buf[at], sizeof(buf) - at, |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
397 "%s&", b->name); |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
398 bud = bud->next; |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
399 } |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
400 grp = grp->next; |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
401 } |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
402 while (list) { |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
403 at += g_snprintf(&buf[at], sizeof(buf) - at, "%s&", |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
404 list->data); |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
405 list = list->next; |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
406 } |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
407 aim_bos_changevisibility(gaim_sess, gaim_conn, |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
408 AIM_VISIBILITYCHANGE_PERMITADD, buf); |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
409 } else { /* Deny Some : Deny people on deny list */ |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
410 list = deny; at = 0; |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
411 if (list == NULL) return; |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
412 while (list) { |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
413 at += g_snprintf(&buf[at], sizeof(buf) - at, "%s&", |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
414 list->data); |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
415 list = list->next; |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
416 } |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
417 aim_bos_changevisibility(gaim_sess, gaim_conn, |
7b06ba09ffe2
[gaim-migrate @ 291]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
280
diff
changeset
|
418 AIM_VISIBILITYCHANGE_DENYADD, buf); |
280
e606585a38bd
[gaim-migrate @ 290]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
276
diff
changeset
|
419 } |
1 | 420 #endif |
421 } | |
422 | |
423 void serv_set_idle(int time) | |
424 { | |
273
4c6c213646a3
[gaim-migrate @ 283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
270
diff
changeset
|
425 #ifndef USE_OSCAR |
237
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
426 char buf[256]; |
1 | 427 g_snprintf(buf, sizeof(buf), "toc_set_idle %d", time); |
428 sflap_send(buf, -1, TYPE_DATA); | |
243
3414ff74cb0f
[gaim-migrate @ 253]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
242
diff
changeset
|
429 #else |
3414ff74cb0f
[gaim-migrate @ 253]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
242
diff
changeset
|
430 aim_bos_setidle(gaim_sess, gaim_conn, time); |
1 | 431 #endif |
432 } | |
433 | |
434 | |
435 void serv_warn(char *name, int anon) | |
436 { | |
437 #ifndef USE_OSCAR | |
438 char *send = g_malloc(256); | |
439 g_snprintf(send, 255, "toc_evil %s %s", name, | |
440 ((anon) ? "anon" : "norm")); | |
441 sflap_send(send, -1, TYPE_DATA); | |
442 g_free(send); | |
443 #endif | |
444 } | |
445 | |
237
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
446 void serv_build_config(char *buf, int len) { |
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
447 toc_build_config(buf, len); |
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
448 } |
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
449 |
1 | 450 |
451 void serv_save_config() | |
452 { | |
453 #ifndef USE_OSCAR | |
454 char *buf = g_malloc(BUF_LONG); | |
455 char *buf2 = g_malloc(MSG_LEN); | |
237
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
456 serv_build_config(buf, BUF_LONG / 2); |
1 | 457 g_snprintf(buf2, MSG_LEN, "toc_set_config {%s}", buf); |
458 sflap_send(buf2, -1, TYPE_DATA); | |
459 g_free(buf2); | |
460 g_free(buf); | |
461 #endif | |
462 } | |
463 | |
464 | |
465 void serv_accept_chat(int i) | |
466 { | |
467 #ifndef USE_OSCAR | |
468 char *buf = g_malloc(256); | |
469 g_snprintf(buf, 255, "toc_chat_accept %d", i); | |
470 sflap_send(buf, -1, TYPE_DATA); | |
471 g_free(buf); | |
252
4a41f8323022
[gaim-migrate @ 262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
249
diff
changeset
|
472 #else |
4a41f8323022
[gaim-migrate @ 262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
249
diff
changeset
|
473 /* this should never get called because libfaim doesn't use the id |
4a41f8323022
[gaim-migrate @ 262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
249
diff
changeset
|
474 * (i'm not even sure Oscar does). go through serv_join_chat instead */ |
1 | 475 #endif |
476 } | |
477 | |
478 void serv_join_chat(int exchange, char *name) | |
479 { | |
273
4c6c213646a3
[gaim-migrate @ 283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
270
diff
changeset
|
480 #ifndef USE_OSCAR |
237
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
481 char buf[BUF_LONG]; |
1 | 482 g_snprintf(buf, sizeof(buf)/2, "toc_chat_join %d \"%s\"", exchange, name); |
483 sflap_send(buf, -1, TYPE_DATA); | |
248
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
484 #else |
302
61894ab8c47e
[gaim-migrate @ 312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
485 sprintf(debug_buff, "Attempting to join chat room %s.\n", name); |
61894ab8c47e
[gaim-migrate @ 312]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
486 debug_print(debug_buff); |
248
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
487 aim_chat_join(gaim_sess, gaim_conn, 0x0004, name); |
1 | 488 #endif |
489 } | |
490 | |
491 void serv_chat_invite(int id, char *message, char *name) | |
492 { | |
273
4c6c213646a3
[gaim-migrate @ 283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
270
diff
changeset
|
493 #ifndef USE_OSCAR |
237
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
494 char buf[BUF_LONG]; |
1 | 495 g_snprintf(buf, sizeof(buf)/2, "toc_chat_invite %d \"%s\" %s", id, message, normalize(name)); |
496 sflap_send(buf, -1, TYPE_DATA); | |
258
1eeece1c7b7b
[gaim-migrate @ 268]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
256
diff
changeset
|
497 #else |
1eeece1c7b7b
[gaim-migrate @ 268]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
256
diff
changeset
|
498 GList *bcs = buddy_chats; |
1eeece1c7b7b
[gaim-migrate @ 268]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
256
diff
changeset
|
499 struct buddy_chat *b = NULL; |
1eeece1c7b7b
[gaim-migrate @ 268]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
256
diff
changeset
|
500 |
1eeece1c7b7b
[gaim-migrate @ 268]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
256
diff
changeset
|
501 while (bcs) { |
1eeece1c7b7b
[gaim-migrate @ 268]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
256
diff
changeset
|
502 b = (struct buddy_chat *)bcs->data; |
1eeece1c7b7b
[gaim-migrate @ 268]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
256
diff
changeset
|
503 if (id == b->id) |
1eeece1c7b7b
[gaim-migrate @ 268]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
256
diff
changeset
|
504 break; |
1eeece1c7b7b
[gaim-migrate @ 268]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
256
diff
changeset
|
505 bcs = bcs->next; |
1eeece1c7b7b
[gaim-migrate @ 268]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
256
diff
changeset
|
506 b = NULL; |
1eeece1c7b7b
[gaim-migrate @ 268]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
256
diff
changeset
|
507 } |
1eeece1c7b7b
[gaim-migrate @ 268]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
256
diff
changeset
|
508 |
1eeece1c7b7b
[gaim-migrate @ 268]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
256
diff
changeset
|
509 if (!b) |
1eeece1c7b7b
[gaim-migrate @ 268]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
256
diff
changeset
|
510 return; |
1eeece1c7b7b
[gaim-migrate @ 268]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
256
diff
changeset
|
511 |
1eeece1c7b7b
[gaim-migrate @ 268]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
256
diff
changeset
|
512 aim_chat_invite(gaim_sess, gaim_conn, name, message, 0x4, b->name, 0x1); |
1 | 513 #endif |
514 } | |
515 | |
516 void serv_chat_leave(int id) | |
517 { | |
518 #ifndef USE_OSCAR | |
519 char *buf = g_malloc(256); | |
520 g_snprintf(buf, 255, "toc_chat_leave %d", id); | |
521 sflap_send(buf, -1, TYPE_DATA); | |
522 g_free(buf); | |
248
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
523 #else |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
524 GList *bcs = buddy_chats; |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
525 struct buddy_chat *b = NULL; |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
526 |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
527 while (bcs) { |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
528 b = (struct buddy_chat *)bcs->data; |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
529 if (id == b->id) |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
530 break; |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
531 bcs = bcs->next; |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
532 b = NULL; |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
533 } |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
534 |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
535 if (!b) |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
536 return; |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
537 |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
538 aim_chat_leaveroom(gaim_sess, b->name); |
1 | 539 #endif |
540 } | |
541 | |
542 void serv_chat_whisper(int id, char *who, char *message) | |
543 { | |
273
4c6c213646a3
[gaim-migrate @ 283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
270
diff
changeset
|
544 #ifndef USE_OSCAR |
237
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
545 char buf2[MSG_LEN]; |
1 | 546 g_snprintf(buf2, sizeof(buf2), "toc_chat_whisper %d %s \"%s\"", id, who, message); |
547 sflap_send(buf2, -1, TYPE_DATA); | |
248
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
548 #else |
258
1eeece1c7b7b
[gaim-migrate @ 268]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
256
diff
changeset
|
549 do_error_dialog("Sorry, Oscar doesn't whisper. Send an IM.", |
1eeece1c7b7b
[gaim-migrate @ 268]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
256
diff
changeset
|
550 "Gaim - Chat"); |
1 | 551 #endif |
552 } | |
553 | |
554 void serv_chat_send(int id, char *message) | |
555 { | |
273
4c6c213646a3
[gaim-migrate @ 283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
270
diff
changeset
|
556 #ifndef USE_OSCAR |
237
6ced2f1c8b24
[gaim-migrate @ 247]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
557 char buf[MSG_LEN]; |
1 | 558 g_snprintf(buf, sizeof(buf), "toc_chat_send %d \"%s\"",id, message); |
559 sflap_send(buf, -1, TYPE_DATA); | |
248
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
560 #else |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
561 struct aim_conn_t *cn; |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
562 GList *bcs = buddy_chats; |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
563 struct buddy_chat *b = NULL; |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
564 |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
565 while (bcs) { |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
566 b = (struct buddy_chat *)bcs->data; |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
567 if (id == b->id) |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
568 break; |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
569 bcs = bcs->next; |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
570 b = NULL; |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
571 } |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
572 if (!b) |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
573 return; |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
574 |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
575 cn = aim_chat_getconn(gaim_sess, b->name); |
cfc73b8501a7
[gaim-migrate @ 258]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
247
diff
changeset
|
576 aim_chat_send_im(gaim_sess, cn, message); |
1 | 577 #endif |
578 } | |
579 | |
580 | |
581 | |
582 | |
583 void serv_got_im(char *name, char *message, int away) | |
584 { | |
585 struct conversation *cnv; | |
586 int is_idle = -1; | |
587 int new_conv = 0; | |
588 char *nname; | |
589 | |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
79
diff
changeset
|
590 #ifdef GAIM_PLUGINS |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
79
diff
changeset
|
591 GList *c = callbacks; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
79
diff
changeset
|
592 struct gaim_callback *g; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
79
diff
changeset
|
593 void (*function)(char **, char **, void *); |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
79
diff
changeset
|
594 while (c) { |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
79
diff
changeset
|
595 g = (struct gaim_callback *)c->data; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
79
diff
changeset
|
596 if (g->event == event_im_recv && g->function != NULL) { |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
79
diff
changeset
|
597 function = g->function; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
79
diff
changeset
|
598 /* I can guarantee you this is wrong */ |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
79
diff
changeset
|
599 (*function)(&name, &message, g->data); |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
79
diff
changeset
|
600 } |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
79
diff
changeset
|
601 c = c->next; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
79
diff
changeset
|
602 } |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
79
diff
changeset
|
603 /* make sure no evil plugin is trying to crash gaim */ |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
79
diff
changeset
|
604 if (message == NULL) |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
79
diff
changeset
|
605 return; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
79
diff
changeset
|
606 #endif |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
79
diff
changeset
|
607 |
1 | 608 nname = g_strdup(normalize(name)); |
609 | |
171
789c792ed14b
[gaim-migrate @ 181]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
145
diff
changeset
|
610 if (!strcasecmp(normalize(current_user->username), nname)) { |
1 | 611 if (!strcmp(message, LAGOMETER_STR)) { |
612 struct timeval tv; | |
613 int ms; | |
614 | |
615 gettimeofday(&tv, NULL); | |
616 | |
617 ms = 1000000 * (tv.tv_sec - lag_tv.tv_sec); | |
618 | |
619 ms += tv.tv_usec - lag_tv.tv_usec; | |
620 | |
621 update_lagometer(ms); | |
622 g_free(nname); | |
623 return; | |
624 } | |
14 | 625 } |
1 | 626 g_free(nname); |
627 | |
628 cnv = find_conversation(name); | |
145
41bd1cd48571
[gaim-migrate @ 155]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
136
diff
changeset
|
629 if (away) away = WFLAG_AUTO; |
1 | 630 |
631 if (awaymessage != NULL) { | |
632 if (!(general_options & OPT_GEN_DISCARD_WHEN_AWAY)) { | |
633 if (cnv == NULL) { | |
634 new_conv = 1; | |
635 cnv = new_conversation(name); | |
636 } | |
637 } | |
638 if (cnv != NULL) { | |
639 if (sound_options & OPT_SOUND_WHEN_AWAY) | |
640 play_sound(AWAY); | |
145
41bd1cd48571
[gaim-migrate @ 155]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
136
diff
changeset
|
641 write_to_conv(cnv, message, away | WFLAG_RECV); |
1 | 642 } |
643 | |
644 } else { | |
645 if (cnv == NULL) { | |
646 new_conv = 1; | |
647 cnv = new_conversation(name); | |
648 } | |
649 if (new_conv && (sound_options & OPT_SOUND_FIRST_RCV)) { | |
650 play_sound(FIRST_RECEIVE); | |
651 } else { | |
652 if (cnv->makesound && (sound_options & OPT_SOUND_RECV)) | |
653 play_sound(RECEIVE); | |
654 } | |
145
41bd1cd48571
[gaim-migrate @ 155]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
136
diff
changeset
|
655 write_to_conv(cnv, message, away | WFLAG_RECV); |
1 | 656 } |
657 | |
658 | |
659 | |
660 | |
661 if (awaymessage != NULL) { | |
662 time_t t; | |
263
8aa7368baae7
[gaim-migrate @ 273]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
663 char tmpmsg[BUF_LEN]; |
1 | 664 |
665 time(&t); | |
666 | |
667 | |
668 if ((cnv == NULL) || (t - cnv->sent_away) < 120) | |
669 return; | |
670 | |
671 cnv->sent_away = t; | |
672 | |
673 if (is_idle) | |
674 is_idle = -1; | |
675 | |
263
8aa7368baae7
[gaim-migrate @ 273]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
676 strcpy(tmpmsg, awaymessage->message); |
8aa7368baae7
[gaim-migrate @ 273]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
677 escape_text(tmpmsg); |
8aa7368baae7
[gaim-migrate @ 273]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
678 escape_message(tmpmsg); |
8aa7368baae7
[gaim-migrate @ 273]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
260
diff
changeset
|
679 serv_send_im(name, tmpmsg, 1); |
1 | 680 |
681 if (is_idle == -1) | |
682 is_idle = 1; | |
683 | |
684 if (cnv != NULL) | |
685 write_to_conv(cnv, awaymessage->message, WFLAG_SEND | WFLAG_AUTO); | |
686 } | |
687 } | |
688 | |
689 | |
690 | |
691 void serv_got_update(char *name, int loggedin, int evil, time_t signon, time_t idle, int type) | |
692 { | |
693 struct buddy *b; | |
694 char *nname; | |
695 | |
696 b = find_buddy(name); | |
697 | |
698 nname = g_strdup(normalize(name)); | |
699 if (!strcasecmp(nname, normalize(current_user->username))) { | |
700 correction_time = (int)(signon - login_time); | |
701 update_all_buddies(); | |
25 | 702 if (!b) { |
703 g_free(nname); | |
1 | 704 return; |
25 | 705 } |
1 | 706 } |
707 | |
25 | 708 g_free(nname); |
1 | 709 |
710 if (!b) { | |
711 sprintf(debug_buff,"Error, no such person\n"); | |
712 debug_print(debug_buff); | |
713 return; | |
714 } | |
715 | |
716 /* This code will 'align' the name from the TOC */ | |
717 /* server with what's in our record. We want to */ | |
718 /* store things how THEY want it... */ | |
719 if (strcmp(name, b->name)) { | |
720 GList *cnv = conversations; | |
721 struct conversation *cv; | |
722 | |
723 char *who = g_malloc(80); | |
724 | |
725 strcpy(who, normalize(name)); | |
726 | |
727 while(cnv) { | |
728 cv = (struct conversation *)cnv->data; | |
729 if (!strcasecmp(who, normalize(cv->name))) { | |
730 g_snprintf(cv->name, sizeof(cv->name), "%s", name); | |
731 if (find_log_info(name) || (general_options & OPT_GEN_LOG_ALL)) | |
732 g_snprintf(who, 63, LOG_CONVERSATION_TITLE, name); | |
733 else | |
734 g_snprintf(who, 63, CONVERSATION_TITLE, name); | |
735 gtk_window_set_title(GTK_WINDOW(cv->window), who); | |
79 | 736 /* was g_free(buf), but break gives us that |
737 * and freeing twice is not good --Sumner */ | |
1 | 738 break; |
739 } | |
740 cnv = cnv->next; | |
741 } | |
45 | 742 g_free(who); |
1 | 743 g_snprintf(b->name, sizeof(b->name), "%s", name); |
744 /*gtk_label_set_text(GTK_LABEL(b->label), b->name);*/ | |
745 | |
746 /* okay lets save the new config... */ | |
747 | |
748 } | |
749 | |
750 b->idle = idle; | |
751 b->evil = evil; | |
136
4e91b92f91a7
[gaim-migrate @ 146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
115
diff
changeset
|
752 #ifdef GAIM_PLUGINS |
4e91b92f91a7
[gaim-migrate @ 146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
115
diff
changeset
|
753 if ((b->uc & UC_UNAVAILABLE) && !(type & UC_UNAVAILABLE)) { |
4e91b92f91a7
[gaim-migrate @ 146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
115
diff
changeset
|
754 GList *c = callbacks; |
4e91b92f91a7
[gaim-migrate @ 146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
115
diff
changeset
|
755 struct gaim_callback *g; |
4e91b92f91a7
[gaim-migrate @ 146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
115
diff
changeset
|
756 void (*function)(char *, void *); |
4e91b92f91a7
[gaim-migrate @ 146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
115
diff
changeset
|
757 while (c) { |
4e91b92f91a7
[gaim-migrate @ 146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
115
diff
changeset
|
758 g = (struct gaim_callback *)c->data; |
4e91b92f91a7
[gaim-migrate @ 146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
115
diff
changeset
|
759 if (g->event == event_buddy_back && |
4e91b92f91a7
[gaim-migrate @ 146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
115
diff
changeset
|
760 g->function != NULL) { |
4e91b92f91a7
[gaim-migrate @ 146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
115
diff
changeset
|
761 function = g->function; |
4e91b92f91a7
[gaim-migrate @ 146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
115
diff
changeset
|
762 (*function)(b->name, g->data); |
4e91b92f91a7
[gaim-migrate @ 146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
115
diff
changeset
|
763 } |
4e91b92f91a7
[gaim-migrate @ 146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
115
diff
changeset
|
764 c = c->next; |
4e91b92f91a7
[gaim-migrate @ 146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
115
diff
changeset
|
765 } |
4e91b92f91a7
[gaim-migrate @ 146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
115
diff
changeset
|
766 } |
4e91b92f91a7
[gaim-migrate @ 146]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
115
diff
changeset
|
767 #endif |
1 | 768 b->uc = type; |
769 | |
770 b->signon = signon; | |
771 | |
772 if (loggedin) { | |
773 if (!b->present) { | |
774 b->present = 1; | |
775 do_pounce(b->name); | |
776 } | |
777 } else | |
778 b->present = 0; | |
779 | |
780 set_buddy(b); | |
781 } | |
782 | |
783 static | |
784 void close_warned(GtkWidget *w, GtkWidget *w2) | |
785 { | |
786 gtk_widget_destroy(w2); | |
787 } | |
788 | |
789 | |
790 | |
791 void serv_got_eviled(char *name, int lev) | |
792 { | |
793 char *buf2 = g_malloc(1024); | |
794 GtkWidget *d, *label, *close; | |
795 | |
796 | |
797 g_snprintf(buf2, 1023, "You have just been warned by %s.\nYour new warning level is %d./%%", | |
798 ((name == NULL) ? "an anonymous person" : name) , lev); | |
799 | |
800 | |
801 d = gtk_dialog_new(); | |
802 gtk_widget_realize(d); | |
803 aol_icon(d->window); | |
804 | |
805 label = gtk_label_new(buf2); | |
806 gtk_widget_show(label); | |
807 close = gtk_button_new_with_label("Close"); | |
808 gtk_widget_show(close); | |
809 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->vbox), | |
810 label, FALSE, FALSE, 5); | |
811 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->action_area), | |
812 close, FALSE, FALSE, 5); | |
813 | |
814 gtk_window_set_title(GTK_WINDOW(d), "Warned"); | |
815 gtk_signal_connect(GTK_OBJECT(close), "clicked", GTK_SIGNAL_FUNC(close_warned), d); | |
816 gtk_widget_show(d); | |
817 } | |
818 | |
819 | |
820 | |
821 static void close_invite(GtkWidget *w, GtkWidget *w2) | |
822 { | |
823 gtk_widget_destroy(w2); | |
824 } | |
825 | |
826 static void chat_invite_callback(GtkWidget *w, GtkWidget *w2) | |
827 { | |
252
4a41f8323022
[gaim-migrate @ 262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
249
diff
changeset
|
828 #ifndef USE_OSCAR |
1 | 829 int i = (int)gtk_object_get_user_data(GTK_OBJECT(w2)); |
830 serv_accept_chat(i); | |
831 gtk_widget_destroy(w2); | |
252
4a41f8323022
[gaim-migrate @ 262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
249
diff
changeset
|
832 #else |
4a41f8323022
[gaim-migrate @ 262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
249
diff
changeset
|
833 char *i = (char *)gtk_object_get_user_data(GTK_OBJECT(w2)); |
4a41f8323022
[gaim-migrate @ 262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
249
diff
changeset
|
834 serv_join_chat(0, i); /* for oscar, it doesn't use the id anyway */ |
4a41f8323022
[gaim-migrate @ 262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
249
diff
changeset
|
835 gtk_widget_destroy(w2); |
4a41f8323022
[gaim-migrate @ 262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
249
diff
changeset
|
836 #endif |
1 | 837 } |
838 | |
839 | |
840 | |
841 void serv_got_chat_invite(char *name, int id, char *who, char *message) | |
842 { | |
843 GtkWidget *d; | |
844 GtkWidget *label; | |
845 GtkWidget *yesbtn; | |
846 GtkWidget *nobtn; | |
847 | |
848 char buf2[BUF_LONG]; | |
849 | |
850 | |
851 g_snprintf(buf2, sizeof(buf2), "User '%s' invites you to buddy chat room: '%s'\n%s", who, name, message); | |
852 | |
853 d = gtk_dialog_new(); | |
854 gtk_widget_realize(d); | |
855 aol_icon(d->window); | |
856 | |
857 | |
858 label = gtk_label_new(buf2); | |
859 gtk_widget_show(label); | |
860 yesbtn = gtk_button_new_with_label("Yes"); | |
861 gtk_widget_show(yesbtn); | |
862 nobtn = gtk_button_new_with_label("No"); | |
863 gtk_widget_show(nobtn); | |
864 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->vbox), | |
865 label, FALSE, FALSE, 5); | |
866 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->action_area), | |
867 yesbtn, FALSE, FALSE, 5); | |
868 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->action_area), | |
869 nobtn, FALSE, FALSE, 5); | |
870 | |
871 | |
872 /* gtk_widget_set_usize(d, 200, 110); */ | |
252
4a41f8323022
[gaim-migrate @ 262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
249
diff
changeset
|
873 #ifndef USE_OSCAR |
1 | 874 gtk_object_set_user_data(GTK_OBJECT(d), (void *)id); |
252
4a41f8323022
[gaim-migrate @ 262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
249
diff
changeset
|
875 #else |
4a41f8323022
[gaim-migrate @ 262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
249
diff
changeset
|
876 gtk_object_set_user_data(GTK_OBJECT(d), (void *)name); |
4a41f8323022
[gaim-migrate @ 262]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
249
diff
changeset
|
877 #endif |
1 | 878 |
879 | |
880 gtk_window_set_title(GTK_WINDOW(d), "Buddy chat invite"); | |
881 gtk_signal_connect(GTK_OBJECT(nobtn), "clicked", GTK_SIGNAL_FUNC(close_invite), d); | |
882 gtk_signal_connect(GTK_OBJECT(yesbtn), "clicked", GTK_SIGNAL_FUNC(chat_invite_callback), d); | |
883 | |
884 | |
885 gtk_widget_show(d); | |
886 } | |
887 | |
888 void serv_got_joined_chat(int id, char *name) | |
889 { | |
890 struct buddy_chat *b; | |
891 | |
892 b = (struct buddy_chat *)g_new0(struct buddy_chat, 1); | |
893 buddy_chats = g_list_append(buddy_chats, b); | |
894 | |
895 b->ignored = NULL; | |
896 b->in_room = NULL; | |
897 b->id = id; | |
898 g_snprintf(b->name, 80, "%s", name); | |
899 show_new_buddy_chat(b); | |
900 } | |
901 | |
902 void serv_got_chat_left(int id) | |
903 { | |
904 GList *bcs = buddy_chats; | |
905 struct buddy_chat *b = NULL; | |
906 | |
907 | |
908 while(bcs) { | |
909 b = (struct buddy_chat *)bcs->data; | |
910 if (id == b->id) { | |
911 break; | |
912 } | |
913 b = NULL; | |
914 bcs = bcs->next; | |
915 } | |
916 | |
917 if (!b) | |
918 return; | |
919 | |
920 if (b->window) | |
921 gtk_widget_destroy(GTK_WIDGET(b->window)); | |
922 | |
923 buddy_chats = g_list_remove(buddy_chats, b); | |
924 | |
925 g_free(b); | |
926 } | |
927 | |
928 void serv_got_chat_in(int id, char *who, int whisper, char *message) | |
929 { | |
930 int w; | |
931 GList *bcs = buddy_chats; | |
932 struct buddy_chat *b = NULL; | |
933 | |
934 while(bcs) { | |
935 b = (struct buddy_chat *)bcs->data; | |
936 if (id == b->id) | |
937 break; | |
938 bcs = bcs->next; | |
939 b = NULL; | |
940 | |
941 } | |
942 if (!b) | |
943 return; | |
944 | |
945 if (whisper) | |
946 w = WFLAG_WHISPER; | |
947 else | |
948 w = 0; | |
949 | |
950 chat_write(b, who, w, message); | |
951 } | |
952 | |
260
325d9804df10
[gaim-migrate @ 270]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
258
diff
changeset
|
953 void serv_rvous_accept(char *name, char *cookie, char *uid) |
325d9804df10
[gaim-migrate @ 270]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
258
diff
changeset
|
954 { |
273
4c6c213646a3
[gaim-migrate @ 283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
270
diff
changeset
|
955 #ifndef USE_OSCAR |
260
325d9804df10
[gaim-migrate @ 270]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
258
diff
changeset
|
956 char buf[MSG_LEN]; |
325d9804df10
[gaim-migrate @ 270]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
258
diff
changeset
|
957 g_snprintf(buf, MSG_LEN, "toc_rvous_accept %s %s %s", normalize(name), |
325d9804df10
[gaim-migrate @ 270]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
258
diff
changeset
|
958 cookie, uid); |
325d9804df10
[gaim-migrate @ 270]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
258
diff
changeset
|
959 sflap_send(buf, strlen(buf), TYPE_DATA); |
325d9804df10
[gaim-migrate @ 270]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
258
diff
changeset
|
960 #endif |
325d9804df10
[gaim-migrate @ 270]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
258
diff
changeset
|
961 } |
325d9804df10
[gaim-migrate @ 270]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
258
diff
changeset
|
962 |
325d9804df10
[gaim-migrate @ 270]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
258
diff
changeset
|
963 void serv_rvous_cancel(char *name, char *cookie, char *uid) |
325d9804df10
[gaim-migrate @ 270]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
258
diff
changeset
|
964 { |
273
4c6c213646a3
[gaim-migrate @ 283]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
270
diff
changeset
|
965 #ifndef USE_OSCAR |
260
325d9804df10
[gaim-migrate @ 270]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
258
diff
changeset
|
966 char buf[MSG_LEN]; |
325d9804df10
[gaim-migrate @ 270]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
258
diff
changeset
|
967 g_snprintf(buf, MSG_LEN, "toc_rvous_cancel %s %s %s", normalize(name), |
325d9804df10
[gaim-migrate @ 270]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
258
diff
changeset
|
968 cookie, uid); |
325d9804df10
[gaim-migrate @ 270]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
258
diff
changeset
|
969 sflap_send(buf, strlen(buf), TYPE_DATA); |
325d9804df10
[gaim-migrate @ 270]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
258
diff
changeset
|
970 #endif |
325d9804df10
[gaim-migrate @ 270]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
258
diff
changeset
|
971 } |