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