annotate plugins/log_reader.c @ 13903:c5bdc567128c

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