Mercurial > pidgin
annotate src/log.h @ 7456:702fbd2460d7
[gaim-migrate @ 8069]
Stop Doxygen from complaining about missing stuff in the logging
documentation comments.
committer: Tailor Script <tailor@pidgin.im>
| author | Christian Hammond <chipx86@chipx86.com> |
|---|---|
| date | Fri, 07 Nov 2003 08:26:34 +0000 |
| parents | 8c0527c91a92 |
| children | 219903d29401 |
| 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 |
| 7440 | 8 * |
| 5872 | 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 */ | |
| 7440 | 59 |
| 60 /** This gets called when the log is first created. | |
| 7431 | 61 I don't think this is actually needed. */ |
| 7440 | 62 void(*create)(GaimLog *log); |
| 63 | |
| 7431 | 64 /** This is used to write to the log file */ |
| 7440 | 65 void(*write)(GaimLog *log, |
| 66 GaimMessageFlags type, | |
| 7431 | 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); | |
| 7440 | 73 |
| 7431 | 74 /** This function returns a sorted GList of available GaimLogs */ |
| 75 GList *(*list)(const char *name, GaimAccount *account); | |
| 7440 | 76 |
| 77 /** Given one of the logs returned by the logger's list function, | |
| 78 * this returns the contents of the log in GtkIMHtml markup */ | |
| 7431 | 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 char *name; /**< The name of this log */ | |
| 7440 | 88 GaimAccount *account; /**< The account this log is taking |
| 89 place on */ | |
| 90 time_t time; /**< The time this conversation | |
| 91 started */ | |
| 92 GaimLogLogger *logger; /**< The logging mechanism this log | |
| 93 is to use */ | |
| 7431 | 94 void *logger_data; /**< Data used by the log logger */ |
| 5872 | 95 }; |
| 96 | |
| 7431 | 97 |
|
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
98 #ifdef __cplusplus |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
99 extern "C" { |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
100 #endif |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
101 |
| 7431 | 102 /*************************************** |
| 103 ** LOG FUNCTIONS ********************** | |
| 104 ***************************************/ | |
| 7440 | 105 |
| 7431 | 106 /** |
| 107 * Creates a new log | |
| 108 * | |
| 109 * @param type The type of log this is. | |
| 7440 | 110 * @param name The name of this conversation (Screenname, chat name, |
| 111 * etc.) | |
| 7431 | 112 * @param account The account the conversation is occuring on |
| 113 * @param time The time this conversation started | |
| 114 * @return The new log | |
| 7440 | 115 */ |
| 116 GaimLog *gaim_log_new(GaimLogType type, const char *name, | |
| 117 GaimAccount *account, time_t time); | |
| 7431 | 118 |
| 119 /** | |
| 120 * Frees a log | |
| 121 * | |
| 122 * @param log The log to destroy | |
| 7440 | 123 */ |
| 7431 | 124 void gaim_log_free(GaimLog *log); |
| 7440 | 125 |
| 7431 | 126 /** |
| 127 * Writes to a log file | |
| 128 * | |
| 129 * @param log The log to write to | |
| 130 * @param type The type of message being logged | |
| 7440 | 131 * @param from Whom this message is coming from, or NULL for |
| 132 * system messages | |
| 7431 | 133 * @param time A timestamp in UNIX time |
| 134 * @param message The message to log | |
| 135 */ | |
| 136 void gaim_log_write(GaimLog *log, | |
| 7440 | 137 GaimMessageFlags type, |
| 138 const char *from, | |
| 139 time_t time, | |
| 7431 | 140 const char *message); |
| 141 | |
| 142 /** | |
| 143 * Reads from a log | |
| 144 * | |
|
7456
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
145 * @param log The log to read from |
|
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
146 * @param flags The returned logging flags. |
|
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
147 * |
|
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
148 * @return The contents of this log in Gaim Markup. |
| 7431 | 149 */ |
| 150 char *gaim_log_read(GaimLog *log, GaimLogReadFlags *flags); | |
| 151 | |
| 152 /** | |
| 153 * Returns a list of all available logs | |
| 154 * | |
| 155 * @param name The name of the log | |
| 156 * @param account The account | |
| 157 * @return A sorted list of GaimLogs | |
| 158 */ | |
| 159 GList *gaim_log_get_logs(const char *name, GaimAccount *account); | |
| 7440 | 160 |
| 5872 | 161 |
| 7431 | 162 /****************************************** |
| 163 ** LOGGER FUNCTIONS ********************** | |
| 164 ******************************************/ | |
| 7440 | 165 |
| 7431 | 166 /** |
| 167 * Creates a new logger | |
| 168 * | |
|
7456
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
169 * @param create The logger's new function. |
|
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
170 * @param write The logger's write function. |
|
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
171 * @param finalize The logger's finalize function. |
|
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
172 * @param list The logger's list function. |
|
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
173 * @param read The logger's read function. |
|
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
174 * |
|
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
175 * @return The new logger |
| 7431 | 176 */ |
| 7440 | 177 GaimLogLogger *gaim_log_logger_new(void(*create)(GaimLog *), |
| 7431 | 178 void(*write)(GaimLog *, GaimMessageFlags, |
| 179 const char *, time_t, const char *), | |
| 7440 | 180 void(*finalize)(GaimLog *), |
| 181 GList*(*list)(const char*, GaimAccount*), | |
| 7431 | 182 char*(*read)(GaimLog*, GaimLogReadFlags*)); |
| 183 /** | |
| 184 * Frees a logger | |
| 7440 | 185 * |
| 7431 | 186 * @param logger The logger to free |
| 187 */ | |
| 188 void gaim_log_logger_free(GaimLogLogger *logger); | |
| 7440 | 189 |
| 7431 | 190 /** |
| 191 * Adds a new logger | |
| 192 * | |
| 193 * @param logger The new logger to add | |
| 194 */ | |
| 195 void gaim_log_logger_add (GaimLogLogger *logger); | |
| 196 | |
| 197 /** | |
| 198 * | |
| 199 * Removes a logger | |
| 200 * | |
| 201 * @param logger The logger to remove | |
| 202 */ | |
| 203 void gaim_log_logger_remove (GaimLogLogger *logger); | |
| 204 | |
| 205 /** | |
| 206 * | |
| 207 * Sets the current logger | |
| 208 * | |
| 209 * @param logger The logger to set | |
| 210 */ | |
| 211 void gaim_log_logger_set (GaimLogLogger *logger); | |
| 7440 | 212 |
| 7431 | 213 /** |
| 7440 | 214 * |
| 7431 | 215 * Returns the current logger |
| 216 * | |
| 217 * @return logger The current logger | |
| 218 */ | |
| 219 GaimLogLogger *gaim_log_logger_get (void); | |
| 7440 | 220 |
| 7431 | 221 /** |
| 7440 | 222 * Returns a GList containing the IDs and Names of the registered log |
| 223 * loggers. | |
| 7431 | 224 * |
| 225 * @return The list of IDs and names. | |
| 226 */ | |
| 227 GList *gaim_log_logger_get_options(void); | |
| 228 | |
| 229 void gaim_log_init(void); | |
| 230 /*@}*/ | |
| 231 | |
| 5872 | 232 |
|
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
233 #ifdef __cplusplus |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
234 } |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
235 #endif |
| 7440 | 236 |
| 7431 | 237 #endif /* _GAIM_LOG_H_ */ |
|
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
238 |
