Mercurial > pidgin
comparison src/server.c @ 1:2846a03bda67
[gaim-migrate @ 10]
The other missing files :)
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Thu, 23 Mar 2000 03:13:54 +0000 |
parents | |
children | d5119dc66284 |
comparison
equal
deleted
inserted
replaced
0:a5ace2e037bc | 1:2846a03bda67 |
---|---|
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 | |
31 #include "../libfaim/aim.h" | |
32 #endif | |
33 #include "gaim.h" | |
34 | |
35 static int idle_timer = -1; | |
36 static time_t lastsent = 0; | |
37 static time_t login_time = 0; | |
38 static struct timeval lag_tv; | |
39 static int is_idle = 0; | |
40 | |
41 int correction_time = 0; | |
42 | |
43 int serv_login(char *username, char *password) | |
44 { | |
45 #ifndef USE_OSCAR | |
46 return toc_login(username, password); | |
47 #else | |
48 return oscar_login(username, password); | |
49 #endif | |
50 } | |
51 | |
52 void serv_close() | |
53 { | |
54 #ifndef USE_OSCAR | |
55 toc_close(); | |
56 #else | |
57 oscar_close(); | |
58 #endif | |
59 gtk_timeout_remove(idle_timer); | |
60 idle_timer = -1; | |
61 } | |
62 | |
63 | |
64 void serv_touch_idle() | |
65 { | |
66 /* Are we idle? If so, not anymore */ | |
67 if (is_idle > 0) { | |
68 is_idle = 0; | |
69 serv_set_idle(0); | |
70 } | |
71 time(&lastsent); | |
72 } | |
73 | |
74 | |
75 static gint check_idle() | |
76 { | |
77 time_t t; | |
78 | |
79 /* Not idle, really... :) */ | |
80 update_all_buddies(); | |
81 | |
82 time(&t); | |
83 | |
84 gettimeofday(&lag_tv, NULL); | |
85 serv_send_im(current_user->username, LAGOMETER_STR, 1); | |
86 | |
87 if (report_idle != IDLE_GAIM) | |
88 return TRUE; | |
89 | |
90 | |
91 if (is_idle) | |
92 return TRUE; | |
93 | |
94 if ((t - lastsent) > 600) { /* 15 minutes! */ | |
95 serv_set_idle((int)t - lastsent); | |
96 is_idle = 1; | |
97 } | |
98 | |
99 | |
100 return TRUE; | |
101 | |
102 } | |
103 | |
104 | |
105 void serv_finish_login() | |
106 { | |
107 char *buf; | |
108 | |
109 if (strlen(current_user->user_info)) { | |
110 buf = g_malloc(strlen(current_user->user_info) * 2); | |
111 strcpy(buf, current_user->user_info); | |
112 escape_text(buf); | |
113 serv_set_info(buf); | |
114 g_free(buf); | |
115 } | |
116 | |
117 if (idle_timer != -1) | |
118 gtk_timeout_remove(idle_timer); | |
119 | |
120 idle_timer = gtk_timeout_add(20000, (GtkFunction)check_idle, NULL); | |
121 serv_touch_idle(); | |
122 | |
123 time(&login_time); | |
124 | |
125 serv_add_buddy(current_user->username); | |
126 | |
127 if (!(general_options & OPT_GEN_REGISTERED)) | |
128 { | |
129 show_register_dialog(); | |
130 save_prefs(); | |
131 } | |
132 } | |
133 | |
134 | |
135 | |
136 void serv_send_im(char *name, char *message, int away) | |
137 { | |
138 char buf[MSG_LEN - 7]; | |
139 #ifndef USE_OSCAR | |
140 g_snprintf(buf, MSG_LEN - 8, "toc_send_im %s \"%s\"%s", normalize(name), | |
141 message, ((away) ? " auto" : "")); | |
142 sflap_send(buf, strlen(buf), TYPE_DATA); | |
143 #else | |
144 aim_send_im(NULL, normalize(name), ((away) ? AIM_IMFLAGS_AWAY : 0), message); | |
145 #endif | |
146 if (!away) | |
147 serv_touch_idle(); | |
148 } | |
149 | |
150 void serv_get_info(char *name) | |
151 { | |
152 #ifndef USE_OSCAR | |
153 char buf[MSG_LEN]; | |
154 g_snprintf(buf, MSG_LEN, "toc_get_info %s", normalize(name)); | |
155 sflap_send(buf, -1, TYPE_DATA); | |
156 #endif | |
157 } | |
158 | |
159 void serv_get_dir(char *name) | |
160 { | |
161 #ifndef USE_OSCAR | |
162 char buf[MSG_LEN]; | |
163 g_snprintf(buf, MSG_LEN, "toc_get_dir %s", normalize(name)); | |
164 sflap_send(buf, -1, TYPE_DATA); | |
165 #endif | |
166 } | |
167 | |
168 void serv_set_dir(char *first, char *middle, char *last, char *maiden, | |
169 char *city, char *state, char *country, int web) | |
170 { | |
171 #ifndef USE_OSCAR | |
172 char buf2[BUF_LEN], buf[BUF_LEN]; | |
173 g_snprintf(buf2, sizeof(buf2), "%s:%s:%s:%s:%s:%s:%s:%s", first, | |
174 middle, last, maiden, city, state, country, | |
175 (web == 1) ? "Y" : ""); | |
176 escape_text(buf2); | |
177 g_snprintf(buf, sizeof(buf), "toc_set_dir %s", buf2); | |
178 sflap_send(buf, -1, TYPE_DATA); | |
179 #endif | |
180 } | |
181 | |
182 void serv_dir_search(char *first, char *middle, char *last, char *maiden, | |
183 char *city, char *state, char *country, char *email) | |
184 { | |
185 #ifndef USE_OSCAR | |
186 char buf[BUF_LONG]; | |
187 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); | |
188 sprintf(debug_buff,"Searching for: %s,%s,%s,%s,%s,%s,%s\n", first, middle, last, maiden, city, state, country); | |
189 debug_print(debug_buff); | |
190 sflap_send(buf, -1, TYPE_DATA); | |
191 #endif | |
192 } | |
193 | |
194 | |
195 void serv_set_away(char *message) | |
196 { | |
197 #ifndef USE_OSCAR | |
198 char buf[MSG_LEN]; | |
199 if (message) | |
200 g_snprintf(buf, MSG_LEN, "toc_set_away \"%s\"", message); | |
201 else | |
202 g_snprintf(buf, MSG_LEN, "toc_set_away"); | |
203 sflap_send(buf, -1, TYPE_DATA); | |
204 #endif | |
205 } | |
206 | |
207 void serv_set_info(char *info) | |
208 { | |
209 char buf[MSG_LEN]; | |
210 #ifndef USE_OSCAR | |
211 g_snprintf(buf, sizeof(buf), "toc_set_info \"%s\n\"", info); | |
212 sflap_send(buf, -1, TYPE_DATA); | |
213 #else | |
214 g_snprintf(buf, sizeof(buf), "%s\n", info); | |
215 aim_bos_setprofile(gaim_conn, buf); | |
216 #endif | |
217 } | |
218 | |
219 void serv_add_buddy(char *name) | |
220 { | |
221 #ifndef USE_OSCAR | |
222 char buf[1024]; | |
223 g_snprintf(buf, sizeof(buf), "toc_add_buddy %s", normalize(name)); | |
224 sflap_send(buf, -1, TYPE_DATA); | |
225 #endif | |
226 } | |
227 | |
228 void serv_add_buddies(GList *buddies) | |
229 { | |
230 char buf[MSG_LEN]; | |
231 int n, num = 0; | |
232 #ifndef USE_OSCAR | |
233 | |
234 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); | |
235 while(buddies) { | |
236 if (num == 20) { | |
237 sflap_send(buf, -1, TYPE_DATA); | |
238 n = g_snprintf(buf, sizeof(buf), "toc_add_buddy"); | |
239 num = 0; | |
240 } | |
241 ++num; | |
242 n += g_snprintf(buf + n, sizeof(buf) - n, " %s", normalize(buddies->data)); | |
243 buddies = buddies->next; | |
244 } | |
245 sflap_send(buf, -1, TYPE_DATA); | |
246 #else | |
247 while(buddies) { | |
248 if (num == 20) { | |
249 aim_bos_setbuddylist(gaim_conn, buf); | |
250 num = 0; | |
251 } | |
252 ++num; | |
253 n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", normalize(buddies->data)); | |
254 buddies = buddies->next; | |
255 } | |
256 aim_bos_setbuddylist(gaim_conn, buf); | |
257 #endif | |
258 } | |
259 | |
260 | |
261 void serv_remove_buddy(char *name) | |
262 { | |
263 #ifndef USE_OSCAR | |
264 char buf[1024]; | |
265 g_snprintf(buf, sizeof(buf), "toc_remove_buddy %s", normalize(name)); | |
266 sflap_send(buf, -1, TYPE_DATA); | |
267 #endif | |
268 } | |
269 | |
270 void serv_add_permit(char *name) | |
271 { | |
272 #ifndef USE_OSCAR | |
273 char buf[1024]; | |
274 g_snprintf(buf, sizeof(buf), "toc_add_permit %s", normalize(name)); | |
275 sflap_send(buf, -1, TYPE_DATA); | |
276 #endif | |
277 } | |
278 | |
279 | |
280 | |
281 void serv_add_deny(char *name) | |
282 { | |
283 #ifndef USE_OSCAR | |
284 char buf[1024]; | |
285 g_snprintf(buf, sizeof(buf), "toc_add_deny %s", normalize(name)); | |
286 sflap_send(buf, -1, TYPE_DATA); | |
287 #endif | |
288 } | |
289 | |
290 | |
291 | |
292 void serv_set_permit_deny() | |
293 { | |
294 #ifndef USE_OSCAR | |
295 char buf[MSG_LEN]; | |
296 int at; | |
297 GList *list; | |
298 /* FIXME! We flash here. */ | |
299 if (permdeny == 1 || permdeny == 3) { | |
300 g_snprintf(buf, sizeof(buf), "toc_add_permit"); | |
301 sflap_send(buf, -1, TYPE_DATA); | |
302 } else { | |
303 g_snprintf(buf, sizeof(buf), "toc_add_deny"); | |
304 sflap_send(buf, -1, TYPE_DATA); | |
305 } | |
306 | |
307 | |
308 at = g_snprintf(buf, sizeof(buf), "toc_add_permit"); | |
309 list = permit; | |
310 while(list) { | |
311 at += g_snprintf(&buf[at], sizeof(buf) - at, " %s", normalize(list->data)); | |
312 list = list->next; | |
313 } | |
314 buf[at] = 0; | |
315 sflap_send(buf, -1, TYPE_DATA); | |
316 | |
317 at = g_snprintf(buf, sizeof(buf), "toc_add_deny"); | |
318 list = deny; | |
319 while(list) { | |
320 at += g_snprintf(&buf[at], sizeof(buf) - at, " %s", normalize(list->data)); | |
321 list = list->next; | |
322 } | |
323 buf[at] = 0; | |
324 sflap_send(buf, -1, TYPE_DATA); | |
325 | |
326 | |
327 | |
328 #endif | |
329 } | |
330 | |
331 void serv_set_idle(int time) | |
332 { | |
333 #ifndef USE_OSCAR | |
334 char buf[256]; | |
335 g_snprintf(buf, sizeof(buf), "toc_set_idle %d", time); | |
336 sflap_send(buf, -1, TYPE_DATA); | |
337 #endif | |
338 } | |
339 | |
340 | |
341 void serv_warn(char *name, int anon) | |
342 { | |
343 #ifndef USE_OSCAR | |
344 char *send = g_malloc(256); | |
345 g_snprintf(send, 255, "toc_evil %s %s", name, | |
346 ((anon) ? "anon" : "norm")); | |
347 sflap_send(send, -1, TYPE_DATA); | |
348 g_free(send); | |
349 #endif | |
350 } | |
351 | |
352 | |
353 void serv_save_config() | |
354 { | |
355 #ifndef USE_OSCAR | |
356 char *buf = g_malloc(BUF_LONG); | |
357 char *buf2 = g_malloc(MSG_LEN); | |
358 toc_build_config(buf, BUF_LONG / 2); | |
359 g_snprintf(buf2, MSG_LEN, "toc_set_config {%s}", buf); | |
360 sflap_send(buf2, -1, TYPE_DATA); | |
361 g_free(buf2); | |
362 g_free(buf); | |
363 #else | |
364 FILE *f; | |
365 char *buf = g_malloc(BUF_LONG); | |
366 char file[1024]; | |
367 | |
368 g_snprintf(file, sizeof(file), "%s/.gaimbuddy", getenv("HOME")); | |
369 | |
370 if ((f = fopen(file,"w"))) { | |
371 build_config(buf, BUF_LONG - 1); | |
372 fprintf(f, "%s\n", buf); | |
373 fclose(f); | |
374 chmod(buf, S_IRUSR | S_IWUSR); | |
375 } else { | |
376 g_snprintf(buf, BUF_LONG / 2, "Error writing file %s", file); | |
377 do_error_dialog(buf, "Error"); | |
378 } | |
379 | |
380 g_free(buf); | |
381 | |
382 #endif | |
383 | |
384 } | |
385 | |
386 | |
387 void serv_accept_chat(int i) | |
388 { | |
389 #ifndef USE_OSCAR | |
390 char *buf = g_malloc(256); | |
391 g_snprintf(buf, 255, "toc_chat_accept %d", i); | |
392 sflap_send(buf, -1, TYPE_DATA); | |
393 g_free(buf); | |
394 #endif | |
395 } | |
396 | |
397 void serv_join_chat(int exchange, char *name) | |
398 { | |
399 #ifndef USE_OSCAR | |
400 char buf[BUF_LONG]; | |
401 g_snprintf(buf, sizeof(buf)/2, "toc_chat_join %d \"%s\"", exchange, name); | |
402 sflap_send(buf, -1, TYPE_DATA); | |
403 #endif | |
404 } | |
405 | |
406 void serv_chat_invite(int id, char *message, char *name) | |
407 { | |
408 #ifndef USE_OSCAR | |
409 char buf[BUF_LONG]; | |
410 g_snprintf(buf, sizeof(buf)/2, "toc_chat_invite %d \"%s\" %s", id, message, normalize(name)); | |
411 sflap_send(buf, -1, TYPE_DATA); | |
412 #endif | |
413 } | |
414 | |
415 void serv_chat_leave(int id) | |
416 { | |
417 #ifndef USE_OSCAR | |
418 char *buf = g_malloc(256); | |
419 g_snprintf(buf, 255, "toc_chat_leave %d", id); | |
420 sflap_send(buf, -1, TYPE_DATA); | |
421 g_free(buf); | |
422 #endif | |
423 } | |
424 | |
425 void serv_chat_whisper(int id, char *who, char *message) | |
426 { | |
427 #ifndef USE_OSCAR | |
428 char buf2[MSG_LEN]; | |
429 g_snprintf(buf2, sizeof(buf2), "toc_chat_whisper %d %s \"%s\"", id, who, message); | |
430 sflap_send(buf2, -1, TYPE_DATA); | |
431 #endif | |
432 } | |
433 | |
434 void serv_chat_send(int id, char *message) | |
435 { | |
436 #ifndef USE_OSCAR | |
437 char buf[MSG_LEN]; | |
438 g_snprintf(buf, sizeof(buf), "toc_chat_send %d \"%s\"",id, message); | |
439 sflap_send(buf, -1, TYPE_DATA); | |
440 #endif | |
441 } | |
442 | |
443 | |
444 | |
445 | |
446 void serv_got_im(char *name, char *message, int away) | |
447 { | |
448 struct conversation *cnv; | |
449 int is_idle = -1; | |
450 int new_conv = 0; | |
451 char *nname; | |
452 | |
453 nname = g_strdup(normalize(name)); | |
454 | |
455 if (!strcasecmp(normalize(name), nname)) { | |
456 if (!strcmp(message, LAGOMETER_STR)) { | |
457 struct timeval tv; | |
458 int ms; | |
459 | |
460 gettimeofday(&tv, NULL); | |
461 | |
462 ms = 1000000 * (tv.tv_sec - lag_tv.tv_sec); | |
463 | |
464 ms += tv.tv_usec - lag_tv.tv_usec; | |
465 | |
466 update_lagometer(ms); | |
467 g_free(nname); | |
468 return; | |
469 } | |
470 | |
471 } | |
472 g_free(nname); | |
473 | |
474 cnv = find_conversation(name); | |
475 | |
476 if (awaymessage != NULL) { | |
477 if (!(general_options & OPT_GEN_DISCARD_WHEN_AWAY)) { | |
478 if (cnv == NULL) { | |
479 new_conv = 1; | |
480 cnv = new_conversation(name); | |
481 } | |
482 } | |
483 if (cnv != NULL) { | |
484 if (sound_options & OPT_SOUND_WHEN_AWAY) | |
485 play_sound(AWAY); | |
486 write_to_conv(cnv, message, WFLAG_AUTO | WFLAG_RECV); | |
487 } | |
488 | |
489 } else { | |
490 if (cnv == NULL) { | |
491 new_conv = 1; | |
492 cnv = new_conversation(name); | |
493 } | |
494 if (new_conv && (sound_options & OPT_SOUND_FIRST_RCV)) { | |
495 play_sound(FIRST_RECEIVE); | |
496 } else { | |
497 if (cnv->makesound && (sound_options & OPT_SOUND_RECV)) | |
498 play_sound(RECEIVE); | |
499 } | |
500 write_to_conv(cnv, message, WFLAG_RECV); | |
501 } | |
502 | |
503 | |
504 | |
505 | |
506 if (awaymessage != NULL) { | |
507 time_t t; | |
508 | |
509 time(&t); | |
510 | |
511 | |
512 if ((cnv == NULL) || (t - cnv->sent_away) < 120) | |
513 return; | |
514 | |
515 cnv->sent_away = t; | |
516 | |
517 if (is_idle) | |
518 is_idle = -1; | |
519 | |
520 serv_send_im(name, awaymessage->message, 1); | |
521 | |
522 if (is_idle == -1) | |
523 is_idle = 1; | |
524 | |
525 if (cnv != NULL) | |
526 write_to_conv(cnv, awaymessage->message, WFLAG_SEND | WFLAG_AUTO); | |
527 } | |
528 } | |
529 | |
530 | |
531 | |
532 void serv_got_update(char *name, int loggedin, int evil, time_t signon, time_t idle, int type) | |
533 { | |
534 struct buddy *b; | |
535 char *nname; | |
536 | |
537 b = find_buddy(name); | |
538 | |
539 nname = g_strdup(normalize(name)); | |
540 if (!strcasecmp(nname, normalize(current_user->username))) { | |
541 correction_time = (int)(signon - login_time); | |
542 update_all_buddies(); | |
543 if (!b) | |
544 return; | |
545 } | |
546 | |
547 | |
548 if (!b) { | |
549 sprintf(debug_buff,"Error, no such person\n"); | |
550 debug_print(debug_buff); | |
551 return; | |
552 } | |
553 | |
554 /* This code will 'align' the name from the TOC */ | |
555 /* server with what's in our record. We want to */ | |
556 /* store things how THEY want it... */ | |
557 if (strcmp(name, b->name)) { | |
558 GList *cnv = conversations; | |
559 struct conversation *cv; | |
560 | |
561 char *who = g_malloc(80); | |
562 | |
563 strcpy(who, normalize(name)); | |
564 | |
565 while(cnv) { | |
566 cv = (struct conversation *)cnv->data; | |
567 if (!strcasecmp(who, normalize(cv->name))) { | |
568 g_snprintf(cv->name, sizeof(cv->name), "%s", name); | |
569 if (find_log_info(name) || (general_options & OPT_GEN_LOG_ALL)) | |
570 g_snprintf(who, 63, LOG_CONVERSATION_TITLE, name); | |
571 else | |
572 g_snprintf(who, 63, CONVERSATION_TITLE, name); | |
573 gtk_window_set_title(GTK_WINDOW(cv->window), who); | |
574 /* no free 'who', set_title needs it. | |
575 */ | |
576 break; | |
577 } | |
578 cnv = cnv->next; | |
579 } | |
580 g_snprintf(b->name, sizeof(b->name), "%s", name); | |
581 /*gtk_label_set_text(GTK_LABEL(b->label), b->name);*/ | |
582 | |
583 /* okay lets save the new config... */ | |
584 | |
585 } | |
586 | |
587 b->idle = idle; | |
588 b->evil = evil; | |
589 b->uc = type; | |
590 | |
591 b->signon = signon; | |
592 | |
593 if (loggedin) { | |
594 if (!b->present) { | |
595 b->present = 1; | |
596 do_pounce(b->name); | |
597 } | |
598 } else | |
599 b->present = 0; | |
600 | |
601 set_buddy(b); | |
602 } | |
603 | |
604 static | |
605 void close_warned(GtkWidget *w, GtkWidget *w2) | |
606 { | |
607 gtk_widget_destroy(w2); | |
608 } | |
609 | |
610 | |
611 | |
612 void serv_got_eviled(char *name, int lev) | |
613 { | |
614 char *buf2 = g_malloc(1024); | |
615 GtkWidget *d, *label, *close; | |
616 | |
617 | |
618 g_snprintf(buf2, 1023, "You have just been warned by %s.\nYour new warning level is %d./%%", | |
619 ((name == NULL) ? "an anonymous person" : name) , lev); | |
620 | |
621 | |
622 d = gtk_dialog_new(); | |
623 gtk_widget_realize(d); | |
624 aol_icon(d->window); | |
625 | |
626 label = gtk_label_new(buf2); | |
627 gtk_widget_show(label); | |
628 close = gtk_button_new_with_label("Close"); | |
629 gtk_widget_show(close); | |
630 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->vbox), | |
631 label, FALSE, FALSE, 5); | |
632 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->action_area), | |
633 close, FALSE, FALSE, 5); | |
634 | |
635 gtk_window_set_title(GTK_WINDOW(d), "Warned"); | |
636 gtk_signal_connect(GTK_OBJECT(close), "clicked", GTK_SIGNAL_FUNC(close_warned), d); | |
637 gtk_widget_show(d); | |
638 } | |
639 | |
640 | |
641 | |
642 static void close_invite(GtkWidget *w, GtkWidget *w2) | |
643 { | |
644 gtk_widget_destroy(w2); | |
645 } | |
646 | |
647 static void chat_invite_callback(GtkWidget *w, GtkWidget *w2) | |
648 { | |
649 int i = (int)gtk_object_get_user_data(GTK_OBJECT(w2)); | |
650 serv_accept_chat(i); | |
651 gtk_widget_destroy(w2); | |
652 } | |
653 | |
654 | |
655 | |
656 void serv_got_chat_invite(char *name, int id, char *who, char *message) | |
657 { | |
658 GtkWidget *d; | |
659 GtkWidget *label; | |
660 GtkWidget *yesbtn; | |
661 GtkWidget *nobtn; | |
662 | |
663 char buf2[BUF_LONG]; | |
664 | |
665 | |
666 g_snprintf(buf2, sizeof(buf2), "User '%s' invites you to buddy chat room: '%s'\n%s", who, name, message); | |
667 | |
668 d = gtk_dialog_new(); | |
669 gtk_widget_realize(d); | |
670 aol_icon(d->window); | |
671 | |
672 | |
673 label = gtk_label_new(buf2); | |
674 gtk_widget_show(label); | |
675 yesbtn = gtk_button_new_with_label("Yes"); | |
676 gtk_widget_show(yesbtn); | |
677 nobtn = gtk_button_new_with_label("No"); | |
678 gtk_widget_show(nobtn); | |
679 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->vbox), | |
680 label, FALSE, FALSE, 5); | |
681 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->action_area), | |
682 yesbtn, FALSE, FALSE, 5); | |
683 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->action_area), | |
684 nobtn, FALSE, FALSE, 5); | |
685 | |
686 | |
687 /* gtk_widget_set_usize(d, 200, 110); */ | |
688 gtk_object_set_user_data(GTK_OBJECT(d), (void *)id); | |
689 | |
690 | |
691 gtk_window_set_title(GTK_WINDOW(d), "Buddy chat invite"); | |
692 gtk_signal_connect(GTK_OBJECT(nobtn), "clicked", GTK_SIGNAL_FUNC(close_invite), d); | |
693 gtk_signal_connect(GTK_OBJECT(yesbtn), "clicked", GTK_SIGNAL_FUNC(chat_invite_callback), d); | |
694 | |
695 | |
696 gtk_widget_show(d); | |
697 } | |
698 | |
699 void serv_got_joined_chat(int id, char *name) | |
700 { | |
701 struct buddy_chat *b; | |
702 | |
703 b = (struct buddy_chat *)g_new0(struct buddy_chat, 1); | |
704 buddy_chats = g_list_append(buddy_chats, b); | |
705 | |
706 b->ignored = NULL; | |
707 b->in_room = NULL; | |
708 b->id = id; | |
709 g_snprintf(b->name, 80, "%s", name); | |
710 show_new_buddy_chat(b); | |
711 } | |
712 | |
713 void serv_got_chat_left(int id) | |
714 { | |
715 GList *bcs = buddy_chats; | |
716 struct buddy_chat *b = NULL; | |
717 | |
718 | |
719 while(bcs) { | |
720 b = (struct buddy_chat *)bcs->data; | |
721 if (id == b->id) { | |
722 break; | |
723 } | |
724 b = NULL; | |
725 bcs = bcs->next; | |
726 } | |
727 | |
728 if (!b) | |
729 return; | |
730 | |
731 if (b->window) | |
732 gtk_widget_destroy(GTK_WIDGET(b->window)); | |
733 | |
734 buddy_chats = g_list_remove(buddy_chats, b); | |
735 | |
736 g_free(b); | |
737 } | |
738 | |
739 void serv_got_chat_in(int id, char *who, int whisper, char *message) | |
740 { | |
741 int w; | |
742 GList *bcs = buddy_chats; | |
743 struct buddy_chat *b = NULL; | |
744 | |
745 while(bcs) { | |
746 b = (struct buddy_chat *)bcs->data; | |
747 if (id == b->id) | |
748 break; | |
749 bcs = bcs->next; | |
750 b = NULL; | |
751 | |
752 } | |
753 if (!b) | |
754 return; | |
755 | |
756 if (whisper) | |
757 w = WFLAG_WHISPER; | |
758 else | |
759 w = 0; | |
760 | |
761 chat_write(b, who, w, message); | |
762 } | |
763 | |
764 |