Mercurial > pidgin
annotate src/util.c @ 1049:749e25dc90cb
[gaim-migrate @ 1059]
removing buddies when appropriate, and a bad fix for a bug
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Wed, 01 Nov 2000 23:44:30 +0000 |
parents | 80a47e3b1bca |
children | 56c7ceb986a8 |
rev | line source |
---|---|
1 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
21 | |
349
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
278
diff
changeset
|
22 #ifdef HAVE_CONFIG_H |
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
278
diff
changeset
|
23 #include "../config.h" |
b402a23f35df
[gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
278
diff
changeset
|
24 #endif |
1 | 25 #include <unistd.h> |
26 #include <errno.h> | |
27 #include <stdio.h> | |
28 #include <stdlib.h> | |
29 #include <sys/time.h> | |
30 #include <sys/types.h> | |
31 #include <sys/stat.h> | |
32 #include <string.h> | |
33 #include <sys/wait.h> | |
34 #include <gtk/gtk.h> | |
210
ec0686b3b03f
[gaim-migrate @ 220]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
209
diff
changeset
|
35 #include <ctype.h> |
1 | 36 #include <pixmaps/aimicon.xpm> |
37 #include "gaim.h" | |
38 | |
39 static GdkPixmap *icon_pm = NULL; | |
40 static GdkBitmap *icon_bm = NULL; | |
41 | |
70 | 42 char *full_date() { |
43 char * date; | |
44 time_t tme; | |
45 | |
46 time(&tme); | |
47 date = ctime(&tme); | |
48 date[strlen(date)-1] = '\0'; | |
49 return date; | |
50 } | |
51 | |
1 | 52 gint badchar(char c) |
53 { | |
970 | 54 switch(c) { |
55 case ' ': | |
56 case ',': | |
57 case '(': | |
58 case ')': | |
59 case '\0': | |
976
2586b2a3725e
[gaim-migrate @ 986]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
970
diff
changeset
|
60 case '\n': |
970 | 61 case '<': |
62 case '>': | |
413
7ea55575cc01
[gaim-migrate @ 423]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
373
diff
changeset
|
63 return 1; |
970 | 64 default: |
65 return 0; | |
66 } | |
1 | 67 } |
68 | |
69 | |
970 | 70 gchar *sec_to_text(gint sec) |
1 | 71 { |
72 int hrs, min; | |
73 char minutes[64]; | |
74 char hours[64]; | |
970 | 75 char *sep; |
1 | 76 char *ret = g_malloc(256); |
77 | |
78 hrs = sec / 3600; | |
79 min = sec % 3600; | |
80 | |
81 min = min / 60; | |
82 sec = min % 60; | |
83 | |
84 if (min) { | |
85 if (min == 1) | |
86 g_snprintf(minutes, sizeof(minutes), "%d minute.", min); | |
87 else | |
88 g_snprintf(minutes, sizeof(minutes), "%d minutes.", min); | |
970 | 89 sep = ", "; |
1 | 90 } else { |
91 if (!hrs) | |
92 g_snprintf(minutes, sizeof(minutes), "%d minutes.", min); | |
93 else { | |
94 minutes[0] = '.'; | |
95 minutes[1] = '\0'; | |
96 } | |
970 | 97 sep = ""; |
1 | 98 } |
99 | |
100 if (hrs) { | |
101 if (hrs == 1) | |
102 g_snprintf(hours, sizeof(hours), "%d hour%s", hrs, sep); | |
103 else | |
104 g_snprintf(hours, sizeof(hours), "%d hours%s", hrs, sep); | |
105 } else | |
106 hours[0] = '\0'; | |
107 | |
108 | |
109 g_snprintf(ret, 256, "%s%s", hours, minutes); | |
110 | |
111 return ret; | |
112 } | |
113 | |
114 gint linkify_text(char *text) | |
115 { | |
116 char *c, *t; | |
845
647b110f7a1a
[gaim-migrate @ 855]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
831
diff
changeset
|
117 char *cpy = g_malloc(strlen(text) * 2 + 1); |
1 | 118 char url_buf[512]; |
119 int cnt=0; | |
120 /* Assumes you have a buffer able to cary at least BUF_LEN * 2 bytes */ | |
121 | |
122 strncpy(cpy, text, strlen(text)); | |
123 cpy[strlen(text)] = 0; | |
124 c = cpy; | |
125 while(*c) { | |
126 if (!strncasecmp(c, "<A", 2)) { | |
127 while(1) { | |
128 if (!strncasecmp(c, "/A>", 3)) { | |
129 break; | |
130 } | |
131 text[cnt++] = *c; | |
132 c++; | |
133 if (!(*c)) | |
134 break; | |
135 } | |
856 | 136 } else if ( (!strncasecmp(c, "http://", 7) || (!strncasecmp(c, "https://", 8)))) { |
1 | 137 t = c; |
138 while(1) { | |
139 if (badchar(*t)) { | |
925 | 140 |
141 if (*(t) == ',' && (*(t+1) != ' ')) | |
142 { | |
143 t++; | |
144 continue; | |
145 } | |
146 | |
1 | 147 if (*(t-1) == '.') |
148 t--; | |
149 strncpy(url_buf, c, t-c); | |
150 url_buf[t-c] = 0; | |
151 cnt += g_snprintf(&text[cnt++], 1024, "<A HREF=\"%s\">%s</A>", url_buf, url_buf); | |
152 cnt--; | |
153 c = t; | |
154 break; | |
155 } | |
156 if (!t) | |
157 break; | |
158 t++; | |
159 | |
160 } | |
161 } else if (!strncasecmp(c, "www.", 4)) { | |
162 if (strncasecmp(c, "www..", 5)) { | |
163 t = c; | |
164 while(1) { | |
165 if (badchar(*t)) { | |
166 if (t-c == 4) { | |
167 break; | |
168 } | |
925 | 169 |
170 if (*(t) == ',' && (*(t+1) != ' ')) | |
171 { | |
172 t++; | |
173 continue; | |
174 } | |
175 | |
1 | 176 if (*(t-1) == '.') |
177 t--; | |
178 strncpy(url_buf, c, t-c); | |
179 url_buf[t-c] = 0; | |
180 cnt += g_snprintf(&text[cnt++], 1024, "<A HREF=\"http://%s\">%s</A>", url_buf, url_buf); | |
181 cnt--; | |
182 c = t; | |
183 break; | |
184 } | |
185 if (!t) | |
186 break; | |
187 t++; | |
188 } | |
189 } | |
190 } else if (!strncasecmp(c, "ftp://", 6)) { | |
191 t = c; | |
192 while(1) { | |
193 if (badchar(*t)) { | |
194 if (*(t-1) == '.') | |
195 t--; | |
196 strncpy(url_buf, c, t-c); | |
197 url_buf[t-c] = 0; | |
198 cnt += g_snprintf(&text[cnt++], 1024, "<A HREF=\"%s\">%s</A>", url_buf, url_buf); | |
199 cnt--; | |
200 c = t; | |
201 break; | |
202 } | |
203 if (!t) | |
204 break; | |
205 t++; | |
206 | |
207 } | |
924 | 208 } else if (!strncasecmp(c, "ftp.", 4) ) { |
209 if (strncasecmp(c, "ftp..", 5)) { | |
1 | 210 t = c; |
211 while(1) { | |
212 if (badchar(*t)) { | |
213 if (t-c == 4) { | |
214 break; | |
215 } | |
216 if (*(t-1) == '.') | |
217 t--; | |
218 strncpy(url_buf, c, t-c); | |
219 url_buf[t-c] = 0; | |
220 cnt += g_snprintf(&text[cnt++], 1024, "<A HREF=\"ftp://%s\">%s</A>", url_buf, url_buf); | |
221 cnt--; | |
222 c = t; | |
223 break; | |
224 } | |
225 if (!t) | |
226 break; | |
227 t++; | |
228 } | |
924 | 229 } |
1 | 230 } else if (!strncasecmp(c, "mailto:", 7)) { |
231 t = c; | |
232 while(1) { | |
233 if (badchar(*t)) { | |
234 if (*(t-1) == '.') | |
235 t--; | |
236 strncpy(url_buf, c, t-c); | |
237 url_buf[t-c] = 0; | |
238 cnt += g_snprintf(&text[cnt++], 1024, "<A HREF=\"%s\">%s</A>", url_buf, url_buf); | |
239 cnt--; | |
240 c = t; | |
241 break; | |
242 } | |
243 if (!t) | |
244 break; | |
245 t++; | |
246 | |
247 } | |
248 } else if (!strncasecmp(c, "@", 1)) { | |
249 char *tmp; | |
250 int flag; | |
251 int len=0; | |
924 | 252 char illegal_chars[] = "!@#$%^&*()[]{}/\\<>\":;\0"; |
1 | 253 url_buf[0] = 0; |
254 | |
927 | 255 if (*(c-1) == ' ' || *(c+1) == ' ' || rindex(illegal_chars, *(c+1)) || *(c+1) == 13 || *(c+1) == 10) |
1 | 256 flag = 0; |
257 else | |
258 flag = 1; | |
259 | |
260 t = c; | |
261 while(flag) { | |
262 if (badchar(*t)) { | |
263 cnt -= (len - 1); | |
264 break; | |
265 } else { | |
266 len++; | |
267 tmp = g_malloc(len + 1); | |
268 tmp[len] = 0; | |
269 tmp[0] = *t; | |
270 strncpy(tmp + 1, url_buf, len - 1); | |
271 strcpy(url_buf, tmp); | |
272 url_buf[len] = 0; | |
273 g_free(tmp); | |
274 t--; | |
275 if (t < cpy) { | |
276 cnt = 0; | |
277 break; | |
278 } | |
279 } | |
280 } | |
281 | |
282 | |
283 t = c + 1; | |
284 | |
285 while(flag) { | |
286 if (badchar(*t)) { | |
287 if (*(t-1) == '.') | |
288 t--; | |
289 cnt += g_snprintf(&text[cnt++], 1024, "<A HREF=\"mailto:%s\">%s</A>", url_buf, url_buf); | |
290 text[cnt]=0; | |
291 | |
292 | |
293 cnt--; | |
294 c = t; | |
295 | |
296 break; | |
297 } else { | |
298 strncat(url_buf, t, 1); | |
299 len++; | |
300 url_buf[len] = 0; | |
301 } | |
302 | |
303 t++; | |
304 | |
305 } | |
306 | |
307 | |
308 } | |
309 | |
310 if (*c == 0) | |
311 break; | |
312 | |
313 text[cnt++] = *c; | |
314 c++; | |
315 | |
316 } | |
317 text[cnt]=0; | |
845
647b110f7a1a
[gaim-migrate @ 855]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
831
diff
changeset
|
318 g_free(cpy); |
1 | 319 return cnt; |
320 } | |
321 | |
322 | |
373
1d29321843b0
[gaim-migrate @ 383]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
323 FILE *open_log_file (char *name) |
1 | 324 { |
79 | 325 char *buf; |
326 char *buf2; | |
1 | 327 char log_all_file[256]; |
328 struct log_conversation *l; | |
329 struct stat st; | |
330 int flag = 0; | |
331 FILE *fd; | |
332 int res; | |
333 | |
334 if (!(general_options & OPT_GEN_LOG_ALL)) { | |
335 | |
373
1d29321843b0
[gaim-migrate @ 383]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
336 l = find_log_info(name); |
1 | 337 if (!l) |
338 return NULL; | |
339 | |
340 if (stat(l->filename, &st) < 0) | |
341 flag = 1; | |
342 | |
343 fd = fopen(l->filename, "a"); | |
344 | |
345 if (flag) { /* is a new file */ | |
346 fprintf(fd, "<HTML><HEAD><TITLE>" ); | |
373
1d29321843b0
[gaim-migrate @ 383]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
347 fprintf(fd, "IM Sessions with %s", name ); |
1 | 348 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"ffffff\">\n" ); |
349 } | |
350 | |
351 return fd; | |
352 } | |
353 | |
79 | 354 buf = g_malloc(BUF_LONG); |
355 buf2 = g_malloc(BUF_LONG); | |
356 | |
1 | 357 /* Dont log yourself */ |
358 g_snprintf(log_all_file, 256, "%s/.gaim", getenv("HOME")); | |
359 | |
360 stat(log_all_file, &st); | |
361 if (!S_ISDIR(st.st_mode)) | |
362 unlink(log_all_file); | |
363 | |
364 fd = fopen(log_all_file, "r"); | |
365 | |
366 if (!fd) { | |
367 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR); | |
368 if (res < 0) { | |
369 g_snprintf(buf, BUF_LONG, "Unable to make directory %s for logging", log_all_file); | |
370 do_error_dialog(buf, "Error!"); | |
371 g_free(buf); | |
372 g_free(buf2); | |
373 return NULL; | |
374 } | |
375 } else | |
376 fclose(fd); | |
377 | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
927
diff
changeset
|
378 g_snprintf(log_all_file, 256, "%s/.gaim/logs", getenv("HOME")); |
1 | 379 |
380 if (stat(log_all_file, &st) < 0) | |
381 flag = 1; | |
382 if (!S_ISDIR(st.st_mode)) | |
383 unlink(log_all_file); | |
384 | |
385 fd = fopen(log_all_file, "r"); | |
386 if (!fd) { | |
387 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR); | |
388 if (res < 0) { | |
389 g_snprintf(buf, BUF_LONG, "Unable to make directory %s for logging", log_all_file); | |
390 do_error_dialog(buf, "Error!"); | |
391 g_free(buf); | |
392 g_free(buf2); | |
393 return NULL; | |
394 } | |
395 } else | |
396 fclose(fd); | |
397 | |
398 | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
927
diff
changeset
|
399 g_snprintf(log_all_file, 256, "%s/.gaim/logs/%s.log", getenv("HOME"), normalize(name)); |
1 | 400 |
401 if (stat(log_all_file, &st) < 0) | |
402 flag = 1; | |
403 | |
404 sprintf(debug_buff,"Logging to: \"%s\"\n", log_all_file); | |
405 debug_print(debug_buff); | |
406 | |
407 fd = fopen(log_all_file, "a"); | |
408 | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
927
diff
changeset
|
409 if (fd && flag) { /* is a new file */ |
1 | 410 fprintf(fd, "<HTML><HEAD><TITLE>" ); |
373
1d29321843b0
[gaim-migrate @ 383]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
411 fprintf(fd, "IM Sessions with %s", name ); |
1 | 412 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"ffffff\">\n" ); |
413 } | |
25 | 414 |
415 g_free(buf); | |
416 g_free(buf2); | |
1 | 417 return fd; |
418 } | |
419 | |
420 | |
254
fa67d29b53d5
[gaim-migrate @ 264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
421 /* we only need this for TOC, because messages must be escaped */ |
1 | 422 int escape_message(char *msg) |
423 { | |
424 char *c, *cpy; | |
425 int cnt=0; | |
426 /* Assumes you have a buffer able to cary at least BUF_LEN * 2 bytes */ | |
427 if (strlen(msg) > BUF_LEN) { | |
428 sprintf(debug_buff, "Warning: truncating message to 2048 bytes\n"); | |
429 debug_print(debug_buff); | |
430 msg[2047]='\0'; | |
431 } | |
432 | |
433 cpy = g_strdup(msg); | |
434 c = cpy; | |
435 while(*c) { | |
436 switch(*c) { | |
437 case '$': | |
438 case '[': | |
439 case ']': | |
440 case '(': | |
441 case ')': | |
442 case '#': | |
443 msg[cnt++]='\\'; | |
444 /* Fall through */ | |
445 default: | |
446 msg[cnt++]=*c; | |
447 } | |
448 c++; | |
449 } | |
450 msg[cnt]='\0'; | |
451 g_free(cpy); | |
452 return cnt; | |
453 } | |
454 | |
254
fa67d29b53d5
[gaim-migrate @ 264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
455 /* we don't need this for oscar either */ |
1 | 456 int escape_text(char *msg) |
457 { | |
458 char *c, *cpy; | |
459 int cnt=0; | |
79 | 460 /* Assumes you have a buffer able to cary at least BUF_LEN * 4 bytes */ |
1 | 461 if (strlen(msg) > BUF_LEN) { |
462 fprintf(stderr, "Warning: truncating message to 2048 bytes\n"); | |
463 msg[2047]='\0'; | |
464 } | |
465 | |
466 cpy = g_strdup(msg); | |
467 c = cpy; | |
468 while(*c) { | |
960
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
927
diff
changeset
|
469 switch(*c) { |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
927
diff
changeset
|
470 case '\n': |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
927
diff
changeset
|
471 msg[cnt++] = '<'; |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
927
diff
changeset
|
472 msg[cnt++] = 'B'; |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
927
diff
changeset
|
473 msg[cnt++] = 'R'; |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
927
diff
changeset
|
474 msg[cnt++] = '>'; |
fa681641643d
[gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
927
diff
changeset
|
475 break; |
1 | 476 case '{': |
477 case '}': | |
478 case '\\': | |
479 case '"': | |
480 msg[cnt++]='\\'; | |
481 /* Fall through */ | |
482 default: | |
483 msg[cnt++]=*c; | |
484 } | |
485 c++; | |
486 } | |
487 msg[cnt]='\0'; | |
488 g_free(cpy); | |
489 return cnt; | |
490 } | |
491 | |
492 char * escape_text2(char *msg) | |
493 { | |
494 char *c, *cpy; | |
495 char *woo; | |
496 int cnt=0; | |
497 /* Assumes you have a buffer able to cary at least BUF_LEN * 2 bytes */ | |
498 if (strlen(msg) > BUF_LEN) { | |
499 fprintf(stderr, "Warning: truncating message to 2048 bytes\n"); | |
500 msg[2047]='\0'; | |
501 } | |
502 | |
79 | 503 woo = malloc(strlen(msg) * 2); |
1 | 504 cpy = g_strdup(msg); |
505 c = cpy; | |
506 while(*c) { | |
507 switch(*c) { | |
508 case '\n': | |
509 woo[cnt++] = '<'; | |
510 woo[cnt++] = 'B'; | |
511 woo[cnt++] = 'R'; | |
512 woo[cnt++] = '>'; | |
513 break; | |
514 case '{': | |
515 case '}': | |
516 case '\\': | |
517 case '"': | |
518 woo[cnt++]='\\'; | |
519 /* Fall through */ | |
520 default: | |
521 woo[cnt++]=*c; | |
522 } | |
523 c++; | |
524 } | |
525 woo[cnt]='\0'; | |
26 | 526 |
527 g_free (cpy); | |
1 | 528 return woo; |
529 } | |
530 | |
531 | |
532 char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" | |
533 "0123456789+/"; | |
534 | |
535 | |
536 char *tobase64(char *text) | |
537 { | |
538 char *out = NULL; | |
539 char *c; | |
540 unsigned int tmp = 0; | |
541 int len = 0, n = 0; | |
542 | |
543 c = text; | |
544 | |
545 while(c) { | |
546 tmp = tmp << 8; | |
547 tmp += *c; | |
548 n++; | |
549 | |
550 if (n == 3) { | |
551 out = g_realloc(out, len+4); | |
552 out[len] = alphabet[(tmp >> 18) & 0x3f]; | |
553 out[len+1] = alphabet[(tmp >> 12) & 0x3f]; | |
554 out[len+2] = alphabet[(tmp >> 6) & 0x3f]; | |
555 out[len+3] = alphabet[tmp & 0x3f]; | |
556 len += 4; | |
557 tmp = 0; | |
558 n = 0; | |
559 } | |
560 c++; | |
561 } | |
562 switch(n) { | |
563 | |
564 case 2: | |
565 out = g_realloc(out, len+5); | |
566 out[len] = alphabet[(tmp >> 12) & 0x3f]; | |
567 out[len+1] = alphabet[(tmp >> 6) & 0x3f]; | |
568 out[len+2] = alphabet[tmp & 0x3f]; | |
569 out[len+3] = '='; | |
570 out[len+4] = 0; | |
571 break; | |
572 case 1: | |
573 out = g_realloc(out, len+4); | |
574 out[len] = alphabet[(tmp >> 6) & 0x3f]; | |
575 out[len+1] = alphabet[tmp & 0x3f]; | |
576 out[len+2] = '='; | |
577 out[len+3] = 0; | |
578 break; | |
579 case 0: | |
580 out = g_realloc(out, len+2); | |
581 out[len] = '='; | |
582 out[len+1] = 0; | |
583 break; | |
584 } | |
585 return out; | |
586 } | |
587 | |
588 | |
589 char *frombase64(char *text) | |
590 { | |
591 char *out = NULL; | |
592 char tmp = 0; | |
593 char *c; | |
594 gint32 tmp2 = 0; | |
595 int len = 0, n = 0; | |
596 | |
597 c = text; | |
598 | |
599 while(*c) { | |
600 if (*c >= 'A' && *c <= 'Z') { | |
601 tmp = *c - 'A'; | |
602 } else if (*c >= 'a' && *c <= 'z') { | |
603 tmp = 26 + (*c - 'a'); | |
604 } else if (*c >= '0' && *c <= 57) { | |
605 tmp = 52 + (*c - '0'); | |
606 } else if (*c == '+') { | |
607 tmp = 62; | |
608 } else if (*c == '/') { | |
609 tmp = 63; | |
610 } else if (*c == '=') { | |
611 if (n == 3) { | |
612 out = g_realloc(out, len + 2); | |
613 out[len] = (char)(tmp2 >> 10) & 0xff; | |
614 len++; | |
615 out[len] = (char)(tmp2 >> 2) & 0xff; | |
616 len++; | |
617 } else if (n == 2) { | |
618 out = g_realloc(out, len + 1); | |
619 out[len] = (char)(tmp2 >> 4) & 0xff; | |
620 len++; | |
621 } | |
622 break; | |
623 } | |
624 tmp2 = ((tmp2 << 6) | (tmp & 0xff)); | |
625 n++; | |
626 if (n == 4) { | |
627 out = g_realloc(out, len + 3); | |
628 out[len] = (char)((tmp2 >> 16) & 0xff); | |
629 len++; | |
630 out[len] = (char)((tmp2 >> 8) & 0xff); | |
631 len++; | |
632 out[len] = (char)(tmp2 & 0xff); | |
633 len++; | |
634 tmp2 = 0; | |
635 n = 0; | |
636 } | |
637 c++; | |
638 } | |
639 | |
194
d7690984c0f1
[gaim-migrate @ 204]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
640 out = g_realloc(out, len+1); |
1 | 641 out[len] = 0; |
642 | |
643 return out; | |
644 } | |
645 | |
646 | |
647 char *normalize(const char *s) | |
648 { | |
649 static char buf[BUF_LEN]; | |
650 char *t, *u; | |
651 int x=0; | |
652 | |
79 | 653 g_return_val_if_fail ((s != NULL), NULL); |
26 | 654 |
655 u = t = g_strdup(s); | |
1 | 656 |
657 strcpy(t, s); | |
658 g_strdown(t); | |
659 | |
26 | 660 while(*t && (x < BUF_LEN - 1)) { |
1 | 661 if (*t != ' ') { |
662 buf[x] = *t; | |
663 x++; | |
664 } | |
665 t++; | |
666 } | |
667 buf[x]='\0'; | |
668 g_free(u); | |
669 return buf; | |
670 } | |
671 | |
672 char *date() | |
673 { | |
674 static char date[80]; | |
675 time_t tme; | |
676 time(&tme); | |
677 strftime(date, sizeof(date), "%H:%M:%S", localtime(&tme)); | |
678 return date; | |
679 } | |
680 | |
681 | |
682 gint clean_pid(void *dummy) | |
683 { | |
684 int status; | |
685 pid_t pid; | |
686 | |
687 pid = waitpid(-1, &status, WNOHANG); | |
688 | |
689 if (pid == 0) | |
690 return TRUE; | |
691 | |
692 return FALSE; | |
693 } | |
694 | |
695 void aol_icon(GdkWindow *w) | |
696 { | |
697 #ifndef _WIN32 | |
698 if (icon_pm == NULL) { | |
699 icon_pm = gdk_pixmap_create_from_xpm_d(w, &icon_bm, | |
700 NULL, (gchar **)aimicon_xpm); | |
701 } | |
702 gdk_window_set_icon(w, NULL, icon_pm, icon_bm); | |
10 | 703 if (mainwindow) gdk_window_set_group(w, mainwindow->window); |
1 | 704 #endif |
705 } | |
706 | |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1009
diff
changeset
|
707 struct aim_user *find_user(const char *name, int protocol) |
1 | 708 { |
709 char *who = g_strdup(normalize(name)); | |
710 GList *usr = aim_users; | |
711 struct aim_user *u; | |
712 | |
713 while(usr) { | |
714 u = (struct aim_user *)usr->data; | |
715 if (!strcmp(normalize(u->username), who)) { | |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1009
diff
changeset
|
716 if (protocol != -1) { |
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1009
diff
changeset
|
717 if (u->protocol == protocol) { |
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1009
diff
changeset
|
718 g_free(who); |
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1009
diff
changeset
|
719 return u; |
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1009
diff
changeset
|
720 } |
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1009
diff
changeset
|
721 } else { |
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1009
diff
changeset
|
722 g_free(who); |
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1009
diff
changeset
|
723 return u; |
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1009
diff
changeset
|
724 } |
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1009
diff
changeset
|
725 |
1 | 726 } |
727 usr = usr->next; | |
728 } | |
729 g_free(who); | |
730 return NULL; | |
731 } | |
180 | 732 |
733 void check_gaim_versions() | |
734 { | |
735 char *cur_ver; | |
736 char *tmp; | |
737 | |
738 tmp = (char *)malloc(BUF_LONG); | |
739 | |
740 cur_ver = (char *)grab_url("http://www.marko.net/gaim/latest-gaim"); | |
741 | |
742 if (!strncasecmp(cur_ver, "g00", 3)) | |
743 { | |
278
29e1669b006b
[gaim-migrate @ 288]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
254
diff
changeset
|
744 g_free(cur_ver); |
29e1669b006b
[gaim-migrate @ 288]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
254
diff
changeset
|
745 g_free(tmp); |
180 | 746 return; |
747 } | |
748 | |
749 g_snprintf(tmp, BUF_LONG, "%s", strstr(cur_ver, "plain")+9); | |
750 g_strchomp(tmp); | |
751 | |
278
29e1669b006b
[gaim-migrate @ 288]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
254
diff
changeset
|
752 if (strcmp(tmp, latest_ver)) |
180 | 753 { |
754 g_snprintf(cur_ver, BUF_LONG, "GAIM v%s is now available.\n\nDownload it at http://www.marko.net/gaim\n", tmp); | |
755 | |
756 do_error_dialog(cur_ver, "GAIM - New Version!"); | |
757 strcpy(latest_ver, tmp); | |
758 save_prefs(); | |
759 } | |
760 | |
761 free(tmp); | |
762 free(cur_ver); | |
763 } | |
764 | |
765 | |
206 | 766 /* |
767 | |
768 This function was taken from EveryBuddy and was written by | |
769 Torrey Searle. tsearle@valhalla.marko.net | |
770 | |
771 http://www.everybuddy.com | |
772 | |
773 */ | |
774 | |
209 | 775 void spell_checker(GtkWidget * text) |
206 | 776 { |
777 int start = 0; | |
778 int end = 0; | |
779 static GdkColor * color = NULL; | |
780 int ignore = 0; | |
781 int point = gtk_editable_get_position(GTK_EDITABLE(text)); | |
782 | |
783 GString * string; | |
784 | |
785 if( color == NULL ) | |
786 { | |
787 GdkColormap * gc = gtk_widget_get_colormap( text ); | |
788 color = g_new0(GdkColor, 1); | |
789 color->red = 255 * 256; | |
790 gdk_colormap_alloc_color(gc, color, FALSE, TRUE); | |
791 } | |
792 | |
793 | |
794 | |
795 end = point-1; | |
796 for( start = end-1; start >= 0; start-- ) | |
797 { | |
798 if((isspace(GTK_TEXT_INDEX(GTK_TEXT(text), start)) || start == 0) | |
799 && !ignore) | |
800 { | |
801 char * word; | |
802 FILE * file; | |
803 char buff[1024]; | |
804 word = gtk_editable_get_chars( GTK_EDITABLE(text), start, end ); | |
805 g_snprintf(buff, 1024, "echo \"%s\" | ispell -l", word ); | |
806 file = popen(buff, "r"); | |
807 | |
808 buff[0] = 0; | |
809 fgets(buff, 255, file); | |
810 | |
811 if(strlen(buff) > 0 ) | |
812 { | |
813 string = g_string_new(word); | |
814 gtk_text_set_point(GTK_TEXT(text), end); | |
815 gtk_text_backward_delete(GTK_TEXT(text), end-start); | |
816 gtk_text_insert( GTK_TEXT(text), NULL, color, NULL, | |
817 string->str, string->len ); | |
818 g_string_free( string, TRUE ); | |
819 } | |
820 else | |
821 { | |
822 string = g_string_new(word); | |
823 gtk_text_set_point(GTK_TEXT(text), end); | |
824 gtk_text_backward_delete(GTK_TEXT(text), end-start); | |
825 gtk_text_insert( GTK_TEXT(text), NULL, &(text->style->fg[0]), NULL, | |
826 string->str, string->len ); | |
827 g_string_free( string, TRUE ); | |
828 } | |
829 pclose( file); | |
846
4b05985bae5e
[gaim-migrate @ 856]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
845
diff
changeset
|
830 g_free(word); |
206 | 831 break; |
832 } | |
833 else if(!isalpha(GTK_TEXT_INDEX(GTK_TEXT(text), start))) | |
834 { | |
835 ignore = 1; | |
836 } | |
837 } | |
838 gtk_text_set_point(GTK_TEXT(text), point); | |
839 | |
840 } | |
841 | |
592
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
842 /* Look for %n, %d, or %t in msg, and replace with the sender's name, date, |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
843 or time */ |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
844 char *away_subs(char *msg, char *name) |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
845 { |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
846 char *c; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
847 static char cpy[BUF_LONG]; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
848 int cnt=0; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
849 time_t t = time(0); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
850 struct tm *tme = localtime(&t); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
851 char tmp[20]; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
852 |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
853 cpy[0] = '\0'; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
854 c = msg; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
855 while(*c) { |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
856 switch(*c) { |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
857 case '%': |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
858 if (*(c+1)) { |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
859 switch (*(c+1)) { |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
860 case 'n': |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
861 // append name |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
862 strcpy (cpy+cnt, name); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
863 cnt += strlen(name); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
864 c++; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
865 break; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
866 case 'd': |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
867 // append date |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
868 strftime (tmp, 20, "%D", tme); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
869 strcpy (cpy+cnt, tmp); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
870 cnt += strlen(tmp); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
871 c++; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
872 break; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
873 case 't': |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
874 // append time |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
875 strftime (tmp, 20, "%r", tme); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
876 strcpy (cpy+cnt, tmp); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
877 cnt += strlen(tmp); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
878 c++; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
879 break; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
880 default: |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
881 cpy[cnt++]=*c; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
882 } |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
883 } |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
884 break; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
885 default: |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
886 cpy[cnt++]=*c; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
887 } |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
888 c++; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
889 } |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
890 cpy[cnt]='\0'; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
891 return(cpy); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
892 } |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
893 |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
894 GtkWidget *picture_button(GtkWidget *window, char *text, char **xpm) |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
895 { |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
896 GtkWidget *button; |
619 | 897 GtkWidget *button_box, *button_box_2, *button_box_3; |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
898 GtkWidget *label; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
899 GdkBitmap *mask; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
900 GdkPixmap *pm; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
901 GtkWidget *pixmap; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
902 |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
903 button = gtk_button_new(); |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
904 if (display_options & OPT_DISP_COOL_LOOK) |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
905 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
906 |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
907 button_box = gtk_hbox_new(FALSE, 5); |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
908 gtk_container_add(GTK_CONTAINER(button), button_box); |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
909 |
619 | 910 button_box_2 = gtk_hbox_new(FALSE, 0); |
911 button_box_3 = gtk_hbox_new(FALSE, 0); | |
912 gtk_box_pack_start(GTK_BOX(button_box), button_box_2, TRUE, TRUE, 0); | |
913 gtk_box_pack_start(GTK_BOX(button_box), button_box_3, TRUE, TRUE, 0); | |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
914 pm = gdk_pixmap_create_from_xpm_d(window->window, &mask, NULL, xpm); |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
915 pixmap = gtk_pixmap_new(pm, mask); |
619 | 916 gtk_box_pack_end(GTK_BOX(button_box_2), pixmap, FALSE, FALSE, 0); |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
917 |
623 | 918 if (text) |
919 { | |
920 label = gtk_label_new(text); | |
921 gtk_box_pack_start(GTK_BOX(button_box_3), label, FALSE, FALSE, 2); | |
967
17ff662183b2
[gaim-migrate @ 977]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
963
diff
changeset
|
922 gtk_widget_show(label); |
623 | 923 } |
619 | 924 |
925 gtk_widget_show(pixmap); | |
926 gtk_widget_show(button_box_2); | |
927 gtk_widget_show(button_box_3); | |
928 gtk_widget_show(button_box); | |
651 | 929 |
726 | 930 /* this causes clipping on lots of buttons with long text */ |
931 /* gtk_widget_set_usize(button, 75, 30);*/ | |
619 | 932 gtk_widget_show(button); |
644
b3900e312d8e
[gaim-migrate @ 654]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
623
diff
changeset
|
933 gdk_pixmap_unref(pm); |
804
17def2bb9720
[gaim-migrate @ 814]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
770
diff
changeset
|
934 gdk_bitmap_unref(mask); |
619 | 935 |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
936 return button; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
937 } |
623 | 938 |
759
9389216aae29
[gaim-migrate @ 769]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
754
diff
changeset
|
939 static GtkTooltips *tips = NULL; |
915
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
940 GtkWidget *picture_button2(GtkWidget *window, char *text, char **xpm, short dispstyle) |
623 | 941 { |
942 GtkWidget *button; | |
943 GtkWidget *button_box, *button_box_2; | |
944 GdkBitmap *mask; | |
945 GdkPixmap *pm; | |
946 GtkWidget *pixmap; | |
754 | 947 GtkWidget *label; |
623 | 948 |
759
9389216aae29
[gaim-migrate @ 769]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
754
diff
changeset
|
949 if (!tips) tips = gtk_tooltips_new(); |
623 | 950 button = gtk_button_new(); |
951 if (display_options & OPT_DISP_COOL_LOOK) | |
952 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
953 | |
651 | 954 button_box = gtk_hbox_new(FALSE, 0); |
623 | 955 gtk_container_add(GTK_CONTAINER(button), button_box); |
956 | |
754 | 957 button_box_2 = gtk_vbox_new(FALSE, 0); |
623 | 958 |
959 gtk_box_pack_start(GTK_BOX(button_box), button_box_2, TRUE, TRUE, 0); | |
967
17ff662183b2
[gaim-migrate @ 977]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
963
diff
changeset
|
960 gtk_widget_show(button_box_2); |
17ff662183b2
[gaim-migrate @ 977]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
963
diff
changeset
|
961 gtk_widget_show(button_box); |
915
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
962 if (dispstyle == 2 || dispstyle == 0) { |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
963 pm = gdk_pixmap_create_from_xpm_d(window->window, &mask, NULL, xpm); |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
964 pixmap = gtk_pixmap_new(pm, mask); |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
965 gtk_box_pack_start(GTK_BOX(button_box_2), pixmap, FALSE, FALSE, 0); |
754 | 966 |
915
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
967 gtk_widget_show(pixmap); |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
968 |
967
17ff662183b2
[gaim-migrate @ 977]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
963
diff
changeset
|
969 gdk_pixmap_unref(pm); |
17ff662183b2
[gaim-migrate @ 977]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
963
diff
changeset
|
970 gdk_bitmap_unref(mask); |
915
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
971 } |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
972 |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
973 if (dispstyle == 2 || dispstyle == 1) |
754 | 974 { |
975 label = gtk_label_new(text); | |
976 gtk_widget_show(label); | |
977 gtk_box_pack_end(GTK_BOX(button_box_2), label, FALSE, FALSE, 0); | |
978 } | |
623 | 979 |
967
17ff662183b2
[gaim-migrate @ 977]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
963
diff
changeset
|
980 gtk_tooltips_set_tip(tips, button, text, "Gaim"); |
623 | 981 gtk_widget_show(button); |
982 return button; | |
983 } | |
984 | |
684
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
985 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
986 /* remove leading whitespace from a string */ |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
987 char *remove_spaces (char *str) |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
988 { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
989 int i; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
990 char *new; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
991 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
992 if (str == NULL) |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
993 return NULL; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
994 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
995 i = strspn (str, " \t\n\r\f"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
996 new = &str[i]; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
997 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
998 return new; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
999 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1000 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1001 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1002 /* translate an AIM 3 buddylist (*.lst) to a GAIM buddylist */ |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1003 void translate_lst (FILE *src_fp, char *dest) |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1004 { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1005 char line[BUF_LEN], *line2; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1006 char *name; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1007 int i; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1008 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1009 sprintf (dest, "m 1\n"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1010 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1011 while (fgets (line, BUF_LEN, src_fp)) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1012 line2 = remove_spaces (line); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1013 if (strstr (line2, "group") == line2) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1014 name = strpbrk (line2, " \t\n\r\f") + 1; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1015 strcat (dest, "g "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1016 for (i = 0; i < strcspn (name, "\n\r"); i++) |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1017 if (name[i] != '\"') |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1018 strncat (dest, &name[i], 1); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1019 strcat (dest, "\n"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1020 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1021 if (strstr (line2, "buddy") == line2) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1022 name = strpbrk (line2, " \t\n\r\f") + 1; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1023 strcat (dest, "b "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1024 for (i = 0; i < strcspn (name, "\n\r"); i++) |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1025 if (name[i] != '\"') |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1026 strncat (dest, &name[i], 1); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1027 strcat (dest, "\n"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1028 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1029 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1030 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1031 return; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1032 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1033 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1034 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1035 /* translate an AIM 4 buddylist (*.blt) to GAIM format */ |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1036 void translate_blt (FILE *src_fp, char *dest) |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1037 { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1038 int i; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1039 char line[BUF_LEN]; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1040 char *buddy; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1041 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1042 sprintf (dest, "m 1\n"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1043 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1044 while (strstr (fgets (line, BUF_LEN, src_fp), "Buddy") == NULL) ; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1045 while (strstr (fgets (line, BUF_LEN, src_fp), "list") == NULL) ; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1046 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1047 while (1) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1048 fgets (line, BUF_LEN, src_fp); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1049 if (strchr (line, '}') != NULL) |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1050 break; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1051 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1052 /* Syntax starting with "<group> {" */ |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1053 if (strchr (line, '{') != NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1054 strcat (dest, "g "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1055 buddy = remove_spaces (strtok (line, "{")); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1056 for (i = 0; i < strlen(buddy); i++) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1057 if (buddy[i] != '\"') |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1058 strncat (dest, &buddy[i], 1); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1059 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1060 strcat (dest, "\n"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1061 while (strchr (fgets (line, BUF_LEN, src_fp), '}') == NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1062 buddy = remove_spaces (line); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1063 strcat (dest, "b "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1064 if (strchr (buddy, '\"') != NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1065 strncat (dest, &buddy[1], strlen(buddy)-3); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1066 strcat (dest, "\n"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1067 } else |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1068 strcat (dest, buddy); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1069 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1070 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1071 /* Syntax "group buddy buddy ..." */ |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1072 else { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1073 buddy = remove_spaces (strtok (line, " \n")); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1074 strcat (dest, "g "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1075 if (strchr (buddy, '\"') != NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1076 strcat (dest, &buddy[1]); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1077 strcat (dest, " "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1078 buddy = remove_spaces (strtok (NULL, " \n")); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1079 while (strchr (buddy, '\"') == NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1080 strcat (dest, buddy); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1081 strcat (dest, " "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1082 buddy = remove_spaces (strtok (NULL, " \n")); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1083 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1084 strncat (dest, buddy, strlen(buddy)-1); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1085 } else { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1086 strcat (dest, buddy); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1087 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1088 strcat (dest, "\n"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1089 while ((buddy = remove_spaces (strtok (NULL, " \n"))) != NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1090 strcat (dest, "b "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1091 if (strchr (buddy, '\"') != NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1092 strcat (dest, &buddy[1]); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1093 strcat (dest, " "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1094 buddy = remove_spaces (strtok (NULL, " \n")); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1095 while (strchr (buddy, '\"') == NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1096 strcat (dest, buddy); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1097 strcat (dest, " "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1098 buddy = remove_spaces (strtok (NULL, " \n")); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1099 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1100 strncat (dest, buddy, strlen(buddy)-1); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1101 } else { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1102 strcat (dest, buddy); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1103 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1104 strcat (dest, "\n"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1105 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1106 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1107 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1108 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1109 return; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1110 } |
764 | 1111 |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1112 char *stylize(gchar *text, int length) |
764 | 1113 { |
1114 gchar *buf; | |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1115 char tmp[length]; |
764 | 1116 |
1117 buf = g_malloc(length); | |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1118 g_snprintf(buf, length, "%s", text); |
764 | 1119 |
831
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1120 if (font_options & OPT_FONT_BOLD) { |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1121 g_snprintf(tmp, length, "<B>%s</B>", buf); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1122 strcpy(buf, tmp); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1123 } |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1124 |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1125 if (font_options & OPT_FONT_ITALIC) { |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1126 g_snprintf(tmp, length, "<I>%s</I>", buf); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1127 strcpy(buf, tmp); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1128 } |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1129 |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1130 if (font_options & OPT_FONT_UNDERLINE) { |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1131 g_snprintf(tmp, length, "<U>%s</U>", buf); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1132 strcpy(buf, tmp); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1133 } |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1134 |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1135 if (font_options & OPT_FONT_STRIKE) { |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1136 g_snprintf(tmp, length, "<S>%s</S>", buf); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1137 strcpy(buf, tmp); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1138 } |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1139 |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1140 if (font_options & OPT_FONT_FACE) { |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1141 g_snprintf(tmp, length, "<FONT FACE=\"%s\">%s</FONT>", fontface, buf); |
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1142 strcpy(buf, tmp); |
764 | 1143 } |
1144 | |
831
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1145 if (font_options & OPT_FONT_FGCOL) { |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1146 g_snprintf(tmp, length, "<FONT COLOR=\"#%02X%02X%02X\">%s</FONT>", fgcolor.red, fgcolor.green, fgcolor.blue, buf); |
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1147 strcpy(buf, tmp); |
764 | 1148 } |
1149 | |
831
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1150 if (font_options & OPT_FONT_BGCOL) { |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1151 g_snprintf(tmp, length, "<BODY BGCOLOR=\"#%02X%02X%02X\">%s</BODY>", bgcolor.red, bgcolor.green, bgcolor.blue, buf); |
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1152 strcpy(buf, tmp); |
764 | 1153 } |
1154 | |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1155 return buf; |
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1156 } |
915
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1157 |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1158 int set_dispstyle (int chat) |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1159 { |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1160 int dispstyle; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1161 |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1162 if (chat) { |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1163 switch (display_options & (OPT_DISP_CHAT_BUTTON_TEXT | |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1164 OPT_DISP_CHAT_BUTTON_XPM)) { |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1165 case OPT_DISP_CHAT_BUTTON_TEXT: |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1166 dispstyle = 1; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1167 break; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1168 case OPT_DISP_CHAT_BUTTON_XPM: |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1169 dispstyle = 0; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1170 break; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1171 default: /* both or neither */ |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1172 dispstyle = 2; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1173 break; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1174 } |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1175 } else { |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1176 switch (display_options & (OPT_DISP_CONV_BUTTON_TEXT | |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1177 OPT_DISP_CONV_BUTTON_XPM)) { |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1178 case OPT_DISP_CONV_BUTTON_TEXT: |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1179 dispstyle = 1; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1180 break; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1181 case OPT_DISP_CONV_BUTTON_XPM: |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1182 dispstyle = 0; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1183 break; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1184 default: /* both or neither */ |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1185 dispstyle = 2; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1186 break; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1187 } |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1188 } |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1189 return dispstyle; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1190 } |
1009
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1191 |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1192 |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1193 void show_usage (int mode, char *name) |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1194 { |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1195 switch (mode) { |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1196 case 0: /* full help text */ |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1197 printf ("Usage: %s [OPTION]...\n\n" |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1198 " -a, --acct display account editor window\n" |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1199 " -l, --login[=NAME] automatically login (optional argument NAME specifies\n" |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1200 " account(s) to use)\n" |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1201 " -u, --user=NAME use account NAME\n" |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1202 " -v, --version display version information window\n" |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1203 " -h, --help display this help and exit\n", name); |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1204 break; |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1205 case 1: /* short message */ |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1206 printf ("Try `%s -h' for more information.\n", name); |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1207 break; |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1208 } |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1209 } |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1210 |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1211 |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1212 void set_first_user (char *name) |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1213 { |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1214 struct aim_user *u; |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1215 |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1009
diff
changeset
|
1216 u = find_user (name, -1); |
1009
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1217 |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1218 if (!u) { /* new user */ |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1219 u = g_new0(struct aim_user, 1); |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1220 g_snprintf(u->username, sizeof(u->username), "%s", name); |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1221 u->protocol = 0 /* PROTO_TOC */; |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1222 aim_users = g_list_prepend (aim_users, u); |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1223 } else { /* user already exists */ |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1224 aim_users = g_list_remove (aim_users, u); |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1225 aim_users = g_list_prepend (aim_users, u); |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1226 } |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1227 save_prefs(); |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1228 } |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1229 |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1230 |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1231 /* <name> is a comma-separated list of names, or NULL |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1232 if NULL and there is at least one user defined in .gaimrc, try to login. |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1233 if not NULL, parse <name> into separate strings, look up each one in |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1234 .gaimrc and, if it's there, try to login. |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1235 returns: 0 if successful |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1236 -1 if no user was found that had a saved password |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1237 */ |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1238 int do_auto_login (char *name) |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1239 { |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1240 struct aim_user *u; |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1241 char **names, **n, *first = NULL; |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1242 int retval = -1; |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1243 |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1244 if (name != NULL) { /* list of names given */ |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1245 names = g_strsplit (name, ",", 32); |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1246 for (n = names; *n != NULL; n++) { |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1247 printf ("user %s...\n", *n); |
1030
38452403563b
[gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1009
diff
changeset
|
1248 u = find_user(*n, -1); |
1009
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1249 if (u) { /* found a user */ |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1250 if (first == NULL) |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1251 first = g_strdup (*n); |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1252 if (u->options & OPT_USR_REM_PASS) { |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1253 printf ("got user %s\n", *n); |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1254 retval = 0; |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1255 serv_login(u); |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1256 } |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1257 } |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1258 } |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1259 /* make the first user listed the default */ |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1260 if (first != NULL) |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1261 set_first_user (first); |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1262 g_strfreev (names); |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1263 g_free (first); |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1264 } else { /* no name given, use default */ |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1265 u = (struct aim_user *)aim_users->data; |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1266 if (u->options & OPT_USR_REM_PASS) { |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1267 retval = 0; |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1268 serv_login(u); |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1269 } |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1270 } |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1271 |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1272 return retval; |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1273 } |
d496fe2614a6
[gaim-migrate @ 1019]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
976
diff
changeset
|
1274 |
1035
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1275 |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1276 int file_is_dir (char *path, GtkWidget *w) |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1277 { |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1278 struct stat st; |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1279 char *name; |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1280 |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1281 if (stat(path, &st) == 0 && S_ISDIR(st.st_mode)) { |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1282 /* append a / if needed */ |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1283 if (path[strlen(path)-1] != '/') |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1284 name = g_strconcat(path,"/",NULL); |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1285 else |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1286 name = g_strdup(path); |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1287 gtk_file_selection_set_filename(GTK_FILE_SELECTION(w), name); |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1288 g_free(name); |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1289 return 1; |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1290 } |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1291 |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1292 return 0; |
80a47e3b1bca
[gaim-migrate @ 1045]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
1030
diff
changeset
|
1293 } |