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