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
|
|
898 buf = g_malloc(strlen(current_user->user_info) * 2);
|
|
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 {
|
|
1648 if (b->toggle)
|
|
1649 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->toggle), FALSE);
|
|
1650
|
|
1651 destroy_dialog(NULL, b->window);
|
|
1652 }
|
|
1653
|
|
1654 void do_add_link(GtkWidget *widget, struct linkdlg *b)
|
|
1655 {
|
|
1656 char *open_tag;
|
|
1657 char *urltext, *showtext;
|
|
1658 open_tag = g_malloc(2048);
|
|
1659
|
|
1660
|
|
1661 urltext = gtk_entry_get_text(GTK_ENTRY(b->url));
|
|
1662 showtext = gtk_entry_get_text(GTK_ENTRY(b->text));
|
|
1663
|
|
1664 g_snprintf(open_tag, 2048, "<A HREF=\"%s\">%s", urltext, showtext);
|
|
1665 surround(b->entry, open_tag, "</A>");
|
|
1666
|
|
1667 g_free(open_tag);
|
|
1668
|
|
1669 destroy_dialog(NULL, b->window);
|
|
1670 }
|
|
1671
|
|
1672
|
|
1673 void show_add_link(GtkWidget *entry, GtkWidget *link)
|
|
1674 {
|
|
1675 GtkWidget *vbox;
|
|
1676 GtkWidget *bbox;
|
|
1677 GtkWidget *table;
|
|
1678 GtkWidget *label;
|
|
1679
|
|
1680 if (!linkdialog) {
|
|
1681 struct linkdlg *b = g_new0(struct linkdlg, 1);
|
|
1682 linkdialog = gtk_window_new(GTK_WINDOW_DIALOG);
|
|
1683 dialogwindows = g_list_prepend(dialogwindows, linkdialog);
|
|
1684
|
|
1685 b->cancel = gtk_button_new_with_label("Cancel");
|
|
1686 b->ok = gtk_button_new_with_label("Ok");
|
|
1687
|
|
1688 vbox = gtk_vbox_new(FALSE, 10);
|
|
1689 bbox = gtk_hbox_new(TRUE, 10);
|
|
1690
|
|
1691 gtk_widget_show(b->ok);
|
|
1692 gtk_widget_show(b->cancel);
|
|
1693
|
|
1694 gtk_box_pack_start(GTK_BOX(bbox), b->ok, FALSE, FALSE, 10);
|
|
1695 gtk_box_pack_start(GTK_BOX(bbox), b->cancel, FALSE, FALSE, 10);
|
|
1696 gtk_widget_show(bbox);
|
|
1697
|
|
1698 table = gtk_table_new(2, 2, FALSE);
|
|
1699 b->url = gtk_entry_new();
|
|
1700 b->text = gtk_entry_new();
|
|
1701
|
|
1702 label = gtk_label_new("URL");
|
|
1703 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);
|
|
1704 gtk_table_attach_defaults(GTK_TABLE(table), b->url, 1, 2, 0, 1);
|
|
1705 gtk_widget_show(label);
|
|
1706
|
|
1707 label = gtk_label_new("Description");
|
|
1708 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);
|
|
1709 gtk_table_attach_defaults(GTK_TABLE(table), b->text, 1, 2, 1, 2);
|
|
1710 gtk_widget_show(label);
|
|
1711
|
|
1712 gtk_widget_show(b->url);
|
|
1713 gtk_widget_show(b->text);
|
|
1714 gtk_widget_show(table);
|
|
1715
|
|
1716 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 10);
|
|
1717 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 10);
|
|
1718 gtk_widget_show(vbox);
|
|
1719
|
|
1720 gtk_signal_connect(GTK_OBJECT(linkdialog), "destroy",
|
|
1721 GTK_SIGNAL_FUNC(cancel_link), b);
|
|
1722 gtk_signal_connect(GTK_OBJECT(b->cancel), "clicked",
|
|
1723 GTK_SIGNAL_FUNC(cancel_link), b);
|
|
1724 gtk_signal_connect(GTK_OBJECT(b->ok), "clicked",
|
|
1725 GTK_SIGNAL_FUNC(do_add_link), b);
|
|
1726
|
|
1727 gtk_container_add(GTK_CONTAINER(linkdialog ), vbox);
|
|
1728 gtk_container_border_width(GTK_CONTAINER(linkdialog ), 10);
|
|
1729 gtk_window_set_title(GTK_WINDOW(linkdialog ), "GAIM - Add URL");
|
|
1730 gtk_window_set_focus(GTK_WINDOW(linkdialog ), b->url);
|
|
1731 b->window = linkdialog;
|
|
1732 b->toggle = link;
|
|
1733 b->entry = entry;
|
|
1734 gtk_widget_realize(linkdialog);
|
|
1735 aol_icon(linkdialog->window);
|
|
1736
|
|
1737 }
|
|
1738
|
|
1739 gtk_widget_show(linkdialog);
|
|
1740 gdk_window_raise(linkdialog->window);
|
|
1741 }
|
|
1742
|
|
1743
|
|
1744 /*------------------------------------------------------*/
|
|
1745 /* Color Selection Dialog */
|
|
1746 /*------------------------------------------------------*/
|
|
1747
|
|
1748 void cancel_color(GtkWidget *widget, GtkWidget *color)
|
|
1749 {
|
|
1750 if (color)
|
|
1751 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(color), FALSE);
|
|
1752 destroy_dialog(NULL, colordialog);
|
|
1753 }
|
|
1754
|
|
1755
|
|
1756
|
|
1757 void do_color(GtkWidget *widget, GtkColorSelection *colorsel)
|
|
1758 {
|
|
1759 gdouble color[3];
|
|
1760 GdkColor text_color;
|
|
1761 GtkWidget *entry;
|
|
1762 char *open_tag;
|
|
1763
|
|
1764 open_tag = g_malloc(30);
|
|
1765
|
|
1766 gtk_color_selection_get_color (colorsel, color);
|
|
1767
|
|
1768 entry = gtk_object_get_user_data(GTK_OBJECT(colorsel));
|
|
1769
|
|
1770 text_color.red = ((guint16)(color[0]*65535))>>8;
|
|
1771 text_color.green = ((guint16)(color[1]*65535))>>8;
|
|
1772 text_color.blue = ((guint16)(color[2]*65535))>>8;
|
|
1773
|
|
1774 g_snprintf(open_tag, 23, "<FONT COLOR=\"#%02X%02X%02X\">", text_color.red, text_color.green, text_color.blue);
|
|
1775
|
|
1776 surround(entry, open_tag, "</FONT>");
|
|
1777 sprintf(debug_buff,"#%02X%02X%02X\n", text_color.red, text_color.green, text_color.blue);
|
|
1778 debug_print(debug_buff);
|
|
1779 g_free(open_tag);
|
|
1780 cancel_color(NULL, NULL);
|
|
1781 }
|
|
1782
|
|
1783
|
|
1784 void show_color_dialog(GtkWidget *entry, GtkWidget *color)
|
|
1785 {
|
|
1786 GtkWidget *colorsel;
|
|
1787
|
|
1788 if (!colordialog) {
|
|
1789
|
|
1790
|
|
1791 colordialog = gtk_color_selection_dialog_new("Select Text Color");
|
|
1792 colorsel = GTK_COLOR_SELECTION_DIALOG(colordialog)->colorsel;
|
|
1793
|
|
1794 gtk_object_set_user_data(GTK_OBJECT(colorsel), entry);
|
|
1795
|
|
1796 gtk_signal_connect(GTK_OBJECT(colordialog), "delete_event", GTK_SIGNAL_FUNC(cancel_color), color);
|
|
1797
|
|
1798 gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(colordialog)->ok_button), "clicked", GTK_SIGNAL_FUNC(do_color), colorsel);
|
|
1799
|
|
1800 gtk_signal_connect(GTK_OBJECT(GTK_COLOR_SELECTION_DIALOG(colordialog)->cancel_button), "clicked", GTK_SIGNAL_FUNC(cancel_color), color);
|
|
1801 gtk_widget_realize(colordialog);
|
|
1802 aol_icon(colordialog->window);
|
|
1803
|
|
1804 }
|
|
1805
|
|
1806 gtk_widget_show(colordialog);
|
|
1807 gdk_window_raise(colordialog->window);
|
|
1808 }
|
|
1809
|
|
1810 /*------------------------------------------------------------------------*/
|
|
1811 /* The dialog for import/export */
|
|
1812 /*------------------------------------------------------------------------*/
|
|
1813
|
|
1814 void do_export(GtkWidget *w, void *dummy)
|
|
1815 {
|
|
1816 FILE *f;
|
|
1817 char *buf = g_malloc(BUF_LONG);
|
|
1818 char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(exportdialog));
|
|
1819
|
|
1820 if ((f = fopen(file,"w"))) {
|
|
1821 toc_build_config(buf, BUF_LONG - 1);
|
|
1822 fprintf(f, "%s\n", buf);
|
|
1823 fclose(f);
|
|
1824 chmod(buf, S_IRUSR | S_IWUSR);
|
|
1825 } else {
|
|
1826 g_snprintf(buf, BUF_LONG / 2, "Error writing file %s", file);
|
|
1827 do_error_dialog(buf, "Error");
|
|
1828 }
|
|
1829 destroy_dialog(NULL, exportdialog);
|
|
1830 exportdialog = NULL;
|
|
1831
|
|
1832 g_free(buf);
|
|
1833
|
|
1834
|
|
1835 }
|
|
1836
|
|
1837
|
|
1838 void show_export_dialog()
|
|
1839 {
|
|
1840 char *buf = g_malloc(BUF_LEN);
|
|
1841 if (!exportdialog) {
|
|
1842 exportdialog = gtk_file_selection_new("Gaim - Export Buddy List");
|
|
1843
|
|
1844 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(exportdialog));
|
|
1845
|
|
1846 g_snprintf(buf, BUF_LEN - 1, "%s/gaim.buddy", getenv("HOME"));
|
|
1847
|
|
1848 gtk_file_selection_set_filename(GTK_FILE_SELECTION(exportdialog), buf);
|
|
1849 gtk_signal_connect(GTK_OBJECT(exportdialog), "destroy",
|
|
1850 GTK_SIGNAL_FUNC(destroy_dialog), exportdialog);
|
|
1851
|
|
1852 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(exportdialog)->ok_button),
|
|
1853 "clicked", GTK_SIGNAL_FUNC(do_export), NULL);
|
|
1854 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(exportdialog)->cancel_button),
|
|
1855 "clicked", GTK_SIGNAL_FUNC(destroy_dialog), exportdialog);
|
|
1856
|
|
1857
|
|
1858 }
|
|
1859
|
|
1860 g_free(buf);
|
|
1861
|
|
1862 gtk_widget_show(exportdialog);
|
|
1863 gdk_window_raise(exportdialog->window);
|
|
1864
|
|
1865 }
|
|
1866
|
|
1867 void do_import(GtkWidget *w, void *dummy)
|
|
1868 {
|
|
1869 GList *grp, *grp2;
|
|
1870 char *buf = g_malloc(BUF_LONG);
|
|
1871 char *buf2;
|
|
1872 char *first = g_malloc(64);
|
|
1873 char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(importdialog));
|
|
1874 FILE *f;
|
|
1875
|
|
1876 if (!(f = fopen(file,"r"))) {
|
|
1877 g_snprintf(buf, BUF_LONG / 2, "Error reading file %s", file);
|
|
1878 do_error_dialog(buf, "Error");
|
|
1879 destroy_dialog(NULL, importdialog);
|
|
1880 importdialog = NULL;
|
|
1881 g_free(buf);
|
|
1882 return;
|
|
1883 }
|
|
1884
|
|
1885 fgets(first, 64, f);
|
|
1886
|
|
1887 if (!strcasecmp(first, "Config {\n")) {
|
|
1888 destroy_dialog(NULL, importdialog);
|
|
1889 importdialog = NULL;
|
25
|
1890 g_free(buf);
|
1
|
1891 return;
|
|
1892 } else if (buf[0] == 'm') {
|
|
1893 buf2 = buf;
|
|
1894 buf = g_malloc(1025);
|
|
1895 g_snprintf(buf, 1024, "toc_set_config {%s}\n", buf2);
|
|
1896 g_free(buf2);
|
|
1897 }
|
|
1898
|
|
1899
|
|
1900 fseek(f, 0, SEEK_SET);
|
|
1901
|
|
1902 fread(buf, BUF_LONG, 1, f);
|
|
1903
|
|
1904 grp = groups;
|
|
1905
|
|
1906 while(grp) {
|
|
1907 grp2 = grp->next;
|
|
1908 remove_group((struct group *)grp->data);
|
|
1909 grp = grp2;
|
|
1910 }
|
|
1911
|
|
1912 parse_toc_buddy_list(buf);
|
|
1913
|
|
1914 serv_save_config();
|
|
1915
|
|
1916 build_edit_tree();
|
|
1917 build_permit_tree();
|
|
1918
|
|
1919 destroy_dialog(NULL, importdialog);
|
|
1920 importdialog = NULL;
|
|
1921
|
|
1922 g_free(buf);
|
|
1923
|
|
1924 }
|
|
1925
|
|
1926 void show_import_dialog()
|
|
1927 {
|
|
1928 char *buf = g_malloc(BUF_LEN);
|
|
1929 if (!importdialog) {
|
|
1930 importdialog = gtk_file_selection_new("Gaim - Import Buddy List");
|
|
1931
|
|
1932 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(importdialog));
|
|
1933
|
|
1934 g_snprintf(buf, BUF_LEN - 1, "%s/", getenv("HOME"));
|
|
1935
|
|
1936 gtk_file_selection_set_filename(GTK_FILE_SELECTION(importdialog), buf);
|
|
1937 gtk_signal_connect(GTK_OBJECT(importdialog), "destroy",
|
|
1938 GTK_SIGNAL_FUNC(destroy_dialog), importdialog);
|
|
1939
|
|
1940 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(importdialog)->ok_button),
|
|
1941 "clicked", GTK_SIGNAL_FUNC(do_import), NULL);
|
|
1942 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(importdialog)->cancel_button),
|
|
1943 "clicked", GTK_SIGNAL_FUNC(destroy_dialog), importdialog);
|
|
1944
|
|
1945
|
|
1946 }
|
|
1947
|
24
|
1948 g_free(buf);
|
1
|
1949 gtk_widget_show(importdialog);
|
|
1950 gdk_window_raise(importdialog->window);
|
|
1951 }
|
|
1952
|
|
1953
|
|
1954 /*------------------------------------------------------------------------*/
|
|
1955 /* The dialog for new away messages */
|
|
1956 /*------------------------------------------------------------------------*/
|
|
1957
|
|
1958 void create_mess(GtkWidget *widget, struct create_away *ca)
|
|
1959 {
|
|
1960 struct away_message *b;
|
|
1961 gchar *away_message;
|
|
1962 guint text_len;
|
|
1963 int is_checked;
|
|
1964
|
|
1965 /* Grab the appropriate data */
|
|
1966 b = g_new0(struct away_message, 1);
|
|
1967 g_snprintf(b->name, sizeof(b->name), "%s", gtk_entry_get_text(GTK_ENTRY(ca->entry)));
|
|
1968
|
|
1969 /* Get proper Length */
|
|
1970 text_len = gtk_text_get_length(GTK_TEXT(ca->text));
|
|
1971 away_message = gtk_editable_get_chars(GTK_EDITABLE(ca->text), 0, text_len);
|
|
1972
|
|
1973 g_snprintf(b->message, sizeof(b->message), "%s", away_message);
|
|
1974
|
|
1975 is_checked = GTK_TOGGLE_BUTTON(ca->checkbx)->active;
|
|
1976
|
|
1977 if (is_checked) do_away_message(NULL, b);
|
|
1978
|
|
1979 /* stick it on the away list */
|
|
1980 if (strlen(b->name)) {
|
|
1981 away_messages = g_list_append(away_messages, b);
|
|
1982 save_prefs();
|
|
1983 do_away_menu();
|
|
1984 if (pd != NULL)
|
|
1985 gtk_list_select_item(GTK_LIST(pd->away_list), g_list_index(away_messages, b));
|
|
1986 }
|
|
1987
|
|
1988 destroy_dialog(NULL, ca->window);
|
|
1989 }
|
|
1990
|
|
1991 void create_away_mess(GtkWidget *widget, void *dummy)
|
|
1992 {
|
|
1993 GtkWidget *bbox;
|
|
1994 GtkWidget *titlebox;
|
|
1995 GtkWidget *tbox;
|
|
1996 GtkWidget *create;
|
|
1997 GtkWidget *sw;
|
|
1998 GtkWidget *label;
|
|
1999
|
|
2000 struct create_away *ca = g_new0(struct create_away, 1);
|
|
2001
|
|
2002 /* Set up window */
|
|
2003 ca->window = gtk_window_new(GTK_WINDOW_DIALOG);
|
|
2004 gtk_container_border_width(GTK_CONTAINER(ca->window), 10);
|
|
2005 gtk_window_set_title(GTK_WINDOW(ca->window), "Gaim - New away message");
|
|
2006 gtk_signal_connect(GTK_OBJECT(ca->window),"delete_event",
|
|
2007 GTK_SIGNAL_FUNC(destroy_dialog), ca->window);
|
|
2008
|
|
2009 /* set up container boxes */
|
|
2010 bbox = gtk_vbox_new(FALSE, 0);
|
|
2011 titlebox = gtk_hbox_new(FALSE, 0);
|
|
2012 tbox = gtk_vbox_new(FALSE, 0);
|
|
2013
|
|
2014 /* Make a label for away entry */
|
|
2015 label = gtk_label_new("Away title: ");
|
|
2016 gtk_box_pack_start(GTK_BOX(titlebox), label, TRUE, TRUE, 0);
|
|
2017
|
|
2018 /* make away title entry */
|
|
2019 ca->entry = gtk_entry_new();
|
|
2020 gtk_box_pack_start(GTK_BOX(titlebox), ca->entry, TRUE, TRUE, 0);
|
|
2021
|
|
2022 sw = gtk_scrolled_window_new(NULL, NULL);
|
|
2023 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
|
|
2024 GTK_POLICY_AUTOMATIC,
|
|
2025 GTK_POLICY_AUTOMATIC);
|
|
2026 gtk_widget_show(sw);
|
|
2027
|
|
2028 /* create and format text box */
|
|
2029 ca->text = gtk_text_new(NULL, NULL);
|
|
2030 gtk_text_set_word_wrap(GTK_TEXT(ca->text), TRUE);
|
|
2031 gtk_text_set_editable(GTK_TEXT(ca->text), TRUE );
|
|
2032 gtk_container_add(GTK_CONTAINER(sw), ca->text);
|
|
2033 gtk_widget_show(ca->text);
|
|
2034 gtk_box_pack_start(GTK_BOX(bbox), sw, TRUE, TRUE, 10);
|
|
2035
|
|
2036 /* make create button */
|
|
2037 create = gtk_button_new_with_label ("Create new message");
|
|
2038 gtk_box_pack_start(GTK_BOX(bbox), create, TRUE, TRUE, 0);
|
|
2039 gtk_signal_connect(GTK_OBJECT(create), "clicked", GTK_SIGNAL_FUNC(create_mess), ca);
|
|
2040
|
|
2041 /* Checkbox for showing away msg */
|
|
2042 ca->checkbx = gtk_check_button_new_with_label("Make away now");
|
|
2043
|
|
2044 /* pack boxes where they belong */
|
|
2045 gtk_box_pack_start(GTK_BOX(tbox), titlebox, TRUE, TRUE, 0);
|
|
2046 gtk_box_pack_start(GTK_BOX(tbox), bbox, FALSE, FALSE, 0);
|
|
2047 gtk_box_pack_start(GTK_BOX(tbox), ca->checkbx, FALSE, FALSE, 0);
|
|
2048 gtk_container_add(GTK_CONTAINER(ca->window), tbox);
|
|
2049
|
|
2050 /* let the world see what we have done. */
|
|
2051 gtk_widget_show(label);
|
|
2052 gtk_widget_show(create);
|
|
2053 gtk_widget_show(ca->checkbx);
|
|
2054 gtk_widget_show(ca->entry);
|
|
2055 gtk_widget_show(titlebox);
|
|
2056 gtk_widget_show(tbox);
|
|
2057 gtk_widget_show(bbox);
|
|
2058
|
|
2059
|
|
2060 gtk_widget_realize(ca->window);
|
|
2061 aol_icon(ca->window->window);
|
|
2062
|
|
2063 gtk_widget_show(ca->window);
|
|
2064
|
|
2065
|
|
2066 }
|
|
2067
|
|
2068 #if 0
|
|
2069
|
|
2070 /*------------------------------------------------------------------------*/
|
|
2071 /* The dialog for file requests */
|
|
2072 /*------------------------------------------------------------------------*/
|
|
2073
|
|
2074
|
|
2075 static void cancel_callback(GtkWidget *widget, struct file_transfer *ft)
|
|
2076 {
|
|
2077 char *send = g_malloc(256);
|
|
2078
|
|
2079 if (ft->accepted) {
|
|
2080 g_free(send);
|
|
2081 return;
|
|
2082 }
|
|
2083
|
|
2084 g_snprintf(send, 255, "toc_rvous_cancel %s %s %s", ft->user, ft->cookie, FILETRANS_UID);
|
|
2085 sflap_send(send, strlen(send), TYPE_DATA);
|
|
2086 g_free(send);
|
|
2087 destroy_dialog(NULL, ft->window);
|
|
2088 g_free(ft->user);
|
|
2089 if (ft->message)
|
|
2090 g_free(ft->message);
|
|
2091 g_free(ft->filename);
|
|
2092 g_free(ft->cookie);
|
|
2093 g_free(ft->ip);
|
|
2094 g_free(ft);
|
|
2095 }
|
|
2096
|
|
2097
|
|
2098 static void warn_callback(GtkWidget *widget, struct file_transfer *ft)
|
|
2099 {
|
|
2100 show_warn_dialog(ft->user);
|
|
2101 }
|
|
2102
|
|
2103 static void info_callback(GtkWidget *widget, struct file_transfer *ft)
|
|
2104 {
|
|
2105 serv_get_info(ft->user);
|
|
2106 }
|
|
2107
|
|
2108 static char *put_16_int(gint i) {
|
|
2109 static char tmp[2];
|
|
2110 g_snprintf(tmp, 2, "%c%c", i >> 8, i & 0xff);
|
|
2111 return tmp;
|
|
2112 }
|
|
2113
|
|
2114 static char *put_32_int(gint i) {
|
|
2115 static char tmp[4];
|
|
2116 g_snprintf(tmp, 4, "%c%c%c%c", (i >> 24) & 0xff, (i >> 16) & 0xff, (i >> 8) & 0xff, i & 0xff);
|
|
2117 return tmp;
|
|
2118 }
|
|
2119
|
|
2120
|
|
2121 static int get_16_int(char *text)
|
|
2122 {
|
|
2123 int tmp = 0;
|
|
2124 tmp = ((*text << 8) & 0xff);
|
|
2125 text++;
|
|
2126 tmp |= (*text & 0xff);
|
|
2127 text++;
|
|
2128 return tmp;
|
|
2129 }
|
|
2130
|
|
2131 static int get_32_int(char *text)
|
|
2132 {
|
|
2133 int tmp = 0;
|
|
2134 tmp = ((*text << 24) & 0xff);
|
|
2135 text++;
|
|
2136 tmp |= ((*text << 16) & 0xff);
|
|
2137 text++;
|
|
2138 tmp |= ((*text << 8) & 0xff);
|
|
2139 text++;
|
|
2140 tmp |= (*text & 0xff);
|
|
2141 text++;
|
|
2142 return tmp;
|
|
2143 }
|
|
2144
|
|
2145 static void do_accept(GtkWidget *w, struct file_transfer *ft)
|
|
2146 {
|
|
2147 char *send = g_malloc(256);
|
|
2148 char *file = gtk_file_selection_get_filename(GTK_FILE_SELECTION(ft->window));
|
|
2149 char *buf;
|
|
2150 char *header;
|
|
2151 int hdrlen;
|
|
2152 char bmagic[5];
|
|
2153 struct sockaddr_in sin;
|
|
2154 int rcv;
|
|
2155 gint hdrtype, encrypt, compress, totfiles, filesleft;
|
|
2156 gint totparts, partsleft, totsize, size, modtime, checksum;
|
|
2157 gint rfrcsum, rfsize, cretime, rfcsum, nrecvd, recvcsum;
|
|
2158 char *bcookie, *idstring;
|
|
2159 char flags, lnameoffset, lsizeoffset, dummy;
|
|
2160 char *macfileinfo;
|
|
2161 gint nencode, nlanguage;
|
|
2162 char *name;
|
|
2163 char *c;
|
|
2164
|
|
2165
|
|
2166 if (!(ft->f = fopen(file,"w"))) {
|
|
2167 buf = g_malloc(BUF_LONG);
|
|
2168 g_snprintf(buf, BUF_LONG / 2, "Error writing file %s", file);
|
|
2169 do_error_dialog(buf, "Error");
|
|
2170 g_free(buf);
|
|
2171 ft->accepted = 0;
|
|
2172 accept_callback(NULL, ft);
|
|
2173 return;
|
|
2174 }
|
|
2175
|
|
2176 ft->accepted = 1;
|
|
2177
|
|
2178 destroy_dialog(NULL, ft->window);
|
|
2179 g_snprintf(send, 255, "toc_rvous_accept %s %s %s", ft->user, ft->cookie, FILETRANS_UID);
|
|
2180 sflap_send(send, strlen(send), TYPE_DATA);
|
|
2181 g_free(send);
|
|
2182
|
|
2183
|
|
2184
|
|
2185 sin.sin_addr.s_addr = inet_addr(ft->ip);
|
|
2186 sin.sin_family = AF_INET;
|
|
2187 sin.sin_port = htons(ft->port);
|
|
2188
|
|
2189 ft->fd = socket(AF_INET, SOCK_STREAM, 0);
|
|
2190
|
|
2191 if (ft->fd <= -1 || connect(ft->fd, (struct sockaddr_in *)&sin, sizeof(sin))) {
|
|
2192 return;
|
|
2193 /*cancel */
|
|
2194 }
|
|
2195
|
|
2196 rcv = 0;
|
|
2197 header = g_malloc(6);
|
|
2198 while (rcv != 6) {
|
|
2199 rcv += read(ft->fd, header + rcv, 6 - rcv);
|
|
2200 while(gtk_events_pending())
|
|
2201 gtk_main_iteration();
|
|
2202 }
|
|
2203
|
|
2204 strncpy(bmagic, header, 4);
|
|
2205 bmagic[4] = 0;
|
|
2206
|
|
2207 hdrlen = ((header[4] << 8) & 0xff) | (header[5] & 0xff);
|
|
2208
|
|
2209 g_free(header);
|
|
2210 header = g_malloc(hdrlen+1);
|
|
2211
|
|
2212 rcv = 0;
|
|
2213
|
|
2214 while (rcv != hdrlen) {
|
|
2215 rcv += read(ft->fd, header + rcv, hdrlen - rcv);
|
|
2216 while(gtk_events_pending())
|
|
2217 gtk_main_iteration();
|
|
2218 }
|
|
2219
|
|
2220 header[hdrlen] = 0;
|
|
2221
|
|
2222 c = header;
|
|
2223
|
|
2224
|
|
2225 hdrtype = get_16_int(c);
|
|
2226 bcookie = g_malloc(9);
|
|
2227 strncpy(bcookie, c, 8);
|
|
2228 c+=8;
|
|
2229 bcookie[8] = 0;
|
|
2230
|
|
2231 encrypt = get_16_int(c); c+=2;
|
|
2232 compress = get_16_int(c); c+=2;
|
|
2233 totfiles = get_16_int(c); c+=2;
|
|
2234 filesleft = get_16_int(c); c+=2;
|
|
2235 totparts = get_16_int(c); c+=2;
|
|
2236 partsleft = get_16_int(c); c+=2;
|
|
2237 totsize = get_32_int(c); c+=4;
|
|
2238 size = get_32_int(c); c+=4;
|
|
2239 modtime = get_32_int(c); c+=4;
|
|
2240 checksum = get_32_int(c); c+=4;
|
|
2241 rfrcsum = get_32_int(c); c+=4;
|
|
2242 rfsize = get_32_int(c); c+=4;
|
|
2243 cretime = get_32_int(c); c+=4;
|
|
2244 rfcsum = get_32_int(c); c+=4;
|
|
2245 nrecvd = get_32_int(c); c+=4;
|
|
2246 recvcsum = get_32_int(c); c+=4;
|
|
2247 idstring = g_malloc(33);
|
|
2248 strncpy(idstring, c, 32);
|
|
2249 c+=32;
|
|
2250 idstring[32] = 0;
|
|
2251 flags = *c; c++;
|
|
2252 lnameoffset = *c; c++;
|
|
2253 lsizeoffset = *c; c++;
|
|
2254 dummy = *c; c++;
|
|
2255
|
|
2256 macfileinfo = g_malloc(70);
|
|
2257 strncpy(macfileinfo, c, 69);
|
|
2258 c+=69;
|
|
2259 macfileinfo[69] = 0;
|
|
2260 nencode = get_16_int(c); c+=2;
|
|
2261 nlanguage = get_16_int(c); c+=2;
|
|
2262
|
|
2263 name = g_strdup(c);
|
|
2264
|
|
2265
|
|
2266 totparts = 1;
|
|
2267 partsleft = 1;
|
|
2268 rfsize = 0;
|
|
2269
|
|
2270
|
|
2271 printf("Header type: %d\n", hdrtype);
|
|
2272 printf("Encryption: %d\n", encrypt);
|
|
2273 printf("Compress: %d\n", compress);
|
|
2274
|
|
2275
|
|
2276
|
|
2277
|
|
2278 }
|
|
2279
|
|
2280
|
|
2281 static void accept_callback(GtkWidget *widget, struct file_transfer *ft)
|
|
2282 {
|
|
2283 char *buf = g_malloc(BUF_LEN);
|
|
2284 char *fname = g_malloc(BUF_LEN);
|
|
2285 char *c;
|
|
2286
|
|
2287 c = ft->filename + strlen(ft->filename);
|
|
2288
|
|
2289 while (c != ft->filename) {
|
|
2290 if (*c == '/' || *c == '\\') {
|
|
2291 strcpy(fname, c+1);
|
|
2292 break;
|
|
2293 }
|
|
2294 c--;
|
|
2295 }
|
|
2296
|
|
2297 if (c == ft->filename)
|
|
2298 strcpy(fname, ft->filename);
|
|
2299
|
|
2300
|
|
2301 destroy_dialog(NULL, ft->window);
|
|
2302
|
|
2303 ft->window = gtk_file_selection_new("Gaim - Save As...");
|
|
2304
|
|
2305 gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(ft->window));
|
|
2306
|
|
2307 g_snprintf(buf, BUF_LEN - 1, "%s/%s", getenv("HOME"), fname);
|
|
2308
|
|
2309 gtk_file_selection_set_filename(GTK_FILE_SELECTION(ft->window), buf);
|
|
2310 gtk_signal_connect(GTK_OBJECT(ft->window), "destroy",
|
|
2311 GTK_SIGNAL_FUNC(cancel_callback), ft);
|
|
2312
|
|
2313 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(ft->window)->ok_button),
|
|
2314 "clicked", GTK_SIGNAL_FUNC(do_accept), ft);
|
|
2315 gtk_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(ft->window)->cancel_button),
|
|
2316 "clicked", GTK_SIGNAL_FUNC(cancel_callback), ft);
|
|
2317
|
|
2318 dialogwindows = g_list_prepend(dialogwindows, ft->window);
|
|
2319
|
|
2320 gtk_widget_show(ft->window);
|
|
2321
|
|
2322 g_free(buf);
|
|
2323 g_free(fname);
|
|
2324
|
|
2325 }
|
|
2326
|
|
2327
|
|
2328
|
|
2329
|
|
2330 void accept_file_dialog(struct file_transfer *ft)
|
|
2331 {
|
|
2332 GtkWidget *accept, *info, *warn, *cancel;
|
|
2333 GtkWidget *text = NULL, *sw;
|
|
2334 GtkWidget *label;
|
|
2335 GtkWidget *vbox, *bbox;
|
|
2336 char buf[1024];
|
|
2337
|
|
2338
|
|
2339 ft->window = gtk_window_new(GTK_WINDOW_DIALOG);
|
|
2340 dialogwindows = g_list_prepend(dialogwindows, ft->window);
|
|
2341
|
|
2342 accept = gtk_button_new_with_label("Accept");
|
|
2343 info = gtk_button_new_with_label("Info");
|
|
2344 warn = gtk_button_new_with_label("Warn");
|
|
2345 cancel = gtk_button_new_with_label("Cancel");
|
|
2346
|
|
2347 bbox = gtk_hbox_new(TRUE, 10);
|
|
2348 vbox = gtk_vbox_new(FALSE, 5);
|
|
2349
|
|
2350 gtk_widget_show(accept);
|
|
2351 gtk_widget_show(info);
|
|
2352 gtk_widget_show(warn);
|
|
2353 gtk_widget_show(cancel);
|
|
2354
|
|
2355 gtk_box_pack_start(GTK_BOX(bbox), accept, TRUE, TRUE, 10);
|
|
2356 gtk_box_pack_start(GTK_BOX(bbox), info, TRUE, TRUE, 10);
|
|
2357 gtk_box_pack_start(GTK_BOX(bbox), warn, TRUE, TRUE, 10);
|
|
2358 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 10);
|
|
2359
|
|
2360 g_snprintf(buf, sizeof(buf), "%s requests you to accept the file: %s (%d bytes)",
|
|
2361 ft->user, ft->filename, ft->size);
|
|
2362 label = gtk_label_new(buf);
|
|
2363 gtk_widget_show(label);
|
|
2364 gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 5);
|
|
2365
|
|
2366 if (ft->message) {
|
|
2367 text = gaim_new_layout();
|
|
2368 sw = gtk_scrolled_window_new (NULL, NULL);
|
|
2369 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
|
2370 GTK_POLICY_NEVER,
|
|
2371 GTK_POLICY_AUTOMATIC);
|
|
2372 gtk_widget_show(sw);
|
|
2373 gtk_container_add(GTK_CONTAINER(sw), text);
|
|
2374 gtk_widget_show(text);
|
|
2375
|
|
2376 gtk_layout_set_size(GTK_LAYOUT(text), 250, 100);
|
|
2377 GTK_LAYOUT (text)->vadjustment->step_increment = 10.0;
|
|
2378 gtk_widget_set_usize(sw, 250, 100);
|
|
2379
|
|
2380 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 10);
|
|
2381 }
|
|
2382 gtk_box_pack_start(GTK_BOX(vbox), bbox, TRUE, TRUE, 5);
|
|
2383
|
|
2384 gtk_window_set_title(GTK_WINDOW(ft->window), "Gaim - Accept File?");
|
|
2385 gtk_window_set_focus(GTK_WINDOW(ft->window), accept);
|
|
2386 gtk_container_add(GTK_CONTAINER(ft->window), vbox);
|
|
2387 gtk_container_border_width(GTK_CONTAINER(ft->window), 10);
|
|
2388 gtk_widget_show(vbox);
|
|
2389 gtk_widget_show(bbox);
|
|
2390 gtk_widget_realize(ft->window);
|
|
2391 aol_icon(ft->window->window);
|
|
2392
|
|
2393 gtk_widget_show(ft->window);
|
|
2394
|
|
2395
|
|
2396 gtk_signal_connect(GTK_OBJECT(accept), "clicked",
|
|
2397 GTK_SIGNAL_FUNC(accept_callback), ft);
|
|
2398 gtk_signal_connect(GTK_OBJECT(cancel), "clicked",
|
|
2399 GTK_SIGNAL_FUNC(cancel_callback), ft);
|
|
2400 gtk_signal_connect(GTK_OBJECT(warn), "clicked",
|
|
2401 GTK_SIGNAL_FUNC(warn_callback), ft);
|
|
2402 gtk_signal_connect(GTK_OBJECT(info), "clicked",
|
|
2403 GTK_SIGNAL_FUNC(info_callback), ft);
|
|
2404
|
|
2405
|
|
2406 if (ft->message) {
|
|
2407 while(gtk_events_pending())
|
|
2408 gtk_main_iteration();
|
|
2409 html_print(text, ft->message);
|
|
2410 }
|
|
2411
|
|
2412
|
|
2413
|
|
2414 }
|
|
2415 #endif
|