comparison libpurple/log.h @ 15528:f61ad08739fc

This is the core code to support log deletion. It's untested.
author Richard Laager <rlaager@wiktel.com>
date Sat, 03 Feb 2007 21:43:29 +0000
parents 5fe8042783c1
children 32c366eeeb99
comparison
equal deleted inserted replaced
15521:aa0c1aa85fd3 15528:f61ad08739fc
78 78
79 /** This function returns a sorted GList of available GaimLogs */ 79 /** This function returns a sorted GList of available GaimLogs */
80 GList *(*list)(GaimLogType type, const char *name, GaimAccount *account); 80 GList *(*list)(GaimLogType type, const char *name, GaimAccount *account);
81 81
82 /** Given one of the logs returned by the logger's list function, 82 /** Given one of the logs returned by the logger's list function,
83 * this returns the contents of the log in GtkIMHtml markup */ 83 * this returns the contents of the log in GtkIMHtml markup */
84 char *(*read)(GaimLog *log, GaimLogReadFlags *flags); 84 char *(*read)(GaimLog *log, GaimLogReadFlags *flags);
85 85
86 /** Given one of the logs returned by the logger's list function, 86 /** Given one of the logs returned by the logger's list function,
87 * this returns the size of the log in bytes */ 87 * this returns the size of the log in bytes */
88 int (*size)(GaimLog *log); 88 int (*size)(GaimLog *log);
89 89
90 /** Returns the total size of all the logs. If this is undefined a default 90 /** Returns the total size of all the logs. If this is undefined a default
91 * implementation is used */ 91 * implementation is used */
92 int (*total_size)(GaimLogType type, const char *name, GaimAccount *account); 92 int (*total_size)(GaimLogType type, const char *name, GaimAccount *account);
93 93
94 /** This function returns a sorted GList of available system GaimLogs */ 94 /** This function returns a sorted GList of available system GaimLogs */
95 GList *(*list_syslog)(GaimAccount *account); 95 GList *(*list_syslog)(GaimAccount *account);
96 96
101 * need to implement this function. 101 * need to implement this function.
102 * 102 *
103 * Loggers which implement this function must create a GaimLogSet, 103 * Loggers which implement this function must create a GaimLogSet,
104 * then call @a cb with @a sets and the newly created GaimLogSet. */ 104 * then call @a cb with @a sets and the newly created GaimLogSet. */
105 void (*get_log_sets)(GaimLogSetCallback cb, GHashTable *sets); 105 void (*get_log_sets)(GaimLogSetCallback cb, GHashTable *sets);
106
107 /* Attempts to delete the specified log, indicating success or failure */
108 gboolean (*delete)(GaimLog *log);
109
110 /* Tests whether a log is deletable */
111 gboolean (*is_deletable)(GaimLog *log);
106 }; 112 };
107 113
108 /** 114 /**
109 * A log. Not the wooden type. 115 * A log. Not the wooden type.
110 */ 116 */
279 * @return The size in bytes 285 * @return The size in bytes
280 */ 286 */
281 int gaim_log_get_total_size(GaimLogType type, const char *name, GaimAccount *account); 287 int gaim_log_get_total_size(GaimLogType type, const char *name, GaimAccount *account);
282 288
283 /** 289 /**
290 * Tests whether a log is deletable
291 *
292 * A return value of @c FALSE indicates that gaim_log_delete() will fail on this
293 * log, unless something changes between the two calls. A return value of @c TRUE,
294 * however, does not guarantee the log can be deleted.
295 *
296 * @param log The log
297 * @return A boolean indicating if the log is deletable
298 */
299 gboolean gaim_log_is_deletable(GaimLog *log);
300
301 /**
302 * Deletes a log
303 *
304 * @param log The log
305 * @return A boolean indicating success or failure
306 */
307 gboolean gaim_log_delete(GaimLog *log);
308
309 /**
284 * Returns the default logger directory Gaim uses for a given account 310 * Returns the default logger directory Gaim uses for a given account
285 * and username. This would be where Gaim stores logs created by 311 * and username. This would be where Gaim stores logs created by
286 * the built-in text or HTML loggers. 312 * the built-in text or HTML loggers.
287 * 313 *
288 * @param type The type of the log. 314 * @param type The type of the log.
330 * for writing. If a log file is already open, the existing 356 * for writing. If a log file is already open, the existing
331 * file handle is retained. The log's logger_data value is 357 * file handle is retained. The log's logger_data value is
332 * set to a GaimLogCommonLoggerData struct containing the log 358 * set to a GaimLogCommonLoggerData struct containing the log
333 * file handle and log path. 359 * file handle and log path.
334 * 360 *
361 * This function is intended to be used as a "common"
362 * implementation of a logger's @c write function.
363 * It should only be passed to gaim_log_logger_new() and never
364 * called directly.
365 *
335 * @param log The log to write to. 366 * @param log The log to write to.
336 * @param ext The file extension to give to this log file. 367 * @param ext The file extension to give to this log file.
337 */ 368 */
338 void gaim_log_common_writer(GaimLog *log, const char *ext); 369 void gaim_log_common_writer(GaimLog *log, const char *ext);
339 370
340 /** 371 /**
341 * Returns a sorted GList of GaimLogs of the requested type. 372 * Returns a sorted GList of GaimLogs of the requested type.
373 *
342 * This function should only be used with logs that are written 374 * This function should only be used with logs that are written
343 * with gaim_log_common_writer(). 375 * with gaim_log_common_writer(). It's intended to be used as
376 * a "common" implementation of a logger's @c list function.
377 * It should only be passed to gaim_log_logger_new() and never
378 * called directly.
344 * 379 *
345 * @param type The type of the logs being listed. 380 * @param type The type of the logs being listed.
346 * @param name The name of the log. 381 * @param name The name of the log.
347 * @param account The account of the log. 382 * @param account The account of the log.
348 * @param ext The file extension this log format uses. 383 * @param ext The file extension this log format uses.
354 GaimAccount *account, const char *ext, 389 GaimAccount *account, const char *ext,
355 GaimLogLogger *logger); 390 GaimLogLogger *logger);
356 391
357 /** 392 /**
358 * Returns the total size of all the logs for a given user, with 393 * Returns the total size of all the logs for a given user, with
359 * a given extension. This is the "common" implemention of a 394 * a given extension.
360 * logger's total_size function. 395 *
361 * This function should only be used with logs that are written 396 * This function should only be used with logs that are written
362 * with gaim_log_common_writer(). 397 * with gaim_log_common_writer(). It's intended to be used as
398 * a "common" implementation of a logger's @c total_size function.
399 * It should only be passed to gaim_log_logger_new() and never
400 * called directly.
363 * 401 *
364 * @param type The type of the logs being sized. 402 * @param type The type of the logs being sized.
365 * @param name The name of the logs to size 403 * @param name The name of the logs to size
366 * (e.g. the username or chat name). 404 * (e.g. the username or chat name).
367 * @param account The account of the log. 405 * @param account The account of the log.
373 int gaim_log_common_total_sizer(GaimLogType type, const char *name, 411 int gaim_log_common_total_sizer(GaimLogType type, const char *name,
374 GaimAccount *account, const char *ext); 412 GaimAccount *account, const char *ext);
375 413
376 /** 414 /**
377 * Returns the size of a given GaimLog. 415 * Returns the size of a given GaimLog.
416 *
378 * This function should only be used with logs that are written 417 * This function should only be used with logs that are written
379 * with gaim_log_common_writer(). 418 * with gaim_log_common_writer(). It's intended to be used as
419 * a "common" implementation of a logger's @c size function.
420 * It should only be passed to gaim_log_logger_new() and never
421 * called directly.
380 * 422 *
381 * @param log The GaimLog to size. 423 * @param log The GaimLog to size.
382 * 424 *
383 * @return An integer indicating the size of the log in bytes. 425 * @return An integer indicating the size of the log in bytes.
384 */ 426 */
385 int gaim_log_common_sizer(GaimLog *log); 427 int gaim_log_common_sizer(GaimLog *log);
428
429 /**
430 * Deletes a log
431 *
432 * This function should only be used with logs that are written
433 * with gaim_log_common_writer(). It's intended to be used as
434 * a "common" implementation of a logger's @c delete function.
435 * It should only be passed to gaim_log_logger_new() and never
436 * called directly.
437 *
438 * @param log The GaimLog to delete.
439 *
440 * @return A boolean indicating success or failure.
441 */
442 gboolean gaim_log_common_deleter(GaimLog *log);
443
444 /**
445 * Checks to see if a log is deletable
446 *
447 * This function should only be used with logs that are written
448 * with gaim_log_common_writer(). It's intended to be used as
449 * a "common" implementation of a logger's @c is_deletable function.
450 * It should only be passed to gaim_log_logger_new() and never
451 * called directly.
452 *
453 * @param log The GaimLog to check.
454 *
455 * @return A boolean indicating if the log is deletable.
456 */
457 gboolean gaim_log_common_is_deletable(GaimLog *log);
458
386 /*@}*/ 459 /*@}*/
387 460
388 /******************************************/ 461 /******************************************/
389 /** @name Logger Functions */ 462 /** @name Logger Functions */
390 /******************************************/ 463 /******************************************/
396 * @param id The logger's id. 469 * @param id The logger's id.
397 * @param name The logger's name. 470 * @param name The logger's name.
398 * @param functions The number of functions being passed. The following 471 * @param functions The number of functions being passed. The following
399 * functions are currently available (in order): @c create, 472 * functions are currently available (in order): @c create,
400 * @c write, @c finalize, @c list, @c read, @c size, 473 * @c write, @c finalize, @c list, @c read, @c size,
401 * @c total_size, @c list_syslog, @c get_log_sets. For 474 * @c total_size, @c list_syslog, @c get_log_sets,
402 * details on these functions, see GaimLogLogger. 475 * @c delete, @c is_deletable.
476 * For details on these functions, see GaimLogLogger.
403 * Functions may not be skipped. For example, passing 477 * Functions may not be skipped. For example, passing
404 * @c create and @c write is acceptable (for a total of 478 * @c create and @c write is acceptable (for a total of
405 * two functions). Passing @c create and @c finalize, 479 * two functions). Passing @c create and @c finalize,
406 * however, is not. To accomplish that, the caller must 480 * however, is not. To accomplish that, the caller must
407 * pass @c create, @c NULL (a placeholder for @c write), 481 * pass @c create, @c NULL (a placeholder for @c write),