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