annotate libpurple/plugins/log_reader.c @ 19244:b29788c6d269

Make msimprpl work without a libpurple attention API. Change PurpleAttentionType to MsimAttentionType and define it in myspace.h, so that msimprpl can use it while libpurple doesn't have it.
author Jeffrey Connelly <jaconnel@calpoly.edu>
date Tue, 14 Aug 2007 03:03:52 +0000
parents 883c18d31bf4
children 615f6343035f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 #include <stdio.h>
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 #include "internal.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 #include "debug.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 #include "log.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 #include "plugin.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 #include "pluginpref.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 #include "prefs.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 #include "stringref.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 #include "util.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 #include "version.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 #include "xmlnode.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
15 /* This must be the last Purple header included. */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 #ifdef _WIN32
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 #include "win32dep.h"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 /* Where is the Windows partition mounted? */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
21 #ifndef PURPLE_LOG_READER_WINDOWS_MOUNT_POINT
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
22 #define PURPLE_LOG_READER_WINDOWS_MOUNT_POINT "/mnt/windows"
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
25 enum name_guesses {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
26 NAME_GUESS_UNKNOWN,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
27 NAME_GUESS_ME,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 NAME_GUESS_THEM
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 /*****************************************************************************
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33 * Adium Logger *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 *****************************************************************************/
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 /* The adium logger doesn't write logs, only reads them. This is to include
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 * Adium logs in the log viewer transparently.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
38 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
39
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
40 static PurpleLogLogger *adium_logger;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 enum adium_log_type {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 ADIUM_HTML,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 ADIUM_TEXT,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 struct adium_logger_data {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 char *path;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 enum adium_log_type type;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
52 static GList *adium_logger_list(PurpleLogType type, const char *sn, PurpleAccount *account)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 GList *list = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 const char *logdir;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
56 PurplePlugin *plugin;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
57 PurplePluginProtocolInfo *prpl_info;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 char *prpl_name;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 char *temp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 char *path;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 GDir *dir;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62
18795
883c18d31bf4 Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18785
diff changeset
63 g_return_val_if_fail(sn != NULL, NULL);
883c18d31bf4 Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18785
diff changeset
64 g_return_val_if_fail(account != NULL, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65
16430
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
66 logdir = purple_prefs_get_string("/plugins/core/log_reader/adium/log_directory");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 /* By clearing the log directory path, this logger can be (effectively) disabled. */
18795
883c18d31bf4 Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18785
diff changeset
69 if (!logdir || !*logdir)
883c18d31bf4 Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18785
diff changeset
70 return NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
72 plugin = purple_find_prpl(purple_account_get_protocol_id(account));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 if (!plugin)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74 return NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
76 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77 if (!prpl_info->list_icon)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 return NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 prpl_name = g_ascii_strup(prpl_info->list_icon(account, NULL), -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 temp = g_strdup_printf("%s.%s", prpl_name, account->username);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 path = g_build_filename(logdir, temp, sn, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 g_free(temp);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 dir = g_dir_open(path, 0, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 if (dir) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 const gchar *file;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90 while ((file = g_dir_read_name(dir))) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
91 if (!purple_str_has_prefix(file, sn))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 continue;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
93 if (purple_str_has_suffix(file, ".html") || purple_str_has_suffix(file, ".AdiumHTMLLog")) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 struct tm tm;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 const char *date = file;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 date += strlen(sn) + 2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 if (sscanf(date, "%u|%u|%u",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 &tm.tm_year, &tm.tm_mon, &tm.tm_mday) != 3) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100
18245
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
101 purple_debug_error("Adium log parse",
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
102 "Filename timestamp parsing error\n");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 char *filename = g_build_filename(path, file, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105 FILE *handle = g_fopen(filename, "rb");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 char *contents;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107 char *contents2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 struct adium_logger_data *data;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
109 PurpleLog *log;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 if (!handle) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 g_free(filename);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 /* XXX: This is really inflexible. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 contents = g_malloc(57);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 fread(contents, 56, 1, handle);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 fclose(handle);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 contents[56] = '\0';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 /* XXX: This is fairly inflexible. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 contents2 = contents;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 while (*contents2 && *contents2 != '>')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 contents2++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 if (*contents2)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 contents2++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 while (*contents2 && *contents2 != '>')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 contents2++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 if (*contents2)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131 contents2++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 if (sscanf(contents2, "%u.%u.%u",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 3) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135
18245
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
136 purple_debug_error("Adium log parse",
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
137 "Contents timestamp parsing error\n");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 g_free(contents);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 g_free(filename);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 g_free(contents);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 data = g_new0(struct adium_logger_data, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 data->path = filename;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 data->type = ADIUM_HTML;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148 tm.tm_year -= 1900;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 tm.tm_mon -= 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 /* XXX: Look into this later... Should we pass in a struct tm? */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
152 log = purple_log_new(PURPLE_LOG_IM, sn, account, NULL, mktime(&tm), NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153 log->logger = adium_logger;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154 log->logger_data = data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155
18249
35d981091506 Prepend to lists for performance, and use g_list_reverse when the list is
Richard Laager <rlaager@wiktel.com>
parents: 18248
diff changeset
156 list = g_list_prepend(list, log);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 }
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
158 } else if (purple_str_has_suffix(file, ".adiumLog")) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 struct tm tm;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 const char *date = file;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 date += strlen(sn) + 2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163 if (sscanf(date, "%u|%u|%u",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164 &tm.tm_year, &tm.tm_mon, &tm.tm_mday) != 3) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165
18245
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
166 purple_debug_error("Adium log parse",
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
167 "Filename timestamp parsing error\n");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 char *filename = g_build_filename(path, file, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 FILE *handle = g_fopen(filename, "rb");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
171 char *contents;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 char *contents2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 struct adium_logger_data *data;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
174 PurpleLog *log;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 if (!handle) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177 g_free(filename);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
178 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
179 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181 /* XXX: This is really inflexible. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 contents = g_malloc(14);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183 fread(contents, 13, 1, handle);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 fclose(handle);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
185 contents[13] = '\0';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
186
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
187 contents2 = contents;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
188 while (*contents2 && *contents2 != '(')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189 contents2++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
190 if (*contents2)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191 contents2++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 if (sscanf(contents2, "%u.%u.%u",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194 &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 3) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195
18245
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
196 purple_debug_error("Adium log parse",
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
197 "Contents timestamp parsing error\n");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198 g_free(contents);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199 g_free(filename);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203 g_free(contents);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 tm.tm_year -= 1900;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 tm.tm_mon -= 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
207
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
208 data = g_new0(struct adium_logger_data, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 data->path = filename;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 data->type = ADIUM_TEXT;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 /* XXX: Look into this later... Should we pass in a struct tm? */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
213 log = purple_log_new(PURPLE_LOG_IM, sn, account, NULL, mktime(&tm), NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 log->logger = adium_logger;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 log->logger_data = data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
216
18249
35d981091506 Prepend to lists for performance, and use g_list_reverse when the list is
Richard Laager <rlaager@wiktel.com>
parents: 18248
diff changeset
217 list = g_list_prepend(list, log);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
218 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
219 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
220 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
221 g_dir_close(dir);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
222 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
223
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
224 g_free(prpl_name);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
225 g_free(path);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227 return list;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
230 static char *adium_logger_read (PurpleLog *log, PurpleLogReadFlags *flags)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
232 struct adium_logger_data *data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 GError *error = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234 gchar *read = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235 gsize length;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236
18373
07c8311ec4e4 Minor comment fix.
Richard Laager <rlaager@wiktel.com>
parents: 18372
diff changeset
237 /* XXX: TODO: We probably want to set PURPLE_LOG_READ_NO_NEWLINE
18371
c13d115b6c6e Make the Adium logger set flags, though it's still very much a stub.
Richard Laager <rlaager@wiktel.com>
parents: 18360
diff changeset
238 * XXX: TODO: for HTML logs. */
18795
883c18d31bf4 Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18785
diff changeset
239 if (flags != NULL)
883c18d31bf4 Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18785
diff changeset
240 *flags = 0;
18371
c13d115b6c6e Make the Adium logger set flags, though it's still very much a stub.
Richard Laager <rlaager@wiktel.com>
parents: 18360
diff changeset
241
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
242 g_return_val_if_fail(log != NULL, g_strdup(""));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
243
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
244 data = log->logger_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246 g_return_val_if_fail(data->path != NULL, g_strdup(""));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247
18245
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
248 purple_debug_info("Adium log read", "Reading %s\n", data->path);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249 if (!g_file_get_contents(data->path, &read, &length, &error)) {
18245
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
250 purple_debug_error("Adium log read", "Error reading log\n");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 if (error)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
252 g_error_free(error);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
253 return g_strdup("");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
254 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
255
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
256 if (data->type != ADIUM_HTML) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
257 char *escaped = g_markup_escape_text(read, -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
258 g_free(read);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
259 read = escaped;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
260 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
261
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
262 #ifdef WIN32
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
263 /* This problem only seems to show up on Windows.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
264 * The BOM is displaying as a space at the beginning of the log.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
265 */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
266 if (purple_str_has_prefix(read, "\xef\xbb\xbf"))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268 /* FIXME: This feels so wrong... */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269 char *temp = g_strdup(&(read[3]));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270 g_free(read);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271 read = temp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
272 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
273 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
274
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
275 /* TODO: Apply formatting.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
276 * Replace the above hack with something better, since we'll
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
277 * be looping over the entire log file contents anyway.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
278 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
279
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
280 return read;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
281 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
282
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
283 static int adium_logger_size (PurpleLog *log)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
284 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
285 struct adium_logger_data *data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
286 char *text;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
287 size_t size;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
289 g_return_val_if_fail(log != NULL, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
290
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
291 data = log->logger_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
292
16430
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
293 if (purple_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
294 struct stat st;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
295
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
296 if (!data->path || stat(data->path, &st))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
297 st.st_size = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
298
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
299 return st.st_size;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
300 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
301
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
302 text = adium_logger_read(log, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
303 size = strlen(text);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304 g_free(text);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
305
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
306 return size;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
307 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
308
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
309 static void adium_logger_finalize(PurpleLog *log)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
310 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
311 struct adium_logger_data *data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
312
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
313 g_return_if_fail(log != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
314
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
315 data = log->logger_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
316
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
317 g_free(data->path);
18246
e236b3bd4542 Eliminate some leaks.
Richard Laager <rlaager@wiktel.com>
parents: 18245
diff changeset
318 g_free(data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
322 /*****************************************************************************
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
323 * Fire Logger *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
324 *****************************************************************************/
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
325
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
326 #if 0
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
327 /* The fire logger doesn't write logs, only reads them. This is to include
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
328 * Fire logs in the log viewer transparently.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
329 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
330
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
331 static PurpleLogLogger *fire_logger;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
333 struct fire_logger_data {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
334 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
335
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
336 static GList *fire_logger_list(PurpleLogType type, const char *sn, PurpleAccount *account)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
337 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338 /* TODO: Do something here. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
339 return NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
340 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
342 static char * fire_logger_read (PurpleLog *log, PurpleLogReadFlags *flags)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
344 struct fire_logger_data *data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346 g_return_val_if_fail(log != NULL, g_strdup(""));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
348 data = log->logger_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
350 /* TODO: Do something here. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351 return g_strdup("");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
352 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
353
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
354 static int fire_logger_size (PurpleLog *log)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
355 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
356 g_return_val_if_fail(log != NULL, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
357
16430
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
358 if (purple_prefs_get_bool("/plugins/core/log_reader/fast_sizes"))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
359 return 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
361 /* TODO: Do something here. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
362 return 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
364
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
365 static void fire_logger_finalize(PurpleLog *log)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
366 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
367 g_return_if_fail(log != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
368
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
369 /* TODO: Do something here. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
370 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
371 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
372
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
374 /*****************************************************************************
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
375 * Messenger Plus! Logger *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
376 *****************************************************************************/
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
377
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
378 #if 0
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
379 /* The messenger_plus logger doesn't write logs, only reads them. This is to include
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
380 * Messenger Plus! logs in the log viewer transparently.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
381 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
382
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
383 static PurpleLogLogger *messenger_plus_logger;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
384
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
385 struct messenger_plus_logger_data {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
386 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
387
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
388 static GList *messenger_plus_logger_list(PurpleLogType type, const char *sn, PurpleAccount *account)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
389 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
390 /* TODO: Do something here. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
391 return NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
392 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
393
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
394 static char * messenger_plus_logger_read (PurpleLog *log, PurpleLogReadFlags *flags)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
395 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
396 struct messenger_plus_logger_data *data = log->logger_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
397
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
398 g_return_val_if_fail(log != NULL, g_strdup(""));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
399
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
400 data = log->logger_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
401
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
402 /* TODO: Do something here. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
403 return g_strdup("");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
404 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
405
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
406 static int messenger_plus_logger_size (PurpleLog *log)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
407 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
408 g_return_val_if_fail(log != NULL, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
409
16430
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
410 if (purple_prefs_get_bool("/plugins/core/log_reader/fast_sizes"))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
411 return 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
412
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
413 /* TODO: Do something here. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
414 return 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
415 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
416
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
417 static void messenger_plus_logger_finalize(PurpleLog *log)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
418 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
419 g_return_if_fail(log != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
420
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
421 /* TODO: Do something here. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
422 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
423 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
424
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
425
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
426 /*****************************************************************************
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
427 * MSN Messenger Logger *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
428 *****************************************************************************/
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
429
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
430 /* The msn logger doesn't write logs, only reads them. This is to include
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
431 * MSN Messenger message histories in the log viewer transparently.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
432 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
433
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
434 static PurpleLogLogger *msn_logger;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
435
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
436 struct msn_logger_data {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
437 xmlnode *root;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
438 xmlnode *message;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
439 const char *session_id;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
440 int last_log;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
441 GString *text;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
442 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
443
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
444 /* This function is really confusing. It makes baby rlaager cry...
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
445 In other news: "You lost a lot of blood but we found most of it."
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
446 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
447 static time_t msn_logger_parse_timestamp(xmlnode *message, struct tm **tm_out)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
448 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
449 const char *datetime;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
450 static struct tm tm2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
451 time_t stamp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
452 const char *date;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
453 const char *time;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
454 int month;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
455 int day;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
456 int year;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
457 int hour;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
458 int min;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
459 int sec;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
460 char am_pm;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
461 char *str;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
462 static struct tm tm;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
463 time_t t;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
464 time_t diff;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
465
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
466 #ifndef G_DISABLE_CHECKS
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
467 if (message != NULL)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
468 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
469 *tm_out = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
470
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
471 /* Trigger the usual warning. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
472 g_return_val_if_fail(message != NULL, (time_t)0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
473 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
474 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
475
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
476 datetime = xmlnode_get_attrib(message, "DateTime");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
477 if (!(datetime && *datetime))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
478 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
479 purple_debug_error("MSN log timestamp parse",
18245
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
480 "Attribute missing: %s\n", "DateTime");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
481 return (time_t)0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
482 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
483
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
484 stamp = purple_str_to_time(datetime, TRUE, &tm2, NULL, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
485 #ifdef HAVE_TM_GMTOFF
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
486 tm2.tm_gmtoff = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
487 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
488 #ifdef HAVE_STRUCT_TM_TM_ZONE
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
489 /* This is used in the place of a timezone abbreviation if the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
490 * offset is way off. The user should never really see it, but
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
491 * it's here just in case. The parens are to make it clear it's
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
492 * not a real timezone. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
493 tm2.tm_zone = _("(UTC)");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
494 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
495
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
496
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
497 date = xmlnode_get_attrib(message, "Date");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
498 if (!(date && *date))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
499 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
500 purple_debug_error("MSN log timestamp parse",
18245
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
501 "Attribute missing: %s\n", "Date");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
502 *tm_out = &tm2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
503 return stamp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
504 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
505
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
506 time = xmlnode_get_attrib(message, "Time");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
507 if (!(time && *time))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
508 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
509 purple_debug_error("MSN log timestamp parse",
18245
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
510 "Attribute missing: %s\n", "Time");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
511 *tm_out = &tm2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
512 return stamp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
513 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
514
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
515 if (sscanf(date, "%u/%u/%u", &month, &day, &year) != 3)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
516 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
517 purple_debug_error("MSN log timestamp parse",
18245
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
518 "%s parsing error\n", "Date");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
519 *tm_out = &tm2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
520 return stamp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
521 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
522 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
523 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
524 if (month > 12)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
525 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
526 int tmp = day;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
527 day = month;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
528 month = tmp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
529 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
530 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
531
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
532 if (sscanf(time, "%u:%u:%u %c", &hour, &min, &sec, &am_pm) != 4)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
533 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
534 purple_debug_error("MSN log timestamp parse",
18245
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
535 "%s parsing error\n", "Time");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
536 *tm_out = &tm2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
537 return stamp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
538 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
539
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
540 if (am_pm == 'P') {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
541 hour += 12;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
542 } else if (hour == 12) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
543 /* 12 AM = 00 hr */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
544 hour = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
545 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
546
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
547 str = g_strdup_printf("%04i-%02i-%02iT%02i:%02i:%02i", year, month, day, hour, min, sec);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
548 t = purple_str_to_time(str, TRUE, &tm, NULL, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
549
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
550
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
551 if (stamp > t)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
552 diff = stamp - t;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
553 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
554 diff = t - stamp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
555
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
556 if (diff > (14 * 60 * 60))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
557 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
558 if (day <= 12)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
559 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
560 /* Swap day & month variables, to see if it's a non-US date. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
561 g_free(str);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
562 str = g_strdup_printf("%04i-%02i-%02iT%02i:%02i:%02i", year, month, day, hour, min, sec);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
563 t = purple_str_to_time(str, TRUE, &tm, NULL, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
564
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
565 if (stamp > t)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
566 diff = stamp - t;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
567 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
568 diff = t - stamp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
569
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
570 if (diff > (14 * 60 * 60))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
571 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
572 /* We got a time, it's not impossible, but
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
573 * the diff is too large. Display the UTC time. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
574 g_free(str);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
575 *tm_out = &tm2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
576 return stamp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
577 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
578 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
579 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
580 /* Legal time */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
581 /* Fall out */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
582 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
583 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
584 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
585 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
586 /* We got a time, it's not impossible, but
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
587 * the diff is too large. Display the UTC time. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
588 g_free(str);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
589 *tm_out = &tm2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
590 return stamp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
591 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
592 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
593
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
594 /* If we got here, the time is legal with a reasonable offset.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
595 * Let's find out if it's in our TZ. */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
596 if (purple_str_to_time(str, FALSE, &tm, NULL, NULL) == stamp)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
597 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
598 g_free(str);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
599 *tm_out = &tm;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
600 return stamp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
601 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
602 g_free(str);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
603
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
604 /* The time isn't in our TZ, but it's reasonable. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
605 #ifdef HAVE_STRUCT_TM_TM_ZONE
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
606 tm.tm_zone = " ";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
607 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
608 *tm_out = &tm;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
609 return stamp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
610 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
611
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
612 static GList *msn_logger_list(PurpleLogType type, const char *sn, PurpleAccount *account)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
613 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
614 GList *list = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
615 char *username;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
616 PurpleBuddy *buddy;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
617 const char *logdir;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
618 const char *savedfilename = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
619 char *logfile;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
620 char *path;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
621 GError *error = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
622 gchar *contents = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
623 gsize length;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
624 xmlnode *root;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
625 xmlnode *message;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
626 const char *old_session_id = "";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
627 struct msn_logger_data *data = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
628
18795
883c18d31bf4 Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18785
diff changeset
629 g_return_val_if_fail(sn != NULL, NULL);
883c18d31bf4 Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18785
diff changeset
630 g_return_val_if_fail(account != NULL, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
631
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
632 if (strcmp(account->protocol_id, "prpl-msn"))
18795
883c18d31bf4 Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18785
diff changeset
633 return NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
634
16430
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
635 logdir = purple_prefs_get_string("/plugins/core/log_reader/msn/log_directory");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
636
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
637 /* By clearing the log directory path, this logger can be (effectively) disabled. */
18795
883c18d31bf4 Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18785
diff changeset
638 if (!logdir || !*logdir)
883c18d31bf4 Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18785
diff changeset
639 return NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
640
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
641 buddy = purple_find_buddy(account, sn);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
642
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
643 if ((username = g_strdup(purple_account_get_string(
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
644 account, "log_reader_msn_log_folder", NULL)))) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
645 /* As a special case, we allow the null string to kill the parsing
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
646 * straight away. This would allow the user to deal with the case
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
647 * when two account have the same username at different domains and
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
648 * only one has logs stored.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
649 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
650 if (!*username) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
651 g_free(username);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
652 return list;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
653 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
654 } else {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
655 username = g_strdup(purple_normalize(account, account->username));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
656 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
657
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
658 if (buddy)
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
659 savedfilename = purple_blist_node_get_string(&buddy->node, "log_reader_msn_log_filename");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
660
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
661 if (savedfilename) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
662 /* As a special case, we allow the null string to kill the parsing
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
663 * straight away. This would allow the user to deal with the case
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
664 * when two buddies have the same username at different domains and
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
665 * only one has logs stored.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
666 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
667 if (!*savedfilename) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
668 g_free(username);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
669 return list;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
670 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
671
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
672 logfile = g_strdup(savedfilename);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
673 } else {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
674 logfile = g_strdup_printf("%s.xml", purple_normalize(account, sn));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
675 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
676
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
677 path = g_build_filename(logdir, username, "History", logfile, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
678
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
679 if (!g_file_test(path, G_FILE_TEST_EXISTS)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
680 gboolean found = FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
681 char *at_sign;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
682 GDir *dir;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
683
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
684 g_free(path);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
685
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
686 if (savedfilename) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
687 /* We had a saved filename, but it doesn't exist.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
688 * Returning now is the right course of action because we don't
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
689 * want to detect another file incorrectly.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
690 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
691 g_free(username);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
692 g_free(logfile);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
693 return list;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
694 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
695
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
696 /* Perhaps we're using a new version of MSN with the weird numbered folders.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
697 * I don't know how the numbers are calculated, so I'm going to attempt to
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
698 * find logs by pattern matching...
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
699 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
700
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
701 at_sign = g_strrstr(username, "@");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
702 if (at_sign)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
703 *at_sign = '\0';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
704
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
705 dir = g_dir_open(logdir, 0, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
706 if (dir) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
707 const gchar *name;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
708
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
709 while ((name = g_dir_read_name(dir))) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
710 const char *c = name;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
711
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
712 if (!purple_str_has_prefix(c, username))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
713 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
714
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
715 c += strlen(username);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
716 while (*c) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
717 if (!g_ascii_isdigit(*c))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
718 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
719
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
720 c++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
721 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
722
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
723 path = g_build_filename(logdir, name, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
724 /* The !c makes sure we got to the end of the while loop above. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
725 if (!*c && g_file_test(path, G_FILE_TEST_IS_DIR)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
726 char *history_path = g_build_filename(
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
727 path, "History", NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
728 if (g_file_test(history_path, G_FILE_TEST_IS_DIR)) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
729 purple_account_set_string(account,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
730 "log_reader_msn_log_folder", name);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
731 g_free(path);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
732 path = history_path;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
733 found = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
734 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
735 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
736 g_free(path);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
737 g_free(history_path);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
738 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
739 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
740 g_free(path);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
741 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
742 g_dir_close(dir);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
743 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
744 g_free(username);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
745
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
746 if (!found) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
747 g_free(logfile);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
748 return list;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
749 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
750
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
751 /* If we've reached this point, we've found a History folder. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
752
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
753 username = g_strdup(purple_normalize(account, sn));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
754 at_sign = g_strrstr(username, "@");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
755 if (at_sign)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
756 *at_sign = '\0';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
757
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
758 found = FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
759 dir = g_dir_open(path, 0, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
760 if (dir) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
761 const gchar *name;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
762
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
763 while ((name = g_dir_read_name(dir))) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
764 const char *c = name;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
765
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
766 if (!purple_str_has_prefix(c, username))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
767 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
768
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
769 c += strlen(username);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
770 while (*c) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
771 if (!g_ascii_isdigit(*c))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
772 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
773
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
774 c++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
775 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
776
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
777 path = g_build_filename(path, name, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
778 if (!strcmp(c, ".xml") &&
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
779 g_file_test(path, G_FILE_TEST_EXISTS)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
780 found = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
781 g_free(logfile);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
782 logfile = g_strdup(name);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
783 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
784 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
785 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
786 g_free(path);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
787 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
788 g_dir_close(dir);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
789 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
790 g_free(username);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
791
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
792 if (!found) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
793 g_free(logfile);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
794 return list;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
795 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
796 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
797 g_free(username);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
798 g_free(logfile);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
799 logfile = NULL; /* No sense saving the obvious buddy@domain.com. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
800 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
801
18245
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
802 purple_debug_info("MSN log read", "Reading %s\n", path);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
803 if (!g_file_get_contents(path, &contents, &length, &error)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
804 g_free(path);
18245
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
805 purple_debug_error("MSN log read", "Error reading log\n");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
806 if (error)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
807 g_error_free(error);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
808 return list;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
809 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
810 g_free(path);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
811
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
812 /* Reading the file was successful...
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
813 * Save its name if it involves the crazy numbers. The idea here is that you could
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
814 * then tweak the blist.xml file by hand if need be. This would be the case if two
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
815 * buddies have the same username at different domains. One set of logs would get
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
816 * detected for both buddies.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
817 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
818 if (buddy && logfile) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
819 purple_blist_node_set_string(&buddy->node, "log_reader_msn_log_filename", logfile);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
820 g_free(logfile);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
821 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
822
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
823 root = xmlnode_from_str(contents, length);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
824 g_free(contents);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
825 if (!root)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
826 return list;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
827
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
828 for (message = xmlnode_get_child(root, "Message"); message;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
829 message = xmlnode_get_next_twin(message)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
830 const char *session_id;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
831
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
832 session_id = xmlnode_get_attrib(message, "SessionID");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
833 if (!session_id) {
18245
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
834 purple_debug_error("MSN log parse",
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
835 "Error parsing message: %s\n", "SessionID missing");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
836 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
837 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
838
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
839 if (strcmp(session_id, old_session_id)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
840 /*
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
841 * The session ID differs from the last message.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
842 * Thus, this is the start of a new conversation.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
843 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
844 struct tm *tm;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
845 time_t stamp;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
846 PurpleLog *log;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
847
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
848 data = g_new0(struct msn_logger_data, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
849 data->root = root;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
850 data->message = message;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
851 data->session_id = session_id;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
852 data->text = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
853 data->last_log = FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
854
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
855 stamp = msn_logger_parse_timestamp(message, &tm);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
856
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
857 log = purple_log_new(PURPLE_LOG_IM, sn, account, NULL, stamp, tm);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
858 log->logger = msn_logger;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
859 log->logger_data = data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
860
18249
35d981091506 Prepend to lists for performance, and use g_list_reverse when the list is
Richard Laager <rlaager@wiktel.com>
parents: 18248
diff changeset
861 list = g_list_prepend(list, log);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
862 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
863 old_session_id = session_id;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
864 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
865
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
866 if (data)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
867 data->last_log = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
868
18249
35d981091506 Prepend to lists for performance, and use g_list_reverse when the list is
Richard Laager <rlaager@wiktel.com>
parents: 18248
diff changeset
869 return g_list_reverse(list);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
870 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
871
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
872 static char * msn_logger_read (PurpleLog *log, PurpleLogReadFlags *flags)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
873 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
874 struct msn_logger_data *data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
875 GString *text = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
876 xmlnode *message;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
877
18765
9cec393c3a21 Fix #2349 (null pointer deref in log_reader plugin).
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18559
diff changeset
878 if (flags != NULL)
9cec393c3a21 Fix #2349 (null pointer deref in log_reader plugin).
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18559
diff changeset
879 *flags = PURPLE_LOG_READ_NO_NEWLINE;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
880 g_return_val_if_fail(log != NULL, g_strdup(""));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
881
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
882 data = log->logger_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
883
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
884 if (data->text) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
885 /* The GTK code which displays the logs g_free()s whatever is
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
886 * returned from this function. Thus, we can't reuse the str
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
887 * part of the GString. The only solution is to free it and
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
888 * start over.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
889 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
890 g_string_free(data->text, FALSE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
891 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
892
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
893 text = g_string_new("");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
894
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
895 if (!data->root || !data->message || !data->session_id) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
896 /* Something isn't allocated correctly. */
18245
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
897 purple_debug_error("MSN log parse",
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
898 "Error parsing message: %s\n", "Internal variables inconsistent");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
899 data->text = text;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
900
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
901 return text->str;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
902 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
903
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
904 for (message = data->message; message;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
905 message = xmlnode_get_next_twin(message)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
906
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
907 const char *new_session_id;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
908 xmlnode *text_node;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
909 const char *from_name = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
910 const char *to_name = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
911 xmlnode *from;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
912 xmlnode *to;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
913 enum name_guesses name_guessed = NAME_GUESS_UNKNOWN;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
914 const char *their_name;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
915 time_t time_unix;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
916 struct tm *tm;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
917 char *timestamp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
918 char *tmp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
919 const char *style;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
920
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
921 new_session_id = xmlnode_get_attrib(message, "SessionID");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
922
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
923 /* If this triggers, something is wrong with the XML. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
924 if (!new_session_id) {
18245
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
925 purple_debug_error("MSN log parse",
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
926 "Error parsing message: %s\n", "New SessionID missing");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
927 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
928 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
929
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
930 if (strcmp(new_session_id, data->session_id)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
931 /* The session ID differs from the first message.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
932 * Thus, this is the start of a new conversation.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
933 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
934 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
935 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
936
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
937 text_node = xmlnode_get_child(message, "Text");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
938 if (!text_node)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
939 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
940
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
941 from = xmlnode_get_child(message, "From");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
942 if (from) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
943 xmlnode *user = xmlnode_get_child(from, "User");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
944
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
945 if (user) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
946 from_name = xmlnode_get_attrib(user, "FriendlyName");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
947
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
948 /* This saves a check later. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
949 if (!*from_name)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
950 from_name = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
951 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
952 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
953
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
954 to = xmlnode_get_child(message, "To");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
955 if (to) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
956 xmlnode *user = xmlnode_get_child(to, "User");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
957 if (user) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
958 to_name = xmlnode_get_attrib(user, "FriendlyName");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
959
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
960 /* This saves a check later. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
961 if (!*to_name)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
962 to_name = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
963 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
964 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
965
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
966 their_name = from_name;
16430
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
967 if (from_name && purple_prefs_get_bool("/plugins/core/log_reader/use_name_heuristics")) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
968 const char *friendly_name = purple_connection_get_display_name(log->account->gc);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
969
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
970 if (friendly_name != NULL) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
971 int friendly_name_length = strlen(friendly_name);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
972 const char *alias;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
973 int alias_length;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
974 PurpleBuddy *buddy = purple_find_buddy(log->account, log->name);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
975 gboolean from_name_matches;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
976 gboolean to_name_matches;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
977
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
978 if (buddy && buddy->alias)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
979 their_name = buddy->alias;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
980
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
981 if (log->account->alias)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
982 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
983 alias = log->account->alias;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
984 alias_length = strlen(alias);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
985 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
986 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
987 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
988 alias = "";
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
989 alias_length = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
990 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
991
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
992 /* Try to guess which user is me.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
993 * The first step is to determine if either of the names matches either my
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
994 * friendly name or alias. For this test, "match" is defined as:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
995 * ^(friendly_name|alias)([^a-zA-Z0-9].*)?$
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
996 */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
997 from_name_matches = (purple_str_has_prefix(from_name, friendly_name) &&
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
998 !isalnum(*(from_name + friendly_name_length))) ||
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
999 (purple_str_has_prefix(from_name, alias) &&
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1000 !isalnum(*(from_name + alias_length)));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1001
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1002 to_name_matches = to_name != NULL && (
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
1003 (purple_str_has_prefix(to_name, friendly_name) &&
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1004 !isalnum(*(to_name + friendly_name_length))) ||
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
1005 (purple_str_has_prefix(to_name, alias) &&
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1006 !isalnum(*(to_name + alias_length))));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1007
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1008 if (from_name_matches) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1009 if (!to_name_matches) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1010 name_guessed = NAME_GUESS_ME;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1011 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1012 } else if (to_name_matches) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1013 name_guessed = NAME_GUESS_THEM;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1014 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1015 if (buddy && buddy->alias) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1016 char *alias = g_strdup(buddy->alias);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1017
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1018 /* "Truncate" the string at the first non-alphanumeric
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1019 * character. The idea is to relax the comparison.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1020 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1021 char *temp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1022 for (temp = alias; *temp ; temp++) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1023 if (!isalnum(*temp)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1024 *temp = '\0';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1025 break;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1026 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1027 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1028 alias_length = strlen(alias);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1029
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1030 /* Try to guess which user is them.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1031 * The first step is to determine if either of the names
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1032 * matches their alias. For this test, "match" is
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1033 * defined as: ^alias([^a-zA-Z0-9].*)?$
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1034 */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
1035 from_name_matches = (purple_str_has_prefix(
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1036 from_name, alias) &&
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1037 !isalnum(*(from_name +
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1038 alias_length)));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1039
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
1040 to_name_matches = to_name && (purple_str_has_prefix(
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1041 to_name, alias) &&
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1042 !isalnum(*(to_name +
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1043 alias_length)));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1044
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1045 g_free(alias);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1046
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1047 if (from_name_matches) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1048 if (!to_name_matches) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1049 name_guessed = NAME_GUESS_THEM;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1050 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1051 } else if (to_name_matches) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1052 name_guessed = NAME_GUESS_ME;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1053 } else if (buddy->server_alias) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1054 friendly_name_length =
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1055 strlen(buddy->server_alias);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1056
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1057 /* Try to guess which user is them.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1058 * The first step is to determine if either of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1059 * the names matches their friendly name. For
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1060 * this test, "match" is defined as:
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1061 * ^friendly_name([^a-zA-Z0-9].*)?$
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1062 */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
1063 from_name_matches = (purple_str_has_prefix(
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1064 from_name,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1065 buddy->server_alias) &&
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1066 !isalnum(*(from_name +
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1067 friendly_name_length)));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1068
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1069 to_name_matches = to_name && (
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
1070 (purple_str_has_prefix(
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1071 to_name, buddy->server_alias) &&
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1072 !isalnum(*(to_name +
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1073 friendly_name_length))));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1074
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1075 if (from_name_matches) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1076 if (!to_name_matches) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1077 name_guessed = NAME_GUESS_THEM;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1078 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1079 } else if (to_name_matches) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1080 name_guessed = NAME_GUESS_ME;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1081 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1082 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1083 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1084 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1085 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1086 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1087
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1088 if (name_guessed != NAME_GUESS_UNKNOWN) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1089 text = g_string_append(text, "<span style=\"color: #");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1090 if (name_guessed == NAME_GUESS_ME)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1091 text = g_string_append(text, "16569E");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1092 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1093 text = g_string_append(text, "A82F2F");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1094 text = g_string_append(text, ";\">");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1095 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1096
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1097 time_unix = msn_logger_parse_timestamp(message, &tm);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1098
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1099 timestamp = g_strdup_printf("<font size=\"2\">(%02u:%02u:%02u)</font> ",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1100 tm->tm_hour, tm->tm_min, tm->tm_sec);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1101 text = g_string_append(text, timestamp);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1102 g_free(timestamp);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1103
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1104 if (from_name) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1105 text = g_string_append(text, "<b>");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1106
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1107 if (name_guessed == NAME_GUESS_ME) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1108 if (log->account->alias)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1109 text = g_string_append(text, log->account->alias);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1110 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1111 text = g_string_append(text, log->account->username);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1112 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1113 else if (name_guessed == NAME_GUESS_THEM)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1114 text = g_string_append(text, their_name);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1115 else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1116 text = g_string_append(text, from_name);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1117
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1118 text = g_string_append(text, ":</b> ");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1119 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1120
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1121 if (name_guessed != NAME_GUESS_UNKNOWN)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1122 text = g_string_append(text, "</span>");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1123
18795
883c18d31bf4 Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18785
diff changeset
1124 style = xmlnode_get_attrib(text_node, "Style");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1125
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1126 tmp = xmlnode_get_data(text_node);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1127 if (style && *style) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1128 text = g_string_append(text, "<span style=\"");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1129 text = g_string_append(text, style);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1130 text = g_string_append(text, "\">");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1131 text = g_string_append(text, tmp);
18372
47ff5e98b371 Make the MSN logger set flags and ues <br> instead of \n. This fixes the
Richard Laager <rlaager@wiktel.com>
parents: 18371
diff changeset
1132 text = g_string_append(text, "</span><br>");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1133 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1134 text = g_string_append(text, tmp);
18372
47ff5e98b371 Make the MSN logger set flags and ues <br> instead of \n. This fixes the
Richard Laager <rlaager@wiktel.com>
parents: 18371
diff changeset
1135 text = g_string_append(text, "<br>");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1136 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1137 g_free(tmp);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1138 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1139
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1140 data->text = text;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1141
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1142 return text->str;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1143 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1144
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
1145 static int msn_logger_size (PurpleLog *log)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1146 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1147 char *text;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1148 size_t size;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1149
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1150 g_return_val_if_fail(log != NULL, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1151
16430
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
1152 if (purple_prefs_get_bool("/plugins/core/log_reader/fast_sizes"))
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1153 return 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1154
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1155 text = msn_logger_read(log, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1156 size = strlen(text);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1157 g_free(text);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1158
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1159 return size;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1160 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1161
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
1162 static void msn_logger_finalize(PurpleLog *log)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1163 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1164 struct msn_logger_data *data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1165
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1166 g_return_if_fail(log != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1167
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1168 data = log->logger_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1169
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1170 if (data->last_log)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1171 xmlnode_free(data->root);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1172
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1173 if (data->text)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1174 g_string_free(data->text, FALSE);
18246
e236b3bd4542 Eliminate some leaks.
Richard Laager <rlaager@wiktel.com>
parents: 18245
diff changeset
1175
e236b3bd4542 Eliminate some leaks.
Richard Laager <rlaager@wiktel.com>
parents: 18245
diff changeset
1176 g_free(data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1177 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1178
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1179
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1180 /*****************************************************************************
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1181 * Trillian Logger *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1182 *****************************************************************************/
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1183
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1184 /* The trillian logger doesn't write logs, only reads them. This is to include
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1185 * Trillian logs in the log viewer transparently.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1186 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1187
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
1188 static PurpleLogLogger *trillian_logger;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
1189 static void trillian_logger_finalize(PurpleLog *log);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1190
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1191 struct trillian_logger_data {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
1192 char *path; /* FIXME: Change this to use PurpleStringref like log.c:old_logger_list */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1193 int offset;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1194 int length;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1195 char *their_nickname;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1196 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1197
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
1198 static GList *trillian_logger_list(PurpleLogType type, const char *sn, PurpleAccount *account)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1199 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1200 GList *list = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1201 const char *logdir;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
1202 PurplePlugin *plugin;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
1203 PurplePluginProtocolInfo *prpl_info;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1204 char *prpl_name;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1205 const char *buddy_name;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1206 char *filename;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1207 char *path;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1208 GError *error = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1209 gchar *contents = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1210 gsize length;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1211 gchar *line;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1212 gchar *c;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1213
18795
883c18d31bf4 Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18785
diff changeset
1214 g_return_val_if_fail(sn != NULL, NULL);
883c18d31bf4 Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18785
diff changeset
1215 g_return_val_if_fail(account != NULL, NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1216
16430
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
1217 logdir = purple_prefs_get_string("/plugins/core/log_reader/trillian/log_directory");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1218
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1219 /* By clearing the log directory path, this logger can be (effectively) disabled. */
18795
883c18d31bf4 Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18785
diff changeset
1220 if (!logdir || !*logdir)
883c18d31bf4 Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18785
diff changeset
1221 return NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1222
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
1223 plugin = purple_find_prpl(purple_account_get_protocol_id(account));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1224 if (!plugin)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1225 return NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1226
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
1227 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1228 if (!prpl_info->list_icon)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1229 return NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1230
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1231 prpl_name = g_ascii_strup(prpl_info->list_icon(account, NULL), -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1232
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
1233 buddy_name = purple_normalize(account, sn);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1234
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1235 filename = g_strdup_printf("%s.log", buddy_name);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1236 path = g_build_filename(
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1237 logdir, prpl_name, filename, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1238
18245
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
1239 purple_debug_info("Trillian log list", "Reading %s\n", path);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1240 /* FIXME: There's really no need to read the entire file at once.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1241 * See src/log.c:old_logger_list for a better approach.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1242 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1243 if (!g_file_get_contents(path, &contents, &length, &error)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1244 if (error) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1245 g_error_free(error);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1246 error = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1247 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1248 g_free(path);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1249
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1250 path = g_build_filename(
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1251 logdir, prpl_name, "Query", filename, NULL);
18245
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
1252 purple_debug_info("Trillian log list", "Reading %s\n", path);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1253 if (!g_file_get_contents(path, &contents, &length, &error)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1254 if (error)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1255 g_error_free(error);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1256 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1257 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1258 g_free(filename);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1259
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1260 if (contents) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1261 struct trillian_logger_data *data = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1262 int offset = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1263 int last_line_offset = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1264
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1265 line = contents;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1266 c = contents;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1267 while (*c) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1268 offset++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1269
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1270 if (*c != '\n') {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1271 c++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1272 continue;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1273 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1274
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1275 *c = '\0';
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
1276 if (purple_str_has_prefix(line, "Session Close ")) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1277 if (data && !data->length) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1278 if (!(data->length = last_line_offset - data->offset)) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1279 /* This log had no data, so we remove it. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1280 GList *last = g_list_last(list);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1281
18245
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
1282 purple_debug_info("Trillian log list",
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
1283 "Empty log. Offset %i\n", data->offset);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1284
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
1285 trillian_logger_finalize((PurpleLog *)last->data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1286 list = g_list_delete_link(list, last);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1287 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1288 }
18108
c0cd4d84ba52 Fix a mistake noticed by Michael Shkutkov and add a comment explaining the code.
Richard Laager <rlaager@wiktel.com>
parents: 17531
diff changeset
1289 } else if (line[0] && line[1] && line[2] &&
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
1290 purple_str_has_prefix(&line[3], "sion Start ")) {
18108
c0cd4d84ba52 Fix a mistake noticed by Michael Shkutkov and add a comment explaining the code.
Richard Laager <rlaager@wiktel.com>
parents: 17531
diff changeset
1291 /* The conditional is to make sure we're not reading off
c0cd4d84ba52 Fix a mistake noticed by Michael Shkutkov and add a comment explaining the code.
Richard Laager <rlaager@wiktel.com>
parents: 17531
diff changeset
1292 * the end of the string. We don't want strlen(), as that'd
c0cd4d84ba52 Fix a mistake noticed by Michael Shkutkov and add a comment explaining the code.
Richard Laager <rlaager@wiktel.com>
parents: 17531
diff changeset
1293 * have to count the whole string needlessly.
18248
ab761acbc614 Remove trailing whitespace.
Richard Laager <rlaager@wiktel.com>
parents: 18247
diff changeset
1294 *
18108
c0cd4d84ba52 Fix a mistake noticed by Michael Shkutkov and add a comment explaining the code.
Richard Laager <rlaager@wiktel.com>
parents: 17531
diff changeset
1295 * The odd check here is because a Session Start at the
c0cd4d84ba52 Fix a mistake noticed by Michael Shkutkov and add a comment explaining the code.
Richard Laager <rlaager@wiktel.com>
parents: 17531
diff changeset
1296 * beginning of the file can be overwritten with a UTF-8
c0cd4d84ba52 Fix a mistake noticed by Michael Shkutkov and add a comment explaining the code.
Richard Laager <rlaager@wiktel.com>
parents: 17531
diff changeset
1297 * byte order mark. Yes, it's weird.
c0cd4d84ba52 Fix a mistake noticed by Michael Shkutkov and add a comment explaining the code.
Richard Laager <rlaager@wiktel.com>
parents: 17531
diff changeset
1298 */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1299 char *their_nickname = line;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1300 char *timestamp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1301
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1302 if (data && !data->length)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1303 data->length = last_line_offset - data->offset;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1304
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1305 while (*their_nickname && (*their_nickname != ':'))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1306 their_nickname++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1307 their_nickname++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1308
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1309 /* This code actually has nothing to do with
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1310 * the timestamp YET. I'm simply using this
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1311 * variable for now to NUL-terminate the
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1312 * their_nickname string.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1313 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1314 timestamp = their_nickname;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1315 while (*timestamp && *timestamp != ')')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1316 timestamp++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1317
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1318 if (*timestamp == ')') {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1319 char *month;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1320 struct tm tm;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1321
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1322 *timestamp = '\0';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1323 if (line[0] && line[1] && line[2])
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1324 timestamp += 3;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1325
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1326 /* Now we start dealing with the timestamp. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1327
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1328 /* Skip over the day name. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1329 while (*timestamp && (*timestamp != ' '))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1330 timestamp++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1331 *timestamp = '\0';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1332 timestamp++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1333
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1334 /* Parse out the month. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1335 month = timestamp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1336 while (*timestamp && (*timestamp != ' '))
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1337 timestamp++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1338 *timestamp = '\0';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1339 timestamp++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1340
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1341 /* Parse the day, time, and year. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1342 if (sscanf(timestamp, "%u %u:%u:%u %u",
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1343 &tm.tm_mday, &tm.tm_hour,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1344 &tm.tm_min, &tm.tm_sec,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1345 &tm.tm_year) != 5) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1346
18245
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
1347 purple_debug_error("Trillian log timestamp parse",
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
1348 "Session Start parsing error\n");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1349 } else {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
1350 PurpleLog *log;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1351
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1352 tm.tm_year -= 1900;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1353
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1354 /* Let the C library deal with
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1355 * daylight savings time.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1356 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1357 tm.tm_isdst = -1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1358
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1359 /* Ugly hack, in case current locale
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1360 * is not English. This code is taken
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1361 * from log.c.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1362 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1363 if (strcmp(month, "Jan") == 0) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1364 tm.tm_mon= 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1365 } else if (strcmp(month, "Feb") == 0) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1366 tm.tm_mon = 1;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1367 } else if (strcmp(month, "Mar") == 0) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1368 tm.tm_mon = 2;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1369 } else if (strcmp(month, "Apr") == 0) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1370 tm.tm_mon = 3;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1371 } else if (strcmp(month, "May") == 0) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1372 tm.tm_mon = 4;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1373 } else if (strcmp(month, "Jun") == 0) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1374 tm.tm_mon = 5;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1375 } else if (strcmp(month, "Jul") == 0) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1376 tm.tm_mon = 6;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1377 } else if (strcmp(month, "Aug") == 0) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1378 tm.tm_mon = 7;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1379 } else if (strcmp(month, "Sep") == 0) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1380 tm.tm_mon = 8;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1381 } else if (strcmp(month, "Oct") == 0) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1382 tm.tm_mon = 9;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1383 } else if (strcmp(month, "Nov") == 0) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1384 tm.tm_mon = 10;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1385 } else if (strcmp(month, "Dec") == 0) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1386 tm.tm_mon = 11;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1387 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1388
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1389 data = g_new0(
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1390 struct trillian_logger_data, 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1391 data->path = g_strdup(path);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1392 data->offset = offset;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1393 data->length = 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1394 data->their_nickname =
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1395 g_strdup(their_nickname);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1396
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1397 /* XXX: Look into this later... Should we pass in a struct tm? */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
1398 log = purple_log_new(PURPLE_LOG_IM,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1399 sn, account, NULL, mktime(&tm), NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1400 log->logger = trillian_logger;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1401 log->logger_data = data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1402
18249
35d981091506 Prepend to lists for performance, and use g_list_reverse when the list is
Richard Laager <rlaager@wiktel.com>
parents: 18248
diff changeset
1403 list = g_list_prepend(list, log);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1404 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1405 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1406 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1407 c++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1408 line = c;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1409 last_line_offset = offset;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1410 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1411
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1412 g_free(contents);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1413 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1414 g_free(path);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1415
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1416 g_free(prpl_name);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1417
18249
35d981091506 Prepend to lists for performance, and use g_list_reverse when the list is
Richard Laager <rlaager@wiktel.com>
parents: 18248
diff changeset
1418 return g_list_reverse(list);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1419 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1420
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
1421 static char * trillian_logger_read (PurpleLog *log, PurpleLogReadFlags *flags)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1422 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1423 struct trillian_logger_data *data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1424 char *read;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1425 FILE *file;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
1426 PurpleBuddy *buddy;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1427 char *escaped;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1428 GString *formatted;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1429 char *c;
17528
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1430 const char *line;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1431
18795
883c18d31bf4 Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18785
diff changeset
1432 if (flags != NULL)
883c18d31bf4 Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18785
diff changeset
1433 *flags = PURPLE_LOG_READ_NO_NEWLINE;
18785
3cc77409b858 bug with flags variable initialization was fixed
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18765
diff changeset
1434
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1435 g_return_val_if_fail(log != NULL, g_strdup(""));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1436
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1437 data = log->logger_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1438
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1439 g_return_val_if_fail(data->path != NULL, g_strdup(""));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1440 g_return_val_if_fail(data->length > 0, g_strdup(""));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1441 g_return_val_if_fail(data->their_nickname != NULL, g_strdup(""));
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1442
18245
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
1443 purple_debug_info("Trillian log read", "Reading %s\n", data->path);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1444
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1445 read = g_malloc(data->length + 2);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1446
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1447 file = g_fopen(data->path, "rb");
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1448 fseek(file, data->offset, SEEK_SET);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1449 fread(read, data->length, 1, file);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1450 fclose(file);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1451
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1452 if (read[data->length-1] == '\n') {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1453 read[data->length] = '\0';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1454 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1455 read[data->length] = '\n';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1456 read[data->length+1] = '\0';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1457 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1458
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1459 /* Load miscellaneous data. */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
1460 buddy = purple_find_buddy(log->account, log->name);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1461
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1462 escaped = g_markup_escape_text(read, -1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1463 g_free(read);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1464 read = escaped;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1465
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1466 /* Apply formatting... */
17529
c529c95e7733 Size the formatting string first, to avoid unnecessary resizing.
Richard Laager <rlaager@wiktel.com>
parents: 17528
diff changeset
1467 formatted = g_string_sized_new(strlen(read));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1468 c = read;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1469 line = read;
17528
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1470 while (c)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1471 {
17528
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1472 const char *link;
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1473 const char *footer = NULL;
17531
21773944db4b Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents: 17530
diff changeset
1474 GString *temp = NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1475
17531
21773944db4b Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents: 17530
diff changeset
1476 if ((c = strstr(c, "\n")))
21773944db4b Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents: 17530
diff changeset
1477 {
17528
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1478 *c = '\0';
17531
21773944db4b Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents: 17530
diff changeset
1479 c++;
17528
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1480 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1481
17528
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1482 /* Convert links.
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1483 *
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1484 * The format is (Link: URL)URL
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1485 * So, I want to find each occurance of "(Link: " and replace that chunk with:
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1486 * <a href="
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1487 * Then, replace the next ")" with:
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1488 * ">
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1489 * Then, replace the next " " (or add this if the end-of-line is reached) with:
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1490 * </a>
18248
ab761acbc614 Remove trailing whitespace.
Richard Laager <rlaager@wiktel.com>
parents: 18247
diff changeset
1491 *
17528
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1492 * As implemented, this isn't perfect, but it should cover common cases.
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1493 */
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1494 while (line && (link = strstr(line, "(Link: ")))
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1495 {
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1496 const char *tmp = link;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1497
17528
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1498 link += 7;
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1499 if (*link)
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1500 {
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1501 char *end_paren;
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1502 char *space;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1503
17528
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1504 if (!(end_paren = strstr(link, ")")))
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1505 {
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1506 /* Something is not as we expect. Bail out. */
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1507 break;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1508 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1509
17531
21773944db4b Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents: 17530
diff changeset
1510 if (!temp)
21773944db4b Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents: 17530
diff changeset
1511 temp = g_string_sized_new(c ? (c - 1 - line) : strlen(line));
21773944db4b Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents: 17530
diff changeset
1512
17528
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1513 g_string_append_len(temp, line, (tmp - line));
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1514
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1515 /* Start an <a> tag. */
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1516 g_string_append(temp, "<a href=\"");
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1517
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1518 /* Append up to the ) */
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1519 g_string_append_len(temp, link, end_paren - link);
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1520
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1521 /* Finish the <a> tag. */
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1522 g_string_append(temp, "\">");
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1523
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1524 /* The \r is a bit of a hack to keep there from being a \r in
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1525 * the link text, which may not matter. */
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1526 if ((space = strstr(end_paren, " ")) || (space = strstr(end_paren, "\r")))
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1527 {
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1528 g_string_append_len(temp, end_paren + 1, space - end_paren - 1);
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1529
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1530 /* Close the <a> tag. */
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1531 g_string_append(temp, "</a>");
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1532
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1533 space++;
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1534 }
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1535 else
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1536 {
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1537 /* There is no space before the end of the line. */
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1538 g_string_append(temp, end_paren + 1);
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1539 /* Close the <a> tag. */
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1540 g_string_append(temp, "</a>");
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1541 }
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1542 line = space;
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1543 }
17530
a6594c34635b Bail out to avoid an infinite loop in an extreme corner case.
Richard Laager <rlaager@wiktel.com>
parents: 17529
diff changeset
1544 else
a6594c34635b Bail out to avoid an infinite loop in an extreme corner case.
Richard Laager <rlaager@wiktel.com>
parents: 17529
diff changeset
1545 {
a6594c34635b Bail out to avoid an infinite loop in an extreme corner case.
Richard Laager <rlaager@wiktel.com>
parents: 17529
diff changeset
1546 /* Something is not as we expect. Bail out. */
a6594c34635b Bail out to avoid an infinite loop in an extreme corner case.
Richard Laager <rlaager@wiktel.com>
parents: 17529
diff changeset
1547 break;
a6594c34635b Bail out to avoid an infinite loop in an extreme corner case.
Richard Laager <rlaager@wiktel.com>
parents: 17529
diff changeset
1548 }
17528
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1549 }
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1550
17531
21773944db4b Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents: 17530
diff changeset
1551 if (temp)
21773944db4b Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents: 17530
diff changeset
1552 {
21773944db4b Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents: 17530
diff changeset
1553 if (line)
21773944db4b Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents: 17530
diff changeset
1554 g_string_append(temp, line);
21773944db4b Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents: 17530
diff changeset
1555 line = temp->str;
17528
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1556 }
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1557
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1558 if (*line == '[') {
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1559 const char *timestamp;
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1560
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1561 if ((timestamp = strstr(line, "]"))) {
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1562 line++;
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1563 /* TODO: Parse the timestamp and convert it to Purple's format. */
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1564 g_string_append(formatted, "<font size=\"2\">(");
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1565 g_string_append_len(formatted, line, (timestamp - line));
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1566 g_string_append(formatted,")</font> ");
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1567 line = timestamp + 1;
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1568 if (line[0] && line[1])
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1569 line++;
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1570 }
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1571
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1572 if (purple_str_has_prefix(line, "*** ")) {
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1573 line += (sizeof("*** ") - 1);
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1574 g_string_append(formatted, "<b>");
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1575 footer = "</b>";
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1576 if (purple_str_has_prefix(line, "NOTE: This user is offline.")) {
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1577 line = _("User is offline.");
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1578 } else if (purple_str_has_prefix(line,
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1579 "NOTE: Your status is currently set to ")) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1580
17528
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1581 line += (sizeof("NOTE: ") - 1);
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1582 } else if (purple_str_has_prefix(line, "Auto-response sent to ")) {
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1583 g_string_append(formatted, _("Auto-response sent:"));
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1584 while (*line && *line != ':')
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1585 line++;
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1586 if (*line)
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1587 line++;
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1588 g_string_append(formatted, "</b>");
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1589 footer = NULL;
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1590 } else if (strstr(line, " signed off ")) {
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1591 if (buddy != NULL && buddy->alias)
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1592 g_string_append_printf(formatted,
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1593 _("%s has signed off."), buddy->alias);
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1594 else
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1595 g_string_append_printf(formatted,
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1596 _("%s has signed off."), log->name);
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1597 line = "";
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1598 } else if (strstr(line, " signed on ")) {
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1599 if (buddy != NULL && buddy->alias)
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1600 g_string_append(formatted, buddy->alias);
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1601 else
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1602 g_string_append(formatted, log->name);
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1603 line = " logged in.";
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1604 } else if (purple_str_has_prefix(line,
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1605 "One or more messages may have been undeliverable.")) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1606
17528
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1607 g_string_append(formatted,
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1608 "<span style=\"color: #ff0000;\">");
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1609 g_string_append(formatted,
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1610 _("One or more messages may have been "
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1611 "undeliverable."));
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1612 line = "";
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1613 footer = "</span></b>";
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1614 } else if (purple_str_has_prefix(line,
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1615 "You have been disconnected.")) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1616
17528
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1617 g_string_append(formatted,
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1618 "<span style=\"color: #ff0000;\">");
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1619 g_string_append(formatted,
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1620 _("You were disconnected from the server."));
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1621 line = "";
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1622 footer = "</span></b>";
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1623 } else if (purple_str_has_prefix(line,
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1624 "You are currently disconnected.")) {
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1625
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1626 g_string_append(formatted,
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1627 "<span style=\"color: #ff0000;\">");
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1628 line = _("You are currently disconnected. Messages "
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1629 "will not be received unless you are "
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1630 "logged in.");
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1631 footer = "</span></b>";
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1632 } else if (purple_str_has_prefix(line,
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1633 "Your previous message has not been sent.")) {
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1634
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1635 g_string_append(formatted,
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1636 "<span style=\"color: #ff0000;\">");
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1637
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1638 if (purple_str_has_prefix(line,
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1639 "Your previous message has not been sent. "
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1640 "Reason: Maximum length exceeded.")) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1641
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1642 g_string_append(formatted,
17528
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1643 _("Message could not be sent because "
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1644 "the maximum length was exceeded."));
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1645 line = "";
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1646 } else {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1647 g_string_append(formatted,
17528
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1648 _("Message could not be sent."));
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1649 line += (sizeof(
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1650 "Your previous message "
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1651 "has not been sent. ") - 1);
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1652 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1653
17528
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1654 footer = "</span></b>";
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1655 }
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1656 } else if (purple_str_has_prefix(line, data->their_nickname)) {
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1657 if (buddy != NULL && buddy->alias) {
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1658 line += strlen(data->their_nickname) + 2;
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1659 g_string_append_printf(formatted,
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1660 "<span style=\"color: #A82F2F;\">"
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1661 "<b>%s</b></span>: ", buddy->alias);
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1662 }
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1663 } else {
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1664 const char *line2 = strstr(line, ":");
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1665 if (line2) {
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1666 const char *acct_name;
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1667 line2++;
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1668 line = line2;
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1669 acct_name = purple_account_get_alias(log->account);
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1670 if (!acct_name)
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1671 acct_name = purple_account_get_username(log->account);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1672
17528
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1673 g_string_append_printf(formatted,
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1674 "<span style=\"color: #16569E;\">"
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1675 "<b>%s</b></span>:", acct_name);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1676 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1677 }
17528
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1678 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1679
17528
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1680 g_string_append(formatted, line);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1681
17531
21773944db4b Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents: 17530
diff changeset
1682 line = c;
21773944db4b Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents: 17530
diff changeset
1683 if (temp)
21773944db4b Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents: 17530
diff changeset
1684 g_string_free(temp, TRUE);
21773944db4b Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents: 17530
diff changeset
1685
17528
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1686 if (footer)
beeef78409b2 A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents: 17467
diff changeset
1687 g_string_append(formatted, footer);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1688
18360
d8f783ed28d3 Make the Trillian logger set flags properly, and use <br> instead of \n for
Richard Laager <rlaager@wiktel.com>
parents: 18359
diff changeset
1689 g_string_append(formatted, "<br>");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1690 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1691
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1692 g_free(read);
18360
d8f783ed28d3 Make the Trillian logger set flags properly, and use <br> instead of \n for
Richard Laager <rlaager@wiktel.com>
parents: 18359
diff changeset
1693
d8f783ed28d3 Make the Trillian logger set flags properly, and use <br> instead of \n for
Richard Laager <rlaager@wiktel.com>
parents: 18359
diff changeset
1694 /* XXX: TODO: What can we do about removing \r characters?
d8f783ed28d3 Make the Trillian logger set flags properly, and use <br> instead of \n for
Richard Laager <rlaager@wiktel.com>
parents: 18359
diff changeset
1695 * XXX: TODO: and will that allow us to avoid this
d8f783ed28d3 Make the Trillian logger set flags properly, and use <br> instead of \n for
Richard Laager <rlaager@wiktel.com>
parents: 18359
diff changeset
1696 * XXX: TODO: g_strchomp(), or is that unrelated? */
17531
21773944db4b Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents: 17530
diff changeset
1697 /* XXX: TODO: Avoid this g_strchomp() */
21773944db4b Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents: 17530
diff changeset
1698 return g_strchomp(g_string_free(formatted, FALSE));
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1699 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1700
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
1701 static int trillian_logger_size (PurpleLog *log)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1702 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1703 struct trillian_logger_data *data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1704 char *text;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1705 size_t size;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1706
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1707 g_return_val_if_fail(log != NULL, 0);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1708
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1709 data = log->logger_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1710
16430
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
1711 if (purple_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1712 return data ? data->length : 0;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1713 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1714
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1715 text = trillian_logger_read(log, NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1716 size = strlen(text);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1717 g_free(text);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1718
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1719 return size;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1720 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1721
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
1722 static void trillian_logger_finalize(PurpleLog *log)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1723 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1724 struct trillian_logger_data *data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1725
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1726 g_return_if_fail(log != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1727
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1728 data = log->logger_data;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1729
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1730 g_free(data->path);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1731 g_free(data->their_nickname);
18246
e236b3bd4542 Eliminate some leaks.
Richard Laager <rlaager@wiktel.com>
parents: 18245
diff changeset
1732 g_free(data);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1733 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1734
17979
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1735 /*****************************************************************************
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1736 * QIP Logger *
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1737 *****************************************************************************/
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1738
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1739 /* The QIP logger doesn't write logs, only reads them. This is to include
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1740 * QIP logs in the log viewer transparently.
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1741 */
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1742 #define QIP_LOG_DELIMITER "--------------------------------------"
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1743 #define QIP_LOG_IN_MESSAGE (QIP_LOG_DELIMITER "<-")
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1744 #define QIP_LOG_OUT_MESSAGE (QIP_LOG_DELIMITER ">-")
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1745 #define QIP_LOG_IN_MESSAGE_ESC (QIP_LOG_DELIMITER "&lt;-")
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1746 #define QIP_LOG_OUT_MESSAGE_ESC (QIP_LOG_DELIMITER "&gt;-")
18176
b14dfa2f49a1 creat new log if difference between current and previous message more then predefined constant (currently one hour)
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18175
diff changeset
1747 #define QIP_LOG_TIMEOUT (60*60)
17979
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1748
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1749 static PurpleLogLogger *qip_logger;
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1750
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1751 struct qip_logger_data {
18248
ab761acbc614 Remove trailing whitespace.
Richard Laager <rlaager@wiktel.com>
parents: 18247
diff changeset
1752
17979
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1753 char *path; /* FIXME: Change this to use PurpleStringref like log.c:old_logger_list */
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1754 int offset;
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1755 int length;
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1756 };
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1757
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1758 static GList *qip_logger_list(PurpleLogType type, const char *sn, PurpleAccount *account)
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1759 {
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1760 GList *list = NULL;
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1761 const char *logdir;
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1762 PurplePlugin *plugin;
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1763 PurplePluginProtocolInfo *prpl_info;
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1764 char *username;
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1765 char *filename;
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1766 char *path;
18251
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1767 char *contents;
18247
97671eb4991e Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents: 18246
diff changeset
1768 struct qip_logger_data *data = NULL;
97671eb4991e Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents: 18246
diff changeset
1769 struct tm prev_tm;
18254
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1770 struct tm tm;
18247
97671eb4991e Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents: 18246
diff changeset
1771 gboolean prev_tm_init = FALSE;
18254
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1772 gboolean main_cycle = TRUE;
18247
97671eb4991e Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents: 18246
diff changeset
1773 char *c;
97671eb4991e Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents: 18246
diff changeset
1774 char *start_log;
18254
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1775 char *new_line;
18247
97671eb4991e Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents: 18246
diff changeset
1776 int offset = 0;
18255
507fb436d8c0 optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18254
diff changeset
1777 GError *error;
17979
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1778
18795
883c18d31bf4 Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18785
diff changeset
1779 g_return_val_if_fail(sn != NULL, NULL);
883c18d31bf4 Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18785
diff changeset
1780 g_return_val_if_fail(account != NULL, NULL);
17979
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1781
18247
97671eb4991e Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents: 18246
diff changeset
1782 /* QIP only supports ICQ. */
17979
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1783 if (strcmp(account->protocol_id, "prpl-icq"))
18795
883c18d31bf4 Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18785
diff changeset
1784 return NULL;
17979
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1785
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1786 logdir = purple_prefs_get_string("/plugins/core/log_reader/qip/log_directory");
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1787
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1788 /* By clearing the log directory path, this logger can be (effectively) disabled. */
18795
883c18d31bf4 Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18785
diff changeset
1789 if (!logdir || !*logdir)
883c18d31bf4 Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18785
diff changeset
1790 return NULL;
17979
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1791
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1792 plugin = purple_find_prpl(purple_account_get_protocol_id(account));
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1793 if (!plugin)
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1794 return NULL;
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1795
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1796 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin);
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1797 if (!prpl_info->list_icon)
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1798 return NULL;
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1799
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1800 username = g_strdup(purple_normalize(account, account->username));
18247
97671eb4991e Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents: 18246
diff changeset
1801 filename = g_strdup_printf("%s.txt", purple_normalize(account, sn));
97671eb4991e Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents: 18246
diff changeset
1802 path = g_build_filename(logdir, username, "History", filename, NULL);
97671eb4991e Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents: 18246
diff changeset
1803 g_free(username);
97671eb4991e Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents: 18246
diff changeset
1804 g_free(filename);
97671eb4991e Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents: 18246
diff changeset
1805
18255
507fb436d8c0 optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18254
diff changeset
1806 purple_debug_info("QIP logger", "Reading %s\n", path);
507fb436d8c0 optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18254
diff changeset
1807
507fb436d8c0 optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18254
diff changeset
1808 error = NULL;
507fb436d8c0 optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18254
diff changeset
1809 if (!g_file_get_contents(path, &contents, NULL, &error)) {
507fb436d8c0 optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18254
diff changeset
1810 purple_debug_error("QIP logger",
507fb436d8c0 optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18254
diff changeset
1811 "Couldn't read file %s: %s \n", path, error->message);
507fb436d8c0 optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18254
diff changeset
1812 g_error_free(error);
18247
97671eb4991e Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents: 18246
diff changeset
1813 g_free(path);
97671eb4991e Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents: 18246
diff changeset
1814 return list;
97671eb4991e Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents: 18246
diff changeset
1815 }
97671eb4991e Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents: 18246
diff changeset
1816
97671eb4991e Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents: 18246
diff changeset
1817 c = contents;
97671eb4991e Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents: 18246
diff changeset
1818 start_log = contents;
18254
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1819 while (main_cycle) {
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1820
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1821 gboolean add_new_log = FALSE;
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1822
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1823 if (*c) {
18255
507fb436d8c0 optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18254
diff changeset
1824 if (purple_str_has_prefix(c, QIP_LOG_IN_MESSAGE) ||
507fb436d8c0 optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18254
diff changeset
1825 purple_str_has_prefix(c, QIP_LOG_OUT_MESSAGE)) {
18254
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1826
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1827 char *tmp;
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1828
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1829 new_line = c;
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1830
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1831 /* find EOL */
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1832 c = strstr(c, "\n");
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1833 c++;
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1834
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1835 /* Find the last '(' character. */
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1836 if ((tmp = strstr(c, "\n")) != NULL) {
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1837 while (*tmp && *tmp != '(') --tmp;
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1838 c = tmp;
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1839 } else {
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1840 while (*c)
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1841 c++;
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1842 c--;
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1843 c = g_strrstr(c, "(");
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1844 }
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1845
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1846 if (c != NULL) {
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1847 const char *timestamp = ++c;
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1848
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1849 /* Parse the time, day, month and year */
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1850 if (sscanf(timestamp, "%u:%u:%u %u/%u/%u",
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1851 &tm.tm_hour, &tm.tm_min, &tm.tm_sec,
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1852 &tm.tm_mday, &tm.tm_mon, &tm.tm_year) != 6) {
18247
97671eb4991e Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents: 18246
diff changeset
1853
97671eb4991e Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents: 18246
diff changeset
1854 purple_debug_error("QIP logger list",
18254
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1855 "Parsing timestamp error\n");
18247
97671eb4991e Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents: 18246
diff changeset
1856 } else {
18254
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1857 tm.tm_mon -= 1;
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1858 tm.tm_year -= 1900;
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1859
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1860 /* Let the C library deal with
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1861 * daylight savings time. */
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1862 tm.tm_isdst = -1;
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1863
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1864 if (!prev_tm_init) {
18247
97671eb4991e Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents: 18246
diff changeset
1865 prev_tm = tm;
18254
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1866 prev_tm_init = TRUE;
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1867 } else {
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1868 add_new_log = difftime(mktime(&tm), mktime(&prev_tm)) > QIP_LOG_TIMEOUT;
18176
b14dfa2f49a1 creat new log if difference between current and previous message more then predefined constant (currently one hour)
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18175
diff changeset
1869 }
b14dfa2f49a1 creat new log if difference between current and previous message more then predefined constant (currently one hour)
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18175
diff changeset
1870 }
b14dfa2f49a1 creat new log if difference between current and previous message more then predefined constant (currently one hour)
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18175
diff changeset
1871 }
b14dfa2f49a1 creat new log if difference between current and previous message more then predefined constant (currently one hour)
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18175
diff changeset
1872 }
18247
97671eb4991e Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents: 18246
diff changeset
1873 } else {
18254
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1874 add_new_log = TRUE;
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1875 main_cycle = FALSE;
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1876 new_line = c;
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1877 }
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1878
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1879 /* adding log */
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1880 if (add_new_log && prev_tm_init) {
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1881 PurpleLog *log;
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1882
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1883 /* filling data */
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1884 data = g_new0(struct qip_logger_data, 1);
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1885 data->path = g_strdup(path);
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1886 data->length = new_line - start_log;
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1887 data->offset = offset;
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1888 offset += data->length;
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1889 purple_debug_info("QIP logger list",
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1890 "Creating log: path = (%s); length = (%d); offset = (%d)\n",
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1891 data->path, data->length, data->offset);
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1892
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1893 /* XXX: Look into this later... Should we pass in a struct tm? */
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1894 log = purple_log_new(PURPLE_LOG_IM, sn, account,
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1895 NULL, mktime(&prev_tm), NULL);
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1896
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1897 log->logger = qip_logger;
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1898 log->logger_data = data;
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1899
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1900 list = g_list_prepend(list, log);
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1901
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1902 prev_tm = tm;
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1903 start_log = new_line;
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1904 }
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1905
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1906 if (*c) {
991f33e9e1a4 avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18253
diff changeset
1907 /* find EOF */
18247
97671eb4991e Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents: 18246
diff changeset
1908 c = strstr(c, "\n");
97671eb4991e Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents: 18246
diff changeset
1909 c++;
18172
3aa11b0169c9 Converting all qip logs into UTF8
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18171
diff changeset
1910 }
18247
97671eb4991e Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents: 18246
diff changeset
1911 }
18248
ab761acbc614 Remove trailing whitespace.
Richard Laager <rlaager@wiktel.com>
parents: 18247
diff changeset
1912
18247
97671eb4991e Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents: 18246
diff changeset
1913 g_free(contents);
17979
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1914 g_free(path);
18249
35d981091506 Prepend to lists for performance, and use g_list_reverse when the list is
Richard Laager <rlaager@wiktel.com>
parents: 18248
diff changeset
1915 return g_list_reverse(list);
17979
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1916 }
18248
ab761acbc614 Remove trailing whitespace.
Richard Laager <rlaager@wiktel.com>
parents: 18247
diff changeset
1917
18251
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1918 static char *qip_logger_read(PurpleLog *log, PurpleLogReadFlags *flags)
17979
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1919 {
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1920 struct qip_logger_data *data;
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1921 PurpleBuddy *buddy;
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1922 GString *formatted;
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1923 char *c;
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1924 const char *line;
18251
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1925 gchar *contents;
18255
507fb436d8c0 optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18254
diff changeset
1926 GError *error;
507fb436d8c0 optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18254
diff changeset
1927 char *utf8_string;
18256
54251fa6389d reading only necessary part of log file using g_fopen/fseek/fread
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18255
diff changeset
1928 FILE *file;
54251fa6389d reading only necessary part of log file using g_fopen/fseek/fread
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18255
diff changeset
1929
18795
883c18d31bf4 Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18785
diff changeset
1930 if (flags != NULL)
883c18d31bf4 Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents: 18785
diff changeset
1931 *flags = PURPLE_LOG_READ_NO_NEWLINE;
18785
3cc77409b858 bug with flags variable initialization was fixed
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18765
diff changeset
1932
17979
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1933 g_return_val_if_fail(log != NULL, g_strdup(""));
18248
ab761acbc614 Remove trailing whitespace.
Richard Laager <rlaager@wiktel.com>
parents: 18247
diff changeset
1934
17979
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1935 data = log->logger_data;
18248
ab761acbc614 Remove trailing whitespace.
Richard Laager <rlaager@wiktel.com>
parents: 18247
diff changeset
1936
17979
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1937 g_return_val_if_fail(data->path != NULL, g_strdup(""));
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1938 g_return_val_if_fail(data->length > 0, g_strdup(""));
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
1939
18255
507fb436d8c0 optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18254
diff changeset
1940 error = NULL;
18256
54251fa6389d reading only necessary part of log file using g_fopen/fseek/fread
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18255
diff changeset
1941
54251fa6389d reading only necessary part of log file using g_fopen/fseek/fread
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18255
diff changeset
1942 contents = g_malloc(data->length + 2);
54251fa6389d reading only necessary part of log file using g_fopen/fseek/fread
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18255
diff changeset
1943
54251fa6389d reading only necessary part of log file using g_fopen/fseek/fread
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18255
diff changeset
1944 file = g_fopen(data->path, "rb");
54251fa6389d reading only necessary part of log file using g_fopen/fseek/fread
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18255
diff changeset
1945 g_return_val_if_fail(file != NULL, g_strdup(""));
54251fa6389d reading only necessary part of log file using g_fopen/fseek/fread
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18255
diff changeset
1946
54251fa6389d reading only necessary part of log file using g_fopen/fseek/fread
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18255
diff changeset
1947 fseek(file, data->offset, SEEK_SET);
54251fa6389d reading only necessary part of log file using g_fopen/fseek/fread
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18255
diff changeset
1948 fread(contents, data->length, 1, file);
54251fa6389d reading only necessary part of log file using g_fopen/fseek/fread
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18255
diff changeset
1949 fclose(file);
54251fa6389d reading only necessary part of log file using g_fopen/fseek/fread
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18255
diff changeset
1950
54251fa6389d reading only necessary part of log file using g_fopen/fseek/fread
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18255
diff changeset
1951 contents[data->length] = '\n';
54251fa6389d reading only necessary part of log file using g_fopen/fseek/fread
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18255
diff changeset
1952 contents[data->length + 1] = '\0';
18255
507fb436d8c0 optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18254
diff changeset
1953
507fb436d8c0 optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18254
diff changeset
1954 /* Convert file contents from Cp1251 to UTF-8 codeset */
507fb436d8c0 optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18254
diff changeset
1955 error = NULL;
507fb436d8c0 optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18254
diff changeset
1956 if (!(utf8_string = g_convert(contents, -1, "UTF-8", "Cp1251", NULL, NULL, &error))) {
507fb436d8c0 optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18254
diff changeset
1957 purple_debug_error("QIP logger",
507fb436d8c0 optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18254
diff changeset
1958 "Couldn't convert file %s to UTF-8: %s\n", data->path, error->message);
507fb436d8c0 optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18254
diff changeset
1959 g_error_free(error);
507fb436d8c0 optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18254
diff changeset
1960 g_free(contents);
507fb436d8c0 optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18254
diff changeset
1961 return g_strdup("");
507fb436d8c0 optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18254
diff changeset
1962 }
18251
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1963
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1964 g_free(contents);
18255
507fb436d8c0 optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18254
diff changeset
1965 contents = g_markup_escape_text(utf8_string, -1);
507fb436d8c0 optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18254
diff changeset
1966 g_free(utf8_string);
507fb436d8c0 optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18254
diff changeset
1967
507fb436d8c0 optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18254
diff changeset
1968 buddy = purple_find_buddy(log->account, log->name);
18251
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1969
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1970 /* Apply formatting... */
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1971 formatted = g_string_sized_new(data->length + 2);
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1972 c = contents;
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1973 line = contents;
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1974
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1975 while (*c) {
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1976 gboolean is_in_message = FALSE;
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1977
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1978 if (purple_str_has_prefix(line, QIP_LOG_IN_MESSAGE_ESC) ||
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1979 purple_str_has_prefix(line, QIP_LOG_OUT_MESSAGE_ESC)) {
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1980
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1981 char *tmp;
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1982 const char *buddy_name;
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1983
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1984 is_in_message = purple_str_has_prefix(line, QIP_LOG_IN_MESSAGE_ESC);
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1985
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1986 /* find EOL */
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1987 c = strstr(c, "\n");
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1988
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1989 /* XXX: Do we need buddy_name when we have buddy->alias? */
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1990 buddy_name = ++c;
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1991
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1992 /* Find the last '(' character. */
18252
6722bbd698ff using while cycle instead of g_strrstr, because g_strrstr doesn't work properly. g_strrstr finds the last '(' of the string, not the line.
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18251
diff changeset
1993 if ((tmp = strstr(c, "\n")) != NULL) {
6722bbd698ff using while cycle instead of g_strrstr, because g_strrstr doesn't work properly. g_strrstr finds the last '(' of the string, not the line.
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18251
diff changeset
1994 while (*tmp && *tmp != '(') --tmp;
6722bbd698ff using while cycle instead of g_strrstr, because g_strrstr doesn't work properly. g_strrstr finds the last '(' of the string, not the line.
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18251
diff changeset
1995 c = tmp;
6722bbd698ff using while cycle instead of g_strrstr, because g_strrstr doesn't work properly. g_strrstr finds the last '(' of the string, not the line.
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18251
diff changeset
1996 } else {
18251
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1997 while (*c)
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1998 c++;
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
1999 c--;
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2000 c = g_strrstr(c, "(");
18172
3aa11b0169c9 Converting all qip logs into UTF8
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18171
diff changeset
2001 }
18251
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2002
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2003 if (c != NULL) {
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2004 const char *timestamp = c;
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2005 int hour;
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2006 int min;
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2007 int sec;
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2008
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2009 timestamp++;
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2010
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2011 /* Parse the time, day, month and year */
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2012 if (sscanf(timestamp, "%u:%u:%u",
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2013 &hour, &min, &sec) != 3) {
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2014 purple_debug_error("QIP logger read",
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2015 "Parsing timestamp error\n");
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2016 } else {
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2017 g_string_append(formatted, "<font size=\"2\">");
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2018 /* TODO: Figure out if we can do anything more locale-independent. */
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2019 g_string_append_printf(formatted,
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2020 "(%u:%02u:%02u) %cM ", hour % 12,
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2021 min, sec, (hour >= 12) ? 'P': 'A');
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2022 g_string_append(formatted, "</font> ");
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2023
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2024 if (is_in_message) {
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2025 if (buddy_name != NULL && buddy->alias) {
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2026 g_string_append_printf(formatted,
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2027 "<span style=\"color: #A82F2F;\">"
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2028 "<b>%s</b></span>: ", buddy->alias);
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2029 }
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2030 } else {
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2031 const char *acct_name;
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2032 acct_name = purple_account_get_alias(log->account);
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2033 if (!acct_name)
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2034 acct_name = purple_account_get_username(log->account);
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2035
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2036 g_string_append_printf(formatted,
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2037 "<span style=\"color: #16569E;\">"
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2038 "<b>%s</b></span>: ", acct_name);
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2039 }
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2040
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2041 /* find EOF */
18172
3aa11b0169c9 Converting all qip logs into UTF8
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18171
diff changeset
2042 c = strstr(c, "\n");
3aa11b0169c9 Converting all qip logs into UTF8
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18171
diff changeset
2043 line = ++c;
18170
179bb0ea89c7 Using g_file_get_contents instead of common file operations; all DEBUG_MESSAGEs were removed
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18169
diff changeset
2044 }
17979
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2045 }
18251
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2046 } else {
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2047 if ((c = strstr(c, "\n")))
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2048 *c = '\0';
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2049
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2050 if (line[0] != '\n' && line[0] != '\r') {
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2051
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2052 g_string_append(formatted, line);
18359
d1e7c8015308 using <br> as end of line instead of '\n' in QIP logger. With this change History plugin works fine
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18256
diff changeset
2053 g_string_append(formatted, "<br>");
18251
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2054 }
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2055 line = ++c;
17979
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2056 }
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2057 }
18170
179bb0ea89c7 Using g_file_get_contents instead of common file operations; all DEBUG_MESSAGEs were removed
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18169
diff changeset
2058 g_free(contents);
18251
8908e9ec2420 Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents: 18250
diff changeset
2059
17979
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2060 /* XXX: TODO: Avoid this g_strchomp() */
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2061 return g_strchomp(g_string_free(formatted, FALSE));
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2062 }
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2063
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2064 static int qip_logger_size (PurpleLog *log)
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2065 {
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2066 struct qip_logger_data *data;
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2067 char *text;
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2068 size_t size;
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2069
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2070 g_return_val_if_fail(log != NULL, 0);
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2071
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2072 data = log->logger_data;
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2073
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2074 if (purple_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) {
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2075 return data ? data->length : 0;
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2076 }
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2077
18248
ab761acbc614 Remove trailing whitespace.
Richard Laager <rlaager@wiktel.com>
parents: 18247
diff changeset
2078 text = qip_logger_read(log, NULL);
17979
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2079 size = strlen(text);
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2080 g_free(text);
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2081
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2082 return size;
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2083 }
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2084
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2085 static void qip_logger_finalize(PurpleLog *log)
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2086 {
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2087 struct qip_logger_data *data;
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2088
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2089 g_return_if_fail(log != NULL);
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2090
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2091 data = log->logger_data;
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2092
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2093 g_free(data->path);
18246
e236b3bd4542 Eliminate some leaks.
Richard Laager <rlaager@wiktel.com>
parents: 18245
diff changeset
2094 g_free(data);
17979
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2095 }
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2096
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2097 /*****************************************************************************
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2098 * Plugin Code *
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2099 *****************************************************************************/
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2100
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2101 static void
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2102 init_plugin(PurplePlugin *plugin)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2103 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2104 char *path;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2105 #ifdef _WIN32
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2106 char *folder;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2107 gboolean found = FALSE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2108 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2109
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2110 g_return_if_fail(plugin != NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2111
16430
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
2112 purple_prefs_add_none("/plugins/core/log_reader");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2113
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2114
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2115 /* Add general preferences. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2116
16430
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
2117 purple_prefs_add_bool("/plugins/core/log_reader/fast_sizes", FALSE);
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
2118 purple_prefs_add_bool("/plugins/core/log_reader/use_name_heuristics", TRUE);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2119
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2120
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2121 /* Add Adium log directory preference. */
16430
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
2122 purple_prefs_add_none("/plugins/core/log_reader/adium");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2123
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2124 /* Calculate default Adium log directory. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2125 #ifdef _WIN32
18250
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2126 purple_prefs_add_string("/plugins/core/log_reader/adium/log_directory", "");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2127 #else
18250
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2128 path = g_build_filename(purple_home_dir(), "Library", "Application Support",
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2129 "Adium 2.0", "Users", "Default", "Logs", NULL);
16430
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
2130 purple_prefs_add_string("/plugins/core/log_reader/adium/log_directory", path);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2131 g_free(path);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2132 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2133
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2134
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2135 /* Add Fire log directory preference. */
16430
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
2136 purple_prefs_add_none("/plugins/core/log_reader/fire");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2137
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2138 /* Calculate default Fire log directory. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2139 #ifdef _WIN32
18250
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2140 purple_prefs_add_string("/plugins/core/log_reader/fire/log_directory", "");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2141 #else
18250
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2142 path = g_build_filename(purple_home_dir(), "Library", "Application Support",
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2143 "Fire", "Sessions", NULL);
16430
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
2144 purple_prefs_add_string("/plugins/core/log_reader/fire/log_directory", path);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2145 g_free(path);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2146 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2147
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2148
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2149 /* Add Messenger Plus! log directory preference. */
16430
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
2150 purple_prefs_add_none("/plugins/core/log_reader/messenger_plus");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2151
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2152 /* Calculate default Messenger Plus! log directory. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2153 #ifdef _WIN32
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2154 folder = wpurple_get_special_folder(CSIDL_PERSONAL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2155 if (folder) {
18250
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2156 path = g_build_filename(folder, "My Chat Logs", NULL);
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2157 g_free(folder);
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2158 } else
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2159 path = g_strdup("");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2160 #else
18250
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2161 path = g_build_filename(PURPLE_LOG_READER_WINDOWS_MOUNT_POINT,
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2162 "Documents and Settings", g_get_user_name(),
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2163 "My Documents", "My Chat Logs", NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2164 #endif
16430
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
2165 purple_prefs_add_string("/plugins/core/log_reader/messenger_plus/log_directory", path);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2166 g_free(path);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2167
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2168
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2169 /* Add MSN Messenger log directory preference. */
16430
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
2170 purple_prefs_add_none("/plugins/core/log_reader/msn");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2171
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2172 /* Calculate default MSN message history directory. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2173 #ifdef _WIN32
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2174 folder = wpurple_get_special_folder(CSIDL_PERSONAL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2175 if (folder) {
18250
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2176 path = g_build_filename(folder, "My Received Files", NULL);
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2177 g_free(folder);
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2178 } else
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2179 path = g_strdup("");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2180 #else
18250
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2181 path = g_build_filename(PURPLE_LOG_READER_WINDOWS_MOUNT_POINT,
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2182 "Documents and Settings", g_get_user_name(),
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2183 "My Documents", "My Received Files", NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2184 #endif
16430
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
2185 purple_prefs_add_string("/plugins/core/log_reader/msn/log_directory", path);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2186 g_free(path);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2187
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2188
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2189 /* Add Trillian log directory preference. */
16430
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
2190 purple_prefs_add_none("/plugins/core/log_reader/trillian");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2191
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2192 #ifdef _WIN32
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2193 /* XXX: While a major hack, this is the most reliable way I could
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2194 * think of to determine the Trillian installation directory.
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2195 */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2196
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2197 path = NULL;
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2198 if ((folder = wpurple_read_reg_string(HKEY_CLASSES_ROOT, "Trillian.SkinZip\\shell\\Add\\command\\", NULL))) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2199 char *value = folder;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2200 char *temp;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2201
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2202 /* Break apart buffer. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2203 if (*value == '"') {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2204 value++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2205 temp = value;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2206 while (*temp && *temp != '"')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2207 temp++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2208 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2209 temp = value;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2210 while (*temp && *temp != ' ')
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2211 temp++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2212 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2213 *temp = '\0';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2214
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2215 /* Set path. */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2216 if (purple_str_has_suffix(value, "trillian.exe")) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2217 value[strlen(value) - (sizeof("trillian.exe") - 1)] = '\0';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2218 path = g_build_filename(value, "users", "default", "talk.ini", NULL);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2219 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2220 g_free(folder);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2221 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2222
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2223 if (!path) {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2224 char *folder = wpurple_get_special_folder(CSIDL_PROGRAM_FILES);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2225 if (folder) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2226 path = g_build_filename(folder, "Trillian",
18250
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2227 "users", "default", "talk.ini", NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2228 g_free(folder);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2229 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2230 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2231
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2232 if (path) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2233 /* Read talk.ini file to find the log directory. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2234 GError *error = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2235
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2236 #if 0 && GLIB_CHECK_VERSION(2,6,0) /* FIXME: Not tested yet. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2237 GKeyFile *key_file;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2238
18245
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
2239 purple_debug_info("Trillian talk.ini read", "Reading %s\n", path);
18248
ab761acbc614 Remove trailing whitespace.
Richard Laager <rlaager@wiktel.com>
parents: 18247
diff changeset
2240
18175
038c14fcadb8 setting error to NULL before using
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 18174
diff changeset
2241 error = NULL;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2242 if (!g_key_file_load_from_file(key_file, path, G_KEY_FILE_NONE, GError &error)) {
18245
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
2243 purple_debug_error("Trillian talk.ini read",
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
2244 "Error reading talk.ini\n");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2245 if (error)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2246 g_error_free(error);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2247 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2248 char *logdir = g_key_file_get_string(key_file, "Logging", "Directory", &error);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2249 if (error) {
18245
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
2250 purple_debug_error("Trillian talk.ini read",
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
2251 "Error reading Directory value from Logging section\n");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2252 g_error_free(error);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2253 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2254
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2255 if (logdir) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2256 g_strchomp(logdir);
18245
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
2257 purple_prefs_add_string("/plugins/core/log_reader/trillian/log_directory", logdir);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2258 found = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2259 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2260
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2261 g_key_file_free(key_file);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2262 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2263 #else /* !GLIB_CHECK_VERSION(2,6,0) */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2264 gsize length;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2265 gchar *contents = NULL;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2266
18245
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
2267 purple_debug_info("Trillian talk.ini read",
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2268 "Reading %s\n", path);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2269 if (!g_file_get_contents(path, &contents, &length, &error)) {
18245
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
2270 purple_debug_error("Trillian talk.ini read",
30b67808b85b Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents: 18244
diff changeset
2271 "Error reading talk.ini\n");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2272 if (error)
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2273 g_error_free(error);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2274 } else {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2275 char *line = contents;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2276 while (*contents) {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2277 if (*contents == '\n') {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2278 *contents = '\0';
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2279
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2280 /* XXX: This assumes the first Directory key is under [Logging]. */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2281 if (purple_str_has_prefix(line, "Directory=")) {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2282 line += (sizeof("Directory=") - 1);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2283 g_strchomp(line);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2284 purple_prefs_add_string(
16430
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
2285 "/plugins/core/log_reader/trillian/log_directory",
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2286 line);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2287 found = TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2288 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2289
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2290 contents++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2291 line = contents;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2292 } else
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2293 contents++;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2294 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2295 g_free(path);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2296 g_free(contents);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2297 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2298 #endif /* !GTK_CHECK_VERSION(2,6,0) */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2299 } /* path */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2300
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2301 if (!found) {
18250
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2302 folder = wpurple_get_special_folder(CSIDL_PROGRAM_FILES);
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2303 if (folder) {
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2304 path = g_build_filename(folder, "Trillian", "users",
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2305 "default", "logs", NULL);
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2306 g_free(folder);
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2307 } else
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2308 path = g_strdup("");
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2309 }
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2310 #else /* !defined(_WIN32) */
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2311 /* TODO: At some point, this could attempt to parse talk.ini
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2312 * TODO: from the default Trillian install directory on the
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2313 * TODO: Windows mount point. */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2314
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2315 /* Calculate default Trillian log directory. */
18250
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2316 path = g_build_filename(PURPLE_LOG_READER_WINDOWS_MOUNT_POINT,
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2317 "Program Files", "Trillian", "users",
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2318 "default", "logs", NULL);
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2319 #endif
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2320
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2321
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2322 /* Add QIP log directory preference. */
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2323 purple_prefs_add_none("/plugins/core/log_reader/qip");
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2324
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2325 /* Calculate default QIP log directory. */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2326 #ifdef _WIN32
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2327 folder = wpurple_get_special_folder(CSIDL_PROGRAM_FILES);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2328 if (folder) {
18250
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2329 path = g_build_filename(folder, "QIP", "Users", NULL);
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2330 g_free(folder);
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2331 } else
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2332 path = g_strdup("");
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2333 #else
18250
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2334 path = g_build_filename(PURPLE_LOG_READER_WINDOWS_MOUNT_POINT,
7a6a1da4121b Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents: 18249
diff changeset
2335 "Program Files", "QIP", "Users", NULL);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2336 #endif
17979
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2337 purple_prefs_add_string("/plugins/core/log_reader/qip/log_directory", path);
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2338 g_free(path);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2339 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2340
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2341 static gboolean
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2342 plugin_load(PurplePlugin *plugin)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2343 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2344 g_return_val_if_fail(plugin != NULL, FALSE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2345
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2346 /* The names of IM clients are marked for translation at the request of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2347 translators who wanted to transliterate them. Many translators
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2348 choose to leave them alone. Choose what's best for your language. */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2349 adium_logger = purple_log_logger_new("adium", _("Adium"), 6,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2350 NULL,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2351 NULL,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2352 adium_logger_finalize,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2353 adium_logger_list,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2354 adium_logger_read,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2355 adium_logger_size);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2356 purple_log_logger_add(adium_logger);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2357
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2358 #if 0
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2359 /* The names of IM clients are marked for translation at the request of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2360 translators who wanted to transliterate them. Many translators
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2361 choose to leave them alone. Choose what's best for your language. */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2362 fire_logger = purple_log_logger_new("fire", _("Fire"), 6,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2363 NULL,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2364 NULL,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2365 fire_logger_finalize,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2366 fire_logger_list,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2367 fire_logger_read,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2368 fire_logger_size);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2369 purple_log_logger_add(fire_logger);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2370
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2371 /* The names of IM clients are marked for translation at the request of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2372 translators who wanted to transliterate them. Many translators
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2373 choose to leave them alone. Choose what's best for your language. */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2374 messenger_plus_logger = purple_log_logger_new("messenger_plus", _("Messenger Plus!"), 6,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2375 NULL,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2376 NULL,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2377 messenger_plus_logger_finalize,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2378 messenger_plus_logger_list,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2379 messenger_plus_logger_read,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2380 messenger_plus_logger_size);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2381 purple_log_logger_add(messenger_plus_logger);
18248
ab761acbc614 Remove trailing whitespace.
Richard Laager <rlaager@wiktel.com>
parents: 18247
diff changeset
2382
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2383 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2384
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2385 /* The names of IM clients are marked for translation at the request of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2386 translators who wanted to transliterate them. Many translators
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2387 choose to leave them alone. Choose what's best for your language. */
17979
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2388 qip_logger = purple_log_logger_new("qip", _("QIP"), 6,
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2389 NULL,
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2390 NULL,
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2391 qip_logger_finalize,
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2392 qip_logger_list,
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2393 qip_logger_read,
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2394 qip_logger_size);
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2395 purple_log_logger_add(qip_logger);
18248
ab761acbc614 Remove trailing whitespace.
Richard Laager <rlaager@wiktel.com>
parents: 18247
diff changeset
2396
17979
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2397 /* The names of IM clients are marked for translation at the request of
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2398 translators who wanted to transliterate them. Many translators
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2399 choose to leave them alone. Choose what's best for your language. */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2400 msn_logger = purple_log_logger_new("msn", _("MSN Messenger"), 6,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2401 NULL,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2402 NULL,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2403 msn_logger_finalize,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2404 msn_logger_list,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2405 msn_logger_read,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2406 msn_logger_size);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2407 purple_log_logger_add(msn_logger);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2408
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2409 /* The names of IM clients are marked for translation at the request of
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2410 translators who wanted to transliterate them. Many translators
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2411 choose to leave them alone. Choose what's best for your language. */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2412 trillian_logger = purple_log_logger_new("trillian", _("Trillian"), 6,
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2413 NULL,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2414 NULL,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2415 trillian_logger_finalize,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2416 trillian_logger_list,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2417 trillian_logger_read,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2418 trillian_logger_size);
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2419 purple_log_logger_add(trillian_logger);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2420
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2421 return TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2422 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2423
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2424 static gboolean
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2425 plugin_unload(PurplePlugin *plugin)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2426 {
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2427 g_return_val_if_fail(plugin != NULL, FALSE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2428
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2429 purple_log_logger_remove(adium_logger);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2430 #if 0
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2431 purple_log_logger_remove(fire_logger);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2432 purple_log_logger_remove(messenger_plus_logger);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2433 #endif
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2434 purple_log_logger_remove(msn_logger);
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2435 purple_log_logger_remove(trillian_logger);
17979
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2436 purple_log_logger_remove(qip_logger);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2437
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2438 return TRUE;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2439 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2440
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2441 static PurplePluginPrefFrame *
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2442 get_plugin_pref_frame(PurplePlugin *plugin)
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2443 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2444 PurplePluginPrefFrame *frame;
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2445 PurplePluginPref *ppref;
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2446
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2447 g_return_val_if_fail(plugin != NULL, FALSE);
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2448
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2449 frame = purple_plugin_pref_frame_new();
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2450
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2451
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2452 /* Add general preferences. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2453
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2454 ppref = purple_plugin_pref_new_with_label(_("General Log Reading Configuration"));
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2455 purple_plugin_pref_frame_add(frame, ppref);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2456
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2457 ppref = purple_plugin_pref_new_with_name_and_label(
16430
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
2458 "/plugins/core/log_reader/fast_sizes", _("Fast size calculations"));
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2459 purple_plugin_pref_frame_add(frame, ppref);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2460
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2461 ppref = purple_plugin_pref_new_with_name_and_label(
16430
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
2462 "/plugins/core/log_reader/use_name_heuristics", _("Use name heuristics"));
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2463 purple_plugin_pref_frame_add(frame, ppref);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2464
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2465
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2466 /* Add Log Directory preferences. */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2467
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2468 ppref = purple_plugin_pref_new_with_label(_("Log Directory"));
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2469 purple_plugin_pref_frame_add(frame, ppref);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2470
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2471 ppref = purple_plugin_pref_new_with_name_and_label(
16430
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
2472 "/plugins/core/log_reader/adium/log_directory", _("Adium"));
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2473 purple_plugin_pref_frame_add(frame, ppref);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2474
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2475 #if 0
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2476 ppref = purple_plugin_pref_new_with_name_and_label(
16430
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
2477 "/plugins/core/log_reader/fire/log_directory", _("Fire"));
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2478 purple_plugin_pref_frame_add(frame, ppref);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2479
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2480 ppref = purple_plugin_pref_new_with_name_and_label(
16430
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
2481 "/plugins/core/log_reader/messenger_plus/log_directory", _("Messenger Plus!"));
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2482 purple_plugin_pref_frame_add(frame, ppref);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2483 #endif
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2484
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2485 ppref = purple_plugin_pref_new_with_name_and_label(
17979
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2486 "/plugins/core/log_reader/qip/log_directory", _("QIP"));
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2487 purple_plugin_pref_frame_add(frame, ppref);
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2488
c8d2e131cc37 QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents: 17531
diff changeset
2489 ppref = purple_plugin_pref_new_with_name_and_label(
16430
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
2490 "/plugins/core/log_reader/msn/log_directory", _("MSN Messenger"));
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2491 purple_plugin_pref_frame_add(frame, ppref);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2492
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2493 ppref = purple_plugin_pref_new_with_name_and_label(
16430
f8eb3e7c4fbd Fix GTK Plugin prefs
Sean Egan <seanegan@gmail.com>
parents: 16424
diff changeset
2494 "/plugins/core/log_reader/trillian/log_directory", _("Trillian"));
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2495 purple_plugin_pref_frame_add(frame, ppref);
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2496
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2497 return frame;
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2498 }
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2499
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2500 static PurplePluginUiInfo prefs_info = {
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2501 get_plugin_pref_frame,
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2502 0, /* page_num (reserved) */
16666
5205dd2bd035 And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents: 16430
diff changeset
2503 NULL, /* frame (reserved) */
5205dd2bd035 And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents: 16430
diff changeset
2504
5205dd2bd035 And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents: 16430
diff changeset
2505 /* padding */
5205dd2bd035 And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents: 16430
diff changeset
2506 NULL,
5205dd2bd035 And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents: 16430
diff changeset
2507 NULL,
5205dd2bd035 And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents: 16430
diff changeset
2508 NULL,
5205dd2bd035 And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents: 16430
diff changeset
2509 NULL
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2510 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2511
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2512 static PurplePluginInfo info =
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2513 {
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2514 PURPLE_PLUGIN_MAGIC,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2515 PURPLE_MAJOR_VERSION,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2516 PURPLE_MINOR_VERSION,
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2517 PURPLE_PLUGIN_STANDARD, /**< type */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2518 NULL, /**< ui_requirement */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2519 0, /**< flags */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2520 NULL, /**< dependencies */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2521 PURPLE_PRIORITY_DEFAULT, /**< priority */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2522 "core-log_reader", /**< id */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2523 N_("Log Reader"), /**< name */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2524 VERSION, /**< version */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2525
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2526 /** summary */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2527 N_("Includes other IM clients' logs in the "
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2528 "log viewer."),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2529
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2530 /** description */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2531 N_("When viewing logs, this plugin will include "
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2532 "logs from other IM clients. Currently, this "
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2533 "includes Adium, MSN Messenger, and Trillian.\n\n"
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2534 "WARNING: This plugin is still alpha code and "
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2535 "may crash frequently. Use it at your own risk!"),
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2536
15566
b6615958d87c Switching to my pidgin.im e-mail address, which I think fits nicely and seems professional.
Richard Laager <rlaager@wiktel.com>
parents: 15373
diff changeset
2537 "Richard Laager <rlaager@pidgin.im>", /**< author */
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2538 PURPLE_WEBSITE, /**< homepage */
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2539 plugin_load, /**< load */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2540 plugin_unload, /**< unload */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2541 NULL, /**< destroy */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2542 NULL, /**< ui_info */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2543 NULL, /**< extra_info */
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2544 &prefs_info, /**< prefs_info */
16666
5205dd2bd035 And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents: 16430
diff changeset
2545 NULL, /**< actions */
5205dd2bd035 And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents: 16430
diff changeset
2546
5205dd2bd035 And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents: 16430
diff changeset
2547 /* padding */
5205dd2bd035 And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents: 16430
diff changeset
2548 NULL,
5205dd2bd035 And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents: 16430
diff changeset
2549 NULL,
5205dd2bd035 And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents: 16430
diff changeset
2550 NULL,
5205dd2bd035 And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents: 16430
diff changeset
2551 NULL
15373
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2552 };
5fe8042783c1 Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2553
15822
32c366eeeb99 sed -ie 's/gaim/purple/g'
Sean Egan <seanegan@gmail.com>
parents: 15566
diff changeset
2554 PURPLE_INIT_PLUGIN(log_reader, init_plugin, info)