Sun, 12 Dec 2004 23:57:52 +0000
[gaim-migrate @ 11562]
Ability to read sub-statuses from ~/.gaim/status.xml. We don't actually
WRITE these to the file yet, so this doesn't do anything.
Also a few other minor changes elsewhere.
| 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; | |
| 37 | ||
| 38 | typedef enum { | |
| 39 | GAIM_LOG_IM, | |
| 40 | GAIM_LOG_CHAT, | |
|
10348
0ab5eb1a828e
[gaim-migrate @ 11562]
Mark Doliner <markdoliner@pidgin.im>
parents:
10231
diff
changeset
|
41 | GAIM_LOG_SYSTEM |
| 7431 | 42 | } GaimLogType; |
| 43 | ||
| 44 | typedef enum { | |
|
10348
0ab5eb1a828e
[gaim-migrate @ 11562]
Mark Doliner <markdoliner@pidgin.im>
parents:
10231
diff
changeset
|
45 | GAIM_LOG_READ_NO_NEWLINE = 1 |
| 7431 | 46 | } GaimLogReadFlags; |
| 47 | ||
| 48 | #include "account.h" | |
| 49 | #include "conversation.h" | |
| 50 | ||
| 51 | /** | |
| 52 | * A log logger. | |
| 53 | * | |
| 54 | * This struct gets filled out and is included in the GaimLog. It contains everything | |
| 55 | * needed to write and read from logs. | |
| 56 | */ | |
| 9000 | 57 | /*@{*/ |
| 7431 | 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
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8735
diff
changeset
|
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); |
|
10231
047177cee39f
[gaim-migrate @ 11366]
Andrew Hart <arhart@users.sourceforge.net>
parents:
10171
diff
changeset
|
82 | |
| 7556 | 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
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8735
diff
changeset
|
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
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
111 | #ifdef __cplusplus |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
112 | extern "C" { |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
113 | #endif |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
114 | |
|
10231
047177cee39f
[gaim-migrate @ 11366]
Andrew Hart <arhart@users.sourceforge.net>
parents:
10171
diff
changeset
|
115 | /***************************************/ |
|
047177cee39f
[gaim-migrate @ 11366]
Andrew Hart <arhart@users.sourceforge.net>
parents:
10171
diff
changeset
|
116 | /** @name Log Functions */ |
|
047177cee39f
[gaim-migrate @ 11366]
Andrew Hart <arhart@users.sourceforge.net>
parents:
10171
diff
changeset
|
117 | /***************************************/ |
|
047177cee39f
[gaim-migrate @ 11366]
Andrew Hart <arhart@users.sourceforge.net>
parents:
10171
diff
changeset
|
118 | /*@{*/ |
| 7440 | 119 | |
| 7431 | 120 | /** |
| 121 | * Creates a new log | |
| 122 | * | |
| 123 | * @param type The type of log this is. | |
| 7440 | 124 | * @param name The name of this conversation (Screenname, chat name, |
| 125 | * etc.) | |
|
8735
01248ea222d3
[gaim-migrate @ 9490]
Jonathan Champ <royanee@users.sourceforge.net>
parents:
8573
diff
changeset
|
126 | * @param account The account the conversation is occurring on |
| 7431 | 127 | * @param time The time this conversation started |
| 128 | * @return The new log | |
| 7440 | 129 | */ |
| 130 | GaimLog *gaim_log_new(GaimLogType type, const char *name, | |
| 131 | GaimAccount *account, time_t time); | |
| 7431 | 132 | |
| 133 | /** | |
| 134 | * Frees a log | |
| 135 | * | |
| 136 | * @param log The log to destroy | |
| 7440 | 137 | */ |
| 7431 | 138 | void gaim_log_free(GaimLog *log); |
| 7440 | 139 | |
| 7431 | 140 | /** |
| 10171 | 141 | * Writes to a log file. Assumes you have checked preferences already. |
| 7431 | 142 | * |
| 143 | * @param log The log to write to | |
| 144 | * @param type The type of message being logged | |
| 7440 | 145 | * @param from Whom this message is coming from, or NULL for |
| 146 | * system messages | |
| 7431 | 147 | * @param time A timestamp in UNIX time |
| 148 | * @param message The message to log | |
| 149 | */ | |
| 150 | void gaim_log_write(GaimLog *log, | |
| 7440 | 151 | GaimMessageFlags type, |
| 152 | const char *from, | |
| 153 | time_t time, | |
| 7431 | 154 | const char *message); |
| 155 | ||
| 156 | /** | |
| 157 | * Reads from a log | |
| 158 | * | |
|
7456
277c888b10e0
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
159 | * @param log The log to read from |
|
277c888b10e0
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
160 | * @param flags The returned logging flags. |
|
277c888b10e0
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
161 | * |
|
277c888b10e0
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
162 | * @return The contents of this log in Gaim Markup. |
| 7431 | 163 | */ |
| 164 | char *gaim_log_read(GaimLog *log, GaimLogReadFlags *flags); | |
| 165 | ||
| 166 | /** | |
| 167 | * Returns a list of all available logs | |
| 168 | * | |
|
8898
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8735
diff
changeset
|
169 | * @param type The type of the log |
| 7431 | 170 | * @param name The name of the log |
| 171 | * @param account The account | |
| 172 | * @return A sorted list of GaimLogs | |
| 173 | */ | |
|
8898
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8735
diff
changeset
|
174 | GList *gaim_log_get_logs(GaimLogType type, const char *name, GaimAccount *account); |
| 7440 | 175 | |
| 7556 | 176 | /** |
| 8573 | 177 | * Returns a list of all available system logs |
| 178 | * | |
| 179 | * @param account The account | |
| 180 | * @return A sorted list of GaimLogs | |
| 181 | */ | |
| 182 | GList *gaim_log_get_system_logs(GaimAccount *account); | |
| 183 | ||
| 184 | /** | |
| 7556 | 185 | * Returns the size of a log |
| 186 | * | |
| 187 | * @param log The log | |
| 188 | * @return The size of the log, in bytes | |
| 189 | */ | |
| 190 | int gaim_log_get_size(GaimLog *log); | |
| 5872 | 191 | |
| 7556 | 192 | /** |
| 193 | * Returns the size, in bytes, of all available logs in this conversation | |
| 194 | * | |
| 9000 | 195 | * @param type The type of the log |
| 7556 | 196 | * @param name The name of the log |
| 197 | * @param account The account | |
| 198 | * @return The size in bytes | |
| 199 | */ | |
|
8898
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8735
diff
changeset
|
200 | int gaim_log_get_total_size(GaimLogType type, const char *name, GaimAccount *account); |
| 8573 | 201 | |
| 202 | /** | |
| 203 | * Implements GCompareFunc | |
| 204 | * | |
| 205 | * @param y A GaimLog | |
| 206 | * @param z Another GaimLog | |
| 207 | * @return A value as specified by GCompareFunc | |
| 208 | */ | |
| 209 | gint gaim_log_compare(gconstpointer y, gconstpointer z); | |
|
10231
047177cee39f
[gaim-migrate @ 11366]
Andrew Hart <arhart@users.sourceforge.net>
parents:
10171
diff
changeset
|
210 | /*@}*/ |
| 8573 | 211 | |
|
10231
047177cee39f
[gaim-migrate @ 11366]
Andrew Hart <arhart@users.sourceforge.net>
parents:
10171
diff
changeset
|
212 | /******************************************/ |
|
047177cee39f
[gaim-migrate @ 11366]
Andrew Hart <arhart@users.sourceforge.net>
parents:
10171
diff
changeset
|
213 | /** @name Logger Functions */ |
|
047177cee39f
[gaim-migrate @ 11366]
Andrew Hart <arhart@users.sourceforge.net>
parents:
10171
diff
changeset
|
214 | /******************************************/ |
|
047177cee39f
[gaim-migrate @ 11366]
Andrew Hart <arhart@users.sourceforge.net>
parents:
10171
diff
changeset
|
215 | /*@{*/ |
| 7440 | 216 | |
| 7431 | 217 | /** |
| 218 | * Creates a new logger | |
| 219 | * | |
|
7456
277c888b10e0
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
220 | * @param create The logger's new function. |
|
277c888b10e0
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
221 | * @param write The logger's write function. |
|
277c888b10e0
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
222 | * @param finalize The logger's finalize function. |
|
277c888b10e0
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
223 | * @param list The logger's list function. |
|
277c888b10e0
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
224 | * @param read The logger's read function. |
| 7556 | 225 | * @param size The logger's size function. |
|
7456
277c888b10e0
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
226 | * |
|
277c888b10e0
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
227 | * @return The new logger |
| 7431 | 228 | */ |
|
8898
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8735
diff
changeset
|
229 | GaimLogLogger *gaim_log_logger_new( |
|
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8735
diff
changeset
|
230 | void(*create)(GaimLog *), |
|
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8735
diff
changeset
|
231 | void(*write)(GaimLog *, GaimMessageFlags, const char *, time_t, const char *), |
|
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8735
diff
changeset
|
232 | void(*finalize)(GaimLog *), |
|
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8735
diff
changeset
|
233 | GList*(*list)(GaimLogType type, const char*, GaimAccount*), |
|
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8735
diff
changeset
|
234 | char*(*read)(GaimLog*, GaimLogReadFlags*), |
|
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8735
diff
changeset
|
235 | int(*size)(GaimLog*)); |
| 7431 | 236 | /** |
| 237 | * Frees a logger | |
| 7440 | 238 | * |
| 7431 | 239 | * @param logger The logger to free |
| 240 | */ | |
| 241 | void gaim_log_logger_free(GaimLogLogger *logger); | |
| 7440 | 242 | |
| 7431 | 243 | /** |
| 244 | * Adds a new logger | |
| 245 | * | |
| 246 | * @param logger The new logger to add | |
| 247 | */ | |
| 248 | void gaim_log_logger_add (GaimLogLogger *logger); | |
| 249 | ||
| 250 | /** | |
| 251 | * | |
| 252 | * Removes a logger | |
| 253 | * | |
| 254 | * @param logger The logger to remove | |
| 255 | */ | |
| 256 | void gaim_log_logger_remove (GaimLogLogger *logger); | |
| 257 | ||
| 258 | /** | |
| 259 | * | |
| 260 | * Sets the current logger | |
| 261 | * | |
| 262 | * @param logger The logger to set | |
| 263 | */ | |
| 264 | void gaim_log_logger_set (GaimLogLogger *logger); | |
| 7440 | 265 | |
| 7431 | 266 | /** |
| 7440 | 267 | * |
| 7431 | 268 | * Returns the current logger |
| 269 | * | |
| 270 | * @return logger The current logger | |
| 271 | */ | |
| 272 | GaimLogLogger *gaim_log_logger_get (void); | |
| 7440 | 273 | |
| 7431 | 274 | /** |
| 7440 | 275 | * Returns a GList containing the IDs and Names of the registered log |
| 276 | * loggers. | |
| 7431 | 277 | * |
| 278 | * @return The list of IDs and names. | |
| 279 | */ | |
| 280 | GList *gaim_log_logger_get_options(void); | |
| 281 | ||
| 282 | void gaim_log_init(void); | |
|
10231
047177cee39f
[gaim-migrate @ 11366]
Andrew Hart <arhart@users.sourceforge.net>
parents:
10171
diff
changeset
|
283 | /*@}*/ |
| 7431 | 284 | |
| 5872 | 285 | |
|
5944
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
286 | #ifdef __cplusplus |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
287 | } |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
288 | #endif |
| 7440 | 289 | |
| 7431 | 290 | #endif /* _GAIM_LOG_H_ */ |