Mercurial > pidgin
annotate src/log.h @ 8163:da57fb60680a
[gaim-migrate @ 8875]
IRC quoting for HTML entities by Daniel Atallah
committer: Tailor Script <tailor@pidgin.im>
author | Ethan Blanton <elb@pidgin.im> |
---|---|
date | Thu, 22 Jan 2004 02:44:13 +0000 |
parents | 81079e3eda47 |
children | 7dcd6f26e4a7 |
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 */ |
77 GList *(*list)(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 */ | |
89 int (*total_size)(const char *name, GaimAccount *account); | |
5872 | 90 }; |
91 | |
7431 | 92 /** |
93 * A log. Not the wooden type. | |
94 */ | |
95 struct _GaimLog { | |
96 GaimLogType type; /**< The type of log this is */ | |
97 char *name; /**< The name of this log */ | |
7440 | 98 GaimAccount *account; /**< The account this log is taking |
99 place on */ | |
100 time_t time; /**< The time this conversation | |
101 started */ | |
102 GaimLogLogger *logger; /**< The logging mechanism this log | |
103 is to use */ | |
7431 | 104 void *logger_data; /**< Data used by the log logger */ |
5872 | 105 }; |
106 | |
7431 | 107 |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
108 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
109 extern "C" { |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
110 #endif |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
111 |
7431 | 112 /*************************************** |
113 ** LOG FUNCTIONS ********************** | |
114 ***************************************/ | |
7440 | 115 |
7431 | 116 /** |
117 * Creates a new log | |
118 * | |
119 * @param type The type of log this is. | |
7440 | 120 * @param name The name of this conversation (Screenname, chat name, |
121 * etc.) | |
7431 | 122 * @param account The account the conversation is occuring on |
123 * @param time The time this conversation started | |
124 * @return The new log | |
7440 | 125 */ |
126 GaimLog *gaim_log_new(GaimLogType type, const char *name, | |
127 GaimAccount *account, time_t time); | |
7431 | 128 |
129 /** | |
130 * Frees a log | |
131 * | |
132 * @param log The log to destroy | |
7440 | 133 */ |
7431 | 134 void gaim_log_free(GaimLog *log); |
7440 | 135 |
7431 | 136 /** |
137 * Writes to a log file | |
138 * | |
139 * @param log The log to write to | |
140 * @param type The type of message being logged | |
7440 | 141 * @param from Whom this message is coming from, or NULL for |
142 * system messages | |
7431 | 143 * @param time A timestamp in UNIX time |
144 * @param message The message to log | |
145 */ | |
146 void gaim_log_write(GaimLog *log, | |
7440 | 147 GaimMessageFlags type, |
148 const char *from, | |
149 time_t time, | |
7431 | 150 const char *message); |
151 | |
152 /** | |
153 * Reads from a log | |
154 * | |
7456
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
155 * @param log The log to read from |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
156 * @param flags The returned logging flags. |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
157 * |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
158 * @return The contents of this log in Gaim Markup. |
7431 | 159 */ |
160 char *gaim_log_read(GaimLog *log, GaimLogReadFlags *flags); | |
161 | |
162 /** | |
163 * Returns a list of all available logs | |
164 * | |
165 * @param name The name of the log | |
166 * @param account The account | |
167 * @return A sorted list of GaimLogs | |
168 */ | |
169 GList *gaim_log_get_logs(const char *name, GaimAccount *account); | |
7440 | 170 |
7556 | 171 /** |
172 * Returns the size of a log | |
173 * | |
174 * @param log The log | |
175 * @return The size of the log, in bytes | |
176 */ | |
177 int gaim_log_get_size(GaimLog *log); | |
5872 | 178 |
7556 | 179 /** |
180 * Returns the size, in bytes, of all available logs in this conversation | |
181 * | |
182 * @param name The name of the log | |
183 * @param account The account | |
184 * @return The size in bytes | |
185 */ | |
7586 | 186 int gaim_log_get_total_size(const char *name, GaimAccount *account); |
7431 | 187 /****************************************** |
188 ** LOGGER FUNCTIONS ********************** | |
189 ******************************************/ | |
7440 | 190 |
7431 | 191 /** |
192 * Creates a new logger | |
193 * | |
7456
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
194 * @param create The logger's new function. |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
195 * @param write The logger's write function. |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
196 * @param finalize The logger's finalize function. |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
197 * @param list The logger's list function. |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
198 * @param read The logger's read function. |
7556 | 199 * @param size The logger's size function. |
7456
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
200 * |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
201 * @return The new logger |
7431 | 202 */ |
7440 | 203 GaimLogLogger *gaim_log_logger_new(void(*create)(GaimLog *), |
7431 | 204 void(*write)(GaimLog *, GaimMessageFlags, |
205 const char *, time_t, const char *), | |
7440 | 206 void(*finalize)(GaimLog *), |
207 GList*(*list)(const char*, GaimAccount*), | |
7556 | 208 char*(*read)(GaimLog*, GaimLogReadFlags*), |
209 int(*size)(GaimLog*)); | |
7431 | 210 /** |
211 * Frees a logger | |
7440 | 212 * |
7431 | 213 * @param logger The logger to free |
214 */ | |
215 void gaim_log_logger_free(GaimLogLogger *logger); | |
7440 | 216 |
7431 | 217 /** |
218 * Adds a new logger | |
219 * | |
220 * @param logger The new logger to add | |
221 */ | |
222 void gaim_log_logger_add (GaimLogLogger *logger); | |
223 | |
224 /** | |
225 * | |
226 * Removes a logger | |
227 * | |
228 * @param logger The logger to remove | |
229 */ | |
230 void gaim_log_logger_remove (GaimLogLogger *logger); | |
231 | |
232 /** | |
233 * | |
234 * Sets the current logger | |
235 * | |
236 * @param logger The logger to set | |
237 */ | |
238 void gaim_log_logger_set (GaimLogLogger *logger); | |
7440 | 239 |
7431 | 240 /** |
7440 | 241 * |
7431 | 242 * Returns the current logger |
243 * | |
244 * @return logger The current logger | |
245 */ | |
246 GaimLogLogger *gaim_log_logger_get (void); | |
7440 | 247 |
7431 | 248 /** |
7440 | 249 * Returns a GList containing the IDs and Names of the registered log |
250 * loggers. | |
7431 | 251 * |
252 * @return The list of IDs and names. | |
253 */ | |
254 GList *gaim_log_logger_get_options(void); | |
255 | |
256 void gaim_log_init(void); | |
257 /*@}*/ | |
258 | |
5872 | 259 |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
260 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
261 } |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
262 #endif |
7440 | 263 |
7431 | 264 #endif /* _GAIM_LOG_H_ */ |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
265 |