Mercurial > pidgin
annotate src/log.h @ 11025:8d2007d738d5
[gaim-migrate @ 12899]
sf patch #1180490, from Richard Laager (who else?)
A pretty peach of a patch that allows you to auto-complete screen names
based on log file names.
committer: Tailor Script <tailor@pidgin.im>
| author | Mark Doliner <mark@kingant.net> |
|---|---|
| date | Thu, 23 Jun 2005 03:04:52 +0000 |
| parents | 5c5120837bab |
| children | 11e465b55fe6 |
| rev | line source |
|---|---|
| 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 | 38 typedef struct _GaimLogSet GaimLogSet; |
| 7431 | 39 |
| 40 typedef enum { | |
| 41 GAIM_LOG_IM, | |
| 42 GAIM_LOG_CHAT, | |
| 10348 | 43 GAIM_LOG_SYSTEM |
| 7431 | 44 } GaimLogType; |
| 45 | |
| 46 typedef enum { | |
| 10348 | 47 GAIM_LOG_READ_NO_NEWLINE = 1 |
| 7431 | 48 } GaimLogReadFlags; |
| 49 | |
| 50 #include "account.h" | |
| 51 #include "conversation.h" | |
| 52 | |
| 53 /** | |
| 54 * A log logger. | |
| 55 * | |
| 56 * This struct gets filled out and is included in the GaimLog. It contains everything | |
| 57 * needed to write and read from logs. | |
| 58 */ | |
| 9000 | 59 /*@{*/ |
| 7431 | 60 struct _GaimLogLogger { |
| 61 char *name; /**< The logger's name */ | |
| 62 char *id; /**< an identifier to refer to this logger */ | |
| 7440 | 63 |
| 64 /** This gets called when the log is first created. | |
| 7431 | 65 I don't think this is actually needed. */ |
|
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10566
diff
changeset
|
66 void (*create)(GaimLog *log); |
| 7440 | 67 |
| 7431 | 68 /** This is used to write to the log file */ |
|
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10566
diff
changeset
|
69 void (*write)(GaimLog *log, |
| 7440 | 70 GaimMessageFlags type, |
| 7431 | 71 const char *from, |
| 72 time_t time, | |
| 73 const char *message); | |
| 74 | |
| 75 /** Called when the log is destroyed */ | |
| 76 void (*finalize)(GaimLog *log); | |
| 7440 | 77 |
| 7431 | 78 /** This function returns a sorted GList of available GaimLogs */ |
| 8898 | 79 GList *(*list)(GaimLogType type, const char *name, GaimAccount *account); |
| 7440 | 80 |
| 81 /** Given one of the logs returned by the logger's list function, | |
| 82 * this returns the contents of the log in GtkIMHtml markup */ | |
| 7431 | 83 char *(*read)(GaimLog *log, GaimLogReadFlags *flags); |
| 10231 | 84 |
| 7556 | 85 /** Given one of the logs returned by the logger's list function, |
| 86 * this returns the size of the log in bytes */ | |
| 87 int (*size)(GaimLog *log); | |
| 8096 | 88 |
| 89 /** Returns the total size of all the logs. If this is undefined a default | |
| 90 * implementation is used */ | |
| 8898 | 91 int (*total_size)(GaimLogType type, const char *name, GaimAccount *account); |
| 8573 | 92 |
| 93 /** This function returns a sorted GList of available system GaimLogs */ | |
| 94 GList *(*list_syslog)(GaimAccount *account); | |
| 11025 | 95 |
| 96 /** Returns a list of GaimLogSets. By passing the data in the GaimLogSets | |
| 97 * to list, the caller can get every available GaimLog from the logger. | |
| 98 * Loggers using gaim_log_common_writer() (or otherwise storing their | |
| 99 * logs in the same directory structure as the stock loggers) do not | |
| 100 * need to implement this function. */ | |
| 101 GList *(*get_log_sets)(void); | |
| 5872 | 102 }; |
| 103 | |
| 7431 | 104 /** |
| 105 * A log. Not the wooden type. | |
| 106 */ | |
| 107 struct _GaimLog { | |
| 108 GaimLogType type; /**< The type of log this is */ | |
| 109 char *name; /**< The name of this log */ | |
| 7440 | 110 GaimAccount *account; /**< The account this log is taking |
| 111 place on */ | |
| 112 time_t time; /**< The time this conversation | |
| 113 started */ | |
| 114 GaimLogLogger *logger; /**< The logging mechanism this log | |
| 115 is to use */ | |
| 7431 | 116 void *logger_data; /**< Data used by the log logger */ |
| 5872 | 117 }; |
| 118 | |
| 10822 | 119 /** |
| 120 * A common logger_data struct containing a file handle and path, as well | |
| 121 * as a pointer to something else for additional data. | |
| 122 */ | |
| 123 struct _GaimLogCommonLoggerData { | |
| 124 char *path; | |
| 125 FILE *file; | |
| 126 void *extra_data; | |
| 127 }; | |
| 7431 | 128 |
| 11025 | 129 /** |
| 130 * Describes available logs. | |
| 131 * | |
| 132 * By passing the elements of this struct to gaim_log_get_logs(), the caller | |
| 133 * can get all available GaimLogs. | |
| 134 */ | |
| 135 struct _GaimLogSet { | |
| 136 GaimLogType type; /**< The type of logs available */ | |
| 137 char *name; /**< The name of the logs available */ | |
| 138 GaimAccount *account; /**< The account the available logs | |
| 139 took place on. This will be | |
| 140 NULL if the account no longer | |
| 141 exists. (Depending on a | |
| 142 logger's implementation of | |
| 143 list, it may not be possible | |
| 144 to load such logs.) */ | |
| 145 gboolean buddy; /**< Is this (account, name) a buddy | |
| 146 on the buddy list? */ | |
| 147 }; | |
| 148 | |
|
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
149 #ifdef __cplusplus |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
150 extern "C" { |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
151 #endif |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
152 |
|
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
153 /***************************************/ |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
154 /** @name Log Functions */ |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
155 /***************************************/ |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
156 /*@{*/ |
| 7440 | 157 |
|
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
158 /** |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
159 * Creates a new log |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
160 * |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
161 * @param type The type of log this is. |
| 11025 | 162 * @param name The name of this conversation (screenname, chat name, |
|
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
163 * etc.) |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
164 * @param account The account the conversation is occurring on |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
165 * @param time The time this conversation started |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
166 * @return The new log |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
167 */ |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
168 GaimLog *gaim_log_new(GaimLogType type, const char *name, |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
169 GaimAccount *account, time_t time); |
| 7431 | 170 |
|
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
171 /** |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
172 * Frees a log |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
173 * |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
174 * @param log The log to destroy |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
175 */ |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
176 void gaim_log_free(GaimLog *log); |
| 7440 | 177 |
|
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
178 /** |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
179 * Writes to a log file. Assumes you have checked preferences already. |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
180 * |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
181 * @param log The log to write to |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
182 * @param type The type of message being logged |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
183 * @param from Whom this message is coming from, or NULL for |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
184 * system messages |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
185 * @param time A timestamp in UNIX time |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
186 * @param message The message to log |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
187 */ |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
188 void gaim_log_write(GaimLog *log, |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
189 GaimMessageFlags type, |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
190 const char *from, |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
191 time_t time, |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
192 const char *message); |
| 7431 | 193 |
|
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
194 /** |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
195 * Reads from a log |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
196 * |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
197 * @param log The log to read from |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
198 * @param flags The returned logging flags. |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
199 * |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
200 * @return The contents of this log in Gaim Markup. |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
201 */ |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
202 char *gaim_log_read(GaimLog *log, GaimLogReadFlags *flags); |
| 7431 | 203 |
|
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
204 /** |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
205 * Returns a list of all available logs |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
206 * |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
207 * @param type The type of the log |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
208 * @param name The name of the log |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
209 * @param account The account |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
210 * @return A sorted list of GaimLogs |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
211 */ |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
212 GList *gaim_log_get_logs(GaimLogType type, const char *name, GaimAccount *account); |
| 7440 | 213 |
|
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
214 /** |
| 11025 | 215 * Returns a list of GaimLogSets. |
| 216 * | |
| 217 * A "log set" here means the information necessary to gather the | |
| 218 * GaimLogs for a given buddy/chat. This information would be passed | |
| 219 * to gaim_log_list to get a list of GaimLogs. | |
| 220 * | |
| 221 * The primary use of this function is to get a list of everyone the | |
| 222 * user has ever talked to (assuming he or she uses logging). | |
| 223 * | |
| 224 * @return A sorted list of all available unique GaimLogSets | |
| 225 */ | |
| 226 GList *gaim_log_get_log_sets(void); | |
| 227 | |
| 228 /** | |
|
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
229 * Returns a list of all available system logs |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
230 * |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
231 * @param account The account |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
232 * @return A sorted list of GaimLogs |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
233 */ |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
234 GList *gaim_log_get_system_logs(GaimAccount *account); |
| 8573 | 235 |
|
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
236 /** |
| 10822 | 237 * Returns the size of a log |
|
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
238 * |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
239 * @param log The log |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
240 * @return The size of the log, in bytes |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
241 */ |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
242 int gaim_log_get_size(GaimLog *log); |
| 5872 | 243 |
|
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
244 /** |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
245 * Returns the size, in bytes, of all available logs in this conversation |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
246 * |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
247 * @param type The type of the log |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
248 * @param name The name of the log |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
249 * @param account The account |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
250 * @return The size in bytes |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
251 */ |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
252 int gaim_log_get_total_size(GaimLogType type, const char *name, GaimAccount *account); |
| 8573 | 253 |
|
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
254 /** |
| 10822 | 255 * Returns the default logger directory Gaim uses for a given account |
| 256 * and username. This would be where Gaim stores logs created by | |
| 257 * the built-in text or HTML loggers. | |
| 258 * | |
| 259 * @param type The type of the log. | |
| 260 * @param name The name of the log. | |
| 261 * @param account The account. | |
| 262 * @return The default logger directory for Gaim. | |
| 263 */ | |
| 264 char *gaim_log_get_log_dir(GaimLogType type, const char *name, GaimAccount *account); | |
| 265 | |
| 266 /** | |
| 11025 | 267 * Implements GCompareFunc for GaimLogs |
|
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
268 * |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
269 * @param y A GaimLog |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
270 * @param z Another GaimLog |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
271 * @return A value as specified by GCompareFunc |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
272 */ |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
273 gint gaim_log_compare(gconstpointer y, gconstpointer z); |
| 11025 | 274 |
| 275 /** | |
| 276 * Implements GCompareFunc for GaimLogSets | |
| 277 * | |
| 278 * @param y A GaimLogSet | |
| 279 * @param z Another GaimLogSet | |
| 280 * @return A value as specified by GCompareFunc | |
| 281 */ | |
| 282 gint gaim_log_set_compare(gconstpointer y, gconstpointer z); | |
| 283 | |
|
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
284 /*@}*/ |
| 8573 | 285 |
|
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
286 /******************************************/ |
| 10822 | 287 /** @name Common Logger Functions */ |
| 288 /******************************************/ | |
| 289 /*@{*/ | |
| 290 | |
| 291 /** | |
| 292 * Opens a new log file in the standard Gaim log location | |
| 293 * with the given file extension, named for the current time, | |
| 294 * for writing. If a log file is already open, the existing | |
| 295 * file handle is retained. The log's logger_data value is | |
| 296 * set to a GaimLogCommonLoggerData struct containing the log | |
| 297 * file handle and log path. | |
| 298 * | |
| 299 * @param log The log to write to. | |
| 300 * @param time The time of the item being logged. | |
| 301 * @param ext The file extension to give to this log file. | |
| 302 */ | |
| 303 void gaim_log_common_writer(GaimLog *log, time_t time, const char *ext); | |
| 304 | |
| 305 /** | |
| 306 * Returns a sorted GList of GaimLogs of the requested type. | |
| 307 * This function should only be used with logs that are written | |
| 308 * with gaim_log_common_writer(). | |
| 309 * | |
| 310 * @param type The type of the logs being listed. | |
| 311 * @param name The name of the log. | |
| 312 * @param account The account of the log. | |
| 313 * @param ext The file extension this log format uses. | |
| 314 * @param logger A reference to the logger struct for this log. | |
| 315 * | |
| 316 * @return A sorted GList of GaimLogs matching the parameters. | |
| 317 */ | |
| 318 GList *gaim_log_common_lister(GaimLogType type, const char *name, | |
| 319 GaimAccount *account, const char *ext, | |
| 320 GaimLogLogger *logger); | |
| 321 | |
| 322 /** | |
| 323 * Returns the size of a given GaimLog. | |
| 324 * This function should only be used with logs that are written | |
| 325 * with gaim_log_common_writer(). | |
| 326 * | |
| 327 * @param log The GaimLog to size. | |
| 328 * | |
| 329 * @return An integer indicating the size of the log in bytes. | |
| 330 */ | |
| 331 int gaim_log_common_sizer(GaimLog *log); | |
| 332 /*@}*/ | |
| 333 | |
| 334 /******************************************/ | |
|
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
335 /** @name Logger Functions */ |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
336 /******************************************/ |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
337 /*@{*/ |
| 7440 | 338 |
|
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
339 /** |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
340 * Creates a new logger |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
341 * |
| 11025 | 342 * @param create The logger's new function. |
| 343 * @param write The logger's write function. | |
| 344 * @param finalize The logger's finalize function. | |
| 345 * @param list The logger's list function. | |
| 346 * @param read The logger's read function. | |
| 347 * @param size The logger's size function. | |
| 348 * @param total_size The logger's total_size function. | |
| 349 * @param list_syslog The logger's list_syslog function. | |
| 350 * @param get_log_sets The logger's get_log_sets function. | |
|
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
351 * |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
352 * @return The new logger |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
353 */ |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
354 GaimLogLogger *gaim_log_logger_new( |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
355 void(*create)(GaimLog *), |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
356 void(*write)(GaimLog *, GaimMessageFlags, const char *, time_t, const char *), |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
357 void(*finalize)(GaimLog *), |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
358 GList*(*list)(GaimLogType type, const char*, GaimAccount*), |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
359 char*(*read)(GaimLog*, GaimLogReadFlags*), |
| 11025 | 360 int(*size)(GaimLog*), |
| 361 int(*total_size)(GaimLogType type, const char *name, GaimAccount *account), | |
| 362 GList*(*list_syslog)(GaimAccount *account), | |
| 363 GList*(*get_log_sets)(void)); | |
| 364 | |
|
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
365 /** |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
366 * Frees a logger |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
367 * |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
368 * @param logger The logger to free |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
369 */ |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
370 void gaim_log_logger_free(GaimLogLogger *logger); |
| 7440 | 371 |
|
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
372 /** |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
373 * Adds a new logger |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
374 * |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
375 * @param logger The new logger to add |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
376 */ |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
377 void gaim_log_logger_add (GaimLogLogger *logger); |
| 7431 | 378 |
|
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
379 /** |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
380 * |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
381 * Removes a logger |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
382 * |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
383 * @param logger The logger to remove |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
384 */ |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
385 void gaim_log_logger_remove (GaimLogLogger *logger); |
| 7431 | 386 |
|
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
387 /** |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
388 * |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
389 * Sets the current logger |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
390 * |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
391 * @param logger The logger to set |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
392 */ |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
393 void gaim_log_logger_set (GaimLogLogger *logger); |
| 7440 | 394 |
|
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
395 /** |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
396 * |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
397 * Returns the current logger |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
398 * |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
399 * @return logger The current logger |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
400 */ |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
401 GaimLogLogger *gaim_log_logger_get (void); |
| 7440 | 402 |
|
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
403 /** |
| 11025 | 404 * Returns a GList containing the IDs and names of the registered |
|
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
405 * loggers. |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
406 * |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
407 * @return The list of IDs and names. |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
408 */ |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
409 GList *gaim_log_logger_get_options(void); |
| 7431 | 410 |
| 11025 | 411 /** |
| 412 * Initializes the log subsystem. | |
| 413 */ | |
|
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
414 void gaim_log_init(void); |
|
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
415 /*@}*/ |
| 7431 | 416 |
| 5872 | 417 |
|
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
418 #ifdef __cplusplus |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
419 } |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
420 #endif |
| 7440 | 421 |
| 7431 | 422 #endif /* _GAIM_LOG_H_ */ |
