Mercurial > pidgin
annotate src/log.h @ 8941:71fddf3f340d
[gaim-migrate @ 9711]
Eradicate the two tab completion preferences.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sun, 16 May 2004 00:26:08 +0000 |
parents | de87e510ff9a |
children | b540c735a6ad |
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 */ | |
7431 | 25 |
5872 | 26 #ifndef _GAIM_LOG_H_ |
27 #define _GAIM_LOG_H_ | |
28 | |
7431 | 29 #include <stdio.h> |
5872 | 30 |
31 | |
7431 | 32 /******************************************************** |
33 * DATA STRUCTURES ************************************** | |
34 ********************************************************/ | |
35 | |
36 typedef struct _GaimLog GaimLog; | |
37 typedef struct _GaimLogLogger GaimLogLogger; | |
38 | |
39 typedef enum { | |
40 GAIM_LOG_IM, | |
41 GAIM_LOG_CHAT, | |
42 GAIM_LOG_SYSTEM, | |
43 } GaimLogType; | |
44 | |
45 typedef enum { | |
46 GAIM_LOG_READ_NO_NEWLINE = 1, | |
47 } GaimLogReadFlags; | |
48 | |
49 #include "account.h" | |
50 #include "conversation.h" | |
51 | |
52 /** | |
53 * A log logger. | |
54 * | |
55 * This struct gets filled out and is included in the GaimLog. It contains everything | |
56 * needed to write and read from logs. | |
57 */ | |
58 struct _GaimLogLogger { | |
59 char *name; /**< The logger's name */ | |
60 char *id; /**< an identifier to refer to this logger */ | |
7440 | 61 |
62 /** This gets called when the log is first created. | |
7431 | 63 I don't think this is actually needed. */ |
7440 | 64 void(*create)(GaimLog *log); |
65 | |
7431 | 66 /** This is used to write to the log file */ |
7440 | 67 void(*write)(GaimLog *log, |
68 GaimMessageFlags type, | |
7431 | 69 const char *from, |
70 time_t time, | |
71 const char *message); | |
72 | |
73 /** Called when the log is destroyed */ | |
74 void (*finalize)(GaimLog *log); | |
7440 | 75 |
7431 | 76 /** This function returns a sorted GList of available GaimLogs */ |
8898 | 77 GList *(*list)(GaimLogType type, const char *name, GaimAccount *account); |
7440 | 78 |
79 /** Given one of the logs returned by the logger's list function, | |
80 * this returns the contents of the log in GtkIMHtml markup */ | |
7431 | 81 char *(*read)(GaimLog *log, GaimLogReadFlags *flags); |
7556 | 82 |
83 /** Given one of the logs returned by the logger's list function, | |
84 * this returns the size of the log in bytes */ | |
85 int (*size)(GaimLog *log); | |
8096 | 86 |
87 /** Returns the total size of all the logs. If this is undefined a default | |
88 * implementation is used */ | |
8898 | 89 int (*total_size)(GaimLogType type, const char *name, GaimAccount *account); |
8573 | 90 |
91 /** This function returns a sorted GList of available system GaimLogs */ | |
92 GList *(*list_syslog)(GaimAccount *account); | |
5872 | 93 }; |
94 | |
7431 | 95 /** |
96 * A log. Not the wooden type. | |
97 */ | |
98 struct _GaimLog { | |
99 GaimLogType type; /**< The type of log this is */ | |
100 char *name; /**< The name of this log */ | |
7440 | 101 GaimAccount *account; /**< The account this log is taking |
102 place on */ | |
103 time_t time; /**< The time this conversation | |
104 started */ | |
105 GaimLogLogger *logger; /**< The logging mechanism this log | |
106 is to use */ | |
7431 | 107 void *logger_data; /**< Data used by the log logger */ |
5872 | 108 }; |
109 | |
7431 | 110 |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
111 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
112 extern "C" { |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
113 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
114 |
7431 | 115 /*************************************** |
116 ** LOG FUNCTIONS ********************** | |
117 ***************************************/ | |
7440 | 118 |
7431 | 119 /** |
120 * Creates a new log | |
121 * | |
122 * @param type The type of log this is. | |
7440 | 123 * @param name The name of this conversation (Screenname, chat name, |
124 * etc.) | |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
125 * @param account The account the conversation is occurring on |
7431 | 126 * @param time The time this conversation started |
127 * @return The new log | |
7440 | 128 */ |
129 GaimLog *gaim_log_new(GaimLogType type, const char *name, | |
130 GaimAccount *account, time_t time); | |
7431 | 131 |
132 /** | |
133 * Frees a log | |
134 * | |
135 * @param log The log to destroy | |
7440 | 136 */ |
7431 | 137 void gaim_log_free(GaimLog *log); |
7440 | 138 |
7431 | 139 /** |
140 * Writes to a log file | |
141 * | |
142 * @param log The log to write to | |
143 * @param type The type of message being logged | |
7440 | 144 * @param from Whom this message is coming from, or NULL for |
145 * system messages | |
7431 | 146 * @param time A timestamp in UNIX time |
147 * @param message The message to log | |
148 */ | |
149 void gaim_log_write(GaimLog *log, | |
7440 | 150 GaimMessageFlags type, |
151 const char *from, | |
152 time_t time, | |
7431 | 153 const char *message); |
154 | |
155 /** | |
156 * Reads from a log | |
157 * | |
7456
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
158 * @param log The log to read from |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
159 * @param flags The returned logging flags. |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
160 * |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
161 * @return The contents of this log in Gaim Markup. |
7431 | 162 */ |
163 char *gaim_log_read(GaimLog *log, GaimLogReadFlags *flags); | |
164 | |
165 /** | |
166 * Returns a list of all available logs | |
167 * | |
8898 | 168 * @param type The type of the log |
7431 | 169 * @param name The name of the log |
170 * @param account The account | |
171 * @return A sorted list of GaimLogs | |
172 */ | |
8898 | 173 GList *gaim_log_get_logs(GaimLogType type, const char *name, GaimAccount *account); |
7440 | 174 |
7556 | 175 /** |
8573 | 176 * Returns a list of all available system logs |
177 * | |
178 * @param account The account | |
179 * @return A sorted list of GaimLogs | |
180 */ | |
181 GList *gaim_log_get_system_logs(GaimAccount *account); | |
182 | |
183 /** | |
7556 | 184 * Returns the size of a log |
185 * | |
186 * @param log The log | |
187 * @return The size of the log, in bytes | |
188 */ | |
189 int gaim_log_get_size(GaimLog *log); | |
5872 | 190 |
7556 | 191 /** |
192 * Returns the size, in bytes, of all available logs in this conversation | |
193 * | |
194 * @param name The name of the log | |
195 * @param account The account | |
196 * @return The size in bytes | |
197 */ | |
8898 | 198 int gaim_log_get_total_size(GaimLogType type, const char *name, GaimAccount *account); |
8573 | 199 |
200 /** | |
201 * Implements GCompareFunc | |
202 * | |
203 * @param y A GaimLog | |
204 * @param z Another GaimLog | |
205 * @return A value as specified by GCompareFunc | |
206 */ | |
207 gint gaim_log_compare(gconstpointer y, gconstpointer z); | |
208 | |
7431 | 209 /****************************************** |
210 ** LOGGER FUNCTIONS ********************** | |
211 ******************************************/ | |
7440 | 212 |
7431 | 213 /** |
214 * Creates a new logger | |
215 * | |
7456
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
216 * @param create The logger's new function. |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
217 * @param write The logger's write function. |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
218 * @param finalize The logger's finalize function. |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
219 * @param list The logger's list function. |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
220 * @param read The logger's read function. |
7556 | 221 * @param size The logger's size function. |
7456
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
222 * |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
223 * @return The new logger |
7431 | 224 */ |
8898 | 225 GaimLogLogger *gaim_log_logger_new( |
226 void(*create)(GaimLog *), | |
227 void(*write)(GaimLog *, GaimMessageFlags, const char *, time_t, const char *), | |
228 void(*finalize)(GaimLog *), | |
229 GList*(*list)(GaimLogType type, const char*, GaimAccount*), | |
230 char*(*read)(GaimLog*, GaimLogReadFlags*), | |
231 int(*size)(GaimLog*)); | |
7431 | 232 /** |
233 * Frees a logger | |
7440 | 234 * |
7431 | 235 * @param logger The logger to free |
236 */ | |
237 void gaim_log_logger_free(GaimLogLogger *logger); | |
7440 | 238 |
7431 | 239 /** |
240 * Adds a new logger | |
241 * | |
242 * @param logger The new logger to add | |
243 */ | |
244 void gaim_log_logger_add (GaimLogLogger *logger); | |
245 | |
246 /** | |
247 * | |
248 * Removes a logger | |
249 * | |
250 * @param logger The logger to remove | |
251 */ | |
252 void gaim_log_logger_remove (GaimLogLogger *logger); | |
253 | |
254 /** | |
255 * | |
256 * Sets the current logger | |
257 * | |
258 * @param logger The logger to set | |
259 */ | |
260 void gaim_log_logger_set (GaimLogLogger *logger); | |
7440 | 261 |
7431 | 262 /** |
7440 | 263 * |
7431 | 264 * Returns the current logger |
265 * | |
266 * @return logger The current logger | |
267 */ | |
268 GaimLogLogger *gaim_log_logger_get (void); | |
7440 | 269 |
7431 | 270 /** |
7440 | 271 * Returns a GList containing the IDs and Names of the registered log |
272 * loggers. | |
7431 | 273 * |
274 * @return The list of IDs and names. | |
275 */ | |
276 GList *gaim_log_logger_get_options(void); | |
277 | |
278 void gaim_log_init(void); | |
279 /*@}*/ | |
280 | |
5872 | 281 |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
282 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
283 } |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
284 #endif |
7440 | 285 |
7431 | 286 #endif /* _GAIM_LOG_H_ */ |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
287 |