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