Mon, 12 Dec 2005 07:35:43 +0000
[gaim-migrate @ 14773]
SF Patch #1377719 from Evan Schoenberg
"A recent reorganization of how the chat_add_users() conversation UI op is
sent removed passing to the UI of whether the additions are new arrivals
or not. This information lets the UI make decisions about how to handle
the new people, what if anything to display, etc."
committer: Richard Laager <rlaager@pidgin.im>
| 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; | |
| 10822 | 37 | typedef struct _GaimLogCommonLoggerData GaimLogCommonLoggerData; |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
38 | typedef struct _GaimLogSet GaimLogSet; |
| 7431 | 39 | |
| 40 | typedef enum { | |
| 41 | GAIM_LOG_IM, | |
| 42 | GAIM_LOG_CHAT, | |
|
10348
0ab5eb1a828e
[gaim-migrate @ 11562]
Mark Doliner <markdoliner@pidgin.im>
parents:
10231
diff
changeset
|
43 | GAIM_LOG_SYSTEM |
| 7431 | 44 | } GaimLogType; |
| 45 | ||
| 46 | typedef enum { | |
|
10348
0ab5eb1a828e
[gaim-migrate @ 11562]
Mark Doliner <markdoliner@pidgin.im>
parents:
10231
diff
changeset
|
47 | GAIM_LOG_READ_NO_NEWLINE = 1 |
| 7431 | 48 | } GaimLogReadFlags; |
| 49 | ||
| 50 | #include "account.h" | |
| 51 | #include "conversation.h" | |
| 52 | ||
|
11177
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
53 | typedef void (*GaimLogSetCallback) (GHashTable *sets, GaimLogSet *set); |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
54 | |
| 7431 | 55 | /** |
| 56 | * A log logger. | |
| 57 | * | |
| 58 | * This struct gets filled out and is included in the GaimLog. It contains everything | |
| 59 | * needed to write and read from logs. | |
| 60 | */ | |
| 61 | struct _GaimLogLogger { | |
| 62 | char *name; /**< The logger's name */ | |
| 63 | char *id; /**< an identifier to refer to this logger */ | |
| 7440 | 64 | |
| 65 | /** This gets called when the log is first created. | |
| 7431 | 66 | I don't think this is actually needed. */ |
|
10812
25c595cbffe8
[gaim-migrate @ 12465]
Richard Laager <rlaager@pidgin.im>
parents:
10566
diff
changeset
|
67 | void (*create)(GaimLog *log); |
| 7440 | 68 | |
| 7431 | 69 | /** This is used to write to the log file */ |
|
10812
25c595cbffe8
[gaim-migrate @ 12465]
Richard Laager <rlaager@pidgin.im>
parents:
10566
diff
changeset
|
70 | void (*write)(GaimLog *log, |
| 7440 | 71 | GaimMessageFlags type, |
| 7431 | 72 | const char *from, |
| 73 | time_t time, | |
| 74 | const char *message); | |
| 75 | ||
| 76 | /** Called when the log is destroyed */ | |
| 77 | void (*finalize)(GaimLog *log); | |
| 7440 | 78 | |
| 7431 | 79 | /** This function returns a sorted GList of available GaimLogs */ |
|
8898
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8735
diff
changeset
|
80 | GList *(*list)(GaimLogType type, const char *name, GaimAccount *account); |
| 7440 | 81 | |
| 82 | /** Given one of the logs returned by the logger's list function, | |
| 83 | * this returns the contents of the log in GtkIMHtml markup */ | |
| 7431 | 84 | char *(*read)(GaimLog *log, GaimLogReadFlags *flags); |
|
10231
047177cee39f
[gaim-migrate @ 11366]
Andrew Hart <arhart@users.sourceforge.net>
parents:
10171
diff
changeset
|
85 | |
| 7556 | 86 | /** Given one of the logs returned by the logger's list function, |
| 87 | * this returns the size of the log in bytes */ | |
| 88 | int (*size)(GaimLog *log); | |
| 8096 | 89 | |
| 90 | /** Returns the total size of all the logs. If this is undefined a default | |
| 91 | * implementation is used */ | |
|
8898
85f5615bc27e
[gaim-migrate @ 9667]
Mark Doliner <markdoliner@pidgin.im>
parents:
8735
diff
changeset
|
92 | int (*total_size)(GaimLogType type, const char *name, GaimAccount *account); |
| 8573 | 93 | |
| 94 | /** This function returns a sorted GList of available system GaimLogs */ | |
| 95 | GList *(*list_syslog)(GaimAccount *account); | |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
96 | |
|
11177
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
97 | /** Adds GaimLogSets to a GHashTable. By passing the data in the GaimLogSets |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
98 | * to list, the caller can get every available GaimLog from the logger. |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
99 | * Loggers using gaim_log_common_writer() (or otherwise storing their |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
100 | * logs in the same directory structure as the stock loggers) do not |
|
11177
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
101 | * need to implement this function. |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
102 | * |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
103 | * Loggers which implement this function must create a GaimLogSet, |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
104 | * then call @a cb with @a sets and the newly created GaimLogSet. */ |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
105 | void (*get_log_sets)(GaimLogSetCallback cb, GHashTable *sets); |
| 5872 | 106 | }; |
| 107 | ||
| 7431 | 108 | /** |
| 109 | * A log. Not the wooden type. | |
| 110 | */ | |
| 111 | struct _GaimLog { | |
| 112 | GaimLogType type; /**< The type of log this is */ | |
| 113 | char *name; /**< The name of this log */ | |
| 7440 | 114 | GaimAccount *account; /**< The account this log is taking |
| 115 | place on */ | |
|
11292
13068c68def6
[gaim-migrate @ 13492]
Richard Laager <rlaager@pidgin.im>
parents:
11177
diff
changeset
|
116 | GaimConversation *conv; /**< The conversation being logged */ |
| 7440 | 117 | time_t time; /**< The time this conversation |
| 118 | started */ | |
| 119 | GaimLogLogger *logger; /**< The logging mechanism this log | |
| 120 | is to use */ | |
| 7431 | 121 | void *logger_data; /**< Data used by the log logger */ |
| 5872 | 122 | }; |
| 123 | ||
| 10822 | 124 | /** |
| 125 | * A common logger_data struct containing a file handle and path, as well | |
| 126 | * as a pointer to something else for additional data. | |
| 127 | */ | |
| 128 | struct _GaimLogCommonLoggerData { | |
| 129 | char *path; | |
| 130 | FILE *file; | |
| 131 | void *extra_data; | |
| 132 | }; | |
| 7431 | 133 | |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
134 | /** |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
135 | * Describes available logs. |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
136 | * |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
137 | * By passing the elements of this struct to gaim_log_get_logs(), the caller |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
138 | * can get all available GaimLogs. |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
139 | */ |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
140 | struct _GaimLogSet { |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
141 | GaimLogType type; /**< The type of logs available */ |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
142 | char *name; /**< The name of the logs available */ |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
143 | GaimAccount *account; /**< The account the available logs |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
144 | took place on. This will be |
|
11503
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
145 | @c NULL if the account no longer |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
146 | exists. (Depending on a |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
147 | logger's implementation of |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
148 | list, it may not be possible |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
149 | to load such logs.) */ |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
150 | gboolean buddy; /**< Is this (account, name) a buddy |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
151 | on the buddy list? */ |
|
11177
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
152 | char *normalized_name; /**< The normalized version of |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
153 | @a name. It must be set, and |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
154 | may be set to the same pointer |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
155 | value as @a name. */ |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
156 | }; |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
157 | |
|
5944
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
158 | #ifdef __cplusplus |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
159 | extern "C" { |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
160 | #endif |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
161 | |
| 10566 | 162 | /***************************************/ |
| 163 | /** @name Log Functions */ | |
| 164 | /***************************************/ | |
| 165 | /*@{*/ | |
| 7440 | 166 | |
| 10566 | 167 | /** |
| 168 | * Creates a new log | |
| 169 | * | |
| 170 | * @param type The type of log this is. | |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
171 | * @param name The name of this conversation (screenname, chat name, |
| 10566 | 172 | * etc.) |
| 173 | * @param account The account the conversation is occurring on | |
|
11292
13068c68def6
[gaim-migrate @ 13492]
Richard Laager <rlaager@pidgin.im>
parents:
11177
diff
changeset
|
174 | * @param conv The conversation being logged |
| 10566 | 175 | * @param time The time this conversation started |
| 176 | * @return The new log | |
| 177 | */ | |
|
11292
13068c68def6
[gaim-migrate @ 13492]
Richard Laager <rlaager@pidgin.im>
parents:
11177
diff
changeset
|
178 | GaimLog *gaim_log_new(GaimLogType type, const char *name, GaimAccount *account, |
|
13068c68def6
[gaim-migrate @ 13492]
Richard Laager <rlaager@pidgin.im>
parents:
11177
diff
changeset
|
179 | GaimConversation *conv, time_t time); |
| 7431 | 180 | |
| 10566 | 181 | /** |
| 182 | * Frees a log | |
| 183 | * | |
| 184 | * @param log The log to destroy | |
| 185 | */ | |
| 186 | void gaim_log_free(GaimLog *log); | |
| 7440 | 187 | |
| 10566 | 188 | /** |
| 189 | * Writes to a log file. Assumes you have checked preferences already. | |
| 190 | * | |
| 191 | * @param log The log to write to | |
| 192 | * @param type The type of message being logged | |
|
11503
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
193 | * @param from Whom this message is coming from, or @c NULL for |
| 10566 | 194 | * system messages |
| 195 | * @param time A timestamp in UNIX time | |
| 196 | * @param message The message to log | |
| 197 | */ | |
| 198 | void gaim_log_write(GaimLog *log, | |
| 199 | GaimMessageFlags type, | |
| 200 | const char *from, | |
| 201 | time_t time, | |
| 202 | const char *message); | |
| 7431 | 203 | |
| 10566 | 204 | /** |
| 205 | * Reads from a log | |
| 206 | * | |
| 207 | * @param log The log to read from | |
| 208 | * @param flags The returned logging flags. | |
| 209 | * | |
| 210 | * @return The contents of this log in Gaim Markup. | |
| 211 | */ | |
| 212 | char *gaim_log_read(GaimLog *log, GaimLogReadFlags *flags); | |
| 7431 | 213 | |
| 10566 | 214 | /** |
| 215 | * Returns a list of all available logs | |
| 216 | * | |
| 217 | * @param type The type of the log | |
| 218 | * @param name The name of the log | |
| 219 | * @param account The account | |
| 220 | * @return A sorted list of GaimLogs | |
| 221 | */ | |
| 222 | GList *gaim_log_get_logs(GaimLogType type, const char *name, GaimAccount *account); | |
| 7440 | 223 | |
| 10566 | 224 | /** |
|
11177
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
225 | * Returns a GHashTable of GaimLogSets. |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
226 | * |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
227 | * A "log set" here means the information necessary to gather the |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
228 | * GaimLogs for a given buddy/chat. This information would be passed |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
229 | * to gaim_log_list to get a list of GaimLogs. |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
230 | * |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
231 | * The primary use of this function is to get a list of everyone the |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
232 | * user has ever talked to (assuming he or she uses logging). |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
233 | * |
|
11177
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
234 | * The GHashTable that's returned will free all log sets in it when |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
235 | * destroyed. If a GaimLogSet is removed from the GHashTable, it |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
236 | * must be freed with gaim_log_set_free(). |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
237 | * |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
238 | * @return A GHashTable of all available unique GaimLogSets |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
239 | */ |
|
11177
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
240 | GHashTable *gaim_log_get_log_sets(void); |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
241 | |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
242 | /** |
| 10566 | 243 | * Returns a list of all available system logs |
| 244 | * | |
| 245 | * @param account The account | |
|
11177
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
246 | * @return A sorted list of GaimLogs |
| 10566 | 247 | */ |
| 248 | GList *gaim_log_get_system_logs(GaimAccount *account); | |
| 8573 | 249 | |
| 10566 | 250 | /** |
| 10822 | 251 | * Returns the size of a log |
| 10566 | 252 | * |
| 253 | * @param log The log | |
| 254 | * @return The size of the log, in bytes | |
| 255 | */ | |
| 256 | int gaim_log_get_size(GaimLog *log); | |
| 5872 | 257 | |
| 10566 | 258 | /** |
| 259 | * Returns the size, in bytes, of all available logs in this conversation | |
| 260 | * | |
| 261 | * @param type The type of the log | |
| 262 | * @param name The name of the log | |
| 263 | * @param account The account | |
| 264 | * @return The size in bytes | |
| 265 | */ | |
| 266 | int gaim_log_get_total_size(GaimLogType type, const char *name, GaimAccount *account); | |
| 8573 | 267 | |
| 10566 | 268 | /** |
| 10822 | 269 | * Returns the default logger directory Gaim uses for a given account |
| 270 | * and username. This would be where Gaim stores logs created by | |
| 271 | * the built-in text or HTML loggers. | |
| 272 | * | |
| 273 | * @param type The type of the log. | |
| 274 | * @param name The name of the log. | |
| 275 | * @param account The account. | |
| 276 | * @return The default logger directory for Gaim. | |
| 277 | */ | |
| 278 | char *gaim_log_get_log_dir(GaimLogType type, const char *name, GaimAccount *account); | |
| 279 | ||
| 280 | /** | |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
281 | * Implements GCompareFunc for GaimLogs |
| 10566 | 282 | * |
|
11177
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
283 | * @param y A GaimLog |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
284 | * @param z Another GaimLog |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
285 | * @return A value as specified by GCompareFunc |
| 10566 | 286 | */ |
| 287 | gint gaim_log_compare(gconstpointer y, gconstpointer z); | |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
288 | |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
289 | /** |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
290 | * Implements GCompareFunc for GaimLogSets |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
291 | * |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
292 | * @param y A GaimLogSet |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
293 | * @param z Another GaimLogSet |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
294 | * @return A value as specified by GCompareFunc |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
295 | */ |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
296 | gint gaim_log_set_compare(gconstpointer y, gconstpointer z); |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
297 | |
|
11177
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
298 | /** |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
299 | * Frees a log set |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
300 | * |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
301 | * @param set The log set to destroy |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
302 | */ |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
303 | void gaim_log_set_free(GaimLogSet *set); |
|
534ca3ae0bfc
[gaim-migrate @ 13285]
Richard Laager <rlaager@pidgin.im>
parents:
11035
diff
changeset
|
304 | |
| 10566 | 305 | /*@}*/ |
| 8573 | 306 | |
| 10566 | 307 | /******************************************/ |
| 10822 | 308 | /** @name Common Logger Functions */ |
| 309 | /******************************************/ | |
| 310 | /*@{*/ | |
| 311 | ||
| 312 | /** | |
| 313 | * Opens a new log file in the standard Gaim log location | |
| 314 | * with the given file extension, named for the current time, | |
| 315 | * for writing. If a log file is already open, the existing | |
| 316 | * file handle is retained. The log's logger_data value is | |
| 317 | * set to a GaimLogCommonLoggerData struct containing the log | |
| 318 | * file handle and log path. | |
| 319 | * | |
| 320 | * @param log The log to write to. | |
| 321 | * @param ext The file extension to give to this log file. | |
| 322 | */ | |
|
11292
13068c68def6
[gaim-migrate @ 13492]
Richard Laager <rlaager@pidgin.im>
parents:
11177
diff
changeset
|
323 | void gaim_log_common_writer(GaimLog *log, const char *ext); |
| 10822 | 324 | |
| 325 | /** | |
| 326 | * Returns a sorted GList of GaimLogs of the requested type. | |
| 327 | * This function should only be used with logs that are written | |
| 328 | * with gaim_log_common_writer(). | |
| 329 | * | |
| 330 | * @param type The type of the logs being listed. | |
| 331 | * @param name The name of the log. | |
| 332 | * @param account The account of the log. | |
| 333 | * @param ext The file extension this log format uses. | |
| 334 | * @param logger A reference to the logger struct for this log. | |
| 335 | * | |
| 336 | * @return A sorted GList of GaimLogs matching the parameters. | |
| 337 | */ | |
| 338 | GList *gaim_log_common_lister(GaimLogType type, const char *name, | |
| 339 | GaimAccount *account, const char *ext, | |
| 340 | GaimLogLogger *logger); | |
| 341 | ||
| 342 | /** | |
| 343 | * Returns the size of a given GaimLog. | |
| 344 | * This function should only be used with logs that are written | |
| 345 | * with gaim_log_common_writer(). | |
| 346 | * | |
| 347 | * @param log The GaimLog to size. | |
| 348 | * | |
| 349 | * @return An integer indicating the size of the log in bytes. | |
| 350 | */ | |
| 351 | int gaim_log_common_sizer(GaimLog *log); | |
| 352 | /*@}*/ | |
| 353 | ||
| 354 | /******************************************/ | |
| 10566 | 355 | /** @name Logger Functions */ |
| 356 | /******************************************/ | |
| 357 | /*@{*/ | |
| 7440 | 358 | |
| 10566 | 359 | /** |
| 360 | * Creates a new logger | |
| 361 | * | |
|
11503
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
362 | * @param id The logger's id. |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
363 | * @param name The logger's name. |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
364 | * @param functions The number of functions being passed. The following |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
365 | * functions are currently available (in order): @c create, |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
366 | * @c write, @c finalize, @c list, @c read, @c size, |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
367 | * @c total_size, @c list_syslog, @c get_log_sets. For |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
368 | * details on these functions, see GaimLogLogger. |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
369 | * Functions may not be skipped. For example, passing |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
370 | * @c create and @c write is acceptable (for a total of |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
371 | * two functions). Passing @c create and @c finalize, |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
372 | * however, is not. To accomplish that, the caller must |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
373 | * pass @c create, @c NULL (a placeholder for @c write), |
|
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
374 | * and @c finalize (for a total of 3 functions). |
| 10566 | 375 | * |
| 376 | * @return The new logger | |
| 377 | */ | |
|
11503
9f15d4c089b9
[gaim-migrate @ 13748]
Richard Laager <rlaager@pidgin.im>
parents:
11292
diff
changeset
|
378 | GaimLogLogger *gaim_log_logger_new(const char *id, const char *name, int functions, ...); |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
379 | |
| 10566 | 380 | /** |
| 381 | * Frees a logger | |
| 382 | * | |
| 383 | * @param logger The logger to free | |
| 384 | */ | |
| 385 | void gaim_log_logger_free(GaimLogLogger *logger); | |
| 7440 | 386 | |
| 10566 | 387 | /** |
| 388 | * Adds a new logger | |
| 389 | * | |
| 390 | * @param logger The new logger to add | |
| 391 | */ | |
| 392 | void gaim_log_logger_add (GaimLogLogger *logger); | |
| 7431 | 393 | |
| 10566 | 394 | /** |
| 395 | * | |
| 396 | * Removes a logger | |
| 397 | * | |
| 398 | * @param logger The logger to remove | |
| 399 | */ | |
| 400 | void gaim_log_logger_remove (GaimLogLogger *logger); | |
| 7431 | 401 | |
| 10566 | 402 | /** |
| 403 | * | |
| 404 | * Sets the current logger | |
| 405 | * | |
| 406 | * @param logger The logger to set | |
| 407 | */ | |
| 408 | void gaim_log_logger_set (GaimLogLogger *logger); | |
| 7440 | 409 | |
| 10566 | 410 | /** |
| 411 | * | |
| 412 | * Returns the current logger | |
| 413 | * | |
| 414 | * @return logger The current logger | |
| 415 | */ | |
| 416 | GaimLogLogger *gaim_log_logger_get (void); | |
| 7440 | 417 | |
| 10566 | 418 | /** |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
419 | * Returns a GList containing the IDs and names of the registered |
| 10566 | 420 | * loggers. |
| 421 | * | |
| 422 | * @return The list of IDs and names. | |
| 423 | */ | |
| 424 | GList *gaim_log_logger_get_options(void); | |
| 7431 | 425 | |
|
11025
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
426 | /** |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
427 | * Initializes the log subsystem. |
|
41b6449f7dff
[gaim-migrate @ 12899]
Richard Laager <rlaager@pidgin.im>
parents:
10822
diff
changeset
|
428 | */ |
| 10566 | 429 | void gaim_log_init(void); |
| 430 | /*@}*/ | |
| 7431 | 431 | |
| 5872 | 432 | |
|
5944
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
433 | #ifdef __cplusplus |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
434 | } |
|
f19df037ac58
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
435 | #endif |
| 7440 | 436 | |
| 7431 | 437 | #endif /* _GAIM_LOG_H_ */ |