Mercurial > pidgin
annotate plugins/log_reader.c @ 13770:9df4a46b0bb3
[gaim-migrate @ 16182]
SF Patch #1460287 from Jrme Poulin (ticpu), with a bug fix by Sadrul
Currently, with a string like "vnc://ticpu.myftp.org:1/", the "ftp.org:1/"
portion will be linkified as an FTP URL. This patch corrects that.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Fri, 12 May 2006 21:50:19 +0000 |
parents | 85267a333422 |
children | 8bda65b88e49 |
rev | line source |
---|---|
11459 | 1 #ifdef HAVE_CONFIG_H |
2 # include <config.h> | |
3 #endif | |
4 | |
5 #include <stdio.h> | |
6 | |
7 #ifndef GAIM_PLUGINS | |
8 # define GAIM_PLUGINS | |
9 #endif | |
10 | |
11 #include "internal.h" | |
12 | |
13 #include "debug.h" | |
14 #include "log.h" | |
15 #include "plugin.h" | |
16 #include "pluginpref.h" | |
17 #include "prefs.h" | |
18 #include "stringref.h" | |
19 #include "util.h" | |
20 #include "version.h" | |
21 #include "xmlnode.h" | |
22 | |
23 /* This must be the last Gaim header included. */ | |
24 #ifdef _WIN32 | |
25 #include "win32dep.h" | |
26 #endif | |
27 | |
28 /* Where is the Windows partition mounted? */ | |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
29 #ifndef GAIM_LOG_READER_WINDOWS_MOUNT_POINT |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
30 #define GAIM_LOG_READER_WINDOWS_MOUNT_POINT "/mnt/windows" |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
31 #endif |
11459 | 32 |
33 enum name_guesses { | |
34 NAME_GUESS_UNKNOWN, | |
35 NAME_GUESS_ME, | |
36 NAME_GUESS_THEM | |
37 }; | |
38 | |
39 | |
40 /***************************************************************************** | |
41 * Adium Logger * | |
42 *****************************************************************************/ | |
43 | |
44 /* The adium logger doesn't write logs, only reads them. This is to include | |
45 * Adium logs in the log viewer transparently. | |
46 */ | |
47 | |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
48 static GaimLogLogger *adium_logger; |
11459 | 49 |
50 enum adium_log_type { | |
51 ADIUM_HTML, | |
52 ADIUM_TEXT, | |
53 }; | |
54 | |
55 struct adium_logger_data { | |
56 char *path; | |
57 enum adium_log_type type; | |
58 }; | |
59 | |
60 static GList *adium_logger_list(GaimLogType type, const char *sn, GaimAccount *account) | |
61 { | |
62 GList *list = NULL; | |
63 const char *logdir; | |
64 GaimPlugin *plugin; | |
65 GaimPluginProtocolInfo *prpl_info; | |
66 char *prpl_name; | |
67 char *temp; | |
68 char *path; | |
69 GDir *dir; | |
70 | |
71 g_return_val_if_fail(sn != NULL, list); | |
72 g_return_val_if_fail(account != NULL, list); | |
73 | |
74 logdir = gaim_prefs_get_string("/plugins/core/log_reader/adium/log_directory"); | |
75 | |
76 /* By clearing the log directory path, this logger can be (effectively) disabled. */ | |
77 if (!*logdir) | |
78 return list; | |
79 | |
80 plugin = gaim_find_prpl(gaim_account_get_protocol_id(account)); | |
81 if (!plugin) | |
82 return NULL; | |
83 | |
84 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); | |
85 if (!prpl_info->list_icon) | |
86 return NULL; | |
87 | |
88 prpl_name = g_ascii_strup(prpl_info->list_icon(account, NULL), -1); | |
89 | |
90 temp = g_strdup_printf("%s.%s", prpl_name, account->username); | |
91 path = g_build_filename(logdir, temp, sn, NULL); | |
92 g_free(temp); | |
93 | |
94 dir = g_dir_open(path, 0, NULL); | |
95 if (dir) { | |
96 const gchar *file; | |
97 | |
98 while ((file = g_dir_read_name(dir))) { | |
13497
2f0d4179ec05
[gaim-migrate @ 15873]
Richard Laager <rlaager@wiktel.com>
parents:
13493
diff
changeset
|
99 if (!gaim_str_has_prefix(file, sn)) |
11459 | 100 continue; |
13497
2f0d4179ec05
[gaim-migrate @ 15873]
Richard Laager <rlaager@wiktel.com>
parents:
13493
diff
changeset
|
101 if (gaim_str_has_suffix(file, ".html") || gaim_str_has_suffix(file, ".AdiumHTMLLog")) { |
11459 | 102 struct tm tm; |
103 const char *date = file; | |
104 | |
105 date += strlen(sn) + 2; | |
106 if (sscanf(date, "%u|%u|%u", | |
107 &tm.tm_year, &tm.tm_mon, &tm.tm_mday) != 3) { | |
108 | |
109 gaim_debug(GAIM_DEBUG_ERROR, "Adium log parse", | |
110 "Filename timestamp parsing error\n"); | |
111 } else { | |
112 char *filename = g_build_filename(path, file, NULL); | |
13157
3a97c65196d1
[gaim-migrate @ 15520]
Richard Laager <rlaager@wiktel.com>
parents:
13119
diff
changeset
|
113 FILE *handle = g_fopen(filename, "rb"); |
11459 | 114 char *contents; |
115 char *contents2; | |
116 struct adium_logger_data *data; | |
117 GaimLog *log; | |
118 | |
119 if (!handle) { | |
120 g_free(filename); | |
121 continue; | |
122 } | |
123 | |
124 /* XXX: This is really inflexible. */ | |
125 contents = g_malloc(57); | |
126 fread(contents, 56, 1, handle); | |
127 fclose(handle); | |
128 contents[56] = '\0'; | |
129 | |
130 /* XXX: This is fairly inflexible. */ | |
131 contents2 = contents; | |
132 while (*contents2 && *contents2 != '>') | |
133 contents2++; | |
134 if (*contents2) | |
135 contents2++; | |
136 while (*contents2 && *contents2 != '>') | |
137 contents2++; | |
138 if (*contents2) | |
139 contents2++; | |
140 | |
141 if (sscanf(contents2, "%u.%u.%u", | |
142 &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 3) { | |
143 | |
144 gaim_debug(GAIM_DEBUG_ERROR, "Adium log parse", | |
145 "Contents timestamp parsing error\n"); | |
146 g_free(contents); | |
147 g_free(filename); | |
148 continue; | |
149 } | |
150 g_free(contents); | |
151 | |
152 data = g_new0(struct adium_logger_data, 1); | |
153 data->path = filename; | |
154 data->type = ADIUM_HTML; | |
155 | |
156 tm.tm_year -= 1900; | |
157 tm.tm_mon -= 1; | |
158 | |
13119
fcde3faa1f57
[gaim-migrate @ 15481]
Richard Laager <rlaager@wiktel.com>
parents:
12727
diff
changeset
|
159 /* XXX: Look into this later... Should we pass in a struct tm? */ |
fcde3faa1f57
[gaim-migrate @ 15481]
Richard Laager <rlaager@wiktel.com>
parents:
12727
diff
changeset
|
160 log = gaim_log_new(GAIM_LOG_IM, sn, account, NULL, mktime(&tm), NULL); |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
161 log->logger = adium_logger; |
11459 | 162 log->logger_data = data; |
163 | |
164 list = g_list_append(list, log); | |
165 } | |
13497
2f0d4179ec05
[gaim-migrate @ 15873]
Richard Laager <rlaager@wiktel.com>
parents:
13493
diff
changeset
|
166 } else if (gaim_str_has_suffix(file, ".adiumLog")) { |
11459 | 167 struct tm tm; |
168 const char *date = file; | |
169 | |
170 date += strlen(sn) + 2; | |
171 if (sscanf(date, "%u|%u|%u", | |
172 &tm.tm_year, &tm.tm_mon, &tm.tm_mday) != 3) { | |
173 | |
174 gaim_debug(GAIM_DEBUG_ERROR, "Adium log parse", | |
175 "Filename timestamp parsing error\n"); | |
176 } else { | |
177 char *filename = g_build_filename(path, file, NULL); | |
13157
3a97c65196d1
[gaim-migrate @ 15520]
Richard Laager <rlaager@wiktel.com>
parents:
13119
diff
changeset
|
178 FILE *handle = g_fopen(filename, "rb"); |
11459 | 179 char *contents; |
180 char *contents2; | |
181 struct adium_logger_data *data; | |
182 GaimLog *log; | |
183 | |
184 if (!handle) { | |
185 g_free(filename); | |
186 continue; | |
187 } | |
188 | |
189 /* XXX: This is really inflexible. */ | |
190 contents = g_malloc(14); | |
191 fread(contents, 13, 1, handle); | |
192 fclose(handle); | |
193 contents[13] = '\0'; | |
194 | |
195 contents2 = contents; | |
196 while (*contents2 && *contents2 != '(') | |
197 contents2++; | |
198 if (*contents2) | |
199 contents2++; | |
200 | |
201 if (sscanf(contents2, "%u.%u.%u", | |
202 &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 3) { | |
203 | |
204 gaim_debug(GAIM_DEBUG_ERROR, "Adium log parse", | |
205 "Contents timestamp parsing error\n"); | |
206 g_free(contents); | |
207 g_free(filename); | |
208 continue; | |
209 } | |
210 | |
211 g_free(contents); | |
212 | |
213 tm.tm_year -= 1900; | |
214 tm.tm_mon -= 1; | |
215 | |
216 data = g_new0(struct adium_logger_data, 1); | |
217 data->path = filename; | |
218 data->type = ADIUM_TEXT; | |
219 | |
13119
fcde3faa1f57
[gaim-migrate @ 15481]
Richard Laager <rlaager@wiktel.com>
parents:
12727
diff
changeset
|
220 /* XXX: Look into this later... Should we pass in a struct tm? */ |
fcde3faa1f57
[gaim-migrate @ 15481]
Richard Laager <rlaager@wiktel.com>
parents:
12727
diff
changeset
|
221 log = gaim_log_new(GAIM_LOG_IM, sn, account, NULL, mktime(&tm), NULL); |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
222 log->logger = adium_logger; |
11459 | 223 log->logger_data = data; |
224 | |
225 list = g_list_append(list, log); | |
226 } | |
227 } | |
228 } | |
229 g_dir_close(dir); | |
230 } | |
231 | |
232 g_free(prpl_name); | |
233 g_free(path); | |
234 | |
235 return list; | |
236 } | |
237 | |
238 static char *adium_logger_read (GaimLog *log, GaimLogReadFlags *flags) | |
239 { | |
240 struct adium_logger_data *data; | |
241 GError *error = NULL; | |
242 gchar *read = NULL; | |
243 gsize length; | |
244 | |
245 g_return_val_if_fail(log != NULL, g_strdup("")); | |
246 | |
247 data = log->logger_data; | |
248 | |
249 g_return_val_if_fail(data->path != NULL, g_strdup("")); | |
250 | |
251 gaim_debug(GAIM_DEBUG_INFO, "Adium log read", | |
252 "Reading %s\n", data->path); | |
253 if (!g_file_get_contents(data->path, &read, &length, &error)) { | |
254 gaim_debug(GAIM_DEBUG_ERROR, "Adium log read", | |
255 "Error reading log\n"); | |
256 if (error) | |
257 g_error_free(error); | |
258 return g_strdup(""); | |
259 } | |
260 | |
261 if (data->type != ADIUM_HTML) { | |
262 char *escaped = g_markup_escape_text(read, -1); | |
263 g_free(read); | |
264 read = escaped; | |
265 } | |
266 | |
267 #ifdef WIN32 | |
268 /* This problem only seems to show up on Windows. | |
269 * The BOM is displaying as a space at the beginning of the log. | |
270 */ | |
13497
2f0d4179ec05
[gaim-migrate @ 15873]
Richard Laager <rlaager@wiktel.com>
parents:
13493
diff
changeset
|
271 if (gaim_str_has_prefix(read, "\xef\xbb\xbf")) |
11459 | 272 { |
273 /* FIXME: This feels so wrong... */ | |
274 char *temp = g_strdup(&(read[3])); | |
275 g_free(read); | |
276 read = temp; | |
277 } | |
278 #endif | |
279 | |
280 /* TODO: Apply formatting. | |
281 * Replace the above hack with something better, since we'll | |
282 * be looping over the entire log file contents anyway. | |
283 */ | |
284 | |
285 return read; | |
286 } | |
287 | |
288 static int adium_logger_size (GaimLog *log) | |
289 { | |
290 struct adium_logger_data *data; | |
291 char *text; | |
292 size_t size; | |
293 | |
294 g_return_val_if_fail(log != NULL, 0); | |
295 | |
296 data = log->logger_data; | |
297 | |
298 if (gaim_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) { | |
299 struct stat st; | |
300 | |
301 if (!data->path || stat(data->path, &st)) | |
302 st.st_size = 0; | |
303 | |
304 return st.st_size; | |
305 } | |
306 | |
307 text = adium_logger_read(log, NULL); | |
308 size = strlen(text); | |
309 g_free(text); | |
310 | |
311 return size; | |
312 } | |
313 | |
314 static void adium_logger_finalize(GaimLog *log) | |
315 { | |
316 struct adium_logger_data *data; | |
317 | |
318 g_return_if_fail(log != NULL); | |
319 | |
320 data = log->logger_data; | |
321 | |
322 g_free(data->path); | |
323 } | |
324 | |
325 | |
326 /***************************************************************************** | |
327 * Fire Logger * | |
328 *****************************************************************************/ | |
329 | |
330 /* The fire logger doesn't write logs, only reads them. This is to include | |
331 * Fire logs in the log viewer transparently. | |
332 */ | |
333 | |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
334 static GaimLogLogger *fire_logger; |
11459 | 335 |
336 struct fire_logger_data { | |
337 }; | |
338 | |
339 static GList *fire_logger_list(GaimLogType type, const char *sn, GaimAccount *account) | |
340 { | |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
341 /* TODO: Do something here. */ |
11459 | 342 return NULL; |
343 } | |
344 | |
345 static char * fire_logger_read (GaimLog *log, GaimLogReadFlags *flags) | |
346 { | |
347 struct fire_logger_data *data; | |
348 | |
349 g_return_val_if_fail(log != NULL, g_strdup("")); | |
350 | |
351 data = log->logger_data; | |
352 | |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
353 /* TODO: Do something here. */ |
11459 | 354 return g_strdup(""); |
355 } | |
356 | |
357 static int fire_logger_size (GaimLog *log) | |
358 { | |
359 g_return_val_if_fail(log != NULL, 0); | |
360 | |
361 if (gaim_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) | |
362 return 0; | |
363 | |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
364 /* TODO: Do something here. */ |
11459 | 365 return 0; |
366 } | |
367 | |
368 static void fire_logger_finalize(GaimLog *log) | |
369 { | |
370 g_return_if_fail(log != NULL); | |
371 | |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
372 /* TODO: Do something here. */ |
11459 | 373 } |
374 | |
375 | |
376 /***************************************************************************** | |
377 * Messenger Plus! Logger * | |
378 *****************************************************************************/ | |
379 | |
380 /* The messenger_plus logger doesn't write logs, only reads them. This is to include | |
381 * Messenger Plus! logs in the log viewer transparently. | |
382 */ | |
383 | |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
384 static GaimLogLogger *messenger_plus_logger; |
11459 | 385 |
386 struct messenger_plus_logger_data { | |
387 }; | |
388 | |
389 static GList *messenger_plus_logger_list(GaimLogType type, const char *sn, GaimAccount *account) | |
390 { | |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
391 /* TODO: Do something here. */ |
11459 | 392 return NULL; |
393 } | |
394 | |
395 static char * messenger_plus_logger_read (GaimLog *log, GaimLogReadFlags *flags) | |
396 { | |
397 struct messenger_plus_logger_data *data = log->logger_data; | |
398 | |
399 g_return_val_if_fail(log != NULL, g_strdup("")); | |
400 | |
401 data = log->logger_data; | |
402 | |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
403 /* TODO: Do something here. */ |
11459 | 404 return g_strdup(""); |
405 } | |
406 | |
407 static int messenger_plus_logger_size (GaimLog *log) | |
408 { | |
409 g_return_val_if_fail(log != NULL, 0); | |
410 | |
411 if (gaim_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) | |
412 return 0; | |
413 | |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
414 /* TODO: Do something here. */ |
11459 | 415 return 0; |
416 } | |
417 | |
418 static void messenger_plus_logger_finalize(GaimLog *log) | |
419 { | |
420 g_return_if_fail(log != NULL); | |
421 | |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
422 /* TODO: Do something here. */ |
11459 | 423 } |
424 | |
425 | |
426 /***************************************************************************** | |
427 * MSN Messenger Logger * | |
428 *****************************************************************************/ | |
429 | |
430 /* The msn logger doesn't write logs, only reads them. This is to include | |
431 * MSN Messenger message histories in the log viewer transparently. | |
432 */ | |
433 | |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
434 static GaimLogLogger *msn_logger; |
11459 | 435 |
436 struct msn_logger_data { | |
437 xmlnode *root; | |
438 xmlnode *message; | |
439 const char *session_id; | |
440 int last_log; | |
441 GString *text; | |
442 }; | |
443 | |
444 static time_t msn_logger_parse_timestamp(xmlnode *message) | |
445 { | |
446 const char *date; | |
447 const char *time; | |
448 struct tm tm; | |
449 char am_pm; | |
450 | |
451 g_return_val_if_fail(message != NULL, (time_t)0); | |
452 | |
453 date = xmlnode_get_attrib(message, "Date"); | |
454 if (!(date && *date)) { | |
455 gaim_debug(GAIM_DEBUG_ERROR, "MSN log timestamp parse", | |
456 "Attribute missing: %s\n", "Date"); | |
457 return (time_t)0; | |
458 } | |
459 | |
460 time = xmlnode_get_attrib(message, "Time"); | |
461 if (!(time && *time)) { | |
462 gaim_debug(GAIM_DEBUG_ERROR, "MSN log timestamp parse", | |
463 "Attribute missing: %s\n", "Time"); | |
464 return (time_t)0; | |
465 } | |
466 | |
467 if (sscanf(date, "%u/%u/%u", &tm.tm_mon, &tm.tm_mday, &tm.tm_year) != 3) | |
468 gaim_debug(GAIM_DEBUG_ERROR, "MSN log timestamp parse", | |
469 "%s parsing error\n", "Date"); | |
470 | |
471 if (sscanf(time, "%u:%u:%u %c", &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &am_pm) != 4) | |
472 gaim_debug(GAIM_DEBUG_ERROR, "MSN log timestamp parse", | |
473 "%s parsing error\n", "Time"); | |
474 | |
475 tm.tm_year -= 1900; | |
476 tm.tm_mon -= 1; | |
477 if (am_pm == 'P') { | |
478 tm.tm_hour += 12; | |
479 } else if (tm.tm_hour == 12) { | |
480 /* 12 AM = 00 hr */ | |
481 tm.tm_hour = 0; | |
482 } | |
483 /* Let the C library deal with daylight savings time. */ | |
484 tm.tm_isdst = -1; | |
485 | |
486 return mktime(&tm); | |
487 } | |
488 | |
489 | |
490 static GList *msn_logger_list(GaimLogType type, const char *sn, GaimAccount *account) | |
491 { | |
492 GList *list = NULL; | |
493 char *username; | |
494 GaimBuddy *buddy; | |
495 const char *logdir; | |
496 const char *savedfilename = NULL; | |
497 char *logfile; | |
498 char *path; | |
499 GError *error = NULL; | |
500 gchar *contents = NULL; | |
501 gsize length; | |
502 xmlnode *root; | |
503 xmlnode *message; | |
504 const char *old_session_id = ""; | |
505 struct msn_logger_data *data = NULL; | |
506 | |
507 g_return_val_if_fail(sn != NULL, list); | |
508 g_return_val_if_fail(account != NULL, list); | |
509 | |
510 if (strcmp(account->protocol_id, "prpl-msn")) | |
511 return list; | |
512 | |
513 logdir = gaim_prefs_get_string("/plugins/core/log_reader/msn/log_directory"); | |
514 | |
515 /* By clearing the log directory path, this logger can be (effectively) disabled. */ | |
516 if (!*logdir) | |
517 return list; | |
518 | |
519 buddy = gaim_find_buddy(account, sn); | |
520 | |
521 if ((username = g_strdup(gaim_account_get_string( | |
522 account, "log_reader_msn_log_folder", NULL)))) { | |
523 /* As a special case, we allow the null string to kill the parsing | |
524 * straight away. This would allow the user to deal with the case | |
525 * when two account have the same username at different domains and | |
526 * only one has logs stored. | |
527 */ | |
528 if (!*username) { | |
529 g_free(username); | |
530 return list; | |
531 } | |
532 } else { | |
533 username = g_strdup(gaim_normalize(account, account->username)); | |
534 } | |
535 | |
536 if (buddy) | |
537 savedfilename = gaim_blist_node_get_string(&buddy->node, "log_reader_msn_log_filename"); | |
538 | |
539 if (savedfilename) { | |
540 /* As a special case, we allow the null string to kill the parsing | |
541 * straight away. This would allow the user to deal with the case | |
542 * when two buddies have the same username at different domains and | |
543 * only one has logs stored. | |
544 */ | |
545 if (!*savedfilename) { | |
546 g_free(username); | |
547 return list; | |
548 } | |
549 | |
550 logfile = g_strdup(savedfilename); | |
551 } else { | |
552 logfile = g_strdup_printf("%s.xml", gaim_normalize(account, sn)); | |
553 } | |
554 | |
555 path = g_build_filename(logdir, username, "History", logfile, NULL); | |
556 | |
557 if (!g_file_test(path, G_FILE_TEST_EXISTS)) { | |
558 gboolean found = FALSE; | |
559 char *at_sign; | |
560 GDir *dir; | |
561 | |
562 g_free(path); | |
563 | |
564 if (savedfilename) { | |
565 /* We had a saved filename, but it doesn't exist. | |
566 * Returning now is the right course of action because we don't | |
567 * want to detect another file incorrectly. | |
568 */ | |
569 g_free(username); | |
570 g_free(logfile); | |
571 return list; | |
572 } | |
573 | |
574 /* Perhaps we're using a new version of MSN with the weird numbered folders. | |
575 * I don't know how the numbers are calculated, so I'm going to attempt to | |
576 * find logs by pattern matching... | |
577 */ | |
578 | |
579 at_sign = g_strrstr(username, "@"); | |
580 if (at_sign) | |
581 *at_sign = '\0'; | |
582 | |
583 dir = g_dir_open(logdir, 0, NULL); | |
584 if (dir) { | |
585 const gchar *name; | |
586 | |
587 while ((name = g_dir_read_name(dir))) { | |
588 const char *c = name; | |
589 | |
13497
2f0d4179ec05
[gaim-migrate @ 15873]
Richard Laager <rlaager@wiktel.com>
parents:
13493
diff
changeset
|
590 if (!gaim_str_has_prefix(c, username)) |
11459 | 591 continue; |
592 | |
593 c += strlen(username); | |
594 while (*c) { | |
595 if (!g_ascii_isdigit(*c)) | |
596 break; | |
597 | |
598 c++; | |
599 } | |
600 | |
601 path = g_build_filename(logdir, name, NULL); | |
602 /* The !c makes sure we got to the end of the while loop above. */ | |
603 if (!*c && g_file_test(path, G_FILE_TEST_IS_DIR)) { | |
604 char *history_path = g_build_filename( | |
605 path, "History", NULL); | |
606 if (g_file_test(history_path, G_FILE_TEST_IS_DIR)) { | |
607 gaim_account_set_string(account, | |
608 "log_reader_msn_log_folder", name); | |
609 g_free(path); | |
610 path = history_path; | |
611 found = TRUE; | |
612 break; | |
613 } | |
614 g_free(path); | |
615 g_free(history_path); | |
616 } | |
617 else | |
618 g_free(path); | |
619 } | |
620 g_dir_close(dir); | |
621 } | |
622 g_free(username); | |
623 | |
624 if (!found) { | |
625 g_free(logfile); | |
626 return list; | |
627 } | |
628 | |
629 /* If we've reached this point, we've found a History folder. */ | |
630 | |
631 username = g_strdup(gaim_normalize(account, sn)); | |
632 at_sign = g_strrstr(username, "@"); | |
633 if (at_sign) | |
634 *at_sign = '\0'; | |
635 | |
636 found = FALSE; | |
637 dir = g_dir_open(path, 0, NULL); | |
638 if (dir) { | |
639 const gchar *name; | |
640 | |
641 while ((name = g_dir_read_name(dir))) { | |
642 const char *c = name; | |
643 | |
13497
2f0d4179ec05
[gaim-migrate @ 15873]
Richard Laager <rlaager@wiktel.com>
parents:
13493
diff
changeset
|
644 if (!gaim_str_has_prefix(c, username)) |
11459 | 645 continue; |
646 | |
647 c += strlen(username); | |
648 while (*c) { | |
649 if (!g_ascii_isdigit(*c)) | |
650 break; | |
651 | |
652 c++; | |
653 } | |
654 | |
655 path = g_build_filename(path, name, NULL); | |
656 if (!strcmp(c, ".xml") && | |
657 g_file_test(path, G_FILE_TEST_EXISTS)) { | |
658 found = TRUE; | |
659 g_free(logfile); | |
660 logfile = g_strdup(name); | |
661 break; | |
662 } | |
663 else | |
664 g_free(path); | |
665 } | |
666 g_dir_close(dir); | |
667 } | |
668 g_free(username); | |
669 | |
670 if (!found) { | |
671 g_free(logfile); | |
672 return list; | |
673 } | |
674 } else { | |
675 g_free(username); | |
676 g_free(logfile); | |
677 logfile = NULL; /* No sense saving the obvious buddy@domain.com. */ | |
678 } | |
679 | |
680 gaim_debug(GAIM_DEBUG_INFO, "MSN log read", | |
681 "Reading %s\n", path); | |
682 if (!g_file_get_contents(path, &contents, &length, &error)) { | |
683 g_free(path); | |
684 gaim_debug(GAIM_DEBUG_ERROR, "MSN log read", | |
685 "Error reading log\n"); | |
686 if (error) | |
687 g_error_free(error); | |
688 return list; | |
689 } | |
690 g_free(path); | |
691 | |
692 /* Reading the file was successful... | |
693 * Save its name if it involves the crazy numbers. The idea here is that you could | |
694 * then tweak the blist.xml file by hand if need be. This would be the case if two | |
695 * buddies have the same username at different domains. One set of logs would get | |
696 * detected for both buddies. | |
697 */ | |
698 if (buddy && logfile) { | |
699 gaim_blist_node_set_string(&buddy->node, "log_reader_msn_log_filename", logfile); | |
700 g_free(logfile); | |
701 } | |
702 | |
703 root = xmlnode_from_str(contents, length); | |
704 g_free(contents); | |
705 if (!root) | |
706 return list; | |
707 | |
708 for (message = xmlnode_get_child(root, "Message"); message; | |
709 message = xmlnode_get_next_twin(message)) { | |
710 const char *session_id; | |
711 | |
712 session_id = xmlnode_get_attrib(message, "SessionID"); | |
713 if (!session_id) { | |
714 gaim_debug(GAIM_DEBUG_ERROR, "MSN log parse", | |
715 "Error parsing message: %s\n", "SessionID missing"); | |
716 continue; | |
717 } | |
718 | |
719 if (strcmp(session_id, old_session_id)) { | |
720 /* | |
721 * The session ID differs from the last message. | |
722 * Thus, this is the start of a new conversation. | |
723 */ | |
724 GaimLog *log; | |
725 | |
726 data = g_new0(struct msn_logger_data, 1); | |
727 data->root = root; | |
728 data->message = message; | |
729 data->session_id = session_id; | |
730 data->text = NULL; | |
731 data->last_log = FALSE; | |
732 | |
13119
fcde3faa1f57
[gaim-migrate @ 15481]
Richard Laager <rlaager@wiktel.com>
parents:
12727
diff
changeset
|
733 /* XXX: Look into this later... Should we pass in a struct tm? */ |
fcde3faa1f57
[gaim-migrate @ 15481]
Richard Laager <rlaager@wiktel.com>
parents:
12727
diff
changeset
|
734 log = gaim_log_new(GAIM_LOG_IM, sn, account, NULL, msn_logger_parse_timestamp(message), NULL); |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
735 log->logger = msn_logger; |
11459 | 736 log->logger_data = data; |
737 | |
738 list = g_list_append(list, log); | |
739 } | |
740 old_session_id = session_id; | |
741 } | |
742 | |
743 if (data) | |
744 data->last_log = TRUE; | |
745 | |
746 return list; | |
747 } | |
748 | |
749 static char * msn_logger_read (GaimLog *log, GaimLogReadFlags *flags) | |
750 { | |
751 struct msn_logger_data *data; | |
752 GString *text = NULL; | |
753 xmlnode *message; | |
754 | |
755 g_return_val_if_fail(log != NULL, g_strdup("")); | |
756 | |
757 data = log->logger_data; | |
758 | |
759 if (data->text) { | |
760 /* The GTK code which displays the logs g_free()s whatever is | |
761 * returned from this function. Thus, we can't reuse the str | |
762 * part of the GString. The only solution is to free it and | |
763 * start over. | |
764 */ | |
765 g_string_free(data->text, FALSE); | |
766 } | |
767 | |
768 text = g_string_new(""); | |
769 | |
770 if (!data->root || !data->message || !data->session_id) { | |
771 /* Something isn't allocated correctly. */ | |
772 gaim_debug(GAIM_DEBUG_ERROR, "MSN log parse", | |
773 "Error parsing message: %s\n", "Internal variables inconsistent"); | |
774 data->text = text; | |
775 | |
776 return text->str; | |
777 } | |
778 | |
779 for (message = data->message; message; | |
780 message = xmlnode_get_next_twin(message)) { | |
781 | |
782 const char *new_session_id; | |
783 xmlnode *text_node; | |
784 const char *from_name = NULL; | |
785 const char *to_name = NULL; | |
786 xmlnode *from; | |
787 xmlnode *to; | |
788 enum name_guesses name_guessed = NAME_GUESS_UNKNOWN; | |
789 const char *their_name; | |
790 time_t time_unix; | |
791 struct tm *tm_new; | |
792 char *timestamp; | |
793 const char *style; | |
794 | |
795 new_session_id = xmlnode_get_attrib(message, "SessionID"); | |
796 | |
797 /* If this triggers, something is wrong with the XML. */ | |
798 if (!new_session_id) { | |
799 gaim_debug(GAIM_DEBUG_ERROR, "MSN log parse", | |
800 "Error parsing message: %s\n", "New SessionID missing"); | |
801 break; | |
802 } | |
803 | |
804 if (strcmp(new_session_id, data->session_id)) { | |
805 /* The session ID differs from the first message. | |
806 * Thus, this is the start of a new conversation. | |
807 */ | |
808 break; | |
809 } | |
810 | |
811 text_node = xmlnode_get_child(message, "Text"); | |
812 if (!text_node) | |
813 continue; | |
814 | |
815 from = xmlnode_get_child(message, "From"); | |
816 if (from) { | |
817 xmlnode *user = xmlnode_get_child(from, "User"); | |
818 | |
819 if (user) { | |
820 from_name = xmlnode_get_attrib(user, "FriendlyName"); | |
821 | |
822 /* This saves a check later. */ | |
823 if (!*from_name) | |
824 from_name = NULL; | |
825 } | |
826 } | |
827 | |
828 to = xmlnode_get_child(message, "To"); | |
829 if (to) { | |
830 xmlnode *user = xmlnode_get_child(to, "User"); | |
831 if (user) { | |
832 to_name = xmlnode_get_attrib(user, "FriendlyName"); | |
833 | |
834 /* This saves a check later. */ | |
835 if (!*to_name) | |
836 to_name = NULL; | |
837 } | |
838 } | |
839 | |
840 their_name = from_name; | |
841 if (from_name && gaim_prefs_get_bool("/plugins/core/log_reader/use_name_heuristics")) { | |
842 const char *friendly_name = gaim_connection_get_display_name(log->account->gc); | |
843 | |
11702
994f1c7bee8b
[gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents:
11503
diff
changeset
|
844 if (friendly_name != NULL) { |
994f1c7bee8b
[gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents:
11503
diff
changeset
|
845 int friendly_name_length = strlen(friendly_name); |
994f1c7bee8b
[gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents:
11503
diff
changeset
|
846 int alias_length = strlen(log->account->alias); |
994f1c7bee8b
[gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents:
11503
diff
changeset
|
847 GaimBuddy *buddy = gaim_find_buddy(log->account, log->name); |
994f1c7bee8b
[gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents:
11503
diff
changeset
|
848 gboolean from_name_matches; |
994f1c7bee8b
[gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents:
11503
diff
changeset
|
849 gboolean to_name_matches; |
994f1c7bee8b
[gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents:
11503
diff
changeset
|
850 |
994f1c7bee8b
[gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents:
11503
diff
changeset
|
851 if (buddy && buddy->alias) |
994f1c7bee8b
[gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents:
11503
diff
changeset
|
852 their_name = buddy->alias; |
11459 | 853 |
11702
994f1c7bee8b
[gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents:
11503
diff
changeset
|
854 /* Try to guess which user is me. |
994f1c7bee8b
[gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents:
11503
diff
changeset
|
855 * The first step is to determine if either of the names matches either my |
994f1c7bee8b
[gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents:
11503
diff
changeset
|
856 * friendly name or alias. For this test, "match" is defined as: |
994f1c7bee8b
[gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents:
11503
diff
changeset
|
857 * ^(friendly_name|alias)([^a-zA-Z0-9].*)?$ |
994f1c7bee8b
[gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents:
11503
diff
changeset
|
858 */ |
13493
e8b0a9376481
[gaim-migrate @ 15869]
Richard Laager <rlaager@wiktel.com>
parents:
13491
diff
changeset
|
859 from_name_matches = from_name != NULL && ( |
13497
2f0d4179ec05
[gaim-migrate @ 15873]
Richard Laager <rlaager@wiktel.com>
parents:
13493
diff
changeset
|
860 (gaim_str_has_prefix(from_name, friendly_name) && |
13493
e8b0a9376481
[gaim-migrate @ 15869]
Richard Laager <rlaager@wiktel.com>
parents:
13491
diff
changeset
|
861 !isalnum(*(from_name + friendly_name_length))) || |
13497
2f0d4179ec05
[gaim-migrate @ 15873]
Richard Laager <rlaager@wiktel.com>
parents:
13493
diff
changeset
|
862 (gaim_str_has_prefix(from_name, log->account->alias) && |
13493
e8b0a9376481
[gaim-migrate @ 15869]
Richard Laager <rlaager@wiktel.com>
parents:
13491
diff
changeset
|
863 !isalnum(*(from_name + alias_length)))); |
11459 | 864 |
13493
e8b0a9376481
[gaim-migrate @ 15869]
Richard Laager <rlaager@wiktel.com>
parents:
13491
diff
changeset
|
865 to_name_matches = to_name != NULL && ( |
e8b0a9376481
[gaim-migrate @ 15869]
Richard Laager <rlaager@wiktel.com>
parents:
13491
diff
changeset
|
866 (gaim_str_has_prefix(to_name, friendly_name) && |
e8b0a9376481
[gaim-migrate @ 15869]
Richard Laager <rlaager@wiktel.com>
parents:
13491
diff
changeset
|
867 !isalnum(*(to_name + friendly_name_length))) || |
e8b0a9376481
[gaim-migrate @ 15869]
Richard Laager <rlaager@wiktel.com>
parents:
13491
diff
changeset
|
868 (gaim_str_has_prefix(to_name, log->account->alias) && |
e8b0a9376481
[gaim-migrate @ 15869]
Richard Laager <rlaager@wiktel.com>
parents:
13491
diff
changeset
|
869 !isalnum(*(to_name + alias_length)))); |
11459 | 870 |
11702
994f1c7bee8b
[gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents:
11503
diff
changeset
|
871 if (from_name_matches) { |
994f1c7bee8b
[gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents:
11503
diff
changeset
|
872 if (!to_name_matches) { |
994f1c7bee8b
[gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents:
11503
diff
changeset
|
873 name_guessed = NAME_GUESS_ME; |
994f1c7bee8b
[gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents:
11503
diff
changeset
|
874 } |
994f1c7bee8b
[gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents:
11503
diff
changeset
|
875 } else if (to_name_matches) { |
994f1c7bee8b
[gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents:
11503
diff
changeset
|
876 name_guessed = NAME_GUESS_THEM; |
994f1c7bee8b
[gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents:
11503
diff
changeset
|
877 } else { |
994f1c7bee8b
[gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents:
11503
diff
changeset
|
878 if (buddy && buddy->alias) { |
11459 | 879 char *alias = g_strdup(buddy->alias); |
880 | |
881 /* "Truncate" the string at the first non-alphanumeric | |
882 * character. The idea is to relax the comparison. | |
883 */ | |
884 char *temp; | |
885 for (temp = alias; *temp ; temp++) { | |
886 if (!isalnum(*temp)) { | |
887 *temp = '\0'; | |
888 break; | |
889 } | |
890 } | |
891 alias_length = strlen(alias); | |
892 | |
893 /* Try to guess which user is them. | |
894 * The first step is to determine if either of the names | |
895 * matches their alias. For this test, "match" is | |
896 * defined as: ^alias([^a-zA-Z0-9].*)?$ | |
897 */ | |
13497
2f0d4179ec05
[gaim-migrate @ 15873]
Richard Laager <rlaager@wiktel.com>
parents:
13493
diff
changeset
|
898 from_name_matches = (gaim_str_has_prefix( |
11459 | 899 from_name, alias) && |
900 !isalnum(*(from_name + | |
901 alias_length))); | |
902 | |
13497
2f0d4179ec05
[gaim-migrate @ 15873]
Richard Laager <rlaager@wiktel.com>
parents:
13493
diff
changeset
|
903 to_name_matches = (gaim_str_has_prefix( |
11459 | 904 to_name, alias) && |
905 !isalnum(*(to_name + | |
906 alias_length))); | |
907 | |
908 g_free(alias); | |
909 | |
910 if (from_name_matches) { | |
911 if (!to_name_matches) { | |
912 name_guessed = NAME_GUESS_THEM; | |
913 } | |
914 } else if (to_name_matches) { | |
915 name_guessed = NAME_GUESS_ME; | |
916 } else if (buddy->server_alias) { | |
917 friendly_name_length = | |
918 strlen(buddy->server_alias); | |
919 | |
920 /* Try to guess which user is them. | |
921 * The first step is to determine if either of | |
922 * the names matches their friendly name. For | |
923 * this test, "match" is defined as: | |
924 * ^friendly_name([^a-zA-Z0-9].*)?$ | |
925 */ | |
13497
2f0d4179ec05
[gaim-migrate @ 15873]
Richard Laager <rlaager@wiktel.com>
parents:
13493
diff
changeset
|
926 from_name_matches = (gaim_str_has_prefix( |
11459 | 927 from_name, |
928 buddy->server_alias) && | |
929 !isalnum(*(from_name + | |
930 friendly_name_length))); | |
931 | |
13497
2f0d4179ec05
[gaim-migrate @ 15873]
Richard Laager <rlaager@wiktel.com>
parents:
13493
diff
changeset
|
932 to_name_matches = (gaim_str_has_prefix( |
11459 | 933 to_name, buddy->server_alias) && |
934 !isalnum(*(to_name + | |
935 friendly_name_length))); | |
936 | |
937 if (from_name_matches) { | |
938 if (!to_name_matches) { | |
939 name_guessed = NAME_GUESS_THEM; | |
940 } | |
941 } else if (to_name_matches) { | |
942 name_guessed = NAME_GUESS_ME; | |
943 } | |
944 } | |
945 } | |
946 } | |
947 } | |
948 } | |
949 | |
950 if (name_guessed != NAME_GUESS_UNKNOWN) { | |
951 text = g_string_append(text, "<span style=\"color: #"); | |
952 if (name_guessed == NAME_GUESS_ME) | |
953 text = g_string_append(text, "16569E"); | |
954 else | |
955 text = g_string_append(text, "A82F2F"); | |
956 text = g_string_append(text, ";\">"); | |
957 } | |
958 | |
959 time_unix = msn_logger_parse_timestamp(message); | |
960 tm_new = localtime(&time_unix); | |
961 | |
962 timestamp = g_strdup_printf("<font size=\"2\">(%02u:%02u:%02u)</font> ", | |
963 tm_new->tm_hour, tm_new->tm_min, tm_new->tm_sec); | |
964 text = g_string_append(text, timestamp); | |
965 g_free(timestamp); | |
966 | |
967 if (from_name) { | |
968 text = g_string_append(text, "<b>"); | |
969 | |
970 if (name_guessed == NAME_GUESS_ME) | |
971 text = g_string_append(text, log->account->alias); | |
972 else if (name_guessed == NAME_GUESS_THEM) | |
973 text = g_string_append(text, their_name); | |
974 else | |
975 text = g_string_append(text, from_name); | |
976 | |
977 text = g_string_append(text, ":</b> "); | |
978 } | |
979 | |
980 if (name_guessed != NAME_GUESS_UNKNOWN) | |
981 text = g_string_append(text, "</span>"); | |
982 | |
983 style = xmlnode_get_attrib(text_node, "Style"); | |
984 | |
985 if (style && *style) { | |
986 text = g_string_append(text, "<span style=\""); | |
987 text = g_string_append(text, style); | |
988 text = g_string_append(text, "\">"); | |
989 text = g_string_append(text, xmlnode_get_data(text_node)); | |
990 text = g_string_append(text, "</span>\n"); | |
991 } else { | |
992 text = g_string_append(text, xmlnode_get_data(text_node)); | |
993 text = g_string_append(text, "\n"); | |
994 } | |
995 } | |
996 | |
997 data->text = text; | |
998 | |
999 return text->str; | |
1000 } | |
1001 | |
1002 static int msn_logger_size (GaimLog *log) | |
1003 { | |
1004 char *text; | |
1005 size_t size; | |
1006 | |
1007 g_return_val_if_fail(log != NULL, 0); | |
1008 | |
1009 if (gaim_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) | |
1010 return 0; | |
1011 | |
1012 text = msn_logger_read(log, NULL); | |
1013 size = strlen(text); | |
1014 g_free(text); | |
1015 | |
1016 return size; | |
1017 } | |
1018 | |
1019 static void msn_logger_finalize(GaimLog *log) | |
1020 { | |
1021 struct msn_logger_data *data; | |
1022 | |
1023 g_return_if_fail(log != NULL); | |
1024 | |
1025 data = log->logger_data; | |
1026 | |
1027 if (data->last_log) | |
1028 xmlnode_free(data->root); | |
1029 | |
1030 if (data->text) | |
1031 g_string_free(data->text, FALSE); | |
1032 } | |
1033 | |
1034 | |
1035 /***************************************************************************** | |
1036 * Trillian Logger * | |
1037 *****************************************************************************/ | |
1038 | |
1039 /* The trillian logger doesn't write logs, only reads them. This is to include | |
1040 * Trillian logs in the log viewer transparently. | |
1041 */ | |
1042 | |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1043 static GaimLogLogger *trillian_logger; |
11459 | 1044 static void trillian_logger_finalize(GaimLog *log); |
1045 | |
1046 struct trillian_logger_data { | |
1047 char *path; /* FIXME: Change this to use GaimStringref like log.c:old_logger_list */ | |
1048 int offset; | |
1049 int length; | |
1050 char *their_nickname; | |
1051 }; | |
1052 | |
1053 static GList *trillian_logger_list(GaimLogType type, const char *sn, GaimAccount *account) | |
1054 { | |
1055 GList *list = NULL; | |
1056 const char *logdir; | |
1057 GaimPlugin *plugin; | |
1058 GaimPluginProtocolInfo *prpl_info; | |
1059 char *prpl_name; | |
1060 const char *buddy_name; | |
1061 char *filename; | |
1062 char *path; | |
1063 GError *error = NULL; | |
1064 gchar *contents = NULL; | |
1065 gsize length; | |
1066 gchar *line; | |
1067 gchar *c; | |
1068 | |
1069 g_return_val_if_fail(sn != NULL, list); | |
1070 g_return_val_if_fail(account != NULL, list); | |
1071 | |
1072 logdir = gaim_prefs_get_string("/plugins/core/log_reader/trillian/log_directory"); | |
1073 | |
1074 /* By clearing the log directory path, this logger can be (effectively) disabled. */ | |
1075 if (!*logdir) | |
1076 return list; | |
1077 | |
1078 plugin = gaim_find_prpl(gaim_account_get_protocol_id(account)); | |
1079 if (!plugin) | |
1080 return NULL; | |
1081 | |
1082 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); | |
1083 if (!prpl_info->list_icon) | |
1084 return NULL; | |
1085 | |
1086 prpl_name = g_ascii_strup(prpl_info->list_icon(account, NULL), -1); | |
1087 | |
1088 buddy_name = gaim_normalize(account, sn); | |
1089 | |
1090 filename = g_strdup_printf("%s.log", buddy_name); | |
1091 path = g_build_filename( | |
1092 logdir, prpl_name, filename, NULL); | |
1093 | |
1094 gaim_debug(GAIM_DEBUG_INFO, "Trillian log list", | |
1095 "Reading %s\n", path); | |
1096 /* FIXME: There's really no need to read the entire file at once. | |
1097 * See src/log.c:old_logger_list for a better approach. | |
1098 */ | |
1099 if (!g_file_get_contents(path, &contents, &length, &error)) { | |
1100 if (error) { | |
1101 g_error_free(error); | |
1102 error = NULL; | |
1103 } | |
1104 g_free(path); | |
1105 | |
1106 path = g_build_filename( | |
1107 logdir, prpl_name, "Query", filename, NULL); | |
1108 gaim_debug(GAIM_DEBUG_INFO, "Trillian log list", | |
1109 "Reading %s\n", path); | |
1110 if (!g_file_get_contents(path, &contents, &length, &error)) { | |
1111 if (error) | |
1112 g_error_free(error); | |
1113 } | |
1114 } | |
1115 g_free(filename); | |
1116 | |
1117 if (contents) { | |
1118 struct trillian_logger_data *data = NULL; | |
1119 int offset = 0; | |
1120 int last_line_offset = 0; | |
1121 | |
1122 line = contents; | |
1123 c = contents; | |
1124 while (*c) { | |
1125 offset++; | |
1126 | |
1127 if (*c != '\n') { | |
1128 c++; | |
1129 continue; | |
1130 } | |
1131 | |
1132 *c = '\0'; | |
13497
2f0d4179ec05
[gaim-migrate @ 15873]
Richard Laager <rlaager@wiktel.com>
parents:
13493
diff
changeset
|
1133 if (gaim_str_has_prefix(line, "Session Close ")) { |
13668
5c8565315d3e
[gaim-migrate @ 16070]
Richard Laager <rlaager@wiktel.com>
parents:
13497
diff
changeset
|
1134 if (data && !data->length) { |
5c8565315d3e
[gaim-migrate @ 16070]
Richard Laager <rlaager@wiktel.com>
parents:
13497
diff
changeset
|
1135 if (!(data->length = last_line_offset - data->offset)) { |
5c8565315d3e
[gaim-migrate @ 16070]
Richard Laager <rlaager@wiktel.com>
parents:
13497
diff
changeset
|
1136 /* This log had no data, so we remove it. */ |
5c8565315d3e
[gaim-migrate @ 16070]
Richard Laager <rlaager@wiktel.com>
parents:
13497
diff
changeset
|
1137 GList *last = g_list_last(list); |
11459 | 1138 |
13668
5c8565315d3e
[gaim-migrate @ 16070]
Richard Laager <rlaager@wiktel.com>
parents:
13497
diff
changeset
|
1139 gaim_debug(GAIM_DEBUG_INFO, "Trillian log list", |
5c8565315d3e
[gaim-migrate @ 16070]
Richard Laager <rlaager@wiktel.com>
parents:
13497
diff
changeset
|
1140 "Empty log. Offset %i\n", data->offset); |
11459 | 1141 |
13668
5c8565315d3e
[gaim-migrate @ 16070]
Richard Laager <rlaager@wiktel.com>
parents:
13497
diff
changeset
|
1142 trillian_logger_finalize((GaimLog *)last->data); |
5c8565315d3e
[gaim-migrate @ 16070]
Richard Laager <rlaager@wiktel.com>
parents:
13497
diff
changeset
|
1143 list = g_list_delete_link(list, last); |
5c8565315d3e
[gaim-migrate @ 16070]
Richard Laager <rlaager@wiktel.com>
parents:
13497
diff
changeset
|
1144 } |
11459 | 1145 } |
1146 } else if (line[0] && line[1] && line [3] && | |
13497
2f0d4179ec05
[gaim-migrate @ 15873]
Richard Laager <rlaager@wiktel.com>
parents:
13493
diff
changeset
|
1147 gaim_str_has_prefix(&line[3], "sion Start ")) { |
11459 | 1148 |
1149 char *their_nickname = line; | |
1150 char *timestamp; | |
1151 | |
1152 if (data && !data->length) | |
1153 data->length = last_line_offset - data->offset; | |
1154 | |
1155 while (*their_nickname && (*their_nickname != ':')) | |
1156 their_nickname++; | |
1157 their_nickname++; | |
1158 | |
1159 /* This code actually has nothing to do with | |
1160 * the timestamp YET. I'm simply using this | |
1161 * variable for now to NUL-terminate the | |
1162 * their_nickname string. | |
1163 */ | |
1164 timestamp = their_nickname; | |
1165 while (*timestamp && *timestamp != ')') | |
1166 timestamp++; | |
1167 | |
1168 if (*timestamp == ')') { | |
1169 char *month; | |
1170 struct tm tm; | |
1171 | |
1172 *timestamp = '\0'; | |
1173 if (line[0] && line[1] && line[2]) | |
1174 timestamp += 3; | |
1175 | |
1176 /* Now we start dealing with the timestamp. */ | |
1177 | |
1178 /* Skip over the day name. */ | |
1179 while (*timestamp && (*timestamp != ' ')) | |
1180 timestamp++; | |
1181 *timestamp = '\0'; | |
1182 timestamp++; | |
1183 | |
1184 /* Parse out the month. */ | |
1185 month = timestamp; | |
1186 while (*timestamp && (*timestamp != ' ')) | |
1187 timestamp++; | |
1188 *timestamp = '\0'; | |
1189 timestamp++; | |
1190 | |
1191 /* Parse the day, time, and year. */ | |
1192 if (sscanf(timestamp, "%u %u:%u:%u %u", | |
1193 &tm.tm_mday, &tm.tm_hour, | |
1194 &tm.tm_min, &tm.tm_sec, | |
1195 &tm.tm_year) != 5) { | |
1196 | |
1197 gaim_debug(GAIM_DEBUG_ERROR, | |
1198 "Trillian log timestamp parse", | |
1199 "Session Start parsing error\n"); | |
1200 } else { | |
1201 GaimLog *log; | |
1202 | |
1203 tm.tm_year -= 1900; | |
1204 | |
1205 /* Let the C library deal with | |
1206 * daylight savings time. | |
1207 */ | |
1208 tm.tm_isdst = -1; | |
1209 | |
1210 /* Ugly hack, in case current locale | |
1211 * is not English. This code is taken | |
1212 * from log.c. | |
1213 */ | |
1214 if (strcmp(month, "Jan") == 0) { | |
1215 tm.tm_mon= 0; | |
1216 } else if (strcmp(month, "Feb") == 0) { | |
1217 tm.tm_mon = 1; | |
1218 } else if (strcmp(month, "Mar") == 0) { | |
1219 tm.tm_mon = 2; | |
1220 } else if (strcmp(month, "Apr") == 0) { | |
1221 tm.tm_mon = 3; | |
1222 } else if (strcmp(month, "May") == 0) { | |
1223 tm.tm_mon = 4; | |
1224 } else if (strcmp(month, "Jun") == 0) { | |
1225 tm.tm_mon = 5; | |
1226 } else if (strcmp(month, "Jul") == 0) { | |
1227 tm.tm_mon = 6; | |
1228 } else if (strcmp(month, "Aug") == 0) { | |
1229 tm.tm_mon = 7; | |
1230 } else if (strcmp(month, "Sep") == 0) { | |
1231 tm.tm_mon = 8; | |
1232 } else if (strcmp(month, "Oct") == 0) { | |
1233 tm.tm_mon = 9; | |
1234 } else if (strcmp(month, "Nov") == 0) { | |
1235 tm.tm_mon = 10; | |
1236 } else if (strcmp(month, "Dec") == 0) { | |
1237 tm.tm_mon = 11; | |
1238 } | |
1239 | |
1240 data = g_new0( | |
1241 struct trillian_logger_data, 1); | |
1242 data->path = g_strdup(path); | |
1243 data->offset = offset; | |
1244 data->length = 0; | |
1245 data->their_nickname = | |
1246 g_strdup(their_nickname); | |
1247 | |
13119
fcde3faa1f57
[gaim-migrate @ 15481]
Richard Laager <rlaager@wiktel.com>
parents:
12727
diff
changeset
|
1248 /* XXX: Look into this later... Should we pass in a struct tm? */ |
11459 | 1249 log = gaim_log_new(GAIM_LOG_IM, |
13119
fcde3faa1f57
[gaim-migrate @ 15481]
Richard Laager <rlaager@wiktel.com>
parents:
12727
diff
changeset
|
1250 sn, account, NULL, mktime(&tm), NULL); |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1251 log->logger = trillian_logger; |
11459 | 1252 log->logger_data = data; |
1253 | |
1254 list = g_list_append(list, log); | |
1255 } | |
1256 } | |
1257 } | |
1258 c++; | |
1259 line = c; | |
1260 last_line_offset = offset; | |
1261 } | |
1262 | |
1263 g_free(contents); | |
1264 } | |
1265 g_free(path); | |
1266 | |
1267 g_free(prpl_name); | |
1268 | |
1269 return list; | |
1270 } | |
1271 | |
1272 static char * trillian_logger_read (GaimLog *log, GaimLogReadFlags *flags) | |
1273 { | |
1274 struct trillian_logger_data *data; | |
1275 char *read; | |
1276 FILE *file; | |
1277 GaimBuddy *buddy; | |
1278 char *escaped; | |
1279 GString *formatted; | |
1280 char *c; | |
1281 char *line; | |
1282 | |
1283 g_return_val_if_fail(log != NULL, g_strdup("")); | |
1284 | |
1285 data = log->logger_data; | |
1286 | |
1287 g_return_val_if_fail(data->path != NULL, g_strdup("")); | |
1288 g_return_val_if_fail(data->length > 0, g_strdup("")); | |
1289 g_return_val_if_fail(data->their_nickname != NULL, g_strdup("")); | |
1290 | |
1291 gaim_debug(GAIM_DEBUG_INFO, "Trillian log read", | |
1292 "Reading %s\n", data->path); | |
1293 | |
1294 read = g_malloc(data->length + 2); | |
1295 | |
13157
3a97c65196d1
[gaim-migrate @ 15520]
Richard Laager <rlaager@wiktel.com>
parents:
13119
diff
changeset
|
1296 file = g_fopen(data->path, "rb"); |
11459 | 1297 fseek(file, data->offset, SEEK_SET); |
1298 fread(read, data->length, 1, file); | |
1299 fclose(file); | |
1300 | |
1301 if (read[data->length-1] == '\n') { | |
1302 read[data->length] = '\0'; | |
1303 } else { | |
1304 read[data->length] = '\n'; | |
1305 read[data->length+1] = '\0'; | |
1306 } | |
1307 | |
1308 /* Load miscellaneous data. */ | |
1309 buddy = gaim_find_buddy(log->account, log->name); | |
1310 | |
1311 escaped = g_markup_escape_text(read, -1); | |
1312 g_free(read); | |
1313 read = escaped; | |
1314 | |
1315 /* Apply formatting... */ | |
1316 formatted = g_string_new(""); | |
1317 c = read; | |
1318 line = read; | |
1319 while (*c) | |
1320 { | |
1321 if (*c == '\n') | |
1322 { | |
1323 char *link_temp_line; | |
1324 char *link; | |
1325 char *timestamp; | |
1326 char *footer = NULL; | |
1327 *c = '\0'; | |
1328 | |
1329 /* Convert links. | |
1330 * | |
1331 * The format is (Link: URL)URL | |
1332 * So, I want to find each occurance of "(Link: " and replace that chunk with: | |
1333 * <a href=" | |
1334 * Then, replace the next ")" with: | |
1335 * "> | |
1336 * Then, replace the next " " (or add this if the end-of-line is reached) with: | |
1337 * </a> | |
1338 */ | |
1339 link_temp_line = NULL; | |
1340 while ((link = g_strstr_len(line, strlen(line), "(Link: "))) { | |
1341 GString *temp; | |
1342 | |
1343 if (!*link) | |
1344 continue; | |
1345 | |
1346 *link = '\0'; | |
1347 link++; | |
1348 | |
1349 temp = g_string_new(line); | |
1350 g_string_append(temp, "<a href=\""); | |
1351 | |
1352 if (strlen(link) >= 6) { | |
1353 link += (sizeof("(Link: ") - 1); | |
1354 | |
1355 while (*link && *link != ')') { | |
1356 g_string_append_c(temp, *link); | |
1357 link++; | |
1358 } | |
1359 if (link) { | |
1360 link++; | |
1361 | |
1362 g_string_append(temp, "\">"); | |
1363 while (*link && *link != ' ') { | |
1364 g_string_append_c(temp, *link); | |
1365 link++; | |
1366 } | |
1367 g_string_append(temp, "</a>"); | |
1368 } | |
1369 | |
1370 g_string_append(temp, link); | |
1371 | |
1372 /* Free the last round's line. */ | |
1373 if (link_temp_line) | |
1374 g_free(line); | |
1375 | |
1376 line = temp->str; | |
1377 g_string_free(temp, FALSE); | |
1378 | |
1379 /* Save this memory location so we can free it later. */ | |
1380 link_temp_line = line; | |
1381 } | |
1382 } | |
1383 | |
1384 timestamp = ""; | |
1385 if (*line == '[') { | |
1386 timestamp = line; | |
1387 while (*timestamp && *timestamp != ']') | |
1388 timestamp++; | |
1389 if (*timestamp == ']') { | |
1390 *timestamp = '\0'; | |
1391 line++; | |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1392 /* TODO: Parse the timestamp and convert it to Gaim's format. */ |
11459 | 1393 g_string_append_printf(formatted, |
1394 "<font size=\"2\">(%s)</font> ", line); | |
1395 line = timestamp; | |
1396 if (line[1] && line[2]) | |
1397 line += 2; | |
1398 } | |
1399 | |
13497
2f0d4179ec05
[gaim-migrate @ 15873]
Richard Laager <rlaager@wiktel.com>
parents:
13493
diff
changeset
|
1400 if (gaim_str_has_prefix(line, "*** ")) { |
11459 | 1401 line += (sizeof("*** ") - 1); |
1402 g_string_append(formatted, "<b>"); | |
1403 footer = "</b>"; | |
13497
2f0d4179ec05
[gaim-migrate @ 15873]
Richard Laager <rlaager@wiktel.com>
parents:
13493
diff
changeset
|
1404 if (gaim_str_has_prefix(line, "NOTE: This user is offline.")) { |
11459 | 1405 line = _("User is offline."); |
13497
2f0d4179ec05
[gaim-migrate @ 15873]
Richard Laager <rlaager@wiktel.com>
parents:
13493
diff
changeset
|
1406 } else if (gaim_str_has_prefix(line, |
11459 | 1407 "NOTE: Your status is currently set to ")) { |
1408 | |
1409 line += (sizeof("NOTE: ") - 1); | |
13497
2f0d4179ec05
[gaim-migrate @ 15873]
Richard Laager <rlaager@wiktel.com>
parents:
13493
diff
changeset
|
1410 } else if (gaim_str_has_prefix(line, "Auto-response sent to ")) { |
11459 | 1411 g_string_append(formatted, _("Auto-response sent:")); |
1412 while (*line && *line != ':') | |
1413 line++; | |
1414 if (*line) | |
1415 line++; | |
1416 g_string_append(formatted, "</b>"); | |
1417 footer = NULL; | |
1418 } else if (strstr(line, " signed off ")) { | |
13491
0dbab0e08f2a
[gaim-migrate @ 15867]
Richard Laager <rlaager@wiktel.com>
parents:
13378
diff
changeset
|
1419 if (buddy != NULL && buddy->alias) |
11459 | 1420 g_string_append_printf(formatted, |
13363
ef5287de40b5
[gaim-migrate @ 15736]
Richard Laager <rlaager@wiktel.com>
parents:
13157
diff
changeset
|
1421 _("%s has signed off."), buddy->alias); |
11459 | 1422 else |
1423 g_string_append_printf(formatted, | |
13363
ef5287de40b5
[gaim-migrate @ 15736]
Richard Laager <rlaager@wiktel.com>
parents:
13157
diff
changeset
|
1424 _("%s has signed off."), log->name); |
11459 | 1425 line = ""; |
1426 } else if (strstr(line, " signed on ")) { | |
13491
0dbab0e08f2a
[gaim-migrate @ 15867]
Richard Laager <rlaager@wiktel.com>
parents:
13378
diff
changeset
|
1427 if (buddy != NULL && buddy->alias) |
11459 | 1428 g_string_append(formatted, buddy->alias); |
1429 else | |
1430 g_string_append(formatted, log->name); | |
1431 line = " logged in."; | |
13497
2f0d4179ec05
[gaim-migrate @ 15873]
Richard Laager <rlaager@wiktel.com>
parents:
13493
diff
changeset
|
1432 } else if (gaim_str_has_prefix(line, |
11459 | 1433 "One or more messages may have been undeliverable.")) { |
1434 | |
1435 g_string_append(formatted, | |
1436 "<span style=\"color: #ff0000;\">"); | |
1437 g_string_append(formatted, | |
1438 _("One or more messages may have been " | |
1439 "undeliverable.")); | |
1440 line = ""; | |
1441 footer = "</span></b>"; | |
13497
2f0d4179ec05
[gaim-migrate @ 15873]
Richard Laager <rlaager@wiktel.com>
parents:
13493
diff
changeset
|
1442 } else if (gaim_str_has_prefix(line, |
11459 | 1443 "You have been disconnected.")) { |
1444 | |
1445 g_string_append(formatted, | |
1446 "<span style=\"color: #ff0000;\">"); | |
1447 g_string_append(formatted, | |
1448 _("You were disconnected from the server.")); | |
1449 line = ""; | |
1450 footer = "</span></b>"; | |
13497
2f0d4179ec05
[gaim-migrate @ 15873]
Richard Laager <rlaager@wiktel.com>
parents:
13493
diff
changeset
|
1451 } else if (gaim_str_has_prefix(line, |
11459 | 1452 "You are currently disconnected.")) { |
1453 | |
1454 g_string_append(formatted, | |
1455 "<span style=\"color: #ff0000;\">"); | |
1456 line = _("You are currently disconnected. Messages " | |
1457 "will not be received unless you are " | |
1458 "logged in."); | |
1459 footer = "</span></b>"; | |
13497
2f0d4179ec05
[gaim-migrate @ 15873]
Richard Laager <rlaager@wiktel.com>
parents:
13493
diff
changeset
|
1460 } else if (gaim_str_has_prefix(line, |
11459 | 1461 "Your previous message has not been sent.")) { |
1462 | |
1463 g_string_append(formatted, | |
1464 "<span style=\"color: #ff0000;\">"); | |
1465 | |
13497
2f0d4179ec05
[gaim-migrate @ 15873]
Richard Laager <rlaager@wiktel.com>
parents:
13493
diff
changeset
|
1466 if (gaim_str_has_prefix(line, |
11459 | 1467 "Your previous message has not been sent. " |
1468 "Reason: Maximum length exceeded.")) { | |
1469 | |
1470 g_string_append(formatted, | |
1471 _("Message could not be sent because " | |
1472 "the maximum length was exceeded.")); | |
1473 line = ""; | |
1474 } else { | |
1475 g_string_append(formatted, | |
1476 _("Message could not be sent.")); | |
1477 line += (sizeof( | |
1478 "Your previous message " | |
1479 "has not been sent. ") - 1); | |
1480 } | |
1481 | |
1482 footer = "</span></b>"; | |
1483 } | |
13497
2f0d4179ec05
[gaim-migrate @ 15873]
Richard Laager <rlaager@wiktel.com>
parents:
13493
diff
changeset
|
1484 } else if (gaim_str_has_prefix(line, data->their_nickname)) { |
13491
0dbab0e08f2a
[gaim-migrate @ 15867]
Richard Laager <rlaager@wiktel.com>
parents:
13378
diff
changeset
|
1485 if (buddy != NULL && buddy->alias) { |
11459 | 1486 line += strlen(data->their_nickname) + 2; |
1487 g_string_append_printf(formatted, | |
1488 "<span style=\"color: #A82F2F;\">" | |
1489 "<b>%s</b></span>: ", buddy->alias); | |
1490 } | |
1491 } else { | |
1492 char *line2 = line; | |
1493 while (*line2 && *line2 != ':') | |
1494 line2++; | |
1495 if (*line2 == ':') { | |
1496 line2++; | |
1497 line = line2; | |
1498 g_string_append_printf(formatted, | |
1499 "<span style=\"color: #16569E;\">" | |
1500 "<b>%s</b></span>:", log->account->alias); | |
1501 } | |
1502 } | |
1503 } | |
1504 | |
1505 g_string_append(formatted, line); | |
1506 | |
1507 if (footer) | |
1508 g_string_append(formatted, footer); | |
1509 | |
1510 g_string_append_c(formatted, '\n'); | |
1511 | |
1512 if (link_temp_line) | |
1513 g_free(link_temp_line); | |
1514 | |
1515 c++; | |
1516 line = c; | |
1517 } else | |
1518 c++; | |
1519 } | |
1520 | |
1521 g_free(read); | |
1522 read = formatted->str; | |
1523 g_string_free(formatted, FALSE); | |
1524 | |
1525 return read; | |
1526 } | |
1527 | |
1528 static int trillian_logger_size (GaimLog *log) | |
1529 { | |
1530 struct trillian_logger_data *data; | |
1531 char *text; | |
1532 size_t size; | |
1533 | |
1534 g_return_val_if_fail(log != NULL, 0); | |
1535 | |
1536 data = log->logger_data; | |
1537 | |
1538 if (gaim_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) { | |
1539 return data ? data->length : 0; | |
1540 } | |
1541 | |
1542 text = trillian_logger_read(log, NULL); | |
1543 size = strlen(text); | |
1544 g_free(text); | |
1545 | |
1546 return size; | |
1547 } | |
1548 | |
1549 static void trillian_logger_finalize(GaimLog *log) | |
1550 { | |
1551 struct trillian_logger_data *data; | |
1552 | |
1553 g_return_if_fail(log != NULL); | |
1554 | |
1555 data = log->logger_data; | |
1556 | |
1557 g_free(data->path); | |
1558 g_free(data->their_nickname); | |
1559 | |
1560 } | |
1561 | |
1562 | |
1563 /***************************************************************************** | |
1564 * Plugin Code * | |
1565 *****************************************************************************/ | |
1566 | |
1567 static void | |
1568 init_plugin(GaimPlugin *plugin) | |
1569 { | |
1570 char *path; | |
1571 #ifdef _WIN32 | |
1572 char *folder; | |
1573 #endif | |
1574 | |
1575 g_return_if_fail(plugin != NULL); | |
1576 | |
1577 gaim_prefs_add_none("/plugins/core/log_reader"); | |
1578 | |
1579 | |
1580 /* Add general preferences. */ | |
1581 | |
1582 gaim_prefs_add_bool("/plugins/core/log_reader/fast_sizes", FALSE); | |
1583 gaim_prefs_add_bool("/plugins/core/log_reader/use_name_heuristics", TRUE); | |
1584 | |
1585 | |
1586 /* Add Adium log directory preference. */ | |
1587 gaim_prefs_add_none("/plugins/core/log_reader/adium"); | |
1588 | |
1589 /* Calculate default Adium log directory. */ | |
1590 #ifdef _WIN32 | |
1591 path = ""; | |
1592 #else | |
1593 path = g_build_filename(gaim_home_dir(), "Library", "Application Support", | |
1594 "Adium 2.0", "Users", "Default", "Logs", NULL); | |
1595 #endif | |
1596 | |
1597 gaim_prefs_add_string("/plugins/core/log_reader/adium/log_directory", path); | |
1598 | |
1599 #ifndef _WIN32 | |
1600 g_free(path); | |
1601 #endif | |
1602 | |
1603 | |
1604 /* Add Fire log directory preference. */ | |
1605 gaim_prefs_add_none("/plugins/core/log_reader/fire"); | |
1606 | |
1607 /* Calculate default Fire log directory. */ | |
1608 #ifdef _WIN32 | |
1609 path = ""; | |
1610 #else | |
1611 path = g_build_filename(gaim_home_dir(), "Library", "Application Support", | |
1612 "Fire", "Sessions", NULL); | |
1613 #endif | |
1614 | |
1615 gaim_prefs_add_string("/plugins/core/log_reader/fire/log_directory", path); | |
1616 | |
1617 #ifndef _WIN32 | |
1618 g_free(path); | |
1619 #endif | |
1620 | |
1621 | |
1622 /* Add Messenger Plus! log directory preference. */ | |
1623 gaim_prefs_add_none("/plugins/core/log_reader/messenger_plus"); | |
1624 | |
1625 /* Calculate default Messenger Plus! log directory. */ | |
1626 #ifdef _WIN32 | |
1627 folder = wgaim_get_special_folder(CSIDL_PERSONAL); | |
1628 if (folder) { | |
1629 #endif | |
1630 path = g_build_filename( | |
1631 #ifdef _WIN32 | |
1632 folder, | |
1633 #else | |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1634 GAIM_LOG_READER_WINDOWS_MOUNT_POINT, "Documents and Settings", |
11459 | 1635 g_get_user_name(), "My Documents", |
1636 #endif | |
1637 "My Chat Logs", NULL); | |
1638 #ifdef _WIN32 | |
1639 g_free(folder); | |
1640 } else /* !folder */ | |
1641 path = g_strdup(""); | |
1642 #endif | |
1643 | |
1644 gaim_prefs_add_string("/plugins/core/log_reader/messenger_plus/log_directory", path); | |
1645 g_free(path); | |
1646 | |
1647 | |
1648 /* Add MSN Messenger log directory preference. */ | |
1649 gaim_prefs_add_none("/plugins/core/log_reader/msn"); | |
1650 | |
1651 /* Calculate default MSN message history directory. */ | |
1652 #ifdef _WIN32 | |
1653 folder = wgaim_get_special_folder(CSIDL_PERSONAL); | |
1654 if (folder) { | |
1655 #endif | |
1656 path = g_build_filename( | |
1657 #ifdef _WIN32 | |
1658 folder, | |
1659 #else | |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1660 GAIM_LOG_READER_WINDOWS_MOUNT_POINT, "Documents and Settings", |
11459 | 1661 g_get_user_name(), "My Documents", |
1662 #endif | |
1663 "My Received Files", NULL); | |
1664 #ifdef _WIN32 | |
1665 g_free(folder); | |
1666 } else /* !folder */ | |
1667 path = g_strdup(""); | |
1668 #endif | |
1669 | |
1670 gaim_prefs_add_string("/plugins/core/log_reader/msn/log_directory", path); | |
1671 g_free(path); | |
1672 | |
1673 | |
1674 /* Add Trillian log directory preference. */ | |
1675 gaim_prefs_add_none("/plugins/core/log_reader/trillian"); | |
1676 | |
1677 #ifdef _WIN32 | |
1678 /* XXX: While a major hack, this is the most reliable way I could | |
1679 * think of to determine the Trillian installation directory. | |
1680 */ | |
1681 HKEY hKey; | |
1682 char buffer[1024] = ""; | |
1683 DWORD size = (sizeof(buffer) - 1); | |
1684 DWORD type; | |
1685 | |
1686 path = NULL; | |
1687 /* TODO: Test this after removing the trailing "\\". */ | |
1688 if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_CLASSES_ROOT, "Trillian.SkinZip\\shell\\Add\\command\\", | |
1689 0, KEY_QUERY_VALUE, &hKey)) { | |
1690 | |
1691 if(ERROR_SUCCESS == RegQueryValueEx(hKey, "", NULL, &type, (LPBYTE)buffer, &size)) { | |
1692 char *value = buffer; | |
1693 char *temp; | |
1694 | |
1695 /* Ensure the data is null terminated. */ | |
1696 value[size] = '\0'; | |
1697 | |
1698 /* Break apart buffer. */ | |
1699 if (*value == '"') { | |
1700 value++; | |
1701 temp = value; | |
1702 while (*temp && *temp != '"') | |
1703 temp++; | |
1704 } else { | |
1705 temp = value; | |
1706 while (*temp && *temp != ' ') | |
1707 temp++; | |
1708 } | |
1709 *temp = '\0'; | |
1710 | |
1711 /* Set path. */ | |
13497
2f0d4179ec05
[gaim-migrate @ 15873]
Richard Laager <rlaager@wiktel.com>
parents:
13493
diff
changeset
|
1712 if (gaim_str_has_suffix(value, "trillian.exe")) |
11459 | 1713 { |
1714 value[strlen(value) - (sizeof("trillian.exe") - 1)] = '\0'; | |
1715 path = g_build_filename(value, "users", "default", "talk.ini", NULL); | |
1716 } | |
1717 } | |
1718 RegCloseKey(hKey); | |
1719 } | |
1720 | |
1721 if (!path) { | |
1722 char *folder = wgaim_get_special_folder(CSIDL_PROGRAM_FILES); | |
1723 if (folder) | |
1724 path = g_build_filename(folder, "Trillian", | |
1725 "users", "default", "talk.ini", NULL); | |
1726 g_free(folder); | |
1727 } | |
1728 } | |
1729 | |
1730 gboolean found = FALSE; | |
1731 | |
1732 if (path) { | |
1733 /* Read talk.ini file to find the log directory. */ | |
1734 GError *error = NULL; | |
1735 | |
1736 #if 0 && GTK_CHECK_VERSION(2,6,0) /* FIXME: Not tested yet. */ | |
1737 GKeyFile *key_file; | |
1738 | |
1739 gaim_debug(GAIM_DEBUG_INFO, "Trillian talk.ini read", | |
1740 "Reading %s\n", path); | |
1741 if (!g_key_file_load_from_file(key_file, path, G_KEY_FILE_NONE, GError &error)) { | |
1742 gaim_debug(GAIM_DEBUG_ERROR, "Trillian talk.ini read", | |
1743 "Error reading talk.ini\n"); | |
1744 if (error) | |
1745 g_error_free(error); | |
1746 } else { | |
1747 char *logdir = g_key_file_get_string(key_file, "Logging", "Directory", &error); | |
1748 if (error) { | |
1749 gaim_debug(GAIM_DEBUG_ERROR, "Trillian talk.ini read", | |
1750 "Error reading Directory value from Logging section\n"); | |
1751 g_error_free(error); | |
1752 } | |
1753 | |
1754 if (logdir) { | |
1755 g_strchomp(logdir); | |
1756 gaim_prefs_add_string( | |
1757 "/plugins/core/log_reader/trillian/log_directory", logdir); | |
1758 found = TRUE; | |
1759 } | |
1760 | |
1761 g_key_file_free(key_file); | |
1762 } | |
1763 #else /* !GTK_CHECK_VERSION(2,6,0) */ | |
1764 GError *error = NULL; | |
1765 gsize length; | |
1766 | |
1767 gaim_debug(GAIM_DEBUG_INFO, "Trillian talk.ini read", | |
1768 "Reading %s\n", path); | |
1769 if (!g_file_get_contents(path, &contents, &length, &error)) { | |
1770 gaim_debug(GAIM_DEBUG_ERROR, "Trillian talk.ini read", | |
1771 "Error reading talk.ini\n"); | |
1772 if (error) | |
1773 g_error_free(error); | |
1774 } else { | |
1775 char *line = contents; | |
1776 while (*contents) { | |
1777 if (*contents == '\n') { | |
1778 *contents = '\0'; | |
1779 | |
1780 /* XXX: This assumes the first Directory key is under [Logging]. */ | |
13497
2f0d4179ec05
[gaim-migrate @ 15873]
Richard Laager <rlaager@wiktel.com>
parents:
13493
diff
changeset
|
1781 if (gaim_str_has_prefix(line, "Directory=")) { |
11459 | 1782 line += (sizeof("Directory=") - 1); |
1783 g_strchomp(line); | |
1784 gaim_prefs_add_string( | |
1785 "/plugins/core/log_reader/trillian/log_directory", | |
1786 line); | |
1787 found = TRUE; | |
1788 } | |
1789 | |
1790 contents++; | |
1791 line = contents; | |
1792 } else | |
1793 contents++; | |
1794 } | |
1795 g_free(path); | |
1796 g_free(contents); | |
1797 } | |
1798 #endif /* !GTK_CHECK_VERSION(2,6,0) */ | |
1799 } /* path */ | |
1800 | |
1801 if (!found) { | |
1802 #endif /* defined(_WIN32) */ | |
1803 | |
1804 /* Calculate default Trillian log directory. */ | |
1805 #ifdef _WIN32 | |
1806 folder = wgaim_get_special_folder(CSIDL_PROGRAM_FILES); | |
1807 if (folder) { | |
1808 #endif | |
1809 path = g_build_filename( | |
1810 #ifdef _WIN32 | |
1811 folder, | |
1812 #else | |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1813 GAIM_LOG_READER_WINDOWS_MOUNT_POINT, "Program Files", |
11459 | 1814 #endif |
1815 "Trillian", "users", "default", "logs", NULL); | |
1816 #ifdef _WIN32 | |
1817 g_free(folder); | |
1818 } else /* !folder */ | |
1819 path = g_strdup(""); | |
1820 #endif | |
1821 | |
1822 gaim_prefs_add_string("/plugins/core/log_reader/trillian/log_directory", path); | |
1823 g_free(path); | |
1824 | |
1825 #ifdef _WIN32 | |
1826 } /* !found */ | |
1827 #endif | |
1828 } | |
1829 | |
1830 static gboolean | |
1831 plugin_load(GaimPlugin *plugin) | |
1832 { | |
1833 g_return_val_if_fail(plugin != NULL, FALSE); | |
1834 | |
13700
85267a333422
[gaim-migrate @ 16103]
Richard Laager <rlaager@wiktel.com>
parents:
13668
diff
changeset
|
1835 /* The names of IM clients are marked for translation at the request of |
85267a333422
[gaim-migrate @ 16103]
Richard Laager <rlaager@wiktel.com>
parents:
13668
diff
changeset
|
1836 translators who wanted to transliterate them. Many translators |
85267a333422
[gaim-migrate @ 16103]
Richard Laager <rlaager@wiktel.com>
parents:
13668
diff
changeset
|
1837 choose to leave them alone. Choose what's best for your language. */ |
13376
8921c9aa2b20
[gaim-migrate @ 15749]
Richard Laager <rlaager@wiktel.com>
parents:
13363
diff
changeset
|
1838 adium_logger = gaim_log_logger_new("adium", _("Adium"), 6, |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1839 NULL, |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1840 NULL, |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1841 adium_logger_finalize, |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1842 adium_logger_list, |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1843 adium_logger_read, |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1844 adium_logger_size); |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1845 gaim_log_logger_add(adium_logger); |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1846 |
13700
85267a333422
[gaim-migrate @ 16103]
Richard Laager <rlaager@wiktel.com>
parents:
13668
diff
changeset
|
1847 /* The names of IM clients are marked for translation at the request of |
85267a333422
[gaim-migrate @ 16103]
Richard Laager <rlaager@wiktel.com>
parents:
13668
diff
changeset
|
1848 translators who wanted to transliterate them. Many translators |
85267a333422
[gaim-migrate @ 16103]
Richard Laager <rlaager@wiktel.com>
parents:
13668
diff
changeset
|
1849 choose to leave them alone. Choose what's best for your language. */ |
13376
8921c9aa2b20
[gaim-migrate @ 15749]
Richard Laager <rlaager@wiktel.com>
parents:
13363
diff
changeset
|
1850 fire_logger = gaim_log_logger_new("fire", _("Fire"), 6, |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1851 NULL, |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1852 NULL, |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1853 fire_logger_finalize, |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1854 fire_logger_list, |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1855 fire_logger_read, |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1856 fire_logger_size); |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1857 gaim_log_logger_add(fire_logger); |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1858 |
13700
85267a333422
[gaim-migrate @ 16103]
Richard Laager <rlaager@wiktel.com>
parents:
13668
diff
changeset
|
1859 /* The names of IM clients are marked for translation at the request of |
85267a333422
[gaim-migrate @ 16103]
Richard Laager <rlaager@wiktel.com>
parents:
13668
diff
changeset
|
1860 translators who wanted to transliterate them. Many translators |
85267a333422
[gaim-migrate @ 16103]
Richard Laager <rlaager@wiktel.com>
parents:
13668
diff
changeset
|
1861 choose to leave them alone. Choose what's best for your language. */ |
13376
8921c9aa2b20
[gaim-migrate @ 15749]
Richard Laager <rlaager@wiktel.com>
parents:
13363
diff
changeset
|
1862 messenger_plus_logger = gaim_log_logger_new("messenger_plus", _("Messenger Plus!"), 6, |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1863 NULL, |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1864 NULL, |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1865 messenger_plus_logger_finalize, |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1866 messenger_plus_logger_list, |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1867 messenger_plus_logger_read, |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1868 messenger_plus_logger_size); |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1869 gaim_log_logger_add(messenger_plus_logger); |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1870 |
13700
85267a333422
[gaim-migrate @ 16103]
Richard Laager <rlaager@wiktel.com>
parents:
13668
diff
changeset
|
1871 /* The names of IM clients are marked for translation at the request of |
85267a333422
[gaim-migrate @ 16103]
Richard Laager <rlaager@wiktel.com>
parents:
13668
diff
changeset
|
1872 translators who wanted to transliterate them. Many translators |
85267a333422
[gaim-migrate @ 16103]
Richard Laager <rlaager@wiktel.com>
parents:
13668
diff
changeset
|
1873 choose to leave them alone. Choose what's best for your language. */ |
13376
8921c9aa2b20
[gaim-migrate @ 15749]
Richard Laager <rlaager@wiktel.com>
parents:
13363
diff
changeset
|
1874 msn_logger = gaim_log_logger_new("msn", _("MSN Messenger"), 6, |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1875 NULL, |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1876 NULL, |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1877 msn_logger_finalize, |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1878 msn_logger_list, |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1879 msn_logger_read, |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1880 msn_logger_size); |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1881 gaim_log_logger_add(msn_logger); |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1882 |
13700
85267a333422
[gaim-migrate @ 16103]
Richard Laager <rlaager@wiktel.com>
parents:
13668
diff
changeset
|
1883 /* The names of IM clients are marked for translation at the request of |
85267a333422
[gaim-migrate @ 16103]
Richard Laager <rlaager@wiktel.com>
parents:
13668
diff
changeset
|
1884 translators who wanted to transliterate them. Many translators |
85267a333422
[gaim-migrate @ 16103]
Richard Laager <rlaager@wiktel.com>
parents:
13668
diff
changeset
|
1885 choose to leave them alone. Choose what's best for your language. */ |
13376
8921c9aa2b20
[gaim-migrate @ 15749]
Richard Laager <rlaager@wiktel.com>
parents:
13363
diff
changeset
|
1886 trillian_logger = gaim_log_logger_new("trillian", _("Trillian"), 6, |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1887 NULL, |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1888 NULL, |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1889 trillian_logger_finalize, |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1890 trillian_logger_list, |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1891 trillian_logger_read, |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1892 trillian_logger_size); |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1893 gaim_log_logger_add(trillian_logger); |
11459 | 1894 |
1895 return TRUE; | |
1896 } | |
1897 | |
1898 static gboolean | |
1899 plugin_unload(GaimPlugin *plugin) | |
1900 { | |
1901 g_return_val_if_fail(plugin != NULL, FALSE); | |
1902 | |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1903 gaim_log_logger_remove(adium_logger); |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1904 gaim_log_logger_remove(fire_logger); |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1905 gaim_log_logger_remove(messenger_plus_logger); |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1906 gaim_log_logger_remove(msn_logger); |
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1907 gaim_log_logger_remove(trillian_logger); |
11459 | 1908 |
1909 return TRUE; | |
1910 } | |
1911 | |
1912 static GaimPluginPrefFrame * | |
1913 get_plugin_pref_frame(GaimPlugin *plugin) | |
1914 { | |
1915 GaimPluginPrefFrame *frame; | |
1916 GaimPluginPref *ppref; | |
1917 | |
1918 g_return_val_if_fail(plugin != NULL, FALSE); | |
1919 | |
1920 frame = gaim_plugin_pref_frame_new(); | |
1921 | |
1922 | |
1923 /* Add general preferences. */ | |
1924 | |
1925 ppref = gaim_plugin_pref_new_with_label(_("General Log Reading Configuration")); | |
1926 gaim_plugin_pref_frame_add(frame, ppref); | |
1927 | |
1928 ppref = gaim_plugin_pref_new_with_name_and_label( | |
1929 "/plugins/core/log_reader/fast_sizes", _("Fast size calculations")); | |
1930 gaim_plugin_pref_frame_add(frame, ppref); | |
1931 | |
1932 ppref = gaim_plugin_pref_new_with_name_and_label( | |
1933 "/plugins/core/log_reader/use_name_heuristics", _("Use name heuristics")); | |
1934 gaim_plugin_pref_frame_add(frame, ppref); | |
1935 | |
1936 | |
1937 /* Add Log Directory preferences. */ | |
1938 | |
1939 ppref = gaim_plugin_pref_new_with_label(_("Log Directory")); | |
1940 gaim_plugin_pref_frame_add(frame, ppref); | |
1941 | |
1942 ppref = gaim_plugin_pref_new_with_name_and_label( | |
13376
8921c9aa2b20
[gaim-migrate @ 15749]
Richard Laager <rlaager@wiktel.com>
parents:
13363
diff
changeset
|
1943 "/plugins/core/log_reader/adium/log_directory", _("Adium")); |
11459 | 1944 gaim_plugin_pref_frame_add(frame, ppref); |
1945 | |
1946 ppref = gaim_plugin_pref_new_with_name_and_label( | |
13376
8921c9aa2b20
[gaim-migrate @ 15749]
Richard Laager <rlaager@wiktel.com>
parents:
13363
diff
changeset
|
1947 "/plugins/core/log_reader/fire/log_directory", _("Fire")); |
11459 | 1948 gaim_plugin_pref_frame_add(frame, ppref); |
1949 | |
1950 ppref = gaim_plugin_pref_new_with_name_and_label( | |
13376
8921c9aa2b20
[gaim-migrate @ 15749]
Richard Laager <rlaager@wiktel.com>
parents:
13363
diff
changeset
|
1951 "/plugins/core/log_reader/messenger_plus/log_directory", _("Messenger Plus!")); |
11459 | 1952 gaim_plugin_pref_frame_add(frame, ppref); |
1953 | |
1954 ppref = gaim_plugin_pref_new_with_name_and_label( | |
13376
8921c9aa2b20
[gaim-migrate @ 15749]
Richard Laager <rlaager@wiktel.com>
parents:
13363
diff
changeset
|
1955 "/plugins/core/log_reader/msn/log_directory", _("MSN Messenger")); |
11459 | 1956 gaim_plugin_pref_frame_add(frame, ppref); |
1957 | |
1958 ppref = gaim_plugin_pref_new_with_name_and_label( | |
13376
8921c9aa2b20
[gaim-migrate @ 15749]
Richard Laager <rlaager@wiktel.com>
parents:
13363
diff
changeset
|
1959 "/plugins/core/log_reader/trillian/log_directory", _("Trillian")); |
11459 | 1960 gaim_plugin_pref_frame_add(frame, ppref); |
1961 | |
1962 return frame; | |
1963 } | |
1964 | |
1965 static GaimPluginUiInfo prefs_info = { | |
12727
ae51c59bf819
[gaim-migrate @ 15071]
Richard Laager <rlaager@wiktel.com>
parents:
11702
diff
changeset
|
1966 get_plugin_pref_frame, |
ae51c59bf819
[gaim-migrate @ 15071]
Richard Laager <rlaager@wiktel.com>
parents:
11702
diff
changeset
|
1967 0, /* page_num (reserved) */ |
ae51c59bf819
[gaim-migrate @ 15071]
Richard Laager <rlaager@wiktel.com>
parents:
11702
diff
changeset
|
1968 NULL /* frame (reserved) */ |
11459 | 1969 }; |
1970 | |
1971 static GaimPluginInfo info = | |
1972 { | |
1973 GAIM_PLUGIN_MAGIC, | |
1974 GAIM_MAJOR_VERSION, | |
1975 GAIM_MINOR_VERSION, | |
1976 GAIM_PLUGIN_STANDARD, /**< type */ | |
1977 NULL, /**< ui_requirement */ | |
1978 0, /**< flags */ | |
1979 NULL, /**< dependencies */ | |
1980 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
1981 "core-log_reader", /**< id */ | |
1982 N_("Log Reader"), /**< name */ | |
1983 VERSION, /**< version */ | |
1984 | |
1985 /** summary */ | |
1986 N_("Includes other IM clients' logs in the " | |
1987 "log viewer."), | |
1988 | |
1989 /** description */ | |
1990 N_("When viewing logs, this plugin will include " | |
1991 "logs from other IM clients. Currently, this " | |
1992 "includes Adium, Fire, Messenger Plus!, " | |
1993 "MSN Messenger, and Trillian."), | |
1994 | |
11503
cd0c8830d881
[gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents:
11459
diff
changeset
|
1995 "Richard Laager <rlaager@users.sf.net>", /**< author */ |
11459 | 1996 GAIM_WEBSITE, /**< homepage */ |
1997 plugin_load, /**< load */ | |
1998 plugin_unload, /**< unload */ | |
1999 NULL, /**< destroy */ | |
2000 NULL, /**< ui_info */ | |
2001 NULL, /**< extra_info */ | |
2002 &prefs_info, /**< prefs_info */ | |
2003 NULL /**< actions */ | |
2004 }; | |
2005 | |
2006 GAIM_INIT_PLUGIN(log_reader, init_plugin, info) |