pidgin: log.h Source File

pidgin 2.14.4

Loading...
Searching...
No Matches
log.h
Go to the documentation of this file.
1
7/* purple
8 *
9 * Purple is the legal property of its developers, whose names are too numerous
10 * to list here. Please refer to the COPYRIGHT file distributed with this
11 * source distribution.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
26 */
27#ifndef _PURPLE_LOG_H_
28#define _PURPLE_LOG_H_
29
30#include <stdio.h>
31
32
33/********************************************************
34 * DATA STRUCTURES **************************************
35 ********************************************************/
36
37typedef struct _PurpleLog PurpleLog;
38typedef struct _PurpleLogLogger PurpleLogLogger;
39typedef struct _PurpleLogCommonLoggerData PurpleLogCommonLoggerData;
40typedef struct _PurpleLogSet PurpleLogSet;
41
42typedef enum {
43 PURPLE_LOG_IM,
44 PURPLE_LOG_CHAT,
45 PURPLE_LOG_SYSTEM
46} PurpleLogType;
47
48typedef enum {
49 PURPLE_LOG_READ_NO_NEWLINE = 1
50} PurpleLogReadFlags;
51
52#include "account.h"
53#include "conversation.h"
54
55typedef void (*PurpleLogSetCallback) (GHashTable *sets, PurpleLogSet *set);
56
63 struct _PurpleLogLogger {
64 char *name;
65 char *id;
69 void (*create)(PurpleLog *log);
70
72 gsize (*write)(PurpleLog *log,
73 PurpleMessageFlags type,
74 const char *from,
75 time_t time,
76 const char *message);
77
79 void (*finalize)(PurpleLog *log);
80
82 GList *(*list)(PurpleLogType type, const char *name, PurpleAccount *account);
83
86 char *(*read)(PurpleLog *log, PurpleLogReadFlags *flags);
87
90 int (*size)(PurpleLog *log);
91
94 int (*total_size)(PurpleLogType type, const char *name, PurpleAccount *account);
95
97 GList *(*list_syslog)(PurpleAccount *account);
98
107 void (*get_log_sets)(PurpleLogSetCallback cb, GHashTable *sets);
108
109 /* Attempts to delete the specified log, indicating success or failure */
110 gboolean (*remove)(PurpleLog *log);
111
112 /* Tests whether a log is deletable */
113 gboolean (*is_deletable)(PurpleLog *log);
114
115 void (*_purple_reserved1)(void);
116 void (*_purple_reserved2)(void);
117 void (*_purple_reserved3)(void);
118 void (*_purple_reserved4)(void);
119};
120
124 struct _PurpleLog {
125 PurpleLogType type;
126 char *name;
127 PurpleAccount *account;
129 PurpleConversation *conv;
130 time_t time;
133 PurpleLogLogger *logger;
135 void *logger_data;
136 struct tm *tm;
143 /* IMPORTANT: Some code in log.c allocates these without zeroing them.
144 * IMPORTANT: Update that code if you add members here. */
145};
146
151 struct _PurpleLogCommonLoggerData {
152 char *path;
153 FILE *file;
154 void *extra_data;
155};
156
163 struct _PurpleLogSet {
164 PurpleLogType type;
165 char *name;
166 PurpleAccount *account;
173 gboolean buddy;
175 char *normalized_name;
180 /* IMPORTANT: Some code in log.c allocates these without zeroing them.
181 * IMPORTANT: Update that code if you add members here. */
182};
183
184#ifdef __cplusplus
185extern "C" {
186#endif
187
188/***************************************/
190/***************************************/
206 PurpleLog *purple_log_new(PurpleLogType type, const char *name, PurpleAccount *account,
207 PurpleConversation *conv, time_t time, const struct tm *tm);
208
214 void purple_log_free(PurpleLog *log);
215
226 void purple_log_write(PurpleLog *log,
227 PurpleMessageFlags type,
228 const char *from,
229 time_t time,
230 const char *message);
231
240 char *purple_log_read(PurpleLog *log, PurpleLogReadFlags *flags);
241
250GList *purple_log_get_logs(PurpleLogType type, const char *name, PurpleAccount *account);
251
268GHashTable *purple_log_get_log_sets(void);
269
276GList *purple_log_get_system_logs(PurpleAccount *account);
277
284 int purple_log_get_size(PurpleLog *log);
285
294 int purple_log_get_total_size(PurpleLogType type, const char *name, PurpleAccount *account);
295
307 int purple_log_get_activity_score(PurpleLogType type, const char *name, PurpleAccount *account);
308
319gboolean purple_log_is_deletable(PurpleLog *log);
320
327gboolean purple_log_delete(PurpleLog *log);
328
339 char *purple_log_get_log_dir(PurpleLogType type, const char *name, PurpleAccount *account);
340
348gint purple_log_compare(gconstpointer y, gconstpointer z);
349
357gint purple_log_set_compare(gconstpointer y, gconstpointer z);
358
364 void purple_log_set_free(PurpleLogSet *set);
365
368/******************************************/
370/******************************************/
389 void purple_log_common_writer(PurpleLog *log, const char *ext);
390
408GList *purple_log_common_lister(PurpleLogType type, const char *name,
409 PurpleAccount *account, const char *ext,
410 PurpleLogLogger *logger);
411
431 int purple_log_common_total_sizer(PurpleLogType type, const char *name,
432 PurpleAccount *account, const char *ext);
433
447 int purple_log_common_sizer(PurpleLog *log);
448
462gboolean purple_log_common_deleter(PurpleLog *log);
463
477gboolean purple_log_common_is_deletable(PurpleLog *log);
478
481/******************************************/
483/******************************************/
506 PurpleLogLogger *purple_log_logger_new(const char *id, const char *name, int functions, ...);
507
513 void purple_log_logger_free(PurpleLogLogger *logger);
514
520 void purple_log_logger_add (PurpleLogLogger *logger);
521
528 void purple_log_logger_remove (PurpleLogLogger *logger);
529
536 void purple_log_logger_set (PurpleLogLogger *logger);
537
544 PurpleLogLogger *purple_log_logger_get (void);
545
552GList *purple_log_logger_get_options(void);
553
554/**************************************************************************/
556/**************************************************************************/
562 void purple_log_init(void);
563
569 void *purple_log_get_handle(void);
570
574 void purple_log_uninit(void);
575
579#ifdef __cplusplus
580}
581#endif
582
583#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