Mercurial > pidgin.yaz
annotate src/util.c @ 976:2586b2a3725e
[gaim-migrate @ 986]
warning works better, i hope :-P for every one fixme i get rid of i add 3, i swear
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Wed, 11 Oct 2000 04:30:26 +0000 |
parents | 9eb07b383df4 |
children | d496fe2614a6 |
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 | |
707 struct aim_user *find_user(const char *name) | |
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)) { | |
716 g_free(who); | |
717 return u; | |
718 } | |
719 usr = usr->next; | |
720 } | |
721 g_free(who); | |
722 return NULL; | |
723 } | |
180 | 724 |
725 void check_gaim_versions() | |
726 { | |
727 char *cur_ver; | |
728 char *tmp; | |
729 | |
730 tmp = (char *)malloc(BUF_LONG); | |
731 | |
732 cur_ver = (char *)grab_url("http://www.marko.net/gaim/latest-gaim"); | |
733 | |
734 if (!strncasecmp(cur_ver, "g00", 3)) | |
735 { | |
278
29e1669b006b
[gaim-migrate @ 288]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
254
diff
changeset
|
736 g_free(cur_ver); |
29e1669b006b
[gaim-migrate @ 288]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
254
diff
changeset
|
737 g_free(tmp); |
180 | 738 return; |
739 } | |
740 | |
741 g_snprintf(tmp, BUF_LONG, "%s", strstr(cur_ver, "plain")+9); | |
742 g_strchomp(tmp); | |
743 | |
278
29e1669b006b
[gaim-migrate @ 288]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
254
diff
changeset
|
744 if (strcmp(tmp, latest_ver)) |
180 | 745 { |
746 g_snprintf(cur_ver, BUF_LONG, "GAIM v%s is now available.\n\nDownload it at http://www.marko.net/gaim\n", tmp); | |
747 | |
748 do_error_dialog(cur_ver, "GAIM - New Version!"); | |
749 strcpy(latest_ver, tmp); | |
750 save_prefs(); | |
751 } | |
752 | |
753 free(tmp); | |
754 free(cur_ver); | |
755 } | |
756 | |
757 | |
206 | 758 /* |
759 | |
760 This function was taken from EveryBuddy and was written by | |
761 Torrey Searle. tsearle@valhalla.marko.net | |
762 | |
763 http://www.everybuddy.com | |
764 | |
765 */ | |
766 | |
209 | 767 void spell_checker(GtkWidget * text) |
206 | 768 { |
769 int start = 0; | |
770 int end = 0; | |
771 static GdkColor * color = NULL; | |
772 int ignore = 0; | |
773 int point = gtk_editable_get_position(GTK_EDITABLE(text)); | |
774 | |
775 GString * string; | |
776 | |
777 if( color == NULL ) | |
778 { | |
779 GdkColormap * gc = gtk_widget_get_colormap( text ); | |
780 color = g_new0(GdkColor, 1); | |
781 color->red = 255 * 256; | |
782 gdk_colormap_alloc_color(gc, color, FALSE, TRUE); | |
783 } | |
784 | |
785 | |
786 | |
787 end = point-1; | |
788 for( start = end-1; start >= 0; start-- ) | |
789 { | |
790 if((isspace(GTK_TEXT_INDEX(GTK_TEXT(text), start)) || start == 0) | |
791 && !ignore) | |
792 { | |
793 char * word; | |
794 FILE * file; | |
795 char buff[1024]; | |
796 word = gtk_editable_get_chars( GTK_EDITABLE(text), start, end ); | |
797 g_snprintf(buff, 1024, "echo \"%s\" | ispell -l", word ); | |
798 file = popen(buff, "r"); | |
799 | |
800 buff[0] = 0; | |
801 fgets(buff, 255, file); | |
802 | |
803 if(strlen(buff) > 0 ) | |
804 { | |
805 string = g_string_new(word); | |
806 gtk_text_set_point(GTK_TEXT(text), end); | |
807 gtk_text_backward_delete(GTK_TEXT(text), end-start); | |
808 gtk_text_insert( GTK_TEXT(text), NULL, color, NULL, | |
809 string->str, string->len ); | |
810 g_string_free( string, TRUE ); | |
811 } | |
812 else | |
813 { | |
814 string = g_string_new(word); | |
815 gtk_text_set_point(GTK_TEXT(text), end); | |
816 gtk_text_backward_delete(GTK_TEXT(text), end-start); | |
817 gtk_text_insert( GTK_TEXT(text), NULL, &(text->style->fg[0]), NULL, | |
818 string->str, string->len ); | |
819 g_string_free( string, TRUE ); | |
820 } | |
821 pclose( file); | |
846
4b05985bae5e
[gaim-migrate @ 856]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
845
diff
changeset
|
822 g_free(word); |
206 | 823 break; |
824 } | |
825 else if(!isalpha(GTK_TEXT_INDEX(GTK_TEXT(text), start))) | |
826 { | |
827 ignore = 1; | |
828 } | |
829 } | |
830 gtk_text_set_point(GTK_TEXT(text), point); | |
831 | |
832 } | |
833 | |
592
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
834 /* 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
|
835 or time */ |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
836 char *away_subs(char *msg, char *name) |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
837 { |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
838 char *c; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
839 static char cpy[BUF_LONG]; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
840 int cnt=0; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
841 time_t t = time(0); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
842 struct tm *tme = localtime(&t); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
843 char tmp[20]; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
844 |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
845 cpy[0] = '\0'; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
846 c = msg; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
847 while(*c) { |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
848 switch(*c) { |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
849 case '%': |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
850 if (*(c+1)) { |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
851 switch (*(c+1)) { |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
852 case 'n': |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
853 // append name |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
854 strcpy (cpy+cnt, name); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
855 cnt += strlen(name); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
856 c++; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
857 break; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
858 case 'd': |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
859 // append date |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
860 strftime (tmp, 20, "%D", tme); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
861 strcpy (cpy+cnt, tmp); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
862 cnt += strlen(tmp); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
863 c++; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
864 break; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
865 case 't': |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
866 // append time |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
867 strftime (tmp, 20, "%r", tme); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
868 strcpy (cpy+cnt, tmp); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
869 cnt += strlen(tmp); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
870 c++; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
871 break; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
872 default: |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
873 cpy[cnt++]=*c; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
874 } |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
875 } |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
876 break; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
877 default: |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
878 cpy[cnt++]=*c; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
879 } |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
880 c++; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
881 } |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
882 cpy[cnt]='\0'; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
883 return(cpy); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
884 } |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
885 |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
886 GtkWidget *picture_button(GtkWidget *window, char *text, char **xpm) |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
887 { |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
888 GtkWidget *button; |
619 | 889 GtkWidget *button_box, *button_box_2, *button_box_3; |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
890 GtkWidget *label; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
891 GdkBitmap *mask; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
892 GdkPixmap *pm; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
893 GtkWidget *pixmap; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
894 |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
895 button = gtk_button_new(); |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
896 if (display_options & OPT_DISP_COOL_LOOK) |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
897 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
898 |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
899 button_box = gtk_hbox_new(FALSE, 5); |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
900 gtk_container_add(GTK_CONTAINER(button), button_box); |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
901 |
619 | 902 button_box_2 = gtk_hbox_new(FALSE, 0); |
903 button_box_3 = gtk_hbox_new(FALSE, 0); | |
904 gtk_box_pack_start(GTK_BOX(button_box), button_box_2, TRUE, TRUE, 0); | |
905 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
|
906 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
|
907 pixmap = gtk_pixmap_new(pm, mask); |
619 | 908 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
|
909 |
623 | 910 if (text) |
911 { | |
912 label = gtk_label_new(text); | |
913 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
|
914 gtk_widget_show(label); |
623 | 915 } |
619 | 916 |
917 gtk_widget_show(pixmap); | |
918 gtk_widget_show(button_box_2); | |
919 gtk_widget_show(button_box_3); | |
920 gtk_widget_show(button_box); | |
651 | 921 |
726 | 922 /* this causes clipping on lots of buttons with long text */ |
923 /* gtk_widget_set_usize(button, 75, 30);*/ | |
619 | 924 gtk_widget_show(button); |
644
b3900e312d8e
[gaim-migrate @ 654]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
623
diff
changeset
|
925 gdk_pixmap_unref(pm); |
804
17def2bb9720
[gaim-migrate @ 814]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
770
diff
changeset
|
926 gdk_bitmap_unref(mask); |
619 | 927 |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
928 return button; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
929 } |
623 | 930 |
759
9389216aae29
[gaim-migrate @ 769]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
754
diff
changeset
|
931 static GtkTooltips *tips = NULL; |
915
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
932 GtkWidget *picture_button2(GtkWidget *window, char *text, char **xpm, short dispstyle) |
623 | 933 { |
934 GtkWidget *button; | |
935 GtkWidget *button_box, *button_box_2; | |
936 GdkBitmap *mask; | |
937 GdkPixmap *pm; | |
938 GtkWidget *pixmap; | |
754 | 939 GtkWidget *label; |
623 | 940 |
759
9389216aae29
[gaim-migrate @ 769]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
754
diff
changeset
|
941 if (!tips) tips = gtk_tooltips_new(); |
623 | 942 button = gtk_button_new(); |
943 if (display_options & OPT_DISP_COOL_LOOK) | |
944 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
945 | |
651 | 946 button_box = gtk_hbox_new(FALSE, 0); |
623 | 947 gtk_container_add(GTK_CONTAINER(button), button_box); |
948 | |
754 | 949 button_box_2 = gtk_vbox_new(FALSE, 0); |
623 | 950 |
951 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
|
952 gtk_widget_show(button_box_2); |
17ff662183b2
[gaim-migrate @ 977]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
963
diff
changeset
|
953 gtk_widget_show(button_box); |
915
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
954 if (dispstyle == 2 || dispstyle == 0) { |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
955 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
|
956 pixmap = gtk_pixmap_new(pm, mask); |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
957 gtk_box_pack_start(GTK_BOX(button_box_2), pixmap, FALSE, FALSE, 0); |
754 | 958 |
915
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
959 gtk_widget_show(pixmap); |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
960 |
967
17ff662183b2
[gaim-migrate @ 977]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
963
diff
changeset
|
961 gdk_pixmap_unref(pm); |
17ff662183b2
[gaim-migrate @ 977]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
963
diff
changeset
|
962 gdk_bitmap_unref(mask); |
915
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
963 } |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
964 |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
965 if (dispstyle == 2 || dispstyle == 1) |
754 | 966 { |
967 label = gtk_label_new(text); | |
968 gtk_widget_show(label); | |
969 gtk_box_pack_end(GTK_BOX(button_box_2), label, FALSE, FALSE, 0); | |
970 } | |
623 | 971 |
967
17ff662183b2
[gaim-migrate @ 977]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
963
diff
changeset
|
972 gtk_tooltips_set_tip(tips, button, text, "Gaim"); |
623 | 973 gtk_widget_show(button); |
974 return button; | |
975 } | |
976 | |
684
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
977 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
978 /* remove leading whitespace from a string */ |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
979 char *remove_spaces (char *str) |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
980 { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
981 int i; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
982 char *new; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
983 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
984 if (str == NULL) |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
985 return NULL; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
986 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
987 i = strspn (str, " \t\n\r\f"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
988 new = &str[i]; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
989 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
990 return 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 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
993 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
994 /* translate an AIM 3 buddylist (*.lst) to a GAIM buddylist */ |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
995 void translate_lst (FILE *src_fp, char *dest) |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
996 { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
997 char line[BUF_LEN], *line2; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
998 char *name; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
999 int i; |
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 sprintf (dest, "m 1\n"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1002 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1003 while (fgets (line, BUF_LEN, src_fp)) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1004 line2 = remove_spaces (line); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1005 if (strstr (line2, "group") == line2) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1006 name = strpbrk (line2, " \t\n\r\f") + 1; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1007 strcat (dest, "g "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1008 for (i = 0; i < strcspn (name, "\n\r"); i++) |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1009 if (name[i] != '\"') |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1010 strncat (dest, &name[i], 1); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1011 strcat (dest, "\n"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1012 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1013 if (strstr (line2, "buddy") == 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, "b "); |
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 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1022 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1023 return; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1024 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1025 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1026 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1027 /* translate an AIM 4 buddylist (*.blt) to GAIM format */ |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1028 void translate_blt (FILE *src_fp, char *dest) |
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 int i; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1031 char line[BUF_LEN]; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1032 char *buddy; |
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 sprintf (dest, "m 1\n"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1035 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1036 while (strstr (fgets (line, BUF_LEN, src_fp), "Buddy") == NULL) ; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1037 while (strstr (fgets (line, BUF_LEN, src_fp), "list") == NULL) ; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1038 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1039 while (1) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1040 fgets (line, BUF_LEN, src_fp); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1041 if (strchr (line, '}') != NULL) |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1042 break; |
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 /* Syntax starting with "<group> {" */ |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1045 if (strchr (line, '{') != NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1046 strcat (dest, "g "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1047 buddy = remove_spaces (strtok (line, "{")); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1048 for (i = 0; i < strlen(buddy); i++) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1049 if (buddy[i] != '\"') |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1050 strncat (dest, &buddy[i], 1); |
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 strcat (dest, "\n"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1053 while (strchr (fgets (line, BUF_LEN, src_fp), '}') == NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1054 buddy = remove_spaces (line); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1055 strcat (dest, "b "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1056 if (strchr (buddy, '\"') != NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1057 strncat (dest, &buddy[1], strlen(buddy)-3); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1058 strcat (dest, "\n"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1059 } else |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1060 strcat (dest, buddy); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1061 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1062 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1063 /* Syntax "group buddy buddy ..." */ |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1064 else { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1065 buddy = remove_spaces (strtok (line, " \n")); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1066 strcat (dest, "g "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1067 if (strchr (buddy, '\"') != NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1068 strcat (dest, &buddy[1]); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1069 strcat (dest, " "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1070 buddy = remove_spaces (strtok (NULL, " \n")); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1071 while (strchr (buddy, '\"') == NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1072 strcat (dest, buddy); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1073 strcat (dest, " "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1074 buddy = remove_spaces (strtok (NULL, " \n")); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1075 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1076 strncat (dest, buddy, strlen(buddy)-1); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1077 } else { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1078 strcat (dest, buddy); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1079 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1080 strcat (dest, "\n"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1081 while ((buddy = remove_spaces (strtok (NULL, " \n"))) != NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1082 strcat (dest, "b "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1083 if (strchr (buddy, '\"') != NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1084 strcat (dest, &buddy[1]); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1085 strcat (dest, " "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1086 buddy = remove_spaces (strtok (NULL, " \n")); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1087 while (strchr (buddy, '\"') == NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1088 strcat (dest, buddy); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1089 strcat (dest, " "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1090 buddy = remove_spaces (strtok (NULL, " \n")); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1091 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1092 strncat (dest, buddy, strlen(buddy)-1); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1093 } else { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1094 strcat (dest, buddy); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1095 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1096 strcat (dest, "\n"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1097 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1098 } |
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 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1101 return; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1102 } |
764 | 1103 |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1104 char *stylize(gchar *text, int length) |
764 | 1105 { |
1106 gchar *buf; | |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1107 char tmp[length]; |
764 | 1108 |
1109 buf = g_malloc(length); | |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1110 g_snprintf(buf, length, "%s", text); |
764 | 1111 |
831
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1112 if (font_options & OPT_FONT_BOLD) { |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1113 g_snprintf(tmp, length, "<B>%s</B>", buf); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1114 strcpy(buf, tmp); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1115 } |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1116 |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1117 if (font_options & OPT_FONT_ITALIC) { |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1118 g_snprintf(tmp, length, "<I>%s</I>", buf); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1119 strcpy(buf, tmp); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1120 } |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1121 |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1122 if (font_options & OPT_FONT_UNDERLINE) { |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1123 g_snprintf(tmp, length, "<U>%s</U>", buf); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1124 strcpy(buf, tmp); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1125 } |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1126 |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1127 if (font_options & OPT_FONT_STRIKE) { |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1128 g_snprintf(tmp, length, "<S>%s</S>", buf); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1129 strcpy(buf, tmp); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1130 } |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1131 |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1132 if (font_options & OPT_FONT_FACE) { |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1133 g_snprintf(tmp, length, "<FONT FACE=\"%s\">%s</FONT>", fontface, buf); |
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1134 strcpy(buf, tmp); |
764 | 1135 } |
1136 | |
831
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1137 if (font_options & OPT_FONT_FGCOL) { |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1138 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
|
1139 strcpy(buf, tmp); |
764 | 1140 } |
1141 | |
831
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1142 if (font_options & OPT_FONT_BGCOL) { |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1143 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
|
1144 strcpy(buf, tmp); |
764 | 1145 } |
1146 | |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1147 return buf; |
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1148 } |
915
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1149 |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1150 int set_dispstyle (int chat) |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1151 { |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1152 int dispstyle; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1153 |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1154 if (chat) { |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1155 switch (display_options & (OPT_DISP_CHAT_BUTTON_TEXT | |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1156 OPT_DISP_CHAT_BUTTON_XPM)) { |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1157 case OPT_DISP_CHAT_BUTTON_TEXT: |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1158 dispstyle = 1; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1159 break; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1160 case OPT_DISP_CHAT_BUTTON_XPM: |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1161 dispstyle = 0; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1162 break; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1163 default: /* both or neither */ |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1164 dispstyle = 2; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1165 break; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1166 } |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1167 } else { |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1168 switch (display_options & (OPT_DISP_CONV_BUTTON_TEXT | |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1169 OPT_DISP_CONV_BUTTON_XPM)) { |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1170 case OPT_DISP_CONV_BUTTON_TEXT: |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1171 dispstyle = 1; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1172 break; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1173 case OPT_DISP_CONV_BUTTON_XPM: |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1174 dispstyle = 0; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1175 break; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1176 default: /* both or neither */ |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1177 dispstyle = 2; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1178 break; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1179 } |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1180 } |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1181 return dispstyle; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1182 } |