Sun, 12 Feb 2006 18:22:27 +0000
[gaim-migrate @ 15617]
I think this is the correct type for the flags here.
| 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.*/ |
| 5872 | 129 | }; |
| 130 | ||
| 10822 | 131 | /** |
| 132 | * A common logger_data struct containing a file handle and path, as well | |
| 133 | * as a pointer to something else for additional data. | |
| 134 | */ | |
| 135 | struct _GaimLogCommonLoggerData { | |
| 136 | char *path; | |
| 137 | FILE *file; | |
| 138 | void *extra_data; | |
| 139 | }; | |
| 7431 | 140 | |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
141 | /** |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
142 | * Describes available logs. |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
143 | * |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
144 | * 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
|
145 | * can get all available GaimLogs. |
|
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 | struct _GaimLogSet { |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
148 | GaimLogType type; /**< The type of logs available */ |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
149 | char *name; /**< The name of the logs available */ |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
150 | GaimAccount *account; /**< The account the available logs |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
151 | took place on. This will be |
|
11503
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
152 | @c NULL if the account no longer |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
153 | exists. (Depending on a |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
154 | logger's implementation of |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
155 | list, it may not be possible |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
156 | to load such logs.) */ |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
157 | gboolean buddy; /**< Is this (account, name) a buddy |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
158 | on the buddy list? */ |
|
11177
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
159 | char *normalized_name; /**< The normalized version of |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
160 | @a name. It must be set, and |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
161 | may be set to the same pointer |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
162 | value as @a name. */ |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
163 | }; |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
164 | |
|
5944
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
165 | #ifdef __cplusplus |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
166 | extern "C" { |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
167 | #endif |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
168 | |
| 10566 | 169 | /***************************************/ |
| 170 | /** @name Log Functions */ | |
| 171 | /***************************************/ | |
| 172 | /*@{*/ | |
| 7440 | 173 | |
| 10566 | 174 | /** |
| 175 | * Creates a new log | |
| 176 | * | |
| 177 | * @param type The type of log this is. | |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
178 | * @param name The name of this conversation (screenname, chat name, |
| 10566 | 179 | * etc.) |
| 180 | * @param account The account the conversation is occurring on | |
|
11292
13068c68def6
[gaim-migrate @ 13492]
Richard Laager <rlaager@pidgin.im>
parents:
11177
diff
changeset
|
181 | * @param conv The conversation being logged |
| 10566 | 182 | * @param time The time this conversation started |
|
13120
c25222322810
[gaim-migrate @ 15481]
Richard Laager <rlaager@pidgin.im>
parents:
13059
diff
changeset
|
183 | * @param tm The time this conversation started, with timezone data, |
|
c25222322810
[gaim-migrate @ 15481]
Richard Laager <rlaager@pidgin.im>
parents:
13059
diff
changeset
|
184 | * if available and if struct tm has the BSD timezone fields. |
| 10566 | 185 | * @return The new log |
| 186 | */ | |
|
11292
13068c68def6
[gaim-migrate @ 13492]
Richard Laager <rlaager@pidgin.im>
parents:
11177
diff
changeset
|
187 | 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
|
188 | GaimConversation *conv, time_t time, const struct tm *tm); |
| 7431 | 189 | |
| 10566 | 190 | /** |
| 191 | * Frees a log | |
| 192 | * | |
| 193 | * @param log The log to destroy | |
| 194 | */ | |
| 195 | void gaim_log_free(GaimLog *log); | |
| 7440 | 196 | |
| 10566 | 197 | /** |
| 198 | * Writes to a log file. Assumes you have checked preferences already. | |
| 199 | * | |
| 200 | * @param log The log to write to | |
| 201 | * @param type The type of message being logged | |
|
11503
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
202 | * @param from Whom this message is coming from, or @c NULL for |
| 10566 | 203 | * system messages |
| 204 | * @param time A timestamp in UNIX time | |
| 205 | * @param message The message to log | |
| 206 | */ | |
| 207 | void gaim_log_write(GaimLog *log, | |
| 208 | GaimMessageFlags type, | |
| 209 | const char *from, | |
| 210 | time_t time, | |
| 211 | const char *message); | |
| 7431 | 212 | |
| 10566 | 213 | /** |
| 214 | * Reads from a log | |
| 215 | * | |
| 216 | * @param log The log to read from | |
| 217 | * @param flags The returned logging flags. | |
| 218 | * | |
| 219 | * @return The contents of this log in Gaim Markup. | |
| 220 | */ | |
| 221 | char *gaim_log_read(GaimLog *log, GaimLogReadFlags *flags); | |
| 7431 | 222 | |
| 10566 | 223 | /** |
| 224 | * Returns a list of all available logs | |
| 225 | * | |
| 226 | * @param type The type of the log | |
| 227 | * @param name The name of the log | |
| 228 | * @param account The account | |
| 229 | * @return A sorted list of GaimLogs | |
| 230 | */ | |
| 231 | GList *gaim_log_get_logs(GaimLogType type, const char *name, GaimAccount *account); | |
| 7440 | 232 | |
| 10566 | 233 | /** |
|
11177
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
234 | * Returns a GHashTable of GaimLogSets. |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
235 | * |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
236 | * A "log set" here means the information necessary to gather the |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
237 | * GaimLogs for a given buddy/chat. This information would be passed |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
238 | * to gaim_log_list to get a list of GaimLogs. |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
239 | * |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
240 | * 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
|
241 | * user has ever talked to (assuming he or she uses logging). |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
242 | * |
|
11177
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
243 | * 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
|
244 | * destroyed. If a GaimLogSet is removed from the GHashTable, it |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
245 | * must be freed with gaim_log_set_free(). |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
246 | * |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
247 | * @return A GHashTable of all available unique GaimLogSets |
|
11025
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 | GHashTable *gaim_log_get_log_sets(void); |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
250 | |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
251 | /** |
| 10566 | 252 | * Returns a list of all available system logs |
| 253 | * | |
| 254 | * @param account The account | |
|
11177
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
255 | * @return A sorted list of GaimLogs |
| 10566 | 256 | */ |
| 257 | GList *gaim_log_get_system_logs(GaimAccount *account); | |
| 8573 | 258 | |
| 10566 | 259 | /** |
| 10822 | 260 | * Returns the size of a log |
| 10566 | 261 | * |
| 262 | * @param log The log | |
| 263 | * @return The size of the log, in bytes | |
| 264 | */ | |
| 265 | int gaim_log_get_size(GaimLog *log); | |
| 5872 | 266 | |
| 10566 | 267 | /** |
| 268 | * Returns the size, in bytes, of all available logs in this conversation | |
| 269 | * | |
| 270 | * @param type The type of the log | |
| 271 | * @param name The name of the log | |
| 272 | * @param account The account | |
| 273 | * @return The size in bytes | |
| 274 | */ | |
| 275 | int gaim_log_get_total_size(GaimLogType type, const char *name, GaimAccount *account); | |
| 8573 | 276 | |
| 10566 | 277 | /** |
| 10822 | 278 | * Returns the default logger directory Gaim uses for a given account |
| 279 | * and username. This would be where Gaim stores logs created by | |
| 280 | * the built-in text or HTML loggers. | |
| 281 | * | |
| 282 | * @param type The type of the log. | |
| 283 | * @param name The name of the log. | |
| 284 | * @param account The account. | |
| 285 | * @return The default logger directory for Gaim. | |
| 286 | */ | |
| 287 | char *gaim_log_get_log_dir(GaimLogType type, const char *name, GaimAccount *account); | |
| 288 | ||
| 289 | /** | |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
290 | * Implements GCompareFunc for GaimLogs |
| 10566 | 291 | * |
|
11177
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
292 | * @param y A GaimLog |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
293 | * @param z Another GaimLog |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
294 | * @return A value as specified by GCompareFunc |
| 10566 | 295 | */ |
| 296 | gint gaim_log_compare(gconstpointer y, gconstpointer z); | |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
297 | |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
298 | /** |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
299 | * Implements GCompareFunc for GaimLogSets |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
300 | * |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
301 | * @param y A GaimLogSet |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
302 | * @param z Another GaimLogSet |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
303 | * @return A value as specified by GCompareFunc |
|
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 | gint gaim_log_set_compare(gconstpointer y, gconstpointer z); |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
306 | |
|
11177
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
307 | /** |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
308 | * Frees a log set |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
309 | * |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
310 | * @param set The log set to destroy |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
311 | */ |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
312 | void gaim_log_set_free(GaimLogSet *set); |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
313 | |
| 10566 | 314 | /*@}*/ |
| 8573 | 315 | |
| 10566 | 316 | /******************************************/ |
| 10822 | 317 | /** @name Common Logger Functions */ |
| 318 | /******************************************/ | |
| 319 | /*@{*/ | |
| 320 | ||
| 321 | /** | |
| 322 | * Opens a new log file in the standard Gaim log location | |
| 323 | * with the given file extension, named for the current time, | |
| 324 | * for writing. If a log file is already open, the existing | |
| 325 | * file handle is retained. The log's logger_data value is | |
| 326 | * set to a GaimLogCommonLoggerData struct containing the log | |
| 327 | * file handle and log path. | |
| 328 | * | |
| 329 | * @param log The log to write to. | |
| 330 | * @param ext The file extension to give to this log file. | |
| 331 | */ | |
|
11292
13068c68def6
[gaim-migrate @ 13492]
Richard Laager <rlaager@pidgin.im>
parents:
11177
diff
changeset
|
332 | void gaim_log_common_writer(GaimLog *log, const char *ext); |
| 10822 | 333 | |
| 334 | /** | |
| 335 | * Returns a sorted GList of GaimLogs of the requested type. | |
| 336 | * This function should only be used with logs that are written | |
| 337 | * with gaim_log_common_writer(). | |
| 338 | * | |
| 339 | * @param type The type of the logs being listed. | |
| 340 | * @param name The name of the log. | |
| 341 | * @param account The account of the log. | |
| 342 | * @param ext The file extension this log format uses. | |
| 343 | * @param logger A reference to the logger struct for this log. | |
| 344 | * | |
| 345 | * @return A sorted GList of GaimLogs matching the parameters. | |
| 346 | */ | |
| 347 | GList *gaim_log_common_lister(GaimLogType type, const char *name, | |
| 348 | GaimAccount *account, const char *ext, | |
| 349 | GaimLogLogger *logger); | |
| 350 | ||
| 351 | /** | |
| 352 | * Returns the size of a given GaimLog. | |
| 353 | * This function should only be used with logs that are written | |
| 354 | * with gaim_log_common_writer(). | |
| 355 | * | |
| 356 | * @param log The GaimLog to size. | |
| 357 | * | |
| 358 | * @return An integer indicating the size of the log in bytes. | |
| 359 | */ | |
| 360 | int gaim_log_common_sizer(GaimLog *log); | |
| 361 | /*@}*/ | |
| 362 | ||
| 363 | /******************************************/ | |
| 10566 | 364 | /** @name Logger Functions */ |
| 365 | /******************************************/ | |
| 366 | /*@{*/ | |
| 7440 | 367 | |
| 10566 | 368 | /** |
| 369 | * Creates a new logger | |
| 370 | * | |
|
11503
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
371 | * @param id The logger's id. |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
372 | * @param name The logger's name. |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
373 | * @param functions The number of functions being passed. The following |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
374 | * functions are currently available (in order): @c create, |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
375 | * @c write, @c finalize, @c list, @c read, @c size, |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
376 | * @c total_size, @c list_syslog, @c get_log_sets. For |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
377 | * details on these functions, see GaimLogLogger. |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
378 | * Functions may not be skipped. For example, passing |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
379 | * @c create and @c write is acceptable (for a total of |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
380 | * two functions). Passing @c create and @c finalize, |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
381 | * however, is not. To accomplish that, the caller must |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
382 | * pass @c create, @c NULL (a placeholder for @c write), |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
383 | * and @c finalize (for a total of 3 functions). |
| 10566 | 384 | * |
| 385 | * @return The new logger | |
| 386 | */ | |
|
11503
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
387 | 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
|
388 | |
| 10566 | 389 | /** |
| 390 | * Frees a logger | |
| 391 | * | |
| 392 | * @param logger The logger to free | |
| 393 | */ | |
| 394 | void gaim_log_logger_free(GaimLogLogger *logger); | |
| 7440 | 395 | |
| 10566 | 396 | /** |
| 397 | * Adds a new logger | |
| 398 | * | |
| 399 | * @param logger The new logger to add | |
| 400 | */ | |
| 401 | void gaim_log_logger_add (GaimLogLogger *logger); | |
| 7431 | 402 | |
| 10566 | 403 | /** |
| 404 | * | |
| 405 | * Removes a logger | |
| 406 | * | |
| 407 | * @param logger The logger to remove | |
| 408 | */ | |
| 409 | void gaim_log_logger_remove (GaimLogLogger *logger); | |
| 7431 | 410 | |
| 10566 | 411 | /** |
| 412 | * | |
| 413 | * Sets the current logger | |
| 414 | * | |
| 415 | * @param logger The logger to set | |
| 416 | */ | |
| 417 | void gaim_log_logger_set (GaimLogLogger *logger); | |
| 7440 | 418 | |
| 10566 | 419 | /** |
| 420 | * | |
| 421 | * Returns the current logger | |
| 422 | * | |
| 423 | * @return logger The current logger | |
| 424 | */ | |
| 425 | GaimLogLogger *gaim_log_logger_get (void); | |
| 7440 | 426 | |
| 10566 | 427 | /** |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
428 | * Returns a GList containing the IDs and names of the registered |
| 10566 | 429 | * loggers. |
| 430 | * | |
| 431 | * @return The list of IDs and names. | |
| 432 | */ | |
| 433 | GList *gaim_log_logger_get_options(void); | |
| 7431 | 434 | |
|
12737
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
435 | /**************************************************************************/ |
|
12835
edc2ec6ae9f3
[gaim-migrate @ 15183]
Richard Laager <rlaager@pidgin.im>
parents:
12737
diff
changeset
|
436 | /** @name Log Subsystem */ |
|
12737
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
437 | /**************************************************************************/ |
|
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
438 | /*@{*/ |
|
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
439 | |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
440 | /** |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
441 | * Initializes the log subsystem. |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
442 | */ |
| 10566 | 443 | void gaim_log_init(void); |
|
12737
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
444 | |
|
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
445 | /** |
|
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
446 | * Returns the log subsystem handle. |
|
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
447 | * |
|
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
448 | * @return The log subsystem handle. |
|
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
449 | */ |
|
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
450 | void *gaim_log_get_handle(void); |
|
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
451 | |
|
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
452 | /** |
|
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
453 | * Uninitializes the log subsystem. |
|
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
454 | */ |
|
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
455 | void gaim_log_uninit(void); |
|
e1300804318e
[gaim-migrate @ 15082]
Richard Laager <rlaager@pidgin.im>
parents:
11503
diff
changeset
|
456 | |
| 10566 | 457 | /*@}*/ |
| 7431 | 458 | |
| 5872 | 459 | |
|
5944
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
460 | #ifdef __cplusplus |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
461 | } |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
462 | #endif |
| 7440 | 463 | |
| 7431 | 464 | #endif /* _GAIM_LOG_H_ */ |