Wed, 12 Nov 2008 05:14:03 +0000
merge of '77693555855fe9cd3215414f79964dba346cc5fa'
and '19a87e98e5857ad0289f2c760d460f7f1dbbb42d'
| 5872 | 1 | /** |
| 2 | * @file log.h Logging API | |
| 3 | * @ingroup core | |
| 4 | * | |
| 5 | * gaim | |
| 6 | * | |
| 8046 | 7 | * Gaim is the legal property of its developers, whose names are too numerous |
| 8 | * to list here. Please refer to the COPYRIGHT file distributed with this | |
| 9 | * source distribution. | |
| 7440 | 10 | * |
| 5872 | 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by | |
| 13 | * the Free Software Foundation; either version 2 of the License, or | |
| 14 | * (at your option) any later version. | |
| 15 | * | |
| 16 | * This program is distributed in the hope that it will be useful, | |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 | * GNU General Public License for more details. | |
| 20 | * | |
| 21 | * You should have received a copy of the GNU General Public License | |
| 22 | * along with this program; if not, write to the Free Software | |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 24 | */ | |
| 25 | #ifndef _GAIM_LOG_H_ | |
| 26 | #define _GAIM_LOG_H_ | |
| 27 | ||
| 7431 | 28 | #include <stdio.h> |
| 5872 | 29 | |
| 30 | ||
| 7431 | 31 | /******************************************************** |
| 32 | * DATA STRUCTURES ************************************** | |
| 33 | ********************************************************/ | |
| 34 | ||
| 35 | typedef struct _GaimLog GaimLog; | |
| 36 | typedef struct _GaimLogLogger GaimLogLogger; | |
| 10822 | 37 | typedef struct _GaimLogCommonLoggerData GaimLogCommonLoggerData; |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
38 | typedef struct _GaimLogSet GaimLogSet; |
| 7431 | 39 | |
| 40 | typedef enum { | |
| 41 | GAIM_LOG_IM, | |
| 42 | GAIM_LOG_CHAT, | |
|
10348
0ab5eb1a828e
[gaim-migrate @ 11562]
Mark Doliner <markdoliner@pidgin.im>
parents:
10231
diff
changeset
|
43 | GAIM_LOG_SYSTEM |
| 7431 | 44 | } GaimLogType; |
| 45 | ||
| 46 | typedef enum { | |
|
10348
0ab5eb1a828e
[gaim-migrate @ 11562]
Mark Doliner <markdoliner@pidgin.im>
parents:
10231
diff
changeset
|
47 | GAIM_LOG_READ_NO_NEWLINE = 1 |
| 7431 | 48 | } GaimLogReadFlags; |
| 49 | ||
| 50 | #include "account.h" | |
| 51 | #include "conversation.h" | |
| 52 | ||
|
11177
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
53 | typedef void (*GaimLogSetCallback) (GHashTable *sets, GaimLogSet *set); |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
54 | |
| 7431 | 55 | /** |
| 56 | * A log logger. | |
| 57 | * | |
| 58 | * This struct gets filled out and is included in the GaimLog. It contains everything | |
| 59 | * needed to write and read from logs. | |
| 60 | */ | |
| 61 | struct _GaimLogLogger { | |
| 62 | char *name; /**< The logger's name */ | |
| 63 | char *id; /**< an identifier to refer to this logger */ | |
| 7440 | 64 | |
| 65 | /** This gets called when the log is first created. | |
| 7431 | 66 | I don't think this is actually needed. */ |
|
10812
25c595cbffe8
[gaim-migrate @ 12465]
Richard Laager <rlaager@pidgin.im>
parents:
10566
diff
changeset
|
67 | void (*create)(GaimLog *log); |
| 7440 | 68 | |
| 7431 | 69 | /** This is used to write to the log file */ |
| 13059 | 70 | gsize (*write)(GaimLog *log, |
| 7440 | 71 | GaimMessageFlags type, |
| 7431 | 72 | const char *from, |
| 73 | time_t time, | |
| 74 | const char *message); | |
| 75 | ||
| 76 | /** Called when the log is destroyed */ | |
| 77 | void (*finalize)(GaimLog *log); | |
| 7440 | 78 | |
| 7431 | 79 | /** This function returns a sorted GList of available GaimLogs */ |
|
8898
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8735
diff
changeset
|
80 | GList *(*list)(GaimLogType type, const char *name, GaimAccount *account); |
| 7440 | 81 | |
| 82 | /** Given one of the logs returned by the logger's list function, | |
| 83 | * this returns the contents of the log in GtkIMHtml markup */ | |
| 7431 | 84 | char *(*read)(GaimLog *log, GaimLogReadFlags *flags); |
|
10231
047177cee39f
[gaim-migrate @ 11366]
Andrew Hart <arhart@users.sourceforge.net>
parents:
10171
diff
changeset
|
85 | |
| 7556 | 86 | /** Given one of the logs returned by the logger's list function, |
| 87 | * this returns the size of the log in bytes */ | |
| 88 | int (*size)(GaimLog *log); | |
| 8096 | 89 | |
| 90 | /** Returns the total size of all the logs. If this is undefined a default | |
| 91 | * implementation is used */ | |
|
8898
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8735
diff
changeset
|
92 | int (*total_size)(GaimLogType type, const char *name, GaimAccount *account); |
| 8573 | 93 | |
| 94 | /** This function returns a sorted GList of available system GaimLogs */ | |
| 95 | GList *(*list_syslog)(GaimAccount *account); | |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
96 | |
|
11177
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
97 | /** Adds GaimLogSets to a GHashTable. By passing the data in the GaimLogSets |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
98 | * to list, the caller can get every available GaimLog from the logger. |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
99 | * Loggers using gaim_log_common_writer() (or otherwise storing their |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
100 | * logs in the same directory structure as the stock loggers) do not |
|
11177
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
101 | * need to implement this function. |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
102 | * |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
103 | * Loggers which implement this function must create a GaimLogSet, |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
104 | * then call @a cb with @a sets and the newly created GaimLogSet. */ |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
105 | void (*get_log_sets)(GaimLogSetCallback cb, GHashTable *sets); |
| 5872 | 106 | }; |
| 107 | ||
| 7431 | 108 | /** |
| 109 | * A log. Not the wooden type. | |
| 110 | */ | |
| 111 | struct _GaimLog { | |
| 112 | GaimLogType type; /**< The type of log this is */ | |
| 113 | char *name; /**< The name of this log */ | |
| 7440 | 114 | GaimAccount *account; /**< The account this log is taking |
|
13120
c25222322810
[gaim-migrate @ 15481]
Richard Laager <rlaager@pidgin.im>
parents:
13059
diff
changeset
|
115 | place on */ |
|
11292
13068c68def6
[gaim-migrate @ 13492]
Richard Laager <rlaager@pidgin.im>
parents:
11177
diff
changeset
|
116 | GaimConversation *conv; /**< The conversation being logged */ |
| 7440 | 117 | time_t time; /**< The time this conversation |
|
13120
c25222322810
[gaim-migrate @ 15481]
Richard Laager <rlaager@pidgin.im>
parents:
13059
diff
changeset
|
118 | started, converted to the local timezone */ |
|
c25222322810
[gaim-migrate @ 15481]
Richard Laager <rlaager@pidgin.im>
parents:
13059
diff
changeset
|
119 | |
| 7440 | 120 | GaimLogLogger *logger; /**< The logging mechanism this log |
|
13120
c25222322810
[gaim-migrate @ 15481]
Richard Laager <rlaager@pidgin.im>
parents:
13059
diff
changeset
|
121 | is to use */ |
| 7431 | 122 | void *logger_data; /**< Data used by the log logger */ |
|
13120
c25222322810
[gaim-migrate @ 15481]
Richard Laager <rlaager@pidgin.im>
parents:
13059
diff
changeset
|
123 | struct tm *tm; /**< The time this conversation |
|
c25222322810
[gaim-migrate @ 15481]
Richard Laager <rlaager@pidgin.im>
parents:
13059
diff
changeset
|
124 | started, saved with original |
|
c25222322810
[gaim-migrate @ 15481]
Richard Laager <rlaager@pidgin.im>
parents:
13059
diff
changeset
|
125 | timezone data, if available and |
|
c25222322810
[gaim-migrate @ 15481]
Richard Laager <rlaager@pidgin.im>
parents:
13059
diff
changeset
|
126 | if struct tm has the BSD |
|
c25222322810
[gaim-migrate @ 15481]
Richard Laager <rlaager@pidgin.im>
parents:
13059
diff
changeset
|
127 | timezone fields, else @c NULL. |
|
c25222322810
[gaim-migrate @ 15481]
Richard Laager <rlaager@pidgin.im>
parents:
13059
diff
changeset
|
128 | Do NOT modify anything in this struct.*/ |
|
13624
c6577def4e2a
[gaim-migrate @ 16009]
Richard Laager <rlaager@pidgin.im>
parents:
13389
diff
changeset
|
129 | |
|
c6577def4e2a
[gaim-migrate @ 16009]
Richard Laager <rlaager@pidgin.im>
parents:
13389
diff
changeset
|
130 | /* IMPORTANT: Some code in log.c allocates these without zeroing them. |
|
c6577def4e2a
[gaim-migrate @ 16009]
Richard Laager <rlaager@pidgin.im>
parents:
13389
diff
changeset
|
131 | * IMPORTANT: Update that code if you add members here. */ |
| 5872 | 132 | }; |
| 133 | ||
| 10822 | 134 | /** |
| 135 | * A common logger_data struct containing a file handle and path, as well | |
| 136 | * as a pointer to something else for additional data. | |
| 137 | */ | |
| 138 | struct _GaimLogCommonLoggerData { | |
| 139 | char *path; | |
| 140 | FILE *file; | |
| 141 | void *extra_data; | |
| 142 | }; | |
| 7431 | 143 | |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
144 | /** |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
145 | * Describes available logs. |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
146 | * |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
147 | * By passing the elements of this struct to gaim_log_get_logs(), the caller |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
148 | * can get all available GaimLogs. |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
149 | */ |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
150 | struct _GaimLogSet { |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
151 | GaimLogType type; /**< The type of logs available */ |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
152 | char *name; /**< The name of the logs available */ |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
153 | GaimAccount *account; /**< The account the available logs |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
154 | took place on. This will be |
|
11503
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
155 | @c NULL if the account no longer |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
156 | exists. (Depending on a |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
157 | logger's implementation of |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
158 | list, it may not be possible |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
159 | to load such logs.) */ |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
160 | gboolean buddy; /**< Is this (account, name) a buddy |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
161 | on the buddy list? */ |
|
11177
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
162 | char *normalized_name; /**< The normalized version of |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
163 | @a name. It must be set, and |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
164 | may be set to the same pointer |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
165 | value as @a name. */ |
|
13624
c6577def4e2a
[gaim-migrate @ 16009]
Richard Laager <rlaager@pidgin.im>
parents:
13389
diff
changeset
|
166 | |
|
c6577def4e2a
[gaim-migrate @ 16009]
Richard Laager <rlaager@pidgin.im>
parents:
13389
diff
changeset
|
167 | /* IMPORTANT: Some code in log.c allocates these without zeroing them. |
|
c6577def4e2a
[gaim-migrate @ 16009]
Richard Laager <rlaager@pidgin.im>
parents:
13389
diff
changeset
|
168 | * IMPORTANT: Update that code if you add members here. */ |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
169 | }; |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
170 | |
|
5944
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
171 | #ifdef __cplusplus |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
172 | extern "C" { |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
173 | #endif |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
174 | |
| 10566 | 175 | /***************************************/ |
| 176 | /** @name Log Functions */ | |
| 177 | /***************************************/ | |
| 178 | /*@{*/ | |
| 7440 | 179 | |
| 10566 | 180 | /** |
| 181 | * Creates a new log | |
| 182 | * | |
| 183 | * @param type The type of log this is. | |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
184 | * @param name The name of this conversation (screenname, chat name, |
| 10566 | 185 | * etc.) |
| 186 | * @param account The account the conversation is occurring on | |
|
11292
13068c68def6
[gaim-migrate @ 13492]
Richard Laager <rlaager@pidgin.im>
parents:
11177
diff
changeset
|
187 | * @param conv The conversation being logged |
| 10566 | 188 | * @param time The time this conversation started |
|
13120
c25222322810
[gaim-migrate @ 15481]
Richard Laager <rlaager@pidgin.im>
parents:
13059
diff
changeset
|
189 | * @param tm The time this conversation started, with timezone data, |
|
c25222322810
[gaim-migrate @ 15481]
Richard Laager <rlaager@pidgin.im>
parents:
13059
diff
changeset
|
190 | * if available and if struct tm has the BSD timezone fields. |
| 10566 | 191 | * @return The new log |
| 192 | */ | |
|
11292
13068c68def6
[gaim-migrate @ 13492]
Richard Laager <rlaager@pidgin.im>
parents:
11177
diff
changeset
|
193 | GaimLog *gaim_log_new(GaimLogType type, const char *name, GaimAccount *account, |
|
13120
c25222322810
[gaim-migrate @ 15481]
Richard Laager <rlaager@pidgin.im>
parents:
13059
diff
changeset
|
194 | GaimConversation *conv, time_t time, const struct tm *tm); |
| 7431 | 195 | |
| 10566 | 196 | /** |
| 197 | * Frees a log | |
| 198 | * | |
| 199 | * @param log The log to destroy | |
| 200 | */ | |
| 201 | void gaim_log_free(GaimLog *log); | |
| 7440 | 202 | |
| 10566 | 203 | /** |
| 204 | * Writes to a log file. Assumes you have checked preferences already. | |
| 205 | * | |
| 206 | * @param log The log to write to | |
| 207 | * @param type The type of message being logged | |
|
11503
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
208 | * @param from Whom this message is coming from, or @c NULL for |
| 10566 | 209 | * system messages |
| 210 | * @param time A timestamp in UNIX time | |
| 211 | * @param message The message to log | |
| 212 | */ | |
| 213 | void gaim_log_write(GaimLog *log, | |
| 214 | GaimMessageFlags type, | |
| 215 | const char *from, | |
| 216 | time_t time, | |
| 217 | const char *message); | |
| 7431 | 218 | |
| 10566 | 219 | /** |
| 220 | * Reads from a log | |
| 221 | * | |
| 222 | * @param log The log to read from | |
| 223 | * @param flags The returned logging flags. | |
| 224 | * | |
| 225 | * @return The contents of this log in Gaim Markup. | |
| 226 | */ | |
| 227 | char *gaim_log_read(GaimLog *log, GaimLogReadFlags *flags); | |
| 7431 | 228 | |
| 10566 | 229 | /** |
| 230 | * Returns a list of all available logs | |
| 231 | * | |
| 232 | * @param type The type of the log | |
| 233 | * @param name The name of the log | |
| 234 | * @param account The account | |
| 235 | * @return A sorted list of GaimLogs | |
| 236 | */ | |
| 237 | GList *gaim_log_get_logs(GaimLogType type, const char *name, GaimAccount *account); | |
| 7440 | 238 | |
| 10566 | 239 | /** |
|
11177
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
240 | * Returns a GHashTable of GaimLogSets. |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
241 | * |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
242 | * A "log set" here means the information necessary to gather the |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
243 | * GaimLogs for a given buddy/chat. This information would be passed |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
244 | * to gaim_log_list to get a list of GaimLogs. |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
245 | * |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
246 | * The primary use of this function is to get a list of everyone the |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
247 | * user has ever talked to (assuming he or she uses logging). |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
248 | * |
|
11177
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
249 | * The GHashTable that's returned will free all log sets in it when |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
250 | * destroyed. If a GaimLogSet is removed from the GHashTable, it |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
251 | * must be freed with gaim_log_set_free(). |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
252 | * |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
253 | * @return A GHashTable of all available unique GaimLogSets |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
254 | */ |
|
11177
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
255 | GHashTable *gaim_log_get_log_sets(void); |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
256 | |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
257 | /** |
| 10566 | 258 | * Returns a list of all available system logs |
| 259 | * | |
| 260 | * @param account The account | |
|
11177
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
261 | * @return A sorted list of GaimLogs |
| 10566 | 262 | */ |
| 263 | GList *gaim_log_get_system_logs(GaimAccount *account); | |
| 8573 | 264 | |
| 10566 | 265 | /** |
| 10822 | 266 | * Returns the size of a log |
| 10566 | 267 | * |
| 268 | * @param log The log | |
| 269 | * @return The size of the log, in bytes | |
| 270 | */ | |
| 271 | int gaim_log_get_size(GaimLog *log); | |
| 5872 | 272 | |
| 10566 | 273 | /** |
| 274 | * Returns the size, in bytes, of all available logs in this conversation | |
| 275 | * | |
| 276 | * @param type The type of the log | |
| 277 | * @param name The name of the log | |
| 278 | * @param account The account | |
| 279 | * @return The size in bytes | |
| 280 | */ | |
| 281 | int gaim_log_get_total_size(GaimLogType type, const char *name, GaimAccount *account); | |
| 8573 | 282 | |
| 10566 | 283 | /** |
| 10822 | 284 | * Returns the default logger directory Gaim uses for a given account |
| 285 | * and username. This would be where Gaim stores logs created by | |
| 286 | * the built-in text or HTML loggers. | |
| 287 | * | |
| 288 | * @param type The type of the log. | |
| 289 | * @param name The name of the log. | |
| 290 | * @param account The account. | |
| 291 | * @return The default logger directory for Gaim. | |
| 292 | */ | |
| 293 | char *gaim_log_get_log_dir(GaimLogType type, const char *name, GaimAccount *account); | |
| 294 | ||
| 295 | /** | |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
296 | * Implements GCompareFunc for GaimLogs |
| 10566 | 297 | * |
|
11177
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
298 | * @param y A GaimLog |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
299 | * @param z Another GaimLog |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
300 | * @return A value as specified by GCompareFunc |
| 10566 | 301 | */ |
| 302 | gint gaim_log_compare(gconstpointer y, gconstpointer z); | |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
303 | |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
304 | /** |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
305 | * Implements GCompareFunc for GaimLogSets |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
306 | * |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
307 | * @param y A GaimLogSet |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
308 | * @param z Another GaimLogSet |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
309 | * @return A value as specified by GCompareFunc |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
310 | */ |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
311 | gint gaim_log_set_compare(gconstpointer y, gconstpointer z); |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
312 | |
|
11177
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
313 | /** |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
314 | * Frees a log set |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
315 | * |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
316 | * @param set The log set to destroy |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
317 | */ |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
318 | void gaim_log_set_free(GaimLogSet *set); |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
319 | |
| 10566 | 320 | /*@}*/ |
| 8573 | 321 | |
| 10566 | 322 | /******************************************/ |
| 10822 | 323 | /** @name Common Logger Functions */ |
| 324 | /******************************************/ | |
| 325 | /*@{*/ | |
| 326 | ||
| 327 | /** | |
| 328 | * Opens a new log file in the standard Gaim log location | |
| 329 | * with the given file extension, named for the current time, | |
| 330 | * for writing. If a log file is already open, the existing | |
| 331 | * file handle is retained. The log's logger_data value is | |
| 332 | * set to a GaimLogCommonLoggerData struct containing the log | |
| 333 | * file handle and log path. | |
| 334 | * | |
| 335 | * @param log The log to write to. | |
| 336 | * @param ext The file extension to give to this log file. | |
| 337 | */ | |
|
11292
13068c68def6
[gaim-migrate @ 13492]
Richard Laager <rlaager@pidgin.im>
parents:
11177
diff
changeset
|
338 | void gaim_log_common_writer(GaimLog *log, const char *ext); |
| 10822 | 339 | |
| 340 | /** | |
| 341 | * Returns a sorted GList of GaimLogs of the requested type. | |
| 342 | * This function should only be used with logs that are written | |
| 343 | * with gaim_log_common_writer(). | |
| 344 | * | |
| 345 | * @param type The type of the logs being listed. | |
| 346 | * @param name The name of the log. | |
| 347 | * @param account The account of the log. | |
| 348 | * @param ext The file extension this log format uses. | |
| 349 | * @param logger A reference to the logger struct for this log. | |
| 350 | * | |
| 351 | * @return A sorted GList of GaimLogs matching the parameters. | |
| 352 | */ | |
| 353 | GList *gaim_log_common_lister(GaimLogType type, const char *name, | |
| 354 | GaimAccount *account, const char *ext, | |
| 355 | GaimLogLogger *logger); | |
| 356 | ||
| 357 | /** | |
|
13389
27cf7d84dfd1
[gaim-migrate @ 15761]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
358 | * Returns the total size of all the logs for a given user, with |
|
27cf7d84dfd1
[gaim-migrate @ 15761]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
359 | * a given extension. This is the "common" implemention of a |
|
27cf7d84dfd1
[gaim-migrate @ 15761]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
360 | * logger's total_size function. |
|
27cf7d84dfd1
[gaim-migrate @ 15761]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
361 | * This function should only be used with logs that are written |
|
27cf7d84dfd1
[gaim-migrate @ 15761]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
362 | * with gaim_log_common_writer(). |
|
27cf7d84dfd1
[gaim-migrate @ 15761]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
363 | * |
|
27cf7d84dfd1
[gaim-migrate @ 15761]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
364 | * @param type The type of the logs being sized. |
|
27cf7d84dfd1
[gaim-migrate @ 15761]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
365 | * @param name The name of the logs to size |
|
27cf7d84dfd1
[gaim-migrate @ 15761]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
366 | * (e.g. the username or chat name). |
|
27cf7d84dfd1
[gaim-migrate @ 15761]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
367 | * @param account The account of the log. |
|
27cf7d84dfd1
[gaim-migrate @ 15761]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
368 | * @param ext The file extension this log format uses. |
|
27cf7d84dfd1
[gaim-migrate @ 15761]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
369 | * |
|
27cf7d84dfd1
[gaim-migrate @ 15761]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
370 | * @return The size of all the logs with the specified extension |
|
27cf7d84dfd1
[gaim-migrate @ 15761]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
371 | * for the specified user. |
|
27cf7d84dfd1
[gaim-migrate @ 15761]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
372 | */ |
|
27cf7d84dfd1
[gaim-migrate @ 15761]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
373 | int gaim_log_common_total_sizer(GaimLogType type, const char *name, |
|
27cf7d84dfd1
[gaim-migrate @ 15761]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
374 | GaimAccount *account, const char *ext); |
|
27cf7d84dfd1
[gaim-migrate @ 15761]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
375 | |
|
27cf7d84dfd1
[gaim-migrate @ 15761]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
376 | /** |
| 10822 | 377 | * Returns the size of a given GaimLog. |
| 378 | * This function should only be used with logs that are written | |
| 379 | * with gaim_log_common_writer(). | |
| 380 | * | |
| 381 | * @param log The GaimLog to size. | |
| 382 | * | |
| 383 | * @return An integer indicating the size of the log in bytes. | |
| 384 | */ | |
| 385 | int gaim_log_common_sizer(GaimLog *log); | |
| 386 | /*@}*/ | |
| 387 | ||
| 388 | /******************************************/ | |
| 10566 | 389 | /** @name Logger Functions */ |
| 390 | /******************************************/ | |
| 391 | /*@{*/ | |
| 7440 | 392 | |
| 10566 | 393 | /** |
| 394 | * Creates a new logger | |
| 395 | * | |
|
11503
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
396 | * @param id The logger's id. |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
397 | * @param name The logger's name. |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
398 | * @param functions The number of functions being passed. The following |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
399 | * functions are currently available (in order): @c create, |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
400 | * @c write, @c finalize, @c list, @c read, @c size, |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
401 | * @c total_size, @c list_syslog, @c get_log_sets. For |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
402 | * details on these functions, see GaimLogLogger. |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
403 | * Functions may not be skipped. For example, passing |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
404 | * @c create and @c write is acceptable (for a total of |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
405 | * two functions). Passing @c create and @c finalize, |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
406 | * however, is not. To accomplish that, the caller must |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
407 | * pass @c create, @c NULL (a placeholder for @c write), |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
408 | * and @c finalize (for a total of 3 functions). |
| 10566 | 409 | * |
| 410 | * @return The new logger | |
| 411 | */ | |
|
11503
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
412 | GaimLogLogger *gaim_log_logger_new(const char *id, const char *name, int functions, ...); |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
413 | |
| 10566 | 414 | /** |
| 415 | * Frees a logger | |
| 416 | * | |
| 417 | * @param logger The logger to free | |
| 418 | */ | |
| 419 | void gaim_log_logger_free(GaimLogLogger *logger); | |
| 7440 | 420 | |
| 10566 | 421 | /** |
| 422 | * Adds a new logger | |
| 423 | * | |
| 424 | * @param logger The new logger to add | |
| 425 | */ | |
| 426 | void gaim_log_logger_add (GaimLogLogger *logger); | |
| 7431 | 427 | |
| 10566 | 428 | /** |
| 429 | * | |
| 430 | * Removes a logger | |
| 431 | * | |
| 432 | * @param logger The logger to remove | |
| 433 | */ | |
| 434 | void gaim_log_logger_remove (GaimLogLogger *logger); | |
| 7431 | 435 | |
| 10566 | 436 | /** |
| 437 | * | |
| 438 | * Sets the current logger | |
| 439 | * | |
| 440 | * @param logger The logger to set | |
| 441 | */ | |
| 442 | void gaim_log_logger_set (GaimLogLogger *logger); | |
| 7440 | 443 | |
| 10566 | 444 | /** |
| 445 | * | |
| 446 | * Returns the current logger | |
| 447 | * | |
| 448 | * @return logger The current logger | |
| 449 | */ | |
| 450 | GaimLogLogger *gaim_log_logger_get (void); | |
| 7440 | 451 | |
| 10566 | 452 | /** |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
453 | * Returns a GList containing the IDs and names of the registered |
| 10566 | 454 | * loggers. |
| 455 | * | |
| 456 | * @return The list of IDs and names. | |
| 457 | */ | |
| 458 | GList *gaim_log_logger_get_options(void); | |
| 7431 | 459 | |
|
12737
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
460 | /**************************************************************************/ |
|
12835
edc2ec6ae9f3
[gaim-migrate @ 15183]
Richard Laager <rlaager@pidgin.im>
parents:
12737
diff
changeset
|
461 | /** @name Log Subsystem */ |
|
12737
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
462 | /**************************************************************************/ |
|
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
463 | /*@{*/ |
|
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
464 | |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
465 | /** |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
466 | * Initializes the log subsystem. |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
467 | */ |
| 10566 | 468 | void gaim_log_init(void); |
|
12737
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
469 | |
|
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
470 | /** |
|
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
471 | * Returns the log subsystem handle. |
|
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
472 | * |
|
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
473 | * @return The log subsystem handle. |
|
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
474 | */ |
|
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
475 | void *gaim_log_get_handle(void); |
|
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
476 | |
|
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
477 | /** |
|
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
478 | * Uninitializes the log subsystem. |
|
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
479 | */ |
|
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
480 | void gaim_log_uninit(void); |
|
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
481 | |
| 10566 | 482 | /*@}*/ |
| 7431 | 483 | |
| 5872 | 484 | |
|
5944
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
485 | #ifdef __cplusplus |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
486 | } |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
487 | #endif |
| 7440 | 488 | |
| 7431 | 489 | #endif /* _GAIM_LOG_H_ */ |