Mercurial > pidgin
annotate src/log.h @ 9584:fe35f55ee984
[gaim-migrate @ 10427]
" When joining a jabber conference many jabber servers
send a recap of the last 20 or so messages. If you
have sounds enabled, this will result in either 20
sounds in row, or worse if mixing is available, a
horrible mix of 20 overlapping sounds. These recap
messages can be identifed be the presence of the
"jabber:x:delay". This patch identifies delayed
messages, passes that information through flags from
the prpl to the core, and then on to the gui. Detailed
changes:
Add GAIM_MESSAGE_DELAYED to GaimMessageFlags to
indicate a delayed message.
Change gtkconv.c to not play sounds when either
GAIM_MESSAGE_DELAYED or GAIM_MESSAGE_SYSTEM are set.
Add GaimConvChatFlags, parallel to GaimConvImFlags, to
pass flags from protocols to core. Currently contains
two flags:
GAIM_CONV_CHAT_WHISPER
GAIM_CONV_CHAT_DELAYED
Change fourth arg of serv_got_chat_in() from "int
whisper" to "GaimConvChatFlags chatflags".
Change jabber prpl to set delayed flag when the
"jabber:x:delay" element is present. Change toc
protocol since it uses the whisper flag." --Nathan Fredrickson
Date: 2004-07-24 00:49
Sender: marv_sfAccepting Donations
Logged In: YES
user_id=790708
I'm not sure I like naming the flags "DELAYED". I mean
that's okay inside jabber since that's what the jabber
protocol refers to it as, but for the the GAIM_*_DELAYED
flags, I think they should be named something else.
I thought about NOSOUND, but I decided that was wrong,
because the flag should say what kind of message it is, not
what to do with it, that's up to the UI to decide.
What's up with not playing sounds on GAIM_MESSAGE_SYSTEM?
This sounds unrelated to this. Are there times when we want
to play sounds on system messages?
Date: 2004-07-24 09:13
Sender: noif
Logged In: YES
user_id=365548
I purposely did not use a name that implied what the UI
should do with the flag. The only characteristic that makes
these messages unique is that they've been stored in the
server for some period of time and are not current. I'm
open to a better flag name than "DELAYED"... I thought about
"RECAP", but that seemed less generalized than "DELAYED".
As for not playing sounds on GAIM_MESSAGE_SYSTEM, that can
be removed if it's controversial. I think I slipped that
in since the setting of the topic was still playing a sound
every time you joined a jabber conference.
I think we can change the flag name ourselves if something else is better.
committer: Tailor Script <tailor@pidgin.im>
| author | Luke Schierer <lschiere@pidgin.im> |
|---|---|
| date | Sat, 24 Jul 2004 15:18:32 +0000 |
| parents | b540c735a6ad |
| children | db62420a53a2 |
| 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 */ | |
| 9000 | 58 /*@{*/ |
| 7431 | 59 struct _GaimLogLogger { |
| 60 char *name; /**< The logger's name */ | |
| 61 char *id; /**< an identifier to refer to this logger */ | |
| 7440 | 62 |
| 63 /** This gets called when the log is first created. | |
| 7431 | 64 I don't think this is actually needed. */ |
| 7440 | 65 void(*create)(GaimLog *log); |
| 66 | |
| 7431 | 67 /** This is used to write to the log file */ |
| 7440 | 68 void(*write)(GaimLog *log, |
| 69 GaimMessageFlags type, | |
| 7431 | 70 const char *from, |
| 71 time_t time, | |
| 72 const char *message); | |
| 73 | |
| 74 /** Called when the log is destroyed */ | |
| 75 void (*finalize)(GaimLog *log); | |
| 7440 | 76 |
| 7431 | 77 /** This function returns a sorted GList of available GaimLogs */ |
| 8898 | 78 GList *(*list)(GaimLogType type, const char *name, GaimAccount *account); |
| 7440 | 79 |
| 80 /** Given one of the logs returned by the logger's list function, | |
| 81 * this returns the contents of the log in GtkIMHtml markup */ | |
| 7431 | 82 char *(*read)(GaimLog *log, GaimLogReadFlags *flags); |
| 7556 | 83 |
| 84 /** Given one of the logs returned by the logger's list function, | |
| 85 * this returns the size of the log in bytes */ | |
| 86 int (*size)(GaimLog *log); | |
| 8096 | 87 |
| 88 /** Returns the total size of all the logs. If this is undefined a default | |
| 89 * implementation is used */ | |
| 8898 | 90 int (*total_size)(GaimLogType type, const char *name, GaimAccount *account); |
| 8573 | 91 |
| 92 /** This function returns a sorted GList of available system GaimLogs */ | |
| 93 GList *(*list_syslog)(GaimAccount *account); | |
| 5872 | 94 }; |
| 95 | |
| 7431 | 96 /** |
| 97 * A log. Not the wooden type. | |
| 98 */ | |
| 99 struct _GaimLog { | |
| 100 GaimLogType type; /**< The type of log this is */ | |
| 101 char *name; /**< The name of this log */ | |
| 7440 | 102 GaimAccount *account; /**< The account this log is taking |
| 103 place on */ | |
| 104 time_t time; /**< The time this conversation | |
| 105 started */ | |
| 106 GaimLogLogger *logger; /**< The logging mechanism this log | |
| 107 is to use */ | |
| 7431 | 108 void *logger_data; /**< Data used by the log logger */ |
| 5872 | 109 }; |
| 110 | |
| 7431 | 111 |
|
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
112 #ifdef __cplusplus |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
113 extern "C" { |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
114 #endif |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
115 |
| 7431 | 116 /*************************************** |
| 117 ** LOG FUNCTIONS ********************** | |
| 118 ***************************************/ | |
| 7440 | 119 |
| 7431 | 120 /** |
| 121 * Creates a new log | |
| 122 * | |
| 123 * @param type The type of log this is. | |
| 7440 | 124 * @param name The name of this conversation (Screenname, chat name, |
| 125 * etc.) | |
|
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
126 * @param account The account the conversation is occurring on |
| 7431 | 127 * @param time The time this conversation started |
| 128 * @return The new log | |
| 7440 | 129 */ |
| 130 GaimLog *gaim_log_new(GaimLogType type, const char *name, | |
| 131 GaimAccount *account, time_t time); | |
| 7431 | 132 |
| 133 /** | |
| 134 * Frees a log | |
| 135 * | |
| 136 * @param log The log to destroy | |
| 7440 | 137 */ |
| 7431 | 138 void gaim_log_free(GaimLog *log); |
| 7440 | 139 |
| 7431 | 140 /** |
| 141 * Writes to a log file | |
| 142 * | |
| 143 * @param log The log to write to | |
| 144 * @param type The type of message being logged | |
| 7440 | 145 * @param from Whom this message is coming from, or NULL for |
| 146 * system messages | |
| 7431 | 147 * @param time A timestamp in UNIX time |
| 148 * @param message The message to log | |
| 149 */ | |
| 150 void gaim_log_write(GaimLog *log, | |
| 7440 | 151 GaimMessageFlags type, |
| 152 const char *from, | |
| 153 time_t time, | |
| 7431 | 154 const char *message); |
| 155 | |
| 156 /** | |
| 157 * Reads from a log | |
| 158 * | |
|
7456
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
159 * @param log The log to read from |
|
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
160 * @param flags The returned logging flags. |
|
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
161 * |
|
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
162 * @return The contents of this log in Gaim Markup. |
| 7431 | 163 */ |
| 164 char *gaim_log_read(GaimLog *log, GaimLogReadFlags *flags); | |
| 165 | |
| 166 /** | |
| 167 * Returns a list of all available logs | |
| 168 * | |
| 8898 | 169 * @param type The type of the log |
| 7431 | 170 * @param name The name of the log |
| 171 * @param account The account | |
| 172 * @return A sorted list of GaimLogs | |
| 173 */ | |
| 8898 | 174 GList *gaim_log_get_logs(GaimLogType type, const char *name, GaimAccount *account); |
| 7440 | 175 |
| 7556 | 176 /** |
| 8573 | 177 * Returns a list of all available system logs |
| 178 * | |
| 179 * @param account The account | |
| 180 * @return A sorted list of GaimLogs | |
| 181 */ | |
| 182 GList *gaim_log_get_system_logs(GaimAccount *account); | |
| 183 | |
| 184 /** | |
| 7556 | 185 * Returns the size of a log |
| 186 * | |
| 187 * @param log The log | |
| 188 * @return The size of the log, in bytes | |
| 189 */ | |
| 190 int gaim_log_get_size(GaimLog *log); | |
| 5872 | 191 |
| 7556 | 192 /** |
| 193 * Returns the size, in bytes, of all available logs in this conversation | |
| 194 * | |
| 9000 | 195 * @param type The type of the log |
| 7556 | 196 * @param name The name of the log |
| 197 * @param account The account | |
| 198 * @return The size in bytes | |
| 199 */ | |
| 8898 | 200 int gaim_log_get_total_size(GaimLogType type, const char *name, GaimAccount *account); |
| 8573 | 201 |
| 202 /** | |
| 203 * Implements GCompareFunc | |
| 204 * | |
| 205 * @param y A GaimLog | |
| 206 * @param z Another GaimLog | |
| 207 * @return A value as specified by GCompareFunc | |
| 208 */ | |
| 209 gint gaim_log_compare(gconstpointer y, gconstpointer z); | |
| 210 | |
| 7431 | 211 /****************************************** |
| 212 ** LOGGER FUNCTIONS ********************** | |
| 213 ******************************************/ | |
| 7440 | 214 |
| 7431 | 215 /** |
| 216 * Creates a new logger | |
| 217 * | |
|
7456
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
218 * @param create The logger's new function. |
|
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
219 * @param write The logger's write function. |
|
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
220 * @param finalize The logger's finalize function. |
|
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
221 * @param list The logger's list function. |
|
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
222 * @param read The logger's read function. |
| 7556 | 223 * @param size The logger's size function. |
|
7456
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
224 * |
|
702fbd2460d7
[gaim-migrate @ 8069]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
225 * @return The new logger |
| 7431 | 226 */ |
| 8898 | 227 GaimLogLogger *gaim_log_logger_new( |
| 228 void(*create)(GaimLog *), | |
| 229 void(*write)(GaimLog *, GaimMessageFlags, const char *, time_t, const char *), | |
| 230 void(*finalize)(GaimLog *), | |
| 231 GList*(*list)(GaimLogType type, const char*, GaimAccount*), | |
| 232 char*(*read)(GaimLog*, GaimLogReadFlags*), | |
| 233 int(*size)(GaimLog*)); | |
| 7431 | 234 /** |
| 235 * Frees a logger | |
| 7440 | 236 * |
| 7431 | 237 * @param logger The logger to free |
| 238 */ | |
| 239 void gaim_log_logger_free(GaimLogLogger *logger); | |
| 7440 | 240 |
| 7431 | 241 /** |
| 242 * Adds a new logger | |
| 243 * | |
| 244 * @param logger The new logger to add | |
| 245 */ | |
| 246 void gaim_log_logger_add (GaimLogLogger *logger); | |
| 247 | |
| 248 /** | |
| 249 * | |
| 250 * Removes a logger | |
| 251 * | |
| 252 * @param logger The logger to remove | |
| 253 */ | |
| 254 void gaim_log_logger_remove (GaimLogLogger *logger); | |
| 255 | |
| 256 /** | |
| 257 * | |
| 258 * Sets the current logger | |
| 259 * | |
| 260 * @param logger The logger to set | |
| 261 */ | |
| 262 void gaim_log_logger_set (GaimLogLogger *logger); | |
| 7440 | 263 |
| 7431 | 264 /** |
| 7440 | 265 * |
| 7431 | 266 * Returns the current logger |
| 267 * | |
| 268 * @return logger The current logger | |
| 269 */ | |
| 270 GaimLogLogger *gaim_log_logger_get (void); | |
| 7440 | 271 |
| 7431 | 272 /** |
| 7440 | 273 * Returns a GList containing the IDs and Names of the registered log |
| 274 * loggers. | |
| 7431 | 275 * |
| 276 * @return The list of IDs and names. | |
| 277 */ | |
| 278 GList *gaim_log_logger_get_options(void); | |
| 279 | |
| 280 void gaim_log_init(void); | |
| 281 /*@}*/ | |
| 282 | |
| 5872 | 283 |
|
5944
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
284 #ifdef __cplusplus |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
285 } |
|
158196b2db19
[gaim-migrate @ 6385]
Christian Hammond <chipx86@chipx86.com>
parents:
5934
diff
changeset
|
286 #endif |
| 7440 | 287 |
| 7431 | 288 #endif /* _GAIM_LOG_H_ */ |
