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