Mercurial > pidgin
annotate src/log.h @ 7780:7ab3d01d2c50
[gaim-migrate @ 8425]
This should obey the logging preferences.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Sat, 06 Dec 2003 21:58:46 +0000 |
parents | c50926062b30 |
children | fa6395637e2c |
rev | line source |
---|---|
5872 | 1 /** |
2 * @file log.h Logging API | |
3 * @ingroup core | |
4 * | |
5 * gaim | |
6 * | |
7431 | 7 * Copyright (C) 2003 Douglas E. Egan |
7440 | 8 * |
5872 | 9 * This program is free software; you can redistribute it and/or modify |
10 * it under the terms of the GNU General Public License as published by | |
11 * the Free Software Foundation; either version 2 of the License, or | |
12 * (at your option) any later version. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program; if not, write to the Free Software | |
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
22 */ | |
7431 | 23 |
5872 | 24 #ifndef _GAIM_LOG_H_ |
25 #define _GAIM_LOG_H_ | |
26 | |
7431 | 27 #include <stdio.h> |
5872 | 28 |
29 | |
7431 | 30 /******************************************************** |
31 * DATA STRUCTURES ************************************** | |
32 ********************************************************/ | |
33 | |
34 typedef struct _GaimLog GaimLog; | |
35 typedef struct _GaimLogLogger GaimLogLogger; | |
36 | |
37 typedef enum { | |
38 GAIM_LOG_IM, | |
39 GAIM_LOG_CHAT, | |
40 GAIM_LOG_SYSTEM, | |
41 } GaimLogType; | |
42 | |
43 typedef enum { | |
44 GAIM_LOG_READ_NO_NEWLINE = 1, | |
45 } GaimLogReadFlags; | |
46 | |
47 #include "account.h" | |
48 #include "conversation.h" | |
49 | |
50 /** | |
51 * A log logger. | |
52 * | |
53 * This struct gets filled out and is included in the GaimLog. It contains everything | |
54 * needed to write and read from logs. | |
55 */ | |
56 struct _GaimLogLogger { | |
57 char *name; /**< The logger's name */ | |
58 char *id; /**< an identifier to refer to this logger */ | |
7440 | 59 |
60 /** This gets called when the log is first created. | |
7431 | 61 I don't think this is actually needed. */ |
7440 | 62 void(*create)(GaimLog *log); |
63 | |
7431 | 64 /** This is used to write to the log file */ |
7440 | 65 void(*write)(GaimLog *log, |
66 GaimMessageFlags type, | |
7431 | 67 const char *from, |
68 time_t time, | |
69 const char *message); | |
70 | |
71 /** Called when the log is destroyed */ | |
72 void (*finalize)(GaimLog *log); | |
7440 | 73 |
7431 | 74 /** This function returns a sorted GList of available GaimLogs */ |
75 GList *(*list)(const char *name, GaimAccount *account); | |
7440 | 76 |
77 /** Given one of the logs returned by the logger's list function, | |
78 * this returns the contents of the log in GtkIMHtml markup */ | |
7431 | 79 char *(*read)(GaimLog *log, GaimLogReadFlags *flags); |
7556 | 80 |
81 /** Given one of the logs returned by the logger's list function, | |
82 * this returns the size of the log in bytes */ | |
83 int (*size)(GaimLog *log); | |
5872 | 84 }; |
85 | |
7431 | 86 /** |
87 * A log. Not the wooden type. | |
88 */ | |
89 struct _GaimLog { | |
90 GaimLogType type; /**< The type of log this is */ | |
91 char *name; /**< The name of this log */ | |
7440 | 92 GaimAccount *account; /**< The account this log is taking |
93 place on */ | |
94 time_t time; /**< The time this conversation | |
95 started */ | |
96 GaimLogLogger *logger; /**< The logging mechanism this log | |
97 is to use */ | |
7431 | 98 void *logger_data; /**< Data used by the log logger */ |
5872 | 99 }; |
100 | |
7431 | 101 |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
102 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
103 extern "C" { |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
104 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
105 |
7431 | 106 /*************************************** |
107 ** LOG FUNCTIONS ********************** | |
108 ***************************************/ | |
7440 | 109 |
7431 | 110 /** |
111 * Creates a new log | |
112 * | |
113 * @param type The type of log this is. | |
7440 | 114 * @param name The name of this conversation (Screenname, chat name, |
115 * etc.) | |
7431 | 116 * @param account The account the conversation is occuring on |
117 * @param time The time this conversation started | |
118 * @return The new log | |
7440 | 119 */ |
120 GaimLog *gaim_log_new(GaimLogType type, const char *name, | |
121 GaimAccount *account, time_t time); | |
7431 | 122 |
123 /** | |
124 * Frees a log | |
125 * | |
126 * @param log The log to destroy | |
7440 | 127 */ |
7431 | 128 void gaim_log_free(GaimLog *log); |
7440 | 129 |
7431 | 130 /** |
131 * Writes to a log file | |
132 * | |
133 * @param log The log to write to | |
134 * @param type The type of message being logged | |
7440 | 135 * @param from Whom this message is coming from, or NULL for |
136 * system messages | |
7431 | 137 * @param time A timestamp in UNIX time |
138 * @param message The message to log | |
139 */ | |
140 void gaim_log_write(GaimLog *log, | |
7440 | 141 GaimMessageFlags type, |
142 const char *from, | |
143 time_t time, | |
7431 | 144 const char *message); |
145 | |
146 /** | |
147 * Reads from a log | |
148 * | |
7456
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
149 * @param log The log to read from |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
150 * @param flags The returned logging flags. |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
151 * |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
152 * @return The contents of this log in Gaim Markup. |
7431 | 153 */ |
154 char *gaim_log_read(GaimLog *log, GaimLogReadFlags *flags); | |
155 | |
156 /** | |
157 * Returns a list of all available logs | |
158 * | |
159 * @param name The name of the log | |
160 * @param account The account | |
161 * @return A sorted list of GaimLogs | |
162 */ | |
163 GList *gaim_log_get_logs(const char *name, GaimAccount *account); | |
7440 | 164 |
7556 | 165 /** |
166 * Returns the size of a log | |
167 * | |
168 * @param log The log | |
169 * @return The size of the log, in bytes | |
170 */ | |
171 int gaim_log_get_size(GaimLog *log); | |
5872 | 172 |
7556 | 173 /** |
174 * Returns the size, in bytes, of all available logs in this conversation | |
175 * | |
176 * @param name The name of the log | |
177 * @param account The account | |
178 * @return The size in bytes | |
179 */ | |
7586 | 180 int gaim_log_get_total_size(const char *name, GaimAccount *account); |
7431 | 181 /****************************************** |
182 ** LOGGER FUNCTIONS ********************** | |
183 ******************************************/ | |
7440 | 184 |
7431 | 185 /** |
186 * Creates a new logger | |
187 * | |
7456
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
188 * @param create The logger's new function. |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
189 * @param write The logger's write function. |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
190 * @param finalize The logger's finalize function. |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
191 * @param list The logger's list function. |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
192 * @param read The logger's read function. |
7556 | 193 * @param size The logger's size function. |
7456
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
194 * |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
195 * @return The new logger |
7431 | 196 */ |
7440 | 197 GaimLogLogger *gaim_log_logger_new(void(*create)(GaimLog *), |
7431 | 198 void(*write)(GaimLog *, GaimMessageFlags, |
199 const char *, time_t, const char *), | |
7440 | 200 void(*finalize)(GaimLog *), |
201 GList*(*list)(const char*, GaimAccount*), | |
7556 | 202 char*(*read)(GaimLog*, GaimLogReadFlags*), |
203 int(*size)(GaimLog*)); | |
7431 | 204 /** |
205 * Frees a logger | |
7440 | 206 * |
7431 | 207 * @param logger The logger to free |
208 */ | |
209 void gaim_log_logger_free(GaimLogLogger *logger); | |
7440 | 210 |
7431 | 211 /** |
212 * Adds a new logger | |
213 * | |
214 * @param logger The new logger to add | |
215 */ | |
216 void gaim_log_logger_add (GaimLogLogger *logger); | |
217 | |
218 /** | |
219 * | |
220 * Removes a logger | |
221 * | |
222 * @param logger The logger to remove | |
223 */ | |
224 void gaim_log_logger_remove (GaimLogLogger *logger); | |
225 | |
226 /** | |
227 * | |
228 * Sets the current logger | |
229 * | |
230 * @param logger The logger to set | |
231 */ | |
232 void gaim_log_logger_set (GaimLogLogger *logger); | |
7440 | 233 |
7431 | 234 /** |
7440 | 235 * |
7431 | 236 * Returns the current logger |
237 * | |
238 * @return logger The current logger | |
239 */ | |
240 GaimLogLogger *gaim_log_logger_get (void); | |
7440 | 241 |
7431 | 242 /** |
7440 | 243 * Returns a GList containing the IDs and Names of the registered log |
244 * loggers. | |
7431 | 245 * |
246 * @return The list of IDs and names. | |
247 */ | |
248 GList *gaim_log_logger_get_options(void); | |
249 | |
250 void gaim_log_init(void); | |
251 /*@}*/ | |
252 | |
5872 | 253 |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
254 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
255 } |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
256 #endif |
7440 | 257 |
7431 | 258 #endif /* _GAIM_LOG_H_ */ |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
259 |