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