comparison libpurple/plugins/log_reader.c @ 15822:32c366eeeb99

sed -ie 's/gaim/purple/g'
author Sean Egan <seanegan@gmail.com>
date Mon, 19 Mar 2007 07:01:17 +0000
parents b6615958d87c
children 4999bbc52881
comparison
equal deleted inserted replaced
15821:84b0f9b23ede 15822:32c366eeeb99
2 # include <config.h> 2 # include <config.h>
3 #endif 3 #endif
4 4
5 #include <stdio.h> 5 #include <stdio.h>
6 6
7 #ifndef GAIM_PLUGINS 7 #ifndef PURPLE_PLUGINS
8 # define GAIM_PLUGINS 8 # define PURPLE_PLUGINS
9 #endif 9 #endif
10 10
11 #include "internal.h" 11 #include "internal.h"
12 12
13 #include "debug.h" 13 #include "debug.h"
18 #include "stringref.h" 18 #include "stringref.h"
19 #include "util.h" 19 #include "util.h"
20 #include "version.h" 20 #include "version.h"
21 #include "xmlnode.h" 21 #include "xmlnode.h"
22 22
23 /* This must be the last Gaim header included. */ 23 /* This must be the last Purple header included. */
24 #ifdef _WIN32 24 #ifdef _WIN32
25 #include "win32dep.h" 25 #include "win32dep.h"
26 #endif 26 #endif
27 27
28 /* Where is the Windows partition mounted? */ 28 /* Where is the Windows partition mounted? */
29 #ifndef GAIM_LOG_READER_WINDOWS_MOUNT_POINT 29 #ifndef PURPLE_LOG_READER_WINDOWS_MOUNT_POINT
30 #define GAIM_LOG_READER_WINDOWS_MOUNT_POINT "/mnt/windows" 30 #define PURPLE_LOG_READER_WINDOWS_MOUNT_POINT "/mnt/windows"
31 #endif 31 #endif
32 32
33 enum name_guesses { 33 enum name_guesses {
34 NAME_GUESS_UNKNOWN, 34 NAME_GUESS_UNKNOWN,
35 NAME_GUESS_ME, 35 NAME_GUESS_ME,
43 43
44 /* The adium logger doesn't write logs, only reads them. This is to include 44 /* The adium logger doesn't write logs, only reads them. This is to include
45 * Adium logs in the log viewer transparently. 45 * Adium logs in the log viewer transparently.
46 */ 46 */
47 47
48 static GaimLogLogger *adium_logger; 48 static PurpleLogLogger *adium_logger;
49 49
50 enum adium_log_type { 50 enum adium_log_type {
51 ADIUM_HTML, 51 ADIUM_HTML,
52 ADIUM_TEXT, 52 ADIUM_TEXT,
53 }; 53 };
55 struct adium_logger_data { 55 struct adium_logger_data {
56 char *path; 56 char *path;
57 enum adium_log_type type; 57 enum adium_log_type type;
58 }; 58 };
59 59
60 static GList *adium_logger_list(GaimLogType type, const char *sn, GaimAccount *account) 60 static GList *adium_logger_list(PurpleLogType type, const char *sn, PurpleAccount *account)
61 { 61 {
62 GList *list = NULL; 62 GList *list = NULL;
63 const char *logdir; 63 const char *logdir;
64 GaimPlugin *plugin; 64 PurplePlugin *plugin;
65 GaimPluginProtocolInfo *prpl_info; 65 PurplePluginProtocolInfo *prpl_info;
66 char *prpl_name; 66 char *prpl_name;
67 char *temp; 67 char *temp;
68 char *path; 68 char *path;
69 GDir *dir; 69 GDir *dir;
70 70
71 g_return_val_if_fail(sn != NULL, list); 71 g_return_val_if_fail(sn != NULL, list);
72 g_return_val_if_fail(account != NULL, list); 72 g_return_val_if_fail(account != NULL, list);
73 73
74 logdir = gaim_prefs_get_string("/plugins/core/log_reader/adium/log_directory"); 74 logdir = purple_prefs_get_string("/plugins/core/log_reader/adium/log_directory");
75 75
76 /* By clearing the log directory path, this logger can be (effectively) disabled. */ 76 /* By clearing the log directory path, this logger can be (effectively) disabled. */
77 if (!*logdir) 77 if (!*logdir)
78 return list; 78 return list;
79 79
80 plugin = gaim_find_prpl(gaim_account_get_protocol_id(account)); 80 plugin = purple_find_prpl(purple_account_get_protocol_id(account));
81 if (!plugin) 81 if (!plugin)
82 return NULL; 82 return NULL;
83 83
84 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); 84 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
85 if (!prpl_info->list_icon) 85 if (!prpl_info->list_icon)
86 return NULL; 86 return NULL;
87 87
88 prpl_name = g_ascii_strup(prpl_info->list_icon(account, NULL), -1); 88 prpl_name = g_ascii_strup(prpl_info->list_icon(account, NULL), -1);
89 89
94 dir = g_dir_open(path, 0, NULL); 94 dir = g_dir_open(path, 0, NULL);
95 if (dir) { 95 if (dir) {
96 const gchar *file; 96 const gchar *file;
97 97
98 while ((file = g_dir_read_name(dir))) { 98 while ((file = g_dir_read_name(dir))) {
99 if (!gaim_str_has_prefix(file, sn)) 99 if (!purple_str_has_prefix(file, sn))
100 continue; 100 continue;
101 if (gaim_str_has_suffix(file, ".html") || gaim_str_has_suffix(file, ".AdiumHTMLLog")) { 101 if (purple_str_has_suffix(file, ".html") || purple_str_has_suffix(file, ".AdiumHTMLLog")) {
102 struct tm tm; 102 struct tm tm;
103 const char *date = file; 103 const char *date = file;
104 104
105 date += strlen(sn) + 2; 105 date += strlen(sn) + 2;
106 if (sscanf(date, "%u|%u|%u", 106 if (sscanf(date, "%u|%u|%u",
107 &tm.tm_year, &tm.tm_mon, &tm.tm_mday) != 3) { 107 &tm.tm_year, &tm.tm_mon, &tm.tm_mday) != 3) {
108 108
109 gaim_debug(GAIM_DEBUG_ERROR, "Adium log parse", 109 purple_debug(PURPLE_DEBUG_ERROR, "Adium log parse",
110 "Filename timestamp parsing error\n"); 110 "Filename timestamp parsing error\n");
111 } else { 111 } else {
112 char *filename = g_build_filename(path, file, NULL); 112 char *filename = g_build_filename(path, file, NULL);
113 FILE *handle = g_fopen(filename, "rb"); 113 FILE *handle = g_fopen(filename, "rb");
114 char *contents; 114 char *contents;
115 char *contents2; 115 char *contents2;
116 struct adium_logger_data *data; 116 struct adium_logger_data *data;
117 GaimLog *log; 117 PurpleLog *log;
118 118
119 if (!handle) { 119 if (!handle) {
120 g_free(filename); 120 g_free(filename);
121 continue; 121 continue;
122 } 122 }
139 contents2++; 139 contents2++;
140 140
141 if (sscanf(contents2, "%u.%u.%u", 141 if (sscanf(contents2, "%u.%u.%u",
142 &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 3) { 142 &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 3) {
143 143
144 gaim_debug(GAIM_DEBUG_ERROR, "Adium log parse", 144 purple_debug(PURPLE_DEBUG_ERROR, "Adium log parse",
145 "Contents timestamp parsing error\n"); 145 "Contents timestamp parsing error\n");
146 g_free(contents); 146 g_free(contents);
147 g_free(filename); 147 g_free(filename);
148 continue; 148 continue;
149 } 149 }
155 155
156 tm.tm_year -= 1900; 156 tm.tm_year -= 1900;
157 tm.tm_mon -= 1; 157 tm.tm_mon -= 1;
158 158
159 /* XXX: Look into this later... Should we pass in a struct tm? */ 159 /* XXX: Look into this later... Should we pass in a struct tm? */
160 log = gaim_log_new(GAIM_LOG_IM, sn, account, NULL, mktime(&tm), NULL); 160 log = purple_log_new(PURPLE_LOG_IM, sn, account, NULL, mktime(&tm), NULL);
161 log->logger = adium_logger; 161 log->logger = adium_logger;
162 log->logger_data = data; 162 log->logger_data = data;
163 163
164 list = g_list_append(list, log); 164 list = g_list_append(list, log);
165 } 165 }
166 } else if (gaim_str_has_suffix(file, ".adiumLog")) { 166 } else if (purple_str_has_suffix(file, ".adiumLog")) {
167 struct tm tm; 167 struct tm tm;
168 const char *date = file; 168 const char *date = file;
169 169
170 date += strlen(sn) + 2; 170 date += strlen(sn) + 2;
171 if (sscanf(date, "%u|%u|%u", 171 if (sscanf(date, "%u|%u|%u",
172 &tm.tm_year, &tm.tm_mon, &tm.tm_mday) != 3) { 172 &tm.tm_year, &tm.tm_mon, &tm.tm_mday) != 3) {
173 173
174 gaim_debug(GAIM_DEBUG_ERROR, "Adium log parse", 174 purple_debug(PURPLE_DEBUG_ERROR, "Adium log parse",
175 "Filename timestamp parsing error\n"); 175 "Filename timestamp parsing error\n");
176 } else { 176 } else {
177 char *filename = g_build_filename(path, file, NULL); 177 char *filename = g_build_filename(path, file, NULL);
178 FILE *handle = g_fopen(filename, "rb"); 178 FILE *handle = g_fopen(filename, "rb");
179 char *contents; 179 char *contents;
180 char *contents2; 180 char *contents2;
181 struct adium_logger_data *data; 181 struct adium_logger_data *data;
182 GaimLog *log; 182 PurpleLog *log;
183 183
184 if (!handle) { 184 if (!handle) {
185 g_free(filename); 185 g_free(filename);
186 continue; 186 continue;
187 } 187 }
199 contents2++; 199 contents2++;
200 200
201 if (sscanf(contents2, "%u.%u.%u", 201 if (sscanf(contents2, "%u.%u.%u",
202 &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 3) { 202 &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 3) {
203 203
204 gaim_debug(GAIM_DEBUG_ERROR, "Adium log parse", 204 purple_debug(PURPLE_DEBUG_ERROR, "Adium log parse",
205 "Contents timestamp parsing error\n"); 205 "Contents timestamp parsing error\n");
206 g_free(contents); 206 g_free(contents);
207 g_free(filename); 207 g_free(filename);
208 continue; 208 continue;
209 } 209 }
216 data = g_new0(struct adium_logger_data, 1); 216 data = g_new0(struct adium_logger_data, 1);
217 data->path = filename; 217 data->path = filename;
218 data->type = ADIUM_TEXT; 218 data->type = ADIUM_TEXT;
219 219
220 /* XXX: Look into this later... Should we pass in a struct tm? */ 220 /* XXX: Look into this later... Should we pass in a struct tm? */
221 log = gaim_log_new(GAIM_LOG_IM, sn, account, NULL, mktime(&tm), NULL); 221 log = purple_log_new(PURPLE_LOG_IM, sn, account, NULL, mktime(&tm), NULL);
222 log->logger = adium_logger; 222 log->logger = adium_logger;
223 log->logger_data = data; 223 log->logger_data = data;
224 224
225 list = g_list_append(list, log); 225 list = g_list_append(list, log);
226 } 226 }
233 g_free(path); 233 g_free(path);
234 234
235 return list; 235 return list;
236 } 236 }
237 237
238 static char *adium_logger_read (GaimLog *log, GaimLogReadFlags *flags) 238 static char *adium_logger_read (PurpleLog *log, PurpleLogReadFlags *flags)
239 { 239 {
240 struct adium_logger_data *data; 240 struct adium_logger_data *data;
241 GError *error = NULL; 241 GError *error = NULL;
242 gchar *read = NULL; 242 gchar *read = NULL;
243 gsize length; 243 gsize length;
246 246
247 data = log->logger_data; 247 data = log->logger_data;
248 248
249 g_return_val_if_fail(data->path != NULL, g_strdup("")); 249 g_return_val_if_fail(data->path != NULL, g_strdup(""));
250 250
251 gaim_debug(GAIM_DEBUG_INFO, "Adium log read", 251 purple_debug(PURPLE_DEBUG_INFO, "Adium log read",
252 "Reading %s\n", data->path); 252 "Reading %s\n", data->path);
253 if (!g_file_get_contents(data->path, &read, &length, &error)) { 253 if (!g_file_get_contents(data->path, &read, &length, &error)) {
254 gaim_debug(GAIM_DEBUG_ERROR, "Adium log read", 254 purple_debug(PURPLE_DEBUG_ERROR, "Adium log read",
255 "Error reading log\n"); 255 "Error reading log\n");
256 if (error) 256 if (error)
257 g_error_free(error); 257 g_error_free(error);
258 return g_strdup(""); 258 return g_strdup("");
259 } 259 }
266 266
267 #ifdef WIN32 267 #ifdef WIN32
268 /* This problem only seems to show up on Windows. 268 /* This problem only seems to show up on Windows.
269 * The BOM is displaying as a space at the beginning of the log. 269 * The BOM is displaying as a space at the beginning of the log.
270 */ 270 */
271 if (gaim_str_has_prefix(read, "\xef\xbb\xbf")) 271 if (purple_str_has_prefix(read, "\xef\xbb\xbf"))
272 { 272 {
273 /* FIXME: This feels so wrong... */ 273 /* FIXME: This feels so wrong... */
274 char *temp = g_strdup(&(read[3])); 274 char *temp = g_strdup(&(read[3]));
275 g_free(read); 275 g_free(read);
276 read = temp; 276 read = temp;
283 */ 283 */
284 284
285 return read; 285 return read;
286 } 286 }
287 287
288 static int adium_logger_size (GaimLog *log) 288 static int adium_logger_size (PurpleLog *log)
289 { 289 {
290 struct adium_logger_data *data; 290 struct adium_logger_data *data;
291 char *text; 291 char *text;
292 size_t size; 292 size_t size;
293 293
294 g_return_val_if_fail(log != NULL, 0); 294 g_return_val_if_fail(log != NULL, 0);
295 295
296 data = log->logger_data; 296 data = log->logger_data;
297 297
298 if (gaim_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) { 298 if (purple_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) {
299 struct stat st; 299 struct stat st;
300 300
301 if (!data->path || stat(data->path, &st)) 301 if (!data->path || stat(data->path, &st))
302 st.st_size = 0; 302 st.st_size = 0;
303 303
309 g_free(text); 309 g_free(text);
310 310
311 return size; 311 return size;
312 } 312 }
313 313
314 static void adium_logger_finalize(GaimLog *log) 314 static void adium_logger_finalize(PurpleLog *log)
315 { 315 {
316 struct adium_logger_data *data; 316 struct adium_logger_data *data;
317 317
318 g_return_if_fail(log != NULL); 318 g_return_if_fail(log != NULL);
319 319
330 #if 0 330 #if 0
331 /* The fire logger doesn't write logs, only reads them. This is to include 331 /* The fire logger doesn't write logs, only reads them. This is to include
332 * Fire logs in the log viewer transparently. 332 * Fire logs in the log viewer transparently.
333 */ 333 */
334 334
335 static GaimLogLogger *fire_logger; 335 static PurpleLogLogger *fire_logger;
336 336
337 struct fire_logger_data { 337 struct fire_logger_data {
338 }; 338 };
339 339
340 static GList *fire_logger_list(GaimLogType type, const char *sn, GaimAccount *account) 340 static GList *fire_logger_list(PurpleLogType type, const char *sn, PurpleAccount *account)
341 { 341 {
342 /* TODO: Do something here. */ 342 /* TODO: Do something here. */
343 return NULL; 343 return NULL;
344 } 344 }
345 345
346 static char * fire_logger_read (GaimLog *log, GaimLogReadFlags *flags) 346 static char * fire_logger_read (PurpleLog *log, PurpleLogReadFlags *flags)
347 { 347 {
348 struct fire_logger_data *data; 348 struct fire_logger_data *data;
349 349
350 g_return_val_if_fail(log != NULL, g_strdup("")); 350 g_return_val_if_fail(log != NULL, g_strdup(""));
351 351
353 353
354 /* TODO: Do something here. */ 354 /* TODO: Do something here. */
355 return g_strdup(""); 355 return g_strdup("");
356 } 356 }
357 357
358 static int fire_logger_size (GaimLog *log) 358 static int fire_logger_size (PurpleLog *log)
359 { 359 {
360 g_return_val_if_fail(log != NULL, 0); 360 g_return_val_if_fail(log != NULL, 0);
361 361
362 if (gaim_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) 362 if (purple_prefs_get_bool("/plugins/core/log_reader/fast_sizes"))
363 return 0; 363 return 0;
364 364
365 /* TODO: Do something here. */ 365 /* TODO: Do something here. */
366 return 0; 366 return 0;
367 } 367 }
368 368
369 static void fire_logger_finalize(GaimLog *log) 369 static void fire_logger_finalize(PurpleLog *log)
370 { 370 {
371 g_return_if_fail(log != NULL); 371 g_return_if_fail(log != NULL);
372 372
373 /* TODO: Do something here. */ 373 /* TODO: Do something here. */
374 } 374 }
382 #if 0 382 #if 0
383 /* The messenger_plus logger doesn't write logs, only reads them. This is to include 383 /* The messenger_plus logger doesn't write logs, only reads them. This is to include
384 * Messenger Plus! logs in the log viewer transparently. 384 * Messenger Plus! logs in the log viewer transparently.
385 */ 385 */
386 386
387 static GaimLogLogger *messenger_plus_logger; 387 static PurpleLogLogger *messenger_plus_logger;
388 388
389 struct messenger_plus_logger_data { 389 struct messenger_plus_logger_data {
390 }; 390 };
391 391
392 static GList *messenger_plus_logger_list(GaimLogType type, const char *sn, GaimAccount *account) 392 static GList *messenger_plus_logger_list(PurpleLogType type, const char *sn, PurpleAccount *account)
393 { 393 {
394 /* TODO: Do something here. */ 394 /* TODO: Do something here. */
395 return NULL; 395 return NULL;
396 } 396 }
397 397
398 static char * messenger_plus_logger_read (GaimLog *log, GaimLogReadFlags *flags) 398 static char * messenger_plus_logger_read (PurpleLog *log, PurpleLogReadFlags *flags)
399 { 399 {
400 struct messenger_plus_logger_data *data = log->logger_data; 400 struct messenger_plus_logger_data *data = log->logger_data;
401 401
402 g_return_val_if_fail(log != NULL, g_strdup("")); 402 g_return_val_if_fail(log != NULL, g_strdup(""));
403 403
405 405
406 /* TODO: Do something here. */ 406 /* TODO: Do something here. */
407 return g_strdup(""); 407 return g_strdup("");
408 } 408 }
409 409
410 static int messenger_plus_logger_size (GaimLog *log) 410 static int messenger_plus_logger_size (PurpleLog *log)
411 { 411 {
412 g_return_val_if_fail(log != NULL, 0); 412 g_return_val_if_fail(log != NULL, 0);
413 413
414 if (gaim_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) 414 if (purple_prefs_get_bool("/plugins/core/log_reader/fast_sizes"))
415 return 0; 415 return 0;
416 416
417 /* TODO: Do something here. */ 417 /* TODO: Do something here. */
418 return 0; 418 return 0;
419 } 419 }
420 420
421 static void messenger_plus_logger_finalize(GaimLog *log) 421 static void messenger_plus_logger_finalize(PurpleLog *log)
422 { 422 {
423 g_return_if_fail(log != NULL); 423 g_return_if_fail(log != NULL);
424 424
425 /* TODO: Do something here. */ 425 /* TODO: Do something here. */
426 } 426 }
433 433
434 /* The msn logger doesn't write logs, only reads them. This is to include 434 /* The msn logger doesn't write logs, only reads them. This is to include
435 * MSN Messenger message histories in the log viewer transparently. 435 * MSN Messenger message histories in the log viewer transparently.
436 */ 436 */
437 437
438 static GaimLogLogger *msn_logger; 438 static PurpleLogLogger *msn_logger;
439 439
440 struct msn_logger_data { 440 struct msn_logger_data {
441 xmlnode *root; 441 xmlnode *root;
442 xmlnode *message; 442 xmlnode *message;
443 const char *session_id; 443 const char *session_id;
478 #endif 478 #endif
479 479
480 datetime = xmlnode_get_attrib(message, "DateTime"); 480 datetime = xmlnode_get_attrib(message, "DateTime");
481 if (!(datetime && *datetime)) 481 if (!(datetime && *datetime))
482 { 482 {
483 gaim_debug_error("MSN log timestamp parse", 483 purple_debug_error("MSN log timestamp parse",
484 "Attribute missing: %s\n", "DateTime"); 484 "Attribute missing: %s\n", "DateTime");
485 return (time_t)0; 485 return (time_t)0;
486 } 486 }
487 487
488 stamp = gaim_str_to_time(datetime, TRUE, &tm2, NULL, NULL); 488 stamp = purple_str_to_time(datetime, TRUE, &tm2, NULL, NULL);
489 #ifdef HAVE_TM_GMTOFF 489 #ifdef HAVE_TM_GMTOFF
490 tm2.tm_gmtoff = 0; 490 tm2.tm_gmtoff = 0;
491 #endif 491 #endif
492 #ifdef HAVE_STRUCT_TM_TM_ZONE 492 #ifdef HAVE_STRUCT_TM_TM_ZONE
493 /* This is used in the place of a timezone abbreviation if the 493 /* This is used in the place of a timezone abbreviation if the
499 499
500 500
501 date = xmlnode_get_attrib(message, "Date"); 501 date = xmlnode_get_attrib(message, "Date");
502 if (!(date && *date)) 502 if (!(date && *date))
503 { 503 {
504 gaim_debug_error("MSN log timestamp parse", 504 purple_debug_error("MSN log timestamp parse",
505 "Attribute missing: %s\n", "Date"); 505 "Attribute missing: %s\n", "Date");
506 *tm_out = &tm2; 506 *tm_out = &tm2;
507 return stamp; 507 return stamp;
508 } 508 }
509 509
510 time = xmlnode_get_attrib(message, "Time"); 510 time = xmlnode_get_attrib(message, "Time");
511 if (!(time && *time)) 511 if (!(time && *time))
512 { 512 {
513 gaim_debug_error("MSN log timestamp parse", 513 purple_debug_error("MSN log timestamp parse",
514 "Attribute missing: %s\n", "Time"); 514 "Attribute missing: %s\n", "Time");
515 *tm_out = &tm2; 515 *tm_out = &tm2;
516 return stamp; 516 return stamp;
517 } 517 }
518 518
519 if (sscanf(date, "%u/%u/%u", &month, &day, &year) != 3) 519 if (sscanf(date, "%u/%u/%u", &month, &day, &year) != 3)
520 { 520 {
521 gaim_debug_error("MSN log timestamp parse", 521 purple_debug_error("MSN log timestamp parse",
522 "%s parsing error\n", "Date"); 522 "%s parsing error\n", "Date");
523 *tm_out = &tm2; 523 *tm_out = &tm2;
524 return stamp; 524 return stamp;
525 } 525 }
526 else 526 else
533 } 533 }
534 } 534 }
535 535
536 if (sscanf(time, "%u:%u:%u %c", &hour, &min, &sec, &am_pm) != 4) 536 if (sscanf(time, "%u:%u:%u %c", &hour, &min, &sec, &am_pm) != 4)
537 { 537 {
538 gaim_debug_error("MSN log timestamp parse", 538 purple_debug_error("MSN log timestamp parse",
539 "%s parsing error\n", "Time"); 539 "%s parsing error\n", "Time");
540 *tm_out = &tm2; 540 *tm_out = &tm2;
541 return stamp; 541 return stamp;
542 } 542 }
543 543
547 /* 12 AM = 00 hr */ 547 /* 12 AM = 00 hr */
548 hour = 0; 548 hour = 0;
549 } 549 }
550 550
551 str = g_strdup_printf("%04i-%02i-%02iT%02i:%02i:%02i", year, month, day, hour, min, sec); 551 str = g_strdup_printf("%04i-%02i-%02iT%02i:%02i:%02i", year, month, day, hour, min, sec);
552 t = gaim_str_to_time(str, TRUE, &tm, NULL, NULL); 552 t = purple_str_to_time(str, TRUE, &tm, NULL, NULL);
553 553
554 554
555 if (stamp > t) 555 if (stamp > t)
556 diff = stamp - t; 556 diff = stamp - t;
557 else 557 else
562 if (day <= 12) 562 if (day <= 12)
563 { 563 {
564 /* Swap day & month variables, to see if it's a non-US date. */ 564 /* Swap day & month variables, to see if it's a non-US date. */
565 g_free(str); 565 g_free(str);
566 str = g_strdup_printf("%04i-%02i-%02iT%02i:%02i:%02i", year, month, day, hour, min, sec); 566 str = g_strdup_printf("%04i-%02i-%02iT%02i:%02i:%02i", year, month, day, hour, min, sec);
567 t = gaim_str_to_time(str, TRUE, &tm, NULL, NULL); 567 t = purple_str_to_time(str, TRUE, &tm, NULL, NULL);
568 568
569 if (stamp > t) 569 if (stamp > t)
570 diff = stamp - t; 570 diff = stamp - t;
571 else 571 else
572 diff = t - stamp; 572 diff = t - stamp;
595 } 595 }
596 } 596 }
597 597
598 /* If we got here, the time is legal with a reasonable offset. 598 /* If we got here, the time is legal with a reasonable offset.
599 * Let's find out if it's in our TZ. */ 599 * Let's find out if it's in our TZ. */
600 if (gaim_str_to_time(str, FALSE, &tm, NULL, NULL) == stamp) 600 if (purple_str_to_time(str, FALSE, &tm, NULL, NULL) == stamp)
601 { 601 {
602 g_free(str); 602 g_free(str);
603 *tm_out = &tm; 603 *tm_out = &tm;
604 return stamp; 604 return stamp;
605 } 605 }
611 #endif 611 #endif
612 *tm_out = &tm; 612 *tm_out = &tm;
613 return stamp; 613 return stamp;
614 } 614 }
615 615
616 static GList *msn_logger_list(GaimLogType type, const char *sn, GaimAccount *account) 616 static GList *msn_logger_list(PurpleLogType type, const char *sn, PurpleAccount *account)
617 { 617 {
618 GList *list = NULL; 618 GList *list = NULL;
619 char *username; 619 char *username;
620 GaimBuddy *buddy; 620 PurpleBuddy *buddy;
621 const char *logdir; 621 const char *logdir;
622 const char *savedfilename = NULL; 622 const char *savedfilename = NULL;
623 char *logfile; 623 char *logfile;
624 char *path; 624 char *path;
625 GError *error = NULL; 625 GError *error = NULL;
634 g_return_val_if_fail(account != NULL, list); 634 g_return_val_if_fail(account != NULL, list);
635 635
636 if (strcmp(account->protocol_id, "prpl-msn")) 636 if (strcmp(account->protocol_id, "prpl-msn"))
637 return list; 637 return list;
638 638
639 logdir = gaim_prefs_get_string("/plugins/core/log_reader/msn/log_directory"); 639 logdir = purple_prefs_get_string("/plugins/core/log_reader/msn/log_directory");
640 640
641 /* By clearing the log directory path, this logger can be (effectively) disabled. */ 641 /* By clearing the log directory path, this logger can be (effectively) disabled. */
642 if (!*logdir) 642 if (!*logdir)
643 return list; 643 return list;
644 644
645 buddy = gaim_find_buddy(account, sn); 645 buddy = purple_find_buddy(account, sn);
646 646
647 if ((username = g_strdup(gaim_account_get_string( 647 if ((username = g_strdup(purple_account_get_string(
648 account, "log_reader_msn_log_folder", NULL)))) { 648 account, "log_reader_msn_log_folder", NULL)))) {
649 /* As a special case, we allow the null string to kill the parsing 649 /* As a special case, we allow the null string to kill the parsing
650 * straight away. This would allow the user to deal with the case 650 * straight away. This would allow the user to deal with the case
651 * when two account have the same username at different domains and 651 * when two account have the same username at different domains and
652 * only one has logs stored. 652 * only one has logs stored.
654 if (!*username) { 654 if (!*username) {
655 g_free(username); 655 g_free(username);
656 return list; 656 return list;
657 } 657 }
658 } else { 658 } else {
659 username = g_strdup(gaim_normalize(account, account->username)); 659 username = g_strdup(purple_normalize(account, account->username));
660 } 660 }
661 661
662 if (buddy) 662 if (buddy)
663 savedfilename = gaim_blist_node_get_string(&buddy->node, "log_reader_msn_log_filename"); 663 savedfilename = purple_blist_node_get_string(&buddy->node, "log_reader_msn_log_filename");
664 664
665 if (savedfilename) { 665 if (savedfilename) {
666 /* As a special case, we allow the null string to kill the parsing 666 /* As a special case, we allow the null string to kill the parsing
667 * straight away. This would allow the user to deal with the case 667 * straight away. This would allow the user to deal with the case
668 * when two buddies have the same username at different domains and 668 * when two buddies have the same username at different domains and
673 return list; 673 return list;
674 } 674 }
675 675
676 logfile = g_strdup(savedfilename); 676 logfile = g_strdup(savedfilename);
677 } else { 677 } else {
678 logfile = g_strdup_printf("%s.xml", gaim_normalize(account, sn)); 678 logfile = g_strdup_printf("%s.xml", purple_normalize(account, sn));
679 } 679 }
680 680
681 path = g_build_filename(logdir, username, "History", logfile, NULL); 681 path = g_build_filename(logdir, username, "History", logfile, NULL);
682 682
683 if (!g_file_test(path, G_FILE_TEST_EXISTS)) { 683 if (!g_file_test(path, G_FILE_TEST_EXISTS)) {
711 const gchar *name; 711 const gchar *name;
712 712
713 while ((name = g_dir_read_name(dir))) { 713 while ((name = g_dir_read_name(dir))) {
714 const char *c = name; 714 const char *c = name;
715 715
716 if (!gaim_str_has_prefix(c, username)) 716 if (!purple_str_has_prefix(c, username))
717 continue; 717 continue;
718 718
719 c += strlen(username); 719 c += strlen(username);
720 while (*c) { 720 while (*c) {
721 if (!g_ascii_isdigit(*c)) 721 if (!g_ascii_isdigit(*c))
728 /* The !c makes sure we got to the end of the while loop above. */ 728 /* The !c makes sure we got to the end of the while loop above. */
729 if (!*c && g_file_test(path, G_FILE_TEST_IS_DIR)) { 729 if (!*c && g_file_test(path, G_FILE_TEST_IS_DIR)) {
730 char *history_path = g_build_filename( 730 char *history_path = g_build_filename(
731 path, "History", NULL); 731 path, "History", NULL);
732 if (g_file_test(history_path, G_FILE_TEST_IS_DIR)) { 732 if (g_file_test(history_path, G_FILE_TEST_IS_DIR)) {
733 gaim_account_set_string(account, 733 purple_account_set_string(account,
734 "log_reader_msn_log_folder", name); 734 "log_reader_msn_log_folder", name);
735 g_free(path); 735 g_free(path);
736 path = history_path; 736 path = history_path;
737 found = TRUE; 737 found = TRUE;
738 break; 738 break;
752 return list; 752 return list;
753 } 753 }
754 754
755 /* If we've reached this point, we've found a History folder. */ 755 /* If we've reached this point, we've found a History folder. */
756 756
757 username = g_strdup(gaim_normalize(account, sn)); 757 username = g_strdup(purple_normalize(account, sn));
758 at_sign = g_strrstr(username, "@"); 758 at_sign = g_strrstr(username, "@");
759 if (at_sign) 759 if (at_sign)
760 *at_sign = '\0'; 760 *at_sign = '\0';
761 761
762 found = FALSE; 762 found = FALSE;
765 const gchar *name; 765 const gchar *name;
766 766
767 while ((name = g_dir_read_name(dir))) { 767 while ((name = g_dir_read_name(dir))) {
768 const char *c = name; 768 const char *c = name;
769 769
770 if (!gaim_str_has_prefix(c, username)) 770 if (!purple_str_has_prefix(c, username))
771 continue; 771 continue;
772 772
773 c += strlen(username); 773 c += strlen(username);
774 while (*c) { 774 while (*c) {
775 if (!g_ascii_isdigit(*c)) 775 if (!g_ascii_isdigit(*c))
801 g_free(username); 801 g_free(username);
802 g_free(logfile); 802 g_free(logfile);
803 logfile = NULL; /* No sense saving the obvious buddy@domain.com. */ 803 logfile = NULL; /* No sense saving the obvious buddy@domain.com. */
804 } 804 }
805 805
806 gaim_debug(GAIM_DEBUG_INFO, "MSN log read", 806 purple_debug(PURPLE_DEBUG_INFO, "MSN log read",
807 "Reading %s\n", path); 807 "Reading %s\n", path);
808 if (!g_file_get_contents(path, &contents, &length, &error)) { 808 if (!g_file_get_contents(path, &contents, &length, &error)) {
809 g_free(path); 809 g_free(path);
810 gaim_debug(GAIM_DEBUG_ERROR, "MSN log read", 810 purple_debug(PURPLE_DEBUG_ERROR, "MSN log read",
811 "Error reading log\n"); 811 "Error reading log\n");
812 if (error) 812 if (error)
813 g_error_free(error); 813 g_error_free(error);
814 return list; 814 return list;
815 } 815 }
820 * then tweak the blist.xml file by hand if need be. This would be the case if two 820 * then tweak the blist.xml file by hand if need be. This would be the case if two
821 * buddies have the same username at different domains. One set of logs would get 821 * buddies have the same username at different domains. One set of logs would get
822 * detected for both buddies. 822 * detected for both buddies.
823 */ 823 */
824 if (buddy && logfile) { 824 if (buddy && logfile) {
825 gaim_blist_node_set_string(&buddy->node, "log_reader_msn_log_filename", logfile); 825 purple_blist_node_set_string(&buddy->node, "log_reader_msn_log_filename", logfile);
826 g_free(logfile); 826 g_free(logfile);
827 } 827 }
828 828
829 root = xmlnode_from_str(contents, length); 829 root = xmlnode_from_str(contents, length);
830 g_free(contents); 830 g_free(contents);
835 message = xmlnode_get_next_twin(message)) { 835 message = xmlnode_get_next_twin(message)) {
836 const char *session_id; 836 const char *session_id;
837 837
838 session_id = xmlnode_get_attrib(message, "SessionID"); 838 session_id = xmlnode_get_attrib(message, "SessionID");
839 if (!session_id) { 839 if (!session_id) {
840 gaim_debug(GAIM_DEBUG_ERROR, "MSN log parse", 840 purple_debug(PURPLE_DEBUG_ERROR, "MSN log parse",
841 "Error parsing message: %s\n", "SessionID missing"); 841 "Error parsing message: %s\n", "SessionID missing");
842 continue; 842 continue;
843 } 843 }
844 844
845 if (strcmp(session_id, old_session_id)) { 845 if (strcmp(session_id, old_session_id)) {
847 * The session ID differs from the last message. 847 * The session ID differs from the last message.
848 * Thus, this is the start of a new conversation. 848 * Thus, this is the start of a new conversation.
849 */ 849 */
850 struct tm *tm; 850 struct tm *tm;
851 time_t stamp; 851 time_t stamp;
852 GaimLog *log; 852 PurpleLog *log;
853 853
854 data = g_new0(struct msn_logger_data, 1); 854 data = g_new0(struct msn_logger_data, 1);
855 data->root = root; 855 data->root = root;
856 data->message = message; 856 data->message = message;
857 data->session_id = session_id; 857 data->session_id = session_id;
858 data->text = NULL; 858 data->text = NULL;
859 data->last_log = FALSE; 859 data->last_log = FALSE;
860 860
861 stamp = msn_logger_parse_timestamp(message, &tm); 861 stamp = msn_logger_parse_timestamp(message, &tm);
862 862
863 log = gaim_log_new(GAIM_LOG_IM, sn, account, NULL, stamp, tm); 863 log = purple_log_new(PURPLE_LOG_IM, sn, account, NULL, stamp, tm);
864 log->logger = msn_logger; 864 log->logger = msn_logger;
865 log->logger_data = data; 865 log->logger_data = data;
866 866
867 list = g_list_append(list, log); 867 list = g_list_append(list, log);
868 } 868 }
873 data->last_log = TRUE; 873 data->last_log = TRUE;
874 874
875 return list; 875 return list;
876 } 876 }
877 877
878 static char * msn_logger_read (GaimLog *log, GaimLogReadFlags *flags) 878 static char * msn_logger_read (PurpleLog *log, PurpleLogReadFlags *flags)
879 { 879 {
880 struct msn_logger_data *data; 880 struct msn_logger_data *data;
881 GString *text = NULL; 881 GString *text = NULL;
882 xmlnode *message; 882 xmlnode *message;
883 883
896 896
897 text = g_string_new(""); 897 text = g_string_new("");
898 898
899 if (!data->root || !data->message || !data->session_id) { 899 if (!data->root || !data->message || !data->session_id) {
900 /* Something isn't allocated correctly. */ 900 /* Something isn't allocated correctly. */
901 gaim_debug(GAIM_DEBUG_ERROR, "MSN log parse", 901 purple_debug(PURPLE_DEBUG_ERROR, "MSN log parse",
902 "Error parsing message: %s\n", "Internal variables inconsistent"); 902 "Error parsing message: %s\n", "Internal variables inconsistent");
903 data->text = text; 903 data->text = text;
904 904
905 return text->str; 905 return text->str;
906 } 906 }
924 924
925 new_session_id = xmlnode_get_attrib(message, "SessionID"); 925 new_session_id = xmlnode_get_attrib(message, "SessionID");
926 926
927 /* If this triggers, something is wrong with the XML. */ 927 /* If this triggers, something is wrong with the XML. */
928 if (!new_session_id) { 928 if (!new_session_id) {
929 gaim_debug(GAIM_DEBUG_ERROR, "MSN log parse", 929 purple_debug(PURPLE_DEBUG_ERROR, "MSN log parse",
930 "Error parsing message: %s\n", "New SessionID missing"); 930 "Error parsing message: %s\n", "New SessionID missing");
931 break; 931 break;
932 } 932 }
933 933
934 if (strcmp(new_session_id, data->session_id)) { 934 if (strcmp(new_session_id, data->session_id)) {
966 to_name = NULL; 966 to_name = NULL;
967 } 967 }
968 } 968 }
969 969
970 their_name = from_name; 970 their_name = from_name;
971 if (from_name && gaim_prefs_get_bool("/plugins/core/log_reader/use_name_heuristics")) { 971 if (from_name && purple_prefs_get_bool("/plugins/core/log_reader/use_name_heuristics")) {
972 const char *friendly_name = gaim_connection_get_display_name(log->account->gc); 972 const char *friendly_name = purple_connection_get_display_name(log->account->gc);
973 973
974 if (friendly_name != NULL) { 974 if (friendly_name != NULL) {
975 int friendly_name_length = strlen(friendly_name); 975 int friendly_name_length = strlen(friendly_name);
976 const char *alias; 976 const char *alias;
977 int alias_length; 977 int alias_length;
978 GaimBuddy *buddy = gaim_find_buddy(log->account, log->name); 978 PurpleBuddy *buddy = purple_find_buddy(log->account, log->name);
979 gboolean from_name_matches; 979 gboolean from_name_matches;
980 gboolean to_name_matches; 980 gboolean to_name_matches;
981 981
982 if (buddy && buddy->alias) 982 if (buddy && buddy->alias)
983 their_name = buddy->alias; 983 their_name = buddy->alias;
996 /* Try to guess which user is me. 996 /* Try to guess which user is me.
997 * The first step is to determine if either of the names matches either my 997 * The first step is to determine if either of the names matches either my
998 * friendly name or alias. For this test, "match" is defined as: 998 * friendly name or alias. For this test, "match" is defined as:
999 * ^(friendly_name|alias)([^a-zA-Z0-9].*)?$ 999 * ^(friendly_name|alias)([^a-zA-Z0-9].*)?$
1000 */ 1000 */
1001 from_name_matches = (gaim_str_has_prefix(from_name, friendly_name) && 1001 from_name_matches = (purple_str_has_prefix(from_name, friendly_name) &&
1002 !isalnum(*(from_name + friendly_name_length))) || 1002 !isalnum(*(from_name + friendly_name_length))) ||
1003 (gaim_str_has_prefix(from_name, alias) && 1003 (purple_str_has_prefix(from_name, alias) &&
1004 !isalnum(*(from_name + alias_length))); 1004 !isalnum(*(from_name + alias_length)));
1005 1005
1006 to_name_matches = to_name != NULL && ( 1006 to_name_matches = to_name != NULL && (
1007 (gaim_str_has_prefix(to_name, friendly_name) && 1007 (purple_str_has_prefix(to_name, friendly_name) &&
1008 !isalnum(*(to_name + friendly_name_length))) || 1008 !isalnum(*(to_name + friendly_name_length))) ||
1009 (gaim_str_has_prefix(to_name, alias) && 1009 (purple_str_has_prefix(to_name, alias) &&
1010 !isalnum(*(to_name + alias_length)))); 1010 !isalnum(*(to_name + alias_length))));
1011 1011
1012 if (from_name_matches) { 1012 if (from_name_matches) {
1013 if (!to_name_matches) { 1013 if (!to_name_matches) {
1014 name_guessed = NAME_GUESS_ME; 1014 name_guessed = NAME_GUESS_ME;
1034 /* Try to guess which user is them. 1034 /* Try to guess which user is them.
1035 * The first step is to determine if either of the names 1035 * The first step is to determine if either of the names
1036 * matches their alias. For this test, "match" is 1036 * matches their alias. For this test, "match" is
1037 * defined as: ^alias([^a-zA-Z0-9].*)?$ 1037 * defined as: ^alias([^a-zA-Z0-9].*)?$
1038 */ 1038 */
1039 from_name_matches = (gaim_str_has_prefix( 1039 from_name_matches = (purple_str_has_prefix(
1040 from_name, alias) && 1040 from_name, alias) &&
1041 !isalnum(*(from_name + 1041 !isalnum(*(from_name +
1042 alias_length))); 1042 alias_length)));
1043 1043
1044 to_name_matches = to_name && (gaim_str_has_prefix( 1044 to_name_matches = to_name && (purple_str_has_prefix(
1045 to_name, alias) && 1045 to_name, alias) &&
1046 !isalnum(*(to_name + 1046 !isalnum(*(to_name +
1047 alias_length))); 1047 alias_length)));
1048 1048
1049 g_free(alias); 1049 g_free(alias);
1062 * The first step is to determine if either of 1062 * The first step is to determine if either of
1063 * the names matches their friendly name. For 1063 * the names matches their friendly name. For
1064 * this test, "match" is defined as: 1064 * this test, "match" is defined as:
1065 * ^friendly_name([^a-zA-Z0-9].*)?$ 1065 * ^friendly_name([^a-zA-Z0-9].*)?$
1066 */ 1066 */
1067 from_name_matches = (gaim_str_has_prefix( 1067 from_name_matches = (purple_str_has_prefix(
1068 from_name, 1068 from_name,
1069 buddy->server_alias) && 1069 buddy->server_alias) &&
1070 !isalnum(*(from_name + 1070 !isalnum(*(from_name +
1071 friendly_name_length))); 1071 friendly_name_length)));
1072 1072
1073 to_name_matches = to_name && ( 1073 to_name_matches = to_name && (
1074 (gaim_str_has_prefix( 1074 (purple_str_has_prefix(
1075 to_name, buddy->server_alias) && 1075 to_name, buddy->server_alias) &&
1076 !isalnum(*(to_name + 1076 !isalnum(*(to_name +
1077 friendly_name_length)))); 1077 friendly_name_length))));
1078 1078
1079 if (from_name_matches) { 1079 if (from_name_matches) {
1144 data->text = text; 1144 data->text = text;
1145 1145
1146 return text->str; 1146 return text->str;
1147 } 1147 }
1148 1148
1149 static int msn_logger_size (GaimLog *log) 1149 static int msn_logger_size (PurpleLog *log)
1150 { 1150 {
1151 char *text; 1151 char *text;
1152 size_t size; 1152 size_t size;
1153 1153
1154 g_return_val_if_fail(log != NULL, 0); 1154 g_return_val_if_fail(log != NULL, 0);
1155 1155
1156 if (gaim_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) 1156 if (purple_prefs_get_bool("/plugins/core/log_reader/fast_sizes"))
1157 return 0; 1157 return 0;
1158 1158
1159 text = msn_logger_read(log, NULL); 1159 text = msn_logger_read(log, NULL);
1160 size = strlen(text); 1160 size = strlen(text);
1161 g_free(text); 1161 g_free(text);
1162 1162
1163 return size; 1163 return size;
1164 } 1164 }
1165 1165
1166 static void msn_logger_finalize(GaimLog *log) 1166 static void msn_logger_finalize(PurpleLog *log)
1167 { 1167 {
1168 struct msn_logger_data *data; 1168 struct msn_logger_data *data;
1169 1169
1170 g_return_if_fail(log != NULL); 1170 g_return_if_fail(log != NULL);
1171 1171
1185 1185
1186 /* The trillian logger doesn't write logs, only reads them. This is to include 1186 /* The trillian logger doesn't write logs, only reads them. This is to include
1187 * Trillian logs in the log viewer transparently. 1187 * Trillian logs in the log viewer transparently.
1188 */ 1188 */
1189 1189
1190 static GaimLogLogger *trillian_logger; 1190 static PurpleLogLogger *trillian_logger;
1191 static void trillian_logger_finalize(GaimLog *log); 1191 static void trillian_logger_finalize(PurpleLog *log);
1192 1192
1193 struct trillian_logger_data { 1193 struct trillian_logger_data {
1194 char *path; /* FIXME: Change this to use GaimStringref like log.c:old_logger_list */ 1194 char *path; /* FIXME: Change this to use PurpleStringref like log.c:old_logger_list */
1195 int offset; 1195 int offset;
1196 int length; 1196 int length;
1197 char *their_nickname; 1197 char *their_nickname;
1198 }; 1198 };
1199 1199
1200 static GList *trillian_logger_list(GaimLogType type, const char *sn, GaimAccount *account) 1200 static GList *trillian_logger_list(PurpleLogType type, const char *sn, PurpleAccount *account)
1201 { 1201 {
1202 GList *list = NULL; 1202 GList *list = NULL;
1203 const char *logdir; 1203 const char *logdir;
1204 GaimPlugin *plugin; 1204 PurplePlugin *plugin;
1205 GaimPluginProtocolInfo *prpl_info; 1205 PurplePluginProtocolInfo *prpl_info;
1206 char *prpl_name; 1206 char *prpl_name;
1207 const char *buddy_name; 1207 const char *buddy_name;
1208 char *filename; 1208 char *filename;
1209 char *path; 1209 char *path;
1210 GError *error = NULL; 1210 GError *error = NULL;
1214 gchar *c; 1214 gchar *c;
1215 1215
1216 g_return_val_if_fail(sn != NULL, list); 1216 g_return_val_if_fail(sn != NULL, list);
1217 g_return_val_if_fail(account != NULL, list); 1217 g_return_val_if_fail(account != NULL, list);
1218 1218
1219 logdir = gaim_prefs_get_string("/plugins/core/log_reader/trillian/log_directory"); 1219 logdir = purple_prefs_get_string("/plugins/core/log_reader/trillian/log_directory");
1220 1220
1221 /* By clearing the log directory path, this logger can be (effectively) disabled. */ 1221 /* By clearing the log directory path, this logger can be (effectively) disabled. */
1222 if (!*logdir) 1222 if (!*logdir)
1223 return list; 1223 return list;
1224 1224
1225 plugin = gaim_find_prpl(gaim_account_get_protocol_id(account)); 1225 plugin = purple_find_prpl(purple_account_get_protocol_id(account));
1226 if (!plugin) 1226 if (!plugin)
1227 return NULL; 1227 return NULL;
1228 1228
1229 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin); 1229 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
1230 if (!prpl_info->list_icon) 1230 if (!prpl_info->list_icon)
1231 return NULL; 1231 return NULL;
1232 1232
1233 prpl_name = g_ascii_strup(prpl_info->list_icon(account, NULL), -1); 1233 prpl_name = g_ascii_strup(prpl_info->list_icon(account, NULL), -1);
1234 1234
1235 buddy_name = gaim_normalize(account, sn); 1235 buddy_name = purple_normalize(account, sn);
1236 1236
1237 filename = g_strdup_printf("%s.log", buddy_name); 1237 filename = g_strdup_printf("%s.log", buddy_name);
1238 path = g_build_filename( 1238 path = g_build_filename(
1239 logdir, prpl_name, filename, NULL); 1239 logdir, prpl_name, filename, NULL);
1240 1240
1241 gaim_debug(GAIM_DEBUG_INFO, "Trillian log list", 1241 purple_debug(PURPLE_DEBUG_INFO, "Trillian log list",
1242 "Reading %s\n", path); 1242 "Reading %s\n", path);
1243 /* FIXME: There's really no need to read the entire file at once. 1243 /* FIXME: There's really no need to read the entire file at once.
1244 * See src/log.c:old_logger_list for a better approach. 1244 * See src/log.c:old_logger_list for a better approach.
1245 */ 1245 */
1246 if (!g_file_get_contents(path, &contents, &length, &error)) { 1246 if (!g_file_get_contents(path, &contents, &length, &error)) {
1250 } 1250 }
1251 g_free(path); 1251 g_free(path);
1252 1252
1253 path = g_build_filename( 1253 path = g_build_filename(
1254 logdir, prpl_name, "Query", filename, NULL); 1254 logdir, prpl_name, "Query", filename, NULL);
1255 gaim_debug(GAIM_DEBUG_INFO, "Trillian log list", 1255 purple_debug(PURPLE_DEBUG_INFO, "Trillian log list",
1256 "Reading %s\n", path); 1256 "Reading %s\n", path);
1257 if (!g_file_get_contents(path, &contents, &length, &error)) { 1257 if (!g_file_get_contents(path, &contents, &length, &error)) {
1258 if (error) 1258 if (error)
1259 g_error_free(error); 1259 g_error_free(error);
1260 } 1260 }
1275 c++; 1275 c++;
1276 continue; 1276 continue;
1277 } 1277 }
1278 1278
1279 *c = '\0'; 1279 *c = '\0';
1280 if (gaim_str_has_prefix(line, "Session Close ")) { 1280 if (purple_str_has_prefix(line, "Session Close ")) {
1281 if (data && !data->length) { 1281 if (data && !data->length) {
1282 if (!(data->length = last_line_offset - data->offset)) { 1282 if (!(data->length = last_line_offset - data->offset)) {
1283 /* This log had no data, so we remove it. */ 1283 /* This log had no data, so we remove it. */
1284 GList *last = g_list_last(list); 1284 GList *last = g_list_last(list);
1285 1285
1286 gaim_debug(GAIM_DEBUG_INFO, "Trillian log list", 1286 purple_debug(PURPLE_DEBUG_INFO, "Trillian log list",
1287 "Empty log. Offset %i\n", data->offset); 1287 "Empty log. Offset %i\n", data->offset);
1288 1288
1289 trillian_logger_finalize((GaimLog *)last->data); 1289 trillian_logger_finalize((PurpleLog *)last->data);
1290 list = g_list_delete_link(list, last); 1290 list = g_list_delete_link(list, last);
1291 } 1291 }
1292 } 1292 }
1293 } else if (line[0] && line[1] && line [3] && 1293 } else if (line[0] && line[1] && line [3] &&
1294 gaim_str_has_prefix(&line[3], "sion Start ")) { 1294 purple_str_has_prefix(&line[3], "sion Start ")) {
1295 1295
1296 char *their_nickname = line; 1296 char *their_nickname = line;
1297 char *timestamp; 1297 char *timestamp;
1298 1298
1299 if (data && !data->length) 1299 if (data && !data->length)
1339 if (sscanf(timestamp, "%u %u:%u:%u %u", 1339 if (sscanf(timestamp, "%u %u:%u:%u %u",
1340 &tm.tm_mday, &tm.tm_hour, 1340 &tm.tm_mday, &tm.tm_hour,
1341 &tm.tm_min, &tm.tm_sec, 1341 &tm.tm_min, &tm.tm_sec,
1342 &tm.tm_year) != 5) { 1342 &tm.tm_year) != 5) {
1343 1343
1344 gaim_debug(GAIM_DEBUG_ERROR, 1344 purple_debug(PURPLE_DEBUG_ERROR,
1345 "Trillian log timestamp parse", 1345 "Trillian log timestamp parse",
1346 "Session Start parsing error\n"); 1346 "Session Start parsing error\n");
1347 } else { 1347 } else {
1348 GaimLog *log; 1348 PurpleLog *log;
1349 1349
1350 tm.tm_year -= 1900; 1350 tm.tm_year -= 1900;
1351 1351
1352 /* Let the C library deal with 1352 /* Let the C library deal with
1353 * daylight savings time. 1353 * daylight savings time.
1391 data->length = 0; 1391 data->length = 0;
1392 data->their_nickname = 1392 data->their_nickname =
1393 g_strdup(their_nickname); 1393 g_strdup(their_nickname);
1394 1394
1395 /* XXX: Look into this later... Should we pass in a struct tm? */ 1395 /* XXX: Look into this later... Should we pass in a struct tm? */
1396 log = gaim_log_new(GAIM_LOG_IM, 1396 log = purple_log_new(PURPLE_LOG_IM,
1397 sn, account, NULL, mktime(&tm), NULL); 1397 sn, account, NULL, mktime(&tm), NULL);
1398 log->logger = trillian_logger; 1398 log->logger = trillian_logger;
1399 log->logger_data = data; 1399 log->logger_data = data;
1400 1400
1401 list = g_list_append(list, log); 1401 list = g_list_append(list, log);
1414 g_free(prpl_name); 1414 g_free(prpl_name);
1415 1415
1416 return list; 1416 return list;
1417 } 1417 }
1418 1418
1419 static char * trillian_logger_read (GaimLog *log, GaimLogReadFlags *flags) 1419 static char * trillian_logger_read (PurpleLog *log, PurpleLogReadFlags *flags)
1420 { 1420 {
1421 struct trillian_logger_data *data; 1421 struct trillian_logger_data *data;
1422 char *read; 1422 char *read;
1423 FILE *file; 1423 FILE *file;
1424 GaimBuddy *buddy; 1424 PurpleBuddy *buddy;
1425 char *escaped; 1425 char *escaped;
1426 GString *formatted; 1426 GString *formatted;
1427 char *c; 1427 char *c;
1428 char *line; 1428 char *line;
1429 1429
1433 1433
1434 g_return_val_if_fail(data->path != NULL, g_strdup("")); 1434 g_return_val_if_fail(data->path != NULL, g_strdup(""));
1435 g_return_val_if_fail(data->length > 0, g_strdup("")); 1435 g_return_val_if_fail(data->length > 0, g_strdup(""));
1436 g_return_val_if_fail(data->their_nickname != NULL, g_strdup("")); 1436 g_return_val_if_fail(data->their_nickname != NULL, g_strdup(""));
1437 1437
1438 gaim_debug(GAIM_DEBUG_INFO, "Trillian log read", 1438 purple_debug(PURPLE_DEBUG_INFO, "Trillian log read",
1439 "Reading %s\n", data->path); 1439 "Reading %s\n", data->path);
1440 1440
1441 read = g_malloc(data->length + 2); 1441 read = g_malloc(data->length + 2);
1442 1442
1443 file = g_fopen(data->path, "rb"); 1443 file = g_fopen(data->path, "rb");
1451 read[data->length] = '\n'; 1451 read[data->length] = '\n';
1452 read[data->length+1] = '\0'; 1452 read[data->length+1] = '\0';
1453 } 1453 }
1454 1454
1455 /* Load miscellaneous data. */ 1455 /* Load miscellaneous data. */
1456 buddy = gaim_find_buddy(log->account, log->name); 1456 buddy = purple_find_buddy(log->account, log->name);
1457 1457
1458 escaped = g_markup_escape_text(read, -1); 1458 escaped = g_markup_escape_text(read, -1);
1459 g_free(read); 1459 g_free(read);
1460 read = escaped; 1460 read = escaped;
1461 1461
1534 while (*timestamp && *timestamp != ']') 1534 while (*timestamp && *timestamp != ']')
1535 timestamp++; 1535 timestamp++;
1536 if (*timestamp == ']') { 1536 if (*timestamp == ']') {
1537 *timestamp = '\0'; 1537 *timestamp = '\0';
1538 line++; 1538 line++;
1539 /* TODO: Parse the timestamp and convert it to Gaim's format. */ 1539 /* TODO: Parse the timestamp and convert it to Purple's format. */
1540 g_string_append_printf(formatted, 1540 g_string_append_printf(formatted,
1541 "<font size=\"2\">(%s)</font> ", line); 1541 "<font size=\"2\">(%s)</font> ", line);
1542 line = timestamp; 1542 line = timestamp;
1543 if (line[1] && line[2]) 1543 if (line[1] && line[2])
1544 line += 2; 1544 line += 2;
1545 } 1545 }
1546 1546
1547 if (gaim_str_has_prefix(line, "*** ")) { 1547 if (purple_str_has_prefix(line, "*** ")) {
1548 line += (sizeof("*** ") - 1); 1548 line += (sizeof("*** ") - 1);
1549 g_string_append(formatted, "<b>"); 1549 g_string_append(formatted, "<b>");
1550 footer = "</b>"; 1550 footer = "</b>";
1551 if (gaim_str_has_prefix(line, "NOTE: This user is offline.")) { 1551 if (purple_str_has_prefix(line, "NOTE: This user is offline.")) {
1552 line = _("User is offline."); 1552 line = _("User is offline.");
1553 } else if (gaim_str_has_prefix(line, 1553 } else if (purple_str_has_prefix(line,
1554 "NOTE: Your status is currently set to ")) { 1554 "NOTE: Your status is currently set to ")) {
1555 1555
1556 line += (sizeof("NOTE: ") - 1); 1556 line += (sizeof("NOTE: ") - 1);
1557 } else if (gaim_str_has_prefix(line, "Auto-response sent to ")) { 1557 } else if (purple_str_has_prefix(line, "Auto-response sent to ")) {
1558 g_string_append(formatted, _("Auto-response sent:")); 1558 g_string_append(formatted, _("Auto-response sent:"));
1559 while (*line && *line != ':') 1559 while (*line && *line != ':')
1560 line++; 1560 line++;
1561 if (*line) 1561 if (*line)
1562 line++; 1562 line++;
1574 if (buddy != NULL && buddy->alias) 1574 if (buddy != NULL && buddy->alias)
1575 g_string_append(formatted, buddy->alias); 1575 g_string_append(formatted, buddy->alias);
1576 else 1576 else
1577 g_string_append(formatted, log->name); 1577 g_string_append(formatted, log->name);
1578 line = " logged in."; 1578 line = " logged in.";
1579 } else if (gaim_str_has_prefix(line, 1579 } else if (purple_str_has_prefix(line,
1580 "One or more messages may have been undeliverable.")) { 1580 "One or more messages may have been undeliverable.")) {
1581 1581
1582 g_string_append(formatted, 1582 g_string_append(formatted,
1583 "<span style=\"color: #ff0000;\">"); 1583 "<span style=\"color: #ff0000;\">");
1584 g_string_append(formatted, 1584 g_string_append(formatted,
1585 _("One or more messages may have been " 1585 _("One or more messages may have been "
1586 "undeliverable.")); 1586 "undeliverable."));
1587 line = ""; 1587 line = "";
1588 footer = "</span></b>"; 1588 footer = "</span></b>";
1589 } else if (gaim_str_has_prefix(line, 1589 } else if (purple_str_has_prefix(line,
1590 "You have been disconnected.")) { 1590 "You have been disconnected.")) {
1591 1591
1592 g_string_append(formatted, 1592 g_string_append(formatted,
1593 "<span style=\"color: #ff0000;\">"); 1593 "<span style=\"color: #ff0000;\">");
1594 g_string_append(formatted, 1594 g_string_append(formatted,
1595 _("You were disconnected from the server.")); 1595 _("You were disconnected from the server."));
1596 line = ""; 1596 line = "";
1597 footer = "</span></b>"; 1597 footer = "</span></b>";
1598 } else if (gaim_str_has_prefix(line, 1598 } else if (purple_str_has_prefix(line,
1599 "You are currently disconnected.")) { 1599 "You are currently disconnected.")) {
1600 1600
1601 g_string_append(formatted, 1601 g_string_append(formatted,
1602 "<span style=\"color: #ff0000;\">"); 1602 "<span style=\"color: #ff0000;\">");
1603 line = _("You are currently disconnected. Messages " 1603 line = _("You are currently disconnected. Messages "
1604 "will not be received unless you are " 1604 "will not be received unless you are "
1605 "logged in."); 1605 "logged in.");
1606 footer = "</span></b>"; 1606 footer = "</span></b>";
1607 } else if (gaim_str_has_prefix(line, 1607 } else if (purple_str_has_prefix(line,
1608 "Your previous message has not been sent.")) { 1608 "Your previous message has not been sent.")) {
1609 1609
1610 g_string_append(formatted, 1610 g_string_append(formatted,
1611 "<span style=\"color: #ff0000;\">"); 1611 "<span style=\"color: #ff0000;\">");
1612 1612
1613 if (gaim_str_has_prefix(line, 1613 if (purple_str_has_prefix(line,
1614 "Your previous message has not been sent. " 1614 "Your previous message has not been sent. "
1615 "Reason: Maximum length exceeded.")) { 1615 "Reason: Maximum length exceeded.")) {
1616 1616
1617 g_string_append(formatted, 1617 g_string_append(formatted,
1618 _("Message could not be sent because " 1618 _("Message could not be sent because "
1626 "has not been sent. ") - 1); 1626 "has not been sent. ") - 1);
1627 } 1627 }
1628 1628
1629 footer = "</span></b>"; 1629 footer = "</span></b>";
1630 } 1630 }
1631 } else if (gaim_str_has_prefix(line, data->their_nickname)) { 1631 } else if (purple_str_has_prefix(line, data->their_nickname)) {
1632 if (buddy != NULL && buddy->alias) { 1632 if (buddy != NULL && buddy->alias) {
1633 line += strlen(data->their_nickname) + 2; 1633 line += strlen(data->their_nickname) + 2;
1634 g_string_append_printf(formatted, 1634 g_string_append_printf(formatted,
1635 "<span style=\"color: #A82F2F;\">" 1635 "<span style=\"color: #A82F2F;\">"
1636 "<b>%s</b></span>: ", buddy->alias); 1636 "<b>%s</b></span>: ", buddy->alias);
1641 line2++; 1641 line2++;
1642 if (*line2 == ':') { 1642 if (*line2 == ':') {
1643 const char *acct_name; 1643 const char *acct_name;
1644 line2++; 1644 line2++;
1645 line = line2; 1645 line = line2;
1646 acct_name = gaim_account_get_alias(log->account); 1646 acct_name = purple_account_get_alias(log->account);
1647 if (!acct_name) 1647 if (!acct_name)
1648 acct_name = gaim_account_get_username(log->account); 1648 acct_name = purple_account_get_username(log->account);
1649 1649
1650 g_string_append_printf(formatted, 1650 g_string_append_printf(formatted,
1651 "<span style=\"color: #16569E;\">" 1651 "<span style=\"color: #16569E;\">"
1652 "<b>%s</b></span>:", acct_name); 1652 "<b>%s</b></span>:", acct_name);
1653 } 1653 }
1675 g_string_free(formatted, FALSE); 1675 g_string_free(formatted, FALSE);
1676 1676
1677 return read; 1677 return read;
1678 } 1678 }
1679 1679
1680 static int trillian_logger_size (GaimLog *log) 1680 static int trillian_logger_size (PurpleLog *log)
1681 { 1681 {
1682 struct trillian_logger_data *data; 1682 struct trillian_logger_data *data;
1683 char *text; 1683 char *text;
1684 size_t size; 1684 size_t size;
1685 1685
1686 g_return_val_if_fail(log != NULL, 0); 1686 g_return_val_if_fail(log != NULL, 0);
1687 1687
1688 data = log->logger_data; 1688 data = log->logger_data;
1689 1689
1690 if (gaim_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) { 1690 if (purple_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) {
1691 return data ? data->length : 0; 1691 return data ? data->length : 0;
1692 } 1692 }
1693 1693
1694 text = trillian_logger_read(log, NULL); 1694 text = trillian_logger_read(log, NULL);
1695 size = strlen(text); 1695 size = strlen(text);
1696 g_free(text); 1696 g_free(text);
1697 1697
1698 return size; 1698 return size;
1699 } 1699 }
1700 1700
1701 static void trillian_logger_finalize(GaimLog *log) 1701 static void trillian_logger_finalize(PurpleLog *log)
1702 { 1702 {
1703 struct trillian_logger_data *data; 1703 struct trillian_logger_data *data;
1704 1704
1705 g_return_if_fail(log != NULL); 1705 g_return_if_fail(log != NULL);
1706 1706
1715 /***************************************************************************** 1715 /*****************************************************************************
1716 * Plugin Code * 1716 * Plugin Code *
1717 *****************************************************************************/ 1717 *****************************************************************************/
1718 1718
1719 static void 1719 static void
1720 init_plugin(GaimPlugin *plugin) 1720 init_plugin(PurplePlugin *plugin)
1721 { 1721 {
1722 char *path; 1722 char *path;
1723 #ifdef _WIN32 1723 #ifdef _WIN32
1724 char *folder; 1724 char *folder;
1725 gboolean found = FALSE; 1725 gboolean found = FALSE;
1726 #endif 1726 #endif
1727 1727
1728 g_return_if_fail(plugin != NULL); 1728 g_return_if_fail(plugin != NULL);
1729 1729
1730 gaim_prefs_add_none("/plugins/core/log_reader"); 1730 purple_prefs_add_none("/plugins/core/log_reader");
1731 1731
1732 1732
1733 /* Add general preferences. */ 1733 /* Add general preferences. */
1734 1734
1735 gaim_prefs_add_bool("/plugins/core/log_reader/fast_sizes", FALSE); 1735 purple_prefs_add_bool("/plugins/core/log_reader/fast_sizes", FALSE);
1736 gaim_prefs_add_bool("/plugins/core/log_reader/use_name_heuristics", TRUE); 1736 purple_prefs_add_bool("/plugins/core/log_reader/use_name_heuristics", TRUE);
1737 1737
1738 1738
1739 /* Add Adium log directory preference. */ 1739 /* Add Adium log directory preference. */
1740 gaim_prefs_add_none("/plugins/core/log_reader/adium"); 1740 purple_prefs_add_none("/plugins/core/log_reader/adium");
1741 1741
1742 /* Calculate default Adium log directory. */ 1742 /* Calculate default Adium log directory. */
1743 #ifdef _WIN32 1743 #ifdef _WIN32
1744 path = ""; 1744 path = "";
1745 #else 1745 #else
1746 path = g_build_filename(gaim_home_dir(), "Library", "Application Support", 1746 path = g_build_filename(purple_home_dir(), "Library", "Application Support",
1747 "Adium 2.0", "Users", "Default", "Logs", NULL); 1747 "Adium 2.0", "Users", "Default", "Logs", NULL);
1748 #endif 1748 #endif
1749 1749
1750 gaim_prefs_add_string("/plugins/core/log_reader/adium/log_directory", path); 1750 purple_prefs_add_string("/plugins/core/log_reader/adium/log_directory", path);
1751 1751
1752 #ifndef _WIN32 1752 #ifndef _WIN32
1753 g_free(path); 1753 g_free(path);
1754 #endif 1754 #endif
1755 1755
1756 1756
1757 /* Add Fire log directory preference. */ 1757 /* Add Fire log directory preference. */
1758 gaim_prefs_add_none("/plugins/core/log_reader/fire"); 1758 purple_prefs_add_none("/plugins/core/log_reader/fire");
1759 1759
1760 /* Calculate default Fire log directory. */ 1760 /* Calculate default Fire log directory. */
1761 #ifdef _WIN32 1761 #ifdef _WIN32
1762 path = ""; 1762 path = "";
1763 #else 1763 #else
1764 path = g_build_filename(gaim_home_dir(), "Library", "Application Support", 1764 path = g_build_filename(purple_home_dir(), "Library", "Application Support",
1765 "Fire", "Sessions", NULL); 1765 "Fire", "Sessions", NULL);
1766 #endif 1766 #endif
1767 1767
1768 gaim_prefs_add_string("/plugins/core/log_reader/fire/log_directory", path); 1768 purple_prefs_add_string("/plugins/core/log_reader/fire/log_directory", path);
1769 1769
1770 #ifndef _WIN32 1770 #ifndef _WIN32
1771 g_free(path); 1771 g_free(path);
1772 #endif 1772 #endif
1773 1773
1774 1774
1775 /* Add Messenger Plus! log directory preference. */ 1775 /* Add Messenger Plus! log directory preference. */
1776 gaim_prefs_add_none("/plugins/core/log_reader/messenger_plus"); 1776 purple_prefs_add_none("/plugins/core/log_reader/messenger_plus");
1777 1777
1778 /* Calculate default Messenger Plus! log directory. */ 1778 /* Calculate default Messenger Plus! log directory. */
1779 #ifdef _WIN32 1779 #ifdef _WIN32
1780 folder = wgaim_get_special_folder(CSIDL_PERSONAL); 1780 folder = wpurple_get_special_folder(CSIDL_PERSONAL);
1781 if (folder) { 1781 if (folder) {
1782 #endif 1782 #endif
1783 path = g_build_filename( 1783 path = g_build_filename(
1784 #ifdef _WIN32 1784 #ifdef _WIN32
1785 folder, 1785 folder,
1786 #else 1786 #else
1787 GAIM_LOG_READER_WINDOWS_MOUNT_POINT, "Documents and Settings", 1787 PURPLE_LOG_READER_WINDOWS_MOUNT_POINT, "Documents and Settings",
1788 g_get_user_name(), "My Documents", 1788 g_get_user_name(), "My Documents",
1789 #endif 1789 #endif
1790 "My Chat Logs", NULL); 1790 "My Chat Logs", NULL);
1791 #ifdef _WIN32 1791 #ifdef _WIN32
1792 g_free(folder); 1792 g_free(folder);
1793 } else /* !folder */ 1793 } else /* !folder */
1794 path = g_strdup(""); 1794 path = g_strdup("");
1795 #endif 1795 #endif
1796 1796
1797 gaim_prefs_add_string("/plugins/core/log_reader/messenger_plus/log_directory", path); 1797 purple_prefs_add_string("/plugins/core/log_reader/messenger_plus/log_directory", path);
1798 g_free(path); 1798 g_free(path);
1799 1799
1800 1800
1801 /* Add MSN Messenger log directory preference. */ 1801 /* Add MSN Messenger log directory preference. */
1802 gaim_prefs_add_none("/plugins/core/log_reader/msn"); 1802 purple_prefs_add_none("/plugins/core/log_reader/msn");
1803 1803
1804 /* Calculate default MSN message history directory. */ 1804 /* Calculate default MSN message history directory. */
1805 #ifdef _WIN32 1805 #ifdef _WIN32
1806 folder = wgaim_get_special_folder(CSIDL_PERSONAL); 1806 folder = wpurple_get_special_folder(CSIDL_PERSONAL);
1807 if (folder) { 1807 if (folder) {
1808 #endif 1808 #endif
1809 path = g_build_filename( 1809 path = g_build_filename(
1810 #ifdef _WIN32 1810 #ifdef _WIN32
1811 folder, 1811 folder,
1812 #else 1812 #else
1813 GAIM_LOG_READER_WINDOWS_MOUNT_POINT, "Documents and Settings", 1813 PURPLE_LOG_READER_WINDOWS_MOUNT_POINT, "Documents and Settings",
1814 g_get_user_name(), "My Documents", 1814 g_get_user_name(), "My Documents",
1815 #endif 1815 #endif
1816 "My Received Files", NULL); 1816 "My Received Files", NULL);
1817 #ifdef _WIN32 1817 #ifdef _WIN32
1818 g_free(folder); 1818 g_free(folder);
1819 } else /* !folder */ 1819 } else /* !folder */
1820 path = g_strdup(""); 1820 path = g_strdup("");
1821 #endif 1821 #endif
1822 1822
1823 gaim_prefs_add_string("/plugins/core/log_reader/msn/log_directory", path); 1823 purple_prefs_add_string("/plugins/core/log_reader/msn/log_directory", path);
1824 g_free(path); 1824 g_free(path);
1825 1825
1826 1826
1827 /* Add Trillian log directory preference. */ 1827 /* Add Trillian log directory preference. */
1828 gaim_prefs_add_none("/plugins/core/log_reader/trillian"); 1828 purple_prefs_add_none("/plugins/core/log_reader/trillian");
1829 1829
1830 #ifdef _WIN32 1830 #ifdef _WIN32
1831 /* XXX: While a major hack, this is the most reliable way I could 1831 /* XXX: While a major hack, this is the most reliable way I could
1832 * think of to determine the Trillian installation directory. 1832 * think of to determine the Trillian installation directory.
1833 */ 1833 */
1834 1834
1835 path = NULL; 1835 path = NULL;
1836 if ((folder = wgaim_read_reg_string(HKEY_CLASSES_ROOT, "Trillian.SkinZip\\shell\\Add\\command\\", NULL))) { 1836 if ((folder = wpurple_read_reg_string(HKEY_CLASSES_ROOT, "Trillian.SkinZip\\shell\\Add\\command\\", NULL))) {
1837 char *value = folder; 1837 char *value = folder;
1838 char *temp; 1838 char *temp;
1839 1839
1840 /* Break apart buffer. */ 1840 /* Break apart buffer. */
1841 if (*value == '"') { 1841 if (*value == '"') {
1849 temp++; 1849 temp++;
1850 } 1850 }
1851 *temp = '\0'; 1851 *temp = '\0';
1852 1852
1853 /* Set path. */ 1853 /* Set path. */
1854 if (gaim_str_has_suffix(value, "trillian.exe")) { 1854 if (purple_str_has_suffix(value, "trillian.exe")) {
1855 value[strlen(value) - (sizeof("trillian.exe") - 1)] = '\0'; 1855 value[strlen(value) - (sizeof("trillian.exe") - 1)] = '\0';
1856 path = g_build_filename(value, "users", "default", "talk.ini", NULL); 1856 path = g_build_filename(value, "users", "default", "talk.ini", NULL);
1857 } 1857 }
1858 g_free(folder); 1858 g_free(folder);
1859 } 1859 }
1860 1860
1861 if (!path) { 1861 if (!path) {
1862 char *folder = wgaim_get_special_folder(CSIDL_PROGRAM_FILES); 1862 char *folder = wpurple_get_special_folder(CSIDL_PROGRAM_FILES);
1863 if (folder) { 1863 if (folder) {
1864 path = g_build_filename(folder, "Trillian", 1864 path = g_build_filename(folder, "Trillian",
1865 "users", "default", "talk.ini", NULL); 1865 "users", "default", "talk.ini", NULL);
1866 g_free(folder); 1866 g_free(folder);
1867 } 1867 }
1872 GError *error = NULL; 1872 GError *error = NULL;
1873 1873
1874 #if 0 && GLIB_CHECK_VERSION(2,6,0) /* FIXME: Not tested yet. */ 1874 #if 0 && GLIB_CHECK_VERSION(2,6,0) /* FIXME: Not tested yet. */
1875 GKeyFile *key_file; 1875 GKeyFile *key_file;
1876 1876
1877 gaim_debug(GAIM_DEBUG_INFO, "Trillian talk.ini read", 1877 purple_debug(PURPLE_DEBUG_INFO, "Trillian talk.ini read",
1878 "Reading %s\n", path); 1878 "Reading %s\n", path);
1879 if (!g_key_file_load_from_file(key_file, path, G_KEY_FILE_NONE, GError &error)) { 1879 if (!g_key_file_load_from_file(key_file, path, G_KEY_FILE_NONE, GError &error)) {
1880 gaim_debug(GAIM_DEBUG_ERROR, "Trillian talk.ini read", 1880 purple_debug(PURPLE_DEBUG_ERROR, "Trillian talk.ini read",
1881 "Error reading talk.ini\n"); 1881 "Error reading talk.ini\n");
1882 if (error) 1882 if (error)
1883 g_error_free(error); 1883 g_error_free(error);
1884 } else { 1884 } else {
1885 char *logdir = g_key_file_get_string(key_file, "Logging", "Directory", &error); 1885 char *logdir = g_key_file_get_string(key_file, "Logging", "Directory", &error);
1886 if (error) { 1886 if (error) {
1887 gaim_debug(GAIM_DEBUG_ERROR, "Trillian talk.ini read", 1887 purple_debug(PURPLE_DEBUG_ERROR, "Trillian talk.ini read",
1888 "Error reading Directory value from Logging section\n"); 1888 "Error reading Directory value from Logging section\n");
1889 g_error_free(error); 1889 g_error_free(error);
1890 } 1890 }
1891 1891
1892 if (logdir) { 1892 if (logdir) {
1893 g_strchomp(logdir); 1893 g_strchomp(logdir);
1894 gaim_prefs_add_string( 1894 purple_prefs_add_string(
1895 "/plugins/core/log_reader/trillian/log_directory", logdir); 1895 "/plugins/core/log_reader/trillian/log_directory", logdir);
1896 found = TRUE; 1896 found = TRUE;
1897 } 1897 }
1898 1898
1899 g_key_file_free(key_file); 1899 g_key_file_free(key_file);
1900 } 1900 }
1901 #else /* !GLIB_CHECK_VERSION(2,6,0) */ 1901 #else /* !GLIB_CHECK_VERSION(2,6,0) */
1902 gsize length; 1902 gsize length;
1903 gchar *contents = NULL; 1903 gchar *contents = NULL;
1904 1904
1905 gaim_debug(GAIM_DEBUG_INFO, "Trillian talk.ini read", 1905 purple_debug(PURPLE_DEBUG_INFO, "Trillian talk.ini read",
1906 "Reading %s\n", path); 1906 "Reading %s\n", path);
1907 if (!g_file_get_contents(path, &contents, &length, &error)) { 1907 if (!g_file_get_contents(path, &contents, &length, &error)) {
1908 gaim_debug(GAIM_DEBUG_ERROR, "Trillian talk.ini read", 1908 purple_debug(PURPLE_DEBUG_ERROR, "Trillian talk.ini read",
1909 "Error reading talk.ini\n"); 1909 "Error reading talk.ini\n");
1910 if (error) 1910 if (error)
1911 g_error_free(error); 1911 g_error_free(error);
1912 } else { 1912 } else {
1913 char *line = contents; 1913 char *line = contents;
1914 while (*contents) { 1914 while (*contents) {
1915 if (*contents == '\n') { 1915 if (*contents == '\n') {
1916 *contents = '\0'; 1916 *contents = '\0';
1917 1917
1918 /* XXX: This assumes the first Directory key is under [Logging]. */ 1918 /* XXX: This assumes the first Directory key is under [Logging]. */
1919 if (gaim_str_has_prefix(line, "Directory=")) { 1919 if (purple_str_has_prefix(line, "Directory=")) {
1920 line += (sizeof("Directory=") - 1); 1920 line += (sizeof("Directory=") - 1);
1921 g_strchomp(line); 1921 g_strchomp(line);
1922 gaim_prefs_add_string( 1922 purple_prefs_add_string(
1923 "/plugins/core/log_reader/trillian/log_directory", 1923 "/plugins/core/log_reader/trillian/log_directory",
1924 line); 1924 line);
1925 found = TRUE; 1925 found = TRUE;
1926 } 1926 }
1927 1927
1939 if (!found) { 1939 if (!found) {
1940 #endif /* defined(_WIN32) */ 1940 #endif /* defined(_WIN32) */
1941 1941
1942 /* Calculate default Trillian log directory. */ 1942 /* Calculate default Trillian log directory. */
1943 #ifdef _WIN32 1943 #ifdef _WIN32
1944 folder = wgaim_get_special_folder(CSIDL_PROGRAM_FILES); 1944 folder = wpurple_get_special_folder(CSIDL_PROGRAM_FILES);
1945 if (folder) { 1945 if (folder) {
1946 #endif 1946 #endif
1947 path = g_build_filename( 1947 path = g_build_filename(
1948 #ifdef _WIN32 1948 #ifdef _WIN32
1949 folder, 1949 folder,
1950 #else 1950 #else
1951 GAIM_LOG_READER_WINDOWS_MOUNT_POINT, "Program Files", 1951 PURPLE_LOG_READER_WINDOWS_MOUNT_POINT, "Program Files",
1952 #endif 1952 #endif
1953 "Trillian", "users", "default", "logs", NULL); 1953 "Trillian", "users", "default", "logs", NULL);
1954 #ifdef _WIN32 1954 #ifdef _WIN32
1955 g_free(folder); 1955 g_free(folder);
1956 } else /* !folder */ 1956 } else /* !folder */
1957 path = g_strdup(""); 1957 path = g_strdup("");
1958 #endif 1958 #endif
1959 1959
1960 gaim_prefs_add_string("/plugins/core/log_reader/trillian/log_directory", path); 1960 purple_prefs_add_string("/plugins/core/log_reader/trillian/log_directory", path);
1961 g_free(path); 1961 g_free(path);
1962 1962
1963 #ifdef _WIN32 1963 #ifdef _WIN32
1964 } /* !found */ 1964 } /* !found */
1965 #endif 1965 #endif
1966 } 1966 }
1967 1967
1968 static gboolean 1968 static gboolean
1969 plugin_load(GaimPlugin *plugin) 1969 plugin_load(PurplePlugin *plugin)
1970 { 1970 {
1971 g_return_val_if_fail(plugin != NULL, FALSE); 1971 g_return_val_if_fail(plugin != NULL, FALSE);
1972 1972
1973 /* The names of IM clients are marked for translation at the request of 1973 /* The names of IM clients are marked for translation at the request of
1974 translators who wanted to transliterate them. Many translators 1974 translators who wanted to transliterate them. Many translators
1975 choose to leave them alone. Choose what's best for your language. */ 1975 choose to leave them alone. Choose what's best for your language. */
1976 adium_logger = gaim_log_logger_new("adium", _("Adium"), 6, 1976 adium_logger = purple_log_logger_new("adium", _("Adium"), 6,
1977 NULL, 1977 NULL,
1978 NULL, 1978 NULL,
1979 adium_logger_finalize, 1979 adium_logger_finalize,
1980 adium_logger_list, 1980 adium_logger_list,
1981 adium_logger_read, 1981 adium_logger_read,
1982 adium_logger_size); 1982 adium_logger_size);
1983 gaim_log_logger_add(adium_logger); 1983 purple_log_logger_add(adium_logger);
1984 1984
1985 #if 0 1985 #if 0
1986 /* The names of IM clients are marked for translation at the request of 1986 /* The names of IM clients are marked for translation at the request of
1987 translators who wanted to transliterate them. Many translators 1987 translators who wanted to transliterate them. Many translators
1988 choose to leave them alone. Choose what's best for your language. */ 1988 choose to leave them alone. Choose what's best for your language. */
1989 fire_logger = gaim_log_logger_new("fire", _("Fire"), 6, 1989 fire_logger = purple_log_logger_new("fire", _("Fire"), 6,
1990 NULL, 1990 NULL,
1991 NULL, 1991 NULL,
1992 fire_logger_finalize, 1992 fire_logger_finalize,
1993 fire_logger_list, 1993 fire_logger_list,
1994 fire_logger_read, 1994 fire_logger_read,
1995 fire_logger_size); 1995 fire_logger_size);
1996 gaim_log_logger_add(fire_logger); 1996 purple_log_logger_add(fire_logger);
1997 1997
1998 /* The names of IM clients are marked for translation at the request of 1998 /* The names of IM clients are marked for translation at the request of
1999 translators who wanted to transliterate them. Many translators 1999 translators who wanted to transliterate them. Many translators
2000 choose to leave them alone. Choose what's best for your language. */ 2000 choose to leave them alone. Choose what's best for your language. */
2001 messenger_plus_logger = gaim_log_logger_new("messenger_plus", _("Messenger Plus!"), 6, 2001 messenger_plus_logger = purple_log_logger_new("messenger_plus", _("Messenger Plus!"), 6,
2002 NULL, 2002 NULL,
2003 NULL, 2003 NULL,
2004 messenger_plus_logger_finalize, 2004 messenger_plus_logger_finalize,
2005 messenger_plus_logger_list, 2005 messenger_plus_logger_list,
2006 messenger_plus_logger_read, 2006 messenger_plus_logger_read,
2007 messenger_plus_logger_size); 2007 messenger_plus_logger_size);
2008 gaim_log_logger_add(messenger_plus_logger); 2008 purple_log_logger_add(messenger_plus_logger);
2009 #endif 2009 #endif
2010 2010
2011 /* The names of IM clients are marked for translation at the request of 2011 /* The names of IM clients are marked for translation at the request of
2012 translators who wanted to transliterate them. Many translators 2012 translators who wanted to transliterate them. Many translators
2013 choose to leave them alone. Choose what's best for your language. */ 2013 choose to leave them alone. Choose what's best for your language. */
2014 msn_logger = gaim_log_logger_new("msn", _("MSN Messenger"), 6, 2014 msn_logger = purple_log_logger_new("msn", _("MSN Messenger"), 6,
2015 NULL, 2015 NULL,
2016 NULL, 2016 NULL,
2017 msn_logger_finalize, 2017 msn_logger_finalize,
2018 msn_logger_list, 2018 msn_logger_list,
2019 msn_logger_read, 2019 msn_logger_read,
2020 msn_logger_size); 2020 msn_logger_size);
2021 gaim_log_logger_add(msn_logger); 2021 purple_log_logger_add(msn_logger);
2022 2022
2023 /* The names of IM clients are marked for translation at the request of 2023 /* The names of IM clients are marked for translation at the request of
2024 translators who wanted to transliterate them. Many translators 2024 translators who wanted to transliterate them. Many translators
2025 choose to leave them alone. Choose what's best for your language. */ 2025 choose to leave them alone. Choose what's best for your language. */
2026 trillian_logger = gaim_log_logger_new("trillian", _("Trillian"), 6, 2026 trillian_logger = purple_log_logger_new("trillian", _("Trillian"), 6,
2027 NULL, 2027 NULL,
2028 NULL, 2028 NULL,
2029 trillian_logger_finalize, 2029 trillian_logger_finalize,
2030 trillian_logger_list, 2030 trillian_logger_list,
2031 trillian_logger_read, 2031 trillian_logger_read,
2032 trillian_logger_size); 2032 trillian_logger_size);
2033 gaim_log_logger_add(trillian_logger); 2033 purple_log_logger_add(trillian_logger);
2034 2034
2035 return TRUE; 2035 return TRUE;
2036 } 2036 }
2037 2037
2038 static gboolean 2038 static gboolean
2039 plugin_unload(GaimPlugin *plugin) 2039 plugin_unload(PurplePlugin *plugin)
2040 { 2040 {
2041 g_return_val_if_fail(plugin != NULL, FALSE); 2041 g_return_val_if_fail(plugin != NULL, FALSE);
2042 2042
2043 gaim_log_logger_remove(adium_logger); 2043 purple_log_logger_remove(adium_logger);
2044 #if 0 2044 #if 0
2045 gaim_log_logger_remove(fire_logger); 2045 purple_log_logger_remove(fire_logger);
2046 gaim_log_logger_remove(messenger_plus_logger); 2046 purple_log_logger_remove(messenger_plus_logger);
2047 #endif 2047 #endif
2048 gaim_log_logger_remove(msn_logger); 2048 purple_log_logger_remove(msn_logger);
2049 gaim_log_logger_remove(trillian_logger); 2049 purple_log_logger_remove(trillian_logger);
2050 2050
2051 return TRUE; 2051 return TRUE;
2052 } 2052 }
2053 2053
2054 static GaimPluginPrefFrame * 2054 static PurplePluginPrefFrame *
2055 get_plugin_pref_frame(GaimPlugin *plugin) 2055 get_plugin_pref_frame(PurplePlugin *plugin)
2056 { 2056 {
2057 GaimPluginPrefFrame *frame; 2057 PurplePluginPrefFrame *frame;
2058 GaimPluginPref *ppref; 2058 PurplePluginPref *ppref;
2059 2059
2060 g_return_val_if_fail(plugin != NULL, FALSE); 2060 g_return_val_if_fail(plugin != NULL, FALSE);
2061 2061
2062 frame = gaim_plugin_pref_frame_new(); 2062 frame = purple_plugin_pref_frame_new();
2063 2063
2064 2064
2065 /* Add general preferences. */ 2065 /* Add general preferences. */
2066 2066
2067 ppref = gaim_plugin_pref_new_with_label(_("General Log Reading Configuration")); 2067 ppref = purple_plugin_pref_new_with_label(_("General Log Reading Configuration"));
2068 gaim_plugin_pref_frame_add(frame, ppref); 2068 purple_plugin_pref_frame_add(frame, ppref);
2069 2069
2070 ppref = gaim_plugin_pref_new_with_name_and_label( 2070 ppref = purple_plugin_pref_new_with_name_and_label(
2071 "/plugins/core/log_reader/fast_sizes", _("Fast size calculations")); 2071 "/plugins/core/log_reader/fast_sizes", _("Fast size calculations"));
2072 gaim_plugin_pref_frame_add(frame, ppref); 2072 purple_plugin_pref_frame_add(frame, ppref);
2073 2073
2074 ppref = gaim_plugin_pref_new_with_name_and_label( 2074 ppref = purple_plugin_pref_new_with_name_and_label(
2075 "/plugins/core/log_reader/use_name_heuristics", _("Use name heuristics")); 2075 "/plugins/core/log_reader/use_name_heuristics", _("Use name heuristics"));
2076 gaim_plugin_pref_frame_add(frame, ppref); 2076 purple_plugin_pref_frame_add(frame, ppref);
2077 2077
2078 2078
2079 /* Add Log Directory preferences. */ 2079 /* Add Log Directory preferences. */
2080 2080
2081 ppref = gaim_plugin_pref_new_with_label(_("Log Directory")); 2081 ppref = purple_plugin_pref_new_with_label(_("Log Directory"));
2082 gaim_plugin_pref_frame_add(frame, ppref); 2082 purple_plugin_pref_frame_add(frame, ppref);
2083 2083
2084 ppref = gaim_plugin_pref_new_with_name_and_label( 2084 ppref = purple_plugin_pref_new_with_name_and_label(
2085 "/plugins/core/log_reader/adium/log_directory", _("Adium")); 2085 "/plugins/core/log_reader/adium/log_directory", _("Adium"));
2086 gaim_plugin_pref_frame_add(frame, ppref); 2086 purple_plugin_pref_frame_add(frame, ppref);
2087 2087
2088 #if 0 2088 #if 0
2089 ppref = gaim_plugin_pref_new_with_name_and_label( 2089 ppref = purple_plugin_pref_new_with_name_and_label(
2090 "/plugins/core/log_reader/fire/log_directory", _("Fire")); 2090 "/plugins/core/log_reader/fire/log_directory", _("Fire"));
2091 gaim_plugin_pref_frame_add(frame, ppref); 2091 purple_plugin_pref_frame_add(frame, ppref);
2092 2092
2093 ppref = gaim_plugin_pref_new_with_name_and_label( 2093 ppref = purple_plugin_pref_new_with_name_and_label(
2094 "/plugins/core/log_reader/messenger_plus/log_directory", _("Messenger Plus!")); 2094 "/plugins/core/log_reader/messenger_plus/log_directory", _("Messenger Plus!"));
2095 gaim_plugin_pref_frame_add(frame, ppref); 2095 purple_plugin_pref_frame_add(frame, ppref);
2096 #endif 2096 #endif
2097 2097
2098 ppref = gaim_plugin_pref_new_with_name_and_label( 2098 ppref = purple_plugin_pref_new_with_name_and_label(
2099 "/plugins/core/log_reader/msn/log_directory", _("MSN Messenger")); 2099 "/plugins/core/log_reader/msn/log_directory", _("MSN Messenger"));
2100 gaim_plugin_pref_frame_add(frame, ppref); 2100 purple_plugin_pref_frame_add(frame, ppref);
2101 2101
2102 ppref = gaim_plugin_pref_new_with_name_and_label( 2102 ppref = purple_plugin_pref_new_with_name_and_label(
2103 "/plugins/core/log_reader/trillian/log_directory", _("Trillian")); 2103 "/plugins/core/log_reader/trillian/log_directory", _("Trillian"));
2104 gaim_plugin_pref_frame_add(frame, ppref); 2104 purple_plugin_pref_frame_add(frame, ppref);
2105 2105
2106 return frame; 2106 return frame;
2107 } 2107 }
2108 2108
2109 static GaimPluginUiInfo prefs_info = { 2109 static PurplePluginUiInfo prefs_info = {
2110 get_plugin_pref_frame, 2110 get_plugin_pref_frame,
2111 0, /* page_num (reserved) */ 2111 0, /* page_num (reserved) */
2112 NULL /* frame (reserved) */ 2112 NULL /* frame (reserved) */
2113 }; 2113 };
2114 2114
2115 static GaimPluginInfo info = 2115 static PurplePluginInfo info =
2116 { 2116 {
2117 GAIM_PLUGIN_MAGIC, 2117 PURPLE_PLUGIN_MAGIC,
2118 GAIM_MAJOR_VERSION, 2118 PURPLE_MAJOR_VERSION,
2119 GAIM_MINOR_VERSION, 2119 PURPLE_MINOR_VERSION,
2120 GAIM_PLUGIN_STANDARD, /**< type */ 2120 PURPLE_PLUGIN_STANDARD, /**< type */
2121 NULL, /**< ui_requirement */ 2121 NULL, /**< ui_requirement */
2122 0, /**< flags */ 2122 0, /**< flags */
2123 NULL, /**< dependencies */ 2123 NULL, /**< dependencies */
2124 GAIM_PRIORITY_DEFAULT, /**< priority */ 2124 PURPLE_PRIORITY_DEFAULT, /**< priority */
2125 "core-log_reader", /**< id */ 2125 "core-log_reader", /**< id */
2126 N_("Log Reader"), /**< name */ 2126 N_("Log Reader"), /**< name */
2127 VERSION, /**< version */ 2127 VERSION, /**< version */
2128 2128
2129 /** summary */ 2129 /** summary */
2136 "includes Adium, MSN Messenger, and Trillian.\n\n" 2136 "includes Adium, MSN Messenger, and Trillian.\n\n"
2137 "WARNING: This plugin is still alpha code and " 2137 "WARNING: This plugin is still alpha code and "
2138 "may crash frequently. Use it at your own risk!"), 2138 "may crash frequently. Use it at your own risk!"),
2139 2139
2140 "Richard Laager <rlaager@pidgin.im>", /**< author */ 2140 "Richard Laager <rlaager@pidgin.im>", /**< author */
2141 GAIM_WEBSITE, /**< homepage */ 2141 PURPLE_WEBSITE, /**< homepage */
2142 plugin_load, /**< load */ 2142 plugin_load, /**< load */
2143 plugin_unload, /**< unload */ 2143 plugin_unload, /**< unload */
2144 NULL, /**< destroy */ 2144 NULL, /**< destroy */
2145 NULL, /**< ui_info */ 2145 NULL, /**< ui_info */
2146 NULL, /**< extra_info */ 2146 NULL, /**< extra_info */
2147 &prefs_info, /**< prefs_info */ 2147 &prefs_info, /**< prefs_info */
2148 NULL /**< actions */ 2148 NULL /**< actions */
2149 }; 2149 };
2150 2150
2151 GAIM_INIT_PLUGIN(log_reader, init_plugin, info) 2151 PURPLE_INIT_PLUGIN(log_reader, init_plugin, info)