Mercurial > pidgin.yaz
annotate src/util.c @ 951:b6d0a7105780
[gaim-migrate @ 961]
0.10.3
committer: Tailor Script <tailor@pidgin.im>
author | Rob Flynn <gaim@robflynn.com> |
---|---|
date | Sat, 07 Oct 2000 09:41:39 +0000 |
parents | 9b04a3419351 |
children | fa681641643d |
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; | |
845
647b110f7a1a
[gaim-migrate @ 855]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
831
diff
changeset
|
124 char *cpy = g_malloc(strlen(text) * 2 + 1); |
1 | 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 } | |
856 | 143 } else if ( (!strncasecmp(c, "http://", 7) || (!strncasecmp(c, "https://", 8)))) { |
1 | 144 t = c; |
145 while(1) { | |
146 if (badchar(*t)) { | |
925 | 147 |
148 if (*(t) == ',' && (*(t+1) != ' ')) | |
149 { | |
150 t++; | |
151 continue; | |
152 } | |
153 | |
1 | 154 if (*(t-1) == '.') |
155 t--; | |
156 strncpy(url_buf, c, t-c); | |
157 url_buf[t-c] = 0; | |
158 cnt += g_snprintf(&text[cnt++], 1024, "<A HREF=\"%s\">%s</A>", url_buf, url_buf); | |
159 cnt--; | |
160 c = t; | |
161 break; | |
162 } | |
163 if (!t) | |
164 break; | |
165 t++; | |
166 | |
167 } | |
168 } else if (!strncasecmp(c, "www.", 4)) { | |
169 if (strncasecmp(c, "www..", 5)) { | |
170 t = c; | |
171 while(1) { | |
172 if (badchar(*t)) { | |
173 if (t-c == 4) { | |
174 break; | |
175 } | |
925 | 176 |
177 if (*(t) == ',' && (*(t+1) != ' ')) | |
178 { | |
179 t++; | |
180 continue; | |
181 } | |
182 | |
1 | 183 if (*(t-1) == '.') |
184 t--; | |
185 strncpy(url_buf, c, t-c); | |
186 url_buf[t-c] = 0; | |
187 cnt += g_snprintf(&text[cnt++], 1024, "<A HREF=\"http://%s\">%s</A>", url_buf, url_buf); | |
188 cnt--; | |
189 c = t; | |
190 break; | |
191 } | |
192 if (!t) | |
193 break; | |
194 t++; | |
195 } | |
196 } | |
197 } else if (!strncasecmp(c, "ftp://", 6)) { | |
198 t = c; | |
199 while(1) { | |
200 if (badchar(*t)) { | |
201 if (*(t-1) == '.') | |
202 t--; | |
203 strncpy(url_buf, c, t-c); | |
204 url_buf[t-c] = 0; | |
205 cnt += g_snprintf(&text[cnt++], 1024, "<A HREF=\"%s\">%s</A>", url_buf, url_buf); | |
206 cnt--; | |
207 c = t; | |
208 break; | |
209 } | |
210 if (!t) | |
211 break; | |
212 t++; | |
213 | |
214 } | |
924 | 215 } else if (!strncasecmp(c, "ftp.", 4) ) { |
216 if (strncasecmp(c, "ftp..", 5)) { | |
1 | 217 t = c; |
218 while(1) { | |
219 if (badchar(*t)) { | |
220 if (t-c == 4) { | |
221 break; | |
222 } | |
223 if (*(t-1) == '.') | |
224 t--; | |
225 strncpy(url_buf, c, t-c); | |
226 url_buf[t-c] = 0; | |
227 cnt += g_snprintf(&text[cnt++], 1024, "<A HREF=\"ftp://%s\">%s</A>", url_buf, url_buf); | |
228 cnt--; | |
229 c = t; | |
230 break; | |
231 } | |
232 if (!t) | |
233 break; | |
234 t++; | |
235 } | |
924 | 236 } |
1 | 237 } else if (!strncasecmp(c, "mailto:", 7)) { |
238 t = c; | |
239 while(1) { | |
240 if (badchar(*t)) { | |
241 if (*(t-1) == '.') | |
242 t--; | |
243 strncpy(url_buf, c, t-c); | |
244 url_buf[t-c] = 0; | |
245 cnt += g_snprintf(&text[cnt++], 1024, "<A HREF=\"%s\">%s</A>", url_buf, url_buf); | |
246 cnt--; | |
247 c = t; | |
248 break; | |
249 } | |
250 if (!t) | |
251 break; | |
252 t++; | |
253 | |
254 } | |
255 } else if (!strncasecmp(c, "@", 1)) { | |
256 char *tmp; | |
257 int flag; | |
258 int len=0; | |
924 | 259 char illegal_chars[] = "!@#$%^&*()[]{}/\\<>\":;\0"; |
1 | 260 url_buf[0] = 0; |
261 | |
927 | 262 if (*(c-1) == ' ' || *(c+1) == ' ' || rindex(illegal_chars, *(c+1)) || *(c+1) == 13 || *(c+1) == 10) |
1 | 263 flag = 0; |
264 else | |
265 flag = 1; | |
266 | |
267 t = c; | |
268 while(flag) { | |
269 if (badchar(*t)) { | |
270 cnt -= (len - 1); | |
271 break; | |
272 } else { | |
273 len++; | |
274 tmp = g_malloc(len + 1); | |
275 tmp[len] = 0; | |
276 tmp[0] = *t; | |
277 strncpy(tmp + 1, url_buf, len - 1); | |
278 strcpy(url_buf, tmp); | |
279 url_buf[len] = 0; | |
280 g_free(tmp); | |
281 t--; | |
282 if (t < cpy) { | |
283 cnt = 0; | |
284 break; | |
285 } | |
286 } | |
287 } | |
288 | |
289 | |
290 t = c + 1; | |
291 | |
292 while(flag) { | |
293 if (badchar(*t)) { | |
294 if (*(t-1) == '.') | |
295 t--; | |
296 cnt += g_snprintf(&text[cnt++], 1024, "<A HREF=\"mailto:%s\">%s</A>", url_buf, url_buf); | |
297 text[cnt]=0; | |
298 | |
299 | |
300 cnt--; | |
301 c = t; | |
302 | |
303 break; | |
304 } else { | |
305 strncat(url_buf, t, 1); | |
306 len++; | |
307 url_buf[len] = 0; | |
308 } | |
309 | |
310 t++; | |
311 | |
312 } | |
313 | |
314 | |
315 } | |
316 | |
317 if (*c == 0) | |
318 break; | |
319 | |
320 text[cnt++] = *c; | |
321 c++; | |
322 | |
323 } | |
324 text[cnt]=0; | |
845
647b110f7a1a
[gaim-migrate @ 855]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
831
diff
changeset
|
325 g_free(cpy); |
1 | 326 return cnt; |
327 } | |
328 | |
329 | |
373
1d29321843b0
[gaim-migrate @ 383]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
330 FILE *open_log_file (char *name) |
1 | 331 { |
79 | 332 char *buf; |
333 char *buf2; | |
1 | 334 char log_all_file[256]; |
335 struct log_conversation *l; | |
336 struct stat st; | |
337 int flag = 0; | |
338 FILE *fd; | |
339 int res; | |
340 | |
341 if (!(general_options & OPT_GEN_LOG_ALL)) { | |
342 | |
373
1d29321843b0
[gaim-migrate @ 383]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
343 l = find_log_info(name); |
1 | 344 if (!l) |
345 return NULL; | |
346 | |
347 if (stat(l->filename, &st) < 0) | |
348 flag = 1; | |
349 | |
350 fd = fopen(l->filename, "a"); | |
351 | |
352 if (flag) { /* is a new file */ | |
353 fprintf(fd, "<HTML><HEAD><TITLE>" ); | |
373
1d29321843b0
[gaim-migrate @ 383]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
354 fprintf(fd, "IM Sessions with %s", name ); |
1 | 355 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"ffffff\">\n" ); |
356 } | |
357 | |
358 return fd; | |
359 } | |
360 | |
79 | 361 buf = g_malloc(BUF_LONG); |
362 buf2 = g_malloc(BUF_LONG); | |
363 | |
1 | 364 /* Dont log yourself */ |
365 g_snprintf(log_all_file, 256, "%s/.gaim", getenv("HOME")); | |
366 | |
367 stat(log_all_file, &st); | |
368 if (!S_ISDIR(st.st_mode)) | |
369 unlink(log_all_file); | |
370 | |
371 fd = fopen(log_all_file, "r"); | |
372 | |
373 if (!fd) { | |
374 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR); | |
375 if (res < 0) { | |
376 g_snprintf(buf, BUF_LONG, "Unable to make directory %s for logging", log_all_file); | |
377 do_error_dialog(buf, "Error!"); | |
378 g_free(buf); | |
379 g_free(buf2); | |
380 return NULL; | |
381 } | |
382 } else | |
383 fclose(fd); | |
384 | |
385 g_snprintf(log_all_file, 256, "%s/.gaim/%s", getenv("HOME"), current_user->username); | |
386 | |
387 if (stat(log_all_file, &st) < 0) | |
388 flag = 1; | |
389 if (!S_ISDIR(st.st_mode)) | |
390 unlink(log_all_file); | |
391 | |
392 fd = fopen(log_all_file, "r"); | |
393 if (!fd) { | |
394 res = mkdir(log_all_file, S_IRUSR | S_IWUSR | S_IXUSR); | |
395 if (res < 0) { | |
396 g_snprintf(buf, BUF_LONG, "Unable to make directory %s for logging", log_all_file); | |
397 do_error_dialog(buf, "Error!"); | |
398 g_free(buf); | |
399 g_free(buf2); | |
400 return NULL; | |
401 } | |
402 } else | |
403 fclose(fd); | |
404 | |
405 | |
373
1d29321843b0
[gaim-migrate @ 383]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
406 g_snprintf(log_all_file, 256, "%s/.gaim/%s/%s.log", getenv("HOME"), current_user->username, normalize(name)); |
1 | 407 |
408 if (stat(log_all_file, &st) < 0) | |
409 flag = 1; | |
410 | |
411 sprintf(debug_buff,"Logging to: \"%s\"\n", log_all_file); | |
412 debug_print(debug_buff); | |
413 | |
414 fd = fopen(log_all_file, "a"); | |
415 | |
416 if (flag) { /* is a new file */ | |
417 fprintf(fd, "<HTML><HEAD><TITLE>" ); | |
373
1d29321843b0
[gaim-migrate @ 383]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
349
diff
changeset
|
418 fprintf(fd, "IM Sessions with %s", name ); |
1 | 419 fprintf(fd, "</TITLE></HEAD><BODY BGCOLOR=\"ffffff\">\n" ); |
420 } | |
25 | 421 |
422 g_free(buf); | |
423 g_free(buf2); | |
1 | 424 return fd; |
425 } | |
426 | |
427 | |
254
fa67d29b53d5
[gaim-migrate @ 264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
428 /* we only need this for TOC, because messages must be escaped */ |
1 | 429 int escape_message(char *msg) |
430 { | |
423
0d4e80bdb96b
[gaim-migrate @ 433]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
413
diff
changeset
|
431 if (!USE_OSCAR) { |
1 | 432 char *c, *cpy; |
433 int cnt=0; | |
434 /* Assumes you have a buffer able to cary at least BUF_LEN * 2 bytes */ | |
435 if (strlen(msg) > BUF_LEN) { | |
436 sprintf(debug_buff, "Warning: truncating message to 2048 bytes\n"); | |
437 debug_print(debug_buff); | |
438 msg[2047]='\0'; | |
439 } | |
440 | |
441 cpy = g_strdup(msg); | |
442 c = cpy; | |
443 while(*c) { | |
444 switch(*c) { | |
445 case '$': | |
446 case '[': | |
447 case ']': | |
448 case '(': | |
449 case ')': | |
450 case '#': | |
451 msg[cnt++]='\\'; | |
452 /* Fall through */ | |
453 default: | |
454 msg[cnt++]=*c; | |
455 } | |
456 c++; | |
457 } | |
458 msg[cnt]='\0'; | |
459 g_free(cpy); | |
460 return cnt; | |
423
0d4e80bdb96b
[gaim-migrate @ 433]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
413
diff
changeset
|
461 } else { |
254
fa67d29b53d5
[gaim-migrate @ 264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
462 return strlen(msg); |
423
0d4e80bdb96b
[gaim-migrate @ 433]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
413
diff
changeset
|
463 } |
1 | 464 } |
465 | |
254
fa67d29b53d5
[gaim-migrate @ 264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
466 /* we don't need this for oscar either */ |
1 | 467 int escape_text(char *msg) |
468 { | |
423
0d4e80bdb96b
[gaim-migrate @ 433]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
413
diff
changeset
|
469 if (!USE_OSCAR) { |
1 | 470 char *c, *cpy; |
471 int cnt=0; | |
79 | 472 /* Assumes you have a buffer able to cary at least BUF_LEN * 4 bytes */ |
1 | 473 if (strlen(msg) > BUF_LEN) { |
474 fprintf(stderr, "Warning: truncating message to 2048 bytes\n"); | |
475 msg[2047]='\0'; | |
476 } | |
477 | |
478 cpy = g_strdup(msg); | |
479 c = cpy; | |
480 while(*c) { | |
481 switch(*c) { | |
482 case '\n': | |
483 msg[cnt++] = '<'; | |
484 msg[cnt++] = 'B'; | |
485 msg[cnt++] = 'R'; | |
486 msg[cnt++] = '>'; | |
487 break; | |
488 case '{': | |
489 case '}': | |
490 case '\\': | |
491 case '"': | |
492 msg[cnt++]='\\'; | |
493 /* Fall through */ | |
494 default: | |
495 msg[cnt++]=*c; | |
496 } | |
497 c++; | |
498 } | |
499 msg[cnt]='\0'; | |
500 g_free(cpy); | |
501 return cnt; | |
423
0d4e80bdb96b
[gaim-migrate @ 433]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
413
diff
changeset
|
502 } else { |
254
fa67d29b53d5
[gaim-migrate @ 264]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
210
diff
changeset
|
503 return strlen(msg); |
423
0d4e80bdb96b
[gaim-migrate @ 433]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
413
diff
changeset
|
504 } |
1 | 505 } |
506 | |
507 char * escape_text2(char *msg) | |
508 { | |
509 char *c, *cpy; | |
510 char *woo; | |
511 int cnt=0; | |
512 /* Assumes you have a buffer able to cary at least BUF_LEN * 2 bytes */ | |
513 if (strlen(msg) > BUF_LEN) { | |
514 fprintf(stderr, "Warning: truncating message to 2048 bytes\n"); | |
515 msg[2047]='\0'; | |
516 } | |
517 | |
79 | 518 woo = malloc(strlen(msg) * 2); |
1 | 519 cpy = g_strdup(msg); |
520 c = cpy; | |
521 while(*c) { | |
522 switch(*c) { | |
523 case '\n': | |
524 woo[cnt++] = '<'; | |
525 woo[cnt++] = 'B'; | |
526 woo[cnt++] = 'R'; | |
527 woo[cnt++] = '>'; | |
528 break; | |
529 case '{': | |
530 case '}': | |
531 case '\\': | |
532 case '"': | |
533 woo[cnt++]='\\'; | |
534 /* Fall through */ | |
535 default: | |
536 woo[cnt++]=*c; | |
537 } | |
538 c++; | |
539 } | |
540 woo[cnt]='\0'; | |
26 | 541 |
542 g_free (cpy); | |
1 | 543 return woo; |
544 } | |
545 | |
546 | |
547 char alphabet[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" | |
548 "0123456789+/"; | |
549 | |
550 | |
551 char *tobase64(char *text) | |
552 { | |
553 char *out = NULL; | |
554 char *c; | |
555 unsigned int tmp = 0; | |
556 int len = 0, n = 0; | |
557 | |
558 c = text; | |
559 | |
560 while(c) { | |
561 tmp = tmp << 8; | |
562 tmp += *c; | |
563 n++; | |
564 | |
565 if (n == 3) { | |
566 out = g_realloc(out, len+4); | |
567 out[len] = alphabet[(tmp >> 18) & 0x3f]; | |
568 out[len+1] = alphabet[(tmp >> 12) & 0x3f]; | |
569 out[len+2] = alphabet[(tmp >> 6) & 0x3f]; | |
570 out[len+3] = alphabet[tmp & 0x3f]; | |
571 len += 4; | |
572 tmp = 0; | |
573 n = 0; | |
574 } | |
575 c++; | |
576 } | |
577 switch(n) { | |
578 | |
579 case 2: | |
580 out = g_realloc(out, len+5); | |
581 out[len] = alphabet[(tmp >> 12) & 0x3f]; | |
582 out[len+1] = alphabet[(tmp >> 6) & 0x3f]; | |
583 out[len+2] = alphabet[tmp & 0x3f]; | |
584 out[len+3] = '='; | |
585 out[len+4] = 0; | |
586 break; | |
587 case 1: | |
588 out = g_realloc(out, len+4); | |
589 out[len] = alphabet[(tmp >> 6) & 0x3f]; | |
590 out[len+1] = alphabet[tmp & 0x3f]; | |
591 out[len+2] = '='; | |
592 out[len+3] = 0; | |
593 break; | |
594 case 0: | |
595 out = g_realloc(out, len+2); | |
596 out[len] = '='; | |
597 out[len+1] = 0; | |
598 break; | |
599 } | |
600 return out; | |
601 } | |
602 | |
603 | |
604 char *frombase64(char *text) | |
605 { | |
606 char *out = NULL; | |
607 char tmp = 0; | |
608 char *c; | |
609 gint32 tmp2 = 0; | |
610 int len = 0, n = 0; | |
611 | |
612 c = text; | |
613 | |
614 while(*c) { | |
615 if (*c >= 'A' && *c <= 'Z') { | |
616 tmp = *c - 'A'; | |
617 } else if (*c >= 'a' && *c <= 'z') { | |
618 tmp = 26 + (*c - 'a'); | |
619 } else if (*c >= '0' && *c <= 57) { | |
620 tmp = 52 + (*c - '0'); | |
621 } else if (*c == '+') { | |
622 tmp = 62; | |
623 } else if (*c == '/') { | |
624 tmp = 63; | |
625 } else if (*c == '=') { | |
626 if (n == 3) { | |
627 out = g_realloc(out, len + 2); | |
628 out[len] = (char)(tmp2 >> 10) & 0xff; | |
629 len++; | |
630 out[len] = (char)(tmp2 >> 2) & 0xff; | |
631 len++; | |
632 } else if (n == 2) { | |
633 out = g_realloc(out, len + 1); | |
634 out[len] = (char)(tmp2 >> 4) & 0xff; | |
635 len++; | |
636 } | |
637 break; | |
638 } | |
639 tmp2 = ((tmp2 << 6) | (tmp & 0xff)); | |
640 n++; | |
641 if (n == 4) { | |
642 out = g_realloc(out, len + 3); | |
643 out[len] = (char)((tmp2 >> 16) & 0xff); | |
644 len++; | |
645 out[len] = (char)((tmp2 >> 8) & 0xff); | |
646 len++; | |
647 out[len] = (char)(tmp2 & 0xff); | |
648 len++; | |
649 tmp2 = 0; | |
650 n = 0; | |
651 } | |
652 c++; | |
653 } | |
654 | |
194
d7690984c0f1
[gaim-migrate @ 204]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
180
diff
changeset
|
655 out = g_realloc(out, len+1); |
1 | 656 out[len] = 0; |
657 | |
658 return out; | |
659 } | |
660 | |
661 | |
662 char *normalize(const char *s) | |
663 { | |
664 static char buf[BUF_LEN]; | |
665 char *t, *u; | |
666 int x=0; | |
667 | |
79 | 668 g_return_val_if_fail ((s != NULL), NULL); |
26 | 669 |
670 u = t = g_strdup(s); | |
1 | 671 |
672 strcpy(t, s); | |
673 g_strdown(t); | |
674 | |
26 | 675 while(*t && (x < BUF_LEN - 1)) { |
1 | 676 if (*t != ' ') { |
677 buf[x] = *t; | |
678 x++; | |
679 } | |
680 t++; | |
681 } | |
682 buf[x]='\0'; | |
683 g_free(u); | |
684 return buf; | |
685 } | |
686 | |
687 int query_state() | |
688 { | |
689 return state; | |
690 } | |
691 | |
692 void set_state(int i) | |
693 { | |
694 state = i; | |
695 } | |
696 | |
697 char *date() | |
698 { | |
699 static char date[80]; | |
700 time_t tme; | |
701 time(&tme); | |
702 strftime(date, sizeof(date), "%H:%M:%S", localtime(&tme)); | |
703 return date; | |
704 } | |
705 | |
706 | |
707 gint clean_pid(void *dummy) | |
708 { | |
709 int status; | |
710 pid_t pid; | |
711 | |
712 pid = waitpid(-1, &status, WNOHANG); | |
713 | |
714 if (pid == 0) | |
715 return TRUE; | |
716 | |
717 return FALSE; | |
718 } | |
719 | |
720 void aol_icon(GdkWindow *w) | |
721 { | |
722 #ifndef _WIN32 | |
723 if (icon_pm == NULL) { | |
724 icon_pm = gdk_pixmap_create_from_xpm_d(w, &icon_bm, | |
725 NULL, (gchar **)aimicon_xpm); | |
726 } | |
727 gdk_window_set_icon(w, NULL, icon_pm, icon_bm); | |
10 | 728 if (mainwindow) gdk_window_set_group(w, mainwindow->window); |
1 | 729 #endif |
730 } | |
731 | |
732 struct aim_user *find_user(const char *name) | |
733 { | |
734 char *who = g_strdup(normalize(name)); | |
735 GList *usr = aim_users; | |
736 struct aim_user *u; | |
737 | |
738 while(usr) { | |
739 u = (struct aim_user *)usr->data; | |
740 if (!strcmp(normalize(u->username), who)) { | |
741 g_free(who); | |
742 return u; | |
743 } | |
744 usr = usr->next; | |
745 } | |
746 g_free(who); | |
747 return NULL; | |
748 } | |
180 | 749 |
750 void check_gaim_versions() | |
751 { | |
752 char *cur_ver; | |
753 char *tmp; | |
754 | |
755 tmp = (char *)malloc(BUF_LONG); | |
756 | |
757 cur_ver = (char *)grab_url("http://www.marko.net/gaim/latest-gaim"); | |
758 | |
759 if (!strncasecmp(cur_ver, "g00", 3)) | |
760 { | |
278
29e1669b006b
[gaim-migrate @ 288]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
254
diff
changeset
|
761 g_free(cur_ver); |
29e1669b006b
[gaim-migrate @ 288]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
254
diff
changeset
|
762 g_free(tmp); |
180 | 763 return; |
764 } | |
765 | |
766 g_snprintf(tmp, BUF_LONG, "%s", strstr(cur_ver, "plain")+9); | |
767 g_strchomp(tmp); | |
768 | |
278
29e1669b006b
[gaim-migrate @ 288]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
254
diff
changeset
|
769 if (strcmp(tmp, latest_ver)) |
180 | 770 { |
771 g_snprintf(cur_ver, BUF_LONG, "GAIM v%s is now available.\n\nDownload it at http://www.marko.net/gaim\n", tmp); | |
772 | |
773 do_error_dialog(cur_ver, "GAIM - New Version!"); | |
774 strcpy(latest_ver, tmp); | |
775 save_prefs(); | |
776 } | |
777 | |
778 free(tmp); | |
779 free(cur_ver); | |
780 } | |
781 | |
782 | |
206 | 783 /* |
784 | |
785 This function was taken from EveryBuddy and was written by | |
786 Torrey Searle. tsearle@valhalla.marko.net | |
787 | |
788 http://www.everybuddy.com | |
789 | |
790 */ | |
791 | |
209 | 792 void spell_checker(GtkWidget * text) |
206 | 793 { |
794 int start = 0; | |
795 int end = 0; | |
796 static GdkColor * color = NULL; | |
797 int ignore = 0; | |
798 int point = gtk_editable_get_position(GTK_EDITABLE(text)); | |
799 | |
800 GString * string; | |
801 | |
802 if( color == NULL ) | |
803 { | |
804 GdkColormap * gc = gtk_widget_get_colormap( text ); | |
805 color = g_new0(GdkColor, 1); | |
806 color->red = 255 * 256; | |
807 gdk_colormap_alloc_color(gc, color, FALSE, TRUE); | |
808 } | |
809 | |
810 | |
811 | |
812 end = point-1; | |
813 for( start = end-1; start >= 0; start-- ) | |
814 { | |
815 if((isspace(GTK_TEXT_INDEX(GTK_TEXT(text), start)) || start == 0) | |
816 && !ignore) | |
817 { | |
818 char * word; | |
819 FILE * file; | |
820 char buff[1024]; | |
821 word = gtk_editable_get_chars( GTK_EDITABLE(text), start, end ); | |
822 g_snprintf(buff, 1024, "echo \"%s\" | ispell -l", word ); | |
823 file = popen(buff, "r"); | |
824 | |
825 buff[0] = 0; | |
826 fgets(buff, 255, file); | |
827 | |
828 if(strlen(buff) > 0 ) | |
829 { | |
830 string = g_string_new(word); | |
831 gtk_text_set_point(GTK_TEXT(text), end); | |
832 gtk_text_backward_delete(GTK_TEXT(text), end-start); | |
833 gtk_text_insert( GTK_TEXT(text), NULL, color, NULL, | |
834 string->str, string->len ); | |
835 g_string_free( string, TRUE ); | |
836 } | |
837 else | |
838 { | |
839 string = g_string_new(word); | |
840 gtk_text_set_point(GTK_TEXT(text), end); | |
841 gtk_text_backward_delete(GTK_TEXT(text), end-start); | |
842 gtk_text_insert( GTK_TEXT(text), NULL, &(text->style->fg[0]), NULL, | |
843 string->str, string->len ); | |
844 g_string_free( string, TRUE ); | |
845 } | |
846 pclose( file); | |
846
4b05985bae5e
[gaim-migrate @ 856]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
845
diff
changeset
|
847 g_free(word); |
206 | 848 break; |
849 } | |
850 else if(!isalpha(GTK_TEXT_INDEX(GTK_TEXT(text), start))) | |
851 { | |
852 ignore = 1; | |
853 } | |
854 } | |
855 gtk_text_set_point(GTK_TEXT(text), point); | |
856 | |
857 } | |
858 | |
592
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
859 /* 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
|
860 or time */ |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
861 char *away_subs(char *msg, char *name) |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
862 { |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
863 char *c; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
864 static char cpy[BUF_LONG]; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
865 int cnt=0; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
866 time_t t = time(0); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
867 struct tm *tme = localtime(&t); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
868 char tmp[20]; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
869 |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
870 cpy[0] = '\0'; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
871 c = msg; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
872 while(*c) { |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
873 switch(*c) { |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
874 case '%': |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
875 if (*(c+1)) { |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
876 switch (*(c+1)) { |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
877 case 'n': |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
878 // append name |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
879 strcpy (cpy+cnt, name); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
880 cnt += strlen(name); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
881 c++; |
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 case 'd': |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
884 // append date |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
885 strftime (tmp, 20, "%D", tme); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
886 strcpy (cpy+cnt, tmp); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
887 cnt += strlen(tmp); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
888 c++; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
889 break; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
890 case 't': |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
891 // append time |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
892 strftime (tmp, 20, "%r", tme); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
893 strcpy (cpy+cnt, tmp); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
894 cnt += strlen(tmp); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
895 c++; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
896 break; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
897 default: |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
898 cpy[cnt++]=*c; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
899 } |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
900 } |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
901 break; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
902 default: |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
903 cpy[cnt++]=*c; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
904 } |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
905 c++; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
906 } |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
907 cpy[cnt]='\0'; |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
908 return(cpy); |
7c75d69a1129
[gaim-migrate @ 602]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
470
diff
changeset
|
909 } |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
910 |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
911 GtkWidget *picture_button(GtkWidget *window, char *text, char **xpm) |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
912 { |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
913 GtkWidget *button; |
619 | 914 GtkWidget *button_box, *button_box_2, *button_box_3; |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
915 GtkWidget *label; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
916 GdkBitmap *mask; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
917 GdkPixmap *pm; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
918 GtkWidget *pixmap; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
919 |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
920 button = gtk_button_new(); |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
921 if (display_options & OPT_DISP_COOL_LOOK) |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
922 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
923 |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
924 button_box = gtk_hbox_new(FALSE, 5); |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
925 gtk_container_add(GTK_CONTAINER(button), button_box); |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
926 |
619 | 927 button_box_2 = gtk_hbox_new(FALSE, 0); |
928 button_box_3 = gtk_hbox_new(FALSE, 0); | |
929 gtk_box_pack_start(GTK_BOX(button_box), button_box_2, TRUE, TRUE, 0); | |
930 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
|
931 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
|
932 pixmap = gtk_pixmap_new(pm, mask); |
619 | 933 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
|
934 |
623 | 935 if (text) |
936 { | |
937 label = gtk_label_new(text); | |
938 gtk_box_pack_start(GTK_BOX(button_box_3), label, FALSE, FALSE, 2); | |
939 } | |
619 | 940 |
941 gtk_widget_show(pixmap); | |
623 | 942 if (text) |
943 { | |
944 gtk_widget_show(label); | |
945 } | |
619 | 946 gtk_widget_show(button_box_2); |
947 gtk_widget_show(button_box_3); | |
948 gtk_widget_show(button_box); | |
651 | 949 |
726 | 950 /* this causes clipping on lots of buttons with long text */ |
951 /* gtk_widget_set_usize(button, 75, 30);*/ | |
619 | 952 gtk_widget_show(button); |
644
b3900e312d8e
[gaim-migrate @ 654]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
623
diff
changeset
|
953 gdk_pixmap_unref(pm); |
804
17def2bb9720
[gaim-migrate @ 814]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
770
diff
changeset
|
954 gdk_bitmap_unref(mask); |
619 | 955 |
603
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
956 return button; |
9b0717b4a490
[gaim-migrate @ 613]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
592
diff
changeset
|
957 } |
623 | 958 |
759
9389216aae29
[gaim-migrate @ 769]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
754
diff
changeset
|
959 static GtkTooltips *tips = NULL; |
915
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
960 GtkWidget *picture_button2(GtkWidget *window, char *text, char **xpm, short dispstyle) |
623 | 961 { |
962 GtkWidget *button; | |
963 GtkWidget *button_box, *button_box_2; | |
964 GdkBitmap *mask; | |
965 GdkPixmap *pm; | |
966 GtkWidget *pixmap; | |
754 | 967 GtkWidget *label; |
623 | 968 |
759
9389216aae29
[gaim-migrate @ 769]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
754
diff
changeset
|
969 if (!tips) tips = gtk_tooltips_new(); |
623 | 970 button = gtk_button_new(); |
971 if (display_options & OPT_DISP_COOL_LOOK) | |
972 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
973 | |
651 | 974 button_box = gtk_hbox_new(FALSE, 0); |
623 | 975 gtk_container_add(GTK_CONTAINER(button), button_box); |
976 | |
754 | 977 button_box_2 = gtk_vbox_new(FALSE, 0); |
623 | 978 |
979 gtk_box_pack_start(GTK_BOX(button_box), button_box_2, TRUE, TRUE, 0); | |
915
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
980 if (dispstyle == 2 || dispstyle == 0) { |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
981 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
|
982 pixmap = gtk_pixmap_new(pm, mask); |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
983 gtk_box_pack_start(GTK_BOX(button_box_2), pixmap, FALSE, FALSE, 0); |
754 | 984 |
915
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
985 gtk_widget_show(pixmap); |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
986 |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
987 } |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
988 |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
989 if (dispstyle == 2 || dispstyle == 1) |
754 | 990 { |
991 label = gtk_label_new(text); | |
992 gtk_widget_show(label); | |
993 gtk_box_pack_end(GTK_BOX(button_box_2), label, FALSE, FALSE, 0); | |
994 } | |
623 | 995 |
996 gtk_widget_show(button_box_2); | |
997 gtk_widget_show(button_box); | |
998 gtk_widget_show(button); | |
915
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
999 if (dispstyle == 2 || dispstyle == 0) { |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1000 gdk_pixmap_unref(pm); |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1001 gdk_bitmap_unref(mask); |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1002 } |
623 | 1003 |
1004 gtk_tooltips_set_tip(tips, button, text, "Gaim"); | |
1005 return button; | |
1006 } | |
1007 | |
684
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1008 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1009 /* remove leading whitespace from a string */ |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1010 char *remove_spaces (char *str) |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1011 { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1012 int i; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1013 char *new; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1014 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1015 if (str == NULL) |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1016 return NULL; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1017 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1018 i = strspn (str, " \t\n\r\f"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1019 new = &str[i]; |
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 return new; |
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 |
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 /* translate an AIM 3 buddylist (*.lst) to a GAIM buddylist */ |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1026 void translate_lst (FILE *src_fp, char *dest) |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1027 { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1028 char line[BUF_LEN], *line2; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1029 char *name; |
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 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1032 sprintf (dest, "m 1\n"); |
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 while (fgets (line, BUF_LEN, src_fp)) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1035 line2 = remove_spaces (line); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1036 if (strstr (line2, "group") == line2) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1037 name = strpbrk (line2, " \t\n\r\f") + 1; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1038 strcat (dest, "g "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1039 for (i = 0; i < strcspn (name, "\n\r"); i++) |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1040 if (name[i] != '\"') |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1041 strncat (dest, &name[i], 1); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1042 strcat (dest, "\n"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1043 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1044 if (strstr (line2, "buddy") == line2) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1045 name = strpbrk (line2, " \t\n\r\f") + 1; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1046 strcat (dest, "b "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1047 for (i = 0; i < strcspn (name, "\n\r"); i++) |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1048 if (name[i] != '\"') |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1049 strncat (dest, &name[i], 1); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1050 strcat (dest, "\n"); |
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 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1053 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1054 return; |
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 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1057 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1058 /* translate an AIM 4 buddylist (*.blt) to GAIM format */ |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1059 void translate_blt (FILE *src_fp, char *dest) |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1060 { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1061 int i; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1062 char line[BUF_LEN]; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1063 char *buddy; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1064 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1065 sprintf (dest, "m 1\n"); |
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 while (strstr (fgets (line, BUF_LEN, src_fp), "Buddy") == NULL) ; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1068 while (strstr (fgets (line, BUF_LEN, src_fp), "list") == NULL) ; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1069 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1070 while (1) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1071 fgets (line, BUF_LEN, src_fp); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1072 if (strchr (line, '}') != NULL) |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1073 break; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1074 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1075 /* Syntax starting with "<group> {" */ |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1076 if (strchr (line, '{') != NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1077 strcat (dest, "g "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1078 buddy = remove_spaces (strtok (line, "{")); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1079 for (i = 0; i < strlen(buddy); i++) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1080 if (buddy[i] != '\"') |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1081 strncat (dest, &buddy[i], 1); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1082 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1083 strcat (dest, "\n"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1084 while (strchr (fgets (line, BUF_LEN, src_fp), '}') == NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1085 buddy = remove_spaces (line); |
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 strncat (dest, &buddy[1], strlen(buddy)-3); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1089 strcat (dest, "\n"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1090 } else |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1091 strcat (dest, buddy); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1092 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1093 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1094 /* Syntax "group buddy buddy ..." */ |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1095 else { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1096 buddy = remove_spaces (strtok (line, " \n")); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1097 strcat (dest, "g "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1098 if (strchr (buddy, '\"') != NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1099 strcat (dest, &buddy[1]); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1100 strcat (dest, " "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1101 buddy = remove_spaces (strtok (NULL, " \n")); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1102 while (strchr (buddy, '\"') == NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1103 strcat (dest, buddy); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1104 strcat (dest, " "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1105 buddy = remove_spaces (strtok (NULL, " \n")); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1106 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1107 strncat (dest, buddy, strlen(buddy)-1); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1108 } else { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1109 strcat (dest, buddy); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1110 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1111 strcat (dest, "\n"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1112 while ((buddy = remove_spaces (strtok (NULL, " \n"))) != NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1113 strcat (dest, "b "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1114 if (strchr (buddy, '\"') != NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1115 strcat (dest, &buddy[1]); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1116 strcat (dest, " "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1117 buddy = remove_spaces (strtok (NULL, " \n")); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1118 while (strchr (buddy, '\"') == NULL) { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1119 strcat (dest, buddy); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1120 strcat (dest, " "); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1121 buddy = remove_spaces (strtok (NULL, " \n")); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1122 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1123 strncat (dest, buddy, strlen(buddy)-1); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1124 } else { |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1125 strcat (dest, buddy); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1126 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1127 strcat (dest, "\n"); |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1128 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1129 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1130 } |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1131 |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1132 return; |
b29c92be568b
[gaim-migrate @ 694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
651
diff
changeset
|
1133 } |
764 | 1134 |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1135 char *stylize(gchar *text, int length) |
764 | 1136 { |
1137 gchar *buf; | |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1138 char tmp[length]; |
764 | 1139 |
1140 buf = g_malloc(length); | |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1141 g_snprintf(buf, length, "%s", text); |
764 | 1142 |
831
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1143 if (font_options & OPT_FONT_BOLD) { |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1144 g_snprintf(tmp, length, "<B>%s</B>", buf); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1145 strcpy(buf, tmp); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1146 } |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1147 |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1148 if (font_options & OPT_FONT_ITALIC) { |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1149 g_snprintf(tmp, length, "<I>%s</I>", buf); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1150 strcpy(buf, tmp); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1151 } |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1152 |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1153 if (font_options & OPT_FONT_UNDERLINE) { |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1154 g_snprintf(tmp, length, "<U>%s</U>", buf); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1155 strcpy(buf, tmp); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1156 } |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1157 |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1158 if (font_options & OPT_FONT_STRIKE) { |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1159 g_snprintf(tmp, length, "<S>%s</S>", buf); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1160 strcpy(buf, tmp); |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1161 } |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1162 |
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1163 if (font_options & OPT_FONT_FACE) { |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1164 g_snprintf(tmp, length, "<FONT FACE=\"%s\">%s</FONT>", fontface, buf); |
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1165 strcpy(buf, tmp); |
764 | 1166 } |
1167 | |
831
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1168 if (font_options & OPT_FONT_FGCOL) { |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1169 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
|
1170 strcpy(buf, tmp); |
764 | 1171 } |
1172 | |
831
97f1ae636ed7
[gaim-migrate @ 841]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
804
diff
changeset
|
1173 if (font_options & OPT_FONT_BGCOL) { |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1174 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
|
1175 strcpy(buf, tmp); |
764 | 1176 } |
1177 | |
765
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1178 return buf; |
bf31bf916f53
[gaim-migrate @ 775]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
764
diff
changeset
|
1179 } |
915
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 int set_dispstyle (int chat) |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1182 { |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1183 int dispstyle; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1184 |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1185 if (chat) { |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1186 switch (display_options & (OPT_DISP_CHAT_BUTTON_TEXT | |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1187 OPT_DISP_CHAT_BUTTON_XPM)) { |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1188 case OPT_DISP_CHAT_BUTTON_TEXT: |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1189 dispstyle = 1; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1190 break; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1191 case OPT_DISP_CHAT_BUTTON_XPM: |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1192 dispstyle = 0; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1193 break; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1194 default: /* both or neither */ |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1195 dispstyle = 2; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1196 break; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1197 } |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1198 } else { |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1199 switch (display_options & (OPT_DISP_CONV_BUTTON_TEXT | |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1200 OPT_DISP_CONV_BUTTON_XPM)) { |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1201 case OPT_DISP_CONV_BUTTON_TEXT: |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1202 dispstyle = 1; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1203 break; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1204 case OPT_DISP_CONV_BUTTON_XPM: |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1205 dispstyle = 0; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1206 break; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1207 default: /* both or neither */ |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1208 dispstyle = 2; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1209 break; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1210 } |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1211 } |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1212 return dispstyle; |
378c862a2381
[gaim-migrate @ 925]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
856
diff
changeset
|
1213 } |