Mercurial > pidgin
annotate src/log.h @ 7432:31faec55ef8e
[gaim-migrate @ 8037]
You'll want these too.
committer: Tailor Script <tailor@pidgin.im>
| author | Sean Egan <seanegan@gmail.com> |
|---|---|
| date | Wed, 05 Nov 2003 06:16:25 +0000 |
| parents | 643cbc9a6035 |
| children | 8c0527c91a92 |
| rev | line source |
|---|---|
| 5872 | 1 /** |
| 2 * @file log.h Logging API | |
| 3 * @ingroup core | |
| 4 * | |
| 5 * gaim | |
| 6 * | |
| 7431 | 7 * Copyright (C) 2003 Douglas E. Egan |
| 5872 | 8 * |
| 9 * This program is free software; you can redistribute it and/or modify | |
| 10 * it under the terms of the GNU General Public License as published by | |
| 11 * the Free Software Foundation; either version 2 of the License, or | |
| 12 * (at your option) any later version. | |
| 13 * | |
| 14 * This program is distributed in the hope that it will be useful, | |
| 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 * GNU General Public License for more details. | |
| 18 * | |
| 19 * You should have received a copy of the GNU General Public License | |
| 20 * along with this program; if not, write to the Free Software | |
| 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 22 */ | |
| 7431 | 23 |
| 5872 | 24 #ifndef _GAIM_LOG_H_ |
| 25 #define _GAIM_LOG_H_ | |
| 26 | |
| 7431 | 27 #include <stdio.h> |
| 5872 | 28 |
| 29 | |
| 7431 | 30 /******************************************************** |
| 31 * DATA STRUCTURES ************************************** | |
| 32 ********************************************************/ | |
| 33 | |
| 34 typedef struct _GaimLog GaimLog; | |
| 35 typedef struct _GaimLogLogger GaimLogLogger; | |
| 36 | |
| 37 typedef enum { | |
| 38 GAIM_LOG_IM, | |
| 39 GAIM_LOG_CHAT, | |
| 40 GAIM_LOG_SYSTEM, | |
| 41 } GaimLogType; | |
| 42 | |
| 43 typedef enum { | |
| 44 GAIM_LOG_READ_NO_NEWLINE = 1, | |
| 45 } GaimLogReadFlags; | |
| 46 | |
| 47 #include "account.h" | |
| 48 #include "conversation.h" | |
| 49 | |
| 50 /** | |
| 51 * A log logger. | |
| 52 * | |
| 53 * This struct gets filled out and is included in the GaimLog. It contains everything | |
| 54 * needed to write and read from logs. | |
| 55 */ | |
| 56 struct _GaimLogLogger { | |
| 57 char *name; /**< The logger's name */ | |
| 58 char *id; /**< an identifier to refer to this logger */ | |
| 59 | |
| 60 /** This gets called when the log is first created. | |
| 61 I don't think this is actually needed. */ | |
| 62 void(*new)(GaimLog *log); | |
| 63 | |
| 64 /** This is used to write to the log file */ | |
| 65 void(*write)(GaimLog *log, | |
| 66 GaimMessageFlags type, | |
| 67 const char *from, | |
| 68 time_t time, | |
| 69 const char *message); | |
| 70 | |
| 71 /** Called when the log is destroyed */ | |
| 72 void (*finalize)(GaimLog *log); | |
| 73 | |
| 74 /** This function returns a sorted GList of available GaimLogs */ | |
| 75 GList *(*list)(const char *name, GaimAccount *account); | |
| 76 | |
| 77 /** Given one of the logs returned by the logger's list function, this returns | |
| 78 * the contents of the log in GtkIMHtml markup */ | |
| 79 char *(*read)(GaimLog *log, GaimLogReadFlags *flags); | |
| 5872 | 80 }; |
| 81 | |
| 7431 | 82 /** |
| 83 * A log. Not the wooden type. | |
| 84 */ | |
| 85 struct _GaimLog { | |
| 86 GaimLogType type; /**< The type of log this is */ | |
| 87 | |
| 88 char *name; /**< The name of this log */ | |
| 89 GaimAccount *account; /**< The account this log is taking place on */ | |
| 90 time_t time; /**< The time this conversation started */ | |
| 91 | |
| 92 GaimLogLogger *logger; /**< The logging mechanism this log is to use */ | |
| 93 void *logger_data; /**< Data used by the log logger */ | |
| 5872 | 94 }; |
| 95 | |
| 7431 | 96 |
|
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
97 #ifdef __cplusplus |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
98 extern "C" { |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
99 #endif |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
100 |
| 7431 | 101 /*************************************** |
| 102 ** LOG FUNCTIONS ********************** | |
| 103 ***************************************/ | |
| 104 | |
| 105 /** | |
| 106 * Creates a new log | |
| 107 * | |
| 108 * @param type The type of log this is. | |
| 109 * @param name The name of this conversation (Screenname, chat name, etc.) | |
| 110 * @param account The account the conversation is occuring on | |
| 111 * @param time The time this conversation started | |
| 112 * @return The new log | |
| 113 */ | |
| 114 GaimLog *gaim_log_new(GaimLogType type, const char *name, GaimAccount *account, time_t time); | |
| 115 | |
| 116 /** | |
| 117 * Frees a log | |
| 118 * | |
| 119 * @param log The log to destroy | |
| 120 */ | |
| 121 void gaim_log_free(GaimLog *log); | |
| 122 | |
| 123 /** | |
| 124 * Writes to a log file | |
| 125 * | |
| 126 * @param log The log to write to | |
| 127 * @param type The type of message being logged | |
| 128 * @param from Whom this message is coming from, or NULL for system messages | |
| 129 * @param time A timestamp in UNIX time | |
| 130 * @param message The message to log | |
| 131 */ | |
| 132 void gaim_log_write(GaimLog *log, | |
| 133 GaimMessageFlags type, | |
| 134 const char *from, | |
| 135 time_t time, | |
| 136 const char *message); | |
| 137 | |
| 138 /** | |
| 139 * Reads from a log | |
| 140 * | |
| 141 * @param log The log to read from | |
| 142 * @return The contents of this log in Gaim Markup. | |
| 143 */ | |
| 144 char *gaim_log_read(GaimLog *log, GaimLogReadFlags *flags); | |
| 145 | |
| 146 /** | |
| 147 * Returns a list of all available logs | |
| 148 * | |
| 149 * @param name The name of the log | |
| 150 * @param account The account | |
| 151 * @return A sorted list of GaimLogs | |
| 152 */ | |
| 153 GList *gaim_log_get_logs(const char *name, GaimAccount *account); | |
| 154 | |
| 5872 | 155 |
| 7431 | 156 /****************************************** |
| 157 ** LOGGER FUNCTIONS ********************** | |
| 158 ******************************************/ | |
| 159 | |
| 160 /** | |
| 161 * Creates a new logger | |
| 162 * | |
| 163 * @param new The logger's new function | |
| 164 * @param write The logger's write function | |
| 165 * @return The new logger | |
| 166 */ | |
| 167 GaimLogLogger *gaim_log_logger_new(void(*new)(GaimLog *), | |
| 168 void(*write)(GaimLog *, GaimMessageFlags, | |
| 169 const char *, time_t, const char *), | |
| 170 void(*finalize)(GaimLog *), GList*(*list)(const char*, GaimAccount*), | |
| 171 char*(*read)(GaimLog*, GaimLogReadFlags*)); | |
| 172 /** | |
| 173 * Frees a logger | |
| 174 * | |
| 175 * @param logger The logger to free | |
| 176 */ | |
| 177 void gaim_log_logger_free(GaimLogLogger *logger); | |
| 178 | |
| 179 /** | |
| 180 * Adds a new logger | |
| 181 * | |
| 182 * @param logger The new logger to add | |
| 183 */ | |
| 184 void gaim_log_logger_add (GaimLogLogger *logger); | |
| 185 | |
| 186 /** | |
| 187 * | |
| 188 * Removes a logger | |
| 189 * | |
| 190 * @param logger The logger to remove | |
| 191 */ | |
| 192 void gaim_log_logger_remove (GaimLogLogger *logger); | |
| 193 | |
| 194 /** | |
| 195 * | |
| 196 * Sets the current logger | |
| 197 * | |
| 198 * @param logger The logger to set | |
| 199 */ | |
| 200 void gaim_log_logger_set (GaimLogLogger *logger); | |
| 201 | |
| 202 /** | |
| 203 * | |
| 204 * Returns the current logger | |
| 205 * | |
| 206 * @return logger The current logger | |
| 207 */ | |
| 208 GaimLogLogger *gaim_log_logger_get (void); | |
| 209 | |
| 210 /** | |
| 211 * Returns a GList containing the IDs and Names of the registered log loggers. | |
| 212 * | |
| 213 * @return The list of IDs and names. | |
| 214 */ | |
| 215 GList *gaim_log_logger_get_options(void); | |
| 216 | |
| 217 void gaim_log_init(void); | |
| 218 /*@}*/ | |
| 219 | |
| 5872 | 220 |
|
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
221 #ifdef __cplusplus |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
222 } |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
223 #endif |
| 7431 | 224 |
| 225 #endif /* _GAIM_LOG_H_ */ | |
|
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
226 |
