Loading...
Searching...
No Matches
log.h
Go to the documentation of this file.
/* purple
*
* Purple is the legal property of its developers, whose names are too numerous
* to list here. Please refer to the COPYRIGHT file distributed with this
* source distribution.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
#ifndef _PURPLE_LOG_H_
#define _PURPLE_LOG_H_
#include <stdio.h>
/********************************************************
* DATA STRUCTURES **************************************
********************************************************/
typedef struct _PurpleLog PurpleLog;
typedef struct _PurpleLogLogger PurpleLogLogger;
typedef struct _PurpleLogCommonLoggerData PurpleLogCommonLoggerData;
typedef struct _PurpleLogSet PurpleLogSet;
typedef enum {
PURPLE_LOG_IM,
PURPLE_LOG_CHAT,
PURPLE_LOG_SYSTEM
} PurpleLogType;
typedef enum {
PURPLE_LOG_READ_NO_NEWLINE = 1
} PurpleLogReadFlags;
#include "account.h"
#include "conversation.h"
typedef void (*PurpleLogSetCallback) (GHashTable *sets, PurpleLogSet *set);
struct _PurpleLogLogger {
char *name;
char *id;
void (*create)(PurpleLog *log);
gsize (*write)(PurpleLog *log,
PurpleMessageFlags type,
const char *from,
time_t time,
const char *message);
void (*finalize)(PurpleLog *log);
GList *(*list)(PurpleLogType type, const char *name, PurpleAccount *account);
char *(*read)(PurpleLog *log, PurpleLogReadFlags *flags);
int (*size)(PurpleLog *log);
int (*total_size)(PurpleLogType type, const char *name, PurpleAccount *account);
GList *(*list_syslog)(PurpleAccount *account);
void (*get_log_sets)(PurpleLogSetCallback cb, GHashTable *sets);
/* Attempts to delete the specified log, indicating success or failure */
gboolean (*remove)(PurpleLog *log);
/* Tests whether a log is deletable */
gboolean (*is_deletable)(PurpleLog *log);
void (*_purple_reserved1)(void);
void (*_purple_reserved2)(void);
void (*_purple_reserved3)(void);
void (*_purple_reserved4)(void);
};
struct _PurpleLog {
PurpleLogType type;
char *name;
PurpleAccount *account;
PurpleConversation *conv;
time_t time;
PurpleLogLogger *logger;
void *logger_data;
struct tm *tm;
/* IMPORTANT: Some code in log.c allocates these without zeroing them.
* IMPORTANT: Update that code if you add members here. */
};
struct _PurpleLogCommonLoggerData {
char *path;
FILE *file;
void *extra_data;
};
struct _PurpleLogSet {
PurpleLogType type;
char *name;
PurpleAccount *account;
gboolean buddy;
char *normalized_name;
/* IMPORTANT: Some code in log.c allocates these without zeroing them.
* IMPORTANT: Update that code if you add members here. */
};
#ifdef __cplusplus
extern "C" {
#endif
/***************************************/
/***************************************/
PurpleLog *purple_log_new(PurpleLogType type, const char *name, PurpleAccount *account,
PurpleConversation *conv, time_t time, const struct tm *tm);
void purple_log_free(PurpleLog *log);
void purple_log_write(PurpleLog *log,
PurpleMessageFlags type,
const char *from,
time_t time,
const char *message);
char *purple_log_read(PurpleLog *log, PurpleLogReadFlags *flags);
GList *purple_log_get_logs(PurpleLogType type, const char *name, PurpleAccount *account);
GHashTable *purple_log_get_log_sets(void);
GList *purple_log_get_system_logs(PurpleAccount *account);
int purple_log_get_size(PurpleLog *log);
int purple_log_get_total_size(PurpleLogType type, const char *name, PurpleAccount *account);
int purple_log_get_activity_score(PurpleLogType type, const char *name, PurpleAccount *account);
gboolean purple_log_is_deletable(PurpleLog *log);
gboolean purple_log_delete(PurpleLog *log);
char *purple_log_get_log_dir(PurpleLogType type, const char *name, PurpleAccount *account);
gint purple_log_compare(gconstpointer y, gconstpointer z);
gint purple_log_set_compare(gconstpointer y, gconstpointer z);
void purple_log_set_free(PurpleLogSet *set);
/******************************************/
/******************************************/
void purple_log_common_writer(PurpleLog *log, const char *ext);
GList *purple_log_common_lister(PurpleLogType type, const char *name,
PurpleAccount *account, const char *ext,
PurpleLogLogger *logger);
int purple_log_common_total_sizer(PurpleLogType type, const char *name,
PurpleAccount *account, const char *ext);
int purple_log_common_sizer(PurpleLog *log);
gboolean purple_log_common_deleter(PurpleLog *log);
gboolean purple_log_common_is_deletable(PurpleLog *log);
/******************************************/
/******************************************/
PurpleLogLogger *purple_log_logger_new(const char *id, const char *name, int functions, ...);
void purple_log_logger_free(PurpleLogLogger *logger);
void purple_log_logger_add (PurpleLogLogger *logger);
void purple_log_logger_remove (PurpleLogLogger *logger);
void purple_log_logger_set (PurpleLogLogger *logger);
PurpleLogLogger *purple_log_logger_get (void);
GList *purple_log_logger_get_options(void);
/**************************************************************************/
/**************************************************************************/
void purple_log_init(void);
void *purple_log_get_handle(void);
void purple_log_uninit(void);
#ifdef __cplusplus
}
#endif
#endif /* _PURPLE_LOG_H_ */
account.h
Account API.
conversation.h
Conversation API.
PurpleMessageFlags
PurpleMessageFlags
Flags applicable to a message.
Definition conversation.h:106
purple_log_common_lister
GList * purple_log_common_lister(PurpleLogType type, const char *name, PurpleAccount *account, const char *ext, PurpleLogLogger *logger)
Returns a sorted GList of PurpleLogs of the requested type.
purple_log_logger_free
void purple_log_logger_free(PurpleLogLogger *logger)
Frees a logger.
purple_log_write
void purple_log_write(PurpleLog *log, PurpleMessageFlags type, const char *from, time_t time, const char *message)
Writes to a log file.
purple_log_get_activity_score
int purple_log_get_activity_score(PurpleLogType type, const char *name, PurpleAccount *account)
Returns the activity score of a log, based on total size in bytes, which is then decayed based on age...
purple_log_logger_add
void purple_log_logger_add(PurpleLogLogger *logger)
Adds a new logger.
purple_log_logger_get_options
GList * purple_log_logger_get_options(void)
Returns a GList containing the IDs and names of the registered loggers.
purple_log_common_sizer
int purple_log_common_sizer(PurpleLog *log)
Returns the size of a given PurpleLog.
purple_log_delete
gboolean purple_log_delete(PurpleLog *log)
Deletes a log.
purple_log_get_logs
GList * purple_log_get_logs(PurpleLogType type, const char *name, PurpleAccount *account)
Returns a list of all available logs.
purple_log_logger_new
PurpleLogLogger * purple_log_logger_new(const char *id, const char *name, int functions,...)
Creates a new logger.
purple_log_free
void purple_log_free(PurpleLog *log)
Frees a log.
purple_log_common_writer
void purple_log_common_writer(PurpleLog *log, const char *ext)
Opens a new log file in the standard Purple log location with the given file extension,...
purple_log_logger_get
PurpleLogLogger * purple_log_logger_get(void)
Returns the current logger.
purple_log_logger_set
void purple_log_logger_set(PurpleLogLogger *logger)
Sets the current logger.
purple_log_logger_remove
void purple_log_logger_remove(PurpleLogLogger *logger)
Removes a logger.
purple_log_get_handle
void * purple_log_get_handle(void)
Returns the log subsystem handle.
purple_log_is_deletable
gboolean purple_log_is_deletable(PurpleLog *log)
Tests whether a log is deletable.
purple_log_get_log_sets
GHashTable * purple_log_get_log_sets(void)
Returns a GHashTable of PurpleLogSets.
purple_log_compare
gint purple_log_compare(gconstpointer y, gconstpointer z)
Implements GCompareFunc for PurpleLogs.
purple_log_set_free
void purple_log_set_free(PurpleLogSet *set)
Frees a log set.
purple_log_common_deleter
gboolean purple_log_common_deleter(PurpleLog *log)
Deletes a log.
purple_log_get_system_logs
GList * purple_log_get_system_logs(PurpleAccount *account)
Returns a list of all available system logs.
purple_log_get_total_size
int purple_log_get_total_size(PurpleLogType type, const char *name, PurpleAccount *account)
Returns the size, in bytes, of all available logs in this conversation.
purple_log_uninit
void purple_log_uninit(void)
Uninitializes the log subsystem.
purple_log_common_is_deletable
gboolean purple_log_common_is_deletable(PurpleLog *log)
Checks to see if a log is deletable.
purple_log_get_size
int purple_log_get_size(PurpleLog *log)
Returns the size of a log.
purple_log_read
char * purple_log_read(PurpleLog *log, PurpleLogReadFlags *flags)
Reads from a log.
purple_log_new
PurpleLog * purple_log_new(PurpleLogType type, const char *name, PurpleAccount *account, PurpleConversation *conv, time_t time, const struct tm *tm)
Creates a new log.
purple_log_set_compare
gint purple_log_set_compare(gconstpointer y, gconstpointer z)
Implements GCompareFunc for PurpleLogSets.
purple_log_common_total_sizer
int purple_log_common_total_sizer(PurpleLogType type, const char *name, PurpleAccount *account, const char *ext)
Returns the total size of all the logs for a given user, with a given extension.
purple_log_get_log_dir
char * purple_log_get_log_dir(PurpleLogType type, const char *name, PurpleAccount *account)
Returns the default logger directory Purple uses for a given account and username.
purple_log_init
void purple_log_init(void)
Initializes the log subsystem.
_PurpleAccount
Structure representing an account.
Definition account.h:170
_PurpleConversation
A core representation of a conversation between two or more people.
Definition conversation.h:339
_PurpleLogCommonLoggerData
A common logger_data struct containing a file handle and path, as well as a pointer to something else...
Definition log.h:151
_PurpleLogLogger
A log logger.
Definition log.h:63
_PurpleLogLogger::id
char * id
an identifier to refer to this logger
Definition log.h:65
_PurpleLogLogger::total_size
int(* total_size)(PurpleLogType type, const char *name, PurpleAccount *account)
Returns the total size of all the logs.
Definition log.h:94
_PurpleLogLogger::get_log_sets
void(* get_log_sets)(PurpleLogSetCallback cb, GHashTable *sets)
Adds PurpleLogSets to a GHashTable.
Definition log.h:107
_PurpleLogLogger::finalize
void(* finalize)(PurpleLog *log)
Called when the log is destroyed.
Definition log.h:79
_PurpleLogLogger::name
char * name
The logger's name.
Definition log.h:64
_PurpleLogLogger::size
int(* size)(PurpleLog *log)
Given one of the logs returned by the logger's list function, this returns the size of the log in byt...
Definition log.h:90
_PurpleLogLogger::create
void(* create)(PurpleLog *log)
This gets called when the log is first created.
Definition log.h:69
_PurpleLogLogger::write
gsize(* write)(PurpleLog *log, PurpleMessageFlags type, const char *from, time_t time, const char *message)
This is used to write to the log file.
Definition log.h:72
_PurpleLogSet
Describes available logs.
Definition log.h:163
_PurpleLogSet::account
PurpleAccount * account
The account the available logs took place on.
Definition log.h:166
_PurpleLogSet::name
char * name
The name of the logs available.
Definition log.h:165
_PurpleLogSet::normalized_name
char * normalized_name
The normalized version of name.
Definition log.h:175
_PurpleLogSet::buddy
gboolean buddy
Is this (account, name) a buddy on the buddy list?
Definition log.h:173
_PurpleLogSet::type
PurpleLogType type
The type of logs available.
Definition log.h:164
_PurpleLog
A log.
Definition log.h:124
_PurpleLog::tm
struct tm * tm
The time this conversation started, saved with original timezone data, if available and if struct tm ...
Definition log.h:136
_PurpleLog::conv
PurpleConversation * conv
The conversation being logged.
Definition log.h:129
_PurpleLog::name
char * name
The name of this log.
Definition log.h:126
_PurpleLog::logger
PurpleLogLogger * logger
The logging mechanism this log is to use.
Definition log.h:133
_PurpleLog::account
PurpleAccount * account
The account this log is taking place on.
Definition log.h:127
_PurpleLog::time
time_t time
The time this conversation started, converted to the local timezone.
Definition log.h:130
_PurpleLog::logger_data
void * logger_data
Data used by the log logger.
Definition log.h:135
_PurpleLog::type
PurpleLogType type
The type of log this is.
Definition log.h:125