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