Mercurial > pidgin
annotate libpurple/plugins/log_reader.c @ 32156:d478be29444a
Add a WebKit Development plugin, that allows opening the builtin
inspector on a view. To use, activate the plugin, right-click a view,
and select 'Inspect Element'.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Fri, 16 Sep 2011 06:10:04 +0000 |
parents | 61ce89013291 |
children | f07501af8bae |
rev | line source |
---|---|
28647
f1437342cc0e
Include 'internal.h' before all other headers to make some non-gcc compilers happy.
Paul Aurich <paul@darkrain42.org>
parents:
27283
diff
changeset
|
1 #include "internal.h" |
f1437342cc0e
Include 'internal.h' before all other headers to make some non-gcc compilers happy.
Paul Aurich <paul@darkrain42.org>
parents:
27283
diff
changeset
|
2 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 #include <stdio.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5 #include "debug.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
6 #include "log.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
7 #include "plugin.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
8 #include "pluginpref.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 #include "prefs.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 #include "stringref.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 #include "util.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
12 #include "version.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 #include "xmlnode.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 |
15822 | 15 /* This must be the last Purple header included. */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 #ifdef _WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
17 #include "win32dep.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
18 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
20 /* Where is the Windows partition mounted? */ |
15822 | 21 #ifndef PURPLE_LOG_READER_WINDOWS_MOUNT_POINT |
22 #define PURPLE_LOG_READER_WINDOWS_MOUNT_POINT "/mnt/windows" | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
23 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
24 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
25 enum name_guesses { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
26 NAME_GUESS_UNKNOWN, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
27 NAME_GUESS_ME, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
28 NAME_GUESS_THEM |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
29 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
30 |
20909
feca1fd51b57
Use functions and loops and all those fancy things.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20898
diff
changeset
|
31 /* Some common functions. */ |
feca1fd51b57
Use functions and loops and all those fancy things.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20898
diff
changeset
|
32 static int get_month(const char *month) |
feca1fd51b57
Use functions and loops and all those fancy things.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20898
diff
changeset
|
33 { |
feca1fd51b57
Use functions and loops and all those fancy things.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20898
diff
changeset
|
34 int iter; |
feca1fd51b57
Use functions and loops and all those fancy things.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20898
diff
changeset
|
35 const char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", |
feca1fd51b57
Use functions and loops and all those fancy things.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20898
diff
changeset
|
36 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL}; |
feca1fd51b57
Use functions and loops and all those fancy things.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20898
diff
changeset
|
37 for (iter = 0; months[iter]; iter++) { |
feca1fd51b57
Use functions and loops and all those fancy things.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20898
diff
changeset
|
38 if (strcmp(month, months[iter]) == 0) |
feca1fd51b57
Use functions and loops and all those fancy things.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20898
diff
changeset
|
39 break; |
feca1fd51b57
Use functions and loops and all those fancy things.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20898
diff
changeset
|
40 } |
feca1fd51b57
Use functions and loops and all those fancy things.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20898
diff
changeset
|
41 return iter; |
feca1fd51b57
Use functions and loops and all those fancy things.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20898
diff
changeset
|
42 } |
feca1fd51b57
Use functions and loops and all those fancy things.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20898
diff
changeset
|
43 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
44 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
45 /***************************************************************************** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
46 * Adium Logger * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
47 *****************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
48 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
49 /* The adium logger doesn't write logs, only reads them. This is to include |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
50 * Adium logs in the log viewer transparently. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
51 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
52 |
15822 | 53 static PurpleLogLogger *adium_logger; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
54 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
55 enum adium_log_type { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 ADIUM_HTML, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
57 ADIUM_TEXT, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
58 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
59 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
60 struct adium_logger_data { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
61 char *path; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
62 enum adium_log_type type; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 |
15822 | 65 static GList *adium_logger_list(PurpleLogType type, const char *sn, PurpleAccount *account) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
66 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 GList *list = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
68 const char *logdir; |
15822 | 69 PurplePlugin *plugin; |
70 PurplePluginProtocolInfo *prpl_info; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
71 char *prpl_name; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
72 char *temp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
73 char *path; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
74 GDir *dir; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
75 |
18795
883c18d31bf4
Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18785
diff
changeset
|
76 g_return_val_if_fail(sn != NULL, NULL); |
883c18d31bf4
Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18785
diff
changeset
|
77 g_return_val_if_fail(account != NULL, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
78 |
16430 | 79 logdir = purple_prefs_get_string("/plugins/core/log_reader/adium/log_directory"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
80 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
81 /* By clearing the log directory path, this logger can be (effectively) disabled. */ |
18795
883c18d31bf4
Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18785
diff
changeset
|
82 if (!logdir || !*logdir) |
883c18d31bf4
Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18785
diff
changeset
|
83 return NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
84 |
15822 | 85 plugin = purple_find_prpl(purple_account_get_protocol_id(account)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
86 if (!plugin) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
87 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
88 |
15822 | 89 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
90 if (!prpl_info->list_icon) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
91 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
92 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
93 prpl_name = g_ascii_strup(prpl_info->list_icon(account, NULL), -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
94 |
31932
61ce89013291
Use accessor functions in a few places
Mark Doliner <mark@kingant.net>
parents:
31757
diff
changeset
|
95 temp = g_strdup_printf("%s.%s", prpl_name, purple_account_get_username(account)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
96 path = g_build_filename(logdir, temp, sn, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
97 g_free(temp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
98 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
99 dir = g_dir_open(path, 0, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
100 if (dir) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
101 const gchar *file; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
102 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
103 while ((file = g_dir_read_name(dir))) { |
15822 | 104 if (!purple_str_has_prefix(file, sn)) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
105 continue; |
15822 | 106 if (purple_str_has_suffix(file, ".html") || purple_str_has_suffix(file, ".AdiumHTMLLog")) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
107 struct tm tm; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
108 const char *date = file; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
109 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
110 date += strlen(sn) + 2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
111 if (sscanf(date, "%u|%u|%u", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
112 &tm.tm_year, &tm.tm_mon, &tm.tm_mday) != 3) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
113 |
18245
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
114 purple_debug_error("Adium log parse", |
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
115 "Filename timestamp parsing error\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
116 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
117 char *filename = g_build_filename(path, file, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
118 FILE *handle = g_fopen(filename, "rb"); |
20898
70082d0db571
Pay attention to the return value of fread. I don't think not doing this
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20897
diff
changeset
|
119 char contents[57]; /* XXX: This is really inflexible. */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
120 char *contents2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
121 struct adium_logger_data *data; |
20898
70082d0db571
Pay attention to the return value of fread. I don't think not doing this
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20897
diff
changeset
|
122 size_t rd; |
15822 | 123 PurpleLog *log; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
124 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
125 if (!handle) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
126 g_free(filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
127 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
128 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
129 |
20910
54d232b52607
Since we are looking at the return value of fread, it actually matters that
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20909
diff
changeset
|
130 rd = fread(contents, 1, 56, handle) == 0; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
131 fclose(handle); |
20898
70082d0db571
Pay attention to the return value of fread. I don't think not doing this
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20897
diff
changeset
|
132 contents[rd] = '\0'; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
133 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
134 /* XXX: This is fairly inflexible. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
135 contents2 = contents; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
136 while (*contents2 && *contents2 != '>') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
137 contents2++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
138 if (*contents2) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
139 contents2++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
140 while (*contents2 && *contents2 != '>') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
141 contents2++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
142 if (*contents2) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
143 contents2++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
144 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
145 if (sscanf(contents2, "%u.%u.%u", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
146 &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 3) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
147 |
18245
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
148 purple_debug_error("Adium log parse", |
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
149 "Contents timestamp parsing error\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
150 g_free(filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
151 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
152 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
153 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
154 data = g_new0(struct adium_logger_data, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
155 data->path = filename; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
156 data->type = ADIUM_HTML; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
157 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
158 tm.tm_year -= 1900; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
159 tm.tm_mon -= 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
160 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
161 /* XXX: Look into this later... Should we pass in a struct tm? */ |
15822 | 162 log = purple_log_new(PURPLE_LOG_IM, sn, account, NULL, mktime(&tm), NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
163 log->logger = adium_logger; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
164 log->logger_data = data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
165 |
18249
35d981091506
Prepend to lists for performance, and use g_list_reverse when the list is
Richard Laager <rlaager@wiktel.com>
parents:
18248
diff
changeset
|
166 list = g_list_prepend(list, log); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
167 } |
15822 | 168 } else if (purple_str_has_suffix(file, ".adiumLog")) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
169 struct tm tm; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
170 const char *date = file; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
171 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
172 date += strlen(sn) + 2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
173 if (sscanf(date, "%u|%u|%u", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
174 &tm.tm_year, &tm.tm_mon, &tm.tm_mday) != 3) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
175 |
18245
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
176 purple_debug_error("Adium log parse", |
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
177 "Filename timestamp parsing error\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
178 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
179 char *filename = g_build_filename(path, file, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
180 FILE *handle = g_fopen(filename, "rb"); |
20898
70082d0db571
Pay attention to the return value of fread. I don't think not doing this
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20897
diff
changeset
|
181 char contents[14]; /* XXX: This is really inflexible. */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
182 char *contents2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
183 struct adium_logger_data *data; |
15822 | 184 PurpleLog *log; |
20898
70082d0db571
Pay attention to the return value of fread. I don't think not doing this
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20897
diff
changeset
|
185 size_t rd; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
186 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
187 if (!handle) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
188 g_free(filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
189 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
190 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
191 |
20910
54d232b52607
Since we are looking at the return value of fread, it actually matters that
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20909
diff
changeset
|
192 rd = fread(contents, 1, 13, handle); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
193 fclose(handle); |
20898
70082d0db571
Pay attention to the return value of fread. I don't think not doing this
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20897
diff
changeset
|
194 contents[rd] = '\0'; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
195 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
196 contents2 = contents; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
197 while (*contents2 && *contents2 != '(') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
198 contents2++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
199 if (*contents2) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
200 contents2++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
201 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
202 if (sscanf(contents2, "%u.%u.%u", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
203 &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 3) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
204 |
18245
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
205 purple_debug_error("Adium log parse", |
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
206 "Contents timestamp parsing error\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
207 g_free(filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
208 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
209 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
210 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
211 tm.tm_year -= 1900; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
212 tm.tm_mon -= 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
213 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
214 data = g_new0(struct adium_logger_data, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
215 data->path = filename; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
216 data->type = ADIUM_TEXT; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
217 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
218 /* XXX: Look into this later... Should we pass in a struct tm? */ |
15822 | 219 log = purple_log_new(PURPLE_LOG_IM, sn, account, NULL, mktime(&tm), NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
220 log->logger = adium_logger; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
221 log->logger_data = data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
222 |
18249
35d981091506
Prepend to lists for performance, and use g_list_reverse when the list is
Richard Laager <rlaager@wiktel.com>
parents:
18248
diff
changeset
|
223 list = g_list_prepend(list, log); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
224 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
225 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
226 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
227 g_dir_close(dir); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
228 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
229 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
230 g_free(prpl_name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
231 g_free(path); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
232 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
233 return list; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
234 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
235 |
15822 | 236 static char *adium_logger_read (PurpleLog *log, PurpleLogReadFlags *flags) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
237 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
238 struct adium_logger_data *data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
239 GError *error = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
240 gchar *read = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
241 |
18373 | 242 /* XXX: TODO: We probably want to set PURPLE_LOG_READ_NO_NEWLINE |
18371
c13d115b6c6e
Make the Adium logger set flags, though it's still very much a stub.
Richard Laager <rlaager@wiktel.com>
parents:
18360
diff
changeset
|
243 * XXX: TODO: for HTML logs. */ |
18795
883c18d31bf4
Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18785
diff
changeset
|
244 if (flags != NULL) |
883c18d31bf4
Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18785
diff
changeset
|
245 *flags = 0; |
18371
c13d115b6c6e
Make the Adium logger set flags, though it's still very much a stub.
Richard Laager <rlaager@wiktel.com>
parents:
18360
diff
changeset
|
246 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
247 g_return_val_if_fail(log != NULL, g_strdup("")); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
248 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
249 data = log->logger_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
250 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
251 g_return_val_if_fail(data->path != NULL, g_strdup("")); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
252 |
18245
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
253 purple_debug_info("Adium log read", "Reading %s\n", data->path); |
20329
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
254 if (!g_file_get_contents(data->path, &read, NULL, &error)) { |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
255 purple_debug_error("Adium log read", "Error reading log: %s\n", |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
256 (error && error->message) ? error->message : "Unknown error"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
257 if (error) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
258 g_error_free(error); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
259 return g_strdup(""); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
260 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
261 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
262 if (data->type != ADIUM_HTML) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
263 char *escaped = g_markup_escape_text(read, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
264 g_free(read); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
265 read = escaped; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
266 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
267 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
268 #ifdef WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
269 /* This problem only seems to show up on Windows. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
270 * The BOM is displaying as a space at the beginning of the log. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
271 */ |
15822 | 272 if (purple_str_has_prefix(read, "\xef\xbb\xbf")) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
273 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
274 /* FIXME: This feels so wrong... */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
275 char *temp = g_strdup(&(read[3])); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
276 g_free(read); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
277 read = temp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
278 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
279 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
280 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
281 /* TODO: Apply formatting. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
282 * Replace the above hack with something better, since we'll |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
283 * be looping over the entire log file contents anyway. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
284 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
285 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
286 return read; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
287 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
288 |
15822 | 289 static int adium_logger_size (PurpleLog *log) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
290 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
291 struct adium_logger_data *data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
292 char *text; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
293 size_t size; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
294 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
295 g_return_val_if_fail(log != NULL, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
296 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
297 data = log->logger_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
298 |
16430 | 299 if (purple_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
300 struct stat st; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
301 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
302 if (!data->path || stat(data->path, &st)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
303 st.st_size = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
304 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
305 return st.st_size; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
306 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
307 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
308 text = adium_logger_read(log, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
309 size = strlen(text); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
310 g_free(text); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
311 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
312 return size; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
313 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
314 |
15822 | 315 static void adium_logger_finalize(PurpleLog *log) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
316 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
317 struct adium_logger_data *data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
318 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
319 g_return_if_fail(log != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
320 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
321 data = log->logger_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
322 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
323 g_free(data->path); |
18246
e236b3bd4542
Eliminate some leaks.
Richard Laager <rlaager@wiktel.com>
parents:
18245
diff
changeset
|
324 g_free(data); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
325 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
326 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
327 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
328 /***************************************************************************** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
329 * Fire Logger * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
330 *****************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
331 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
332 #if 0 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
333 /* The fire logger doesn't write logs, only reads them. This is to include |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
334 * Fire logs in the log viewer transparently. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
335 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
336 |
15822 | 337 static PurpleLogLogger *fire_logger; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
338 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
339 struct fire_logger_data { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
340 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
341 |
15822 | 342 static GList *fire_logger_list(PurpleLogType type, const char *sn, PurpleAccount *account) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
343 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
344 /* TODO: Do something here. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
345 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
346 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
347 |
15822 | 348 static char * fire_logger_read (PurpleLog *log, PurpleLogReadFlags *flags) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
349 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
350 struct fire_logger_data *data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
351 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
352 g_return_val_if_fail(log != NULL, g_strdup("")); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
353 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
354 data = log->logger_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
355 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
356 /* TODO: Do something here. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
357 return g_strdup(""); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
358 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
359 |
15822 | 360 static int fire_logger_size (PurpleLog *log) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
361 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
362 g_return_val_if_fail(log != NULL, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
363 |
16430 | 364 if (purple_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
365 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
366 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
367 /* TODO: Do something here. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
368 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
369 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
370 |
15822 | 371 static void fire_logger_finalize(PurpleLog *log) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
372 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
373 g_return_if_fail(log != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
374 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
375 /* TODO: Do something here. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
376 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
377 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
378 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
379 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
380 /***************************************************************************** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
381 * Messenger Plus! Logger * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
382 *****************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
383 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
384 #if 0 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
385 /* The messenger_plus logger doesn't write logs, only reads them. This is to include |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
386 * Messenger Plus! logs in the log viewer transparently. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
387 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
388 |
15822 | 389 static PurpleLogLogger *messenger_plus_logger; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
390 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
391 struct messenger_plus_logger_data { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
392 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
393 |
15822 | 394 static GList *messenger_plus_logger_list(PurpleLogType type, const char *sn, PurpleAccount *account) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
395 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
396 /* TODO: Do something here. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
397 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
398 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
399 |
15822 | 400 static char * messenger_plus_logger_read (PurpleLog *log, PurpleLogReadFlags *flags) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
401 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
402 struct messenger_plus_logger_data *data = log->logger_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
403 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
404 g_return_val_if_fail(log != NULL, g_strdup("")); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
405 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
406 data = log->logger_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
407 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
408 /* TODO: Do something here. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
409 return g_strdup(""); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
410 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
411 |
15822 | 412 static int messenger_plus_logger_size (PurpleLog *log) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
413 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
414 g_return_val_if_fail(log != NULL, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
415 |
16430 | 416 if (purple_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
417 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
418 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
419 /* TODO: Do something here. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
420 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
421 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
422 |
15822 | 423 static void messenger_plus_logger_finalize(PurpleLog *log) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
424 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
425 g_return_if_fail(log != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
426 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
427 /* TODO: Do something here. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
428 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
429 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
430 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
431 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
432 /***************************************************************************** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
433 * MSN Messenger Logger * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
434 *****************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
435 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
436 /* The msn logger doesn't write logs, only reads them. This is to include |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
437 * MSN Messenger message histories in the log viewer transparently. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
438 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
439 |
15822 | 440 static PurpleLogLogger *msn_logger; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
441 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
442 struct msn_logger_data { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
443 xmlnode *root; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
444 xmlnode *message; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
445 const char *session_id; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
446 int last_log; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
447 GString *text; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
448 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
449 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
450 /* This function is really confusing. It makes baby rlaager cry... |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
451 In other news: "You lost a lot of blood but we found most of it." |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
452 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
453 static time_t msn_logger_parse_timestamp(xmlnode *message, struct tm **tm_out) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
454 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
455 const char *datetime; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
456 static struct tm tm2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
457 time_t stamp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
458 const char *date; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
459 const char *time; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
460 int month; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
461 int day; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
462 int year; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
463 int hour; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
464 int min; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
465 int sec; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
466 char am_pm; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
467 char *str; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
468 static struct tm tm; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
469 time_t t; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
470 time_t diff; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
471 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
472 #ifndef G_DISABLE_CHECKS |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
473 if (message != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
474 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
475 *tm_out = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
476 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
477 /* Trigger the usual warning. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
478 g_return_val_if_fail(message != NULL, (time_t)0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
479 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
480 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
481 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
482 datetime = xmlnode_get_attrib(message, "DateTime"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
483 if (!(datetime && *datetime)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
484 { |
15822 | 485 purple_debug_error("MSN log timestamp parse", |
18245
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
486 "Attribute missing: %s\n", "DateTime"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
487 return (time_t)0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
488 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
489 |
15822 | 490 stamp = purple_str_to_time(datetime, TRUE, &tm2, NULL, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
491 #ifdef HAVE_TM_GMTOFF |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
492 tm2.tm_gmtoff = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
493 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
494 #ifdef HAVE_STRUCT_TM_TM_ZONE |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
495 /* This is used in the place of a timezone abbreviation if the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
496 * offset is way off. The user should never really see it, but |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
497 * it's here just in case. The parens are to make it clear it's |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
498 * not a real timezone. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
499 tm2.tm_zone = _("(UTC)"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
500 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
501 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
502 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
503 date = xmlnode_get_attrib(message, "Date"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
504 if (!(date && *date)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
505 { |
15822 | 506 purple_debug_error("MSN log timestamp parse", |
18245
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
507 "Attribute missing: %s\n", "Date"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
508 *tm_out = &tm2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
509 return stamp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
510 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
511 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
512 time = xmlnode_get_attrib(message, "Time"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
513 if (!(time && *time)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
514 { |
15822 | 515 purple_debug_error("MSN log timestamp parse", |
18245
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
516 "Attribute missing: %s\n", "Time"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
517 *tm_out = &tm2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
518 return stamp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
519 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
520 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
521 if (sscanf(date, "%u/%u/%u", &month, &day, &year) != 3) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
522 { |
15822 | 523 purple_debug_error("MSN log timestamp parse", |
18245
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
524 "%s parsing error\n", "Date"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
525 *tm_out = &tm2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
526 return stamp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
527 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
528 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
529 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
530 if (month > 12) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
531 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
532 int tmp = day; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
533 day = month; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
534 month = tmp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
535 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
536 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
537 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
538 if (sscanf(time, "%u:%u:%u %c", &hour, &min, &sec, &am_pm) != 4) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
539 { |
15822 | 540 purple_debug_error("MSN log timestamp parse", |
18245
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
541 "%s parsing error\n", "Time"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
542 *tm_out = &tm2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
543 return stamp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
544 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
545 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
546 if (am_pm == 'P') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
547 hour += 12; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
548 } else if (hour == 12) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
549 /* 12 AM = 00 hr */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
550 hour = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
551 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
552 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
553 str = g_strdup_printf("%04i-%02i-%02iT%02i:%02i:%02i", year, month, day, hour, min, sec); |
15822 | 554 t = purple_str_to_time(str, TRUE, &tm, NULL, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
555 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
556 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
557 if (stamp > t) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
558 diff = stamp - t; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
559 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
560 diff = t - stamp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
561 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
562 if (diff > (14 * 60 * 60)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
563 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
564 if (day <= 12) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
565 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
566 /* Swap day & month variables, to see if it's a non-US date. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
567 g_free(str); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
568 str = g_strdup_printf("%04i-%02i-%02iT%02i:%02i:%02i", year, month, day, hour, min, sec); |
15822 | 569 t = purple_str_to_time(str, TRUE, &tm, NULL, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
570 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
571 if (stamp > t) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
572 diff = stamp - t; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
573 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
574 diff = t - stamp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
575 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
576 if (diff > (14 * 60 * 60)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
577 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
578 /* We got a time, it's not impossible, but |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
579 * the diff is too large. Display the UTC time. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
580 g_free(str); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
581 *tm_out = &tm2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
582 return stamp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
583 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
584 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
585 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
586 /* Legal time */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
587 /* Fall out */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
588 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
589 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
590 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
591 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
592 /* We got a time, it's not impossible, but |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
593 * the diff is too large. Display the UTC time. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
594 g_free(str); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
595 *tm_out = &tm2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
596 return stamp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
597 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
598 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
599 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
600 /* If we got here, the time is legal with a reasonable offset. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
601 * Let's find out if it's in our TZ. */ |
15822 | 602 if (purple_str_to_time(str, FALSE, &tm, NULL, NULL) == stamp) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
603 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
604 g_free(str); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
605 *tm_out = &tm; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
606 return stamp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
607 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
608 g_free(str); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
609 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
610 /* The time isn't in our TZ, but it's reasonable. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
611 #ifdef HAVE_STRUCT_TM_TM_ZONE |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
612 tm.tm_zone = " "; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
613 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
614 *tm_out = &tm; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
615 return stamp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
616 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
617 |
15822 | 618 static GList *msn_logger_list(PurpleLogType type, const char *sn, PurpleAccount *account) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
619 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
620 GList *list = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
621 char *username; |
15822 | 622 PurpleBuddy *buddy; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
623 const char *logdir; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
624 const char *savedfilename = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
625 char *logfile; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
626 char *path; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
627 GError *error = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
628 gchar *contents = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
629 gsize length; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
630 xmlnode *root; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
631 xmlnode *message; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
632 const char *old_session_id = ""; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
633 struct msn_logger_data *data = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
634 |
18795
883c18d31bf4
Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18785
diff
changeset
|
635 g_return_val_if_fail(sn != NULL, NULL); |
883c18d31bf4
Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18785
diff
changeset
|
636 g_return_val_if_fail(account != NULL, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
637 |
31932
61ce89013291
Use accessor functions in a few places
Mark Doliner <mark@kingant.net>
parents:
31757
diff
changeset
|
638 if (strcmp(purple_account_get_protocol_id(account), "prpl-msn")) |
18795
883c18d31bf4
Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18785
diff
changeset
|
639 return NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
640 |
16430 | 641 logdir = purple_prefs_get_string("/plugins/core/log_reader/msn/log_directory"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
642 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
643 /* By clearing the log directory path, this logger can be (effectively) disabled. */ |
18795
883c18d31bf4
Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18785
diff
changeset
|
644 if (!logdir || !*logdir) |
883c18d31bf4
Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18785
diff
changeset
|
645 return NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
646 |
15822 | 647 buddy = purple_find_buddy(account, sn); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
648 |
15822 | 649 if ((username = g_strdup(purple_account_get_string( |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
650 account, "log_reader_msn_log_folder", NULL)))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
651 /* As a special case, we allow the null string to kill the parsing |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
652 * straight away. This would allow the user to deal with the case |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
653 * when two account have the same username at different domains and |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
654 * only one has logs stored. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
655 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
656 if (!*username) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
657 g_free(username); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
658 return list; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
659 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
660 } else { |
31932
61ce89013291
Use accessor functions in a few places
Mark Doliner <mark@kingant.net>
parents:
31757
diff
changeset
|
661 username = g_strdup(purple_normalize(account, purple_account_get_username(account))); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
662 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
663 |
24314
0d0088b03745
Hide the blistnode, buddy, contact, group, and chat structs
Gary Kramlich <grim@reaperworld.com>
parents:
24034
diff
changeset
|
664 if (buddy) { |
24317 | 665 savedfilename = purple_blist_node_get_string((PurpleBlistNode *)buddy, |
666 "log_reader_msn_log_filename"); | |
24314
0d0088b03745
Hide the blistnode, buddy, contact, group, and chat structs
Gary Kramlich <grim@reaperworld.com>
parents:
24034
diff
changeset
|
667 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
668 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
669 if (savedfilename) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
670 /* As a special case, we allow the null string to kill the parsing |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
671 * straight away. This would allow the user to deal with the case |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
672 * when two buddies have the same username at different domains and |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
673 * only one has logs stored. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
674 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
675 if (!*savedfilename) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
676 g_free(username); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
677 return list; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
678 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
679 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
680 logfile = g_strdup(savedfilename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
681 } else { |
15822 | 682 logfile = g_strdup_printf("%s.xml", purple_normalize(account, sn)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
683 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
684 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
685 path = g_build_filename(logdir, username, "History", logfile, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
686 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
687 if (!g_file_test(path, G_FILE_TEST_EXISTS)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
688 gboolean found = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
689 char *at_sign; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
690 GDir *dir; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
691 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
692 g_free(path); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
693 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
694 if (savedfilename) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
695 /* We had a saved filename, but it doesn't exist. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
696 * Returning now is the right course of action because we don't |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
697 * want to detect another file incorrectly. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
698 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
699 g_free(username); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
700 g_free(logfile); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
701 return list; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
702 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
703 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
704 /* Perhaps we're using a new version of MSN with the weird numbered folders. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
705 * I don't know how the numbers are calculated, so I'm going to attempt to |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
706 * find logs by pattern matching... |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
707 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
708 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
709 at_sign = g_strrstr(username, "@"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
710 if (at_sign) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
711 *at_sign = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
712 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
713 dir = g_dir_open(logdir, 0, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
714 if (dir) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
715 const gchar *name; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
716 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
717 while ((name = g_dir_read_name(dir))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
718 const char *c = name; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
719 |
15822 | 720 if (!purple_str_has_prefix(c, username)) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
721 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
722 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
723 c += strlen(username); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
724 while (*c) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
725 if (!g_ascii_isdigit(*c)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
726 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
727 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
728 c++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
729 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
730 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
731 path = g_build_filename(logdir, name, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
732 /* The !c makes sure we got to the end of the while loop above. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
733 if (!*c && g_file_test(path, G_FILE_TEST_IS_DIR)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
734 char *history_path = g_build_filename( |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
735 path, "History", NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
736 if (g_file_test(history_path, G_FILE_TEST_IS_DIR)) { |
15822 | 737 purple_account_set_string(account, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
738 "log_reader_msn_log_folder", name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
739 g_free(path); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
740 path = history_path; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
741 found = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
742 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
743 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
744 g_free(path); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
745 g_free(history_path); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
746 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
747 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
748 g_free(path); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
749 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
750 g_dir_close(dir); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
751 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
752 g_free(username); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
753 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
754 if (!found) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
755 g_free(logfile); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
756 return list; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
757 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
758 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
759 /* If we've reached this point, we've found a History folder. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
760 |
15822 | 761 username = g_strdup(purple_normalize(account, sn)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
762 at_sign = g_strrstr(username, "@"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
763 if (at_sign) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
764 *at_sign = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
765 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
766 found = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
767 dir = g_dir_open(path, 0, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
768 if (dir) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
769 const gchar *name; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
770 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
771 while ((name = g_dir_read_name(dir))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
772 const char *c = name; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
773 |
15822 | 774 if (!purple_str_has_prefix(c, username)) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
775 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
776 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
777 c += strlen(username); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
778 while (*c) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
779 if (!g_ascii_isdigit(*c)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
780 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
781 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
782 c++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
783 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
784 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
785 path = g_build_filename(path, name, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
786 if (!strcmp(c, ".xml") && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
787 g_file_test(path, G_FILE_TEST_EXISTS)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
788 found = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
789 g_free(logfile); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
790 logfile = g_strdup(name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
791 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
792 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
793 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
794 g_free(path); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
795 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
796 g_dir_close(dir); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
797 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
798 g_free(username); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
799 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
800 if (!found) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
801 g_free(logfile); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
802 return list; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
803 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
804 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
805 g_free(username); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
806 g_free(logfile); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
807 logfile = NULL; /* No sense saving the obvious buddy@domain.com. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
808 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
809 |
18245
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
810 purple_debug_info("MSN log read", "Reading %s\n", path); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
811 if (!g_file_get_contents(path, &contents, &length, &error)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
812 g_free(path); |
18245
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
813 purple_debug_error("MSN log read", "Error reading log\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
814 if (error) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
815 g_error_free(error); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
816 return list; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
817 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
818 g_free(path); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
819 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
820 /* Reading the file was successful... |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
821 * Save its name if it involves the crazy numbers. The idea here is that you could |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
822 * then tweak the blist.xml file by hand if need be. This would be the case if two |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
823 * buddies have the same username at different domains. One set of logs would get |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
824 * detected for both buddies. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
825 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
826 if (buddy && logfile) { |
24314
0d0088b03745
Hide the blistnode, buddy, contact, group, and chat structs
Gary Kramlich <grim@reaperworld.com>
parents:
24034
diff
changeset
|
827 PurpleBlistNode *node = (PurpleBlistNode *)buddy; |
0d0088b03745
Hide the blistnode, buddy, contact, group, and chat structs
Gary Kramlich <grim@reaperworld.com>
parents:
24034
diff
changeset
|
828 purple_blist_node_set_string(node, "log_reader_msn_log_filename", logfile); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
829 g_free(logfile); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
830 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
831 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
832 root = xmlnode_from_str(contents, length); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
833 g_free(contents); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
834 if (!root) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
835 return list; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
836 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
837 for (message = xmlnode_get_child(root, "Message"); message; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
838 message = xmlnode_get_next_twin(message)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
839 const char *session_id; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
840 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
841 session_id = xmlnode_get_attrib(message, "SessionID"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
842 if (!session_id) { |
18245
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
843 purple_debug_error("MSN log parse", |
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
844 "Error parsing message: %s\n", "SessionID missing"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
845 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
846 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
847 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
848 if (strcmp(session_id, old_session_id)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
849 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
850 * The session ID differs from the last message. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
851 * Thus, this is the start of a new conversation. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
852 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
853 struct tm *tm; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
854 time_t stamp; |
15822 | 855 PurpleLog *log; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
856 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
857 data = g_new0(struct msn_logger_data, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
858 data->root = root; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
859 data->message = message; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
860 data->session_id = session_id; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
861 data->text = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
862 data->last_log = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
863 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
864 stamp = msn_logger_parse_timestamp(message, &tm); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
865 |
15822 | 866 log = purple_log_new(PURPLE_LOG_IM, sn, account, NULL, stamp, tm); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
867 log->logger = msn_logger; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
868 log->logger_data = data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
869 |
18249
35d981091506
Prepend to lists for performance, and use g_list_reverse when the list is
Richard Laager <rlaager@wiktel.com>
parents:
18248
diff
changeset
|
870 list = g_list_prepend(list, log); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
871 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
872 old_session_id = session_id; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
873 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
874 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
875 if (data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
876 data->last_log = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
877 |
18249
35d981091506
Prepend to lists for performance, and use g_list_reverse when the list is
Richard Laager <rlaager@wiktel.com>
parents:
18248
diff
changeset
|
878 return g_list_reverse(list); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
879 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
880 |
15822 | 881 static char * msn_logger_read (PurpleLog *log, PurpleLogReadFlags *flags) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
882 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
883 struct msn_logger_data *data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
884 GString *text = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
885 xmlnode *message; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
886 |
18765
9cec393c3a21
Fix #2349 (null pointer deref in log_reader plugin).
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18559
diff
changeset
|
887 if (flags != NULL) |
9cec393c3a21
Fix #2349 (null pointer deref in log_reader plugin).
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18559
diff
changeset
|
888 *flags = PURPLE_LOG_READ_NO_NEWLINE; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
889 g_return_val_if_fail(log != NULL, g_strdup("")); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
890 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
891 data = log->logger_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
892 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
893 if (data->text) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
894 /* The GTK code which displays the logs g_free()s whatever is |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
895 * returned from this function. Thus, we can't reuse the str |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
896 * part of the GString. The only solution is to free it and |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
897 * start over. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
898 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
899 g_string_free(data->text, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
900 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
901 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
902 text = g_string_new(""); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
903 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
904 if (!data->root || !data->message || !data->session_id) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
905 /* Something isn't allocated correctly. */ |
18245
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
906 purple_debug_error("MSN log parse", |
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
907 "Error parsing message: %s\n", "Internal variables inconsistent"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
908 data->text = text; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
909 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
910 return text->str; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
911 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
912 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
913 for (message = data->message; message; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
914 message = xmlnode_get_next_twin(message)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
915 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
916 const char *new_session_id; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
917 xmlnode *text_node; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
918 const char *from_name = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
919 const char *to_name = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
920 xmlnode *from; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
921 xmlnode *to; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
922 enum name_guesses name_guessed = NAME_GUESS_UNKNOWN; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
923 const char *their_name; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
924 time_t time_unix; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
925 struct tm *tm; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
926 char *timestamp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
927 char *tmp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
928 const char *style; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
929 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
930 new_session_id = xmlnode_get_attrib(message, "SessionID"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
931 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
932 /* If this triggers, something is wrong with the XML. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
933 if (!new_session_id) { |
18245
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
934 purple_debug_error("MSN log parse", |
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
935 "Error parsing message: %s\n", "New SessionID missing"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
936 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
937 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
938 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
939 if (strcmp(new_session_id, data->session_id)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
940 /* The session ID differs from the first message. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
941 * Thus, this is the start of a new conversation. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
942 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
943 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
944 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
945 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
946 text_node = xmlnode_get_child(message, "Text"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
947 if (!text_node) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
948 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
949 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
950 from = xmlnode_get_child(message, "From"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
951 if (from) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
952 xmlnode *user = xmlnode_get_child(from, "User"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
953 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
954 if (user) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
955 from_name = xmlnode_get_attrib(user, "FriendlyName"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
956 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
957 /* This saves a check later. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
958 if (!*from_name) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
959 from_name = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
960 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
961 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
962 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
963 to = xmlnode_get_child(message, "To"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
964 if (to) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
965 xmlnode *user = xmlnode_get_child(to, "User"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
966 if (user) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
967 to_name = xmlnode_get_attrib(user, "FriendlyName"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
968 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
969 /* This saves a check later. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
970 if (!*to_name) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
971 to_name = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
972 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
973 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
974 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
975 their_name = from_name; |
16430 | 976 if (from_name && purple_prefs_get_bool("/plugins/core/log_reader/use_name_heuristics")) { |
31932
61ce89013291
Use accessor functions in a few places
Mark Doliner <mark@kingant.net>
parents:
31757
diff
changeset
|
977 const char *friendly_name = purple_connection_get_display_name(purple_account_get_connection(log->account)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
978 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
979 if (friendly_name != NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
980 int friendly_name_length = strlen(friendly_name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
981 const char *alias; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
982 int alias_length; |
15822 | 983 PurpleBuddy *buddy = purple_find_buddy(log->account, log->name); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
984 gboolean from_name_matches; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
985 gboolean to_name_matches; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
986 |
24314
0d0088b03745
Hide the blistnode, buddy, contact, group, and chat structs
Gary Kramlich <grim@reaperworld.com>
parents:
24034
diff
changeset
|
987 if (buddy) |
0d0088b03745
Hide the blistnode, buddy, contact, group, and chat structs
Gary Kramlich <grim@reaperworld.com>
parents:
24034
diff
changeset
|
988 their_name = purple_buddy_get_alias(buddy); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
989 |
31932
61ce89013291
Use accessor functions in a few places
Mark Doliner <mark@kingant.net>
parents:
31757
diff
changeset
|
990 alias = purple_account_get_alias(log->account); |
61ce89013291
Use accessor functions in a few places
Mark Doliner <mark@kingant.net>
parents:
31757
diff
changeset
|
991 if (alias) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
992 alias_length = strlen(alias); |
31932
61ce89013291
Use accessor functions in a few places
Mark Doliner <mark@kingant.net>
parents:
31757
diff
changeset
|
993 } else { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
994 alias = ""; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
995 alias_length = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
996 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
997 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
998 /* Try to guess which user is me. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
999 * The first step is to determine if either of the names matches either my |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1000 * friendly name or alias. For this test, "match" is defined as: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1001 * ^(friendly_name|alias)([^a-zA-Z0-9].*)?$ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1002 */ |
15822 | 1003 from_name_matches = (purple_str_has_prefix(from_name, friendly_name) && |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1004 !isalnum(*(from_name + friendly_name_length))) || |
15822 | 1005 (purple_str_has_prefix(from_name, alias) && |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1006 !isalnum(*(from_name + alias_length))); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1007 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1008 to_name_matches = to_name != NULL && ( |
15822 | 1009 (purple_str_has_prefix(to_name, friendly_name) && |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1010 !isalnum(*(to_name + friendly_name_length))) || |
15822 | 1011 (purple_str_has_prefix(to_name, alias) && |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1012 !isalnum(*(to_name + alias_length)))); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1013 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1014 if (from_name_matches) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1015 if (!to_name_matches) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1016 name_guessed = NAME_GUESS_ME; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1017 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1018 } else if (to_name_matches) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1019 name_guessed = NAME_GUESS_THEM; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1020 } else { |
24314
0d0088b03745
Hide the blistnode, buddy, contact, group, and chat structs
Gary Kramlich <grim@reaperworld.com>
parents:
24034
diff
changeset
|
1021 if (buddy) { |
24315
848542528965
Simplify some of the changes. Yeah, this code sucks. I wrote it a LONG
Richard Laager <rlaager@wiktel.com>
parents:
24314
diff
changeset
|
1022 const char *server_alias = NULL; |
848542528965
Simplify some of the changes. Yeah, this code sucks. I wrote it a LONG
Richard Laager <rlaager@wiktel.com>
parents:
24314
diff
changeset
|
1023 char *alias = g_strdup(purple_buddy_get_alias(buddy)); |
848542528965
Simplify some of the changes. Yeah, this code sucks. I wrote it a LONG
Richard Laager <rlaager@wiktel.com>
parents:
24314
diff
changeset
|
1024 char *temp; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1025 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1026 /* "Truncate" the string at the first non-alphanumeric |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1027 * character. The idea is to relax the comparison. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1028 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1029 for (temp = alias; *temp ; temp++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1030 if (!isalnum(*temp)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1031 *temp = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1032 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1033 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1034 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1035 alias_length = strlen(alias); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1036 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1037 /* Try to guess which user is them. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1038 * The first step is to determine if either of the names |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1039 * matches their alias. For this test, "match" is |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1040 * defined as: ^alias([^a-zA-Z0-9].*)?$ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1041 */ |
15822 | 1042 from_name_matches = (purple_str_has_prefix( |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1043 from_name, alias) && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1044 !isalnum(*(from_name + |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1045 alias_length))); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1046 |
15822 | 1047 to_name_matches = to_name && (purple_str_has_prefix( |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1048 to_name, alias) && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1049 !isalnum(*(to_name + |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1050 alias_length))); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1051 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1052 g_free(alias); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1053 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1054 if (from_name_matches) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1055 if (!to_name_matches) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1056 name_guessed = NAME_GUESS_THEM; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1057 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1058 } else if (to_name_matches) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1059 name_guessed = NAME_GUESS_ME; |
24314
0d0088b03745
Hide the blistnode, buddy, contact, group, and chat structs
Gary Kramlich <grim@reaperworld.com>
parents:
24034
diff
changeset
|
1060 } else if ((server_alias = purple_buddy_get_server_alias(buddy))) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1061 friendly_name_length = |
24314
0d0088b03745
Hide the blistnode, buddy, contact, group, and chat structs
Gary Kramlich <grim@reaperworld.com>
parents:
24034
diff
changeset
|
1062 strlen(server_alias); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1063 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1064 /* Try to guess which user is them. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1065 * The first step is to determine if either of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1066 * the names matches their friendly name. For |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1067 * this test, "match" is defined as: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1068 * ^friendly_name([^a-zA-Z0-9].*)?$ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1069 */ |
15822 | 1070 from_name_matches = (purple_str_has_prefix( |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1071 from_name, |
24314
0d0088b03745
Hide the blistnode, buddy, contact, group, and chat structs
Gary Kramlich <grim@reaperworld.com>
parents:
24034
diff
changeset
|
1072 server_alias) && |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1073 !isalnum(*(from_name + |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1074 friendly_name_length))); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1075 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1076 to_name_matches = to_name && ( |
15822 | 1077 (purple_str_has_prefix( |
24314
0d0088b03745
Hide the blistnode, buddy, contact, group, and chat structs
Gary Kramlich <grim@reaperworld.com>
parents:
24034
diff
changeset
|
1078 to_name, server_alias) && |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1079 !isalnum(*(to_name + |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1080 friendly_name_length)))); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1081 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1082 if (from_name_matches) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1083 if (!to_name_matches) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1084 name_guessed = NAME_GUESS_THEM; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1085 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1086 } else if (to_name_matches) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1087 name_guessed = NAME_GUESS_ME; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1088 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1089 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1090 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1091 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1092 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1093 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1094 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1095 if (name_guessed != NAME_GUESS_UNKNOWN) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1096 text = g_string_append(text, "<span style=\"color: #"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1097 if (name_guessed == NAME_GUESS_ME) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1098 text = g_string_append(text, "16569E"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1099 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1100 text = g_string_append(text, "A82F2F"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1101 text = g_string_append(text, ";\">"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1102 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1103 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1104 time_unix = msn_logger_parse_timestamp(message, &tm); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1105 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1106 timestamp = g_strdup_printf("<font size=\"2\">(%02u:%02u:%02u)</font> ", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1107 tm->tm_hour, tm->tm_min, tm->tm_sec); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1108 text = g_string_append(text, timestamp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1109 g_free(timestamp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1110 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1111 if (from_name) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1112 text = g_string_append(text, "<b>"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1113 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1114 if (name_guessed == NAME_GUESS_ME) { |
31932
61ce89013291
Use accessor functions in a few places
Mark Doliner <mark@kingant.net>
parents:
31757
diff
changeset
|
1115 if (purple_account_get_alias(log->account)) |
61ce89013291
Use accessor functions in a few places
Mark Doliner <mark@kingant.net>
parents:
31757
diff
changeset
|
1116 text = g_string_append(text, purple_account_get_alias(log->account)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1117 else |
31932
61ce89013291
Use accessor functions in a few places
Mark Doliner <mark@kingant.net>
parents:
31757
diff
changeset
|
1118 text = g_string_append(text, purple_account_get_username(log->account)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1119 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1120 else if (name_guessed == NAME_GUESS_THEM) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1121 text = g_string_append(text, their_name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1122 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1123 text = g_string_append(text, from_name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1124 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1125 text = g_string_append(text, ":</b> "); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1126 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1127 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1128 if (name_guessed != NAME_GUESS_UNKNOWN) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1129 text = g_string_append(text, "</span>"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1130 |
18795
883c18d31bf4
Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18785
diff
changeset
|
1131 style = xmlnode_get_attrib(text_node, "Style"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1132 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1133 tmp = xmlnode_get_data(text_node); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1134 if (style && *style) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1135 text = g_string_append(text, "<span style=\""); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1136 text = g_string_append(text, style); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1137 text = g_string_append(text, "\">"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1138 text = g_string_append(text, tmp); |
18372
47ff5e98b371
Make the MSN logger set flags and ues <br> instead of \n. This fixes the
Richard Laager <rlaager@wiktel.com>
parents:
18371
diff
changeset
|
1139 text = g_string_append(text, "</span><br>"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1140 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1141 text = g_string_append(text, tmp); |
18372
47ff5e98b371
Make the MSN logger set flags and ues <br> instead of \n. This fixes the
Richard Laager <rlaager@wiktel.com>
parents:
18371
diff
changeset
|
1142 text = g_string_append(text, "<br>"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1143 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1144 g_free(tmp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1145 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1146 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1147 data->text = text; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1148 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1149 return text->str; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1150 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1151 |
15822 | 1152 static int msn_logger_size (PurpleLog *log) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1153 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1154 char *text; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1155 size_t size; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1156 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1157 g_return_val_if_fail(log != NULL, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1158 |
16430 | 1159 if (purple_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1160 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1161 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1162 text = msn_logger_read(log, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1163 size = strlen(text); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1164 g_free(text); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1165 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1166 return size; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1167 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1168 |
15822 | 1169 static void msn_logger_finalize(PurpleLog *log) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1170 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1171 struct msn_logger_data *data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1172 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1173 g_return_if_fail(log != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1174 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1175 data = log->logger_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1176 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1177 if (data->last_log) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1178 xmlnode_free(data->root); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1179 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1180 if (data->text) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1181 g_string_free(data->text, FALSE); |
18246
e236b3bd4542
Eliminate some leaks.
Richard Laager <rlaager@wiktel.com>
parents:
18245
diff
changeset
|
1182 |
e236b3bd4542
Eliminate some leaks.
Richard Laager <rlaager@wiktel.com>
parents:
18245
diff
changeset
|
1183 g_free(data); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1184 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1185 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1186 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1187 /***************************************************************************** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1188 * Trillian Logger * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1189 *****************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1190 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1191 /* The trillian logger doesn't write logs, only reads them. This is to include |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1192 * Trillian logs in the log viewer transparently. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1193 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1194 |
15822 | 1195 static PurpleLogLogger *trillian_logger; |
1196 static void trillian_logger_finalize(PurpleLog *log); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1197 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1198 struct trillian_logger_data { |
15822 | 1199 char *path; /* FIXME: Change this to use PurpleStringref like log.c:old_logger_list */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1200 int offset; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1201 int length; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1202 char *their_nickname; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1203 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1204 |
15822 | 1205 static GList *trillian_logger_list(PurpleLogType type, const char *sn, PurpleAccount *account) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1206 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1207 GList *list = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1208 const char *logdir; |
15822 | 1209 PurplePlugin *plugin; |
1210 PurplePluginProtocolInfo *prpl_info; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1211 char *prpl_name; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1212 const char *buddy_name; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1213 char *filename; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1214 char *path; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1215 GError *error = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1216 gchar *contents = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1217 gsize length; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1218 gchar *line; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1219 gchar *c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1220 |
18795
883c18d31bf4
Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18785
diff
changeset
|
1221 g_return_val_if_fail(sn != NULL, NULL); |
883c18d31bf4
Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18785
diff
changeset
|
1222 g_return_val_if_fail(account != NULL, NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1223 |
16430 | 1224 logdir = purple_prefs_get_string("/plugins/core/log_reader/trillian/log_directory"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1225 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1226 /* By clearing the log directory path, this logger can be (effectively) disabled. */ |
18795
883c18d31bf4
Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18785
diff
changeset
|
1227 if (!logdir || !*logdir) |
883c18d31bf4
Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18785
diff
changeset
|
1228 return NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1229 |
15822 | 1230 plugin = purple_find_prpl(purple_account_get_protocol_id(account)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1231 if (!plugin) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1232 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1233 |
15822 | 1234 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1235 if (!prpl_info->list_icon) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1236 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1237 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1238 prpl_name = g_ascii_strup(prpl_info->list_icon(account, NULL), -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1239 |
15822 | 1240 buddy_name = purple_normalize(account, sn); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1241 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1242 filename = g_strdup_printf("%s.log", buddy_name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1243 path = g_build_filename( |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1244 logdir, prpl_name, filename, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1245 |
18245
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
1246 purple_debug_info("Trillian log list", "Reading %s\n", path); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1247 /* FIXME: There's really no need to read the entire file at once. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1248 * See src/log.c:old_logger_list for a better approach. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1249 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1250 if (!g_file_get_contents(path, &contents, &length, &error)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1251 if (error) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1252 g_error_free(error); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1253 error = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1254 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1255 g_free(path); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1256 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1257 path = g_build_filename( |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1258 logdir, prpl_name, "Query", filename, NULL); |
18245
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
1259 purple_debug_info("Trillian log list", "Reading %s\n", path); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1260 if (!g_file_get_contents(path, &contents, &length, &error)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1261 if (error) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1262 g_error_free(error); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1263 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1264 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1265 g_free(filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1266 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1267 if (contents) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1268 struct trillian_logger_data *data = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1269 int offset = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1270 int last_line_offset = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1271 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1272 line = contents; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1273 c = contents; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1274 while (*c) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1275 offset++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1276 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1277 if (*c != '\n') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1278 c++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1279 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1280 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1281 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1282 *c = '\0'; |
15822 | 1283 if (purple_str_has_prefix(line, "Session Close ")) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1284 if (data && !data->length) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1285 if (!(data->length = last_line_offset - data->offset)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1286 /* This log had no data, so we remove it. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1287 GList *last = g_list_last(list); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1288 |
18245
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
1289 purple_debug_info("Trillian log list", |
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
1290 "Empty log. Offset %i\n", data->offset); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1291 |
15822 | 1292 trillian_logger_finalize((PurpleLog *)last->data); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1293 list = g_list_delete_link(list, last); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1294 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1295 } |
18108
c0cd4d84ba52
Fix a mistake noticed by Michael Shkutkov and add a comment explaining the code.
Richard Laager <rlaager@wiktel.com>
parents:
17531
diff
changeset
|
1296 } else if (line[0] && line[1] && line[2] && |
15822 | 1297 purple_str_has_prefix(&line[3], "sion Start ")) { |
18108
c0cd4d84ba52
Fix a mistake noticed by Michael Shkutkov and add a comment explaining the code.
Richard Laager <rlaager@wiktel.com>
parents:
17531
diff
changeset
|
1298 /* The conditional is to make sure we're not reading off |
c0cd4d84ba52
Fix a mistake noticed by Michael Shkutkov and add a comment explaining the code.
Richard Laager <rlaager@wiktel.com>
parents:
17531
diff
changeset
|
1299 * the end of the string. We don't want strlen(), as that'd |
c0cd4d84ba52
Fix a mistake noticed by Michael Shkutkov and add a comment explaining the code.
Richard Laager <rlaager@wiktel.com>
parents:
17531
diff
changeset
|
1300 * have to count the whole string needlessly. |
18248
ab761acbc614
Remove trailing whitespace.
Richard Laager <rlaager@wiktel.com>
parents:
18247
diff
changeset
|
1301 * |
18108
c0cd4d84ba52
Fix a mistake noticed by Michael Shkutkov and add a comment explaining the code.
Richard Laager <rlaager@wiktel.com>
parents:
17531
diff
changeset
|
1302 * The odd check here is because a Session Start at the |
c0cd4d84ba52
Fix a mistake noticed by Michael Shkutkov and add a comment explaining the code.
Richard Laager <rlaager@wiktel.com>
parents:
17531
diff
changeset
|
1303 * beginning of the file can be overwritten with a UTF-8 |
c0cd4d84ba52
Fix a mistake noticed by Michael Shkutkov and add a comment explaining the code.
Richard Laager <rlaager@wiktel.com>
parents:
17531
diff
changeset
|
1304 * byte order mark. Yes, it's weird. |
c0cd4d84ba52
Fix a mistake noticed by Michael Shkutkov and add a comment explaining the code.
Richard Laager <rlaager@wiktel.com>
parents:
17531
diff
changeset
|
1305 */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1306 char *their_nickname = line; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1307 char *timestamp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1308 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1309 if (data && !data->length) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1310 data->length = last_line_offset - data->offset; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1311 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1312 while (*their_nickname && (*their_nickname != ':')) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1313 their_nickname++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1314 their_nickname++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1315 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1316 /* This code actually has nothing to do with |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1317 * the timestamp YET. I'm simply using this |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1318 * variable for now to NUL-terminate the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1319 * their_nickname string. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1320 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1321 timestamp = their_nickname; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1322 while (*timestamp && *timestamp != ')') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1323 timestamp++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1324 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1325 if (*timestamp == ')') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1326 char *month; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1327 struct tm tm; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1328 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1329 *timestamp = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1330 if (line[0] && line[1] && line[2]) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1331 timestamp += 3; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1332 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1333 /* Now we start dealing with the timestamp. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1334 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1335 /* Skip over the day name. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1336 while (*timestamp && (*timestamp != ' ')) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1337 timestamp++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1338 *timestamp = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1339 timestamp++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1340 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1341 /* Parse out the month. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1342 month = timestamp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1343 while (*timestamp && (*timestamp != ' ')) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1344 timestamp++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1345 *timestamp = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1346 timestamp++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1347 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1348 /* Parse the day, time, and year. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1349 if (sscanf(timestamp, "%u %u:%u:%u %u", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1350 &tm.tm_mday, &tm.tm_hour, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1351 &tm.tm_min, &tm.tm_sec, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1352 &tm.tm_year) != 5) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1353 |
18245
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
1354 purple_debug_error("Trillian log timestamp parse", |
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
1355 "Session Start parsing error\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1356 } else { |
15822 | 1357 PurpleLog *log; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1358 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1359 tm.tm_year -= 1900; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1360 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1361 /* Let the C library deal with |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1362 * daylight savings time. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1363 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1364 tm.tm_isdst = -1; |
20909
feca1fd51b57
Use functions and loops and all those fancy things.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20898
diff
changeset
|
1365 tm.tm_mon = get_month(month); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1366 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1367 data = g_new0( |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1368 struct trillian_logger_data, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1369 data->path = g_strdup(path); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1370 data->offset = offset; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1371 data->length = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1372 data->their_nickname = |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1373 g_strdup(their_nickname); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1374 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1375 /* XXX: Look into this later... Should we pass in a struct tm? */ |
15822 | 1376 log = purple_log_new(PURPLE_LOG_IM, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1377 sn, account, NULL, mktime(&tm), NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1378 log->logger = trillian_logger; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1379 log->logger_data = data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1380 |
18249
35d981091506
Prepend to lists for performance, and use g_list_reverse when the list is
Richard Laager <rlaager@wiktel.com>
parents:
18248
diff
changeset
|
1381 list = g_list_prepend(list, log); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1382 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1383 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1384 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1385 c++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1386 line = c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1387 last_line_offset = offset; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1388 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1389 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1390 g_free(contents); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1391 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1392 g_free(path); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1393 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1394 g_free(prpl_name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1395 |
18249
35d981091506
Prepend to lists for performance, and use g_list_reverse when the list is
Richard Laager <rlaager@wiktel.com>
parents:
18248
diff
changeset
|
1396 return g_list_reverse(list); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1397 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1398 |
15822 | 1399 static char * trillian_logger_read (PurpleLog *log, PurpleLogReadFlags *flags) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1400 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1401 struct trillian_logger_data *data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1402 char *read; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1403 FILE *file; |
15822 | 1404 PurpleBuddy *buddy; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1405 char *escaped; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1406 GString *formatted; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1407 char *c; |
17528
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1408 const char *line; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1409 |
18795
883c18d31bf4
Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18785
diff
changeset
|
1410 if (flags != NULL) |
883c18d31bf4
Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18785
diff
changeset
|
1411 *flags = PURPLE_LOG_READ_NO_NEWLINE; |
18785
3cc77409b858
bug with flags variable initialization was fixed
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18765
diff
changeset
|
1412 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1413 g_return_val_if_fail(log != NULL, g_strdup("")); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1414 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1415 data = log->logger_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1416 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1417 g_return_val_if_fail(data->path != NULL, g_strdup("")); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1418 g_return_val_if_fail(data->length > 0, g_strdup("")); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1419 g_return_val_if_fail(data->their_nickname != NULL, g_strdup("")); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1420 |
18245
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
1421 purple_debug_info("Trillian log read", "Reading %s\n", data->path); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1422 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1423 read = g_malloc(data->length + 2); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1424 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1425 file = g_fopen(data->path, "rb"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1426 fseek(file, data->offset, SEEK_SET); |
20910
54d232b52607
Since we are looking at the return value of fread, it actually matters that
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20909
diff
changeset
|
1427 data->length = fread(read, 1, data->length, file); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1428 fclose(file); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1429 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1430 if (read[data->length-1] == '\n') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1431 read[data->length] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1432 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1433 read[data->length] = '\n'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1434 read[data->length+1] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1435 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1436 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1437 /* Load miscellaneous data. */ |
15822 | 1438 buddy = purple_find_buddy(log->account, log->name); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1439 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1440 escaped = g_markup_escape_text(read, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1441 g_free(read); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1442 read = escaped; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1443 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1444 /* Apply formatting... */ |
17529
c529c95e7733
Size the formatting string first, to avoid unnecessary resizing.
Richard Laager <rlaager@wiktel.com>
parents:
17528
diff
changeset
|
1445 formatted = g_string_sized_new(strlen(read)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1446 c = read; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1447 line = read; |
17528
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1448 while (c) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1449 { |
17528
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1450 const char *link; |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1451 const char *footer = NULL; |
17531
21773944db4b
Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents:
17530
diff
changeset
|
1452 GString *temp = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1453 |
31757
b863432e81d1
log_reader: Properly fix the QIP crash, and unbreak the Trillian reader (c is NULL the last time through, so just quit out early then)
Paul Aurich <paul@darkrain42.org>
parents:
31755
diff
changeset
|
1454 /* There's always a trailing '\n' at the end of the file (see above), so |
b863432e81d1
log_reader: Properly fix the QIP crash, and unbreak the Trillian reader (c is NULL the last time through, so just quit out early then)
Paul Aurich <paul@darkrain42.org>
parents:
31755
diff
changeset
|
1455 * just quit out if we don't find another, because we're at the end. |
b863432e81d1
log_reader: Properly fix the QIP crash, and unbreak the Trillian reader (c is NULL the last time through, so just quit out early then)
Paul Aurich <paul@darkrain42.org>
parents:
31755
diff
changeset
|
1456 */ |
31753
d1ea32c41634
log_reader: strchr(), and some simplifying to make clang happier
Paul Aurich <paul@darkrain42.org>
parents:
31086
diff
changeset
|
1457 c = strchr(c, '\n'); |
31757
b863432e81d1
log_reader: Properly fix the QIP crash, and unbreak the Trillian reader (c is NULL the last time through, so just quit out early then)
Paul Aurich <paul@darkrain42.org>
parents:
31755
diff
changeset
|
1458 if (!c) |
b863432e81d1
log_reader: Properly fix the QIP crash, and unbreak the Trillian reader (c is NULL the last time through, so just quit out early then)
Paul Aurich <paul@darkrain42.org>
parents:
31755
diff
changeset
|
1459 break; |
b863432e81d1
log_reader: Properly fix the QIP crash, and unbreak the Trillian reader (c is NULL the last time through, so just quit out early then)
Paul Aurich <paul@darkrain42.org>
parents:
31755
diff
changeset
|
1460 |
31753
d1ea32c41634
log_reader: strchr(), and some simplifying to make clang happier
Paul Aurich <paul@darkrain42.org>
parents:
31086
diff
changeset
|
1461 *c = '\0'; |
d1ea32c41634
log_reader: strchr(), and some simplifying to make clang happier
Paul Aurich <paul@darkrain42.org>
parents:
31086
diff
changeset
|
1462 c++; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1463 |
17528
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1464 /* Convert links. |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1465 * |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1466 * The format is (Link: URL)URL |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1467 * So, I want to find each occurance of "(Link: " and replace that chunk with: |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1468 * <a href=" |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1469 * Then, replace the next ")" with: |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1470 * "> |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1471 * Then, replace the next " " (or add this if the end-of-line is reached) with: |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1472 * </a> |
18248
ab761acbc614
Remove trailing whitespace.
Richard Laager <rlaager@wiktel.com>
parents:
18247
diff
changeset
|
1473 * |
17528
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1474 * As implemented, this isn't perfect, but it should cover common cases. |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1475 */ |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1476 while (line && (link = strstr(line, "(Link: "))) |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1477 { |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1478 const char *tmp = link; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1479 |
17528
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1480 link += 7; |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1481 if (*link) |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1482 { |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1483 char *end_paren; |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1484 char *space; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1485 |
31753
d1ea32c41634
log_reader: strchr(), and some simplifying to make clang happier
Paul Aurich <paul@darkrain42.org>
parents:
31086
diff
changeset
|
1486 if (!(end_paren = strchr(link, ')'))) |
17528
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1487 { |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1488 /* Something is not as we expect. Bail out. */ |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1489 break; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1490 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1491 |
17531
21773944db4b
Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents:
17530
diff
changeset
|
1492 if (!temp) |
31753
d1ea32c41634
log_reader: strchr(), and some simplifying to make clang happier
Paul Aurich <paul@darkrain42.org>
parents:
31086
diff
changeset
|
1493 temp = g_string_sized_new(strlen(line)); |
17531
21773944db4b
Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents:
17530
diff
changeset
|
1494 |
17528
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1495 g_string_append_len(temp, line, (tmp - line)); |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1496 |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1497 /* Start an <a> tag. */ |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1498 g_string_append(temp, "<a href=\""); |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1499 |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1500 /* Append up to the ) */ |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1501 g_string_append_len(temp, link, end_paren - link); |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1502 |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1503 /* Finish the <a> tag. */ |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1504 g_string_append(temp, "\">"); |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1505 |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1506 /* The \r is a bit of a hack to keep there from being a \r in |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1507 * the link text, which may not matter. */ |
31753
d1ea32c41634
log_reader: strchr(), and some simplifying to make clang happier
Paul Aurich <paul@darkrain42.org>
parents:
31086
diff
changeset
|
1508 if ((space = strchr(end_paren, ' ')) || (space = strchr(end_paren, '\r'))) |
17528
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1509 { |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1510 g_string_append_len(temp, end_paren + 1, space - end_paren - 1); |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1511 |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1512 /* Close the <a> tag. */ |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1513 g_string_append(temp, "</a>"); |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1514 |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1515 space++; |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1516 } |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1517 else |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1518 { |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1519 /* There is no space before the end of the line. */ |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1520 g_string_append(temp, end_paren + 1); |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1521 /* Close the <a> tag. */ |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1522 g_string_append(temp, "</a>"); |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1523 } |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1524 line = space; |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1525 } |
17530
a6594c34635b
Bail out to avoid an infinite loop in an extreme corner case.
Richard Laager <rlaager@wiktel.com>
parents:
17529
diff
changeset
|
1526 else |
a6594c34635b
Bail out to avoid an infinite loop in an extreme corner case.
Richard Laager <rlaager@wiktel.com>
parents:
17529
diff
changeset
|
1527 { |
a6594c34635b
Bail out to avoid an infinite loop in an extreme corner case.
Richard Laager <rlaager@wiktel.com>
parents:
17529
diff
changeset
|
1528 /* Something is not as we expect. Bail out. */ |
a6594c34635b
Bail out to avoid an infinite loop in an extreme corner case.
Richard Laager <rlaager@wiktel.com>
parents:
17529
diff
changeset
|
1529 break; |
a6594c34635b
Bail out to avoid an infinite loop in an extreme corner case.
Richard Laager <rlaager@wiktel.com>
parents:
17529
diff
changeset
|
1530 } |
17528
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1531 } |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1532 |
17531
21773944db4b
Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents:
17530
diff
changeset
|
1533 if (temp) |
21773944db4b
Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents:
17530
diff
changeset
|
1534 { |
21773944db4b
Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents:
17530
diff
changeset
|
1535 if (line) |
21773944db4b
Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents:
17530
diff
changeset
|
1536 g_string_append(temp, line); |
21773944db4b
Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents:
17530
diff
changeset
|
1537 line = temp->str; |
17528
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1538 } |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1539 |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1540 if (*line == '[') { |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1541 const char *timestamp; |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1542 |
31753
d1ea32c41634
log_reader: strchr(), and some simplifying to make clang happier
Paul Aurich <paul@darkrain42.org>
parents:
31086
diff
changeset
|
1543 if ((timestamp = strchr(line, ']'))) { |
17528
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1544 line++; |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1545 /* TODO: Parse the timestamp and convert it to Purple's format. */ |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1546 g_string_append(formatted, "<font size=\"2\">("); |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1547 g_string_append_len(formatted, line, (timestamp - line)); |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1548 g_string_append(formatted,")</font> "); |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1549 line = timestamp + 1; |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1550 if (line[0] && line[1]) |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1551 line++; |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1552 } |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1553 |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1554 if (purple_str_has_prefix(line, "*** ")) { |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1555 line += (sizeof("*** ") - 1); |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1556 g_string_append(formatted, "<b>"); |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1557 footer = "</b>"; |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1558 if (purple_str_has_prefix(line, "NOTE: This user is offline.")) { |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1559 line = _("User is offline."); |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1560 } else if (purple_str_has_prefix(line, |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1561 "NOTE: Your status is currently set to ")) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1562 |
17528
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1563 line += (sizeof("NOTE: ") - 1); |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1564 } else if (purple_str_has_prefix(line, "Auto-response sent to ")) { |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1565 g_string_append(formatted, _("Auto-response sent:")); |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1566 while (*line && *line != ':') |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1567 line++; |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1568 if (*line) |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1569 line++; |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1570 g_string_append(formatted, "</b>"); |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1571 footer = NULL; |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1572 } else if (strstr(line, " signed off ")) { |
24315
848542528965
Simplify some of the changes. Yeah, this code sucks. I wrote it a LONG
Richard Laager <rlaager@wiktel.com>
parents:
24314
diff
changeset
|
1573 const char *alias = NULL; |
848542528965
Simplify some of the changes. Yeah, this code sucks. I wrote it a LONG
Richard Laager <rlaager@wiktel.com>
parents:
24314
diff
changeset
|
1574 |
848542528965
Simplify some of the changes. Yeah, this code sucks. I wrote it a LONG
Richard Laager <rlaager@wiktel.com>
parents:
24314
diff
changeset
|
1575 if (buddy != NULL) |
848542528965
Simplify some of the changes. Yeah, this code sucks. I wrote it a LONG
Richard Laager <rlaager@wiktel.com>
parents:
24314
diff
changeset
|
1576 alias = purple_buddy_get_alias(buddy); |
848542528965
Simplify some of the changes. Yeah, this code sucks. I wrote it a LONG
Richard Laager <rlaager@wiktel.com>
parents:
24314
diff
changeset
|
1577 |
848542528965
Simplify some of the changes. Yeah, this code sucks. I wrote it a LONG
Richard Laager <rlaager@wiktel.com>
parents:
24314
diff
changeset
|
1578 if (alias != NULL) { |
848542528965
Simplify some of the changes. Yeah, this code sucks. I wrote it a LONG
Richard Laager <rlaager@wiktel.com>
parents:
24314
diff
changeset
|
1579 g_string_append_printf(formatted, |
848542528965
Simplify some of the changes. Yeah, this code sucks. I wrote it a LONG
Richard Laager <rlaager@wiktel.com>
parents:
24314
diff
changeset
|
1580 _("%s has signed off."), alias); |
24314
0d0088b03745
Hide the blistnode, buddy, contact, group, and chat structs
Gary Kramlich <grim@reaperworld.com>
parents:
24034
diff
changeset
|
1581 } else { |
17528
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1582 g_string_append_printf(formatted, |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1583 _("%s has signed off."), log->name); |
24314
0d0088b03745
Hide the blistnode, buddy, contact, group, and chat structs
Gary Kramlich <grim@reaperworld.com>
parents:
24034
diff
changeset
|
1584 } |
17528
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1585 line = ""; |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1586 } else if (strstr(line, " signed on ")) { |
24315
848542528965
Simplify some of the changes. Yeah, this code sucks. I wrote it a LONG
Richard Laager <rlaager@wiktel.com>
parents:
24314
diff
changeset
|
1587 const char *alias = NULL; |
848542528965
Simplify some of the changes. Yeah, this code sucks. I wrote it a LONG
Richard Laager <rlaager@wiktel.com>
parents:
24314
diff
changeset
|
1588 |
848542528965
Simplify some of the changes. Yeah, this code sucks. I wrote it a LONG
Richard Laager <rlaager@wiktel.com>
parents:
24314
diff
changeset
|
1589 if (buddy != NULL) |
848542528965
Simplify some of the changes. Yeah, this code sucks. I wrote it a LONG
Richard Laager <rlaager@wiktel.com>
parents:
24314
diff
changeset
|
1590 alias = purple_buddy_get_alias(buddy); |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
29408
diff
changeset
|
1591 |
24315
848542528965
Simplify some of the changes. Yeah, this code sucks. I wrote it a LONG
Richard Laager <rlaager@wiktel.com>
parents:
24314
diff
changeset
|
1592 if (alias != NULL) |
848542528965
Simplify some of the changes. Yeah, this code sucks. I wrote it a LONG
Richard Laager <rlaager@wiktel.com>
parents:
24314
diff
changeset
|
1593 g_string_append(formatted, alias); |
848542528965
Simplify some of the changes. Yeah, this code sucks. I wrote it a LONG
Richard Laager <rlaager@wiktel.com>
parents:
24314
diff
changeset
|
1594 else |
17528
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1595 g_string_append(formatted, log->name); |
24315
848542528965
Simplify some of the changes. Yeah, this code sucks. I wrote it a LONG
Richard Laager <rlaager@wiktel.com>
parents:
24314
diff
changeset
|
1596 |
17528
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1597 line = " logged in."; |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1598 } else if (purple_str_has_prefix(line, |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1599 "One or more messages may have been undeliverable.")) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1600 |
17528
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1601 g_string_append(formatted, |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1602 "<span style=\"color: #ff0000;\">"); |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1603 g_string_append(formatted, |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1604 _("One or more messages may have been " |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1605 "undeliverable.")); |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1606 line = ""; |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1607 footer = "</span></b>"; |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1608 } else if (purple_str_has_prefix(line, |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1609 "You have been disconnected.")) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1610 |
17528
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1611 g_string_append(formatted, |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1612 "<span style=\"color: #ff0000;\">"); |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1613 g_string_append(formatted, |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1614 _("You were disconnected from the server.")); |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1615 line = ""; |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1616 footer = "</span></b>"; |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1617 } else if (purple_str_has_prefix(line, |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1618 "You are currently disconnected.")) { |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1619 |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1620 g_string_append(formatted, |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1621 "<span style=\"color: #ff0000;\">"); |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1622 line = _("You are currently disconnected. Messages " |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1623 "will not be received unless you are " |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1624 "logged in."); |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1625 footer = "</span></b>"; |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1626 } else if (purple_str_has_prefix(line, |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1627 "Your previous message has not been sent.")) { |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1628 |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1629 g_string_append(formatted, |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1630 "<span style=\"color: #ff0000;\">"); |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1631 |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1632 if (purple_str_has_prefix(line, |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1633 "Your previous message has not been sent. " |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1634 "Reason: Maximum length exceeded.")) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1635 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1636 g_string_append(formatted, |
17528
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1637 _("Message could not be sent because " |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1638 "the maximum length was exceeded.")); |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1639 line = ""; |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1640 } else { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1641 g_string_append(formatted, |
17528
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1642 _("Message could not be sent.")); |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1643 line += (sizeof( |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1644 "Your previous message " |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1645 "has not been sent. ") - 1); |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1646 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1647 |
17528
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1648 footer = "</span></b>"; |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1649 } |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1650 } else if (purple_str_has_prefix(line, data->their_nickname)) { |
24314
0d0088b03745
Hide the blistnode, buddy, contact, group, and chat structs
Gary Kramlich <grim@reaperworld.com>
parents:
24034
diff
changeset
|
1651 if (buddy != NULL) { |
24315
848542528965
Simplify some of the changes. Yeah, this code sucks. I wrote it a LONG
Richard Laager <rlaager@wiktel.com>
parents:
24314
diff
changeset
|
1652 const char *alias = purple_buddy_get_alias(buddy); |
848542528965
Simplify some of the changes. Yeah, this code sucks. I wrote it a LONG
Richard Laager <rlaager@wiktel.com>
parents:
24314
diff
changeset
|
1653 |
848542528965
Simplify some of the changes. Yeah, this code sucks. I wrote it a LONG
Richard Laager <rlaager@wiktel.com>
parents:
24314
diff
changeset
|
1654 if (alias != NULL) { |
24314
0d0088b03745
Hide the blistnode, buddy, contact, group, and chat structs
Gary Kramlich <grim@reaperworld.com>
parents:
24034
diff
changeset
|
1655 line += strlen(data->their_nickname) + 2; |
0d0088b03745
Hide the blistnode, buddy, contact, group, and chat structs
Gary Kramlich <grim@reaperworld.com>
parents:
24034
diff
changeset
|
1656 g_string_append_printf(formatted, |
0d0088b03745
Hide the blistnode, buddy, contact, group, and chat structs
Gary Kramlich <grim@reaperworld.com>
parents:
24034
diff
changeset
|
1657 "<span style=\"color: #A82F2F;\">" |
0d0088b03745
Hide the blistnode, buddy, contact, group, and chat structs
Gary Kramlich <grim@reaperworld.com>
parents:
24034
diff
changeset
|
1658 "<b>%s</b></span>: ", alias); |
0d0088b03745
Hide the blistnode, buddy, contact, group, and chat structs
Gary Kramlich <grim@reaperworld.com>
parents:
24034
diff
changeset
|
1659 } |
17528
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1660 } |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1661 } else { |
31753
d1ea32c41634
log_reader: strchr(), and some simplifying to make clang happier
Paul Aurich <paul@darkrain42.org>
parents:
31086
diff
changeset
|
1662 const char *line2 = strchr(line, ':'); |
17528
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1663 if (line2) { |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1664 const char *acct_name; |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1665 line2++; |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1666 line = line2; |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1667 acct_name = purple_account_get_alias(log->account); |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1668 if (!acct_name) |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1669 acct_name = purple_account_get_username(log->account); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1670 |
17528
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1671 g_string_append_printf(formatted, |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1672 "<span style=\"color: #16569E;\">" |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1673 "<b>%s</b></span>:", acct_name); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1674 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1675 } |
17528
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1676 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1677 |
17528
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1678 g_string_append(formatted, line); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1679 |
17531
21773944db4b
Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents:
17530
diff
changeset
|
1680 line = c; |
21773944db4b
Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents:
17530
diff
changeset
|
1681 if (temp) |
21773944db4b
Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents:
17530
diff
changeset
|
1682 g_string_free(temp, TRUE); |
21773944db4b
Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents:
17530
diff
changeset
|
1683 |
17528
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1684 if (footer) |
beeef78409b2
A patch from o_sukhodolsky to restructure the Trillian log formatting code
Richard Laager <rlaager@wiktel.com>
parents:
17467
diff
changeset
|
1685 g_string_append(formatted, footer); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1686 |
18360
d8f783ed28d3
Make the Trillian logger set flags properly, and use <br> instead of \n for
Richard Laager <rlaager@wiktel.com>
parents:
18359
diff
changeset
|
1687 g_string_append(formatted, "<br>"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1688 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1689 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1690 g_free(read); |
18360
d8f783ed28d3
Make the Trillian logger set flags properly, and use <br> instead of \n for
Richard Laager <rlaager@wiktel.com>
parents:
18359
diff
changeset
|
1691 |
d8f783ed28d3
Make the Trillian logger set flags properly, and use <br> instead of \n for
Richard Laager <rlaager@wiktel.com>
parents:
18359
diff
changeset
|
1692 /* XXX: TODO: What can we do about removing \r characters? |
d8f783ed28d3
Make the Trillian logger set flags properly, and use <br> instead of \n for
Richard Laager <rlaager@wiktel.com>
parents:
18359
diff
changeset
|
1693 * XXX: TODO: and will that allow us to avoid this |
d8f783ed28d3
Make the Trillian logger set flags properly, and use <br> instead of \n for
Richard Laager <rlaager@wiktel.com>
parents:
18359
diff
changeset
|
1694 * XXX: TODO: g_strchomp(), or is that unrelated? */ |
17531
21773944db4b
Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents:
17530
diff
changeset
|
1695 /* XXX: TODO: Avoid this g_strchomp() */ |
21773944db4b
Don't create the temp GString unless it's actually needed, and avoid
Richard Laager <rlaager@wiktel.com>
parents:
17530
diff
changeset
|
1696 return g_strchomp(g_string_free(formatted, FALSE)); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1697 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1698 |
15822 | 1699 static int trillian_logger_size (PurpleLog *log) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1700 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1701 struct trillian_logger_data *data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1702 char *text; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1703 size_t size; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1704 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1705 g_return_val_if_fail(log != NULL, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1706 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1707 data = log->logger_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1708 |
16430 | 1709 if (purple_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1710 return data ? data->length : 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1711 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1712 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1713 text = trillian_logger_read(log, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1714 size = strlen(text); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1715 g_free(text); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1716 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1717 return size; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1718 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1719 |
15822 | 1720 static void trillian_logger_finalize(PurpleLog *log) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1721 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1722 struct trillian_logger_data *data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1723 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1724 g_return_if_fail(log != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1725 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1726 data = log->logger_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1727 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1728 g_free(data->path); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1729 g_free(data->their_nickname); |
18246
e236b3bd4542
Eliminate some leaks.
Richard Laager <rlaager@wiktel.com>
parents:
18245
diff
changeset
|
1730 g_free(data); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1731 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1732 |
17979
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1733 /***************************************************************************** |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1734 * QIP Logger * |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1735 *****************************************************************************/ |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1736 |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1737 /* The QIP logger doesn't write logs, only reads them. This is to include |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1738 * QIP logs in the log viewer transparently. |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1739 */ |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1740 #define QIP_LOG_DELIMITER "--------------------------------------" |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1741 #define QIP_LOG_IN_MESSAGE (QIP_LOG_DELIMITER "<-") |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1742 #define QIP_LOG_OUT_MESSAGE (QIP_LOG_DELIMITER ">-") |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1743 #define QIP_LOG_IN_MESSAGE_ESC (QIP_LOG_DELIMITER "<-") |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1744 #define QIP_LOG_OUT_MESSAGE_ESC (QIP_LOG_DELIMITER ">-") |
18176
b14dfa2f49a1
creat new log if difference between current and previous message more then predefined constant (currently one hour)
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18175
diff
changeset
|
1745 #define QIP_LOG_TIMEOUT (60*60) |
17979
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1746 |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1747 static PurpleLogLogger *qip_logger; |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1748 |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1749 struct qip_logger_data { |
18248
ab761acbc614
Remove trailing whitespace.
Richard Laager <rlaager@wiktel.com>
parents:
18247
diff
changeset
|
1750 |
17979
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1751 char *path; /* FIXME: Change this to use PurpleStringref like log.c:old_logger_list */ |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1752 int offset; |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1753 int length; |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1754 }; |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1755 |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1756 static GList *qip_logger_list(PurpleLogType type, const char *sn, PurpleAccount *account) |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1757 { |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1758 GList *list = NULL; |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1759 const char *logdir; |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1760 PurplePlugin *plugin; |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1761 PurplePluginProtocolInfo *prpl_info; |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1762 char *username; |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1763 char *filename; |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1764 char *path; |
18251
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1765 char *contents; |
18247
97671eb4991e
Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents:
18246
diff
changeset
|
1766 struct qip_logger_data *data = NULL; |
97671eb4991e
Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents:
18246
diff
changeset
|
1767 struct tm prev_tm; |
18254
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1768 struct tm tm; |
18247
97671eb4991e
Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents:
18246
diff
changeset
|
1769 gboolean prev_tm_init = FALSE; |
18254
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1770 gboolean main_cycle = TRUE; |
18247
97671eb4991e
Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents:
18246
diff
changeset
|
1771 char *c; |
97671eb4991e
Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents:
18246
diff
changeset
|
1772 char *start_log; |
24034
1568dc7a14f8
Warnings cleanup from Lee Roach. Fixes #6242.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22830
diff
changeset
|
1773 char *new_line = NULL; |
18247
97671eb4991e
Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents:
18246
diff
changeset
|
1774 int offset = 0; |
18255
507fb436d8c0
optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18254
diff
changeset
|
1775 GError *error; |
17979
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1776 |
18795
883c18d31bf4
Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18785
diff
changeset
|
1777 g_return_val_if_fail(sn != NULL, NULL); |
883c18d31bf4
Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18785
diff
changeset
|
1778 g_return_val_if_fail(account != NULL, NULL); |
17979
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1779 |
18247
97671eb4991e
Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents:
18246
diff
changeset
|
1780 /* QIP only supports ICQ. */ |
31932
61ce89013291
Use accessor functions in a few places
Mark Doliner <mark@kingant.net>
parents:
31757
diff
changeset
|
1781 if (strcmp(purple_account_get_protocol_id(account), "prpl-icq")) |
18795
883c18d31bf4
Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18785
diff
changeset
|
1782 return NULL; |
17979
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1783 |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1784 logdir = purple_prefs_get_string("/plugins/core/log_reader/qip/log_directory"); |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1785 |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1786 /* By clearing the log directory path, this logger can be (effectively) disabled. */ |
18795
883c18d31bf4
Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18785
diff
changeset
|
1787 if (!logdir || !*logdir) |
883c18d31bf4
Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18785
diff
changeset
|
1788 return NULL; |
17979
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1789 |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1790 plugin = purple_find_prpl(purple_account_get_protocol_id(account)); |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1791 if (!plugin) |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1792 return NULL; |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1793 |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1794 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(plugin); |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1795 if (!prpl_info->list_icon) |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1796 return NULL; |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1797 |
31932
61ce89013291
Use accessor functions in a few places
Mark Doliner <mark@kingant.net>
parents:
31757
diff
changeset
|
1798 username = g_strdup(purple_normalize(account, purple_account_get_username(account))); |
18247
97671eb4991e
Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents:
18246
diff
changeset
|
1799 filename = g_strdup_printf("%s.txt", purple_normalize(account, sn)); |
97671eb4991e
Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents:
18246
diff
changeset
|
1800 path = g_build_filename(logdir, username, "History", filename, NULL); |
97671eb4991e
Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents:
18246
diff
changeset
|
1801 g_free(username); |
97671eb4991e
Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents:
18246
diff
changeset
|
1802 g_free(filename); |
97671eb4991e
Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents:
18246
diff
changeset
|
1803 |
18255
507fb436d8c0
optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18254
diff
changeset
|
1804 purple_debug_info("QIP logger", "Reading %s\n", path); |
507fb436d8c0
optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18254
diff
changeset
|
1805 |
507fb436d8c0
optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18254
diff
changeset
|
1806 error = NULL; |
507fb436d8c0
optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18254
diff
changeset
|
1807 if (!g_file_get_contents(path, &contents, NULL, &error)) { |
507fb436d8c0
optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18254
diff
changeset
|
1808 purple_debug_error("QIP logger", |
20329
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
1809 "Couldn't read file %s: %s \n", path, |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
1810 (error && error->message) ? error->message : "Unknown error"); |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
1811 if (error) |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
1812 g_error_free(error); |
18247
97671eb4991e
Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents:
18246
diff
changeset
|
1813 g_free(path); |
97671eb4991e
Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents:
18246
diff
changeset
|
1814 return list; |
97671eb4991e
Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents:
18246
diff
changeset
|
1815 } |
97671eb4991e
Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents:
18246
diff
changeset
|
1816 |
97671eb4991e
Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents:
18246
diff
changeset
|
1817 c = contents; |
97671eb4991e
Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents:
18246
diff
changeset
|
1818 start_log = contents; |
18254
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1819 while (main_cycle) { |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1820 |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1821 gboolean add_new_log = FALSE; |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1822 |
31757
b863432e81d1
log_reader: Properly fix the QIP crash, and unbreak the Trillian reader (c is NULL the last time through, so just quit out early then)
Paul Aurich <paul@darkrain42.org>
parents:
31755
diff
changeset
|
1823 if (c && *c) { |
18255
507fb436d8c0
optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18254
diff
changeset
|
1824 if (purple_str_has_prefix(c, QIP_LOG_IN_MESSAGE) || |
507fb436d8c0
optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18254
diff
changeset
|
1825 purple_str_has_prefix(c, QIP_LOG_OUT_MESSAGE)) { |
18254
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1826 |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1827 char *tmp; |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
29408
diff
changeset
|
1828 |
18254
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1829 new_line = c; |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1830 |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1831 /* find EOL */ |
31753
d1ea32c41634
log_reader: strchr(), and some simplifying to make clang happier
Paul Aurich <paul@darkrain42.org>
parents:
31086
diff
changeset
|
1832 c = strchr(c, '\n'); |
18254
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1833 c++; |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1834 |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1835 /* Find the last '(' character. */ |
31753
d1ea32c41634
log_reader: strchr(), and some simplifying to make clang happier
Paul Aurich <paul@darkrain42.org>
parents:
31086
diff
changeset
|
1836 if ((tmp = strchr(c, '\n')) != NULL) { |
18254
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1837 while (*tmp && *tmp != '(') --tmp; |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1838 c = tmp; |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1839 } else { |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1840 while (*c) |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1841 c++; |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1842 c--; |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1843 c = g_strrstr(c, "("); |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1844 } |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1845 |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1846 if (c != NULL) { |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1847 const char *timestamp = ++c; |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1848 |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1849 /* Parse the time, day, month and year */ |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1850 if (sscanf(timestamp, "%u:%u:%u %u/%u/%u", |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1851 &tm.tm_hour, &tm.tm_min, &tm.tm_sec, |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1852 &tm.tm_mday, &tm.tm_mon, &tm.tm_year) != 6) { |
18247
97671eb4991e
Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents:
18246
diff
changeset
|
1853 |
97671eb4991e
Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents:
18246
diff
changeset
|
1854 purple_debug_error("QIP logger list", |
18254
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1855 "Parsing timestamp error\n"); |
18247
97671eb4991e
Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents:
18246
diff
changeset
|
1856 } else { |
18254
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1857 tm.tm_mon -= 1; |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1858 tm.tm_year -= 1900; |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1859 |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1860 /* Let the C library deal with |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1861 * daylight savings time. */ |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1862 tm.tm_isdst = -1; |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1863 |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1864 if (!prev_tm_init) { |
18247
97671eb4991e
Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents:
18246
diff
changeset
|
1865 prev_tm = tm; |
18254
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1866 prev_tm_init = TRUE; |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1867 } else { |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1868 add_new_log = difftime(mktime(&tm), mktime(&prev_tm)) > QIP_LOG_TIMEOUT; |
18176
b14dfa2f49a1
creat new log if difference between current and previous message more then predefined constant (currently one hour)
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18175
diff
changeset
|
1869 } |
b14dfa2f49a1
creat new log if difference between current and previous message more then predefined constant (currently one hour)
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18175
diff
changeset
|
1870 } |
b14dfa2f49a1
creat new log if difference between current and previous message more then predefined constant (currently one hour)
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18175
diff
changeset
|
1871 } |
b14dfa2f49a1
creat new log if difference between current and previous message more then predefined constant (currently one hour)
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18175
diff
changeset
|
1872 } |
18247
97671eb4991e
Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents:
18246
diff
changeset
|
1873 } else { |
18254
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1874 add_new_log = TRUE; |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1875 main_cycle = FALSE; |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1876 new_line = c; |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1877 } |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1878 |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1879 /* adding log */ |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1880 if (add_new_log && prev_tm_init) { |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1881 PurpleLog *log; |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1882 |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1883 /* filling data */ |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1884 data = g_new0(struct qip_logger_data, 1); |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1885 data->path = g_strdup(path); |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1886 data->length = new_line - start_log; |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1887 data->offset = offset; |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1888 offset += data->length; |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1889 purple_debug_info("QIP logger list", |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
29408
diff
changeset
|
1890 "Creating log: path = (%s); length = (%d); offset = (%d)\n", |
18254
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1891 data->path, data->length, data->offset); |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1892 |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1893 /* XXX: Look into this later... Should we pass in a struct tm? */ |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1894 log = purple_log_new(PURPLE_LOG_IM, sn, account, |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1895 NULL, mktime(&prev_tm), NULL); |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1896 |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1897 log->logger = qip_logger; |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1898 log->logger_data = data; |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1899 |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1900 list = g_list_prepend(list, log); |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1901 |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1902 prev_tm = tm; |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1903 start_log = new_line; |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1904 } |
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1905 |
31755
6d6056e176fe
log_reader: Fix an actual crash in the QIP reader.
Paul Aurich <paul@darkrain42.org>
parents:
31753
diff
changeset
|
1906 if (c && *c) { |
18254
991f33e9e1a4
avoiding some finding EOL and creating new log only in one place
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18253
diff
changeset
|
1907 /* find EOF */ |
31757
b863432e81d1
log_reader: Properly fix the QIP crash, and unbreak the Trillian reader (c is NULL the last time through, so just quit out early then)
Paul Aurich <paul@darkrain42.org>
parents:
31755
diff
changeset
|
1908 if ((c = strchr(c, '\n'))) |
b863432e81d1
log_reader: Properly fix the QIP crash, and unbreak the Trillian reader (c is NULL the last time through, so just quit out early then)
Paul Aurich <paul@darkrain42.org>
parents:
31755
diff
changeset
|
1909 c++; |
18172
3aa11b0169c9
Converting all qip logs into UTF8
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18171
diff
changeset
|
1910 } |
18247
97671eb4991e
Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents:
18246
diff
changeset
|
1911 } |
18248
ab761acbc614
Remove trailing whitespace.
Richard Laager <rlaager@wiktel.com>
parents:
18247
diff
changeset
|
1912 |
18247
97671eb4991e
Avoid some extra nesting.
Richard Laager <rlaager@wiktel.com>
parents:
18246
diff
changeset
|
1913 g_free(contents); |
17979
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1914 g_free(path); |
18249
35d981091506
Prepend to lists for performance, and use g_list_reverse when the list is
Richard Laager <rlaager@wiktel.com>
parents:
18248
diff
changeset
|
1915 return g_list_reverse(list); |
17979
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1916 } |
18248
ab761acbc614
Remove trailing whitespace.
Richard Laager <rlaager@wiktel.com>
parents:
18247
diff
changeset
|
1917 |
18251
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1918 static char *qip_logger_read(PurpleLog *log, PurpleLogReadFlags *flags) |
17979
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1919 { |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1920 struct qip_logger_data *data; |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1921 PurpleBuddy *buddy; |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1922 GString *formatted; |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1923 char *c; |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1924 const char *line; |
18251
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1925 gchar *contents; |
18255
507fb436d8c0
optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18254
diff
changeset
|
1926 GError *error; |
507fb436d8c0
optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18254
diff
changeset
|
1927 char *utf8_string; |
18256
54251fa6389d
reading only necessary part of log file using g_fopen/fseek/fread
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18255
diff
changeset
|
1928 FILE *file; |
54251fa6389d
reading only necessary part of log file using g_fopen/fseek/fread
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18255
diff
changeset
|
1929 |
18795
883c18d31bf4
Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18785
diff
changeset
|
1930 if (flags != NULL) |
883c18d31bf4
Fix more null pointer derefs in the log reader plugin. Fixes #2378.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18785
diff
changeset
|
1931 *flags = PURPLE_LOG_READ_NO_NEWLINE; |
18785
3cc77409b858
bug with flags variable initialization was fixed
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18765
diff
changeset
|
1932 |
17979
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1933 g_return_val_if_fail(log != NULL, g_strdup("")); |
18248
ab761acbc614
Remove trailing whitespace.
Richard Laager <rlaager@wiktel.com>
parents:
18247
diff
changeset
|
1934 |
17979
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1935 data = log->logger_data; |
18248
ab761acbc614
Remove trailing whitespace.
Richard Laager <rlaager@wiktel.com>
parents:
18247
diff
changeset
|
1936 |
17979
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1937 g_return_val_if_fail(data->path != NULL, g_strdup("")); |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1938 g_return_val_if_fail(data->length > 0, g_strdup("")); |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
1939 |
18256
54251fa6389d
reading only necessary part of log file using g_fopen/fseek/fread
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18255
diff
changeset
|
1940 file = g_fopen(data->path, "rb"); |
54251fa6389d
reading only necessary part of log file using g_fopen/fseek/fread
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18255
diff
changeset
|
1941 g_return_val_if_fail(file != NULL, g_strdup("")); |
20332
3a9709bfde65
applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents:
20329
diff
changeset
|
1942 |
3a9709bfde65
applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents:
20329
diff
changeset
|
1943 contents = g_malloc(data->length + 2); |
3a9709bfde65
applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents:
20329
diff
changeset
|
1944 |
18256
54251fa6389d
reading only necessary part of log file using g_fopen/fseek/fread
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18255
diff
changeset
|
1945 fseek(file, data->offset, SEEK_SET); |
20910
54d232b52607
Since we are looking at the return value of fread, it actually matters that
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20909
diff
changeset
|
1946 data->length = fread(contents, 1, data->length, file); |
18256
54251fa6389d
reading only necessary part of log file using g_fopen/fseek/fread
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18255
diff
changeset
|
1947 fclose(file); |
54251fa6389d
reading only necessary part of log file using g_fopen/fseek/fread
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18255
diff
changeset
|
1948 |
54251fa6389d
reading only necessary part of log file using g_fopen/fseek/fread
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18255
diff
changeset
|
1949 contents[data->length] = '\n'; |
54251fa6389d
reading only necessary part of log file using g_fopen/fseek/fread
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18255
diff
changeset
|
1950 contents[data->length + 1] = '\0'; |
18255
507fb436d8c0
optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18254
diff
changeset
|
1951 |
507fb436d8c0
optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18254
diff
changeset
|
1952 /* Convert file contents from Cp1251 to UTF-8 codeset */ |
507fb436d8c0
optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18254
diff
changeset
|
1953 error = NULL; |
507fb436d8c0
optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18254
diff
changeset
|
1954 if (!(utf8_string = g_convert(contents, -1, "UTF-8", "Cp1251", NULL, NULL, &error))) { |
507fb436d8c0
optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18254
diff
changeset
|
1955 purple_debug_error("QIP logger", |
20329
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
1956 "Couldn't convert file %s to UTF-8: %s\n", data->path, |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
1957 (error && error->message) ? error->message : "Unknown error"); |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
1958 if (error) |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
1959 g_error_free(error); |
18255
507fb436d8c0
optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18254
diff
changeset
|
1960 g_free(contents); |
507fb436d8c0
optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18254
diff
changeset
|
1961 return g_strdup(""); |
507fb436d8c0
optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18254
diff
changeset
|
1962 } |
18251
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1963 |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1964 g_free(contents); |
18255
507fb436d8c0
optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18254
diff
changeset
|
1965 contents = g_markup_escape_text(utf8_string, -1); |
507fb436d8c0
optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18254
diff
changeset
|
1966 g_free(utf8_string); |
507fb436d8c0
optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18254
diff
changeset
|
1967 |
507fb436d8c0
optimization: finding offsets without converting to UTF8 and escaping
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18254
diff
changeset
|
1968 buddy = purple_find_buddy(log->account, log->name); |
18251
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1969 |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1970 /* Apply formatting... */ |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1971 formatted = g_string_sized_new(data->length + 2); |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1972 c = contents; |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1973 line = contents; |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1974 |
24425 | 1975 while (c && *c) { |
18251
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1976 gboolean is_in_message = FALSE; |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1977 |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1978 if (purple_str_has_prefix(line, QIP_LOG_IN_MESSAGE_ESC) || |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1979 purple_str_has_prefix(line, QIP_LOG_OUT_MESSAGE_ESC)) { |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1980 |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1981 char *tmp; |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1982 const char *buddy_name; |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1983 |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1984 is_in_message = purple_str_has_prefix(line, QIP_LOG_IN_MESSAGE_ESC); |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1985 |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1986 /* find EOL */ |
31753
d1ea32c41634
log_reader: strchr(), and some simplifying to make clang happier
Paul Aurich <paul@darkrain42.org>
parents:
31086
diff
changeset
|
1987 c = strchr(c, '\n'); |
18251
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1988 |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1989 /* XXX: Do we need buddy_name when we have buddy->alias? */ |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1990 buddy_name = ++c; |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1991 |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1992 /* Find the last '(' character. */ |
31753
d1ea32c41634
log_reader: strchr(), and some simplifying to make clang happier
Paul Aurich <paul@darkrain42.org>
parents:
31086
diff
changeset
|
1993 if ((tmp = strchr(c, '\n')) != NULL) { |
18252
6722bbd698ff
using while cycle instead of g_strrstr, because g_strrstr doesn't work properly. g_strrstr finds the last '(' of the string, not the line.
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18251
diff
changeset
|
1994 while (*tmp && *tmp != '(') --tmp; |
6722bbd698ff
using while cycle instead of g_strrstr, because g_strrstr doesn't work properly. g_strrstr finds the last '(' of the string, not the line.
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18251
diff
changeset
|
1995 c = tmp; |
6722bbd698ff
using while cycle instead of g_strrstr, because g_strrstr doesn't work properly. g_strrstr finds the last '(' of the string, not the line.
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18251
diff
changeset
|
1996 } else { |
18251
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1997 while (*c) |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1998 c++; |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
1999 c--; |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2000 c = g_strrstr(c, "("); |
18172
3aa11b0169c9
Converting all qip logs into UTF8
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18171
diff
changeset
|
2001 } |
18251
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2002 |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2003 if (c != NULL) { |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2004 const char *timestamp = c; |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2005 int hour; |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2006 int min; |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2007 int sec; |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2008 |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2009 timestamp++; |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2010 |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2011 /* Parse the time, day, month and year */ |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2012 if (sscanf(timestamp, "%u:%u:%u", |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2013 &hour, &min, &sec) != 3) { |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2014 purple_debug_error("QIP logger read", |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2015 "Parsing timestamp error\n"); |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2016 } else { |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2017 g_string_append(formatted, "<font size=\"2\">"); |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2018 /* TODO: Figure out if we can do anything more locale-independent. */ |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2019 g_string_append_printf(formatted, |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2020 "(%u:%02u:%02u) %cM ", hour % 12, |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2021 min, sec, (hour >= 12) ? 'P': 'A'); |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2022 g_string_append(formatted, "</font> "); |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2023 |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2024 if (is_in_message) { |
24315
848542528965
Simplify some of the changes. Yeah, this code sucks. I wrote it a LONG
Richard Laager <rlaager@wiktel.com>
parents:
24314
diff
changeset
|
2025 const char *alias = NULL; |
24314
0d0088b03745
Hide the blistnode, buddy, contact, group, and chat structs
Gary Kramlich <grim@reaperworld.com>
parents:
24034
diff
changeset
|
2026 |
0d0088b03745
Hide the blistnode, buddy, contact, group, and chat structs
Gary Kramlich <grim@reaperworld.com>
parents:
24034
diff
changeset
|
2027 if (buddy_name != NULL && buddy != NULL && |
24315
848542528965
Simplify some of the changes. Yeah, this code sucks. I wrote it a LONG
Richard Laager <rlaager@wiktel.com>
parents:
24314
diff
changeset
|
2028 (alias = purple_buddy_get_alias(buddy))) |
24314
0d0088b03745
Hide the blistnode, buddy, contact, group, and chat structs
Gary Kramlich <grim@reaperworld.com>
parents:
24034
diff
changeset
|
2029 { |
18251
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2030 g_string_append_printf(formatted, |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2031 "<span style=\"color: #A82F2F;\">" |
24314
0d0088b03745
Hide the blistnode, buddy, contact, group, and chat structs
Gary Kramlich <grim@reaperworld.com>
parents:
24034
diff
changeset
|
2032 "<b>%s</b></span>: ", alias); |
18251
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2033 } |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2034 } else { |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2035 const char *acct_name; |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2036 acct_name = purple_account_get_alias(log->account); |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2037 if (!acct_name) |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2038 acct_name = purple_account_get_username(log->account); |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2039 |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2040 g_string_append_printf(formatted, |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2041 "<span style=\"color: #16569E;\">" |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2042 "<b>%s</b></span>: ", acct_name); |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2043 } |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2044 |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2045 /* find EOF */ |
31753
d1ea32c41634
log_reader: strchr(), and some simplifying to make clang happier
Paul Aurich <paul@darkrain42.org>
parents:
31086
diff
changeset
|
2046 c = strchr(c, '\n'); |
18172
3aa11b0169c9
Converting all qip logs into UTF8
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18171
diff
changeset
|
2047 line = ++c; |
18170
179bb0ea89c7
Using g_file_get_contents instead of common file operations; all DEBUG_MESSAGEs were removed
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18169
diff
changeset
|
2048 } |
17979
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2049 } |
18251
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2050 } else { |
31753
d1ea32c41634
log_reader: strchr(), and some simplifying to make clang happier
Paul Aurich <paul@darkrain42.org>
parents:
31086
diff
changeset
|
2051 if ((c = strchr(c, '\n'))) |
18251
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2052 *c = '\0'; |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2053 |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2054 if (line[0] != '\n' && line[0] != '\r') { |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2055 |
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2056 g_string_append(formatted, line); |
18359
d1e7c8015308
using <br> as end of line instead of '\n' in QIP logger. With this change History plugin works fine
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18256
diff
changeset
|
2057 g_string_append(formatted, "<br>"); |
18251
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2058 } |
20332
3a9709bfde65
applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents:
20329
diff
changeset
|
2059 |
3a9709bfde65
applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents:
20329
diff
changeset
|
2060 if (c) |
3a9709bfde65
applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Luke Schierer <lschiere@pidgin.im>
parents:
20329
diff
changeset
|
2061 line = ++c; |
17979
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2062 } |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2063 } |
18170
179bb0ea89c7
Using g_file_get_contents instead of common file operations; all DEBUG_MESSAGEs were removed
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18169
diff
changeset
|
2064 g_free(contents); |
18251
8908e9ec2420
Optimize this QIP code some more.
Richard Laager <rlaager@wiktel.com>
parents:
18250
diff
changeset
|
2065 |
17979
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2066 /* XXX: TODO: Avoid this g_strchomp() */ |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2067 return g_strchomp(g_string_free(formatted, FALSE)); |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2068 } |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2069 |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2070 static int qip_logger_size (PurpleLog *log) |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2071 { |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2072 struct qip_logger_data *data; |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2073 char *text; |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2074 size_t size; |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2075 |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2076 g_return_val_if_fail(log != NULL, 0); |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2077 |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2078 data = log->logger_data; |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2079 |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2080 if (purple_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) { |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2081 return data ? data->length : 0; |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2082 } |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2083 |
18248
ab761acbc614
Remove trailing whitespace.
Richard Laager <rlaager@wiktel.com>
parents:
18247
diff
changeset
|
2084 text = qip_logger_read(log, NULL); |
17979
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2085 size = strlen(text); |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2086 g_free(text); |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2087 |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2088 return size; |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2089 } |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2090 |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2091 static void qip_logger_finalize(PurpleLog *log) |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2092 { |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2093 struct qip_logger_data *data; |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2094 |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2095 g_return_if_fail(log != NULL); |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2096 |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2097 data = log->logger_data; |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2098 |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2099 g_free(data->path); |
18246
e236b3bd4542
Eliminate some leaks.
Richard Laager <rlaager@wiktel.com>
parents:
18245
diff
changeset
|
2100 g_free(data); |
17979
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2101 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2102 |
20897
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2103 /************************************************************************* |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2104 * aMSN Logger * |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2105 *************************************************************************/ |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2106 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2107 /* The aMSN logger doesn't write logs, only reads them. This is to include |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2108 * aMSN logs in the log viewer transparently. |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2109 */ |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2110 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2111 static PurpleLogLogger *amsn_logger; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2112 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2113 struct amsn_logger_data { |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2114 char *path; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2115 int offset; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2116 int length; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2117 }; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2118 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2119 #define AMSN_LOG_CONV_START "|\"LRED[Conversation started on " |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2120 #define AMSN_LOG_CONV_END "|\"LRED[You have closed the window on " |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2121 #define AMSN_LOG_CONV_EXTRA "01 Aug 2001 00:00:00]" |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2122 |
20921
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2123 static GList *amsn_logger_parse_file(char *filename, const char *sn, PurpleAccount *account) |
20897
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2124 { |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2125 GList *list = NULL; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2126 GError *error; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2127 char *contents; |
20921
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2128 struct amsn_logger_data *data; |
20897
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2129 PurpleLog *log; |
20921
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2130 |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2131 purple_debug_info("aMSN logger", "Reading %s\n", filename); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2132 error = NULL; |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2133 if (!g_file_get_contents(filename, &contents, NULL, &error)) { |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2134 purple_debug_error("aMSN logger", |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2135 "Couldn't read file %s: %s \n", filename, |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2136 (error && error->message) ? |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2137 error->message : "Unknown error"); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2138 if (error) |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2139 g_error_free(error); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2140 } else { |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2141 char *c = contents; |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2142 gboolean found_start = FALSE; |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2143 char *start_log = c; |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2144 int offset = 0; |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2145 struct tm tm; |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2146 while (c && *c) { |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2147 if (purple_str_has_prefix(c, AMSN_LOG_CONV_START)) { |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2148 char month[4]; |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2149 if (sscanf(c + strlen(AMSN_LOG_CONV_START), |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2150 "%u %3s %u %u:%u:%u", |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2151 &tm.tm_mday, (char*)&month, &tm.tm_year, |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2152 &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) { |
20897
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2153 found_start = FALSE; |
20921
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2154 purple_debug_error("aMSN logger", |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2155 "Error parsing start date for %s\n", |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2156 filename); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2157 } else { |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2158 tm.tm_year -= 1900; |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2159 |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2160 /* Let the C library deal with |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2161 * daylight savings time. |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2162 */ |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2163 tm.tm_isdst = -1; |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2164 tm.tm_mon = get_month(month); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2165 |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2166 found_start = TRUE; |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2167 offset = c - contents; |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2168 start_log = c; |
20897
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2169 } |
20921
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2170 } else if (purple_str_has_prefix(c, AMSN_LOG_CONV_END) && found_start) { |
20897
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2171 data = g_new0(struct amsn_logger_data, 1); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2172 data->path = g_strdup(filename); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2173 data->offset = offset; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2174 data->length = c - start_log |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2175 + strlen(AMSN_LOG_CONV_END) |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2176 + strlen(AMSN_LOG_CONV_EXTRA); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2177 log = purple_log_new(PURPLE_LOG_IM, sn, account, NULL, mktime(&tm), NULL); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2178 log->logger = amsn_logger; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2179 log->logger_data = data; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2180 list = g_list_prepend(list, log); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2181 found_start = FALSE; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2182 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2183 purple_debug_info("aMSN logger", |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2184 "Found log for %s:" |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2185 " path = (%s)," |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2186 " offset = (%d)," |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2187 " length = (%d)\n", |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2188 sn, data->path, data->offset, data->length); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2189 } |
31753
d1ea32c41634
log_reader: strchr(), and some simplifying to make clang happier
Paul Aurich <paul@darkrain42.org>
parents:
31086
diff
changeset
|
2190 c = strchr(c, '\n'); |
20921
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2191 c++; |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2192 } |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2193 |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2194 /* I've seen the file end without the AMSN_LOG_CONV_END bit */ |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2195 if (found_start) { |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2196 data = g_new0(struct amsn_logger_data, 1); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2197 data->path = g_strdup(filename); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2198 data->offset = offset; |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2199 data->length = c - start_log |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2200 + strlen(AMSN_LOG_CONV_END) |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2201 + strlen(AMSN_LOG_CONV_EXTRA); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2202 log = purple_log_new(PURPLE_LOG_IM, sn, account, NULL, mktime(&tm), NULL); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2203 log->logger = amsn_logger; |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2204 log->logger_data = data; |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2205 list = g_list_prepend(list, log); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2206 found_start = FALSE; |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2207 |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2208 purple_debug_info("aMSN logger", |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2209 "Found log for %s:" |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2210 " path = (%s)," |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2211 " offset = (%d)," |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2212 " length = (%d)\n", |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2213 sn, data->path, data->offset, data->length); |
20897
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2214 } |
20921
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2215 g_free(contents); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2216 } |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2217 |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2218 return list; |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2219 } |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2220 |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2221 /* `log_dir`/username@hotmail.com/logs/buddyname@hotmail.com.log */ |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2222 /* `log_dir`/username@hotmail.com/logs/Month Year/buddyname@hotmail.com.log */ |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2223 static GList *amsn_logger_list(PurpleLogType type, const char *sn, PurpleAccount *account) |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2224 { |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2225 GList *list = NULL; |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2226 const char *logdir; |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2227 char *username; |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2228 char *log_path; |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2229 char *buddy_log; |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2230 char *filename; |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2231 GDir *dir; |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2232 const char *name; |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2233 |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2234 logdir = purple_prefs_get_string("/plugins/core/log_reader/amsn/log_directory"); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2235 |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2236 /* By clearing the log directory path, this logger can be (effectively) disabled. */ |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2237 if (!logdir || !*logdir) |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2238 return NULL; |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2239 |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2240 /* aMSN only works with MSN/WLM */ |
31932
61ce89013291
Use accessor functions in a few places
Mark Doliner <mark@kingant.net>
parents:
31757
diff
changeset
|
2241 if (strcmp(purple_account_get_protocol_id(account), "prpl-msn")) |
20921
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2242 return NULL; |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2243 |
31932
61ce89013291
Use accessor functions in a few places
Mark Doliner <mark@kingant.net>
parents:
31757
diff
changeset
|
2244 username = g_strdup(purple_normalize(account, purple_account_get_username(account))); |
20921
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2245 buddy_log = g_strdup_printf("%s.log", purple_normalize(account, sn)); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2246 log_path = g_build_filename(logdir, username, "logs", NULL); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2247 |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2248 /* First check in the top-level */ |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2249 filename = g_build_filename(log_path, buddy_log, NULL); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2250 if (g_file_test(filename, G_FILE_TEST_EXISTS)) |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2251 list = amsn_logger_parse_file(filename, sn, account); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2252 else |
20897
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2253 g_free(filename); |
20921
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2254 |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2255 /* Check in previous months */ |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2256 dir = g_dir_open(log_path, 0, NULL); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2257 if (dir) { |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2258 while ((name = g_dir_read_name(dir)) != NULL) { |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2259 filename = g_build_filename(log_path, name, buddy_log, NULL); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2260 if (g_file_test(filename, G_FILE_TEST_EXISTS)) |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2261 list = g_list_concat(list, amsn_logger_parse_file(filename, sn, account)); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2262 g_free(filename); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2263 } |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2264 g_dir_close(dir); |
20897
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2265 } |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2266 |
20921
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2267 g_free(log_path); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2268 |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2269 /* New versions use 'friendlier' directory names */ |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2270 purple_util_chrreplace(username, '@', '_'); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2271 purple_util_chrreplace(username, '.', '_'); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2272 |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2273 log_path = g_build_filename(logdir, username, "logs", NULL); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2274 |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2275 /* First check in the top-level */ |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2276 filename = g_build_filename(log_path, buddy_log, NULL); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2277 if (g_file_test(filename, G_FILE_TEST_EXISTS)) |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2278 list = g_list_concat(list, amsn_logger_parse_file(filename, sn, account)); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2279 g_free(filename); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2280 |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2281 /* Check in previous months */ |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2282 dir = g_dir_open(log_path, 0, NULL); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2283 if (dir) { |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2284 while ((name = g_dir_read_name(dir)) != NULL) { |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2285 filename = g_build_filename(log_path, name, buddy_log, NULL); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2286 if (g_file_test(filename, G_FILE_TEST_EXISTS)) |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2287 list = g_list_concat(list, amsn_logger_parse_file(filename, sn, account)); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2288 g_free(filename); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2289 } |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2290 g_dir_close(dir); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2291 } |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2292 |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2293 g_free(log_path); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2294 g_free(username); |
b2b16843851b
A patch from QuLogic to eliminate some duplication in the aMSN code, also
Richard Laager <rlaager@wiktel.com>
parents:
20910
diff
changeset
|
2295 g_free(buddy_log); |
20897
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2296 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2297 return list; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2298 } |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2299 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2300 /* Really it's |"L, but the string's been escaped */ |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2301 #define AMSN_LOG_FORMAT_TAG "|"L" |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2302 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2303 static char *amsn_logger_read(PurpleLog *log, PurpleLogReadFlags *flags) |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2304 { |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2305 struct amsn_logger_data *data; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2306 FILE *file; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2307 char *contents; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2308 char *escaped; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2309 GString *formatted; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2310 char *start; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2311 gboolean in_span = FALSE; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2312 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2313 if (flags != NULL) |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2314 *flags = PURPLE_LOG_READ_NO_NEWLINE; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2315 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2316 g_return_val_if_fail(log != NULL, g_strdup("")); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2317 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2318 data = log->logger_data; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2319 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2320 g_return_val_if_fail(data->path != NULL, g_strdup("")); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2321 g_return_val_if_fail(data->length > 0, g_strdup("")); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2322 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2323 contents = g_malloc(data->length + 2); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2324 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2325 file = g_fopen(data->path, "rb"); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2326 g_return_val_if_fail(file != NULL, g_strdup("")); |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
29408
diff
changeset
|
2327 |
20897
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2328 fseek(file, data->offset, SEEK_SET); |
20910
54d232b52607
Since we are looking at the return value of fread, it actually matters that
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20909
diff
changeset
|
2329 data->length = fread(contents, 1, data->length, file); |
20897
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2330 fclose(file); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2331 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2332 contents[data->length] = '\n'; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2333 contents[data->length + 1] = '\0'; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2334 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2335 escaped = g_markup_escape_text(contents, -1); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2336 g_free(contents); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2337 contents = escaped; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2338 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2339 formatted = g_string_sized_new(data->length + 2); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2340 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2341 start = contents; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2342 while (start && *start) { |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2343 char *end; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2344 char *old_tag; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2345 char *tag; |
31753
d1ea32c41634
log_reader: strchr(), and some simplifying to make clang happier
Paul Aurich <paul@darkrain42.org>
parents:
31086
diff
changeset
|
2346 end = strchr(start, '\n'); |
20897
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2347 if (!end) |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2348 break; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2349 *end = '\0'; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2350 if (purple_str_has_prefix(start, AMSN_LOG_FORMAT_TAG) && in_span) { |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2351 /* New format for this line */ |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2352 g_string_append(formatted, "</span><br>"); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2353 in_span = FALSE; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2354 } else if (start != contents) { |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2355 /* Continue format from previous line */ |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2356 g_string_append(formatted, "<br>"); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2357 } |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2358 old_tag = start; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2359 tag = strstr(start, AMSN_LOG_FORMAT_TAG); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2360 while (tag) { |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2361 g_string_append_len(formatted, old_tag, tag - old_tag); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2362 tag += strlen(AMSN_LOG_FORMAT_TAG); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2363 if (in_span) { |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2364 g_string_append(formatted, "</span>"); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2365 in_span = FALSE; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2366 } |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2367 if (*tag == 'C') { |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2368 /* |"LCxxxxxx is a hex colour */ |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2369 char colour[7]; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2370 strncpy(colour, tag + 1, 6); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2371 colour[6] = '\0'; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2372 g_string_append_printf(formatted, "<span style=\"color: #%s;\">", colour); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2373 /* This doesn't appear to work? */ |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2374 /* g_string_append_printf(formatted, "<span style=\"color: #%6s;\">", tag + 1); */ |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2375 in_span = TRUE; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2376 old_tag = tag + 7; /* C + xxxxxx */ |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2377 } else { |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2378 /* |"Lxxx is a 3-digit colour code */ |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2379 if (purple_str_has_prefix(tag, "RED")) { |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2380 g_string_append(formatted, "<span style=\"color: red;\">"); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2381 in_span = TRUE; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2382 } else if (purple_str_has_prefix(tag, "GRA")) { |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2383 g_string_append(formatted, "<span style=\"color: gray;\">"); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2384 in_span = TRUE; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2385 } else if (purple_str_has_prefix(tag, "NOR")) { |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2386 g_string_append(formatted, "<span style=\"color: black;\">"); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2387 in_span = TRUE; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2388 } else if (purple_str_has_prefix(tag, "ITA")) { |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2389 g_string_append(formatted, "<span style=\"color: blue;\">"); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2390 in_span = TRUE; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2391 } else if (purple_str_has_prefix(tag, "GRE")) { |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2392 g_string_append(formatted, "<span style=\"color: darkgreen;\">"); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2393 in_span = TRUE; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2394 } else { |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2395 purple_debug_info("aMSN logger", "Unknown colour format: %3s\n", tag); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2396 } |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2397 old_tag = tag + 3; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2398 } |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2399 tag = strstr(tag, AMSN_LOG_FORMAT_TAG); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2400 } |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2401 g_string_append(formatted, old_tag); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2402 start = end + 1; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2403 } |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2404 if (in_span) |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2405 g_string_append(formatted, "</span>"); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2406 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2407 g_free(contents); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2408 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2409 return g_string_free(formatted, FALSE); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2410 } |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2411 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2412 static int amsn_logger_size(PurpleLog *log) |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2413 { |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2414 struct amsn_logger_data *data; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2415 char *text; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2416 int size; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2417 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2418 g_return_val_if_fail(log != NULL, 0); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2419 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2420 data = log->logger_data; |
31086
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
29408
diff
changeset
|
2421 |
20897
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2422 if (purple_prefs_get_bool("/plugins/core/log_reader/fast_sizes")) { |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2423 return data ? data->length : 0; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2424 } |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2425 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2426 text = amsn_logger_read(log, NULL); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2427 size = strlen(text); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2428 g_free(text); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2429 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2430 return size; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2431 } |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2432 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2433 static void amsn_logger_finalize(PurpleLog *log) |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2434 { |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2435 struct amsn_logger_data *data; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2436 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2437 g_return_if_fail(log != NULL); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2438 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2439 data = log->logger_data; |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2440 g_free(data->path); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2441 g_free(data); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2442 } |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2443 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2444 /***************************************************************************** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2445 * Plugin Code * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2446 *****************************************************************************/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2447 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2448 static void |
15822 | 2449 init_plugin(PurplePlugin *plugin) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2450 { |
20931
f56e94167372
Set log_reader paths at plugin load time instead of init time. This should hopefully make any crashes more clearly attributable to this plugin (hopefully there are no outstanding crashes in the init code, but this is a safeguard).
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20930
diff
changeset
|
2451 |
f56e94167372
Set log_reader paths at plugin load time instead of init time. This should hopefully make any crashes more clearly attributable to this plugin (hopefully there are no outstanding crashes in the init code, but this is a safeguard).
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20930
diff
changeset
|
2452 } |
f56e94167372
Set log_reader paths at plugin load time instead of init time. This should hopefully make any crashes more clearly attributable to this plugin (hopefully there are no outstanding crashes in the init code, but this is a safeguard).
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20930
diff
changeset
|
2453 |
22007
c38d72677c8a
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@wiktel.com>
parents:
21030
diff
changeset
|
2454 static void log_reader_init_prefs(void) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2455 char *path; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2456 #ifdef _WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2457 char *folder; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2458 gboolean found = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2459 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2460 |
16430 | 2461 purple_prefs_add_none("/plugins/core/log_reader"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2462 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2463 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2464 /* Add general preferences. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2465 |
16430 | 2466 purple_prefs_add_bool("/plugins/core/log_reader/fast_sizes", FALSE); |
2467 purple_prefs_add_bool("/plugins/core/log_reader/use_name_heuristics", TRUE); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2468 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2469 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2470 /* Add Adium log directory preference. */ |
16430 | 2471 purple_prefs_add_none("/plugins/core/log_reader/adium"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2472 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2473 /* Calculate default Adium log directory. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2474 #ifdef _WIN32 |
18250
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2475 purple_prefs_add_string("/plugins/core/log_reader/adium/log_directory", ""); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2476 #else |
18250
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2477 path = g_build_filename(purple_home_dir(), "Library", "Application Support", |
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2478 "Adium 2.0", "Users", "Default", "Logs", NULL); |
16430 | 2479 purple_prefs_add_string("/plugins/core/log_reader/adium/log_directory", path); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2480 g_free(path); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2481 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2482 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2483 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2484 /* Add Fire log directory preference. */ |
16430 | 2485 purple_prefs_add_none("/plugins/core/log_reader/fire"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2486 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2487 /* Calculate default Fire log directory. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2488 #ifdef _WIN32 |
18250
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2489 purple_prefs_add_string("/plugins/core/log_reader/fire/log_directory", ""); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2490 #else |
18250
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2491 path = g_build_filename(purple_home_dir(), "Library", "Application Support", |
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2492 "Fire", "Sessions", NULL); |
16430 | 2493 purple_prefs_add_string("/plugins/core/log_reader/fire/log_directory", path); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2494 g_free(path); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2495 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2496 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2497 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2498 /* Add Messenger Plus! log directory preference. */ |
16430 | 2499 purple_prefs_add_none("/plugins/core/log_reader/messenger_plus"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2500 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2501 /* Calculate default Messenger Plus! log directory. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2502 #ifdef _WIN32 |
20329
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2503 path = NULL; |
15822 | 2504 folder = wpurple_get_special_folder(CSIDL_PERSONAL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2505 if (folder) { |
18250
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2506 path = g_build_filename(folder, "My Chat Logs", NULL); |
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2507 g_free(folder); |
20329
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2508 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2509 #else |
18250
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2510 path = g_build_filename(PURPLE_LOG_READER_WINDOWS_MOUNT_POINT, |
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2511 "Documents and Settings", g_get_user_name(), |
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2512 "My Documents", "My Chat Logs", NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2513 #endif |
20329
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2514 purple_prefs_add_string("/plugins/core/log_reader/messenger_plus/log_directory", path ? path : ""); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2515 g_free(path); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2516 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2517 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2518 /* Add MSN Messenger log directory preference. */ |
16430 | 2519 purple_prefs_add_none("/plugins/core/log_reader/msn"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2520 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2521 /* Calculate default MSN message history directory. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2522 #ifdef _WIN32 |
20329
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2523 path = NULL; |
15822 | 2524 folder = wpurple_get_special_folder(CSIDL_PERSONAL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2525 if (folder) { |
18250
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2526 path = g_build_filename(folder, "My Received Files", NULL); |
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2527 g_free(folder); |
20329
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2528 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2529 #else |
18250
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2530 path = g_build_filename(PURPLE_LOG_READER_WINDOWS_MOUNT_POINT, |
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2531 "Documents and Settings", g_get_user_name(), |
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2532 "My Documents", "My Received Files", NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2533 #endif |
20329
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2534 purple_prefs_add_string("/plugins/core/log_reader/msn/log_directory", path ? path : ""); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2535 g_free(path); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2536 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2537 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2538 /* Add Trillian log directory preference. */ |
16430 | 2539 purple_prefs_add_none("/plugins/core/log_reader/trillian"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2540 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2541 #ifdef _WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2542 /* XXX: While a major hack, this is the most reliable way I could |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2543 * think of to determine the Trillian installation directory. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2544 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2545 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2546 path = NULL; |
15822 | 2547 if ((folder = wpurple_read_reg_string(HKEY_CLASSES_ROOT, "Trillian.SkinZip\\shell\\Add\\command\\", NULL))) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2548 char *value = folder; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2549 char *temp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2550 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2551 /* Break apart buffer. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2552 if (*value == '"') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2553 value++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2554 temp = value; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2555 while (*temp && *temp != '"') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2556 temp++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2557 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2558 temp = value; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2559 while (*temp && *temp != ' ') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2560 temp++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2561 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2562 *temp = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2563 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2564 /* Set path. */ |
15822 | 2565 if (purple_str_has_suffix(value, "trillian.exe")) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2566 value[strlen(value) - (sizeof("trillian.exe") - 1)] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2567 path = g_build_filename(value, "users", "default", "talk.ini", NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2568 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2569 g_free(folder); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2570 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2571 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2572 if (!path) { |
15822 | 2573 char *folder = wpurple_get_special_folder(CSIDL_PROGRAM_FILES); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2574 if (folder) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2575 path = g_build_filename(folder, "Trillian", |
18250
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2576 "users", "default", "talk.ini", NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2577 g_free(folder); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2578 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2579 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2580 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2581 if (path) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2582 /* Read talk.ini file to find the log directory. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2583 GError *error = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2584 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2585 #if 0 && GLIB_CHECK_VERSION(2,6,0) /* FIXME: Not tested yet. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2586 GKeyFile *key_file; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2587 |
18245
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
2588 purple_debug_info("Trillian talk.ini read", "Reading %s\n", path); |
18248
ab761acbc614
Remove trailing whitespace.
Richard Laager <rlaager@wiktel.com>
parents:
18247
diff
changeset
|
2589 |
18175
038c14fcadb8
setting error to NULL before using
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
18174
diff
changeset
|
2590 error = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2591 if (!g_key_file_load_from_file(key_file, path, G_KEY_FILE_NONE, GError &error)) { |
18245
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
2592 purple_debug_error("Trillian talk.ini read", |
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
2593 "Error reading talk.ini\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2594 if (error) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2595 g_error_free(error); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2596 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2597 char *logdir = g_key_file_get_string(key_file, "Logging", "Directory", &error); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2598 if (error) { |
18245
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
2599 purple_debug_error("Trillian talk.ini read", |
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
2600 "Error reading Directory value from Logging section\n"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2601 g_error_free(error); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2602 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2603 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2604 if (logdir) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2605 g_strchomp(logdir); |
18245
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
2606 purple_prefs_add_string("/plugins/core/log_reader/trillian/log_directory", logdir); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2607 found = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2608 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2609 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2610 g_key_file_free(key_file); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2611 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2612 #else /* !GLIB_CHECK_VERSION(2,6,0) */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2613 gchar *contents = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2614 |
18245
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
2615 purple_debug_info("Trillian talk.ini read", |
20329
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2616 "Reading %s\n", path); |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2617 if (!g_file_get_contents(path, &contents, NULL, &error)) { |
18245
30b67808b85b
Change the purple_debug(level, ...) statements to purple_debug_level(...)
Richard Laager <rlaager@wiktel.com>
parents:
18244
diff
changeset
|
2618 purple_debug_error("Trillian talk.ini read", |
20329
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2619 "Error reading talk.ini: %s\n", |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2620 (error && error->message) ? error->message : "Unknown error"); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2621 if (error) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2622 g_error_free(error); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2623 } else { |
20329
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2624 char *cursor, *line; |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2625 line = cursor = contents; |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2626 while (*cursor) { |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2627 if (*cursor == '\n') { |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2628 *cursor = '\0'; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2629 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2630 /* XXX: This assumes the first Directory key is under [Logging]. */ |
15822 | 2631 if (purple_str_has_prefix(line, "Directory=")) { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2632 line += (sizeof("Directory=") - 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2633 g_strchomp(line); |
15822 | 2634 purple_prefs_add_string( |
16430 | 2635 "/plugins/core/log_reader/trillian/log_directory", |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2636 line); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2637 found = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2638 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2639 |
20329
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2640 cursor++; |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2641 line = cursor; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2642 } else |
20329
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2643 cursor++; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2644 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2645 g_free(contents); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2646 } |
20329
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2647 g_free(path); |
29408
5434f768917b
Get rid of a few version checks that we no longer need now that we depend
Mark Doliner <mark@kingant.net>
parents:
28647
diff
changeset
|
2648 #endif /* !GLIB_CHECK_VERSION(2,6,0) */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2649 } /* path */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2650 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2651 if (!found) { |
20329
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2652 path = NULL; |
18250
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2653 folder = wpurple_get_special_folder(CSIDL_PROGRAM_FILES); |
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2654 if (folder) { |
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2655 path = g_build_filename(folder, "Trillian", "users", |
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2656 "default", "logs", NULL); |
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2657 g_free(folder); |
20329
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2658 } |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2659 |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2660 purple_prefs_add_string( |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2661 "/plugins/core/log_reader/trillian/log_directory", path ? path : ""); |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2662 g_free(path); |
18250
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2663 } |
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2664 #else /* !defined(_WIN32) */ |
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2665 /* TODO: At some point, this could attempt to parse talk.ini |
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2666 * TODO: from the default Trillian install directory on the |
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2667 * TODO: Windows mount point. */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2668 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2669 /* Calculate default Trillian log directory. */ |
18250
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2670 path = g_build_filename(PURPLE_LOG_READER_WINDOWS_MOUNT_POINT, |
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2671 "Program Files", "Trillian", "users", |
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2672 "default", "logs", NULL); |
20329
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2673 purple_prefs_add_string( |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2674 "/plugins/core/log_reader/trillian/log_directory", path); |
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2675 g_free(path); |
18250
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2676 #endif |
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2677 |
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2678 /* Add QIP log directory preference. */ |
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2679 purple_prefs_add_none("/plugins/core/log_reader/qip"); |
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2680 |
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2681 /* Calculate default QIP log directory. */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2682 #ifdef _WIN32 |
20329
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2683 path = NULL; |
15822 | 2684 folder = wpurple_get_special_folder(CSIDL_PROGRAM_FILES); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2685 if (folder) { |
18250
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2686 path = g_build_filename(folder, "QIP", "Users", NULL); |
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2687 g_free(folder); |
20329
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2688 } |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2689 #else |
18250
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2690 path = g_build_filename(PURPLE_LOG_READER_WINDOWS_MOUNT_POINT, |
7a6a1da4121b
Trying to avoid duplicating a single line of code is stupid. I've finally
Richard Laager <rlaager@wiktel.com>
parents:
18249
diff
changeset
|
2691 "Program Files", "QIP", "Users", NULL); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2692 #endif |
20329
24ce4fcce5b0
applied changes from e56db1b8a7bb8729e30fb3bf99a94ff7887fe4ec
Luke Schierer <lschiere@pidgin.im>
parents:
20319
diff
changeset
|
2693 purple_prefs_add_string("/plugins/core/log_reader/qip/log_directory", path ? path : ""); |
17979
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2694 g_free(path); |
20897
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2695 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2696 /* Add aMSN Messenger log directory preference. */ |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2697 purple_prefs_add_none("/plugins/core/log_reader/amsn"); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2698 |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2699 /* Calculate default aMSN log directory. */ |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2700 #ifdef _WIN32 |
20930 | 2701 path = NULL; |
20897
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2702 folder = wpurple_get_special_folder(CSIDL_PROFILE); /* Silly aMSN, not using CSIDL_APPDATA */ |
20930 | 2703 if (folder) { |
2704 path = g_build_filename(folder, "amsn", NULL); | |
2705 g_free(folder); | |
2706 } | |
20897
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2707 #else |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2708 path = g_build_filename(purple_home_dir(), ".amsn", NULL); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2709 #endif |
20930 | 2710 purple_prefs_add_string("/plugins/core/log_reader/amsn/log_directory", path ? path : ""); |
20897
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2711 g_free(path); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2712 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2713 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2714 static gboolean |
15822 | 2715 plugin_load(PurplePlugin *plugin) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2716 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2717 g_return_val_if_fail(plugin != NULL, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2718 |
20931
f56e94167372
Set log_reader paths at plugin load time instead of init time. This should hopefully make any crashes more clearly attributable to this plugin (hopefully there are no outstanding crashes in the init code, but this is a safeguard).
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20930
diff
changeset
|
2719 log_reader_init_prefs(); |
f56e94167372
Set log_reader paths at plugin load time instead of init time. This should hopefully make any crashes more clearly attributable to this plugin (hopefully there are no outstanding crashes in the init code, but this is a safeguard).
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20930
diff
changeset
|
2720 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2721 /* The names of IM clients are marked for translation at the request of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2722 translators who wanted to transliterate them. Many translators |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2723 choose to leave them alone. Choose what's best for your language. */ |
15822 | 2724 adium_logger = purple_log_logger_new("adium", _("Adium"), 6, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2725 NULL, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2726 NULL, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2727 adium_logger_finalize, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2728 adium_logger_list, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2729 adium_logger_read, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2730 adium_logger_size); |
15822 | 2731 purple_log_logger_add(adium_logger); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2732 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2733 #if 0 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2734 /* The names of IM clients are marked for translation at the request of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2735 translators who wanted to transliterate them. Many translators |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2736 choose to leave them alone. Choose what's best for your language. */ |
15822 | 2737 fire_logger = purple_log_logger_new("fire", _("Fire"), 6, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2738 NULL, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2739 NULL, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2740 fire_logger_finalize, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2741 fire_logger_list, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2742 fire_logger_read, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2743 fire_logger_size); |
15822 | 2744 purple_log_logger_add(fire_logger); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2745 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2746 /* The names of IM clients are marked for translation at the request of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2747 translators who wanted to transliterate them. Many translators |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2748 choose to leave them alone. Choose what's best for your language. */ |
15822 | 2749 messenger_plus_logger = purple_log_logger_new("messenger_plus", _("Messenger Plus!"), 6, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2750 NULL, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2751 NULL, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2752 messenger_plus_logger_finalize, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2753 messenger_plus_logger_list, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2754 messenger_plus_logger_read, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2755 messenger_plus_logger_size); |
15822 | 2756 purple_log_logger_add(messenger_plus_logger); |
18248
ab761acbc614
Remove trailing whitespace.
Richard Laager <rlaager@wiktel.com>
parents:
18247
diff
changeset
|
2757 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2758 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2759 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2760 /* The names of IM clients are marked for translation at the request of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2761 translators who wanted to transliterate them. Many translators |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2762 choose to leave them alone. Choose what's best for your language. */ |
17979
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2763 qip_logger = purple_log_logger_new("qip", _("QIP"), 6, |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2764 NULL, |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2765 NULL, |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2766 qip_logger_finalize, |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2767 qip_logger_list, |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2768 qip_logger_read, |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2769 qip_logger_size); |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2770 purple_log_logger_add(qip_logger); |
18248
ab761acbc614
Remove trailing whitespace.
Richard Laager <rlaager@wiktel.com>
parents:
18247
diff
changeset
|
2771 |
17979
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2772 /* The names of IM clients are marked for translation at the request of |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2773 translators who wanted to transliterate them. Many translators |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2774 choose to leave them alone. Choose what's best for your language. */ |
15822 | 2775 msn_logger = purple_log_logger_new("msn", _("MSN Messenger"), 6, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2776 NULL, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2777 NULL, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2778 msn_logger_finalize, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2779 msn_logger_list, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2780 msn_logger_read, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2781 msn_logger_size); |
15822 | 2782 purple_log_logger_add(msn_logger); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2783 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2784 /* The names of IM clients are marked for translation at the request of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2785 translators who wanted to transliterate them. Many translators |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2786 choose to leave them alone. Choose what's best for your language. */ |
15822 | 2787 trillian_logger = purple_log_logger_new("trillian", _("Trillian"), 6, |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2788 NULL, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2789 NULL, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2790 trillian_logger_finalize, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2791 trillian_logger_list, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2792 trillian_logger_read, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2793 trillian_logger_size); |
15822 | 2794 purple_log_logger_add(trillian_logger); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2795 |
20897
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2796 /* The names of IM clients are marked for translation at the request of |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2797 translators who wanted to transliterate them. Many translators |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2798 choose to leave them alone. Choose what's best for your language. */ |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2799 amsn_logger = purple_log_logger_new("amsn", _("aMSN"), 6, |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2800 NULL, |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2801 NULL, |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2802 amsn_logger_finalize, |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2803 amsn_logger_list, |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2804 amsn_logger_read, |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2805 amsn_logger_size); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2806 purple_log_logger_add(amsn_logger); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2807 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2808 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2809 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2810 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2811 static gboolean |
15822 | 2812 plugin_unload(PurplePlugin *plugin) |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2813 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2814 g_return_val_if_fail(plugin != NULL, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2815 |
15822 | 2816 purple_log_logger_remove(adium_logger); |
22830
f15d9ded0c45
Clean up loggers when quitting (or unloading the logreader plugin).
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22007
diff
changeset
|
2817 purple_log_logger_free(adium_logger); |
f15d9ded0c45
Clean up loggers when quitting (or unloading the logreader plugin).
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22007
diff
changeset
|
2818 adium_logger = NULL; |
f15d9ded0c45
Clean up loggers when quitting (or unloading the logreader plugin).
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22007
diff
changeset
|
2819 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2820 #if 0 |
15822 | 2821 purple_log_logger_remove(fire_logger); |
22830
f15d9ded0c45
Clean up loggers when quitting (or unloading the logreader plugin).
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22007
diff
changeset
|
2822 purple_log_logger_free(fire_logger); |
f15d9ded0c45
Clean up loggers when quitting (or unloading the logreader plugin).
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22007
diff
changeset
|
2823 fire_logger = NULL; |
f15d9ded0c45
Clean up loggers when quitting (or unloading the logreader plugin).
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22007
diff
changeset
|
2824 |
15822 | 2825 purple_log_logger_remove(messenger_plus_logger); |
22830
f15d9ded0c45
Clean up loggers when quitting (or unloading the logreader plugin).
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22007
diff
changeset
|
2826 purple_log_logger_free(messenger_plus_logger); |
f15d9ded0c45
Clean up loggers when quitting (or unloading the logreader plugin).
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22007
diff
changeset
|
2827 messenger_plus_logger = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2828 #endif |
22830
f15d9ded0c45
Clean up loggers when quitting (or unloading the logreader plugin).
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22007
diff
changeset
|
2829 |
15822 | 2830 purple_log_logger_remove(msn_logger); |
22830
f15d9ded0c45
Clean up loggers when quitting (or unloading the logreader plugin).
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22007
diff
changeset
|
2831 purple_log_logger_free(msn_logger); |
f15d9ded0c45
Clean up loggers when quitting (or unloading the logreader plugin).
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22007
diff
changeset
|
2832 msn_logger = NULL; |
f15d9ded0c45
Clean up loggers when quitting (or unloading the logreader plugin).
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22007
diff
changeset
|
2833 |
15822 | 2834 purple_log_logger_remove(trillian_logger); |
22830
f15d9ded0c45
Clean up loggers when quitting (or unloading the logreader plugin).
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22007
diff
changeset
|
2835 purple_log_logger_free(trillian_logger); |
f15d9ded0c45
Clean up loggers when quitting (or unloading the logreader plugin).
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22007
diff
changeset
|
2836 trillian_logger = NULL; |
f15d9ded0c45
Clean up loggers when quitting (or unloading the logreader plugin).
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22007
diff
changeset
|
2837 |
17979
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2838 purple_log_logger_remove(qip_logger); |
22830
f15d9ded0c45
Clean up loggers when quitting (or unloading the logreader plugin).
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22007
diff
changeset
|
2839 purple_log_logger_free(qip_logger); |
f15d9ded0c45
Clean up loggers when quitting (or unloading the logreader plugin).
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22007
diff
changeset
|
2840 qip_logger = NULL; |
f15d9ded0c45
Clean up loggers when quitting (or unloading the logreader plugin).
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22007
diff
changeset
|
2841 |
20897
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2842 purple_log_logger_remove(amsn_logger); |
22830
f15d9ded0c45
Clean up loggers when quitting (or unloading the logreader plugin).
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22007
diff
changeset
|
2843 purple_log_logger_free(amsn_logger); |
f15d9ded0c45
Clean up loggers when quitting (or unloading the logreader plugin).
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22007
diff
changeset
|
2844 amsn_logger = NULL; |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2845 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2846 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2847 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2848 |
15822 | 2849 static PurplePluginPrefFrame * |
2850 get_plugin_pref_frame(PurplePlugin *plugin) | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2851 { |
15822 | 2852 PurplePluginPrefFrame *frame; |
2853 PurplePluginPref *ppref; | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2854 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2855 g_return_val_if_fail(plugin != NULL, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2856 |
15822 | 2857 frame = purple_plugin_pref_frame_new(); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2858 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2859 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2860 /* Add general preferences. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2861 |
15822 | 2862 ppref = purple_plugin_pref_new_with_label(_("General Log Reading Configuration")); |
2863 purple_plugin_pref_frame_add(frame, ppref); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2864 |
15822 | 2865 ppref = purple_plugin_pref_new_with_name_and_label( |
16430 | 2866 "/plugins/core/log_reader/fast_sizes", _("Fast size calculations")); |
15822 | 2867 purple_plugin_pref_frame_add(frame, ppref); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2868 |
15822 | 2869 ppref = purple_plugin_pref_new_with_name_and_label( |
16430 | 2870 "/plugins/core/log_reader/use_name_heuristics", _("Use name heuristics")); |
15822 | 2871 purple_plugin_pref_frame_add(frame, ppref); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2872 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2873 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2874 /* Add Log Directory preferences. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2875 |
15822 | 2876 ppref = purple_plugin_pref_new_with_label(_("Log Directory")); |
2877 purple_plugin_pref_frame_add(frame, ppref); | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2878 |
15822 | 2879 ppref = purple_plugin_pref_new_with_name_and_label( |
16430 | 2880 "/plugins/core/log_reader/adium/log_directory", _("Adium")); |
15822 | 2881 purple_plugin_pref_frame_add(frame, ppref); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2882 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2883 #if 0 |
15822 | 2884 ppref = purple_plugin_pref_new_with_name_and_label( |
16430 | 2885 "/plugins/core/log_reader/fire/log_directory", _("Fire")); |
15822 | 2886 purple_plugin_pref_frame_add(frame, ppref); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2887 |
15822 | 2888 ppref = purple_plugin_pref_new_with_name_and_label( |
16430 | 2889 "/plugins/core/log_reader/messenger_plus/log_directory", _("Messenger Plus!")); |
15822 | 2890 purple_plugin_pref_frame_add(frame, ppref); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2891 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2892 |
15822 | 2893 ppref = purple_plugin_pref_new_with_name_and_label( |
17979
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2894 "/plugins/core/log_reader/qip/log_directory", _("QIP")); |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2895 purple_plugin_pref_frame_add(frame, ppref); |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2896 |
c8d2e131cc37
QIP logger was implemented
Michael Shkutkov <mshkutkov@soc.pidgin.im>
parents:
17531
diff
changeset
|
2897 ppref = purple_plugin_pref_new_with_name_and_label( |
16430 | 2898 "/plugins/core/log_reader/msn/log_directory", _("MSN Messenger")); |
15822 | 2899 purple_plugin_pref_frame_add(frame, ppref); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2900 |
15822 | 2901 ppref = purple_plugin_pref_new_with_name_and_label( |
16430 | 2902 "/plugins/core/log_reader/trillian/log_directory", _("Trillian")); |
15822 | 2903 purple_plugin_pref_frame_add(frame, ppref); |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2904 |
20897
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2905 ppref = purple_plugin_pref_new_with_name_and_label( |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2906 "/plugins/core/log_reader/amsn/log_directory", _("aMSN")); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2907 purple_plugin_pref_frame_add(frame, ppref); |
8de7c44fd577
Patch from QuLogic to add support for aMSN logs from the log-reader plugin.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
20332
diff
changeset
|
2908 |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2909 return frame; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2910 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2911 |
15822 | 2912 static PurplePluginUiInfo prefs_info = { |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2913 get_plugin_pref_frame, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2914 0, /* page_num (reserved) */ |
16666
5205dd2bd035
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16430
diff
changeset
|
2915 NULL, /* frame (reserved) */ |
5205dd2bd035
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16430
diff
changeset
|
2916 |
5205dd2bd035
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16430
diff
changeset
|
2917 /* padding */ |
5205dd2bd035
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16430
diff
changeset
|
2918 NULL, |
5205dd2bd035
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16430
diff
changeset
|
2919 NULL, |
5205dd2bd035
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16430
diff
changeset
|
2920 NULL, |
5205dd2bd035
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16430
diff
changeset
|
2921 NULL |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2922 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2923 |
15822 | 2924 static PurplePluginInfo info = |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2925 { |
15822 | 2926 PURPLE_PLUGIN_MAGIC, |
2927 PURPLE_MAJOR_VERSION, | |
2928 PURPLE_MINOR_VERSION, | |
2929 PURPLE_PLUGIN_STANDARD, /**< type */ | |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2930 NULL, /**< ui_requirement */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2931 0, /**< flags */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2932 NULL, /**< dependencies */ |
15822 | 2933 PURPLE_PRIORITY_DEFAULT, /**< priority */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2934 "core-log_reader", /**< id */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2935 N_("Log Reader"), /**< name */ |
21030
3cc856ca2338
Add a --with-extraversion option to ./configure so packagers can fine tune
Stu Tomlinson <stu@nosnilmot.com>
parents:
21000
diff
changeset
|
2936 DISPLAY_VERSION, /**< version */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2937 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2938 /** summary */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2939 N_("Includes other IM clients' logs in the " |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2940 "log viewer."), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2941 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2942 /** description */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2943 N_("When viewing logs, this plugin will include " |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2944 "logs from other IM clients. Currently, this " |
27283
8d1e8060b1d8
The Log Reader plugin also supports aMSN logs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24425
diff
changeset
|
2945 "includes Adium, MSN Messenger, aMSN, and " |
8d1e8060b1d8
The Log Reader plugin also supports aMSN logs.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24425
diff
changeset
|
2946 "Trillian.\n\n" |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2947 "WARNING: This plugin is still alpha code and " |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2948 "may crash frequently. Use it at your own risk!"), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2949 |
15566
b6615958d87c
Switching to my pidgin.im e-mail address, which I think fits nicely and seems professional.
Richard Laager <rlaager@wiktel.com>
parents:
15373
diff
changeset
|
2950 "Richard Laager <rlaager@pidgin.im>", /**< author */ |
15822 | 2951 PURPLE_WEBSITE, /**< homepage */ |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2952 plugin_load, /**< load */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2953 plugin_unload, /**< unload */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2954 NULL, /**< destroy */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2955 NULL, /**< ui_info */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2956 NULL, /**< extra_info */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2957 &prefs_info, /**< prefs_info */ |
16666
5205dd2bd035
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16430
diff
changeset
|
2958 NULL, /**< actions */ |
5205dd2bd035
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16430
diff
changeset
|
2959 |
5205dd2bd035
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16430
diff
changeset
|
2960 /* padding */ |
5205dd2bd035
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16430
diff
changeset
|
2961 NULL, |
5205dd2bd035
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16430
diff
changeset
|
2962 NULL, |
5205dd2bd035
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16430
diff
changeset
|
2963 NULL, |
5205dd2bd035
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16430
diff
changeset
|
2964 NULL |
15373
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2965 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2966 |
15822 | 2967 PURPLE_INIT_PLUGIN(log_reader, init_plugin, info) |