annotate plugins/log_reader.c @ 11971:cc7146eee26f

[gaim-migrate @ 14264] I took a stab at getting Novell working. Coding stuff without being able to test it is scary. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Fri, 04 Nov 2005 07:37:10 +0000
parents 994f1c7bee8b
children ae51c59bf819
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))) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
99 if (!g_str_has_prefix(file, sn))
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
100 continue;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
101 if (g_str_has_suffix(file, ".html")) {
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);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
113 FILE *handle = fopen(filename, "rb");
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
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
159 log = gaim_log_new(GAIM_LOG_IM, sn, account, NULL, mktime(&tm));
11503
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
160 log->logger = adium_logger;
11459
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
161 log->logger_data = data;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
162
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
163 list = g_list_append(list, log);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
164 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
165 } else if (g_str_has_suffix(file, ".adiumLog")) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
166 struct tm tm;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
167 const char *date = file;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
168
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
169 date += strlen(sn) + 2;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
170 if (sscanf(date, "%u|%u|%u",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
171 &tm.tm_year, &tm.tm_mon, &tm.tm_mday) != 3) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
172
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
173 gaim_debug(GAIM_DEBUG_ERROR, "Adium log parse",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
174 "Filename timestamp parsing error\n");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
175 } else {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
176 char *filename = g_build_filename(path, file, NULL);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
177 FILE *handle = fopen(filename, "rb");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
178 char *contents;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
179 char *contents2;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
180 struct adium_logger_data *data;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
181 GaimLog *log;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
182
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
183 if (!handle) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
184 g_free(filename);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
185 continue;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
186 }
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 /* XXX: This is really inflexible. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
189 contents = g_malloc(14);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
190 fread(contents, 13, 1, handle);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
191 fclose(handle);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
192 contents[13] = '\0';
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
193
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
194 contents2 = contents;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
195 while (*contents2 && *contents2 != '(')
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
196 contents2++;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
197 if (*contents2)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
198 contents2++;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
199
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
200 if (sscanf(contents2, "%u.%u.%u",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
201 &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 3) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
202
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
203 gaim_debug(GAIM_DEBUG_ERROR, "Adium log parse",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
204 "Contents timestamp parsing error\n");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
205 g_free(contents);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
206 g_free(filename);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
207 continue;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
208 }
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 g_free(contents);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
211
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
212 tm.tm_year -= 1900;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
213 tm.tm_mon -= 1;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
214
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
215 data = g_new0(struct adium_logger_data, 1);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
216 data->path = filename;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
217 data->type = ADIUM_TEXT;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
218
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
219 log = gaim_log_new(GAIM_LOG_IM, sn, account, NULL, mktime(&tm));
11503
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
220 log->logger = adium_logger;
11459
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
221 log->logger_data = data;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
222
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
223 list = g_list_append(list, log);
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 }
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 g_dir_close(dir);
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
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
230 g_free(prpl_name);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
231 g_free(path);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
232
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
233 return list;
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
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
236 static char *adium_logger_read (GaimLog *log, GaimLogReadFlags *flags)
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 struct adium_logger_data *data;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
239 GError *error = NULL;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
240 gchar *read = NULL;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
241 gsize length;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
242
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
243 g_return_val_if_fail(log != NULL, g_strdup(""));
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 data = log->logger_data;
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 g_return_val_if_fail(data->path != NULL, g_strdup(""));
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 gaim_debug(GAIM_DEBUG_INFO, "Adium log read",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
250 "Reading %s\n", data->path);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
251 if (!g_file_get_contents(data->path, &read, &length, &error)) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
252 gaim_debug(GAIM_DEBUG_ERROR, "Adium log read",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
253 "Error reading log\n");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
254 if (error)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
255 g_error_free(error);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
256 return g_strdup("");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
257 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
258
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
259 if (data->type != ADIUM_HTML) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
260 char *escaped = g_markup_escape_text(read, -1);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
261 g_free(read);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
262 read = escaped;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
263 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
264
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
265 #ifdef WIN32
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
266 /* This problem only seems to show up on Windows.
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
267 * 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
268 */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
269 if (g_str_has_prefix(read, "\xef\xbb\xbf"))
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
270 {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
271 /* FIXME: This feels so wrong... */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
272 char *temp = g_strdup(&(read[3]));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
273 g_free(read);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
274 read = temp;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
275 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
276 #endif
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 /* TODO: Apply formatting.
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
279 * Replace the above hack with something better, since we'll
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
280 * be looping over the entire log file contents anyway.
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
281 */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
282
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
283 return read;
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
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
286 static int adium_logger_size (GaimLog *log)
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 struct adium_logger_data *data;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
289 char *text;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
290 size_t size;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
291
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
292 g_return_val_if_fail(log != NULL, 0);
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 data = log->logger_data;
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 if (gaim_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
297 struct stat st;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
298
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
299 if (!data->path || stat(data->path, &st))
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
300 st.st_size = 0;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
301
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
302 return st.st_size;
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
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
305 text = adium_logger_read(log, NULL);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
306 size = strlen(text);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
307 g_free(text);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
308
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
309 return size;
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
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
312 static void adium_logger_finalize(GaimLog *log)
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 struct adium_logger_data *data;
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 g_return_if_fail(log != NULL);
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 data = log->logger_data;
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 g_free(data->path);
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
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 * Fire Logger *
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
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
328 /* 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
329 * Fire logs in the log viewer transparently.
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
330 */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
331
11503
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
332 static GaimLogLogger *fire_logger;
11459
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
333
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
334 struct fire_logger_data {
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
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
337 static GList *fire_logger_list(GaimLogType type, const char *sn, GaimAccount *account)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
338 {
11503
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
339 /* TODO: Do something here. */
11459
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
340 return NULL;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
341 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
342
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
343 static char * fire_logger_read (GaimLog *log, GaimLogReadFlags *flags)
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 struct fire_logger_data *data;
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 g_return_val_if_fail(log != NULL, g_strdup(""));
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 data = log->logger_data;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
350
11503
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
351 /* TODO: Do something here. */
11459
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
352 return g_strdup("");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
353 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
354
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
355 static int fire_logger_size (GaimLog *log)
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 g_return_val_if_fail(log != NULL, 0);
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 if (gaim_prefs_get_bool("/plugins/core/log_reader/fast_sizes"))
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
360 return 0;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
361
11503
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
362 /* TODO: Do something here. */
11459
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
363 return 0;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
364 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
365
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
366 static void fire_logger_finalize(GaimLog *log)
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 g_return_if_fail(log != NULL);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
369
11503
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
370 /* TODO: Do something here. */
11459
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
371 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
372
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 * Messenger Plus! Logger *
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
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
378 /* 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
379 * Messenger Plus! logs in the log viewer transparently.
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
380 */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
381
11503
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
382 static GaimLogLogger *messenger_plus_logger;
11459
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
383
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
384 struct messenger_plus_logger_data {
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
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
387 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
388 {
11503
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
389 /* TODO: Do something here. */
11459
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
390 return NULL;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
391 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
392
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
393 static char * messenger_plus_logger_read (GaimLog *log, GaimLogReadFlags *flags)
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 struct messenger_plus_logger_data *data = log->logger_data;
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 g_return_val_if_fail(log != NULL, g_strdup(""));
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 data = log->logger_data;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
400
11503
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
401 /* TODO: Do something here. */
11459
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
402 return g_strdup("");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
403 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
404
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
405 static int messenger_plus_logger_size (GaimLog *log)
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 g_return_val_if_fail(log != NULL, 0);
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 if (gaim_prefs_get_bool("/plugins/core/log_reader/fast_sizes"))
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
410 return 0;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
411
11503
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
412 /* TODO: Do something here. */
11459
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
413 return 0;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
414 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
415
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
416 static void messenger_plus_logger_finalize(GaimLog *log)
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 g_return_if_fail(log != NULL);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
419
11503
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
420 /* TODO: Do something here. */
11459
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
421 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
422
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 * MSN Messenger Logger *
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
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
428 /* 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
429 * MSN Messenger message histories in the log viewer transparently.
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
430 */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
431
11503
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
432 static GaimLogLogger *msn_logger;
11459
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
433
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
434 struct msn_logger_data {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
435 xmlnode *root;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
436 xmlnode *message;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
437 const char *session_id;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
438 int last_log;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
439 GString *text;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
440 };
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
441
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
442 static time_t msn_logger_parse_timestamp(xmlnode *message)
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 const char *date;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
445 const char *time;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
446 struct tm tm;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
447 char am_pm;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
448
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
449 g_return_val_if_fail(message != NULL, (time_t)0);
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 date = xmlnode_get_attrib(message, "Date");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
452 if (!(date && *date)) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
453 gaim_debug(GAIM_DEBUG_ERROR, "MSN log timestamp parse",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
454 "Attribute missing: %s\n", "Date");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
455 return (time_t)0;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
456 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
457
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
458 time = xmlnode_get_attrib(message, "Time");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
459 if (!(time && *time)) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
460 gaim_debug(GAIM_DEBUG_ERROR, "MSN log timestamp parse",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
461 "Attribute missing: %s\n", "Time");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
462 return (time_t)0;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
463 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
464
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
465 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
466 gaim_debug(GAIM_DEBUG_ERROR, "MSN log timestamp parse",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
467 "%s parsing error\n", "Date");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
468
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
469 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
470 gaim_debug(GAIM_DEBUG_ERROR, "MSN log timestamp parse",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
471 "%s parsing error\n", "Time");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
472
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
473 tm.tm_year -= 1900;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
474 tm.tm_mon -= 1;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
475 if (am_pm == 'P') {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
476 tm.tm_hour += 12;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
477 } else if (tm.tm_hour == 12) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
478 /* 12 AM = 00 hr */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
479 tm.tm_hour = 0;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
480 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
481 /* Let the C library deal with daylight savings time. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
482 tm.tm_isdst = -1;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
483
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
484 return mktime(&tm);
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
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 static GList *msn_logger_list(GaimLogType type, const char *sn, GaimAccount *account)
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 GList *list = NULL;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
491 char *username;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
492 GaimBuddy *buddy;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
493 const char *logdir;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
494 const char *savedfilename = NULL;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
495 char *logfile;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
496 char *path;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
497 GError *error = NULL;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
498 gchar *contents = NULL;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
499 gsize length;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
500 xmlnode *root;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
501 xmlnode *message;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
502 const char *old_session_id = "";
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
503 struct msn_logger_data *data = NULL;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
504
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
505 g_return_val_if_fail(sn != NULL, list);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
506 g_return_val_if_fail(account != NULL, list);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
507
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
508 if (strcmp(account->protocol_id, "prpl-msn"))
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
509 return list;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
510
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
511 logdir = gaim_prefs_get_string("/plugins/core/log_reader/msn/log_directory");
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 /* By clearing the log directory path, this logger can be (effectively) disabled. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
514 if (!*logdir)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
515 return list;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
516
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
517 buddy = gaim_find_buddy(account, sn);
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 if ((username = g_strdup(gaim_account_get_string(
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
520 account, "log_reader_msn_log_folder", NULL)))) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
521 /* 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
522 * straight away. This would allow the user to deal with the case
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
523 * when two account have the same username at different domains and
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
524 * only one has logs stored.
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
525 */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
526 if (!*username) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
527 g_free(username);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
528 return list;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
529 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
530 } else {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
531 username = g_strdup(gaim_normalize(account, account->username));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
532 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
533
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
534 if (buddy)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
535 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
536
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
537 if (savedfilename) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
538 /* 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
539 * straight away. This would allow the user to deal with the case
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
540 * when two buddies have the same username at different domains and
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
541 * only one has logs stored.
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
542 */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
543 if (!*savedfilename) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
544 g_free(username);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
545 return list;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
546 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
547
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
548 logfile = g_strdup(savedfilename);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
549 } else {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
550 logfile = g_strdup_printf("%s.xml", gaim_normalize(account, sn));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
551 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
552
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
553 path = g_build_filename(logdir, username, "History", logfile, NULL);
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 if (!g_file_test(path, G_FILE_TEST_EXISTS)) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
556 gboolean found = FALSE;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
557 char *at_sign;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
558 GDir *dir;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
559
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
560 g_free(path);
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 if (savedfilename) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
563 /* We had a saved filename, but it doesn't exist.
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
564 * Returning now is the right course of action because we don't
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
565 * want to detect another file incorrectly.
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
566 */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
567 g_free(username);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
568 g_free(logfile);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
569 return list;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
570 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
571
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
572 /* 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
573 * 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
574 * find logs by pattern matching...
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
575 */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
576
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
577 at_sign = g_strrstr(username, "@");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
578 if (at_sign)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
579 *at_sign = '\0';
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
580
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
581 dir = g_dir_open(logdir, 0, NULL);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
582 if (dir) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
583 const gchar *name;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
584
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
585 while ((name = g_dir_read_name(dir))) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
586 const char *c = name;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
587
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
588 if (!g_str_has_prefix(c, username))
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
589 continue;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
590
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
591 c += strlen(username);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
592 while (*c) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
593 if (!g_ascii_isdigit(*c))
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
594 break;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
595
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
596 c++;
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
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
599 path = g_build_filename(logdir, name, NULL);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
600 /* 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
601 if (!*c && g_file_test(path, G_FILE_TEST_IS_DIR)) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
602 char *history_path = g_build_filename(
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
603 path, "History", NULL);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
604 if (g_file_test(history_path, G_FILE_TEST_IS_DIR)) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
605 gaim_account_set_string(account,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
606 "log_reader_msn_log_folder", name);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
607 g_free(path);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
608 path = history_path;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
609 found = TRUE;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
610 break;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
611 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
612 g_free(path);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
613 g_free(history_path);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
614 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
615 else
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
616 g_free(path);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
617 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
618 g_dir_close(dir);
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_free(username);
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 if (!found) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
623 g_free(logfile);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
624 return list;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
625 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
626
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
627 /* If we've reached this point, we've found a History folder. */
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 username = g_strdup(gaim_normalize(account, sn));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
630 at_sign = g_strrstr(username, "@");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
631 if (at_sign)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
632 *at_sign = '\0';
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
633
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
634 found = FALSE;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
635 dir = g_dir_open(path, 0, NULL);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
636 if (dir) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
637 const gchar *name;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
638
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
639 while ((name = g_dir_read_name(dir))) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
640 const char *c = name;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
641
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
642 if (!g_str_has_prefix(c, username))
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
643 continue;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
644
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
645 c += strlen(username);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
646 while (*c) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
647 if (!g_ascii_isdigit(*c))
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
648 break;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
649
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
650 c++;
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
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
653 path = g_build_filename(path, name, NULL);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
654 if (!strcmp(c, ".xml") &&
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
655 g_file_test(path, G_FILE_TEST_EXISTS)) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
656 found = TRUE;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
657 g_free(logfile);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
658 logfile = g_strdup(name);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
659 break;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
660 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
661 else
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
662 g_free(path);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
663 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
664 g_dir_close(dir);
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_free(username);
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 if (!found) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
669 g_free(logfile);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
670 return list;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
671 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
672 } else {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
673 g_free(username);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
674 g_free(logfile);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
675 logfile = NULL; /* No sense saving the obvious buddy@domain.com. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
676 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
677
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
678 gaim_debug(GAIM_DEBUG_INFO, "MSN log read",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
679 "Reading %s\n", path);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
680 if (!g_file_get_contents(path, &contents, &length, &error)) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
681 g_free(path);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
682 gaim_debug(GAIM_DEBUG_ERROR, "MSN log read",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
683 "Error reading log\n");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
684 if (error)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
685 g_error_free(error);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
686 return list;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
687 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
688 g_free(path);
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 /* Reading the file was successful...
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
691 * 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
692 * 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
693 * 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
694 * detected for both buddies.
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
695 *
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
696 * I can't think of how buddy would be NULL.
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
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
733 log = gaim_log_new(GAIM_LOG_IM, sn, account, NULL, msn_logger_parse_timestamp(message));
11503
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
734 log->logger = msn_logger;
11459
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
735 log->logger_data = data;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
736
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
737 list = g_list_append(list, log);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
738 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
739 old_session_id = session_id;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
740 }
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 if (data)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
743 data->last_log = TRUE;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
744
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
745 return list;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
746 }
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 static char * msn_logger_read (GaimLog *log, GaimLogReadFlags *flags)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
749 {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
750 struct msn_logger_data *data;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
751 GString *text = NULL;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
752 xmlnode *message;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
753
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
754 g_return_val_if_fail(log != NULL, g_strdup(""));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
755
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
756 data = log->logger_data;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
757
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
758 if (data->text) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
759 /* The GTK code which displays the logs g_free()s whatever is
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
760 * returned from this function. Thus, we can't reuse the str
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
761 * part of the GString. The only solution is to free it and
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
762 * start over.
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
763 */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
764 g_string_free(data->text, FALSE);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
765 }
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 text = g_string_new("");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
768
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
769 if (!data->root || !data->message || !data->session_id) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
770 /* Something isn't allocated correctly. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
771 gaim_debug(GAIM_DEBUG_ERROR, "MSN log parse",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
772 "Error parsing message: %s\n", "Internal variables inconsistent");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
773 data->text = text;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
774
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
775 return text->str;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
776 }
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 for (message = data->message; message;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
779 message = xmlnode_get_next_twin(message)) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
780
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
781 const char *new_session_id;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
782 xmlnode *text_node;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
783 const char *from_name = NULL;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
784 const char *to_name = NULL;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
785 xmlnode *from;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
786 xmlnode *to;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
787 enum name_guesses name_guessed = NAME_GUESS_UNKNOWN;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
788 const char *their_name;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
789 time_t time_unix;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
790 struct tm *tm_new;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
791 char *timestamp;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
792 const char *style;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
793
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
794 new_session_id = xmlnode_get_attrib(message, "SessionID");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
795
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
796 /* If this triggers, something is wrong with the XML. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
797 if (!new_session_id) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
798 gaim_debug(GAIM_DEBUG_ERROR, "MSN log parse",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
799 "Error parsing message: %s\n", "New SessionID missing");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
800 break;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
801 }
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 if (strcmp(new_session_id, data->session_id)) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
804 /* The session ID differs from the first message.
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
805 * Thus, this is the start of a new conversation.
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
806 */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
807 break;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
808 }
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 text_node = xmlnode_get_child(message, "Text");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
811 if (!text_node)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
812 continue;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
813
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
814 from = xmlnode_get_child(message, "From");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
815 if (from) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
816 xmlnode *user = xmlnode_get_child(from, "User");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
817
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
818 if (user) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
819 from_name = xmlnode_get_attrib(user, "FriendlyName");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
820
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
821 /* This saves a check later. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
822 if (!*from_name)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
823 from_name = NULL;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
824 }
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 to = xmlnode_get_child(message, "To");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
828 if (to) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
829 xmlnode *user = xmlnode_get_child(to, "User");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
830 if (user) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
831 to_name = xmlnode_get_attrib(user, "FriendlyName");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
832
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
833 /* This saves a check later. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
834 if (!*to_name)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
835 to_name = NULL;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
836 }
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 their_name = from_name;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
840 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
841 const char *friendly_name = gaim_connection_get_display_name(log->account->gc);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
842
11702
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
843 if (friendly_name != NULL) {
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
844 int friendly_name_length = strlen(friendly_name);
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
845 int alias_length = strlen(log->account->alias);
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
846 GaimBuddy *buddy = gaim_find_buddy(log->account, log->name);
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
847 gboolean from_name_matches;
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
848 gboolean to_name_matches;
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
849
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
850 if (buddy && buddy->alias)
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
851 their_name = buddy->alias;
11459
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
852
11702
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
853 /* Try to guess which user is me.
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
854 * 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
855 * friendly name or alias. For this test, "match" is defined as:
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
856 * ^(friendly_name|alias)([^a-zA-Z0-9].*)?$
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
857 */
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
858 from_name_matches = ((g_str_has_prefix(
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
859 from_name, friendly_name) &&
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
860 !isalnum(*(from_name + friendly_name_length))) ||
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
861 (g_str_has_prefix(from_name, log->account->alias) &&
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
862 !isalnum(*(from_name + alias_length))));
11459
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
863
11702
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
864 to_name_matches = ((g_str_has_prefix(
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
865 to_name, friendly_name) &&
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
866 !isalnum(*(to_name + friendly_name_length))) ||
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
867 (g_str_has_prefix(to_name, log->account->alias) &&
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
868 !isalnum(*(to_name + alias_length))));
11459
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
869
11702
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
870 if (from_name_matches) {
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
871 if (!to_name_matches) {
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
872 name_guessed = NAME_GUESS_ME;
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
873 }
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
874 } else if (to_name_matches) {
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
875 name_guessed = NAME_GUESS_THEM;
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
876 } else {
994f1c7bee8b [gaim-migrate @ 13993]
Richard Laager <rlaager@wiktel.com>
parents: 11503
diff changeset
877 if (buddy && buddy->alias) {
11459
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
878 char *alias = g_strdup(buddy->alias);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
879
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
880 /* "Truncate" the string at the first non-alphanumeric
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
881 * character. The idea is to relax the comparison.
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
882 */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
883 char *temp;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
884 for (temp = alias; *temp ; temp++) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
885 if (!isalnum(*temp)) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
886 *temp = '\0';
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
887 break;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
888 }
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 alias_length = strlen(alias);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
891
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
892 /* Try to guess which user is them.
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
893 * The first step is to determine if either of the names
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
894 * matches their alias. For this test, "match" is
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
895 * defined as: ^alias([^a-zA-Z0-9].*)?$
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
896 */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
897 from_name_matches = (g_str_has_prefix(
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
898 from_name, alias) &&
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
899 !isalnum(*(from_name +
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
900 alias_length)));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
901
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
902 to_name_matches = (g_str_has_prefix(
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
903 to_name, alias) &&
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
904 !isalnum(*(to_name +
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
905 alias_length)));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
906
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
907 g_free(alias);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
908
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
909 if (from_name_matches) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
910 if (!to_name_matches) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
911 name_guessed = NAME_GUESS_THEM;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
912 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
913 } else if (to_name_matches) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
914 name_guessed = NAME_GUESS_ME;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
915 } else if (buddy->server_alias) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
916 friendly_name_length =
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
917 strlen(buddy->server_alias);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
918
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
919 /* Try to guess which user is them.
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
920 * The first step is to determine if either of
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
921 * the names matches their friendly name. For
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
922 * this test, "match" is defined as:
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
923 * ^friendly_name([^a-zA-Z0-9].*)?$
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
924 */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
925 from_name_matches = (g_str_has_prefix(
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
926 from_name,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
927 buddy->server_alias) &&
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
928 !isalnum(*(from_name +
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
929 friendly_name_length)));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
930
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
931 to_name_matches = (g_str_has_prefix(
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
932 to_name, buddy->server_alias) &&
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
933 !isalnum(*(to_name +
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
934 friendly_name_length)));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
935
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
936 if (from_name_matches) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
937 if (!to_name_matches) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
938 name_guessed = NAME_GUESS_THEM;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
939 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
940 } else if (to_name_matches) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
941 name_guessed = NAME_GUESS_ME;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
942 }
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 if (name_guessed != NAME_GUESS_UNKNOWN) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
950 text = g_string_append(text, "<span style=\"color: #");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
951 if (name_guessed == NAME_GUESS_ME)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
952 text = g_string_append(text, "16569E");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
953 else
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
954 text = g_string_append(text, "A82F2F");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
955 text = g_string_append(text, ";\">");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
956 }
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 time_unix = msn_logger_parse_timestamp(message);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
959 tm_new = localtime(&time_unix);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
960
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
961 timestamp = g_strdup_printf("<font size=\"2\">(%02u:%02u:%02u)</font> ",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
962 tm_new->tm_hour, tm_new->tm_min, tm_new->tm_sec);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
963 text = g_string_append(text, timestamp);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
964 g_free(timestamp);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
965
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
966 if (from_name) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
967 text = g_string_append(text, "<b>");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
968
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
969 if (name_guessed == NAME_GUESS_ME)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
970 text = g_string_append(text, log->account->alias);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
971 else if (name_guessed == NAME_GUESS_THEM)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
972 text = g_string_append(text, their_name);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
973 else
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
974 text = g_string_append(text, from_name);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
975
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
976 text = g_string_append(text, ":</b> ");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
977 }
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 if (name_guessed != NAME_GUESS_UNKNOWN)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
980 text = g_string_append(text, "</span>");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
981
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
982 style = xmlnode_get_attrib(text_node, "Style");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
983
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
984 if (style && *style) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
985 text = g_string_append(text, "<span style=\"");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
986 text = g_string_append(text, style);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
987 text = g_string_append(text, "\">");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
988 text = g_string_append(text, xmlnode_get_data(text_node));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
989 text = g_string_append(text, "</span>\n");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
990 } else {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
991 text = g_string_append(text, xmlnode_get_data(text_node));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
992 text = g_string_append(text, "\n");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
993 }
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 data->text = text;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
997
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
998 return text->str;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
999 }
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 static int msn_logger_size (GaimLog *log)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1002 {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1003 char *text;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1004 size_t size;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1005
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1006 g_return_val_if_fail(log != NULL, 0);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1007
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1008 if (gaim_prefs_get_bool("/plugins/core/log_reader/fast_sizes"))
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1009 return 0;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1010
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1011 text = msn_logger_read(log, NULL);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1012 size = strlen(text);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1013 g_free(text);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1014
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1015 return size;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1016 }
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 static void msn_logger_finalize(GaimLog *log)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1019 {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1020 struct msn_logger_data *data;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1021
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1022 g_return_if_fail(log != NULL);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1023
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1024 data = log->logger_data;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1025
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1026 if (data->last_log)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1027 xmlnode_free(data->root);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1028
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1029 if (data->text)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1030 g_string_free(data->text, FALSE);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1031 }
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 * Trillian Logger *
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1036 *****************************************************************************/
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 /* 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
1039 * Trillian logs in the log viewer transparently.
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1040 */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1041
11503
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1042 static GaimLogLogger *trillian_logger;
11459
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1043 static void trillian_logger_finalize(GaimLog *log);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1044
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1045 struct trillian_logger_data {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1046 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
1047 int offset;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1048 int length;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1049 char *their_nickname;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1050 };
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 static GList *trillian_logger_list(GaimLogType type, const char *sn, GaimAccount *account)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1053 {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1054 GList *list = NULL;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1055 const char *logdir;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1056 GaimPlugin *plugin;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1057 GaimPluginProtocolInfo *prpl_info;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1058 char *prpl_name;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1059 const char *buddy_name;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1060 char *filename;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1061 char *path;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1062 GError *error = NULL;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1063 gchar *contents = NULL;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1064 gsize length;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1065 gchar *line;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1066 gchar *c;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1067
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1068 g_return_val_if_fail(sn != NULL, list);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1069 g_return_val_if_fail(account != NULL, list);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1070
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1071 logdir = gaim_prefs_get_string("/plugins/core/log_reader/trillian/log_directory");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1072
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1073 /* By clearing the log directory path, this logger can be (effectively) disabled. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1074 if (!*logdir)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1075 return list;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1076
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1077 plugin = gaim_find_prpl(gaim_account_get_protocol_id(account));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1078 if (!plugin)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1079 return NULL;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1080
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1081 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(plugin);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1082 if (!prpl_info->list_icon)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1083 return NULL;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1084
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1085 prpl_name = g_ascii_strup(prpl_info->list_icon(account, NULL), -1);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1086
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1087 buddy_name = gaim_normalize(account, sn);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1088
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1089 filename = g_strdup_printf("%s.log", buddy_name);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1090 path = g_build_filename(
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1091 logdir, prpl_name, filename, NULL);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1092
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1093 gaim_debug(GAIM_DEBUG_INFO, "Trillian log list",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1094 "Reading %s\n", path);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1095 /* 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
1096 * See src/log.c:old_logger_list for a better approach.
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1097 */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1098 if (!g_file_get_contents(path, &contents, &length, &error)) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1099 if (error) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1100 g_error_free(error);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1101 error = NULL;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1102 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1103 g_free(path);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1104
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1105 path = g_build_filename(
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1106 logdir, prpl_name, "Query", filename, NULL);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1107 gaim_debug(GAIM_DEBUG_INFO, "Trillian log list",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1108 "Reading %s\n", path);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1109 if (!g_file_get_contents(path, &contents, &length, &error)) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1110 if (error)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1111 g_error_free(error);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1112 }
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 g_free(filename);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1115
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1116 if (contents) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1117 struct trillian_logger_data *data = NULL;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1118 int offset = 0;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1119 int last_line_offset = 0;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1120
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1121 line = contents;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1122 c = contents;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1123 while (*c) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1124 offset++;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1125
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1126 if (*c != '\n') {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1127 c++;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1128 continue;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1129 }
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 *c = '\0';
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1132 if (g_str_has_prefix(line, "Session Close ")) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1133 if (data && !data->length)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1134 data->length = last_line_offset - data->offset;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1135 if (!data->length) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1136 /* This log had no data, so we remove it. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1137 GList *last = g_list_last(list);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1138
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1139 gaim_debug(GAIM_DEBUG_INFO, "Trillian log list",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1140 "Empty log. Offset %i\n", data->offset);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1141
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1142 trillian_logger_finalize((GaimLog *)last->data);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1143 list = g_list_delete_link(list, last);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1144 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1145 } else if (line[0] && line[1] && line [3] &&
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1146 g_str_has_prefix(&line[3], "sion Start ")) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1147
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1148 char *their_nickname = line;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1149 char *timestamp;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1150
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1151 if (data && !data->length)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1152 data->length = last_line_offset - data->offset;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1153
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1154 while (*their_nickname && (*their_nickname != ':'))
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1155 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
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1158 /* This code actually has nothing to do with
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1159 * the timestamp YET. I'm simply using this
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1160 * variable for now to NUL-terminate the
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1161 * their_nickname string.
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1162 */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1163 timestamp = their_nickname;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1164 while (*timestamp && *timestamp != ')')
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1165 timestamp++;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1166
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1167 if (*timestamp == ')') {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1168 char *month;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1169 struct tm tm;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1170
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1171 *timestamp = '\0';
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1172 if (line[0] && line[1] && line[2])
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1173 timestamp += 3;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1174
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1175 /* Now we start dealing with the timestamp. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1176
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1177 /* Skip over the day name. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1178 while (*timestamp && (*timestamp != ' '))
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1179 timestamp++;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1180 *timestamp = '\0';
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1181 timestamp++;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1182
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1183 /* Parse out the month. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1184 month = timestamp;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1185 while (*timestamp && (*timestamp != ' '))
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1186 timestamp++;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1187 *timestamp = '\0';
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1188 timestamp++;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1189
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1190 /* Parse the day, time, and year. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1191 if (sscanf(timestamp, "%u %u:%u:%u %u",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1192 &tm.tm_mday, &tm.tm_hour,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1193 &tm.tm_min, &tm.tm_sec,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1194 &tm.tm_year) != 5) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1195
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1196 gaim_debug(GAIM_DEBUG_ERROR,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1197 "Trillian log timestamp parse",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1198 "Session Start parsing error\n");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1199 } else {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1200 GaimLog *log;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1201
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1202 tm.tm_year -= 1900;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1203
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1204 /* Let the C library deal with
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1205 * daylight savings time.
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1206 */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1207 tm.tm_isdst = -1;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1208
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1209 /* Ugly hack, in case current locale
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1210 * is not English. This code is taken
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1211 * from log.c.
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1212 */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1213 if (strcmp(month, "Jan") == 0) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1214 tm.tm_mon= 0;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1215 } else if (strcmp(month, "Feb") == 0) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1216 tm.tm_mon = 1;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1217 } else if (strcmp(month, "Mar") == 0) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1218 tm.tm_mon = 2;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1219 } else if (strcmp(month, "Apr") == 0) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1220 tm.tm_mon = 3;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1221 } else if (strcmp(month, "May") == 0) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1222 tm.tm_mon = 4;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1223 } else if (strcmp(month, "Jun") == 0) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1224 tm.tm_mon = 5;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1225 } else if (strcmp(month, "Jul") == 0) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1226 tm.tm_mon = 6;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1227 } else if (strcmp(month, "Aug") == 0) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1228 tm.tm_mon = 7;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1229 } else if (strcmp(month, "Sep") == 0) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1230 tm.tm_mon = 8;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1231 } else if (strcmp(month, "Oct") == 0) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1232 tm.tm_mon = 9;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1233 } else if (strcmp(month, "Nov") == 0) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1234 tm.tm_mon = 10;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1235 } else if (strcmp(month, "Dec") == 0) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1236 tm.tm_mon = 11;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1237 }
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 data = g_new0(
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1240 struct trillian_logger_data, 1);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1241 data->path = g_strdup(path);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1242 data->offset = offset;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1243 data->length = 0;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1244 data->their_nickname =
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1245 g_strdup(their_nickname);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1246
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1247 log = gaim_log_new(GAIM_LOG_IM,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1248 sn, account, NULL, mktime(&tm));
11503
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1249 log->logger = trillian_logger;
11459
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1250 log->logger_data = data;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1251
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1252 list = g_list_append(list, log);
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 }
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 c++;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1257 line = c;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1258 last_line_offset = offset;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1259 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1260
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1261 g_free(contents);
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(path);
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(prpl_name);
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 return list;
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
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1270 static char * trillian_logger_read (GaimLog *log, GaimLogReadFlags *flags)
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 struct trillian_logger_data *data;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1273 char *read;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1274 FILE *file;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1275 GaimBuddy *buddy;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1276 char *escaped;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1277 GString *formatted;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1278 char *c;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1279 char *line;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1280
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1281 g_return_val_if_fail(log != NULL, g_strdup(""));
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 data = log->logger_data;
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 g_return_val_if_fail(data->path != NULL, g_strdup(""));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1286 g_return_val_if_fail(data->length > 0, g_strdup(""));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1287 g_return_val_if_fail(data->their_nickname != NULL, g_strdup(""));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1288
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1289 gaim_debug(GAIM_DEBUG_INFO, "Trillian log read",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1290 "Reading %s\n", data->path);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1291
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1292 read = g_malloc(data->length + 2);
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 file = fopen(data->path, "rb");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1295 fseek(file, data->offset, SEEK_SET);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1296 fread(read, data->length, 1, file);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1297 fclose(file);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1298
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1299 if (read[data->length-1] == '\n') {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1300 read[data->length] = '\0';
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1301 } else {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1302 read[data->length] = '\n';
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1303 read[data->length+1] = '\0';
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1304 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1305
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1306 /* Load miscellaneous data. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1307 buddy = gaim_find_buddy(log->account, log->name);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1308
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1309 escaped = g_markup_escape_text(read, -1);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1310 g_free(read);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1311 read = escaped;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1312
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1313 /* Apply formatting... */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1314 formatted = g_string_new("");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1315 c = read;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1316 line = read;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1317 while (*c)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1318 {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1319 if (*c == '\n')
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 char *link_temp_line;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1322 char *link;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1323 char *timestamp;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1324 char *footer = NULL;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1325 *c = '\0';
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1326
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1327 /* Convert links.
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 * The format is (Link: URL)URL
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1330 * 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
1331 * <a href="
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1332 * Then, replace the next ")" with:
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1333 * ">
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1334 * 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
1335 * </a>
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1336 */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1337 link_temp_line = NULL;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1338 while ((link = g_strstr_len(line, strlen(line), "(Link: "))) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1339 GString *temp;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1340
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1341 if (!*link)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1342 continue;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1343
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1344 *link = '\0';
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1345 link++;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1346
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1347 temp = g_string_new(line);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1348 g_string_append(temp, "<a href=\"");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1349
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1350 if (strlen(link) >= 6) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1351 link += (sizeof("(Link: ") - 1);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1352
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1353 while (*link && *link != ')') {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1354 g_string_append_c(temp, *link);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1355 link++;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1356 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1357 if (link) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1358 link++;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1359
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1360 g_string_append(temp, "\">");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1361 while (*link && *link != ' ') {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1362 g_string_append_c(temp, *link);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1363 link++;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1364 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1365 g_string_append(temp, "</a>");
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
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1368 g_string_append(temp, link);
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 /* Free the last round's line. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1371 if (link_temp_line)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1372 g_free(line);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1373
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1374 line = temp->str;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1375 g_string_free(temp, FALSE);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1376
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1377 /* Save this memory location so we can free it later. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1378 link_temp_line = line;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1379 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1380 }
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 timestamp = "";
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1383 if (*line == '[') {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1384 timestamp = line;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1385 while (*timestamp && *timestamp != ']')
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1386 timestamp++;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1387 if (*timestamp == ']') {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1388 *timestamp = '\0';
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1389 line++;
11503
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1390 /* TODO: Parse the timestamp and convert it to Gaim's format. */
11459
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1391 g_string_append_printf(formatted,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1392 "<font size=\"2\">(%s)</font> ", line);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1393 line = timestamp;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1394 if (line[1] && line[2])
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1395 line += 2;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1396 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1397
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1398 if (g_str_has_prefix(line, "*** ")) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1399 line += (sizeof("*** ") - 1);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1400 g_string_append(formatted, "<b>");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1401 footer = "</b>";
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1402 if (g_str_has_prefix(line, "NOTE: This user is offline.")) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1403 line = _("User is offline.");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1404 } else if (g_str_has_prefix(line,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1405 "NOTE: Your status is currently set to ")) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1406
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1407 line += (sizeof("NOTE: ") - 1);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1408 } else if (g_str_has_prefix(line, "Auto-response sent to ")) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1409 g_string_append(formatted, _("Auto-response sent:"));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1410 while (*line && *line != ':')
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1411 line++;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1412 if (*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 g_string_append(formatted, "</b>");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1415 footer = NULL;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1416 } else if (strstr(line, " signed off ")) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1417 if (buddy->alias)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1418 g_string_append_printf(formatted,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1419 _("%s logged out."), buddy->alias);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1420 else
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1421 g_string_append_printf(formatted,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1422 _("%s logged out."), log->name);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1423 line = "";
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1424 } else if (strstr(line, " signed on ")) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1425 if (buddy->alias)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1426 g_string_append(formatted, buddy->alias);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1427 else
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1428 g_string_append(formatted, log->name);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1429 line = " logged in.";
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1430 } else if (g_str_has_prefix(line,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1431 "One or more messages may have been undeliverable.")) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1432
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1433 g_string_append(formatted,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1434 "<span style=\"color: #ff0000;\">");
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 _("One or more messages may have been "
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1437 "undeliverable."));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1438 line = "";
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1439 footer = "</span></b>";
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1440 } else if (g_str_has_prefix(line,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1441 "You have been disconnected.")) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1442
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1443 g_string_append(formatted,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1444 "<span style=\"color: #ff0000;\">");
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 _("You were disconnected from the server."));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1447 line = "";
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1448 footer = "</span></b>";
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1449 } else if (g_str_has_prefix(line,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1450 "You are currently disconnected.")) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1451
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1452 g_string_append(formatted,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1453 "<span style=\"color: #ff0000;\">");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1454 line = _("You are currently disconnected. Messages "
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1455 "will not be received unless you are "
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1456 "logged in.");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1457 footer = "</span></b>";
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1458 } else if (g_str_has_prefix(line,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1459 "Your previous message has not been sent.")) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1460
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1461 g_string_append(formatted,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1462 "<span style=\"color: #ff0000;\">");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1463
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1464 if (g_str_has_prefix(line,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1465 "Your previous message has not been sent. "
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1466 "Reason: Maximum length exceeded.")) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1467
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1468 g_string_append(formatted,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1469 _("Message could not be sent because "
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1470 "the maximum length was exceeded."));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1471 line = "";
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1472 } else {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1473 g_string_append(formatted,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1474 _("Message could not be sent."));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1475 line += (sizeof(
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1476 "Your previous message "
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1477 "has not been sent. ") - 1);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1478 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1479
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1480 footer = "</span></b>";
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 } else if (g_str_has_prefix(line, data->their_nickname)) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1483 if (buddy->alias) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1484 line += strlen(data->their_nickname) + 2;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1485 g_string_append_printf(formatted,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1486 "<span style=\"color: #A82F2F;\">"
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1487 "<b>%s</b></span>: ", buddy->alias);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1488 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1489 } else {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1490 char *line2 = line;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1491 while (*line2 && *line2 != ':')
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1492 line2++;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1493 if (*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 line = line2;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1496 g_string_append_printf(formatted,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1497 "<span style=\"color: #16569E;\">"
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1498 "<b>%s</b></span>:", log->account->alias);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1499 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1500 }
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 g_string_append(formatted, line);
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 if (footer)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1506 g_string_append(formatted, footer);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1507
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1508 g_string_append_c(formatted, '\n');
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 if (link_temp_line)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1511 g_free(link_temp_line);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1512
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1513 c++;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1514 line = c;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1515 } else
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1516 c++;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1517 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1518
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1519 g_free(read);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1520 read = formatted->str;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1521 g_string_free(formatted, FALSE);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1522
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1523 return read;
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
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1526 static int trillian_logger_size (GaimLog *log)
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 struct trillian_logger_data *data;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1529 char *text;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1530 size_t size;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1531
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1532 g_return_val_if_fail(log != NULL, 0);
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 data = log->logger_data;
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 if (gaim_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1537 return data ? data->length : 0;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1538 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1539
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1540 text = trillian_logger_read(log, NULL);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1541 size = strlen(text);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1542 g_free(text);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1543
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1544 return size;
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
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1547 static void trillian_logger_finalize(GaimLog *log)
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 struct trillian_logger_data *data;
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 g_return_if_fail(log != NULL);
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 data = log->logger_data;
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 g_free(data->path);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1556 g_free(data->their_nickname);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1557
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1558 }
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 * Plugin Code *
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
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1565 static void
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1566 init_plugin(GaimPlugin *plugin)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1567 {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1568 char *path;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1569 #ifdef _WIN32
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1570 char *folder;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1571 #endif
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1572
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1573 g_return_if_fail(plugin != NULL);
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 gaim_prefs_add_none("/plugins/core/log_reader");
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
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1578 /* Add general preferences. */
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 gaim_prefs_add_bool("/plugins/core/log_reader/fast_sizes", FALSE);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1581 gaim_prefs_add_bool("/plugins/core/log_reader/use_name_heuristics", TRUE);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1582
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1583
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1584 /* Add Adium log directory preference. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1585 gaim_prefs_add_none("/plugins/core/log_reader/adium");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1586
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1587 /* Calculate default Adium log directory. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1588 #ifdef _WIN32
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1589 path = "";
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1590 #else
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1591 path = g_build_filename(gaim_home_dir(), "Library", "Application Support",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1592 "Adium 2.0", "Users", "Default", "Logs", NULL);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1593 #endif
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1594
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1595 gaim_prefs_add_string("/plugins/core/log_reader/adium/log_directory", path);
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 #ifndef _WIN32
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1598 g_free(path);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1599 #endif
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1600
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1601
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1602 /* Add Fire log directory preference. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1603 gaim_prefs_add_none("/plugins/core/log_reader/fire");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1604
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1605 /* Calculate default Fire log directory. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1606 #ifdef _WIN32
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1607 path = "";
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1608 #else
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1609 path = g_build_filename(gaim_home_dir(), "Library", "Application Support",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1610 "Fire", "Sessions", NULL);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1611 #endif
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1612
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1613 gaim_prefs_add_string("/plugins/core/log_reader/fire/log_directory", path);
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 #ifndef _WIN32
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1616 g_free(path);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1617 #endif
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1618
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1619
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1620 /* Add Messenger Plus! log directory preference. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1621 gaim_prefs_add_none("/plugins/core/log_reader/messenger_plus");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1622
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1623 /* Calculate default Messenger Plus! log directory. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1624 #ifdef _WIN32
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1625 folder = wgaim_get_special_folder(CSIDL_PERSONAL);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1626 if (folder) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1627 #endif
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1628 path = g_build_filename(
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1629 #ifdef _WIN32
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1630 folder,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1631 #else
11503
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1632 GAIM_LOG_READER_WINDOWS_MOUNT_POINT, "Documents and Settings",
11459
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1633 g_get_user_name(), "My Documents",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1634 #endif
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1635 "My Chat Logs", NULL);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1636 #ifdef _WIN32
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1637 g_free(folder);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1638 } else /* !folder */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1639 path = g_strdup("");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1640 #endif
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1641
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1642 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
1643 g_free(path);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1644
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1645
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1646 /* Add MSN Messenger log directory preference. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1647 gaim_prefs_add_none("/plugins/core/log_reader/msn");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1648
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1649 /* Calculate default MSN message history directory. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1650 #ifdef _WIN32
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1651 folder = wgaim_get_special_folder(CSIDL_PERSONAL);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1652 if (folder) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1653 #endif
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1654 path = g_build_filename(
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1655 #ifdef _WIN32
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1656 folder,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1657 #else
11503
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1658 GAIM_LOG_READER_WINDOWS_MOUNT_POINT, "Documents and Settings",
11459
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1659 g_get_user_name(), "My Documents",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1660 #endif
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1661 "My Received Files", NULL);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1662 #ifdef _WIN32
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1663 g_free(folder);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1664 } else /* !folder */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1665 path = g_strdup("");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1666 #endif
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1667
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1668 gaim_prefs_add_string("/plugins/core/log_reader/msn/log_directory", path);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1669 g_free(path);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1670
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1671
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1672 /* Add Trillian log directory preference. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1673 gaim_prefs_add_none("/plugins/core/log_reader/trillian");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1674
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1675 #ifdef _WIN32
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1676 /* 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
1677 * think of to determine the Trillian installation directory.
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1678 */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1679 HKEY hKey;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1680 char buffer[1024] = "";
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1681 DWORD size = (sizeof(buffer) - 1);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1682 DWORD type;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1683
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1684 path = NULL;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1685 /* TODO: Test this after removing the trailing "\\". */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1686 if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_CLASSES_ROOT, "Trillian.SkinZip\\shell\\Add\\command\\",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1687 0, KEY_QUERY_VALUE, &hKey)) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1688
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1689 if(ERROR_SUCCESS == RegQueryValueEx(hKey, "", NULL, &type, (LPBYTE)buffer, &size)) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1690 char *value = buffer;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1691 char *temp;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1692
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1693 /* Ensure the data is null terminated. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1694 value[size] = '\0';
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1695
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1696 /* Break apart buffer. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1697 if (*value == '"') {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1698 value++;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1699 temp = value;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1700 while (*temp && *temp != '"')
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1701 temp++;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1702 } else {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1703 temp = value;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1704 while (*temp && *temp != ' ')
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1705 temp++;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1706 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1707 *temp = '\0';
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 /* Set path. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1710 if (g_str_has_suffix(value, "trillian.exe"))
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1711 {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1712 value[strlen(value) - (sizeof("trillian.exe") - 1)] = '\0';
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1713 path = g_build_filename(value, "users", "default", "talk.ini", NULL);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1714 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1715 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1716 RegCloseKey(hKey);
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
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1719 if (!path) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1720 char *folder = wgaim_get_special_folder(CSIDL_PROGRAM_FILES);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1721 if (folder)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1722 path = g_build_filename(folder, "Trillian",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1723 "users", "default", "talk.ini", NULL);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1724 g_free(folder);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1725 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1726 }
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 gboolean found = FALSE;
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 if (path) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1731 /* Read talk.ini file to find the log directory. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1732 GError *error = NULL;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1733
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1734 #if 0 && GTK_CHECK_VERSION(2,6,0) /* FIXME: Not tested yet. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1735 GKeyFile *key_file;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1736
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1737 gaim_debug(GAIM_DEBUG_INFO, "Trillian talk.ini read",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1738 "Reading %s\n", path);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1739 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
1740 gaim_debug(GAIM_DEBUG_ERROR, "Trillian talk.ini read",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1741 "Error reading talk.ini\n");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1742 if (error)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1743 g_error_free(error);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1744 } else {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1745 char *logdir = g_key_file_get_string(key_file, "Logging", "Directory", &error);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1746 if (error) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1747 gaim_debug(GAIM_DEBUG_ERROR, "Trillian talk.ini read",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1748 "Error reading Directory value from Logging section\n");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1749 g_error_free(error);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1750 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1751
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1752 if (logdir) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1753 g_strchomp(logdir);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1754 gaim_prefs_add_string(
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1755 "/plugins/core/log_reader/trillian/log_directory", logdir);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1756 found = TRUE;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1757 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1758
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1759 g_key_file_free(key_file);
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 #else /* !GTK_CHECK_VERSION(2,6,0) */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1762 GError *error = NULL;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1763 gsize length;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1764
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1765 gaim_debug(GAIM_DEBUG_INFO, "Trillian talk.ini read",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1766 "Reading %s\n", path);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1767 if (!g_file_get_contents(path, &contents, &length, &error)) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1768 gaim_debug(GAIM_DEBUG_ERROR, "Trillian talk.ini read",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1769 "Error reading talk.ini\n");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1770 if (error)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1771 g_error_free(error);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1772 } else {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1773 char *line = contents;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1774 while (*contents) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1775 if (*contents == '\n') {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1776 *contents = '\0';
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1777
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1778 /* XXX: This assumes the first Directory key is under [Logging]. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1779 if (g_str_has_prefix(line, "Directory=")) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1780 line += (sizeof("Directory=") - 1);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1781 g_strchomp(line);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1782 gaim_prefs_add_string(
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1783 "/plugins/core/log_reader/trillian/log_directory",
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1784 line);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1785 found = TRUE;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1786 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1787
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1788 contents++;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1789 line = contents;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1790 } else
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1791 contents++;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1792 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1793 g_free(path);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1794 g_free(contents);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1795 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1796 #endif /* !GTK_CHECK_VERSION(2,6,0) */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1797 } /* path */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1798
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1799 if (!found) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1800 #endif /* defined(_WIN32) */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1801
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1802 /* Calculate default Trillian log directory. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1803 #ifdef _WIN32
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1804 folder = wgaim_get_special_folder(CSIDL_PROGRAM_FILES);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1805 if (folder) {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1806 #endif
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1807 path = g_build_filename(
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1808 #ifdef _WIN32
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1809 folder,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1810 #else
11503
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1811 GAIM_LOG_READER_WINDOWS_MOUNT_POINT, "Program Files",
11459
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1812 #endif
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1813 "Trillian", "users", "default", "logs", NULL);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1814 #ifdef _WIN32
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1815 g_free(folder);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1816 } else /* !folder */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1817 path = g_strdup("");
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1818 #endif
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1819
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1820 gaim_prefs_add_string("/plugins/core/log_reader/trillian/log_directory", path);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1821 g_free(path);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1822
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1823 #ifdef _WIN32
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1824 } /* !found */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1825 #endif
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1826 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1827
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1828 static gboolean
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1829 plugin_load(GaimPlugin *plugin)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1830 {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1831 g_return_val_if_fail(plugin != NULL, FALSE);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1832
11503
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1833 adium_logger = gaim_log_logger_new("adium", "Adium", 6,
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1834 NULL,
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1835 NULL,
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1836 adium_logger_finalize,
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1837 adium_logger_list,
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1838 adium_logger_read,
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1839 adium_logger_size);
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1840 gaim_log_logger_add(adium_logger);
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1841
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1842 fire_logger = gaim_log_logger_new("fire", "Fire", 6,
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1843 NULL,
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1844 NULL,
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1845 fire_logger_finalize,
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1846 fire_logger_list,
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1847 fire_logger_read,
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1848 fire_logger_size);
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1849 gaim_log_logger_add(fire_logger);
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1850
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1851 messenger_plus_logger = gaim_log_logger_new("messenger_plus", "Messenger Plus!", 6,
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 NULL,
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1854 messenger_plus_logger_finalize,
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1855 messenger_plus_logger_list,
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1856 messenger_plus_logger_read,
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1857 messenger_plus_logger_size);
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1858 gaim_log_logger_add(messenger_plus_logger);
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1859
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1860 msn_logger = gaim_log_logger_new("msn", "MSN Messenger", 6,
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1861 NULL,
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1862 NULL,
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1863 msn_logger_finalize,
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1864 msn_logger_list,
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1865 msn_logger_read,
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1866 msn_logger_size);
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1867 gaim_log_logger_add(msn_logger);
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1868
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1869 trillian_logger = gaim_log_logger_new("trillian", "Trillian", 6,
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1870 NULL,
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1871 NULL,
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1872 trillian_logger_finalize,
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1873 trillian_logger_list,
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1874 trillian_logger_read,
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1875 trillian_logger_size);
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1876 gaim_log_logger_add(trillian_logger);
11459
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1877
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1878 return TRUE;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1879 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1880
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1881 static gboolean
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1882 plugin_unload(GaimPlugin *plugin)
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1883 {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1884 g_return_val_if_fail(plugin != NULL, FALSE);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1885
11503
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1886 gaim_log_logger_remove(adium_logger);
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1887 gaim_log_logger_remove(fire_logger);
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1888 gaim_log_logger_remove(messenger_plus_logger);
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1889 gaim_log_logger_remove(msn_logger);
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1890 gaim_log_logger_remove(trillian_logger);
11459
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1891
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1892 return TRUE;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1893 }
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 static GaimPluginPrefFrame *
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1896 get_plugin_pref_frame(GaimPlugin *plugin)
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 GaimPluginPrefFrame *frame;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1899 GaimPluginPref *ppref;
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
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1903 frame = gaim_plugin_pref_frame_new();
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1904
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1905
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1906 /* Add general preferences. */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1907
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1908 ppref = gaim_plugin_pref_new_with_label(_("General Log Reading Configuration"));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1909 gaim_plugin_pref_frame_add(frame, ppref);
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 ppref = gaim_plugin_pref_new_with_name_and_label(
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1912 "/plugins/core/log_reader/fast_sizes", _("Fast size calculations"));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1913 gaim_plugin_pref_frame_add(frame, ppref);
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 ppref = gaim_plugin_pref_new_with_name_and_label(
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1916 "/plugins/core/log_reader/use_name_heuristics", _("Use name heuristics"));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1917 gaim_plugin_pref_frame_add(frame, ppref);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1918
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 /* Add Log Directory preferences. */
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 ppref = gaim_plugin_pref_new_with_label(_("Log Directory"));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1923 gaim_plugin_pref_frame_add(frame, ppref);
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_name_and_label(
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1926 "/plugins/core/log_reader/adium/log_directory", _("Adium"));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1927 gaim_plugin_pref_frame_add(frame, ppref);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1928
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1929 ppref = gaim_plugin_pref_new_with_name_and_label(
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1930 "/plugins/core/log_reader/fire/log_directory", _("Fire"));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1931 gaim_plugin_pref_frame_add(frame, ppref);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1932
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1933 ppref = gaim_plugin_pref_new_with_name_and_label(
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1934 "/plugins/core/log_reader/messenger_plus/log_directory", _("Messenger Plus!"));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1935 gaim_plugin_pref_frame_add(frame, ppref);
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 ppref = gaim_plugin_pref_new_with_name_and_label(
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1938 "/plugins/core/log_reader/msn/log_directory", _("MSN Messenger"));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1939 gaim_plugin_pref_frame_add(frame, ppref);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1940
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1941 ppref = gaim_plugin_pref_new_with_name_and_label(
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1942 "/plugins/core/log_reader/trillian/log_directory", _("Trillian"));
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1943 gaim_plugin_pref_frame_add(frame, ppref);
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1944
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1945 return frame;
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1946 }
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1947
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1948 static GaimPluginUiInfo prefs_info = {
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1949 get_plugin_pref_frame
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1950 };
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1951
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1952 static GaimPluginInfo info =
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 GAIM_PLUGIN_MAGIC,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1955 GAIM_MAJOR_VERSION,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1956 GAIM_MINOR_VERSION,
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1957 GAIM_PLUGIN_STANDARD, /**< type */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1958 NULL, /**< ui_requirement */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1959 0, /**< flags */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1960 NULL, /**< dependencies */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1961 GAIM_PRIORITY_DEFAULT, /**< priority */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1962 "core-log_reader", /**< id */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1963 N_("Log Reader"), /**< name */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1964 VERSION, /**< version */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1965
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1966 /** summary */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1967 N_("Includes other IM clients' logs in the "
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1968 "log viewer."),
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 /** description */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1971 N_("When viewing logs, this plugin will include "
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1972 "logs from other IM clients. Currently, this "
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1973 "includes Adium, Fire, Messenger Plus!, "
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1974 "MSN Messenger, and Trillian."),
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1975
11503
cd0c8830d881 [gaim-migrate @ 13748]
Richard Laager <rlaager@wiktel.com>
parents: 11459
diff changeset
1976 "Richard Laager <rlaager@users.sf.net>", /**< author */
11459
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1977 GAIM_WEBSITE, /**< homepage */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1978 plugin_load, /**< load */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1979 plugin_unload, /**< unload */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1980 NULL, /**< destroy */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1981 NULL, /**< ui_info */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1982 NULL, /**< extra_info */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1983 &prefs_info, /**< prefs_info */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1984 NULL /**< actions */
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1985 };
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1986
b8f6f1fd30c0 [gaim-migrate @ 13698]
Richard Laager <rlaager@wiktel.com>
parents:
diff changeset
1987 GAIM_INIT_PLUGIN(log_reader, init_plugin, info)