annotate libgaim/plugins/log_reader.c @ 14950:8f27e3e5d2a2

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