pidgin  2.14.10
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 
37 typedef struct _PurpleLog PurpleLog;
38 typedef struct _PurpleLogLogger PurpleLogLogger;
40 typedef struct _PurpleLogSet PurpleLogSet;
41 
42 typedef enum {
43  PURPLE_LOG_IM,
44  PURPLE_LOG_CHAT,
45  PURPLE_LOG_SYSTEM
46 } PurpleLogType;
47 
48 typedef enum {
49  PURPLE_LOG_READ_NO_NEWLINE = 1
50 } PurpleLogReadFlags;
51 
52 #include "account.h"
53 #include "conversation.h"
54 
55 typedef void (*PurpleLogSetCallback) (GHashTable *sets, PurpleLogSet *set);
56 
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;
130  time_t time;
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 
152  char *path;
153  FILE *file;
154  void *extra_data;
155 };
156 
164  PurpleLogType type;
165  char *name;
173  gboolean buddy;
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
185 extern "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 
215 
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 
250 GList *purple_log_get_logs(PurpleLogType type, const char *name, PurpleAccount *account);
251 
268 GHashTable *purple_log_get_log_sets(void);
269 
277 
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 
320 
328 
339 char *purple_log_get_log_dir(PurpleLogType type, const char *name, PurpleAccount *account);
340 
348 gint purple_log_compare(gconstpointer y, gconstpointer z);
349 
357 gint purple_log_set_compare(gconstpointer y, gconstpointer z);
358 
365 
368 /******************************************/
370 /******************************************/
389 void purple_log_common_writer(PurpleLog *log, const char *ext);
390 
408 GList *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 
448 
463 
478 
481 /******************************************/
483 /******************************************/
506 PurpleLogLogger *purple_log_logger_new(const char *id, const char *name, int functions, ...);
507 
514 
521 
529 
537 
545 
553 
554 /**************************************************************************/
556 /**************************************************************************/
562 void purple_log_init(void);
563 
570 
574 void purple_log_uninit(void);
575 
579 #ifdef __cplusplus
580 }
581 #endif
582 
583 #endif /* _PURPLE_LOG_H_ */
Account API.
Conversation API.
PurpleMessageFlags
Flags applicable to a message.
Definition: conversation.h:106
void purple_log_logger_free(PurpleLogLogger *logger)
Frees a logger.
void purple_log_write(PurpleLog *log, PurpleMessageFlags type, const char *from, time_t time, const char *message)
Writes to a log file.
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...
void purple_log_logger_add(PurpleLogLogger *logger)
Adds a new logger.
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.
int purple_log_common_sizer(PurpleLog *log)
Returns the size of a given PurpleLog.
GHashTable * purple_log_get_log_sets(void)
Returns a GHashTable of PurpleLogSets.
gboolean purple_log_delete(PurpleLog *log)
Deletes a log.
void purple_log_free(PurpleLog *log)
Frees a log.
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,...
PurpleLogLogger * purple_log_logger_new(const char *id, const char *name, int functions,...)
Creates a new logger.
void purple_log_logger_set(PurpleLogLogger *logger)
Sets the current logger.
void purple_log_logger_remove(PurpleLogLogger *logger)
Removes a logger.
gboolean purple_log_is_deletable(PurpleLog *log)
Tests whether a log is deletable.
PurpleLog * purple_log_new(PurpleLogType type, const char *name, PurpleAccount *account, PurpleConversation *conv, time_t time, const struct tm *tm)
Creates a new log.
gint purple_log_compare(gconstpointer y, gconstpointer z)
Implements GCompareFunc for PurpleLogs.
void purple_log_set_free(PurpleLogSet *set)
Frees a log set.
gboolean purple_log_common_deleter(PurpleLog *log)
Deletes a log.
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.
void purple_log_uninit(void)
Uninitializes the log subsystem.
gboolean purple_log_common_is_deletable(PurpleLog *log)
Checks to see if a log is deletable.
char * purple_log_read(PurpleLog *log, PurpleLogReadFlags *flags)
Reads from a log.
GList * purple_log_get_system_logs(PurpleAccount *account)
Returns a list of all available system logs.
int purple_log_get_size(PurpleLog *log)
Returns the size of a log.
GList * purple_log_get_logs(PurpleLogType type, const char *name, PurpleAccount *account)
Returns a list of all available logs.
void * purple_log_get_handle(void)
Returns the log subsystem handle.
gint purple_log_set_compare(gconstpointer y, gconstpointer z)
Implements GCompareFunc for PurpleLogSets.
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.
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.
GList * purple_log_logger_get_options(void)
Returns a GList containing the IDs and names of the registered loggers.
PurpleLogLogger * purple_log_logger_get(void)
Returns the current logger.
void purple_log_init(void)
Initializes the log subsystem.
Structure representing an account.
Definition: account.h:170
A core representation of a conversation between two or more people.
Definition: conversation.h:339
A common logger_data struct containing a file handle and path, as well as a pointer to something else...
Definition: log.h:151
A log logger.
Definition: log.h:63
char * id
an identifier to refer to this logger
Definition: log.h:65
int(* total_size)(PurpleLogType type, const char *name, PurpleAccount *account)
Returns the total size of all the logs.
Definition: log.h:94
void(* get_log_sets)(PurpleLogSetCallback cb, GHashTable *sets)
Adds PurpleLogSets to a GHashTable.
Definition: log.h:107
void(* finalize)(PurpleLog *log)
Called when the log is destroyed.
Definition: log.h:79
char * name
The logger's name.
Definition: log.h:64
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
void(* create)(PurpleLog *log)
This gets called when the log is first created.
Definition: log.h:69
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
Describes available logs.
Definition: log.h:163
PurpleAccount * account
The account the available logs took place on.
Definition: log.h:166
char * name
The name of the logs available.
Definition: log.h:165
char * normalized_name
The normalized version of name.
Definition: log.h:175
gboolean buddy
Is this (account, name) a buddy on the buddy list?
Definition: log.h:173
PurpleLogType type
The type of logs available.
Definition: log.h:164
A log.
Definition: log.h:124
struct tm * tm
The time this conversation started, saved with original timezone data, if available and if struct tm ...
Definition: log.h:136
PurpleConversation * conv
The conversation being logged.
Definition: log.h:129
char * name
The name of this log.
Definition: log.h:126
PurpleLogLogger * logger
The logging mechanism this log is to use.
Definition: log.h:133
PurpleAccount * account
The account this log is taking place on.
Definition: log.h:127
time_t time
The time this conversation started, converted to the local timezone.
Definition: log.h:130
void * logger_data
Data used by the log logger.
Definition: log.h:135
PurpleLogType type
The type of log this is.
Definition: log.h:125