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