log.h

Go to the documentation of this file.
00001 
00006 /* purple
00007  *
00008  * Purple is the legal property of its developers, whose names are too numerous
00009  * to list here.  Please refer to the COPYRIGHT file distributed with this
00010  * source distribution.
00011  *
00012  * This program is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU General Public License as published by
00014  * the Free Software Foundation; either version 2 of the License, or
00015  * (at your option) any later version.
00016  *
00017  * This program is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU General Public License
00023  * along with this program; if not, write to the Free Software
00024  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
00025  *
00026  * @see @ref log-signals
00027  */
00028 #ifndef _PURPLE_LOG_H_
00029 #define _PURPLE_LOG_H_
00030 
00031 #include <stdio.h>
00032 
00033 
00034 /********************************************************
00035  * DATA STRUCTURES **************************************
00036  ********************************************************/
00037 
00038 typedef struct _PurpleLog PurpleLog;
00039 typedef struct _PurpleLogLogger PurpleLogLogger;
00040 typedef struct _PurpleLogCommonLoggerData PurpleLogCommonLoggerData;
00041 typedef struct _PurpleLogSet PurpleLogSet;
00042 
00043 typedef enum {
00044     PURPLE_LOG_IM,
00045     PURPLE_LOG_CHAT,
00046     PURPLE_LOG_SYSTEM
00047 } PurpleLogType;
00048 
00049 typedef enum {
00050     PURPLE_LOG_READ_NO_NEWLINE = 1
00051 } PurpleLogReadFlags;
00052 
00053 #include "account.h"
00054 #include "conversation.h"
00055 
00056 typedef void (*PurpleLogSetCallback) (GHashTable *sets, PurpleLogSet *set);
00057 
00064 struct _PurpleLogLogger {
00065     char *name;               
00066     char *id;                 
00070     void (*create)(PurpleLog *log);
00071 
00073     gsize (*write)(PurpleLog *log,
00074              PurpleMessageFlags type,
00075              const char *from,
00076              time_t time,
00077              const char *message);
00078 
00080     void (*finalize)(PurpleLog *log);
00081 
00083     GList *(*list)(PurpleLogType type, const char *name, PurpleAccount *account);
00084 
00087     char *(*read)(PurpleLog *log, PurpleLogReadFlags *flags);
00088 
00091     int (*size)(PurpleLog *log);
00092 
00095     int (*total_size)(PurpleLogType type, const char *name, PurpleAccount *account);
00096 
00098     GList *(*list_syslog)(PurpleAccount *account);
00099 
00108     void (*get_log_sets)(PurpleLogSetCallback cb, GHashTable *sets);
00109 
00110     /* Attempts to delete the specified log, indicating success or failure */
00111     gboolean (*remove)(PurpleLog *log);
00112 
00113     /* Tests whether a log is deletable */
00114     gboolean (*is_deletable)(PurpleLog *log);
00115 
00116     void (*_purple_reserved1)(void);
00117     void (*_purple_reserved2)(void);
00118     void (*_purple_reserved3)(void);
00119     void (*_purple_reserved4)(void);
00120 };
00121 
00125 struct _PurpleLog {
00126     PurpleLogType type;                     
00127     char *name;                           
00128     PurpleAccount *account;                 
00130     PurpleConversation *conv;               
00131     time_t time;                          
00134     PurpleLogLogger *logger;                
00136     void *logger_data;                    
00137     struct tm *tm;                        
00144     /* IMPORTANT: Some code in log.c allocates these without zeroing them.
00145      * IMPORTANT: Update that code if you add members here. */
00146 };
00147 
00152 struct _PurpleLogCommonLoggerData {
00153     char *path;
00154     FILE *file;
00155     void *extra_data;
00156 };
00157 
00164 struct _PurpleLogSet {
00165     PurpleLogType type;                     
00166     char *name;                           
00167     PurpleAccount *account;                 
00174     gboolean buddy;                       
00176     char *normalized_name;                
00181     /* IMPORTANT: Some code in log.c allocates these without zeroing them.
00182      * IMPORTANT: Update that code if you add members here. */
00183 };
00184 
00185 #ifdef __cplusplus
00186 extern "C" {
00187 #endif
00188 
00189 /***************************************/
00191 /***************************************/
00207 PurpleLog *purple_log_new(PurpleLogType type, const char *name, PurpleAccount *account,
00208                       PurpleConversation *conv, time_t time, const struct tm *tm);
00209 
00215 void purple_log_free(PurpleLog *log);
00216 
00227 void purple_log_write(PurpleLog *log,
00228             PurpleMessageFlags type,
00229             const char *from,
00230             time_t time,
00231             const char *message);
00232 
00241 char *purple_log_read(PurpleLog *log, PurpleLogReadFlags *flags);
00242 
00251 GList *purple_log_get_logs(PurpleLogType type, const char *name, PurpleAccount *account);
00252 
00269 GHashTable *purple_log_get_log_sets(void);
00270 
00277 GList *purple_log_get_system_logs(PurpleAccount *account);
00278 
00285 int purple_log_get_size(PurpleLog *log);
00286 
00295 int purple_log_get_total_size(PurpleLogType type, const char *name, PurpleAccount *account);
00296 
00307 gboolean purple_log_is_deletable(PurpleLog *log);
00308 
00315 gboolean purple_log_delete(PurpleLog *log);
00316 
00327 char *purple_log_get_log_dir(PurpleLogType type, const char *name, PurpleAccount *account);
00328 
00336 gint purple_log_compare(gconstpointer y, gconstpointer z);
00337 
00345 gint purple_log_set_compare(gconstpointer y, gconstpointer z);
00346 
00352 void purple_log_set_free(PurpleLogSet *set);
00353 
00356 /******************************************/
00358 /******************************************/
00377 void purple_log_common_writer(PurpleLog *log, const char *ext);
00378 
00396 GList *purple_log_common_lister(PurpleLogType type, const char *name,
00397                               PurpleAccount *account, const char *ext,
00398                               PurpleLogLogger *logger);
00399 
00419 int purple_log_common_total_sizer(PurpleLogType type, const char *name,
00420                                 PurpleAccount *account, const char *ext);
00421 
00435 int purple_log_common_sizer(PurpleLog *log);
00436 
00450 gboolean purple_log_common_deleter(PurpleLog *log);
00451 
00465 gboolean purple_log_common_is_deletable(PurpleLog *log);
00466 
00469 /******************************************/
00471 /******************************************/
00494 PurpleLogLogger *purple_log_logger_new(const char *id, const char *name, int functions, ...);
00495 
00501 void purple_log_logger_free(PurpleLogLogger *logger);
00502 
00508 void purple_log_logger_add (PurpleLogLogger *logger);
00509 
00516 void purple_log_logger_remove (PurpleLogLogger *logger);
00517 
00524 void purple_log_logger_set (PurpleLogLogger *logger);
00525 
00532 PurpleLogLogger *purple_log_logger_get (void);
00533 
00540 GList *purple_log_logger_get_options(void);
00541 
00542 /**************************************************************************/
00544 /**************************************************************************/
00550 void purple_log_init(void);
00551 
00557 void *purple_log_get_handle(void);
00558 
00562 void purple_log_uninit(void);
00563 
00567 #ifdef __cplusplus
00568 }
00569 #endif
00570 
00571 #endif /* _PURPLE_LOG_H_ */