Mercurial > pidgin
annotate src/dialogs.c @ 123:f7a5f376f54e
[gaim-migrate @ 133]
I'm not touching this anymore, I swear.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sun, 16 Apr 2000 01:59:17 +0000 |
parents | 521db4bf5f28 |
children | fe81c8b4951d |
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 <string.h> | |
23 #include <stdio.h> | |
24 #include <stdlib.h> | |
25 #include <time.h> | |
26 #include <sys/types.h> | |
27 #include <sys/stat.h> | |
28 #include <fcntl.h> | |
29 #include <sys/socket.h> | |
30 #include <netdb.h> | |
31 #include <netinet/in.h> | |
32 #include <unistd.h> | |
33 #include <netinet/in.h> | |
34 #include <arpa/inet.h> | |
35 | |
36 #include <gtk/gtk.h> | |
37 #include "gaim.h" | |
38 #include "gtkhtml.h" | |
39 | |
40 static GtkWidget *imdialog = NULL; /*I only want ONE of these :) */ | |
41 static GList *dialogwindows = NULL; | |
42 static GtkWidget *linkdialog, *colordialog, *exportdialog, *importdialog, *logdialog; | |
43 | |
44 /*static void accept_callback(GtkWidget *widget, struct file_transfer *t);*/ | |
45 | |
46 struct create_away { | |
47 GtkWidget *window; | |
48 GtkWidget *entry; | |
49 GtkWidget *text; | |
50 GtkWidget *checkbx; | |
51 }; | |
52 | |
53 | |
54 struct warning { | |
55 GtkWidget *window; | |
56 GtkWidget *anon; | |
57 char *who; | |
58 }; | |
59 | |
60 struct addbuddy { | |
61 GtkWidget *window; | |
62 GtkWidget *combo; | |
63 GtkWidget *entry; | |
64 }; | |
65 | |
66 struct addperm { | |
67 GtkWidget *window; | |
68 GSList *buttons; | |
69 GtkWidget *entry; | |
70 }; | |
71 | |
72 struct addbp { | |
73 GtkWidget *window; | |
74 GtkWidget *nameentry; | |
75 GtkWidget *messentry; | |
76 GtkWidget *sendim; | |
77 GtkWidget *openwindow; | |
78 }; | |
79 | |
80 struct findbyemail { | |
81 GtkWidget *window; | |
82 GtkWidget *emailentry; | |
83 }; | |
84 | |
85 struct findbyinfo { | |
86 GtkWidget *window; | |
87 GtkWidget *firstentry; | |
88 GtkWidget *middleentry; | |
89 GtkWidget *lastentry; | |
90 GtkWidget *maidenentry; | |
91 GtkWidget *cityentry; | |
92 GtkWidget *stateentry; | |
93 GtkWidget *countryentry; | |
94 }; | |
95 | |
96 struct registerdlg { | |
97 GtkWidget *window; | |
98 GtkWidget *name; | |
99 GtkWidget *email; | |
100 GtkWidget *uname; | |
101 GtkWidget *sname; | |
102 GtkWidget *country; | |
103 }; | |
104 | |
105 struct info_dlg { | |
106 GtkWidget *window; | |
107 GtkWidget *text; | |
108 GtkWidget *close; | |
109 }; | |
110 | |
111 | |
112 struct set_info_dlg { | |
113 GtkWidget *window; | |
114 GtkWidget *text; | |
115 GtkWidget *save; | |
116 GtkWidget *cancel; | |
117 }; | |
118 | |
119 struct set_dir_dlg { | |
120 GtkWidget *window; | |
121 GtkWidget *first; | |
122 GtkWidget *middle; | |
123 GtkWidget *last; | |
124 GtkWidget *maiden; | |
125 GtkWidget *city; | |
126 GtkWidget *state; | |
127 GtkWidget *country; | |
128 GtkWidget *web; | |
129 GtkWidget *cancel; | |
130 GtkWidget *save; | |
131 }; | |
132 | |
133 struct linkdlg { | |
134 GtkWidget *ok; | |
135 GtkWidget *cancel; | |
136 GtkWidget *window; | |
137 GtkWidget *url; | |
138 GtkWidget *text; | |
139 GtkWidget *toggle; | |
140 GtkWidget *entry; | |
141 }; | |
142 | |
143 | |
144 /*------------------------------------------------------------------------*/ | |
145 /* Function to Send an Email */ | |
146 /*------------------------------------------------------------------------*/ | |
147 | |
148 static int g_sendemail(char *name, char *email, int uname, int sname, char *country) | |
149 { | |
150 static char email_data[2000]; | |
151 int sock; | |
152 struct hostent *host; | |
153 struct sockaddr_in site; | |
154 /* char data[3]; */ | |
155 FILE *sockfile; | |
156 char uname_output; | |
157 FILE *tmpfile; | |
158 char filename[128]; | |
159 char buf[256]; | |
160 int i=0, tmpfd=-1; | |
161 | |
162 while (i<10000 && tmpfd < 0) { | |
163 g_snprintf(filename, 128, "/tmp/gaim_%s%d.tmp", current_user->username, i++); | |
164 | |
165 tmpfd = open(filename, O_RDWR|O_CREAT|O_EXCL, 0600); | |
166 } | |
167 | |
168 if(tmpfd < 0) { | |
169 return -1; | |
170 } | |
171 | |
172 | |
173 if (uname) | |
174 { | |
175 g_snprintf(buf, sizeof(buf), "uname -a > %s", filename); | |
176 system(buf); | |
177 } | |
178 | |
179 host = gethostbyname(REG_SRVR); | |
180 if (!host) | |
181 { | |
182 printf("Error Resolving Mail Server.\n"); | |
183 return -1; | |
184 } | |
185 | |
186 site.sin_family = AF_INET; | |
187 site.sin_addr.s_addr = *(long *)(host->h_addr); | |
188 site.sin_port = htons(REG_PORT); | |
189 | |
190 sock = socket(AF_INET, SOCK_STREAM, 0); | |
191 if (sock < 0) | |
192 { | |
193 printf("Socket Error.\n"); | |
194 return -1; | |
195 } | |
196 | |
197 if (connect(sock, (struct sockaddr *)&site, sizeof(site))) | |
198 { | |
199 printf("Error Connecting to Socket.\n"); | |
200 return -1; | |
201 } | |
202 | |
203 sockfile = fdopen(sock, "r+"); | |
204 | |
205 g_snprintf(email_data, sizeof(email_data), "mail from: %s\n", REG_EMAIL_ADDR); | |
206 fputs(email_data, sockfile); | |
207 | |
208 g_snprintf(email_data, sizeof(email_data), "rcpt to: %s\n", REG_EMAIL_ADDR); | |
209 fputs(email_data, sockfile); | |
210 | |
211 g_snprintf(email_data, sizeof(email_data), "data\n"); | |
212 fputs(email_data, sockfile); | |
213 g_snprintf(email_data, sizeof(email_data), "Subject: Registration Information\n\nBelow is the submitted Registration Information\n----------------------------------\nName: %s\nEmail: %s\nCountry: %s\nSName: %s\nGAIM: v%s\nUname: ", name, email, country, sname ? current_user->username : "N/A", VERSION); | |
214 fputs(email_data, sockfile); | |
215 | |
216 if (uname) | |
217 { | |
218 tmpfile = fopen(filename, "r"); | |
219 while (!feof(tmpfile)) | |
220 { | |
221 uname_output = fgetc(tmpfile); | |
222 if (!feof(tmpfile)) | |
223 fputc(uname_output, sockfile); | |
224 } | |
225 fclose(tmpfile); | |
226 } | |
227 | |
228 unlink(filename); | |
229 | |
230 g_snprintf(email_data, sizeof(email_data), "\n.\nquit\n\n"); | |
231 fputs(email_data, sockfile); | |
232 | |
233 /* while (fgets(data, 2, sockfile)) { | |
234 } | |
235 */ | |
236 /* I don't think the above is necessary... */ | |
237 | |
238 close(sock); | |
239 | |
240 return 1; | |
241 } | |
242 | |
243 /*------------------------------------------------------------------------*/ | |
244 /* Destroys */ | |
245 /*------------------------------------------------------------------------*/ | |
246 | |
247 | |
248 static void destroy_dialog(GtkWidget *w, GtkWidget *w2) | |
249 { | |
250 GtkWidget *dest; | |
251 | |
252 if (!GTK_IS_WIDGET(w2)) | |
253 dest = w; | |
254 else | |
255 dest = w2; | |
256 | |
257 if (dest == imdialog) | |
258 imdialog = NULL; | |
259 | |
260 if (dest == exportdialog) | |
261 exportdialog = NULL; | |
262 | |
263 if (dest == importdialog) | |
264 importdialog = NULL; | |
265 | |
266 if (dest == logdialog) | |
267 logdialog = NULL; | |
268 | |
269 if (dest == colordialog) | |
270 colordialog = NULL; | |
271 | |
272 if (dest == linkdialog) | |
273 linkdialog = NULL; | |
274 | |
275 dialogwindows = g_list_remove(dialogwindows, dest); | |
276 gtk_widget_destroy(dest); | |
277 | |
278 } | |
279 | |
280 | |
281 void destroy_all_dialogs() | |
282 { | |
283 GList *d = dialogwindows; | |
284 | |
285 while(d) { | |
286 destroy_dialog(NULL, d->data); | |
287 d = d->next; | |
288 } | |
289 | |
290 g_list_free(dialogwindows); | |
291 dialogwindows = NULL; | |
292 | |
84 | 293 do_im_back(NULL, NULL); |
294 | |
1 | 295 if (imdialog) { |
296 destroy_dialog(NULL, imdialog); | |
297 imdialog = NULL; | |
298 } | |
299 | |
300 if (linkdialog) { | |
301 destroy_dialog(NULL, linkdialog); | |
302 linkdialog = NULL; | |
303 } | |
304 if (colordialog) { | |
305 destroy_dialog(NULL, colordialog); | |
306 colordialog = NULL; | |
307 } | |
308 | |
309 if (exportdialog) { | |
310 destroy_dialog(NULL, exportdialog); | |
311 exportdialog = NULL; | |
312 } | |
313 | |
314 if (importdialog) { | |
315 destroy_dialog(NULL, exportdialog); | |
316 importdialog = NULL; | |
317 } | |
318 | |
319 if (logdialog) { | |
320 destroy_dialog(NULL, logdialog); | |
321 logdialog = NULL; | |
322 } | |
323 | |
324 } | |
325 | |
326 static void do_warn(GtkWidget *widget, struct warning *w) | |
327 { | |
328 serv_warn(w->who, (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w->anon))) ? | |
329 1 : 0); | |
330 | |
331 destroy_dialog(NULL, w->window); | |
332 } | |
333 | |
334 | |
335 void show_warn_dialog(char *who) | |
336 { | |
337 GtkWidget *cancel; | |
338 GtkWidget *warn; | |
339 GtkWidget *label; | |
340 GtkWidget *vbox; | |
341 GtkWidget *bbox; | |
342 struct warning *w = g_new0(struct warning, 1); | |
343 | |
344 char *buf = g_malloc(128); | |
345 w->window = gtk_window_new(GTK_WINDOW_DIALOG); | |
346 dialogwindows = g_list_prepend(dialogwindows, w->window); | |
347 cancel = gtk_button_new_with_label("Cancel"); | |
348 warn = gtk_button_new_with_label("Warn"); | |
349 bbox = gtk_hbox_new(TRUE, 10); | |
350 vbox = gtk_vbox_new(FALSE, 5); | |
351 | |
352 /* Put the buttons in the box */ | |
353 gtk_box_pack_start(GTK_BOX(bbox), warn, TRUE, TRUE, 10); | |
354 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 10); | |
355 | |
356 g_snprintf(buf, 127, "Do you really want to warn %s?", who); | |
357 label = gtk_label_new(buf); | |
358 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); | |
359 gtk_widget_show(label); | |
360 w->anon = gtk_check_button_new_with_label("Warn anonymously?"); | |
361 gtk_box_pack_start(GTK_BOX(vbox), w->anon, TRUE, TRUE, 0); | |
362 | |
363 label = gtk_label_new("Anonymous warnings are less harsh."); | |
364 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); | |
365 gtk_widget_show(label); | |
366 | |
367 w->who = who; | |
368 | |
369 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5); | |
370 | |
371 /* Handle closes right */ | |
372 gtk_signal_connect(GTK_OBJECT(w->window), "delete_event", | |
373 GTK_SIGNAL_FUNC(destroy_dialog), w->window); | |
374 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", | |
375 GTK_SIGNAL_FUNC(destroy_dialog), w->window); | |
376 gtk_signal_connect(GTK_OBJECT(warn), "clicked", | |
377 GTK_SIGNAL_FUNC(do_warn), w); | |
378 /* Finish up */ | |
379 gtk_widget_show(warn); | |
380 gtk_widget_show(cancel); | |
381 gtk_widget_show(w->anon); | |
382 gtk_widget_show(bbox); | |
383 gtk_widget_show(vbox); | |
384 gtk_window_set_title(GTK_WINDOW(w->window), "Gaim - Warn user?"); | |
385 gtk_container_add(GTK_CONTAINER(w->window), vbox); | |
386 gtk_widget_realize(w->window); | |
387 aol_icon(w->window->window); | |
388 | |
389 gtk_widget_show(w->window); | |
25 | 390 g_free(buf); |
1 | 391 } |
392 | |
393 | |
394 /*------------------------------------------------------------------------*/ | |
395 /* The dialog for getting an error */ | |
396 /*------------------------------------------------------------------------*/ | |
397 | |
398 void | |
399 do_error_dialog(char *message, char *title) | |
400 { | |
401 GtkWidget *d; | |
402 GtkWidget *label; | |
403 GtkWidget *close; | |
404 | |
405 | |
406 d = gtk_dialog_new(); | |
407 | |
408 label = gtk_label_new(message); | |
409 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
410 gtk_widget_show(label); | |
411 close = gtk_button_new_with_label("Close"); | |
412 gtk_widget_show(close); | |
413 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->vbox), | |
414 label, FALSE, FALSE, 5); | |
415 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(d)->action_area), | |
416 close, FALSE, FALSE, 5); | |
417 | |
418 | |
419 gtk_window_set_title(GTK_WINDOW(d), title); | |
420 gtk_signal_connect(GTK_OBJECT(close), "clicked", GTK_SIGNAL_FUNC(destroy_dialog), d); | |
421 gtk_widget_realize(d); | |
422 aol_icon(d->window); | |
423 | |
424 gtk_widget_show(d); | |
425 } | |
426 | |
427 | |
428 | |
429 void show_error_dialog(char *c) | |
430 { | |
431 | |
432 int no = atoi(c); | |
433 char *w = strtok(NULL, ":"); | |
434 char buf[256]; | |
435 char buf2[32]; | |
436 | |
437 | |
438 switch(no) { | |
439 case 69: | |
440 g_snprintf(buf, sizeof(buf), "Unable to write file %s.", w); | |
441 break; | |
442 case 169: | |
443 g_snprintf(buf, sizeof(buf), "Unable to read file %s.", w); | |
444 break; | |
445 case 269: | |
446 g_snprintf(buf, sizeof(buf), "Message too long, last %s bytes truncated.", w); | |
447 break; | |
448 case 901: | |
449 g_snprintf(buf, sizeof(buf), "%s not currently logged in.", w); | |
450 break; | |
451 case 902: | |
452 g_snprintf(buf, sizeof(buf), "Warning of %s not allowed.", w); | |
453 break; | |
454 case 903: | |
455 g_snprintf(buf, sizeof(buf), "A message has been dropped, you are exceeding the server speed limit."); | |
456 break; | |
457 case 950: | |
458 g_snprintf(buf, sizeof(buf), "Chat in %s is not available.", w); | |
459 break; | |
460 case 960: | |
461 g_snprintf(buf, sizeof(buf), "You are sending messages too fast to %s.", w); | |
462 break; | |
463 case 961: | |
464 g_snprintf(buf, sizeof(buf), "You missed an IM from %s because it was too big.", w); | |
465 break; | |
466 case 962: | |
467 g_snprintf(buf, sizeof(buf), "You missed an IM from %s because it was sent too fast.", w); | |
468 break; | |
469 case 970: | |
470 g_snprintf(buf, sizeof(buf), "Failure."); | |
471 break; | |
472 case 971: | |
473 g_snprintf(buf, sizeof(buf), "Too many matches."); | |
474 break; | |
475 case 972: | |
476 g_snprintf(buf, sizeof(buf), "Need more qualifiers."); | |
477 break; | |
478 case 973: | |
479 g_snprintf(buf, sizeof(buf), "Dir service temporarily unavailable."); | |
480 break; | |
481 case 974: | |
482 g_snprintf(buf, sizeof(buf), "Email lookup restricted."); | |
483 break; | |
484 case 975: | |
485 g_snprintf(buf, sizeof(buf), "Keyword ignored."); | |
486 break; | |
487 case 976: | |
488 g_snprintf(buf, sizeof(buf), "No keywords."); | |
489 break; | |
490 case 977: | |
491 g_snprintf(buf, sizeof(buf), "User has no directory information."); | |
492 /* g_snprintf(buf, sizeof(buf), "Language not supported."); */ | |
493 break; | |
494 case 978: | |
495 g_snprintf(buf, sizeof(buf), "Country not supported."); | |
496 break; | |
497 case 979: | |
498 g_snprintf(buf, sizeof(buf), "Failure unknown: %s.", w); | |
499 break; | |
500 case 980: | |
501 g_snprintf(buf, sizeof(buf), "Incorrect nickname or password."); | |
502 break; | |
503 case 981: | |
504 g_snprintf(buf, sizeof(buf), "The service is temporarily unavailable."); | |
505 break; | |
506 case 982: | |
507 g_snprintf(buf, sizeof(buf), "Your warning level is currently too high to log in."); | |
508 break; | |
509 case 983: | |
510 g_snprintf(buf, sizeof(buf), "You have been connecting and disconnecting too frequently. Wait ten minutes and try again. If you continue to try, you will need to wait even longer."); | |
511 break; | |
512 case 989: | |
513 g_snprintf(buf, sizeof(buf), "An unknown signon error has occurred: %s.", w); | |
514 break; | |
515 default: | |
516 g_snprintf(buf, sizeof(buf), "An unknown error, %d, has occured. Info: %s", no, w); | |
517 } | |
518 | |
519 g_snprintf(buf2, sizeof(buf2), "Gaim - Error %d", no); | |
520 | |
521 | |
522 do_error_dialog(buf, buf2); | |
523 return; | |
524 } | |
525 | |
526 static void do_im(GtkWidget *widget, GtkWidget *imentry) | |
527 { | |
528 char *who; | |
529 struct conversation *c; | |
530 | |
531 who = g_strdup(normalize(gtk_entry_get_text(GTK_ENTRY(imentry)))); | |
532 | |
533 destroy_dialog(NULL, imdialog); | |
534 imdialog = NULL; | |
535 | |
536 if (!strcasecmp(who, "")) { | |
537 g_free(who); | |
538 return; | |
539 } | |
540 | |
541 c = find_conversation(who); | |
542 | |
543 if (c == NULL) { | |
544 c = new_conversation(who); | |
545 } else { | |
546 gdk_window_raise(c->window->window); | |
547 } | |
548 g_free(who); | |
549 } | |
550 | |
551 void show_ee_dialog(int ee) | |
552 { | |
553 GtkWidget *ok; | |
554 GtkWidget *label; | |
555 GtkWidget *box; | |
556 GtkWidget *eedialog; | |
557 | |
558 eedialog = gtk_window_new(GTK_WINDOW_DIALOG); | |
559 ok = gtk_button_new_with_label("OK"); | |
560 box = gtk_vbox_new(FALSE, 10); | |
561 | |
562 if (ee == 0) | |
563 label = gtk_label_new("Amazing! Simply Amazing!"); | |
564 else if (ee == 1) | |
565 label = gtk_label_new("Pimpin\' Penguin Style! *Waddle Waddle*"); | |
566 else | |
567 label = gtk_label_new("You should be me. I'm so cute!"); | |
568 | |
569 gtk_widget_show(label); | |
570 gtk_widget_show(ok); | |
571 | |
572 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 10); | |
573 gtk_box_pack_start(GTK_BOX(box), ok, FALSE, FALSE, 10); | |
574 | |
575 gtk_widget_show(box); | |
576 | |
577 gtk_container_add(GTK_CONTAINER(eedialog), box); | |
578 gtk_window_set_title(GTK_WINDOW(eedialog), "Gaim - SUPRISE!"); | |
579 | |
580 gtk_signal_connect(GTK_OBJECT(ok), "clicked", | |
581 GTK_SIGNAL_FUNC(destroy_dialog), eedialog); | |
582 gtk_widget_realize(eedialog); | |
583 aol_icon(eedialog->window); | |
584 | |
585 gtk_widget_show(eedialog); | |
586 } | |
587 | |
588 void show_im_dialog(GtkWidget *w, GtkWidget *w2) | |
589 { | |
590 GtkWidget *cancel; | |
591 GtkWidget *ok; | |
592 GtkWidget *imentry; | |
593 GtkWidget *vbox; | |
594 GtkWidget *ebox; | |
595 GtkWidget *bbox; | |
596 GtkWidget *label; | |
597 | |
598 if (!imdialog) { | |
599 | |
600 imdialog = gtk_window_new(GTK_WINDOW_DIALOG); | |
601 cancel = gtk_button_new_with_label("Cancel"); | |
602 ok = gtk_button_new_with_label("OK"); | |
603 bbox = gtk_hbox_new(TRUE, 10); | |
604 vbox = gtk_vbox_new(FALSE, 5); | |
605 ebox = gtk_hbox_new(FALSE, 2); | |
606 | |
607 /* Put the buttons in the box */ | |
608 gtk_box_pack_start(GTK_BOX(bbox), ok, TRUE, TRUE, 10); | |
609 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 10); | |
610 | |
611 label = gtk_label_new("IM who: "); | |
612 gtk_box_pack_start(GTK_BOX(ebox), label, TRUE, TRUE, 10); | |
613 gtk_widget_show(label); | |
614 | |
615 imentry = gtk_entry_new(); | |
616 gtk_box_pack_start(GTK_BOX(ebox), imentry, TRUE, TRUE, 10); | |
617 | |
618 gtk_box_pack_start(GTK_BOX(vbox), ebox, FALSE, FALSE, 5); | |
619 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5); | |
620 | |
621 /* Handle closes right */ | |
622 gtk_signal_connect(GTK_OBJECT(imentry), "activate", | |
623 GTK_SIGNAL_FUNC(do_im), imentry); | |
624 gtk_signal_connect(GTK_OBJECT(imdialog), "destroy", | |
625 GTK_SIGNAL_FUNC(destroy_dialog), imdialog); | |
626 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", | |
627 GTK_SIGNAL_FUNC(destroy_dialog), imdialog); | |
628 gtk_signal_connect(GTK_OBJECT(ok), "clicked", | |
629 GTK_SIGNAL_FUNC(do_im), imentry); | |
630 /* Finish up */ | |
631 gtk_widget_show(ok); | |
632 gtk_widget_show(cancel); | |
633 gtk_widget_show(ebox); | |
634 gtk_widget_show(imentry); | |
635 gtk_widget_show(bbox); | |
636 gtk_widget_show(vbox); | |
637 gtk_window_set_title(GTK_WINDOW(imdialog), "Gaim - IM user"); | |
638 gtk_container_add(GTK_CONTAINER(imdialog), vbox); | |
639 gtk_widget_grab_focus(imentry); | |
640 gtk_widget_realize(imdialog); | |
641 aol_icon(imdialog->window); | |
642 | |
643 } | |
644 gtk_widget_show(imdialog); | |
645 } | |
646 | |
647 | |
648 /*------------------------------------------------------------------------*/ | |
649 /* The dialog for adding buddies */ | |
650 /*------------------------------------------------------------------------*/ | |
651 | |
652 void do_add_buddy(GtkWidget *w, struct addbuddy *a) | |
653 { | |
654 char *grp, *who; | |
655 struct conversation *c; | |
656 | |
657 who = gtk_entry_get_text(GTK_ENTRY(a->entry)); | |
658 grp = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(a->combo)->entry)); | |
659 | |
660 c = find_conversation(who); | |
661 | |
662 add_buddy(grp, who); | |
663 | |
664 if (c != NULL) | |
665 gtk_label_set_text(GTK_LABEL(GTK_BIN(c->add_button)->child), "Remove"); | |
666 | |
667 build_edit_tree(); | |
668 | |
669 serv_save_config(); | |
670 | |
671 serv_add_buddy(who); | |
672 | |
673 update_num_groups(); | |
674 | |
675 destroy_dialog(NULL, a->window); | |
676 } | |
677 | |
678 | |
679 static GList *groups_tree() | |
680 { | |
681 GList *tmp=NULL; | |
682 char *tmp2; | |
683 struct group *g; | |
684 GList *grp = groups; | |
685 | |
686 if (!grp) { | |
687 tmp2 = g_strdup("Buddies"); | |
688 tmp = g_list_append(tmp, tmp2); | |
689 } else { | |
690 while(grp) { | |
691 g = (struct group *)grp->data; | |
692 tmp2 = g->name; | |
693 tmp=g_list_append(tmp, tmp2); | |
694 grp = grp->next; | |
695 } | |
696 } | |
697 return tmp; | |
698 } | |
699 | |
700 | |
701 void show_add_buddy(char *buddy, char *group) | |
702 { | |
703 GtkWidget *cancel; | |
704 GtkWidget *add; | |
705 GtkWidget *label; | |
706 GtkWidget *bbox; | |
707 GtkWidget *vbox; | |
708 GtkWidget *topbox; | |
709 struct addbuddy *a = g_new0(struct addbuddy, 1); | |
710 | |
711 a->window = gtk_window_new(GTK_WINDOW_DIALOG); | |
712 dialogwindows = g_list_prepend(dialogwindows, a->window); | |
713 cancel = gtk_button_new_with_label("Cancel"); | |
714 add = gtk_button_new_with_label("Add"); | |
715 bbox = gtk_hbox_new(TRUE, 10); | |
716 topbox = gtk_hbox_new(FALSE, 5); | |
717 vbox = gtk_vbox_new(FALSE, 5); | |
718 a->entry = gtk_entry_new(); | |
719 a->combo = gtk_combo_new(); | |
720 /* Fix the combo box */ | |
721 gtk_combo_set_popdown_strings(GTK_COMBO(a->combo), groups_tree()); | |
722 /* Put the buttons in the box */ | |
723 gtk_box_pack_start(GTK_BOX(bbox), add, TRUE, TRUE, 10); | |
724 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 10); | |
725 | |
726 label = gtk_label_new("Add"); | |
727 gtk_widget_show(label); | |
728 gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5); | |
729 gtk_box_pack_start(GTK_BOX(topbox), a->entry, FALSE, FALSE, 5); | |
730 if (buddy != NULL) | |
731 gtk_entry_set_text(GTK_ENTRY(a->entry), buddy); | |
732 | |
733 label = gtk_label_new("to group"); | |
734 gtk_widget_show(label); | |
735 gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5); | |
736 gtk_box_pack_start(GTK_BOX(topbox), a->combo, FALSE, FALSE, 5); | |
737 | |
738 if (group != NULL) | |
739 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(a->combo)->entry), group); | |
740 | |
741 /* And the boxes in the box */ | |
742 gtk_box_pack_start(GTK_BOX(vbox), topbox, TRUE, TRUE, 5); | |
743 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5); | |
744 | |
745 /* Handle closes right */ | |
746 gtk_signal_connect(GTK_OBJECT(a->window), "destroy", | |
747 GTK_SIGNAL_FUNC(destroy_dialog), a->window); | |
748 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", | |
749 GTK_SIGNAL_FUNC(destroy_dialog), a->window); | |
750 gtk_signal_connect(GTK_OBJECT(add), "clicked", | |
751 GTK_SIGNAL_FUNC(do_add_buddy), a); | |
752 gtk_signal_connect(GTK_OBJECT(a->entry), "activate", | |
753 GTK_SIGNAL_FUNC(do_add_buddy), a); | |
754 /* Finish up */ | |
755 gtk_widget_show(add); | |
756 gtk_widget_show(cancel); | |
757 gtk_widget_show(a->combo); | |
758 gtk_widget_show(a->entry); | |
759 gtk_widget_show(topbox); | |
760 gtk_widget_show(bbox); | |
761 gtk_widget_show(vbox); | |
762 gtk_window_set_title(GTK_WINDOW(a->window), "Gaim - Add Buddy"); | |
763 gtk_window_set_focus(GTK_WINDOW(a->window), a->entry); | |
764 gtk_container_add(GTK_CONTAINER(a->window), vbox); | |
765 gtk_widget_realize(a->window); | |
766 aol_icon(a->window->window); | |
767 | |
768 gtk_widget_show(a->window); | |
769 } | |
770 | |
771 | |
772 /*------------------------------------------------------------------------*/ | |
773 /* The dialog for new buddy pounces */ | |
774 /*------------------------------------------------------------------------*/ | |
775 | |
776 | |
777 void do_new_bp(GtkWidget *w, struct addbp *b) | |
778 { | |
779 struct buddy_pounce *bp = g_new0(struct buddy_pounce, 1); | |
780 | |
26 | 781 g_snprintf(bp->name, 80, "%s", gtk_entry_get_text(GTK_ENTRY(b->nameentry))); |
782 g_snprintf(bp->message, 2048, "%s", gtk_entry_get_text(GTK_ENTRY(b->messentry))); | |
783 | |
1 | 784 if (GTK_TOGGLE_BUTTON(b->openwindow)->active) |
785 bp->popup = 1; | |
786 else | |
787 bp->popup = 0; | |
788 | |
789 if (GTK_TOGGLE_BUTTON(b->sendim)->active) | |
790 bp->sendim = 1; | |
791 else | |
792 bp->sendim = 0; | |
26 | 793 |
1 | 794 buddy_pounces = g_list_append(buddy_pounces, bp); |
795 | |
796 do_bp_menu(); | |
797 | |
798 destroy_dialog(NULL, b->window); | |
799 g_free(b); | |
800 } | |
801 | |
802 | |
803 void show_new_bp(char *name) | |
804 { | |
805 GtkWidget *cancel; | |
806 GtkWidget *ok; | |
807 GtkWidget *label; | |
808 GtkWidget *bbox; | |
809 GtkWidget *vbox; | |
810 | |
811 struct addbp *b = g_new0(struct addbp, 1); | |
812 | |
813 b->window = gtk_window_new(GTK_WINDOW_DIALOG); | |
814 dialogwindows = g_list_prepend(dialogwindows, b->window); | |
815 cancel = gtk_button_new_with_label("Cancel"); | |
816 ok = gtk_button_new_with_label("OK"); | |
817 bbox = gtk_hbox_new(TRUE, 10); | |
818 vbox = gtk_vbox_new(FALSE, 5); | |
819 b->nameentry = gtk_entry_new(); | |
820 b->messentry = gtk_entry_new(); | |
821 | |
822 /* Put the buttons in the box */ | |
823 gtk_box_pack_start(GTK_BOX(bbox), ok, TRUE, TRUE, 10); | |
824 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 10); | |
825 | |
826 label = gtk_label_new("Buddy To Pounce:"); | |
827 gtk_widget_show(label); | |
828 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
829 gtk_box_pack_start(GTK_BOX(vbox), b->nameentry, FALSE, FALSE, 0); | |
830 | |
831 b->openwindow = gtk_check_button_new_with_label("Open IM Window on Buddy Logon"); | |
832 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->openwindow), FALSE); | |
833 | |
834 b->sendim = gtk_check_button_new_with_label("Send IM on Buddy Logon"); | |
835 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->sendim), TRUE); | |
836 | |
837 gtk_widget_show(b->openwindow); | |
838 gtk_widget_show(b->sendim); | |
839 gtk_box_pack_start(GTK_BOX(vbox), b->openwindow, FALSE, FALSE, 0); | |
840 gtk_box_pack_start(GTK_BOX(vbox), b->sendim, FALSE, FALSE, 0); | |
841 | |
842 label = gtk_label_new("Message to send:"); | |
843 gtk_widget_show(label); | |
844 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
845 gtk_box_pack_start(GTK_BOX(vbox), b->messentry, FALSE, FALSE, 0); | |
846 | |
847 | |
848 /* And the boxes in the box */ | |
849 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
850 | |
851 /* Handle closes right */ | |
852 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", | |
853 GTK_SIGNAL_FUNC(destroy_dialog), b->window); | |
854 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", | |
855 GTK_SIGNAL_FUNC(destroy_dialog), b->window); | |
856 gtk_signal_connect(GTK_OBJECT(ok), "clicked", | |
857 GTK_SIGNAL_FUNC(do_new_bp), b); | |
858 gtk_signal_connect(GTK_OBJECT(b->messentry), "activate", | |
859 GTK_SIGNAL_FUNC(do_new_bp), b); | |
860 | |
861 | |
862 /* Finish up */ | |
863 gtk_widget_show(ok); | |
864 gtk_widget_show(cancel); | |
865 gtk_widget_show(b->nameentry); | |
866 gtk_widget_show(b->messentry); | |
867 gtk_widget_show(bbox); | |
868 gtk_widget_show(vbox); | |
869 gtk_window_set_title(GTK_WINDOW(b->window), "Gaim - New Buddy Pounce"); | |
870 if (name != NULL) { | |
871 gtk_entry_set_text(GTK_ENTRY(b->nameentry), name); | |
872 gtk_window_set_focus(GTK_WINDOW(b->window), b->messentry); | |
873 } else | |
874 gtk_window_set_focus(GTK_WINDOW(b->window), b->nameentry); | |
875 gtk_container_add(GTK_CONTAINER(b->window), vbox); | |
876 gtk_container_border_width(GTK_CONTAINER(b->window), 10); | |
877 gtk_widget_realize(b->window); | |
878 aol_icon(b->window->window); | |
879 | |
880 gtk_widget_show(b->window); | |
881 } | |
882 | |
883 | |
884 | |
885 /*------------------------------------------------------------------------*/ | |
886 /* The dialog for SET INFO / SET DIR INFO */ | |
887 /*------------------------------------------------------------------------*/ | |
888 | |
889 void do_save_info(GtkWidget *widget, struct set_info_dlg *b) | |
890 { | |
891 gchar *junk; | |
892 char *buf; | |
893 | |
894 junk = gtk_editable_get_chars(GTK_EDITABLE(b->text), 0, -1); | |
895 | |
896 g_snprintf(current_user->user_info, sizeof(current_user->user_info), "%s", junk); | |
25 | 897 |
1 | 898 save_prefs(); |
899 | |
79 | 900 buf = g_malloc(strlen(current_user->user_info) * 4); |
122
521db4bf5f28
[gaim-migrate @ 132]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
84
diff
changeset
|
901 if (!buf) { |
521db4bf5f28
[gaim-migrate @ 132]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
84
diff
changeset
|
902 buf = g_malloc(1); |
521db4bf5f28
[gaim-migrate @ 132]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
84
diff
changeset
|
903 buf[0] = 0; |
521db4bf5f28
[gaim-migrate @ 132]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
84
diff
changeset
|
904 } |
1 | 905 g_snprintf(buf, strlen(current_user->user_info) * 2, "%s", current_user->user_info); |
906 escape_text(buf); | |
907 serv_set_info(buf); | |
908 g_free(buf); | |
25 | 909 g_free(junk); |
1 | 910 destroy_dialog(NULL, b->window); |
911 g_free(b); | |
912 } | |
913 | |
914 void do_set_dir(GtkWidget *widget, struct set_dir_dlg *b) | |
915 { | |
916 char *first = gtk_entry_get_text(GTK_ENTRY(b->first)); | |
917 int web = GTK_TOGGLE_BUTTON(b->web)->active; | |
918 char *middle = gtk_entry_get_text(GTK_ENTRY(b->middle)); | |
919 char *last = gtk_entry_get_text(GTK_ENTRY(b->last)); | |
920 char *maiden = gtk_entry_get_text(GTK_ENTRY(b->maiden)); | |
921 char *city = gtk_entry_get_text(GTK_ENTRY(b->city)); | |
922 char *state = gtk_entry_get_text(GTK_ENTRY(b->state)); | |
923 char *country = gtk_entry_get_text(GTK_ENTRY(b->country)); | |
924 | |
925 | |
926 serv_set_dir(first, middle, last, maiden, city, state, country, web); | |
927 | |
928 destroy_dialog(NULL, b->window); | |
929 g_free(b); | |
930 } | |
931 | |
932 void show_set_dir() | |
933 { | |
934 GtkWidget *label; | |
935 GtkWidget *bot; | |
936 GtkWidget *top; | |
937 GtkWidget *table; | |
938 | |
939 struct set_dir_dlg *b = g_new0(struct set_dir_dlg, 1); | |
940 | |
941 b->window = gtk_window_new(GTK_WINDOW_DIALOG); | |
942 dialogwindows = g_list_prepend(dialogwindows, b->window); | |
943 | |
944 b->cancel = gtk_button_new_with_label("Cancel"); | |
945 b->save = gtk_button_new_with_label("Save"); | |
946 | |
947 bot = gtk_hbox_new(TRUE, 10); | |
948 top = gtk_vbox_new(FALSE, 10); | |
949 | |
950 gtk_widget_show(b->save); | |
951 gtk_widget_show(b->cancel); | |
952 | |
953 gtk_box_pack_start(GTK_BOX(bot), b->save, FALSE, FALSE, 5); | |
954 gtk_box_pack_start(GTK_BOX(bot), b->cancel, FALSE, FALSE, 5); | |
955 | |
956 gtk_widget_show(bot); | |
957 | |
958 table = gtk_table_new(10, 2, FALSE); | |
959 | |
960 b->first = gtk_entry_new(); | |
961 b->middle = gtk_entry_new(); | |
962 b->last = gtk_entry_new(); | |
963 b->maiden = gtk_entry_new(); | |
964 b->city = gtk_entry_new(); | |
965 b->state = gtk_entry_new(); | |
966 b->country = gtk_entry_new(); | |
967 b->web = gtk_check_button_new_with_label("Allow Web Searches To Find Your Info"); | |
968 | |
969 label = gtk_label_new("First Name"); | |
970 gtk_widget_show(label); | |
971 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
972 gtk_table_attach_defaults(GTK_TABLE(table), b->first, 1, 2, 0, 1); | |
973 | |
974 label = gtk_label_new("Middle Name"); | |
975 gtk_widget_show(label); | |
976 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
977 gtk_table_attach_defaults(GTK_TABLE(table), b->middle, 1, 2, 1, 2); | |
978 | |
979 label = gtk_label_new("Last Name"); | |
980 gtk_widget_show(label); | |
981 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3); | |
982 gtk_table_attach_defaults(GTK_TABLE(table), b->last, 1, 2, 2, 3); | |
983 | |
984 label = gtk_label_new("Maiden Name"); | |
985 gtk_widget_show(label); | |
986 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4); | |
987 gtk_table_attach_defaults(GTK_TABLE(table), b->maiden, 1, 2, 3, 4); | |
988 | |
989 label = gtk_label_new("City"); | |
990 gtk_widget_show(label); | |
991 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 4, 5); | |
992 gtk_table_attach_defaults(GTK_TABLE(table), b->city, 1, 2, 4, 5); | |
993 | |
994 label = gtk_label_new("State"); | |
995 gtk_widget_show(label); | |
996 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 5, 6); | |
997 gtk_table_attach_defaults(GTK_TABLE(table), b->state, 1, 2, 5, 6); | |
998 | |
999 label = gtk_label_new("Country"); | |
1000 gtk_widget_show(label); | |
1001 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 6, 7); | |
1002 gtk_table_attach_defaults(GTK_TABLE(table), b->country, 1, 2, 6, 7); | |
1003 | |
1004 gtk_table_attach_defaults(GTK_TABLE(table), b->web, 0, 2, 8, 9); | |
1005 | |
1006 gtk_widget_show(table); | |
1007 gtk_box_pack_start(GTK_BOX(top), table, FALSE, FALSE, 5); | |
1008 gtk_box_pack_start(GTK_BOX(top), bot, FALSE, FALSE, 5); | |
1009 | |
1010 gtk_widget_show(b->first); | |
1011 gtk_widget_show(b->middle); | |
1012 gtk_widget_show(b->last); | |
1013 gtk_widget_show(b->maiden); | |
1014 gtk_widget_show(b->city); | |
1015 gtk_widget_show(b->state); | |
1016 gtk_widget_show(b->country); | |
1017 gtk_widget_show(b->web); | |
1018 | |
1019 gtk_widget_show(top); | |
1020 | |
1021 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", | |
1022 GTK_SIGNAL_FUNC(destroy_dialog), b->window); | |
1023 gtk_signal_connect(GTK_OBJECT(b->cancel), "clicked", | |
1024 GTK_SIGNAL_FUNC(destroy_dialog), b->window); | |
1025 gtk_signal_connect(GTK_OBJECT(b->save), "clicked", GTK_SIGNAL_FUNC(do_set_dir), b); | |
1026 | |
1027 gtk_container_add(GTK_CONTAINER(b->window), top); | |
1028 gtk_container_border_width(GTK_CONTAINER(b->window), 10); | |
1029 gtk_widget_set_usize(b->window, 530, 280); | |
1030 gtk_window_set_title(GTK_WINDOW(b->window), "Gaim - Set Dir Info"); | |
1031 gtk_window_set_focus(GTK_WINDOW(b->window), b->first); | |
1032 gtk_widget_realize(b->window); | |
1033 aol_icon(b->window->window); | |
1034 | |
1035 gtk_widget_show(b->window); | |
1036 } | |
1037 | |
1038 void show_set_info() | |
1039 { | |
1040 GtkWidget *bot; | |
1041 GtkWidget *top; | |
1042 | |
1043 struct set_info_dlg *b = g_new0(struct set_info_dlg, 1); | |
1044 | |
1045 b->window = gtk_window_new(GTK_WINDOW_DIALOG); | |
1046 dialogwindows = g_list_prepend(dialogwindows, b->window); | |
1047 | |
1048 b->cancel = gtk_button_new_with_label("Cancel"); | |
1049 b->save = gtk_button_new_with_label("Save"); | |
1050 | |
1051 bot = gtk_hbox_new(TRUE, 10); | |
1052 top = gtk_vbox_new(FALSE, 10); | |
1053 | |
1054 gtk_widget_show(b->save); | |
1055 gtk_widget_show(b->cancel); | |
1056 | |
1057 gtk_box_pack_start(GTK_BOX(bot), b->save, FALSE, FALSE, 10); | |
1058 gtk_box_pack_start(GTK_BOX(bot), b->cancel, FALSE, FALSE, 10); | |
1059 | |
1060 | |
1061 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", | |
1062 GTK_SIGNAL_FUNC(destroy_dialog), b->window); | |
1063 gtk_signal_connect(GTK_OBJECT(b->cancel), "clicked", | |
1064 GTK_SIGNAL_FUNC(destroy_dialog), b->window); | |
1065 gtk_signal_connect(GTK_OBJECT(b->save), "clicked", | |
1066 GTK_SIGNAL_FUNC(do_save_info), b); | |
1067 | |
1068 gtk_widget_show(bot); | |
1069 | |
1070 | |
1071 b->text = gtk_text_new(NULL, NULL); | |
1072 gtk_text_set_word_wrap(GTK_TEXT(b->text), TRUE); | |
1073 gtk_text_set_editable(GTK_TEXT(b->text), TRUE); | |
1074 gtk_widget_set_usize(b->text, 350, 100); | |
1075 gtk_text_insert(GTK_TEXT(b->text), NULL, NULL, NULL, current_user->user_info, -1); | |
1076 | |
1077 gtk_widget_show(b->text); | |
1078 | |
1079 gtk_box_pack_start(GTK_BOX(top), b->text, TRUE, TRUE, 10); | |
1080 gtk_widget_show(top); | |
1081 | |
1082 gtk_box_pack_start(GTK_BOX(top), bot, FALSE, FALSE, 10); | |
1083 gtk_container_add(GTK_CONTAINER(b->window), top); | |
1084 gtk_container_border_width(GTK_CONTAINER(b->window), 10); | |
1085 gtk_widget_realize(b->window); | |
1086 aol_icon(b->window->window); | |
1087 | |
1088 gtk_window_set_title(GTK_WINDOW(b->window), "Gaim - Set User Info"); | |
1089 gtk_widget_show(b->window); | |
1090 | |
1091 } | |
1092 | |
1093 /*------------------------------------------------------------------------*/ | |
1094 /* The dialog for registration information */ | |
1095 /*------------------------------------------------------------------------*/ | |
1096 | |
1097 void do_register_dialog(GtkWidget *widget, struct registerdlg *b) | |
1098 { | |
1099 char *email = gtk_entry_get_text(GTK_ENTRY(b->email)); | |
1100 char *name = gtk_entry_get_text(GTK_ENTRY(b->name)); | |
1101 int uname = GTK_TOGGLE_BUTTON(b->uname)->active; | |
1102 int sname = GTK_TOGGLE_BUTTON(b->sname)->active; | |
1103 char *country = gtk_entry_get_text(GTK_ENTRY(b->country)); | |
1104 | |
1105 general_options |= OPT_GEN_REGISTERED; | |
1106 save_prefs(); | |
1107 | |
1108 destroy_dialog(NULL, b->window); | |
1109 | |
1110 g_free(b); | |
1111 | |
1112 g_sendemail(name, email, uname, sname, country); | |
1113 } | |
1114 | |
1115 void set_reg_flag(GtkWidget *widget, struct registerdlg *b) | |
1116 { | |
1117 general_options |= OPT_GEN_REGISTERED; | |
1118 save_prefs(); | |
1119 destroy_dialog(NULL, b->window); | |
1120 g_free(b); | |
1121 } | |
1122 | |
1123 void show_register_dialog() | |
1124 { | |
1125 GtkWidget *ok; | |
1126 GtkWidget *cancel; | |
1127 GtkWidget *label; | |
1128 GtkWidget *table; | |
1129 GtkWidget *vbox; | |
1130 GtkWidget *bbox; | |
1131 | |
1132 struct registerdlg *b = g_new0(struct registerdlg, 1); | |
1133 b->window = gtk_window_new(GTK_WINDOW_DIALOG); | |
1134 dialogwindows = g_list_prepend(dialogwindows, b->window); | |
1135 | |
1136 cancel = gtk_button_new_with_label("Cancel"); | |
1137 ok = gtk_button_new_with_label("Send"); | |
1138 | |
1139 bbox = gtk_hbox_new(TRUE, 10); | |
1140 table = gtk_table_new(6, 2, TRUE); | |
1141 vbox = gtk_vbox_new(FALSE, 5); | |
1142 | |
1143 b->name = gtk_entry_new(); | |
1144 b->email = gtk_entry_new(); | |
1145 b->uname = gtk_check_button_new_with_label("Send the output of uname -a with registration"); | |
1146 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->uname), TRUE); | |
1147 b->sname = gtk_check_button_new_with_label("Send my screenname with registration"); | |
1148 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->sname), TRUE); | |
1149 gtk_box_pack_start(GTK_BOX(bbox), ok, TRUE, TRUE, 10); | |
1150 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 10); | |
1151 | |
1152 label = gtk_label_new("This list will not, in any way, be distributed and\nwill be used for internal census purposes only.\nAll fields are completely optional."); | |
1153 gtk_widget_show(label); | |
1154 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 2, 0, 1); | |
1155 | |
1156 label = gtk_label_new("Name"); | |
1157 gtk_widget_show(label); | |
1158 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
1159 gtk_table_attach_defaults(GTK_TABLE(table), b->name, 1, 2, 1, 2); | |
1160 | |
1161 label = gtk_label_new("Email"); | |
1162 gtk_widget_show(label); | |
1163 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3); | |
1164 gtk_table_attach_defaults(GTK_TABLE(table), b->email, 1, 2, 2, 3); | |
1165 | |
1166 label = gtk_label_new("Country"); | |
1167 b->country = gtk_entry_new(); | |
1168 gtk_widget_show(label); | |
1169 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4); | |
1170 gtk_table_attach_defaults(GTK_TABLE(table), b->country, 1, 2, 3, 4); | |
1171 | |
1172 gtk_table_attach_defaults(GTK_TABLE(table), b->sname, 0, 2, 4, 5); | |
1173 gtk_table_attach_defaults(GTK_TABLE(table), b->uname, 0, 2, 5, 6); | |
1174 | |
1175 gtk_box_pack_start(GTK_BOX(vbox), table, TRUE, TRUE, 5); | |
1176 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5); | |
1177 | |
1178 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", | |
1179 GTK_SIGNAL_FUNC(destroy_dialog), b->window); | |
1180 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", | |
1181 GTK_SIGNAL_FUNC(set_reg_flag), b); | |
1182 gtk_signal_connect(GTK_OBJECT(ok), "clicked", | |
1183 GTK_SIGNAL_FUNC(do_register_dialog), b); | |
1184 | |
1185 gtk_widget_show(ok); | |
1186 gtk_widget_show(cancel); | |
1187 gtk_widget_show(b->name); | |
1188 gtk_widget_show(b->email); | |
1189 gtk_widget_show(b->uname); | |
1190 gtk_widget_show(b->sname); | |
1191 gtk_widget_show(b->country); | |
1192 gtk_widget_show(table); | |
1193 gtk_widget_show(bbox); | |
1194 gtk_widget_show(vbox); | |
1195 gtk_window_set_title(GTK_WINDOW(b->window), "Gaim - Registration"); | |
1196 gtk_window_set_focus(GTK_WINDOW(b->window), b->name); | |
1197 gtk_container_add(GTK_CONTAINER(b->window), vbox); | |
1198 gtk_container_border_width(GTK_CONTAINER(b->window), 10); | |
1199 gtk_widget_realize(b->window); | |
1200 aol_icon(b->window->window); | |
1201 | |
1202 gtk_widget_show(b->window); | |
1203 } | |
1204 | |
1205 | |
1206 /*------------------------------------------------------------------------*/ | |
1207 /* The dialog for the info requests */ | |
1208 /*------------------------------------------------------------------------*/ | |
1209 | |
1210 void g_show_info(char *url) | |
1211 { | |
1212 GtkWidget *ok; | |
1213 GtkWidget *label; | |
1214 GtkWidget *text; | |
1215 GtkWidget *bbox; | |
1216 GtkWidget *sw; | |
1217 char *url_text; | |
1218 | |
1219 struct info_dlg *b = g_new0(struct info_dlg, 1); | |
1220 | |
1221 b->window = gtk_window_new(GTK_WINDOW_DIALOG); | |
1222 dialogwindows = g_list_prepend(dialogwindows, b->window); | |
1223 gtk_container_border_width(GTK_CONTAINER(b->window), 5); | |
1224 bbox = gtk_vbox_new(FALSE, 5); | |
1225 gtk_container_add(GTK_CONTAINER(b->window), bbox); | |
1226 | |
1227 ok = gtk_button_new_with_label("OK"); | |
1228 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", | |
1229 GTK_SIGNAL_FUNC(destroy_dialog), b->window); | |
1230 gtk_signal_connect(GTK_OBJECT(ok), "clicked", | |
1231 GTK_SIGNAL_FUNC(destroy_dialog), b->window); | |
1232 | |
1233 label = gtk_label_new("Below are the results of your search: "); | |
1234 | |
1235 sw = gtk_scrolled_window_new (NULL, NULL); | |
1236 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), | |
1237 GTK_POLICY_NEVER, | |
1238 GTK_POLICY_ALWAYS); | |
1239 text = gtk_html_new(NULL, NULL); | |
1240 b->text = text; | |
1241 gtk_container_add(GTK_CONTAINER(sw), text); | |
1242 | |
1243 GTK_HTML (text)->hadj->step_increment = 10.0; | |
1244 GTK_HTML (text)->vadj->step_increment = 10.0; | |
1245 gtk_widget_set_usize(sw, 300, 250); | |
1246 | |
1247 gtk_box_pack_start(GTK_BOX(bbox), label, FALSE, FALSE, 0); | |
1248 gtk_box_pack_start(GTK_BOX(bbox), sw, TRUE, TRUE, 0); | |
1249 gtk_box_pack_start(GTK_BOX(bbox), ok, FALSE, FALSE, 0); | |
1250 | |
1251 gtk_widget_realize(b->window); | |
1252 aol_icon(b->window->window); | |
1253 gtk_widget_show_all(b->window); | |
1254 | |
1255 url_text = grab_url(url); | |
1256 gtk_html_append_text(GTK_HTML(b->text), url_text, 0); | |
1257 g_free(url_text); | |
1258 } | |
1259 | |
1260 /*------------------------------------------------------------------------*/ | |
1261 /* The dialog for adding to permit/deny */ | |
1262 /*------------------------------------------------------------------------*/ | |
1263 | |
1264 | |
1265 static void do_add_perm(GtkWidget *w, struct addperm *p) | |
1266 { | |
1267 | |
1268 char *who; | |
1269 char *name; | |
1270 int d = 0; | |
1271 GSList *buttons = p->buttons; | |
1272 | |
1273 | |
1274 who = gtk_entry_get_text(GTK_ENTRY(p->entry)); | |
1275 | |
1276 name = g_malloc(strlen(who) + 2); | |
1277 g_snprintf(name, strlen(who) + 2, "%s", who); | |
1278 | |
1279 while(buttons) { | |
1280 if((int)gtk_object_get_user_data(GTK_OBJECT(buttons->data)) == 1) { | |
1281 if (GTK_TOGGLE_BUTTON(buttons->data)->active) | |
1282 d = 1; | |
1283 } | |
1284 buttons = buttons->next; | |
1285 } | |
1286 | |
1287 if (d) { | |
1288 deny = g_list_append(deny, name); | |
1289 serv_add_deny(name); | |
1290 } else { | |
1291 permit = g_list_append(permit, name); | |
1292 serv_add_permit(name); | |
1293 } | |
1294 | |
1295 | |
1296 | |
1297 build_permit_tree(); | |
1298 | |
1299 serv_save_config(); | |
1300 | |
1301 destroy_dialog(NULL, p->window); | |
1302 } | |
1303 | |
1304 | |
1305 | |
1306 void show_add_perm(char *who) | |
1307 { | |
1308 GtkWidget *cancel; | |
1309 GtkWidget *add; | |
1310 GtkWidget *label; | |
1311 GtkWidget *bbox; | |
1312 GtkWidget *vbox; | |
1313 GtkWidget *rbox; | |
1314 GtkWidget *topbox; | |
1315 GtkWidget *which; | |
1316 struct addperm *p = g_new0(struct addperm, 1); | |
1317 | |
1318 p->window = gtk_window_new(GTK_WINDOW_DIALOG); | |
1319 dialogwindows = g_list_prepend(dialogwindows, p->window); | |
1320 cancel = gtk_button_new_with_label("Cancel"); | |
1321 add = gtk_button_new_with_label("Add"); | |
1322 bbox = gtk_hbox_new(TRUE, 10); | |
1323 topbox = gtk_hbox_new(FALSE, 5); | |
1324 vbox = gtk_vbox_new(FALSE, 5); | |
1325 rbox = gtk_vbox_new(FALSE, 5); | |
1326 p->entry = gtk_entry_new(); | |
1327 | |
1328 if (who != NULL) | |
1329 gtk_entry_set_text(GTK_ENTRY(p->entry), who); | |
1330 | |
1331 which = gtk_radio_button_new_with_label(NULL, "Deny"); | |
1332 gtk_box_pack_start(GTK_BOX(rbox), which, FALSE, FALSE, 0); | |
1333 gtk_object_set_user_data(GTK_OBJECT(which), (int *)1); | |
1334 gtk_widget_show(which); | |
1335 | |
1336 which = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(which)), "Permit"); | |
1337 gtk_box_pack_start(GTK_BOX(rbox), which, FALSE, FALSE, 0); | |
1338 gtk_object_set_user_data(GTK_OBJECT(which), (int *)2); | |
1339 gtk_widget_show(which); | |
1340 | |
1341 /* Put the buttons in the box */ | |
1342 gtk_box_pack_start(GTK_BOX(bbox), add, TRUE, TRUE, 10); | |
1343 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 10); | |
1344 | |
1345 label = gtk_label_new("Add"); | |
1346 gtk_widget_show(label); | |
1347 gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5); | |
1348 gtk_box_pack_start(GTK_BOX(topbox), p->entry, FALSE, FALSE, 5); | |
1349 gtk_box_pack_start(GTK_BOX(topbox), rbox, FALSE, FALSE, 5); | |
1350 /* And the boxes in the box */ | |
1351 gtk_box_pack_start(GTK_BOX(vbox), topbox, TRUE, TRUE, 5); | |
1352 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5); | |
1353 | |
1354 | |
1355 p->buttons = gtk_radio_button_group(GTK_RADIO_BUTTON(which)); | |
1356 /* Handle closes right */ | |
1357 gtk_signal_connect(GTK_OBJECT(p->window), "destroy", | |
1358 GTK_SIGNAL_FUNC(destroy_dialog), p->window); | |
1359 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", | |
1360 GTK_SIGNAL_FUNC(destroy_dialog), p->window); | |
1361 gtk_signal_connect(GTK_OBJECT(add), "clicked", | |
1362 GTK_SIGNAL_FUNC(do_add_perm), p); | |
1363 gtk_signal_connect(GTK_OBJECT(p->entry), "activate", | |
1364 GTK_SIGNAL_FUNC(do_add_perm), p); | |
1365 | |
1366 /* Finish up */ | |
1367 gtk_widget_show(add); | |
1368 gtk_widget_show(cancel); | |
1369 gtk_widget_show(p->entry); | |
1370 gtk_widget_show(topbox); | |
1371 gtk_widget_show(bbox); | |
1372 gtk_widget_show(vbox); | |
1373 gtk_widget_show(rbox); | |
1374 gtk_window_set_title(GTK_WINDOW(p->window), "Gaim - Add Permit/Deny"); | |
1375 gtk_window_set_focus(GTK_WINDOW(p->window), p->entry); | |
1376 gtk_container_add(GTK_CONTAINER(p->window), vbox); | |
1377 gtk_widget_realize(p->window); | |
1378 aol_icon(p->window->window); | |
1379 | |
1380 gtk_widget_show(p->window); | |
1381 } | |
1382 | |
1383 | |
1384 /*------------------------------------------------------------------------*/ | |
1385 /* Function Called To Add A Log */ | |
1386 /*------------------------------------------------------------------------*/ | |
1387 | |
1388 void do_log(GtkWidget *w, char *name) | |
1389 { | |
1390 struct log_conversation *l; | |
1391 struct conversation *c; | |
1392 char buf[128]; | |
1393 | |
1394 c = find_conversation(name); | |
1395 if (!find_log_info(name)) { | |
1396 l = (struct log_conversation *)g_new0(struct log_conversation, 1); | |
1397 strcpy(l->name, name); | |
1398 strcpy(l->filename, gtk_file_selection_get_filename(GTK_FILE_SELECTION(logdialog))); | |
1399 log_conversations = g_list_append(log_conversations, l); | |
1400 | |
1401 if (c != NULL) | |
1402 { | |
1403 g_snprintf(buf, sizeof(buf), LOG_CONVERSATION_TITLE, c->name); | |
1404 gtk_window_set_title(GTK_WINDOW(c->window), buf); | |
1405 } | |
1406 } | |
1407 | |
1408 save_prefs(); | |
1409 | |
1410 destroy_dialog(NULL, logdialog); | |
1411 logdialog = NULL; | |
1412 } | |
1413 | |
1414 static void cancel_log(GtkWidget *w, char *name) | |
1415 { | |
1416 | |
1417 struct conversation *c = gtk_object_get_user_data(GTK_OBJECT(logdialog)); | |
1418 | |
1419 if (c != NULL) | |
1420 { | |
1421 set_state_lock(1); | |
1422 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(c->log_button), FALSE); | |
1423 set_state_lock(0); | |
1424 } | |
1425 destroy_dialog(NULL, logdialog); | |
1426 } | |
1427 | |
1428 void show_log_dialog(char *bname) | |
1429 { | |
1430 char *buf = g_malloc(BUF_LEN); | |
1431 struct conversation *c = find_conversation(bname); | |
1432 | |
1433 | |
1434 if (!logdialog) { | |
1435 logdialog = gtk_file_selection_new("Gaim - Log Conversation"); | |
1436 | |
1437 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(logdialog)); | |
1438 | |
1439 gtk_object_set_user_data(GTK_OBJECT(logdialog), c); | |
1440 | |
1441 g_snprintf(buf, BUF_LEN - 1, "%s/%s.log", getenv("HOME"), bname); | |
1442 | |
1443 gtk_file_selection_set_filename(GTK_FILE_SELECTION(logdialog), buf); | |
1444 gtk_signal_connect(GTK_OBJECT(logdialog), "delete_event", GTK_SIGNAL_FUNC(cancel_log), c); | |
1445 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(logdialog)->ok_button), "clicked", GTK_SIGNAL_FUNC(do_log), bname); | |
1446 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(logdialog)->cancel_button), "clicked", GTK_SIGNAL_FUNC(cancel_log), bname); | |
1447 } | |
1448 | |
25 | 1449 g_free(buf); |
1450 | |
1 | 1451 gtk_widget_show(logdialog); |
1452 gdk_window_raise(logdialog->window); | |
1453 } | |
1454 | |
1455 /*------------------------------------------------------*/ | |
1456 /* Find Buddy By Email */ | |
1457 /*------------------------------------------------------*/ | |
1458 | |
1459 void do_find_info(GtkWidget *w, struct findbyinfo *b) | |
1460 { | |
1461 char *first; | |
1462 char *middle; | |
1463 char *last; | |
1464 char *maiden; | |
1465 char *city; | |
1466 char *state; | |
1467 char *country; | |
1468 | |
1469 first = gtk_entry_get_text(GTK_ENTRY(b->firstentry)); | |
1470 middle = gtk_entry_get_text(GTK_ENTRY(b->middleentry)); | |
1471 last = gtk_entry_get_text(GTK_ENTRY(b->lastentry)); | |
1472 maiden = gtk_entry_get_text(GTK_ENTRY(b->maidenentry)); | |
1473 city = gtk_entry_get_text(GTK_ENTRY(b->cityentry)); | |
1474 state = gtk_entry_get_text(GTK_ENTRY(b->stateentry)); | |
1475 country = gtk_entry_get_text(GTK_ENTRY(b->countryentry)); | |
1476 | |
1477 serv_dir_search(first, middle, last, maiden, city, state, country, ""); | |
1478 destroy_dialog(NULL, b->window); | |
1479 } | |
1480 | |
1481 void do_find_email(GtkWidget *w, struct findbyemail *b) | |
1482 { | |
1483 char *email; | |
1484 | |
1485 email = gtk_entry_get_text(GTK_ENTRY(b->emailentry)); | |
1486 | |
1487 serv_dir_search("","","","","","","", email); | |
1488 | |
1489 destroy_dialog(NULL, b->window); | |
1490 } | |
1491 | |
1492 void show_find_info() | |
1493 { | |
1494 GtkWidget *cancel; | |
1495 GtkWidget *ok; | |
1496 GtkWidget *label; | |
1497 GtkWidget *bbox; | |
1498 GtkWidget *vbox; | |
1499 GtkWidget *topbox; | |
1500 | |
1501 struct findbyinfo *b = g_new0(struct findbyinfo, 1); | |
1502 b->window = gtk_window_new(GTK_WINDOW_DIALOG); | |
1503 dialogwindows = g_list_prepend(dialogwindows, b->window); | |
1504 | |
1505 cancel = gtk_button_new_with_label("Cancel"); | |
1506 ok = gtk_button_new_with_label("OK"); | |
1507 | |
1508 bbox = gtk_hbox_new(TRUE, 10); | |
1509 topbox = gtk_table_new(7, 2, TRUE); | |
1510 vbox = gtk_vbox_new(FALSE, 5); | |
1511 | |
1512 b->firstentry = gtk_entry_new(); | |
1513 b->middleentry = gtk_entry_new(); | |
1514 b->lastentry = gtk_entry_new(); | |
1515 b->maidenentry = gtk_entry_new(); | |
1516 b->cityentry = gtk_entry_new(); | |
1517 b->stateentry = gtk_entry_new(); | |
1518 b->countryentry = gtk_entry_new(); | |
1519 | |
1520 gtk_box_pack_start(GTK_BOX(bbox), ok, TRUE, TRUE, 10); | |
1521 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 10); | |
1522 | |
1523 label = gtk_label_new("First Name"); | |
1524 gtk_widget_show(label); | |
1525 gtk_table_attach_defaults(GTK_TABLE(topbox), label, 0, 1, 0, 1); | |
1526 gtk_table_attach_defaults(GTK_TABLE(topbox), b->firstentry, 1, 2, 0, 1); | |
1527 | |
1528 label = gtk_label_new("Middle Name"); | |
1529 gtk_widget_show(label); | |
1530 gtk_table_attach_defaults(GTK_TABLE(topbox), label, 0, 1, 1, 2); | |
1531 gtk_table_attach_defaults(GTK_TABLE(topbox), b->middleentry, 1, 2, 1, 2); | |
1532 | |
1533 label = gtk_label_new("Last Name"); | |
1534 gtk_widget_show(label); | |
1535 gtk_table_attach_defaults(GTK_TABLE(topbox), label, 0, 1, 2, 3); | |
1536 gtk_table_attach_defaults(GTK_TABLE(topbox), b->lastentry, 1, 2, 2, 3); | |
1537 | |
1538 label = gtk_label_new("Maiden Name"); | |
1539 gtk_widget_show(label); | |
1540 gtk_table_attach_defaults(GTK_TABLE(topbox), label, 0, 1, 3, 4); | |
1541 gtk_table_attach_defaults(GTK_TABLE(topbox), b->maidenentry, 1, 2, 3, 4); | |
1542 | |
1543 label = gtk_label_new("City"); | |
1544 gtk_widget_show(label); | |
1545 gtk_table_attach_defaults(GTK_TABLE(topbox), label, 0, 1, 4, 5); | |
1546 gtk_table_attach_defaults(GTK_TABLE(topbox), b->cityentry, 1, 2, 4, 5); | |
1547 | |
1548 label = gtk_label_new("State"); | |
1549 gtk_widget_show(label); | |
1550 gtk_table_attach_defaults(GTK_TABLE(topbox), label, 0, 1, 5, 6); | |
1551 gtk_table_attach_defaults(GTK_TABLE(topbox), b->stateentry, 1, 2, 5, 6); | |
1552 | |
1553 label = gtk_label_new("Country"); | |
1554 gtk_widget_show(label); | |
1555 gtk_table_attach_defaults(GTK_TABLE(topbox), label, 0, 1, 6, 7); | |
1556 gtk_table_attach_defaults(GTK_TABLE(topbox), b->countryentry, 1, 2, 6, 7); | |
1557 | |
1558 gtk_box_pack_start(GTK_BOX(vbox), topbox, TRUE, TRUE, 5); | |
1559 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5); | |
1560 | |
1561 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", | |
1562 GTK_SIGNAL_FUNC(destroy_dialog), b->window); | |
1563 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", | |
1564 GTK_SIGNAL_FUNC(destroy_dialog), b->window); | |
1565 gtk_signal_connect(GTK_OBJECT(ok), "clicked", | |
1566 GTK_SIGNAL_FUNC(do_find_info), b); | |
1567 | |
1568 gtk_widget_show(ok); | |
1569 gtk_widget_show(cancel); | |
1570 gtk_widget_show(b->firstentry); | |
1571 gtk_widget_show(b->middleentry); | |
1572 gtk_widget_show(b->lastentry); | |
1573 gtk_widget_show(b->maidenentry); | |
1574 gtk_widget_show(b->cityentry); | |
1575 gtk_widget_show(b->stateentry); | |
1576 gtk_widget_show(b->countryentry); | |
1577 gtk_widget_show(topbox); | |
1578 gtk_widget_show(bbox); | |
1579 gtk_widget_show(vbox); | |
1580 gtk_window_set_title(GTK_WINDOW(b->window), "Gaim - Find Buddy By Info"); | |
1581 gtk_window_set_focus(GTK_WINDOW(b->window), b->firstentry); | |
1582 gtk_container_add(GTK_CONTAINER(b->window), vbox); | |
1583 gtk_container_border_width(GTK_CONTAINER(b->window), 10); | |
1584 gtk_widget_realize(b->window); | |
1585 aol_icon(b->window->window); | |
1586 | |
1587 gtk_widget_show(b->window); | |
1588 } | |
1589 | |
1590 void show_find_email() | |
1591 { | |
1592 GtkWidget *cancel; | |
1593 GtkWidget *ok; | |
1594 GtkWidget *label; | |
1595 GtkWidget *bbox; | |
1596 GtkWidget *vbox; | |
1597 GtkWidget *topbox; | |
1598 | |
1599 struct findbyemail *b = g_new0(struct findbyemail, 1); | |
1600 b->window = gtk_window_new(GTK_WINDOW_DIALOG); | |
1601 dialogwindows = g_list_prepend(dialogwindows, b->window); | |
1602 | |
1603 cancel = gtk_button_new_with_label("Cancel"); | |
1604 ok = gtk_button_new_with_label("OK"); | |
1605 | |
1606 bbox = gtk_hbox_new(TRUE, 10); | |
1607 topbox = gtk_hbox_new(FALSE, 5); | |
1608 vbox = gtk_vbox_new(FALSE, 5); | |
1609 | |
1610 b->emailentry = gtk_entry_new(); | |
1611 | |
1612 gtk_box_pack_start(GTK_BOX(bbox), ok, TRUE, TRUE, 10); | |
1613 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 10); | |
1614 | |
1615 label = gtk_label_new("Email"); | |
1616 gtk_widget_show(label); | |
1617 gtk_box_pack_start(GTK_BOX(topbox), label, FALSE, FALSE, 5); | |
1618 gtk_box_pack_start(GTK_BOX(topbox), b->emailentry, FALSE, FALSE, 5); | |
1619 | |
1620 gtk_box_pack_start(GTK_BOX(vbox), topbox, TRUE, TRUE, 5); | |
1621 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5); | |
1622 | |
1623 gtk_signal_connect(GTK_OBJECT(b->window), "destroy", | |
1624 GTK_SIGNAL_FUNC(destroy_dialog), b->window); | |
1625 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", | |
1626 GTK_SIGNAL_FUNC(destroy_dialog), b->window); | |
1627 gtk_signal_connect(GTK_OBJECT(ok), "clicked", | |
1628 GTK_SIGNAL_FUNC(do_find_email), b); | |
1629 gtk_signal_connect(GTK_OBJECT(b->emailentry), "activate", | |
1630 GTK_SIGNAL_FUNC(do_find_email), b); | |
1631 | |
1632 gtk_widget_show(ok); | |
1633 gtk_widget_show(cancel); | |
1634 gtk_widget_show(b->emailentry); | |
1635 gtk_widget_show(topbox); | |
1636 gtk_widget_show(bbox); | |
1637 gtk_widget_show(vbox); | |
1638 gtk_window_set_title(GTK_WINDOW(b->window), "Gaim - Find Buddy By Email"); | |
1639 gtk_window_set_focus(GTK_WINDOW(b->window), b->emailentry); | |
1640 gtk_container_add(GTK_CONTAINER(b->window), vbox); | |
1641 gtk_container_border_width(GTK_CONTAINER(b->window), 10); | |
1642 gtk_widget_realize(b->window); | |
1643 aol_icon(b->window->window); | |
1644 | |
1645 gtk_widget_show(b->window); | |
1646 } | |
1647 | |
1648 /*------------------------------------------------------*/ | |
1649 /* Link Dialog */ | |
1650 /*------------------------------------------------------*/ | |
1651 | |
1652 void cancel_link(GtkWidget *widget, struct linkdlg *b) | |
1653 { | |
62 | 1654 if (b->toggle) { |
1655 set_state_lock(1); | |
1 | 1656 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->toggle), FALSE); |
62 | 1657 set_state_lock(0); |
1658 } | |
1 | 1659 destroy_dialog(NULL, b->window); |
1660 } | |
1661 | |
1662 void do_add_link(GtkWidget *widget, struct linkdlg *b) | |
1663 { | |
1664 char *open_tag; | |
1665 char *urltext, *showtext; | |
1666 open_tag = g_malloc(2048); | |
1667 | |
1668 | |
1669 urltext = gtk_entry_get_text(GTK_ENTRY(b->url)); | |
1670 showtext = gtk_entry_get_text(GTK_ENTRY(b->text)); | |
1671 | |
1672 g_snprintf(open_tag, 2048, "<A HREF=\"%s\">%s", urltext, showtext); | |
1673 surround(b->entry, open_tag, "</A>"); | |
1674 | |
1675 g_free(open_tag); | |
1676 | |
1677 destroy_dialog(NULL, b->window); | |
1678 } | |
1679 | |
1680 | |
1681 void show_add_link(GtkWidget *entry, GtkWidget *link) | |
1682 { | |
1683 GtkWidget *vbox; | |
1684 GtkWidget *bbox; | |
1685 GtkWidget *table; | |
1686 GtkWidget *label; | |
1687 | |
1688 if (!linkdialog) { | |
1689 struct linkdlg *b = g_new0(struct linkdlg, 1); | |
1690 linkdialog = gtk_window_new(GTK_WINDOW_DIALOG); | |
1691 dialogwindows = g_list_prepend(dialogwindows, linkdialog); | |
1692 | |
1693 b->cancel = gtk_button_new_with_label("Cancel"); | |
1694 b->ok = gtk_button_new_with_label("Ok"); | |
1695 | |
1696 vbox = gtk_vbox_new(FALSE, 10); | |
1697 bbox = gtk_hbox_new(TRUE, 10); | |
1698 | |
1699 gtk_widget_show(b->ok); | |
1700 gtk_widget_show(b->cancel); | |
1701 | |
1702 gtk_box_pack_start(GTK_BOX(bbox), b->ok, FALSE, FALSE, 10); | |
1703 gtk_box_pack_start(GTK_BOX(bbox), b->cancel, FALSE, FALSE, 10); | |
1704 gtk_widget_show(bbox); | |
1705 | |
1706 table = gtk_table_new(2, 2, FALSE); | |
1707 b->url = gtk_entry_new(); | |
1708 b->text = gtk_entry_new(); | |
1709 | |
1710 label = gtk_label_new("URL"); | |
1711 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
1712 gtk_table_attach_defaults(GTK_TABLE(table), b->url, 1, 2, 0, 1); | |
1713 gtk_widget_show(label); | |
1714 | |
1715 label = gtk_label_new("Description"); | |
1716 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
1717 gtk_table_attach_defaults(GTK_TABLE(table), b->text, 1, 2, 1, 2); | |
1718 gtk_widget_show(label); | |
1719 | |
1720 gtk_widget_show(b->url); | |
1721 gtk_widget_show(b->text); | |
1722 gtk_widget_show(table); | |
1723 | |
1724 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 10); | |
1725 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 10); | |
1726 gtk_widget_show(vbox); | |
1727 | |
1728 gtk_signal_connect(GTK_OBJECT(linkdialog), "destroy", | |
1729 GTK_SIGNAL_FUNC(cancel_link), b); | |
1730 gtk_signal_connect(GTK_OBJECT(b->cancel), "clicked", | |
1731 GTK_SIGNAL_FUNC(cancel_link), b); | |
1732 gtk_signal_connect(GTK_OBJECT(b->ok), "clicked", | |
1733 GTK_SIGNAL_FUNC(do_add_link), b); | |
1734 | |
1735 gtk_container_add(GTK_CONTAINER(linkdialog ), vbox); | |
1736 gtk_container_border_width(GTK_CONTAINER(linkdialog ), 10); | |
1737 gtk_window_set_title(GTK_WINDOW(linkdialog ), "GAIM - Add URL"); | |
1738 gtk_window_set_focus(GTK_WINDOW(linkdialog ), b->url); | |
1739 b->window = linkdialog; | |
1740 b->toggle = link; | |
1741 b->entry = entry; | |
1742 gtk_widget_realize(linkdialog); | |
1743 aol_icon(linkdialog->window); | |
1744 | |
1745 } | |
1746 | |
1747 gtk_widget_show(linkdialog); | |
1748 gdk_window_raise(linkdialog->window); | |
1749 } | |
1750 | |
1751 | |
1752 /*------------------------------------------------------*/ | |
1753 /* Color Selection Dialog */ | |
1754 /*------------------------------------------------------*/ | |
1755 | |
1756 void cancel_color(GtkWidget *widget, GtkWidget *color) | |
1757 { | |
61 | 1758 if (color) |
1759 { | |
1760 set_state_lock(1); | |
1761 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(color), FALSE); | |
1762 set_state_lock(0); | |
1763 } | |
1 | 1764 destroy_dialog(NULL, colordialog); |
1765 } | |
1766 | |
1767 | |
1768 | |
1769 void do_color(GtkWidget *widget, GtkColorSelection *colorsel) | |
1770 { | |
1771 gdouble color[3]; | |
1772 GdkColor text_color; | |
1773 GtkWidget *entry; | |
1774 char *open_tag; | |
1775 | |
1776 open_tag = g_malloc(30); | |
1777 | |
1778 gtk_color_selection_get_color (colorsel, color); | |
1779 | |
1780 entry = gtk_object_get_user_data(GTK_OBJECT(colorsel)); | |
1781 | |
1782 text_color.red = ((guint16)(color[0]*65535))>>8; | |
1783 text_color.green = ((guint16)(color[1]*65535))>>8; | |
1784 text_color.blue = ((guint16)(color[2]*65535))>>8; | |
1785 | |
1786 g_snprintf(open_tag, 23, "<FONT COLOR=\"#%02X%02X%02X\">", text_color.red, text_color.green, text_color.blue); | |
1787 | |
1788 surround(entry, open_tag, "</FONT>"); | |
1789 sprintf(debug_buff,"#%02X%02X%02X\n", text_color.red, text_color.green, text_color.blue); | |
1790 debug_print(debug_buff); | |
1791 g_free(open_tag); | |
1792 cancel_color(NULL, NULL); | |
1793 } | |
1794 | |
1795 | |
1796 void show_color_dialog(GtkWidget *entry, GtkWidget *color) | |
1797 { | |
1798 GtkWidget *colorsel; | |
1799 | |
1800 if (!colordialog) { | |
1801 | |
1802 | |
1803 colordialog = gtk_color_selection_dialog_new("Select Text Color"); | |
1804 colorsel = GTK_COLOR_SELECTION_DIALOG(colordialog)->colorsel; | |
1805 | |
1806 gtk_object_set_user_data(GTK_OBJECT(colorsel), entry); | |
1807 | |
1808 gtk_signal_connect(GTK_OBJECT(colordialog), "delete_event", GTK_SIGNAL_FUNC(cancel_color), color); | |
1809 | |
1810 gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(colordialog)->ok_button), "clicked", GTK_SIGNAL_FUNC(do_color), colorsel); | |
1811 | |
1812 gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(colordialog)->cancel_button), "clicked", GTK_SIGNAL_FUNC(cancel_color), color); | |
1813 gtk_widget_realize(colordialog); | |
1814 aol_icon(colordialog->window); | |
1815 | |
1816 } | |
1817 | |
1818 gtk_widget_show(colordialog); | |
1819 gdk_window_raise(colordialog->window); | |
1820 } | |
1821 | |
1822 /*------------------------------------------------------------------------*/ | |
1823 /* The dialog for import/export */ | |
1824 /*------------------------------------------------------------------------*/ | |
1825 | |
1826 void do_export(GtkWidget *w, void *dummy) | |
1827 { | |
1828 FILE *f; | |
1829 char *buf = g_malloc(BUF_LONG); | |
1830 char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(exportdialog)); | |
1831 | |
1832 if ((f = fopen(file,"w"))) { | |
1833 toc_build_config(buf, BUF_LONG - 1); | |
1834 fprintf(f, "%s\n", buf); | |
1835 fclose(f); | |
1836 chmod(buf, S_IRUSR | S_IWUSR); | |
1837 } else { | |
1838 g_snprintf(buf, BUF_LONG / 2, "Error writing file %s", file); | |
1839 do_error_dialog(buf, "Error"); | |
1840 } | |
1841 destroy_dialog(NULL, exportdialog); | |
1842 exportdialog = NULL; | |
1843 | |
1844 g_free(buf); | |
1845 | |
1846 | |
1847 } | |
1848 | |
1849 | |
1850 void show_export_dialog() | |
1851 { | |
1852 char *buf = g_malloc(BUF_LEN); | |
1853 if (!exportdialog) { | |
1854 exportdialog = gtk_file_selection_new("Gaim - Export Buddy List"); | |
1855 | |
1856 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(exportdialog)); | |
1857 | |
1858 g_snprintf(buf, BUF_LEN - 1, "%s/gaim.buddy", getenv("HOME")); | |
1859 | |
1860 gtk_file_selection_set_filename(GTK_FILE_SELECTION(exportdialog), buf); | |
1861 gtk_signal_connect(GTK_OBJECT(exportdialog), "destroy", | |
1862 GTK_SIGNAL_FUNC(destroy_dialog), exportdialog); | |
1863 | |
1864 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(exportdialog)->ok_button), | |
1865 "clicked", GTK_SIGNAL_FUNC(do_export), NULL); | |
1866 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(exportdialog)->cancel_button), | |
1867 "clicked", GTK_SIGNAL_FUNC(destroy_dialog), exportdialog); | |
1868 | |
1869 | |
1870 } | |
1871 | |
1872 g_free(buf); | |
1873 | |
1874 gtk_widget_show(exportdialog); | |
1875 gdk_window_raise(exportdialog->window); | |
1876 | |
1877 } | |
1878 | |
1879 void do_import(GtkWidget *w, void *dummy) | |
1880 { | |
1881 GList *grp, *grp2; | |
1882 char *buf = g_malloc(BUF_LONG); | |
1883 char *buf2; | |
1884 char *first = g_malloc(64); | |
1885 char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(importdialog)); | |
1886 FILE *f; | |
1887 | |
1888 if (!(f = fopen(file,"r"))) { | |
1889 g_snprintf(buf, BUF_LONG / 2, "Error reading file %s", file); | |
1890 do_error_dialog(buf, "Error"); | |
1891 destroy_dialog(NULL, importdialog); | |
1892 importdialog = NULL; | |
1893 g_free(buf); | |
37 | 1894 g_free(first); |
1 | 1895 return; |
1896 } | |
1897 | |
1898 fgets(first, 64, f); | |
1899 | |
1900 if (!strcasecmp(first, "Config {\n")) { | |
1901 destroy_dialog(NULL, importdialog); | |
1902 importdialog = NULL; | |
25 | 1903 g_free(buf); |
37 | 1904 g_free(first); |
1 | 1905 return; |
1906 } else if (buf[0] == 'm') { | |
1907 buf2 = buf; | |
1908 buf = g_malloc(1025); | |
1909 g_snprintf(buf, 1024, "toc_set_config {%s}\n", buf2); | |
1910 g_free(buf2); | |
1911 } | |
1912 | |
1913 | |
1914 fseek(f, 0, SEEK_SET); | |
1915 | |
1916 fread(buf, BUF_LONG, 1, f); | |
1917 | |
1918 grp = groups; | |
1919 | |
1920 while(grp) { | |
1921 grp2 = grp->next; | |
1922 remove_group((struct group *)grp->data); | |
1923 grp = grp2; | |
1924 } | |
1925 | |
1926 parse_toc_buddy_list(buf); | |
1927 | |
1928 serv_save_config(); | |
1929 | |
1930 build_edit_tree(); | |
1931 build_permit_tree(); | |
1932 | |
1933 destroy_dialog(NULL, importdialog); | |
1934 importdialog = NULL; | |
1935 | |
1936 g_free(buf); | |
37 | 1937 g_free(first); |
1938 | |
1 | 1939 } |
1940 | |
1941 void show_import_dialog() | |
1942 { | |
1943 char *buf = g_malloc(BUF_LEN); | |
1944 if (!importdialog) { | |
1945 importdialog = gtk_file_selection_new("Gaim - Import Buddy List"); | |
1946 | |
1947 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(importdialog)); | |
1948 | |
1949 g_snprintf(buf, BUF_LEN - 1, "%s/", getenv("HOME")); | |
1950 | |
1951 gtk_file_selection_set_filename(GTK_FILE_SELECTION(importdialog), buf); | |
1952 gtk_signal_connect(GTK_OBJECT(importdialog), "destroy", | |
1953 GTK_SIGNAL_FUNC(destroy_dialog), importdialog); | |
1954 | |
1955 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(importdialog)->ok_button), | |
1956 "clicked", GTK_SIGNAL_FUNC(do_import), NULL); | |
1957 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(importdialog)->cancel_button), | |
1958 "clicked", GTK_SIGNAL_FUNC(destroy_dialog), importdialog); | |
1959 | |
1960 | |
1961 } | |
1962 | |
24 | 1963 g_free(buf); |
1 | 1964 gtk_widget_show(importdialog); |
1965 gdk_window_raise(importdialog->window); | |
1966 } | |
1967 | |
1968 | |
1969 /*------------------------------------------------------------------------*/ | |
1970 /* The dialog for new away messages */ | |
1971 /*------------------------------------------------------------------------*/ | |
1972 | |
1973 void create_mess(GtkWidget *widget, struct create_away *ca) | |
1974 { | |
1975 struct away_message *b; | |
1976 gchar *away_message; | |
1977 guint text_len; | |
1978 int is_checked; | |
1979 | |
1980 /* Grab the appropriate data */ | |
1981 b = g_new0(struct away_message, 1); | |
1982 g_snprintf(b->name, sizeof(b->name), "%s", gtk_entry_get_text(GTK_ENTRY(ca->entry))); | |
1983 | |
1984 /* Get proper Length */ | |
1985 text_len = gtk_text_get_length(GTK_TEXT(ca->text)); | |
1986 away_message = gtk_editable_get_chars(GTK_EDITABLE(ca->text), 0, text_len); | |
1987 | |
1988 g_snprintf(b->message, sizeof(b->message), "%s", away_message); | |
38 | 1989 g_free(away_message); |
1 | 1990 is_checked = GTK_TOGGLE_BUTTON(ca->checkbx)->active; |
1991 | |
1992 if (is_checked) do_away_message(NULL, b); | |
1993 | |
1994 /* stick it on the away list */ | |
1995 if (strlen(b->name)) { | |
1996 away_messages = g_list_append(away_messages, b); | |
1997 save_prefs(); | |
1998 do_away_menu(); | |
1999 if (pd != NULL) | |
2000 gtk_list_select_item(GTK_LIST(pd->away_list), g_list_index(away_messages, b)); | |
2001 } | |
2002 | |
2003 destroy_dialog(NULL, ca->window); | |
2004 } | |
2005 | |
2006 void create_away_mess(GtkWidget *widget, void *dummy) | |
2007 { | |
2008 GtkWidget *bbox; | |
2009 GtkWidget *titlebox; | |
2010 GtkWidget *tbox; | |
2011 GtkWidget *create; | |
2012 GtkWidget *sw; | |
2013 GtkWidget *label; | |
2014 | |
2015 struct create_away *ca = g_new0(struct create_away, 1); | |
2016 | |
2017 /* Set up window */ | |
2018 ca->window = gtk_window_new(GTK_WINDOW_DIALOG); | |
2019 gtk_container_border_width(GTK_CONTAINER(ca->window), 10); | |
2020 gtk_window_set_title(GTK_WINDOW(ca->window), "Gaim - New away message"); | |
2021 gtk_signal_connect(GTK_OBJECT(ca->window),"delete_event", | |
2022 GTK_SIGNAL_FUNC(destroy_dialog), ca->window); | |
2023 | |
2024 /* set up container boxes */ | |
2025 bbox = gtk_vbox_new(FALSE, 0); | |
2026 titlebox = gtk_hbox_new(FALSE, 0); | |
2027 tbox = gtk_vbox_new(FALSE, 0); | |
2028 | |
2029 /* Make a label for away entry */ | |
2030 label = gtk_label_new("Away title: "); | |
2031 gtk_box_pack_start(GTK_BOX(titlebox), label, TRUE, TRUE, 0); | |
2032 | |
2033 /* make away title entry */ | |
2034 ca->entry = gtk_entry_new(); | |
2035 gtk_box_pack_start(GTK_BOX(titlebox), ca->entry, TRUE, TRUE, 0); | |
2036 | |
2037 sw = gtk_scrolled_window_new(NULL, NULL); | |
2038 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
2039 GTK_POLICY_AUTOMATIC, | |
2040 GTK_POLICY_AUTOMATIC); | |
2041 gtk_widget_show(sw); | |
2042 | |
2043 /* create and format text box */ | |
2044 ca->text = gtk_text_new(NULL, NULL); | |
2045 gtk_text_set_word_wrap(GTK_TEXT(ca->text), TRUE); | |
2046 gtk_text_set_editable(GTK_TEXT(ca->text), TRUE ); | |
2047 gtk_container_add(GTK_CONTAINER(sw), ca->text); | |
2048 gtk_widget_show(ca->text); | |
2049 gtk_box_pack_start(GTK_BOX(bbox), sw, TRUE, TRUE, 10); | |
2050 | |
2051 /* make create button */ | |
2052 create = gtk_button_new_with_label ("Create new message"); | |
2053 gtk_box_pack_start(GTK_BOX(bbox), create, TRUE, TRUE, 0); | |
2054 gtk_signal_connect(GTK_OBJECT(create), "clicked", GTK_SIGNAL_FUNC(create_mess), ca); | |
2055 | |
2056 /* Checkbox for showing away msg */ | |
2057 ca->checkbx = gtk_check_button_new_with_label("Make away now"); | |
2058 | |
2059 /* pack boxes where they belong */ | |
2060 gtk_box_pack_start(GTK_BOX(tbox), titlebox, TRUE, TRUE, 0); | |
2061 gtk_box_pack_start(GTK_BOX(tbox), bbox, FALSE, FALSE, 0); | |
2062 gtk_box_pack_start(GTK_BOX(tbox), ca->checkbx, FALSE, FALSE, 0); | |
2063 gtk_container_add(GTK_CONTAINER(ca->window), tbox); | |
2064 | |
2065 /* let the world see what we have done. */ | |
2066 gtk_widget_show(label); | |
2067 gtk_widget_show(create); | |
2068 gtk_widget_show(ca->checkbx); | |
2069 gtk_widget_show(ca->entry); | |
2070 gtk_widget_show(titlebox); | |
2071 gtk_widget_show(tbox); | |
2072 gtk_widget_show(bbox); | |
2073 | |
2074 | |
2075 gtk_widget_realize(ca->window); | |
2076 aol_icon(ca->window->window); | |
2077 | |
2078 gtk_widget_show(ca->window); | |
2079 | |
2080 | |
2081 } | |
2082 | |
2083 #if 0 | |
2084 | |
2085 /*------------------------------------------------------------------------*/ | |
2086 /* The dialog for file requests */ | |
2087 /*------------------------------------------------------------------------*/ | |
2088 | |
2089 | |
2090 static void cancel_callback(GtkWidget *widget, struct file_transfer *ft) | |
2091 { | |
2092 char *send = g_malloc(256); | |
2093 | |
2094 if (ft->accepted) { | |
2095 g_free(send); | |
2096 return; | |
2097 } | |
2098 | |
2099 g_snprintf(send, 255, "toc_rvous_cancel %s %s %s", ft->user, ft->cookie, FILETRANS_UID); | |
2100 sflap_send(send, strlen(send), TYPE_DATA); | |
2101 g_free(send); | |
2102 destroy_dialog(NULL, ft->window); | |
2103 g_free(ft->user); | |
2104 if (ft->message) | |
2105 g_free(ft->message); | |
2106 g_free(ft->filename); | |
2107 g_free(ft->cookie); | |
2108 g_free(ft->ip); | |
2109 g_free(ft); | |
2110 } | |
2111 | |
2112 | |
2113 static void warn_callback(GtkWidget *widget, struct file_transfer *ft) | |
2114 { | |
2115 show_warn_dialog(ft->user); | |
2116 } | |
2117 | |
2118 static void info_callback(GtkWidget *widget, struct file_transfer *ft) | |
2119 { | |
2120 serv_get_info(ft->user); | |
2121 } | |
2122 | |
2123 static char *put_16_int(gint i) { | |
2124 static char tmp[2]; | |
2125 g_snprintf(tmp, 2, "%c%c", i >> 8, i & 0xff); | |
2126 return tmp; | |
2127 } | |
2128 | |
2129 static char *put_32_int(gint i) { | |
2130 static char tmp[4]; | |
2131 g_snprintf(tmp, 4, "%c%c%c%c", (i >> 24) & 0xff, (i >> 16) & 0xff, (i >> 8) & 0xff, i & 0xff); | |
2132 return tmp; | |
2133 } | |
2134 | |
2135 | |
2136 static int get_16_int(char *text) | |
2137 { | |
2138 int tmp = 0; | |
2139 tmp = ((*text << 8) & 0xff); | |
2140 text++; | |
2141 tmp |= (*text & 0xff); | |
2142 text++; | |
2143 return tmp; | |
2144 } | |
2145 | |
2146 static int get_32_int(char *text) | |
2147 { | |
2148 int tmp = 0; | |
2149 tmp = ((*text << 24) & 0xff); | |
2150 text++; | |
2151 tmp |= ((*text << 16) & 0xff); | |
2152 text++; | |
2153 tmp |= ((*text << 8) & 0xff); | |
2154 text++; | |
2155 tmp |= (*text & 0xff); | |
2156 text++; | |
2157 return tmp; | |
2158 } | |
2159 | |
2160 static void do_accept(GtkWidget *w, struct file_transfer *ft) | |
2161 { | |
2162 char *send = g_malloc(256); | |
2163 char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(ft->window)); | |
2164 char *buf; | |
2165 char *header; | |
2166 int hdrlen; | |
79 | 2167 int read_rv; |
1 | 2168 char bmagic[5]; |
2169 struct sockaddr_in sin; | |
2170 int rcv; | |
2171 gint hdrtype, encrypt, compress, totfiles, filesleft; | |
2172 gint totparts, partsleft, totsize, size, modtime, checksum; | |
2173 gint rfrcsum, rfsize, cretime, rfcsum, nrecvd, recvcsum; | |
2174 char *bcookie, *idstring; | |
2175 char flags, lnameoffset, lsizeoffset, dummy; | |
2176 char *macfileinfo; | |
2177 gint nencode, nlanguage; | |
2178 char *name; | |
2179 char *c; | |
2180 | |
2181 | |
2182 if (!(ft->f = fopen(file,"w"))) { | |
2183 buf = g_malloc(BUF_LONG); | |
2184 g_snprintf(buf, BUF_LONG / 2, "Error writing file %s", file); | |
2185 do_error_dialog(buf, "Error"); | |
2186 g_free(buf); | |
2187 ft->accepted = 0; | |
2188 accept_callback(NULL, ft); | |
2189 return; | |
2190 } | |
2191 | |
2192 ft->accepted = 1; | |
2193 | |
2194 destroy_dialog(NULL, ft->window); | |
2195 g_snprintf(send, 255, "toc_rvous_accept %s %s %s", ft->user, ft->cookie, FILETRANS_UID); | |
2196 sflap_send(send, strlen(send), TYPE_DATA); | |
2197 g_free(send); | |
2198 | |
2199 | |
2200 | |
2201 sin.sin_addr.s_addr = inet_addr(ft->ip); | |
2202 sin.sin_family = AF_INET; | |
2203 sin.sin_port = htons(ft->port); | |
2204 | |
2205 ft->fd = socket(AF_INET, SOCK_STREAM, 0); | |
2206 | |
2207 if (ft->fd <= -1 || connect(ft->fd, (struct sockaddr_in *)&sin, sizeof(sin))) { | |
79 | 2208 g_free(buf); |
1 | 2209 return; |
2210 /*cancel */ | |
2211 } | |
2212 | |
2213 rcv = 0; | |
2214 header = g_malloc(6); | |
2215 while (rcv != 6) { | |
79 | 2216 read_rv = read(ft->fd, header + rcv, 6 - rcv); |
2217 if(read_rv < 0) { | |
2218 g_free(header); | |
2219 g_free(buf); | |
2220 return; | |
2221 } | |
2222 rcv += read_rv; | |
1 | 2223 while(gtk_events_pending()) |
2224 gtk_main_iteration(); | |
2225 } | |
2226 | |
2227 strncpy(bmagic, header, 4); | |
2228 bmagic[4] = 0; | |
2229 | |
2230 hdrlen = ((header[4] << 8) & 0xff) | (header[5] & 0xff); | |
2231 | |
2232 g_free(header); | |
2233 header = g_malloc(hdrlen+1); | |
2234 | |
2235 rcv = 0; | |
2236 | |
2237 while (rcv != hdrlen) { | |
79 | 2238 read_rv = read(ft->fd, header + rcv, hdrlen - rcv); |
2239 if(read_rv < 0) { | |
2240 g_free(header); | |
2241 g_free(buf); | |
2242 return; | |
2243 } | |
2244 rcv += read_rv; | |
1 | 2245 while(gtk_events_pending()) |
2246 gtk_main_iteration(); | |
2247 } | |
2248 | |
2249 header[hdrlen] = 0; | |
2250 | |
2251 c = header; | |
2252 | |
2253 | |
2254 hdrtype = get_16_int(c); | |
2255 bcookie = g_malloc(9); | |
2256 strncpy(bcookie, c, 8); | |
2257 c+=8; | |
2258 bcookie[8] = 0; | |
2259 | |
2260 encrypt = get_16_int(c); c+=2; | |
2261 compress = get_16_int(c); c+=2; | |
2262 totfiles = get_16_int(c); c+=2; | |
2263 filesleft = get_16_int(c); c+=2; | |
2264 totparts = get_16_int(c); c+=2; | |
2265 partsleft = get_16_int(c); c+=2; | |
2266 totsize = get_32_int(c); c+=4; | |
2267 size = get_32_int(c); c+=4; | |
2268 modtime = get_32_int(c); c+=4; | |
2269 checksum = get_32_int(c); c+=4; | |
2270 rfrcsum = get_32_int(c); c+=4; | |
2271 rfsize = get_32_int(c); c+=4; | |
2272 cretime = get_32_int(c); c+=4; | |
2273 rfcsum = get_32_int(c); c+=4; | |
2274 nrecvd = get_32_int(c); c+=4; | |
2275 recvcsum = get_32_int(c); c+=4; | |
2276 idstring = g_malloc(33); | |
2277 strncpy(idstring, c, 32); | |
2278 c+=32; | |
2279 idstring[32] = 0; | |
2280 flags = *c; c++; | |
2281 lnameoffset = *c; c++; | |
2282 lsizeoffset = *c; c++; | |
2283 dummy = *c; c++; | |
2284 | |
2285 macfileinfo = g_malloc(70); | |
2286 strncpy(macfileinfo, c, 69); | |
2287 c+=69; | |
2288 macfileinfo[69] = 0; | |
2289 nencode = get_16_int(c); c+=2; | |
2290 nlanguage = get_16_int(c); c+=2; | |
2291 | |
2292 name = g_strdup(c); | |
2293 | |
2294 | |
2295 totparts = 1; | |
2296 partsleft = 1; | |
2297 rfsize = 0; | |
2298 | |
2299 | |
2300 printf("Header type: %d\n", hdrtype); | |
2301 printf("Encryption: %d\n", encrypt); | |
2302 printf("Compress: %d\n", compress); | |
2303 | |
2304 | |
2305 | |
2306 | |
2307 } | |
2308 | |
2309 | |
2310 static void accept_callback(GtkWidget *widget, struct file_transfer *ft) | |
2311 { | |
2312 char *buf = g_malloc(BUF_LEN); | |
2313 char *fname = g_malloc(BUF_LEN); | |
2314 char *c; | |
2315 | |
2316 c = ft->filename + strlen(ft->filename); | |
2317 | |
2318 while (c != ft->filename) { | |
2319 if (*c == '/' || *c == '\\') { | |
2320 strcpy(fname, c+1); | |
2321 break; | |
2322 } | |
2323 c--; | |
2324 } | |
2325 | |
2326 if (c == ft->filename) | |
2327 strcpy(fname, ft->filename); | |
2328 | |
2329 | |
2330 destroy_dialog(NULL, ft->window); | |
2331 | |
2332 ft->window = gtk_file_selection_new("Gaim - Save As..."); | |
2333 | |
2334 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(ft->window)); | |
2335 | |
2336 g_snprintf(buf, BUF_LEN - 1, "%s/%s", getenv("HOME"), fname); | |
2337 | |
2338 gtk_file_selection_set_filename(GTK_FILE_SELECTION(ft->window), buf); | |
2339 gtk_signal_connect(GTK_OBJECT(ft->window), "destroy", | |
2340 GTK_SIGNAL_FUNC(cancel_callback), ft); | |
2341 | |
2342 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(ft->window)->ok_button), | |
2343 "clicked", GTK_SIGNAL_FUNC(do_accept), ft); | |
2344 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(ft->window)->cancel_button), | |
2345 "clicked", GTK_SIGNAL_FUNC(cancel_callback), ft); | |
2346 | |
2347 dialogwindows = g_list_prepend(dialogwindows, ft->window); | |
2348 | |
2349 gtk_widget_show(ft->window); | |
2350 | |
2351 g_free(buf); | |
2352 g_free(fname); | |
2353 | |
2354 } | |
2355 | |
2356 | |
2357 | |
2358 | |
2359 void accept_file_dialog(struct file_transfer *ft) | |
2360 { | |
2361 GtkWidget *accept, *info, *warn, *cancel; | |
2362 GtkWidget *text = NULL, *sw; | |
2363 GtkWidget *label; | |
2364 GtkWidget *vbox, *bbox; | |
2365 char buf[1024]; | |
2366 | |
2367 | |
2368 ft->window = gtk_window_new(GTK_WINDOW_DIALOG); | |
2369 dialogwindows = g_list_prepend(dialogwindows, ft->window); | |
2370 | |
2371 accept = gtk_button_new_with_label("Accept"); | |
2372 info = gtk_button_new_with_label("Info"); | |
2373 warn = gtk_button_new_with_label("Warn"); | |
2374 cancel = gtk_button_new_with_label("Cancel"); | |
2375 | |
2376 bbox = gtk_hbox_new(TRUE, 10); | |
2377 vbox = gtk_vbox_new(FALSE, 5); | |
2378 | |
2379 gtk_widget_show(accept); | |
2380 gtk_widget_show(info); | |
2381 gtk_widget_show(warn); | |
2382 gtk_widget_show(cancel); | |
2383 | |
2384 gtk_box_pack_start(GTK_BOX(bbox), accept, TRUE, TRUE, 10); | |
2385 gtk_box_pack_start(GTK_BOX(bbox), info, TRUE, TRUE, 10); | |
2386 gtk_box_pack_start(GTK_BOX(bbox), warn, TRUE, TRUE, 10); | |
2387 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 10); | |
2388 | |
2389 g_snprintf(buf, sizeof(buf), "%s requests you to accept the file: %s (%d bytes)", | |
2390 ft->user, ft->filename, ft->size); | |
2391 label = gtk_label_new(buf); | |
2392 gtk_widget_show(label); | |
2393 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 5); | |
2394 | |
2395 if (ft->message) { | |
2396 text = gaim_new_layout(); | |
2397 sw = gtk_scrolled_window_new (NULL, NULL); | |
2398 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), | |
2399 GTK_POLICY_NEVER, | |
2400 GTK_POLICY_AUTOMATIC); | |
2401 gtk_widget_show(sw); | |
2402 gtk_container_add(GTK_CONTAINER(sw), text); | |
2403 gtk_widget_show(text); | |
2404 | |
2405 gtk_layout_set_size(GTK_LAYOUT(text), 250, 100); | |
2406 GTK_LAYOUT (text)->vadjustment->step_increment = 10.0; | |
2407 gtk_widget_set_usize(sw, 250, 100); | |
2408 | |
2409 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 10); | |
2410 } | |
2411 gtk_box_pack_start(GTK_BOX(vbox), bbox, TRUE, TRUE, 5); | |
2412 | |
2413 gtk_window_set_title(GTK_WINDOW(ft->window), "Gaim - Accept File?"); | |
2414 gtk_window_set_focus(GTK_WINDOW(ft->window), accept); | |
2415 gtk_container_add(GTK_CONTAINER(ft->window), vbox); | |
2416 gtk_container_border_width(GTK_CONTAINER(ft->window), 10); | |
2417 gtk_widget_show(vbox); | |
2418 gtk_widget_show(bbox); | |
2419 gtk_widget_realize(ft->window); | |
2420 aol_icon(ft->window->window); | |
2421 | |
2422 gtk_widget_show(ft->window); | |
2423 | |
2424 | |
2425 gtk_signal_connect(GTK_OBJECT(accept), "clicked", | |
2426 GTK_SIGNAL_FUNC(accept_callback), ft); | |
2427 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", | |
2428 GTK_SIGNAL_FUNC(cancel_callback), ft); | |
2429 gtk_signal_connect(GTK_OBJECT(warn), "clicked", | |
2430 GTK_SIGNAL_FUNC(warn_callback), ft); | |
2431 gtk_signal_connect(GTK_OBJECT(info), "clicked", | |
2432 GTK_SIGNAL_FUNC(info_callback), ft); | |
2433 | |
2434 | |
2435 if (ft->message) { | |
2436 while(gtk_events_pending()) | |
2437 gtk_main_iteration(); | |
2438 html_print(text, ft->message); | |
2439 } | |
2440 | |
2441 | |
2442 | |
2443 } | |
2444 #endif |