Mercurial > pidgin
annotate src/log.h @ 8573:7dcd6f26e4a7
[gaim-migrate @ 9321]
" This patch reimplements the system log. It writes
system log to
~/.gaim/logs/<protocol>/<username>/.system/<timestamp>.(txt|html),
where <timestamp> is the time that the account
<username> with <protocol> signs on. Nathan (faceprint)
and LSchiere suggested this logging scheme. No code is
currently written to read the old system logs.
Note that if you change the logging format, you need to
re-login the accounts for the change to take effect."
--Ka-Hing (javabsp) Cheung
who continues:
"Now this one applies, also contains a rider patch that, if
you enable sound for "Someone says your name in chat", it
will not play a sound if the message is a system message,
like if jabber chat tells you that "*** becomes available"
and *** is you, it won't play a sound."
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Sat, 03 Apr 2004 18:34:29 +0000 |
parents | 81079e3eda47 |
children | 92cbf9713795 |
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); | |
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.) | |
7431 | 125 * @param account The account the conversation is occuring on |
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 * | |
168 * @param name The name of the log | |
169 * @param account The account | |
170 * @return A sorted list of GaimLogs | |
171 */ | |
172 GList *gaim_log_get_logs(const char *name, GaimAccount *account); | |
7440 | 173 |
7556 | 174 /** |
8573 | 175 * Returns a list of all available system logs |
176 * | |
177 * @param account The account | |
178 * @return A sorted list of GaimLogs | |
179 */ | |
180 GList *gaim_log_get_system_logs(GaimAccount *account); | |
181 | |
182 /** | |
7556 | 183 * Returns the size of a log |
184 * | |
185 * @param log The log | |
186 * @return The size of the log, in bytes | |
187 */ | |
188 int gaim_log_get_size(GaimLog *log); | |
5872 | 189 |
7556 | 190 /** |
191 * Returns the size, in bytes, of all available logs in this conversation | |
192 * | |
193 * @param name The name of the log | |
194 * @param account The account | |
195 * @return The size in bytes | |
196 */ | |
7586 | 197 int gaim_log_get_total_size(const char *name, GaimAccount *account); |
8573 | 198 |
199 /** | |
200 * Implements GCompareFunc | |
201 * | |
202 * @param y A GaimLog | |
203 * @param z Another GaimLog | |
204 * @return A value as specified by GCompareFunc | |
205 */ | |
206 gint gaim_log_compare(gconstpointer y, gconstpointer z); | |
207 | |
7431 | 208 /****************************************** |
209 ** LOGGER FUNCTIONS ********************** | |
210 ******************************************/ | |
7440 | 211 |
7431 | 212 /** |
213 * Creates a new logger | |
214 * | |
7456
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
215 * @param create The logger's new function. |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
216 * @param write The logger's write function. |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
217 * @param finalize The logger's finalize function. |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
218 * @param list The logger's list function. |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
219 * @param read The logger's read function. |
7556 | 220 * @param size The logger's size function. |
7456
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
221 * |
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
222 * @return The new logger |
7431 | 223 */ |
7440 | 224 GaimLogLogger *gaim_log_logger_new(void(*create)(GaimLog *), |
7431 | 225 void(*write)(GaimLog *, GaimMessageFlags, |
226 const char *, time_t, const char *), | |
7440 | 227 void(*finalize)(GaimLog *), |
228 GList*(*list)(const char*, GaimAccount*), | |
7556 | 229 char*(*read)(GaimLog*, GaimLogReadFlags*), |
230 int(*size)(GaimLog*)); | |
7431 | 231 /** |
232 * Frees a logger | |
7440 | 233 * |
7431 | 234 * @param logger The logger to free |
235 */ | |
236 void gaim_log_logger_free(GaimLogLogger *logger); | |
7440 | 237 |
7431 | 238 /** |
239 * Adds a new logger | |
240 * | |
241 * @param logger The new logger to add | |
242 */ | |
243 void gaim_log_logger_add (GaimLogLogger *logger); | |
244 | |
245 /** | |
246 * | |
247 * Removes a logger | |
248 * | |
249 * @param logger The logger to remove | |
250 */ | |
251 void gaim_log_logger_remove (GaimLogLogger *logger); | |
252 | |
253 /** | |
254 * | |
255 * Sets the current logger | |
256 * | |
257 * @param logger The logger to set | |
258 */ | |
259 void gaim_log_logger_set (GaimLogLogger *logger); | |
7440 | 260 |
7431 | 261 /** |
7440 | 262 * |
7431 | 263 * Returns the current logger |
264 * | |
265 * @return logger The current logger | |
266 */ | |
267 GaimLogLogger *gaim_log_logger_get (void); | |
7440 | 268 |
7431 | 269 /** |
7440 | 270 * Returns a GList containing the IDs and Names of the registered log |
271 * loggers. | |
7431 | 272 * |
273 * @return The list of IDs and names. | |
274 */ | |
275 GList *gaim_log_logger_get_options(void); | |
276 | |
277 void gaim_log_init(void); | |
278 /*@}*/ | |
279 | |
5872 | 280 |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
281 #ifdef __cplusplus |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
282 } |
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
283 #endif |
7440 | 284 |
7431 | 285 #endif /* _GAIM_LOG_H_ */ |
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
286 |