Frameworks/libpurple.framework/Versions/0.6.2/Headers/log.h
author Zachary West <zacw@adium.im>
Fri Aug 21 13:25:11 2009 -0700 (2009-08-21)
changeset 2592 e8d15275025e
parent 1739 Frameworks/libpurple.framework/Versions/0.6.0/Headers/log.h@8b0daad9656c
permissions -rw-r--r--
im.pidgin.adium.1-4 at 267c6165e02e34318a1823960bd04c0639952f73
Evan@653
     1
/**
Evan@653
     2
 * @file log.h Logging API
Evan@653
     3
 * @ingroup core
Evan@653
     4
 * @see @ref log-signals
Evan@653
     5
 */
Evan@653
     6
Evan@653
     7
/* purple
Evan@653
     8
 *
Evan@653
     9
 * Purple is the legal property of its developers, whose names are too numerous
Evan@653
    10
 * to list here.  Please refer to the COPYRIGHT file distributed with this
Evan@653
    11
 * source distribution.
Evan@653
    12
 *
Evan@653
    13
 * This program is free software; you can redistribute it and/or modify
Evan@653
    14
 * it under the terms of the GNU General Public License as published by
Evan@653
    15
 * the Free Software Foundation; either version 2 of the License, or
Evan@653
    16
 * (at your option) any later version.
Evan@653
    17
 *
Evan@653
    18
 * This program is distributed in the hope that it will be useful,
Evan@653
    19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Evan@653
    20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Evan@653
    21
 * GNU General Public License for more details.
Evan@653
    22
 *
Evan@653
    23
 * You should have received a copy of the GNU General Public License
Evan@653
    24
 * along with this program; if not, write to the Free Software
Evan@653
    25
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
Evan@653
    26
 */
Evan@653
    27
#ifndef _PURPLE_LOG_H_
Evan@653
    28
#define _PURPLE_LOG_H_
Evan@653
    29
Evan@653
    30
#include <stdio.h>
Evan@653
    31
Evan@653
    32
Evan@653
    33
/********************************************************
Evan@653
    34
 * DATA STRUCTURES **************************************
Evan@653
    35
 ********************************************************/
Evan@653
    36
Evan@653
    37
typedef struct _PurpleLog PurpleLog;
Evan@653
    38
typedef struct _PurpleLogLogger PurpleLogLogger;
Evan@653
    39
typedef struct _PurpleLogCommonLoggerData PurpleLogCommonLoggerData;
Evan@653
    40
typedef struct _PurpleLogSet PurpleLogSet;
Evan@653
    41
Evan@653
    42
typedef enum {
Evan@653
    43
	PURPLE_LOG_IM,
Evan@653
    44
	PURPLE_LOG_CHAT,
Evan@653
    45
	PURPLE_LOG_SYSTEM
Evan@653
    46
} PurpleLogType;
Evan@653
    47
Evan@653
    48
typedef enum {
Evan@653
    49
	PURPLE_LOG_READ_NO_NEWLINE = 1
Evan@653
    50
} PurpleLogReadFlags;
Evan@653
    51
Evan@653
    52
#include "account.h"
Evan@653
    53
#include "conversation.h"
Evan@653
    54
Evan@653
    55
typedef void (*PurpleLogSetCallback) (GHashTable *sets, PurpleLogSet *set);
Evan@653
    56
Evan@653
    57
/**
Evan@653
    58
 * A log logger.
Evan@653
    59
 *
Evan@653
    60
 * This struct gets filled out and is included in the PurpleLog.  It contains everything
Evan@653
    61
 * needed to write and read from logs.
Evan@653
    62
 */
Evan@653
    63
struct _PurpleLogLogger {
Evan@653
    64
	char *name;               /**< The logger's name */
Evan@653
    65
	char *id;                 /**< an identifier to refer to this logger */
Evan@653
    66
Evan@653
    67
	/** This gets called when the log is first created.
Evan@653
    68
	    I don't think this is actually needed. */
Evan@653
    69
	void (*create)(PurpleLog *log);
Evan@653
    70
Evan@653
    71
	/** This is used to write to the log file */
Evan@653
    72
	gsize (*write)(PurpleLog *log,
Evan@653
    73
		     PurpleMessageFlags type,
Evan@653
    74
		     const char *from,
Evan@653
    75
		     time_t time,
Evan@653
    76
		     const char *message);
Evan@653
    77
Evan@653
    78
	/** Called when the log is destroyed */
Evan@653
    79
	void (*finalize)(PurpleLog *log);
Evan@653
    80
Evan@653
    81
	/** This function returns a sorted GList of available PurpleLogs */
Evan@653
    82
	GList *(*list)(PurpleLogType type, const char *name, PurpleAccount *account);
Evan@653
    83
Evan@653
    84
	/** Given one of the logs returned by the logger's list function,
Evan@653
    85
	 *  this returns the contents of the log in GtkIMHtml markup */
Evan@653
    86
	char *(*read)(PurpleLog *log, PurpleLogReadFlags *flags);
Evan@653
    87
Evan@653
    88
	/** Given one of the logs returned by the logger's list function,
Evan@653
    89
	 *  this returns the size of the log in bytes */
Evan@653
    90
	int (*size)(PurpleLog *log);
Evan@653
    91
Evan@653
    92
	/** Returns the total size of all the logs. If this is undefined a default
Evan@653
    93
	 *  implementation is used */
Evan@653
    94
	int (*total_size)(PurpleLogType type, const char *name, PurpleAccount *account);
Evan@653
    95
Evan@653
    96
	/** This function returns a sorted GList of available system PurpleLogs */
Evan@653
    97
	GList *(*list_syslog)(PurpleAccount *account);
Evan@653
    98
Evan@653
    99
	/** Adds PurpleLogSets to a GHashTable. By passing the data in the PurpleLogSets
Evan@653
   100
	 *  to list, the caller can get every available PurpleLog from the logger.
Evan@653
   101
	 *  Loggers using purple_log_common_writer() (or otherwise storing their
Evan@653
   102
	 *  logs in the same directory structure as the stock loggers) do not
Evan@653
   103
	 *  need to implement this function.
Evan@653
   104
	 *
Evan@653
   105
	 *  Loggers which implement this function must create a PurpleLogSet,
Evan@653
   106
	 *  then call @a cb with @a sets and the newly created PurpleLogSet. */
Evan@653
   107
	void (*get_log_sets)(PurpleLogSetCallback cb, GHashTable *sets);
Evan@653
   108
Evan@653
   109
	/* Attempts to delete the specified log, indicating success or failure */
Evan@653
   110
	gboolean (*remove)(PurpleLog *log);
Evan@653
   111
Evan@653
   112
	/* Tests whether a log is deletable */
Evan@653
   113
	gboolean (*is_deletable)(PurpleLog *log);
Evan@653
   114
Evan@653
   115
	void (*_purple_reserved1)(void);
Evan@653
   116
	void (*_purple_reserved2)(void);
Evan@653
   117
	void (*_purple_reserved3)(void);
Evan@653
   118
	void (*_purple_reserved4)(void);
Evan@653
   119
};
Evan@653
   120
Evan@653
   121
/**
Evan@653
   122
 * A log.  Not the wooden type.
Evan@653
   123
 */
Evan@653
   124
struct _PurpleLog {
Evan@653
   125
	PurpleLogType type;                     /**< The type of log this is */
Evan@653
   126
	char *name;                           /**< The name of this log */
Evan@653
   127
	PurpleAccount *account;                 /**< The account this log is taking
Evan@653
   128
	                                           place on */
Evan@653
   129
	PurpleConversation *conv;               /**< The conversation being logged */
Evan@653
   130
	time_t time;                          /**< The time this conversation
Evan@653
   131
	                                           started, converted to the local timezone */
Evan@653
   132
Evan@653
   133
	PurpleLogLogger *logger;                /**< The logging mechanism this log
Evan@653
   134
	                                           is to use */
Evan@653
   135
	void *logger_data;                    /**< Data used by the log logger */
Evan@653
   136
	struct tm *tm;                        /**< The time this conversation
Evan@653
   137
	                                           started, saved with original
Evan@653
   138
	                                           timezone data, if available and
Evan@653
   139
	                                           if struct tm has the BSD
Evan@653
   140
	                                           timezone fields, else @c NULL.
Evan@653
   141
	                                           Do NOT modify anything in this struct.*/
Evan@653
   142
Evan@653
   143
	/* IMPORTANT: Some code in log.c allocates these without zeroing them.
Evan@653
   144
	 * IMPORTANT: Update that code if you add members here. */
Evan@653
   145
};
Evan@653
   146
Evan@653
   147
/**
Evan@653
   148
 * A common logger_data struct containing a file handle and path, as well
Evan@653
   149
 * as a pointer to something else for additional data.
Evan@653
   150
 */
Evan@653
   151
struct _PurpleLogCommonLoggerData {
Evan@653
   152
	char *path;
Evan@653
   153
	FILE *file;
Evan@653
   154
	void *extra_data;
Evan@653
   155
};
Evan@653
   156
Evan@653
   157
/**
Evan@653
   158
 * Describes available logs.
Evan@653
   159
 *
Evan@653
   160
 * By passing the elements of this struct to purple_log_get_logs(), the caller
Evan@653
   161
 * can get all available PurpleLogs.
Evan@653
   162
 */
Evan@653
   163
struct _PurpleLogSet {
Evan@653
   164
	PurpleLogType type;                     /**< The type of logs available */
Evan@653
   165
	char *name;                           /**< The name of the logs available */
Evan@653
   166
	PurpleAccount *account;                 /**< The account the available logs
Evan@653
   167
	                                           took place on. This will be
Evan@653
   168
	                                           @c NULL if the account no longer
Evan@653
   169
	                                           exists. (Depending on a
Evan@653
   170
	                                           logger's implementation of
Evan@653
   171
	                                           list, it may not be possible
Evan@653
   172
	                                           to load such logs.) */
Evan@653
   173
	gboolean buddy;                       /**< Is this (account, name) a buddy
Evan@653
   174
	                                           on the buddy list? */
Evan@653
   175
	char *normalized_name;                /**< The normalized version of
Evan@653
   176
	                                           @a name. It must be set, and
Evan@653
   177
	                                           may be set to the same pointer
Evan@653
   178
	                                           value as @a name. */
Evan@653
   179
Evan@653
   180
	/* IMPORTANT: Some code in log.c allocates these without zeroing them.
Evan@653
   181
	 * IMPORTANT: Update that code if you add members here. */
Evan@653
   182
};
Evan@653
   183
Evan@653
   184
#ifdef __cplusplus
Evan@653
   185
extern "C" {
Evan@653
   186
#endif
Evan@653
   187
Evan@653
   188
/***************************************/
Evan@653
   189
/** @name Log Functions                */
Evan@653
   190
/***************************************/
Evan@653
   191
/*@{*/
Evan@653
   192
Evan@653
   193
/**
Evan@653
   194
 * Creates a new log
Evan@653
   195
 *
Evan@653
   196
 * @param type        The type of log this is.
Evan@1427
   197
 * @param name        The name of this conversation (buddy name, chat name,
Evan@653
   198
 *                    etc.)
Evan@653
   199
 * @param account     The account the conversation is occurring on
Evan@653
   200
 * @param conv        The conversation being logged
Evan@653
   201
 * @param time        The time this conversation started
Evan@653
   202
 * @param tm          The time this conversation started, with timezone data,
Evan@653
   203
 *                    if available and if struct tm has the BSD timezone fields.
Evan@653
   204
 * @return            The new log
Evan@653
   205
 */
Evan@653
   206
PurpleLog *purple_log_new(PurpleLogType type, const char *name, PurpleAccount *account,
Evan@653
   207
                      PurpleConversation *conv, time_t time, const struct tm *tm);
Evan@653
   208
Evan@653
   209
/**
Evan@653
   210
 * Frees a log
Evan@653
   211
 *
Evan@653
   212
 * @param log         The log to destroy
Evan@653
   213
 */
Evan@653
   214
void purple_log_free(PurpleLog *log);
Evan@653
   215
Evan@653
   216
/**
Evan@653
   217
 * Writes to a log file. Assumes you have checked preferences already.
Evan@653
   218
 *
Evan@653
   219
 * @param log          The log to write to
Evan@653
   220
 * @param type         The type of message being logged
Evan@653
   221
 * @param from         Whom this message is coming from, or @c NULL for
Evan@653
   222
 *                     system messages
Evan@653
   223
 * @param time         A timestamp in UNIX time
Evan@653
   224
 * @param message      The message to log
Evan@653
   225
 */
Evan@653
   226
void purple_log_write(PurpleLog *log,
Evan@653
   227
		    PurpleMessageFlags type,
Evan@653
   228
		    const char *from,
Evan@653
   229
		    time_t time,
Evan@653
   230
		    const char *message);
Evan@653
   231
Evan@653
   232
/**
Evan@653
   233
 * Reads from a log
Evan@653
   234
 *
Evan@653
   235
 * @param log   The log to read from
Evan@653
   236
 * @param flags The returned logging flags.
Evan@653
   237
 *
Evan@653
   238
 * @return The contents of this log in Purple Markup.
Evan@653
   239
 */
Evan@653
   240
char *purple_log_read(PurpleLog *log, PurpleLogReadFlags *flags);
Evan@653
   241
Evan@653
   242
/**
Evan@653
   243
 * Returns a list of all available logs
Evan@653
   244
 *
Evan@653
   245
 * @param type                The type of the log
Evan@653
   246
 * @param name                The name of the log
Evan@653
   247
 * @param account             The account
Evan@653
   248
 * @return                    A sorted list of PurpleLogs
Evan@653
   249
 */
Evan@653
   250
GList *purple_log_get_logs(PurpleLogType type, const char *name, PurpleAccount *account);
Evan@653
   251
Evan@653
   252
/**
Evan@653
   253
 * Returns a GHashTable of PurpleLogSets.
Evan@653
   254
 *
Evan@653
   255
 * A "log set" here means the information necessary to gather the
Evan@653
   256
 * PurpleLogs for a given buddy/chat. This information would be passed
Evan@653
   257
 * to purple_log_list to get a list of PurpleLogs.
Evan@653
   258
 *
Evan@653
   259
 * The primary use of this function is to get a list of everyone the
Evan@653
   260
 * user has ever talked to (assuming he or she uses logging).
Evan@653
   261
 *
Evan@653
   262
 * The GHashTable that's returned will free all log sets in it when
Evan@653
   263
 * destroyed. If a PurpleLogSet is removed from the GHashTable, it
Evan@653
   264
 * must be freed with purple_log_set_free().
Evan@653
   265
 *
Evan@653
   266
 * @return A GHashTable of all available unique PurpleLogSets
Evan@653
   267
 */
Evan@653
   268
GHashTable *purple_log_get_log_sets(void);
Evan@653
   269
Evan@653
   270
/**
Evan@653
   271
 * Returns a list of all available system logs
Evan@653
   272
 *
Evan@653
   273
 * @param account The account
Evan@653
   274
 * @return        A sorted list of PurpleLogs
Evan@653
   275
 */
Evan@653
   276
GList *purple_log_get_system_logs(PurpleAccount *account);
Evan@653
   277
Evan@653
   278
/**
Evan@653
   279
 * Returns the size of a log
Evan@653
   280
 *
Evan@653
   281
 * @param log                 The log
Evan@653
   282
 * @return                    The size of the log, in bytes
Evan@653
   283
 */
Evan@653
   284
int purple_log_get_size(PurpleLog *log);
Evan@653
   285
Evan@653
   286
/**
Evan@653
   287
 * Returns the size, in bytes, of all available logs in this conversation
Evan@653
   288
 *
Evan@653
   289
 * @param type                The type of the log
Evan@653
   290
 * @param name                The name of the log
Evan@653
   291
 * @param account             The account
Evan@653
   292
 * @return                    The size in bytes
Evan@653
   293
 */
Evan@653
   294
int purple_log_get_total_size(PurpleLogType type, const char *name, PurpleAccount *account);
Evan@653
   295
Evan@653
   296
/**
Evan@1427
   297
 * Returns the activity score of a log, based on total size in bytes,
Evan@1427
   298
 * which is then decayed based on age
Evan@1427
   299
 *
Evan@1427
   300
 * @param type                The type of the log
Evan@1427
   301
 * @param name                The name of the log
Evan@1427
   302
 * @param account             The account
Evan@1427
   303
 * @return                    The activity score
Evan@1427
   304
 *
Evan@1427
   305
 * @since 2.6.0
Evan@1427
   306
 */
Evan@1427
   307
int purple_log_get_activity_score(PurpleLogType type, const char *name, PurpleAccount *account);
Evan@1427
   308
Evan@1427
   309
/**
Evan@653
   310
 * Tests whether a log is deletable
Evan@653
   311
 *
Evan@653
   312
 * A return value of @c FALSE indicates that purple_log_delete() will fail on this
Evan@653
   313
 * log, unless something changes between the two calls.  A return value of @c TRUE,
Evan@653
   314
 * however, does not guarantee the log can be deleted.
Evan@653
   315
 *
Evan@653
   316
 * @param log                 The log
Evan@653
   317
 * @return                    A boolean indicating if the log is deletable
Evan@653
   318
 */
Evan@653
   319
gboolean purple_log_is_deletable(PurpleLog *log);
Evan@653
   320
Evan@653
   321
/**
Evan@653
   322
 * Deletes a log
Evan@653
   323
 *
Evan@653
   324
 * @param log                 The log
Evan@653
   325
 * @return                    A boolean indicating success or failure
Evan@653
   326
 */
Evan@653
   327
gboolean purple_log_delete(PurpleLog *log);
Evan@653
   328
Evan@653
   329
/**
Evan@653
   330
 * Returns the default logger directory Purple uses for a given account
Evan@653
   331
 * and username.  This would be where Purple stores logs created by
Evan@653
   332
 * the built-in text or HTML loggers.
Evan@653
   333
 *
Evan@653
   334
 * @param type                The type of the log.
Evan@653
   335
 * @param name                The name of the log.
Evan@653
   336
 * @param account             The account.
Evan@653
   337
 * @return                    The default logger directory for Purple.
Evan@653
   338
 */
Evan@653
   339
char *purple_log_get_log_dir(PurpleLogType type, const char *name, PurpleAccount *account);
Evan@653
   340
Evan@653
   341
/**
Evan@653
   342
 * Implements GCompareFunc for PurpleLogs
Evan@653
   343
 *
Evan@653
   344
 * @param y                   A PurpleLog
Evan@653
   345
 * @param z                   Another PurpleLog
Evan@653
   346
 * @return                    A value as specified by GCompareFunc
Evan@653
   347
 */
Evan@653
   348
gint purple_log_compare(gconstpointer y, gconstpointer z);
Evan@653
   349
Evan@653
   350
/**
Evan@653
   351
 * Implements GCompareFunc for PurpleLogSets
Evan@653
   352
 *
Evan@653
   353
 * @param y                   A PurpleLogSet
Evan@653
   354
 * @param z                   Another PurpleLogSet
Evan@653
   355
 * @return                    A value as specified by GCompareFunc
Evan@653
   356
 */
Evan@653
   357
gint purple_log_set_compare(gconstpointer y, gconstpointer z);
Evan@653
   358
Evan@653
   359
/**
Evan@653
   360
 * Frees a log set
Evan@653
   361
 *
Evan@653
   362
 * @param set         The log set to destroy
Evan@653
   363
 */
Evan@653
   364
void purple_log_set_free(PurpleLogSet *set);
Evan@653
   365
Evan@653
   366
/*@}*/
Evan@653
   367
Evan@653
   368
/******************************************/
Evan@653
   369
/** @name Common Logger Functions         */
Evan@653
   370
/******************************************/
Evan@653
   371
/*@{*/
Evan@653
   372
Evan@653
   373
/**
Evan@653
   374
 * Opens a new log file in the standard Purple log location
Evan@653
   375
 * with the given file extension, named for the current time,
Evan@653
   376
 * for writing.  If a log file is already open, the existing
Evan@653
   377
 * file handle is retained.  The log's logger_data value is
Evan@653
   378
 * set to a PurpleLogCommonLoggerData struct containing the log
Evan@653
   379
 * file handle and log path.
Evan@653
   380
 *
Evan@653
   381
 * This function is intended to be used as a "common"
Evan@653
   382
 * implementation of a logger's @c write function.
Evan@653
   383
 * It should only be passed to purple_log_logger_new() and never
Evan@653
   384
 * called directly.
Evan@653
   385
 *
Evan@653
   386
 * @param log   The log to write to.
Evan@653
   387
 * @param ext   The file extension to give to this log file.
Evan@653
   388
 */
Evan@653
   389
void purple_log_common_writer(PurpleLog *log, const char *ext);
Evan@653
   390
Evan@653
   391
/**
Evan@653
   392
 * Returns a sorted GList of PurpleLogs of the requested type.
Evan@653
   393
 *
Evan@653
   394
 * This function should only be used with logs that are written
Evan@653
   395
 * with purple_log_common_writer().  It's intended to be used as
Evan@653
   396
 * a "common" implementation of a logger's @c list function.
Evan@653
   397
 * It should only be passed to purple_log_logger_new() and never
Evan@653
   398
 * called directly.
Evan@653
   399
 *
Evan@653
   400
 * @param type     The type of the logs being listed.
Evan@653
   401
 * @param name     The name of the log.
Evan@653
   402
 * @param account  The account of the log.
Evan@653
   403
 * @param ext      The file extension this log format uses.
Evan@653
   404
 * @param logger   A reference to the logger struct for this log.
Evan@653
   405
 *
Evan@653
   406
 * @return A sorted GList of PurpleLogs matching the parameters.
Evan@653
   407
 */
Evan@653
   408
GList *purple_log_common_lister(PurpleLogType type, const char *name,
Evan@653
   409
							  PurpleAccount *account, const char *ext,
Evan@653
   410
							  PurpleLogLogger *logger);
Evan@653
   411
Evan@653
   412
/**
Evan@653
   413
 * Returns the total size of all the logs for a given user, with
Evan@653
   414
 * a given extension.
Evan@653
   415
 *
Evan@653
   416
 * This function should only be used with logs that are written
Evan@653
   417
 * with purple_log_common_writer().  It's intended to be used as
Evan@653
   418
 * a "common" implementation of a logger's @c total_size function.
Evan@653
   419
 * It should only be passed to purple_log_logger_new() and never
Evan@653
   420
 * called directly.
Evan@653
   421
 *
Evan@653
   422
 * @param type     The type of the logs being sized.
Evan@653
   423
 * @param name     The name of the logs to size
Evan@653
   424
 *                 (e.g. the username or chat name).
Evan@653
   425
 * @param account  The account of the log.
Evan@653
   426
 * @param ext      The file extension this log format uses.
Evan@653
   427
 *
Evan@653
   428
 * @return The size of all the logs with the specified extension
Evan@653
   429
 *         for the specified user.
Evan@653
   430
 */
Evan@653
   431
int purple_log_common_total_sizer(PurpleLogType type, const char *name,
Evan@653
   432
								PurpleAccount *account, const char *ext);
Evan@653
   433
Evan@653
   434
/**
Evan@653
   435
 * Returns the size of a given PurpleLog.
Evan@653
   436
 *
Evan@653
   437
 * This function should only be used with logs that are written
Evan@653
   438
 * with purple_log_common_writer().  It's intended to be used as
Evan@653
   439
 * a "common" implementation of a logger's @c size function.
Evan@653
   440
 * It should only be passed to purple_log_logger_new() and never
Evan@653
   441
 * called directly.
Evan@653
   442
 *
Evan@653
   443
 * @param log      The PurpleLog to size.
Evan@653
   444
 *
Evan@653
   445
 * @return An integer indicating the size of the log in bytes.
Evan@653
   446
 */
Evan@653
   447
int purple_log_common_sizer(PurpleLog *log);
Evan@653
   448
Evan@653
   449
/**
Evan@653
   450
 * Deletes a log
Evan@653
   451
 *
Evan@653
   452
 * This function should only be used with logs that are written
Evan@653
   453
 * with purple_log_common_writer().  It's intended to be used as
Evan@653
   454
 * a "common" implementation of a logger's @c delete function.
Evan@653
   455
 * It should only be passed to purple_log_logger_new() and never
Evan@653
   456
 * called directly.
Evan@653
   457
 *
Evan@653
   458
 * @param log      The PurpleLog to delete.
Evan@653
   459
 *
Evan@653
   460
 * @return A boolean indicating success or failure.
Evan@653
   461
 */
Evan@653
   462
gboolean purple_log_common_deleter(PurpleLog *log);
Evan@653
   463
Evan@653
   464
/**
Evan@653
   465
 * Checks to see if a log is deletable
Evan@653
   466
 *
Evan@653
   467
 * This function should only be used with logs that are written
Evan@653
   468
 * with purple_log_common_writer().  It's intended to be used as
Evan@653
   469
 * a "common" implementation of a logger's @c is_deletable function.
Evan@653
   470
 * It should only be passed to purple_log_logger_new() and never
Evan@653
   471
 * called directly.
Evan@653
   472
 *
Evan@653
   473
 * @param log      The PurpleLog to check.
Evan@653
   474
 *
Evan@653
   475
 * @return A boolean indicating if the log is deletable.
Evan@653
   476
 */
Evan@653
   477
gboolean purple_log_common_is_deletable(PurpleLog *log);
Evan@653
   478
Evan@653
   479
/*@}*/
Evan@653
   480
Evan@653
   481
/******************************************/
Evan@653
   482
/** @name Logger Functions                */
Evan@653
   483
/******************************************/
Evan@653
   484
/*@{*/
Evan@653
   485
Evan@653
   486
/**
Evan@653
   487
 * Creates a new logger
Evan@653
   488
 *
Evan@653
   489
 * @param id           The logger's id.
Evan@653
   490
 * @param name         The logger's name.
Evan@653
   491
 * @param functions    The number of functions being passed. The following
Evan@653
   492
 *                     functions are currently available (in order): @c create,
Evan@653
   493
 *                     @c write, @c finalize, @c list, @c read, @c size,
Evan@653
   494
 *                     @c total_size, @c list_syslog, @c get_log_sets,
Evan@653
   495
 *                     @c remove, @c is_deletable.
Evan@653
   496
 *                     For details on these functions, see PurpleLogLogger.
Evan@653
   497
 *                     Functions may not be skipped. For example, passing
Evan@653
   498
 *                     @c create and @c write is acceptable (for a total of
Evan@653
   499
 *                     two functions). Passing @c create and @c finalize,
Evan@653
   500
 *                     however, is not. To accomplish that, the caller must
Evan@653
   501
 *                     pass @c create, @c NULL (a placeholder for @c write),
Evan@653
   502
 *                     and @c finalize (for a total of 3 functions).
Evan@653
   503
 *
Evan@653
   504
 * @return The new logger
Evan@653
   505
 */
Evan@653
   506
PurpleLogLogger *purple_log_logger_new(const char *id, const char *name, int functions, ...);
Evan@653
   507
Evan@653
   508
/**
Evan@653
   509
 * Frees a logger
Evan@653
   510
 *
Evan@653
   511
 * @param logger       The logger to free
Evan@653
   512
 */
Evan@653
   513
void purple_log_logger_free(PurpleLogLogger *logger);
Evan@653
   514
Evan@653
   515
/**
Evan@653
   516
 * Adds a new logger
Evan@653
   517
 *
Evan@653
   518
 * @param logger       The new logger to add
Evan@653
   519
 */
Evan@653
   520
void purple_log_logger_add (PurpleLogLogger *logger);
Evan@653
   521
Evan@653
   522
/**
Evan@653
   523
 *
Evan@653
   524
 * Removes a logger
Evan@653
   525
 *
Evan@653
   526
 * @param logger       The logger to remove
Evan@653
   527
 */
Evan@653
   528
void purple_log_logger_remove (PurpleLogLogger *logger);
Evan@653
   529
Evan@653
   530
/**
Evan@653
   531
 *
Evan@653
   532
 * Sets the current logger
Evan@653
   533
 *
Evan@653
   534
 * @param logger       The logger to set
Evan@653
   535
 */
Evan@653
   536
void purple_log_logger_set (PurpleLogLogger *logger);
Evan@653
   537
Evan@653
   538
/**
Evan@653
   539
 *
Evan@653
   540
 * Returns the current logger
Evan@653
   541
 *
Evan@653
   542
 * @return logger      The current logger
Evan@653
   543
 */
Evan@653
   544
PurpleLogLogger *purple_log_logger_get (void);
Evan@653
   545
Evan@653
   546
/**
Evan@653
   547
 * Returns a GList containing the IDs and names of the registered
Evan@653
   548
 * loggers.
Evan@653
   549
 *
Evan@653
   550
 * @return The list of IDs and names.
Evan@653
   551
 */
Evan@653
   552
GList *purple_log_logger_get_options(void);
Evan@653
   553
Evan@653
   554
/**************************************************************************/
Evan@653
   555
/** @name Log Subsystem                                                   */
Evan@653
   556
/**************************************************************************/
Evan@653
   557
/*@{*/
Evan@653
   558
Evan@653
   559
/**
Evan@653
   560
 * Initializes the log subsystem.
Evan@653
   561
 */
Evan@653
   562
void purple_log_init(void);
Evan@653
   563
Evan@653
   564
/**
Evan@653
   565
 * Returns the log subsystem handle.
Evan@653
   566
 *
Evan@653
   567
 * @return The log subsystem handle.
Evan@653
   568
 */
Evan@653
   569
void *purple_log_get_handle(void);
Evan@653
   570
Evan@653
   571
/**
Evan@653
   572
 * Uninitializes the log subsystem.
Evan@653
   573
 */
Evan@653
   574
void purple_log_uninit(void);
Evan@653
   575
Evan@653
   576
/*@}*/
Evan@653
   577
Evan@653
   578
Evan@653
   579
#ifdef __cplusplus
Evan@653
   580
}
Evan@653
   581
#endif
Evan@653
   582
Evan@653
   583
#endif /* _PURPLE_LOG_H_ */