Mercurial > pidgin
annotate src/util.c @ 771:72e556f6b99d
[gaim-migrate @ 781]
libfaim gets warnings, and other minor changes
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Mon, 28 Aug 2000 05:07:43 +0000 |
parents | 172c5cf98dfa |
children | 17def2bb9720 |
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 static int state; | |
42 | |
70 | 43 char *full_date() { |
44 char * date; | |
45 time_t tme; | |
46 | |
47 time(&tme); | |
48 date = ctime(&tme); | |
49 date[strlen(date)-1] = '\0'; | |
50 return date; | |
51 } | |
52 | |
1 | 53 gint badchar(char c) |
54 { | |
55 if (c == ' ') | |
56 return 1; | |
57 if (c == ',') | |
58 return 1; | |
59 if (c == ')') | |
60 return 1; | |
61 if (c == '(') | |
62 return 1; | |
63 if (c == 0) | |
64 return 1; | |
65 if (c == '\n') | |
66 return 1; | |
413
7ea55575cc01
[gaim-migrate @ 423]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
373
diff
changeset
|
67 if (c == '<') |
7ea55575cc01
[gaim-migrate @ 423]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
373
diff
changeset
|
68 return 1; |
470
4bf9c74b9e4d
[gaim-migrate @ 480]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
423
diff
changeset
|
69 if (c == '>') |
4bf9c74b9e4d
[gaim-migrate @ 480]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
423
diff
changeset
|
70 return 1; |
1 | 71 return 0; |
72 | |
73 | |
74 } | |
75 | |
76 | |
77 char *sec_to_text(int sec) | |
78 { | |
79 int hrs, min; | |
80 char minutes[64]; | |
81 char hours[64]; | |
82 char sep[16]; | |
83 char *ret = g_malloc(256); | |
84 | |
85 hrs = sec / 3600; | |
86 min = sec % 3600; | |
87 | |
88 min = min / 60; | |
89 sec = min % 60; | |
90 | |
91 if (min) { | |
92 if (min == 1) | |
93 g_snprintf(minutes, sizeof(minutes), "%d minute.", min); | |
94 else | |
95 g_snprintf(minutes, sizeof(minutes), "%d minutes.", min); | |
96 sprintf(sep, ", "); | |
97 } else { | |
98 if (!hrs) | |
99 g_snprintf(minutes, sizeof(minutes), "%d minutes.", min); | |
100 else { | |
101 minutes[0] = '.'; | |
102 minutes[1] = '\0'; | |
103 } | |
104 sep[0] = '\0'; | |
105 } | |
106 | |
107 if (hrs) { | |
108 if (hrs == 1) | |
109 g_snprintf(hours, sizeof(hours), "%d hour%s", hrs, sep); | |
110 else | |
111 g_snprintf(hours, sizeof(hours), "%d hours%s", hrs, sep); | |
112 } else | |
113 hours[0] = '\0'; | |
114 | |
115 | |
116 g_snprintf(ret, 256, "%s%s", hours, minutes); | |
117 | |
118 return ret; | |
119 } | |
120 | |
121 gint linkify_text(char *text) | |
122 { | |
123 char *c, *t; | |
124 char cpy[BUF_LONG]; | |
125 char url_buf[512]; | |
126 int cnt=0; | |
127 /* Assumes you have a buffer able to cary at least BUF_LEN * 2 bytes */ | |
128 | |
129 strncpy(cpy, text, strlen(text)); | |
130 cpy[strlen(text)] = 0; | |
131 c = cpy; | |
132 while(*c) { | |
133 if (!strncasecmp(c, "<A", 2)) { | |
134 while(1) { | |
135 if (!strncasecmp(c, "/A>", 3)) { | |
136 break; | |
137 } | |
138 text[cnt++] = *c; | |
139 c++; | |
140 if (!(*c)) | |
141 break; | |
142 } | |
143 } else if (!strncasecmp(c, "http://", 7)) { | |
144 t = c; | |
145 while(1) { | |
146 if (badchar(*t)) { | |
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 } | |
169 if (*(t-1) == '.') | |
170 t--; | |
171 strncpy(url_buf, c, t-c); | |
172 url_buf[t-c] = 0; | |
173 cnt += g_snprintf(&text[cnt++], 1024, "<A HREF=\"http://%s\">%s</A>", url_buf, url_buf); | |
174 cnt--; | |
175 c = t; | |
176 break; | |
177 } | |
178 if (!t) | |
179 break; | |
180 t++; | |
181 } | |
182 } | |
183 } else if (!strncasecmp(c, "ftp://", 6)) { | |
184 t = c; | |
185 while(1) { | |
186 if (badchar(*t)) { | |
187 if (*(t-1) == '.') | |
188 t--; | |
189 strncpy(url_buf, c, t-c); | |
190 url_buf[t-c] = 0; | |
191 cnt += g_snprintf(&text[cnt++], 1024, "<A HREF=\"%s\">%s</A>", url_buf, url_buf); | |
192 cnt--; | |
193 c = t; | |
194 break; | |
195 } | |
196 if (!t) | |
197 break; | |
198 t++; | |
199 | |
200 } | |
201 } else if (!strncasecmp(c, "ftp.", 4)) { | |
202 t = c; | |
203 while(1) { | |
204 if (badchar(*t)) { | |
205 if (t-c == 4) { | |
206 break; | |
207 } | |
208 if (*(t-1) == '.') | |
209 t--; | |
210 strncpy(url_buf, c, t-c); | |
211 url_buf[t-c] = 0; | |
212 cnt += g_snprintf(&text[cnt++], 1024, "<A HREF=\"ftp://%s\">%s</A>", url_buf, url_buf); | |
213 cnt--; | |
214 c = t; | |
215 break; | |
216 } | |
217 if (!t) | |
218 break; | |
219 t++; | |
220 } | |
221 } else if (!strncasecmp(c, "mailto:", 7)) { | |
222 t = c; | |
223 while(1) { | |
224 if (badchar(*t)) { | |
225 if (*(t-1) == '.') | |
226 t--; | |
227 strncpy(url_buf, c, t-c); | |
228 url_buf[t-c] = 0; | |
229 cnt += g_snprintf(&text[cnt++], 1024, "<A HREF=\"%s\">%s</A>", url_buf, url_buf); | |
230 cnt--; | |
231 c = t; | |
232 break; | |
233 } | |
234 if (!t) | |
235 break; | |
236 t++; | |
237 | |
238 } | |
239 } else if (!strncasecmp(c, "@", 1)) { | |
240 char *tmp; | |
241 int flag; | |
242 int len=0; | |
243 url_buf[0] = 0; | |
244 | |
245 if (*(c-1) == ' ' || *(c+1) == ' ') | |
246 flag = 0; | |
247 else | |
248 flag = 1; | |
249 | |
250 t = c; | |
251 while(flag) { | |
252 if (badchar(*t)) { | |
253 cnt -= (len - 1); | |
254 break; | |
255 } else { | |
256 len++; | |
257 tmp = g_malloc(len + 1); | |
258 tmp[len] = 0; | |
259 tmp[0] = *t; | |
260 strncpy(tmp + 1, url_buf, len - 1); | |
261 strcpy(url_buf, tmp); | |
262 url_buf[len] = 0; | |
263 g_free(tmp); | |
264 t--; | |
265 if (t < cpy) { | |
266 cnt = 0; | |
267 break; | |
268 } | |
269 } | |
270 } | |
271 | |
272 | |
273 t = c + 1; | |
274 | |
275 while(flag) { | |
276 if (badchar(*t)) { | |
277 if (*(t-1) == '.') | |
278 t--; | |
279 cnt += g_snprintf(&text[cnt++], 1024, "<A HREF=\"mailto:%s\">%s</A>", url_buf, url_buf); | |
280 text[cnt]=0; | |
281 | |
282 | |
283 cnt--; | |
284 c = t; | |
285 | |
286 break; | |
287 } else { | |
288 strncat(url_buf, t, 1); | |
289 len++; | |
290 url_buf[len] = 0; | |
291 } | |
292 | |
293 t++; | |
294 | |
295 } | |
296 | |
297 | |
298 } | |
299 | |
300 if (*c == 0) | |
301 break; | |
302 | |
303 text[cnt++] = *c; | |
304 c++; | |
305 | |
306 } | |
307 text[cnt]=0; | |
308 return cnt; | |
309 } | |
310 | |
311 | |
373
1d29321843b0
[gaim-migrate @ 383]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
312 FILE *open_log_file (char *name) |
1 | 313 { |
79 | 314 char *buf; |
315 char *buf2; | |
1 | 316 char log_all_file[256]; |
317 struct log_conversation *l; | |
318 struct stat st; | |
319 int flag = 0; | |
320 FILE *fd; | |
321 int res; | |
322 | |
323 if (!(general_options & OPT_GEN_LOG_ALL)) { | |
324 | |
373
1d29321843b0
[gaim-migrate @ 383]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
325 l = find_log_info(name); |
1 | 326 if (!l) |
327 return NULL; | |
328 | |
329 if (stat(l->filename, &st) < 0) | |
330 flag = 1; | |
331 | |
332 fd = fopen(l->filename, "a"); | |
333 | |
334 if (flag) { /* is a new file */ | |
335 fprintf(fd, "<HTML><HEAD><TITLE>" ); | |
373
1d29321843b0
[gaim-migrate @ 383]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
336 fprintf(fd, "IM Sessions with %s", name ); |
1 | 337 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"ffffff\">\n" ); |
338 } | |
339 | |
340 return fd; | |
341 } | |
342 | |
79 | 343 buf = g_malloc(BUF_LONG); |
344 buf2 = g_malloc(BUF_LONG); | |
345 | |
1 | 346 /* Dont log yourself */ |
347 g_snprintf(log_all_file, 256, "%s/.gaim", getenv("HOME")); | |
348 | |
349 stat(log_all_file, &st); | |
350 if (!S_ISDIR(st.st_mode)) | |
351 unlink(log_all_file); | |
352 | |
353 fd = fopen(log_all_file, "r"); | |
354 | |
355 if (!fd) { | |
356 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR); | |
357 if (res < 0) { | |
358 g_snprintf(buf, BUF_LONG, "Unable to make directory %s for logging", log_all_file); | |
359 do_error_dialog(buf, "Error!"); | |
360 g_free(buf); | |
361 g_free(buf2); | |
362 return NULL; | |
363 } | |
364 } else | |
365 fclose(fd); | |
366 | |
367 g_snprintf(log_all_file, 256, "%s/.gaim/%s", getenv("HOME"), current_user->username); | |
368 | |
369 if (stat(log_all_file, &st) < 0) | |
370 flag = 1; | |
371 if (!S_ISDIR(st.st_mode)) | |
372 unlink(log_all_file); | |
373 | |
374 fd = fopen(log_all_file, "r"); | |
375 if (!fd) { | |
376 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR); | |
377 if (res < 0) { | |
378 g_snprintf(buf, BUF_LONG, "Unable to make directory %s for logging", log_all_file); | |
379 do_error_dialog(buf, "Error!"); | |
380 g_free(buf); | |
381 g_free(buf2); | |
382 return NULL; | |
383 } | |
384 } else | |
385 fclose(fd); | |
386 | |
387 | |
373
1d29321843b0
[gaim-migrate @ 383]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
388 g_snprintf(log_all_file, 256, "%s/.gaim/%s/%s.log", getenv("HOME"), current_user->username, normalize(name)); |
1 | 389 |
390 if (stat(log_all_file, &st) < 0) | |
391 flag = 1; | |
392 | |
393 sprintf(debug_buff,"Logging to: \"%s\"\n", log_all_file); | |
394 debug_print(debug_buff); | |
395 | |
396 fd = fopen(log_all_file, "a"); | |
397 | |
398 if (flag) { /* is a new file */ | |
399 fprintf(fd, "<HTML><HEAD><TITLE>" ); | |
373
1d29321843b0
[gaim-migrate @ 383]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
400 fprintf(fd, "IM Sessions with %s", name ); |
1 | 401 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"ffffff\">\n" ); |
402 } | |
25 | 403 |
404 g_free(buf); | |
405 g_free(buf2); | |
1 | 406 return fd; |
407 } | |
408 | |
409 | |
254
fa67d29b53d5
[gaim-migrate @ 264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
410 /* we only need this for TOC, because messages must be escaped */ |
1 | 411 int escape_message(char *msg) |
412 { | |
423
0d4e80bdb96b
[gaim-migrate @ 433]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
413
diff
changeset
|
413 if (!USE_OSCAR) { |
1 | 414 char *c, *cpy; |
415 int cnt=0; | |
416 /* Assumes you have a buffer able to cary at least BUF_LEN * 2 bytes */ | |
417 if (strlen(msg) > BUF_LEN) { | |
418 sprintf(debug_buff, "Warning: truncating message to 2048 bytes\n"); | |
419 debug_print(debug_buff); | |
420 msg[2047]='\0'; | |
421 } | |
422 | |
423 cpy = g_strdup(msg); | |
424 c = cpy; | |
425 while(*c) { | |
426 switch(*c) { | |
427 case '$': | |
428 case '[': | |
429 case ']': | |
430 case '(': | |
431 case ')': | |
432 case '#': | |
433 msg[cnt++]='\\'; | |
434 /* Fall through */ | |
435 default: | |
436 msg[cnt++]=*c; | |
437 } | |
438 c++; | |
439 } | |
440 msg[cnt]='\0'; | |
441 g_free(cpy); | |
442 return cnt; | |
423
0d4e80bdb96b
[gaim-migrate @ 433]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
413
diff
changeset
|
443 } else { |
254
fa67d29b53d5
[gaim-migrate @ 264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
444 return strlen(msg); |
423
0d4e80bdb96b
[gaim-migrate @ 433]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
413
diff
changeset
|
445 } |
1 | 446 } |
447 | |
254
fa67d29b53d5
[gaim-migrate @ 264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
448 /* we don't need this for oscar either */ |
1 | 449 int escape_text(char *msg) |
450 { | |
423
0d4e80bdb96b
[gaim-migrate @ 433]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
413
diff
changeset
|
451 if (!USE_OSCAR) { |
1 | 452 char *c, *cpy; |
453 int cnt=0; | |
79 | 454 /* Assumes you have a buffer able to cary at least BUF_LEN * 4 bytes */ |
1 | 455 if (strlen(msg) > BUF_LEN) { |
456 fprintf(stderr, "Warning: truncating message to 2048 bytes\n"); | |
457 msg[2047]='\0'; | |
458 } | |
459 | |
460 cpy = g_strdup(msg); | |
461 c = cpy; | |
462 while(*c) { | |
463 switch(*c) { | |
464 case '\n': | |
465 msg[cnt++] = '<'; | |
466 msg[cnt++] = 'B'; | |
467 msg[cnt++] = 'R'; | |
468 msg[cnt++] = '>'; | |
469 break; | |
470 case '{': | |
471 case '}': | |
472 case '\\': | |
473 case '"': | |
474 msg[cnt++]='\\'; | |
475 /* Fall through */ | |
476 default: | |
477 msg[cnt++]=*c; | |
478 } | |
479 c++; | |
480 } | |
481 msg[cnt]='\0'; | |
482 g_free(cpy); | |
483 return cnt; | |
423
0d4e80bdb96b
[gaim-migrate @ 433]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
413
diff
changeset
|
484 } else { |
254
fa67d29b53d5
[gaim-migrate @ 264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
485 return strlen(msg); |
423
0d4e80bdb96b
[gaim-migrate @ 433]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
413
diff
changeset
|
486 } |
1 | 487 } |
488 | |
489 char * escape_text2(char *msg) | |
490 { | |
491 char *c, *cpy; | |
492 char *woo; | |
493 int cnt=0; | |
494 /* Assumes you have a buffer able to cary at least BUF_LEN * 2 bytes */ | |
495 if (strlen(msg) > BUF_LEN) { | |
496 fprintf(stderr, "Warning: truncating message to 2048 bytes\n"); | |
497 msg[2047]='\0'; | |
498 } | |
499 | |
79 | 500 woo = malloc(strlen(msg) * 2); |
1 | 501 cpy = g_strdup(msg); |
502 c = cpy; | |
503 while(*c) { | |
504 switch(*c) { | |
505 case '\n': | |
506 woo[cnt++] = '<'; | |
507 woo[cnt++] = 'B'; | |
508 woo[cnt++] = 'R'; | |
509 woo[cnt++] = '>'; | |
510 break; | |
511 case '{': | |
512 case '}': | |
513 case '\\': | |
514 case '"': | |
515 woo[cnt++]='\\'; | |
516 /* Fall through */ | |
517 default: | |
518 woo[cnt++]=*c; | |
519 } | |
520 c++; | |
521 } | |
522 woo[cnt]='\0'; | |
26 | 523 |
524 g_free (cpy); | |
1 | 525 return woo; |
526 } | |
527 | |
528 | |
529 char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" | |
530 "0123456789+/"; | |
531 | |
532 | |
533 char *tobase64(char *text) | |
534 { | |
535 char *out = NULL; | |
536 char *c; | |
537 unsigned int tmp = 0; | |
538 int len = 0, n = 0; | |
539 | |
540 c = text; | |
541 | |
542 while(c) { | |
543 tmp = tmp << 8; | |
544 tmp += *c; | |
545 n++; | |
546 | |
547 if (n == 3) { | |
548 out = g_realloc(out, len+4); | |
549 out[len] = alphabet[(tmp >> 18) & 0x3f]; | |
550 out[len+1] = alphabet[(tmp >> 12) & 0x3f]; | |
551 out[len+2] = alphabet[(tmp >> 6) & 0x3f]; | |
552 out[len+3] = alphabet[tmp & 0x3f]; | |
553 len += 4; | |
554 tmp = 0; | |
555 n = 0; | |
556 } | |
557 c++; | |
558 } | |
559 switch(n) { | |
560 | |
561 case 2: | |
562 out = g_realloc(out, len+5); | |
563 out[len] = alphabet[(tmp >> 12) & 0x3f]; | |
564 out[len+1] = alphabet[(tmp >> 6) & 0x3f]; | |
565 out[len+2] = alphabet[tmp & 0x3f]; | |
566 out[len+3] = '='; | |
567 out[len+4] = 0; | |
568 break; | |
569 case 1: | |
570 out = g_realloc(out, len+4); | |
571 out[len] = alphabet[(tmp >> 6) & 0x3f]; | |
572 out[len+1] = alphabet[tmp & 0x3f]; | |
573 out[len+2] = '='; | |
574 out[len+3] = 0; | |
575 break; | |
576 case 0: | |
577 out = g_realloc(out, len+2); | |
578 out[len] = '='; | |
579 out[len+1] = 0; | |
580 break; | |
581 } | |
582 return out; | |
583 } | |
584 | |
585 | |
586 char *frombase64(char *text) | |
587 { | |
588 char *out = NULL; | |
589 char tmp = 0; | |
590 char *c; | |
591 gint32 tmp2 = 0; | |
592 int len = 0, n = 0; | |
593 | |
594 c = text; | |
595 | |
596 while(*c) { | |
597 if (*c >= 'A' && *c <= 'Z') { | |
598 tmp = *c - 'A'; | |
599 } else if (*c >= 'a' && *c <= 'z') { | |
600 tmp = 26 + (*c - 'a'); | |
601 } else if (*c >= '0' && *c <= 57) { | |
602 tmp = 52 + (*c - '0'); | |
603 } else if (*c == '+') { | |
604 tmp = 62; | |
605 } else if (*c == '/') { | |
606 tmp = 63; | |
607 } else if (*c == '=') { | |
608 if (n == 3) { | |
609 out = g_realloc(out, len + 2); | |
610 out[len] = (char)(tmp2 >> 10) & 0xff; | |
611 len++; | |
612 out[len] = (char)(tmp2 >> 2) & 0xff; | |
613 len++; | |
614 } else if (n == 2) { | |
615 out = g_realloc(out, len + 1); | |
616 out[len] = (char)(tmp2 >> 4) & 0xff; | |
617 len++; | |
618 } | |
619 break; | |
620 } | |
621 tmp2 = ((tmp2 << 6) | (tmp & 0xff)); | |
622 n++; | |
623 if (n == 4) { | |
624 out = g_realloc(out, len + 3); | |
625 out[len] = (char)((tmp2 >> 16) & 0xff); | |
626 len++; | |
627 out[len] = (char)((tmp2 >> 8) & 0xff); | |
628 len++; | |
629 out[len] = (char)(tmp2 & 0xff); | |
630 len++; | |
631 tmp2 = 0; | |
632 n = 0; | |
633 } | |
634 c++; | |
635 } | |
636 | |
194
d7690984c0f1
[gaim-migrate @ 204]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
637 out = g_realloc(out, len+1); |
1 | 638 out[len] = 0; |
639 | |
640 return out; | |
641 } | |
642 | |
643 | |
644 char *normalize(const char *s) | |
645 { | |
646 static char buf[BUF_LEN]; | |
647 char *t, *u; | |
648 int x=0; | |
649 | |
79 | 650 g_return_val_if_fail ((s != NULL), NULL); |
26 | 651 |
652 u = t = g_strdup(s); | |
1 | 653 |
654 strcpy(t, s); | |
655 g_strdown(t); | |
656 | |
26 | 657 while(*t && (x < BUF_LEN - 1)) { |
1 | 658 if (*t != ' ') { |
659 buf[x] = *t; | |
660 x++; | |
661 } | |
662 t++; | |
663 } | |
664 buf[x]='\0'; | |
665 g_free(u); | |
666 return buf; | |
667 } | |
668 | |
669 int query_state() | |
670 { | |
671 return state; | |
672 } | |
673 | |
674 void set_state(int i) | |
675 { | |
676 state = i; | |
677 } | |
678 | |
679 char *date() | |
680 { | |
681 static char date[80]; | |
682 time_t tme; | |
683 time(&tme); | |
684 strftime(date, sizeof(date), "%H:%M:%S", localtime(&tme)); | |
685 return date; | |
686 } | |
687 | |
688 | |
689 gint clean_pid(void *dummy) | |
690 { | |
691 int status; | |
692 pid_t pid; | |
693 | |
694 pid = waitpid(-1, &status, WNOHANG); | |
695 | |
696 if (pid == 0) | |
697 return TRUE; | |
698 | |
699 return FALSE; | |
700 } | |
701 | |
702 void aol_icon(GdkWindow *w) | |
703 { | |
704 #ifndef _WIN32 | |
705 if (icon_pm == NULL) { | |
706 icon_pm = gdk_pixmap_create_from_xpm_d(w, &icon_bm, | |
707 NULL, (gchar **)aimicon_xpm); | |
708 } | |
709 gdk_window_set_icon(w, NULL, icon_pm, icon_bm); | |
10 | 710 if (mainwindow) gdk_window_set_group(w, mainwindow->window); |
1 | 711 #endif |
712 } | |
713 | |
714 struct aim_user *find_user(const char *name) | |
715 { | |
716 char *who = g_strdup(normalize(name)); | |
717 GList *usr = aim_users; | |
718 struct aim_user *u; | |
719 | |
720 while(usr) { | |
721 u = (struct aim_user *)usr->data; | |
722 if (!strcmp(normalize(u->username), who)) { | |
723 g_free(who); | |
724 return u; | |
725 } | |
726 usr = usr->next; | |
727 } | |
728 g_free(who); | |
729 return NULL; | |
730 } | |
180 | 731 |
732 void check_gaim_versions() | |
733 { | |
734 char *cur_ver; | |
735 char *tmp; | |
736 | |
737 tmp = (char *)malloc(BUF_LONG); | |
738 | |
739 cur_ver = (char *)grab_url("http://www.marko.net/gaim/latest-gaim"); | |
740 | |
741 if (!strncasecmp(cur_ver, "g00", 3)) | |
742 { | |
278
29e1669b006b
[gaim-migrate @ 288]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
254
diff
changeset
|
743 g_free(cur_ver); |
29e1669b006b
[gaim-migrate @ 288]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
254
diff
changeset
|
744 g_free(tmp); |
180 | 745 return; |
746 } | |
747 | |
748 g_snprintf(tmp, BUF_LONG, "%s", strstr(cur_ver, "plain")+9); | |
749 g_strchomp(tmp); | |
750 | |
278
29e1669b006b
[gaim-migrate @ 288]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
254
diff
changeset
|
751 if (strcmp(tmp, latest_ver)) |
180 | 752 { |
753 g_snprintf(cur_ver, BUF_LONG, "GAIM v%s is now available.\n\nDownload it at http://www.marko.net/gaim\n", tmp); | |
754 | |
755 do_error_dialog(cur_ver, "GAIM - New Version!"); | |
756 strcpy(latest_ver, tmp); | |
757 save_prefs(); | |
758 } | |
759 | |
760 free(tmp); | |
761 free(cur_ver); | |
762 } | |
763 | |
764 | |
206 | 765 /* |
766 | |
767 This function was taken from EveryBuddy and was written by | |
768 Torrey Searle. tsearle@valhalla.marko.net | |
769 | |
770 http://www.everybuddy.com | |
771 | |
772 */ | |
773 | |
209 | 774 void spell_checker(GtkWidget * text) |
206 | 775 { |
776 int start = 0; | |
777 int end = 0; | |
778 static GdkColor * color = NULL; | |
779 int ignore = 0; | |
780 int point = gtk_editable_get_position(GTK_EDITABLE(text)); | |
781 | |
782 GString * string; | |
783 | |
784 if( color == NULL ) | |
785 { | |
786 GdkColormap * gc = gtk_widget_get_colormap( text ); | |
787 color = g_new0(GdkColor, 1); | |
788 color->red = 255 * 256; | |
789 gdk_colormap_alloc_color(gc, color, FALSE, TRUE); | |
790 } | |
791 | |
792 | |
793 | |
794 end = point-1; | |
795 for( start = end-1; start >= 0; start-- ) | |
796 { | |
797 if((isspace(GTK_TEXT_INDEX(GTK_TEXT(text), start)) || start == 0) | |
798 && !ignore) | |
799 { | |
800 char * word; | |
801 FILE * file; | |
802 char buff[1024]; | |
803 word = gtk_editable_get_chars( GTK_EDITABLE(text), start, end ); | |
804 g_snprintf(buff, 1024, "echo \"%s\" | ispell -l", word ); | |
805 file = popen(buff, "r"); | |
806 | |
807 buff[0] = 0; | |
808 fgets(buff, 255, file); | |
809 | |
810 if(strlen(buff) > 0 ) | |
811 { | |
812 string = g_string_new(word); | |
813 gtk_text_set_point(GTK_TEXT(text), end); | |
814 gtk_text_backward_delete(GTK_TEXT(text), end-start); | |
815 gtk_text_insert( GTK_TEXT(text), NULL, color, NULL, | |
816 string->str, string->len ); | |
817 g_string_free( string, TRUE ); | |
818 } | |
819 else | |
820 { | |
821 string = g_string_new(word); | |
822 gtk_text_set_point(GTK_TEXT(text), end); | |
823 gtk_text_backward_delete(GTK_TEXT(text), end-start); | |
824 gtk_text_insert( GTK_TEXT(text), NULL, &(text->style->fg[0]), NULL, | |
825 string->str, string->len ); | |
826 g_string_free( string, TRUE ); | |
827 } | |
828 pclose( file); | |
829 break; | |
830 } | |
831 else if(!isalpha(GTK_TEXT_INDEX(GTK_TEXT(text), start))) | |
832 { | |
833 ignore = 1; | |
834 } | |
835 } | |
836 gtk_text_set_point(GTK_TEXT(text), point); | |
837 | |
838 } | |
839 | |
592
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
840 /* 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
|
841 or time */ |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
842 char *away_subs(char *msg, char *name) |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
843 { |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
844 char *c; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
845 static char cpy[BUF_LONG]; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
846 int cnt=0; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
847 time_t t = time(0); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
848 struct tm *tme = localtime(&t); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
849 char tmp[20]; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
850 |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
851 cpy[0] = '\0'; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
852 c = msg; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
853 while(*c) { |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
854 switch(*c) { |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
855 case '%': |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
856 if (*(c+1)) { |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
857 switch (*(c+1)) { |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
858 case 'n': |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
859 // append name |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
860 strcpy (cpy+cnt, name); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
861 cnt += strlen(name); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
862 c++; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
863 break; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
864 case 'd': |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
865 // append date |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
866 strftime (tmp, 20, "%D", tme); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
867 strcpy (cpy+cnt, tmp); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
868 cnt += strlen(tmp); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
869 c++; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
870 break; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
871 case 't': |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
872 // append time |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
873 strftime (tmp, 20, "%r", tme); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
874 strcpy (cpy+cnt, tmp); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
875 cnt += strlen(tmp); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
876 c++; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
877 break; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
878 default: |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
879 cpy[cnt++]=*c; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
880 } |
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 break; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
883 default: |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
884 cpy[cnt++]=*c; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
885 } |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
886 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 cpy[cnt]='\0'; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
889 return(cpy); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
890 } |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
891 |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
892 GtkWidget *picture_button(GtkWidget *window, char *text, char **xpm) |
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 *button; |
619 | 895 GtkWidget *button_box, *button_box_2, *button_box_3; |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
896 GtkWidget *label; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
897 GdkBitmap *mask; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
898 GdkPixmap *pm; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
899 GtkWidget *pixmap; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
900 |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
901 button = gtk_button_new(); |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
902 if (display_options & OPT_DISP_COOL_LOOK) |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
903 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
904 |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
905 button_box = gtk_hbox_new(FALSE, 5); |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
906 gtk_container_add(GTK_CONTAINER(button), button_box); |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
907 |
619 | 908 button_box_2 = gtk_hbox_new(FALSE, 0); |
909 button_box_3 = gtk_hbox_new(FALSE, 0); | |
910 gtk_box_pack_start(GTK_BOX(button_box), button_box_2, TRUE, TRUE, 0); | |
911 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
|
912 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
|
913 pixmap = gtk_pixmap_new(pm, mask); |
619 | 914 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
|
915 |
623 | 916 if (text) |
917 { | |
918 label = gtk_label_new(text); | |
919 gtk_box_pack_start(GTK_BOX(button_box_3), label, FALSE, FALSE, 2); | |
920 } | |
619 | 921 |
922 gtk_widget_show(pixmap); | |
623 | 923 if (text) |
924 { | |
925 gtk_widget_show(label); | |
926 } | |
619 | 927 gtk_widget_show(button_box_2); |
928 gtk_widget_show(button_box_3); | |
929 gtk_widget_show(button_box); | |
651 | 930 |
726 | 931 /* this causes clipping on lots of buttons with long text */ |
932 /* gtk_widget_set_usize(button, 75, 30);*/ | |
619 | 933 gtk_widget_show(button); |
644
b3900e312d8e
[gaim-migrate @ 654]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
623
diff
changeset
|
934 gdk_pixmap_unref(pm); |
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; |
754 | 940 GtkWidget *picture_button2(GtkWidget *window, char *text, char **xpm, short showtext) |
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); | |
960 pm = gdk_pixmap_create_from_xpm_d(window->window, &mask, NULL, xpm); | |
961 pixmap = gtk_pixmap_new(pm, mask); | |
754 | 962 gtk_box_pack_start(GTK_BOX(button_box_2), pixmap, FALSE, FALSE, 0); |
963 | |
767
be917c4d3e39
[gaim-migrate @ 777]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
765
diff
changeset
|
964 if (showtext) |
754 | 965 { |
966 label = gtk_label_new(text); | |
967 gtk_widget_show(label); | |
968 gtk_box_pack_end(GTK_BOX(button_box_2), label, FALSE, FALSE, 0); | |
969 } | |
623 | 970 |
971 gtk_widget_show(pixmap); | |
972 gtk_widget_show(button_box_2); | |
973 gtk_widget_show(button_box); | |
974 gtk_widget_show(button); | |
644
b3900e312d8e
[gaim-migrate @ 654]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
623
diff
changeset
|
975 gdk_pixmap_unref(pm); |
623 | 976 |
977 gtk_tooltips_set_tip(tips, button, text, "Gaim"); | |
978 return button; | |
979 } | |
980 | |
684
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
981 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
982 /* remove leading whitespace from a string */ |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
983 char *remove_spaces (char *str) |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
984 { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
985 int i; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
986 char *new; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
987 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
988 if (str == NULL) |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
989 return NULL; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
990 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
991 i = strspn (str, " \t\n\r\f"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
992 new = &str[i]; |
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 return new; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
995 } |
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 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
998 /* translate an AIM 3 buddylist (*.lst) to a GAIM buddylist */ |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
999 void translate_lst (FILE *src_fp, char *dest) |
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 char line[BUF_LEN], *line2; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1002 char *name; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1003 int i; |
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 sprintf (dest, "m 1\n"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1006 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1007 while (fgets (line, BUF_LEN, src_fp)) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1008 line2 = remove_spaces (line); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1009 if (strstr (line2, "group") == line2) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1010 name = strpbrk (line2, " \t\n\r\f") + 1; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1011 strcat (dest, "g "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1012 for (i = 0; i < strcspn (name, "\n\r"); i++) |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1013 if (name[i] != '\"') |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1014 strncat (dest, &name[i], 1); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1015 strcat (dest, "\n"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1016 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1017 if (strstr (line2, "buddy") == line2) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1018 name = strpbrk (line2, " \t\n\r\f") + 1; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1019 strcat (dest, "b "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1020 for (i = 0; i < strcspn (name, "\n\r"); i++) |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1021 if (name[i] != '\"') |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1022 strncat (dest, &name[i], 1); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1023 strcat (dest, "\n"); |
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 return; |
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 /* translate an AIM 4 buddylist (*.blt) to GAIM format */ |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1032 void translate_blt (FILE *src_fp, char *dest) |
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 int i; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1035 char line[BUF_LEN]; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1036 char *buddy; |
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 sprintf (dest, "m 1\n"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1039 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1040 while (strstr (fgets (line, BUF_LEN, src_fp), "Buddy") == NULL) ; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1041 while (strstr (fgets (line, BUF_LEN, src_fp), "list") == NULL) ; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1042 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1043 while (1) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1044 fgets (line, BUF_LEN, src_fp); |
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 break; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1047 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1048 /* Syntax starting with "<group> {" */ |
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 strcat (dest, "g "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1051 buddy = remove_spaces (strtok (line, "{")); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1052 for (i = 0; i < strlen(buddy); i++) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1053 if (buddy[i] != '\"') |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1054 strncat (dest, &buddy[i], 1); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1055 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1056 strcat (dest, "\n"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1057 while (strchr (fgets (line, BUF_LEN, src_fp), '}') == NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1058 buddy = remove_spaces (line); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1059 strcat (dest, "b "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1060 if (strchr (buddy, '\"') != NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1061 strncat (dest, &buddy[1], strlen(buddy)-3); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1062 strcat (dest, "\n"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1063 } else |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1064 strcat (dest, buddy); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1065 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1066 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1067 /* Syntax "group buddy buddy ..." */ |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1068 else { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1069 buddy = remove_spaces (strtok (line, " \n")); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1070 strcat (dest, "g "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1071 if (strchr (buddy, '\"') != NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1072 strcat (dest, &buddy[1]); |
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 while (strchr (buddy, '\"') == NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1076 strcat (dest, buddy); |
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 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1080 strncat (dest, buddy, strlen(buddy)-1); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1081 } else { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1082 strcat (dest, buddy); |
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 strcat (dest, "\n"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1085 while ((buddy = remove_spaces (strtok (NULL, " \n"))) != NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1086 strcat (dest, "b "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1087 if (strchr (buddy, '\"') != NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1088 strcat (dest, &buddy[1]); |
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 while (strchr (buddy, '\"') == NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1092 strcat (dest, buddy); |
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 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1096 strncat (dest, buddy, strlen(buddy)-1); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1097 } else { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1098 strcat (dest, buddy); |
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 strcat (dest, "\n"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1101 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1102 } |
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 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1105 return; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1106 } |
764 | 1107 |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1108 char *stylize(gchar *text, int length) |
764 | 1109 { |
1110 gchar *buf; | |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1111 char tmp[length]; |
764 | 1112 |
1113 buf = g_malloc(length); | |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1114 g_snprintf(buf, length, "%s", text); |
764 | 1115 |
1116 if (font_options & OPT_FONT_FACE) | |
1117 { | |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1118 g_snprintf(tmp, length, "<FONT FACE=\"%s\">%s</FONT>", fontface, buf); |
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1119 strcpy(buf, tmp); |
764 | 1120 } |
1121 | |
1122 if (font_options & OPT_FONT_FGCOL) | |
1123 { | |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1124 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
|
1125 strcpy(buf, tmp); |
764 | 1126 } |
1127 | |
1128 if (font_options & OPT_FONT_BGCOL) | |
1129 { | |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1130 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
|
1131 strcpy(buf, tmp); |
764 | 1132 } |
1133 | |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1134 return buf; |
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1135 } |