Mercurial > pidgin.yaz
annotate src/log.h @ 11274:67a929d50cfe
[gaim-migrate @ 13459]
commit the make dist changes to po files, as otherwise it takes 15 minutes
to process them (and a minute amount of time after the first attempt)
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Mon, 15 Aug 2005 16:22:25 +0000 |
parents | 3924db2b1ca8 |
children | ef9280fdc511 |
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 | |
11177
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
53 typedef void (*GaimLogSetCallback) (GHashTable *sets, GaimLogSet *set); |
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
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
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10566
diff
changeset
|
67 void (*create)(GaimLog *log); |
7440 | 68 |
7431 | 69 /** This is used to write to the log file */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10566
diff
changeset
|
70 void (*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 | 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 | 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 | 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 | 96 |
11177
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
97 /** Adds GaimLogSets to a GHashTable. By passing the data in the GaimLogSets |
11025 | 98 * to list, the caller can get every available GaimLog from the logger. |
99 * Loggers using gaim_log_common_writer() (or otherwise storing their | |
100 * logs in the same directory structure as the stock loggers) do not | |
11177
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
101 * need to implement this function. |
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
102 * |
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
103 * Loggers which implement this function must create a GaimLogSet, |
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
104 * then call @a cb with @a sets and the newly created GaimLogSet. */ |
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
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 |
115 place on */ | |
116 time_t time; /**< The time this conversation | |
117 started */ | |
118 GaimLogLogger *logger; /**< The logging mechanism this log | |
119 is to use */ | |
7431 | 120 void *logger_data; /**< Data used by the log logger */ |
5872 | 121 }; |
122 | |
10822 | 123 /** |
124 * A common logger_data struct containing a file handle and path, as well | |
125 * as a pointer to something else for additional data. | |
126 */ | |
127 struct _GaimLogCommonLoggerData { | |
128 char *path; | |
129 FILE *file; | |
130 void *extra_data; | |
131 }; | |
7431 | 132 |
11025 | 133 /** |
134 * Describes available logs. | |
135 * | |
136 * By passing the elements of this struct to gaim_log_get_logs(), the caller | |
137 * can get all available GaimLogs. | |
138 */ | |
139 struct _GaimLogSet { | |
140 GaimLogType type; /**< The type of logs available */ | |
141 char *name; /**< The name of the logs available */ | |
142 GaimAccount *account; /**< The account the available logs | |
143 took place on. This will be | |
144 NULL if the account no longer | |
145 exists. (Depending on a | |
146 logger's implementation of | |
147 list, it may not be possible | |
148 to load such logs.) */ | |
149 gboolean buddy; /**< Is this (account, name) a buddy | |
150 on the buddy list? */ | |
11177
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
151 char *normalized_name; /**< The normalized version of |
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
152 @a name. It must be set, and |
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
153 may be set to the same pointer |
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
154 value as @a name. */ |
11025 | 155 }; |
156 | |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
157 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
158 extern "C" { |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
159 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
160 |
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
161 /***************************************/ |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
162 /** @name Log Functions */ |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
163 /***************************************/ |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
164 /*@{*/ |
7440 | 165 |
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
166 /** |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
167 * Creates a new log |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
168 * |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
169 * @param type The type of log this is. |
11025 | 170 * @param name The name of this conversation (screenname, chat name, |
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
171 * etc.) |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
172 * @param account The account the conversation is occurring on |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
173 * @param time The time this conversation started |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
174 * @return The new log |
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 GaimLog *gaim_log_new(GaimLogType type, const char *name, |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
177 GaimAccount *account, time_t time); |
7431 | 178 |
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
179 /** |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
180 * Frees a log |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
181 * |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
182 * @param log The log to destroy |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
183 */ |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
184 void gaim_log_free(GaimLog *log); |
7440 | 185 |
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
186 /** |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
187 * Writes to a log file. Assumes you have checked preferences already. |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
188 * |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
189 * @param log The log to write to |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
190 * @param type The type of message being logged |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
191 * @param from Whom this message is coming from, or NULL for |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
192 * system messages |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
193 * @param time A timestamp in UNIX time |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
194 * @param message The message to log |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
195 */ |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
196 void gaim_log_write(GaimLog *log, |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
197 GaimMessageFlags type, |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
198 const char *from, |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
199 time_t time, |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
200 const char *message); |
7431 | 201 |
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
202 /** |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
203 * Reads from a log |
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 * @param log The log to read from |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
206 * @param flags The returned logging flags. |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
207 * |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
208 * @return The contents of this log in Gaim Markup. |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
209 */ |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
210 char *gaim_log_read(GaimLog *log, GaimLogReadFlags *flags); |
7431 | 211 |
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
212 /** |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
213 * Returns a list of all available logs |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
214 * |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
215 * @param type The type of the log |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
216 * @param name The name of the log |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
217 * @param account The account |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
218 * @return A sorted list of GaimLogs |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
219 */ |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
220 GList *gaim_log_get_logs(GaimLogType type, const char *name, GaimAccount *account); |
7440 | 221 |
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
222 /** |
11177
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
223 * Returns a GHashTable of GaimLogSets. |
11025 | 224 * |
225 * A "log set" here means the information necessary to gather the | |
226 * GaimLogs for a given buddy/chat. This information would be passed | |
227 * to gaim_log_list to get a list of GaimLogs. | |
228 * | |
229 * The primary use of this function is to get a list of everyone the | |
230 * user has ever talked to (assuming he or she uses logging). | |
231 * | |
11177
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
232 * The GHashTable that's returned will free all log sets in it when |
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
233 * destroyed. If a GaimLogSet is removed from the GHashTable, it |
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
234 * must be freed with gaim_log_set_free(). |
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
235 * |
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
236 * @return A GHashTable of all available unique GaimLogSets |
11025 | 237 */ |
11177
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
238 GHashTable *gaim_log_get_log_sets(void); |
11025 | 239 |
240 /** | |
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
241 * Returns a list of all available system logs |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
242 * |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
243 * @param account The account |
11177
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
244 * @return A sorted list of GaimLogs |
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
245 */ |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
246 GList *gaim_log_get_system_logs(GaimAccount *account); |
8573 | 247 |
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
248 /** |
10822 | 249 * Returns the size of a log |
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
250 * |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
251 * @param log The log |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
252 * @return The size of the log, in bytes |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
253 */ |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
254 int gaim_log_get_size(GaimLog *log); |
5872 | 255 |
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
256 /** |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
257 * 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
|
258 * |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
259 * @param type The type of the log |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
260 * @param name The name of the log |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
261 * @param account The account |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
262 * @return The size in bytes |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
263 */ |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
264 int gaim_log_get_total_size(GaimLogType type, const char *name, GaimAccount *account); |
8573 | 265 |
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
266 /** |
10822 | 267 * Returns the default logger directory Gaim uses for a given account |
268 * and username. This would be where Gaim stores logs created by | |
269 * the built-in text or HTML loggers. | |
270 * | |
271 * @param type The type of the log. | |
272 * @param name The name of the log. | |
273 * @param account The account. | |
274 * @return The default logger directory for Gaim. | |
275 */ | |
276 char *gaim_log_get_log_dir(GaimLogType type, const char *name, GaimAccount *account); | |
277 | |
278 /** | |
11025 | 279 * Implements GCompareFunc for GaimLogs |
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
280 * |
11177
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
281 * @param y A GaimLog |
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
282 * @param z Another GaimLog |
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
283 * @return A value as specified by GCompareFunc |
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
284 */ |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
285 gint gaim_log_compare(gconstpointer y, gconstpointer z); |
11025 | 286 |
287 /** | |
288 * Implements GCompareFunc for GaimLogSets | |
289 * | |
290 * @param y A GaimLogSet | |
291 * @param z Another GaimLogSet | |
292 * @return A value as specified by GCompareFunc | |
293 */ | |
294 gint gaim_log_set_compare(gconstpointer y, gconstpointer z); | |
295 | |
11177
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
296 /** |
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
297 * Frees a log set |
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
298 * |
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
299 * @param set The log set to destroy |
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
300 */ |
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
301 void gaim_log_set_free(GaimLogSet *set); |
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
302 |
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
303 /*@}*/ |
8573 | 304 |
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
305 /******************************************/ |
10822 | 306 /** @name Common Logger Functions */ |
307 /******************************************/ | |
308 /*@{*/ | |
309 | |
310 /** | |
311 * Opens a new log file in the standard Gaim log location | |
312 * with the given file extension, named for the current time, | |
313 * for writing. If a log file is already open, the existing | |
314 * file handle is retained. The log's logger_data value is | |
315 * set to a GaimLogCommonLoggerData struct containing the log | |
316 * file handle and log path. | |
317 * | |
318 * @param log The log to write to. | |
319 * @param time The time of the item being logged. | |
320 * @param ext The file extension to give to this log file. | |
321 */ | |
322 void gaim_log_common_writer(GaimLog *log, time_t time, const char *ext); | |
323 | |
324 /** | |
325 * Returns a sorted GList of GaimLogs of the requested type. | |
326 * This function should only be used with logs that are written | |
327 * with gaim_log_common_writer(). | |
328 * | |
329 * @param type The type of the logs being listed. | |
330 * @param name The name of the log. | |
331 * @param account The account of the log. | |
332 * @param ext The file extension this log format uses. | |
333 * @param logger A reference to the logger struct for this log. | |
334 * | |
335 * @return A sorted GList of GaimLogs matching the parameters. | |
336 */ | |
337 GList *gaim_log_common_lister(GaimLogType type, const char *name, | |
338 GaimAccount *account, const char *ext, | |
339 GaimLogLogger *logger); | |
340 | |
341 /** | |
342 * Returns the size of a given GaimLog. | |
343 * This function should only be used with logs that are written | |
344 * with gaim_log_common_writer(). | |
345 * | |
346 * @param log The GaimLog to size. | |
347 * | |
348 * @return An integer indicating the size of the log in bytes. | |
349 */ | |
350 int gaim_log_common_sizer(GaimLog *log); | |
351 /*@}*/ | |
352 | |
353 /******************************************/ | |
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
354 /** @name Logger Functions */ |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
355 /******************************************/ |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
356 /*@{*/ |
7440 | 357 |
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
358 /** |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
359 * Creates a new logger |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
360 * |
11025 | 361 * @param create The logger's new function. |
362 * @param write The logger's write function. | |
363 * @param finalize The logger's finalize function. | |
364 * @param list The logger's list function. | |
365 * @param read The logger's read function. | |
366 * @param size The logger's size function. | |
367 * @param total_size The logger's total_size function. | |
368 * @param list_syslog The logger's list_syslog function. | |
369 * @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
|
370 * |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
371 * @return The new logger |
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 GaimLogLogger *gaim_log_logger_new( |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
374 void(*create)(GaimLog *), |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
375 void(*write)(GaimLog *, GaimMessageFlags, const char *, time_t, const char *), |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
376 void(*finalize)(GaimLog *), |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
377 GList*(*list)(GaimLogType type, const char*, GaimAccount*), |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
378 char*(*read)(GaimLog*, GaimLogReadFlags*), |
11025 | 379 int(*size)(GaimLog*), |
380 int(*total_size)(GaimLogType type, const char *name, GaimAccount *account), | |
381 GList*(*list_syslog)(GaimAccount *account), | |
11177
3924db2b1ca8
[gaim-migrate @ 13285]
Richard Laager <rlaager@wiktel.com>
parents:
11035
diff
changeset
|
382 void(*get_log_sets)(GaimLogSetCallback cb, GHashTable *sets)); |
11025 | 383 |
10566
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 * Frees a logger |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
386 * |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
387 * @param logger The logger to free |
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 void gaim_log_logger_free(GaimLogLogger *logger); |
7440 | 390 |
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
391 /** |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
392 * Adds a new logger |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
393 * |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
394 * @param logger The new logger to add |
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 void gaim_log_logger_add (GaimLogLogger *logger); |
7431 | 397 |
10566
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 * |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
400 * Removes a logger |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
401 * |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
402 * @param logger The logger to remove |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
403 */ |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
404 void gaim_log_logger_remove (GaimLogLogger *logger); |
7431 | 405 |
10566
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 * |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
408 * Sets the current logger |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
409 * |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
410 * @param logger The logger to set |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
411 */ |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
412 void gaim_log_logger_set (GaimLogLogger *logger); |
7440 | 413 |
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
414 /** |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
415 * |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
416 * Returns the current logger |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
417 * |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
418 * @return logger The current logger |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
419 */ |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
420 GaimLogLogger *gaim_log_logger_get (void); |
7440 | 421 |
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
422 /** |
11025 | 423 * 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
|
424 * loggers. |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
425 * |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
426 * @return The list of IDs and names. |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
427 */ |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
428 GList *gaim_log_logger_get_options(void); |
7431 | 429 |
11025 | 430 /** |
431 * Initializes the log subsystem. | |
432 */ | |
10566
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
433 void gaim_log_init(void); |
62fc579810f4
[gaim-migrate @ 11949]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10348
diff
changeset
|
434 /*@}*/ |
7431 | 435 |
5872 | 436 |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
437 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
438 } |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
439 #endif |
7440 | 440 |
7431 | 441 #endif /* _GAIM_LOG_H_ */ |