comparison src/log.h @ 11177:3924db2b1ca8

[gaim-migrate @ 13285] Performance optimizing the log set and screenname autocompletion code. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Mon, 01 Aug 2005 04:08:27 +0000
parents 11e465b55fe6
children ef9280fdc511
comparison
equal deleted inserted replaced
11176:6932df31225f 11177:3924db2b1ca8
47 GAIM_LOG_READ_NO_NEWLINE = 1 47 GAIM_LOG_READ_NO_NEWLINE = 1
48 } GaimLogReadFlags; 48 } GaimLogReadFlags;
49 49
50 #include "account.h" 50 #include "account.h"
51 #include "conversation.h" 51 #include "conversation.h"
52
53 typedef void (*GaimLogSetCallback) (GHashTable *sets, GaimLogSet *set);
52 54
53 /** 55 /**
54 * A log logger. 56 * A log logger.
55 * 57 *
56 * This struct gets filled out and is included in the GaimLog. It contains everything 58 * This struct gets filled out and is included in the GaimLog. It contains everything
90 int (*total_size)(GaimLogType type, const char *name, GaimAccount *account); 92 int (*total_size)(GaimLogType type, const char *name, GaimAccount *account);
91 93
92 /** This function returns a sorted GList of available system GaimLogs */ 94 /** This function returns a sorted GList of available system GaimLogs */
93 GList *(*list_syslog)(GaimAccount *account); 95 GList *(*list_syslog)(GaimAccount *account);
94 96
95 /** Returns a list of GaimLogSets. By passing the data in the GaimLogSets 97 /** Adds GaimLogSets to a GHashTable. By passing the data in the GaimLogSets
96 * to list, the caller can get every available GaimLog from the logger. 98 * to list, the caller can get every available GaimLog from the logger.
97 * Loggers using gaim_log_common_writer() (or otherwise storing their 99 * Loggers using gaim_log_common_writer() (or otherwise storing their
98 * logs in the same directory structure as the stock loggers) do not 100 * logs in the same directory structure as the stock loggers) do not
99 * need to implement this function. */ 101 * need to implement this function.
100 GList *(*get_log_sets)(void); 102 *
103 * Loggers which implement this function must create a GaimLogSet,
104 * then call @a cb with @a sets and the newly created GaimLogSet. */
105 void (*get_log_sets)(GaimLogSetCallback cb, GHashTable *sets);
101 }; 106 };
102 107
103 /** 108 /**
104 * A log. Not the wooden type. 109 * A log. Not the wooden type.
105 */ 110 */
141 logger's implementation of 146 logger's implementation of
142 list, it may not be possible 147 list, it may not be possible
143 to load such logs.) */ 148 to load such logs.) */
144 gboolean buddy; /**< Is this (account, name) a buddy 149 gboolean buddy; /**< Is this (account, name) a buddy
145 on the buddy list? */ 150 on the buddy list? */
151 char *normalized_name; /**< The normalized version of
152 @a name. It must be set, and
153 may be set to the same pointer
154 value as @a name. */
146 }; 155 };
147 156
148 #ifdef __cplusplus 157 #ifdef __cplusplus
149 extern "C" { 158 extern "C" {
150 #endif 159 #endif
209 * @return A sorted list of GaimLogs 218 * @return A sorted list of GaimLogs
210 */ 219 */
211 GList *gaim_log_get_logs(GaimLogType type, const char *name, GaimAccount *account); 220 GList *gaim_log_get_logs(GaimLogType type, const char *name, GaimAccount *account);
212 221
213 /** 222 /**
214 * Returns a list of GaimLogSets. 223 * Returns a GHashTable of GaimLogSets.
215 * 224 *
216 * A "log set" here means the information necessary to gather the 225 * A "log set" here means the information necessary to gather the
217 * GaimLogs for a given buddy/chat. This information would be passed 226 * GaimLogs for a given buddy/chat. This information would be passed
218 * to gaim_log_list to get a list of GaimLogs. 227 * to gaim_log_list to get a list of GaimLogs.
219 * 228 *
220 * The primary use of this function is to get a list of everyone the 229 * The primary use of this function is to get a list of everyone the
221 * user has ever talked to (assuming he or she uses logging). 230 * user has ever talked to (assuming he or she uses logging).
222 * 231 *
223 * @return A sorted list of all available unique GaimLogSets 232 * The GHashTable that's returned will free all log sets in it when
224 */ 233 * destroyed. If a GaimLogSet is removed from the GHashTable, it
225 GList *gaim_log_get_log_sets(void); 234 * must be freed with gaim_log_set_free().
235 *
236 * @return A GHashTable of all available unique GaimLogSets
237 */
238 GHashTable *gaim_log_get_log_sets(void);
226 239
227 /** 240 /**
228 * Returns a list of all available system logs 241 * Returns a list of all available system logs
229 * 242 *
230 * @param account The account 243 * @param account The account
231 * @return A sorted list of GaimLogs 244 * @return A sorted list of GaimLogs
232 */ 245 */
233 GList *gaim_log_get_system_logs(GaimAccount *account); 246 GList *gaim_log_get_system_logs(GaimAccount *account);
234 247
235 /** 248 /**
236 * Returns the size of a log 249 * Returns the size of a log
263 char *gaim_log_get_log_dir(GaimLogType type, const char *name, GaimAccount *account); 276 char *gaim_log_get_log_dir(GaimLogType type, const char *name, GaimAccount *account);
264 277
265 /** 278 /**
266 * Implements GCompareFunc for GaimLogs 279 * Implements GCompareFunc for GaimLogs
267 * 280 *
268 * @param y A GaimLog 281 * @param y A GaimLog
269 * @param z Another GaimLog 282 * @param z Another GaimLog
270 * @return A value as specified by GCompareFunc 283 * @return A value as specified by GCompareFunc
271 */ 284 */
272 gint gaim_log_compare(gconstpointer y, gconstpointer z); 285 gint gaim_log_compare(gconstpointer y, gconstpointer z);
273 286
274 /** 287 /**
275 * Implements GCompareFunc for GaimLogSets 288 * Implements GCompareFunc for GaimLogSets
277 * @param y A GaimLogSet 290 * @param y A GaimLogSet
278 * @param z Another GaimLogSet 291 * @param z Another GaimLogSet
279 * @return A value as specified by GCompareFunc 292 * @return A value as specified by GCompareFunc
280 */ 293 */
281 gint gaim_log_set_compare(gconstpointer y, gconstpointer z); 294 gint gaim_log_set_compare(gconstpointer y, gconstpointer z);
295
296 /**
297 * Frees a log set
298 *
299 * @param set The log set to destroy
300 */
301 void gaim_log_set_free(GaimLogSet *set);
282 302
283 /*@}*/ 303 /*@}*/
284 304
285 /******************************************/ 305 /******************************************/
286 /** @name Common Logger Functions */ 306 /** @name Common Logger Functions */
357 GList*(*list)(GaimLogType type, const char*, GaimAccount*), 377 GList*(*list)(GaimLogType type, const char*, GaimAccount*),
358 char*(*read)(GaimLog*, GaimLogReadFlags*), 378 char*(*read)(GaimLog*, GaimLogReadFlags*),
359 int(*size)(GaimLog*), 379 int(*size)(GaimLog*),
360 int(*total_size)(GaimLogType type, const char *name, GaimAccount *account), 380 int(*total_size)(GaimLogType type, const char *name, GaimAccount *account),
361 GList*(*list_syslog)(GaimAccount *account), 381 GList*(*list_syslog)(GaimAccount *account),
362 GList*(*get_log_sets)(void)); 382 void(*get_log_sets)(GaimLogSetCallback cb, GHashTable *sets));
363 383
364 /** 384 /**
365 * Frees a logger 385 * Frees a logger
366 * 386 *
367 * @param logger The logger to free 387 * @param logger The logger to free