comparison libgaim/conversation.h @ 14192:60b1bc8dbf37

[gaim-migrate @ 16863] Renamed 'core' to 'libgaim' committer: Tailor Script <tailor@pidgin.im>
author Evan Schoenberg <evan.s@dreskin.net>
date Sat, 19 Aug 2006 01:50:10 +0000
parents
children 82b59abcaee4
comparison
equal deleted inserted replaced
14191:009db0b357b5 14192:60b1bc8dbf37
1 /**
2 * @file conversation.h Conversation API
3 * @ingroup core
4 *
5 * gaim
6 *
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.
10 *
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 *
25 * @see @ref conversation-signals
26 */
27 #ifndef _GAIM_CONVERSATION_H_
28 #define _GAIM_CONVERSATION_H_
29
30 /**************************************************************************/
31 /** Data Structures */
32 /**************************************************************************/
33
34
35 typedef struct _GaimConversationUiOps GaimConversationUiOps;
36 typedef struct _GaimConversation GaimConversation;
37 typedef struct _GaimConvIm GaimConvIm;
38 typedef struct _GaimConvChat GaimConvChat;
39 typedef struct _GaimConvChatBuddy GaimConvChatBuddy;
40
41 /**
42 * A type of conversation.
43 */
44 typedef enum
45 {
46 GAIM_CONV_TYPE_UNKNOWN = 0, /**< Unknown conversation type. */
47 GAIM_CONV_TYPE_IM, /**< Instant Message. */
48 GAIM_CONV_TYPE_CHAT, /**< Chat room. */
49 GAIM_CONV_TYPE_MISC, /**< A misc. conversation. */
50 GAIM_CONV_TYPE_ANY /**< Any type of conversation. */
51
52 } GaimConversationType;
53
54 /**
55 * Conversation update type.
56 */
57 typedef enum
58 {
59 GAIM_CONV_UPDATE_ADD = 0, /**< The buddy associated with the conversation
60 was added. */
61 GAIM_CONV_UPDATE_REMOVE, /**< The buddy associated with the conversation
62 was removed. */
63 GAIM_CONV_UPDATE_ACCOUNT, /**< The gaim_account was changed. */
64 GAIM_CONV_UPDATE_TYPING, /**< The typing state was updated. */
65 GAIM_CONV_UPDATE_UNSEEN, /**< The unseen state was updated. */
66 GAIM_CONV_UPDATE_LOGGING, /**< Logging for this conversation was
67 enabled or disabled. */
68 GAIM_CONV_UPDATE_TOPIC, /**< The topic for a chat was updated. */
69 /*
70 * XXX These need to go when we implement a more generic core/UI event
71 * system.
72 */
73 GAIM_CONV_ACCOUNT_ONLINE, /**< One of the user's accounts went online. */
74 GAIM_CONV_ACCOUNT_OFFLINE, /**< One of the user's accounts went offline. */
75 GAIM_CONV_UPDATE_AWAY, /**< The other user went away. */
76 GAIM_CONV_UPDATE_ICON, /**< The other user's buddy icon changed. */
77 GAIM_CONV_UPDATE_TITLE,
78 GAIM_CONV_UPDATE_CHATLEFT,
79
80 GAIM_CONV_UPDATE_FEATURES, /**< The features for a chat have changed */
81
82 } GaimConvUpdateType;
83
84 /**
85 * The typing state of a user.
86 */
87 typedef enum
88 {
89 GAIM_NOT_TYPING = 0, /**< Not typing. */
90 GAIM_TYPING, /**< Currently typing. */
91 GAIM_TYPED /**< Stopped typing momentarily. */
92
93 } GaimTypingState;
94
95 /**
96 * Flags applicable to a message. Most will have send, recv or system.
97 */
98 typedef enum
99 {
100 GAIM_MESSAGE_SEND = 0x0001, /**< Outgoing message. */
101 GAIM_MESSAGE_RECV = 0x0002, /**< Incoming message. */
102 GAIM_MESSAGE_SYSTEM = 0x0004, /**< System message. */
103 GAIM_MESSAGE_AUTO_RESP = 0x0008, /**< Auto response. */
104 GAIM_MESSAGE_ACTIVE_ONLY = 0x0010, /**< Hint to the UI that this
105 message should not be
106 shown in conversations
107 which are only open for
108 internal UI purposes
109 (e.g. for contact-aware
110 conversions). */
111 GAIM_MESSAGE_NICK = 0x0020, /**< Contains your nick. */
112 GAIM_MESSAGE_NO_LOG = 0x0040, /**< Do not log. */
113 GAIM_MESSAGE_WHISPER = 0x0080, /**< Whispered message. */
114 GAIM_MESSAGE_ERROR = 0x0200, /**< Error message. */
115 GAIM_MESSAGE_DELAYED = 0x0400, /**< Delayed message. */
116 GAIM_MESSAGE_RAW = 0x0800, /**< "Raw" message - don't
117 apply formatting */
118 GAIM_MESSAGE_IMAGES = 0x1000 /**< Message contains images */
119
120 } GaimMessageFlags;
121
122 /**
123 * Flags applicable to users in Chats.
124 */
125 typedef enum
126 {
127 GAIM_CBFLAGS_NONE = 0x0000, /**< No flags */
128 GAIM_CBFLAGS_VOICE = 0x0001, /**< Voiced user or "Participant" */
129 GAIM_CBFLAGS_HALFOP = 0x0002, /**< Half-op */
130 GAIM_CBFLAGS_OP = 0x0004, /**< Channel Op or Moderator */
131 GAIM_CBFLAGS_FOUNDER = 0x0008, /**< Channel Founder */
132 GAIM_CBFLAGS_TYPING = 0x0010, /**< Currently typing */
133
134 } GaimConvChatBuddyFlags;
135
136 #include "account.h"
137 #include "buddyicon.h"
138 #include "log.h"
139 #include "server.h"
140
141 /**
142 * Conversation operations and events.
143 *
144 * Any UI representing a conversation must assign a filled-out
145 * GaimConversationUiOps structure to the GaimConversation.
146 */
147 struct _GaimConversationUiOps
148 {
149 void (*create_conversation)(GaimConversation *conv);
150 void (*destroy_conversation)(GaimConversation *conv);
151 void (*write_chat)(GaimConversation *conv, const char *who,
152 const char *message, GaimMessageFlags flags,
153 time_t mtime);
154 void (*write_im)(GaimConversation *conv, const char *who,
155 const char *message, GaimMessageFlags flags,
156 time_t mtime);
157 void (*write_conv)(GaimConversation *conv, const char *name, const char *alias,
158 const char *message, GaimMessageFlags flags,
159 time_t mtime);
160
161 void (*chat_add_users)(GaimConversation *conv, GList *cbuddies, gboolean new_arrivals);
162
163 void (*chat_rename_user)(GaimConversation *conv, const char *old_name,
164 const char *new_name, const char *new_alias);
165 void (*chat_remove_users)(GaimConversation *conv, GList *users);
166 void (*chat_update_user)(GaimConversation *conv, const char *user);
167
168 void (*present)(GaimConversation *conv);
169
170 gboolean (*has_focus)(GaimConversation *conv);
171
172 /* Custom Smileys */
173 gboolean (*custom_smiley_add)(GaimConversation *conv, const char *smile, gboolean remote);
174 void (*custom_smiley_write)(GaimConversation *conv, const char *smile,
175 const guchar *data, gsize size);
176 void (*custom_smiley_close)(GaimConversation *conv, const char *smile);
177 };
178
179 /**
180 * Data specific to Instant Messages.
181 */
182 struct _GaimConvIm
183 {
184 GaimConversation *conv; /**< The parent conversation. */
185
186 GaimTypingState typing_state; /**< The current typing state. */
187 guint typing_timeout; /**< The typing timer handle. */
188 time_t type_again; /**< The type again time. */
189 guint send_typed_timeout; /**< The type again timer handle. */
190
191 GaimBuddyIcon *icon; /**< The buddy icon. */
192 };
193
194 /**
195 * Data specific to Chats.
196 */
197 struct _GaimConvChat
198 {
199 GaimConversation *conv; /**< The parent conversation. */
200
201 GList *in_room; /**< The users in the room. */
202 GList *ignored; /**< Ignored users. */
203 char *who; /**< The person who set the topic. */
204 char *topic; /**< The topic. */
205 int id; /**< The chat ID. */
206 char *nick; /**< Your nick in this chat. */
207
208 gboolean left; /**< We left the chat and kept the window open */
209 };
210
211 /**
212 * Data for "Chat Buddies"
213 */
214 struct _GaimConvChatBuddy
215 {
216 char *name; /**< The name */
217 char *alias; /**< The alias */
218 char *alias_key; /**< The alias key */
219 gboolean buddy; /**< ChatBuddy is on the blist */
220 GaimConvChatBuddyFlags flags; /**< Flags (ops, voice etc.) */
221 };
222
223 /**
224 * A core representation of a conversation between two or more people.
225 *
226 * The conversation can be an IM or a chat.
227 */
228 struct _GaimConversation
229 {
230 GaimConversationType type; /**< The type of conversation. */
231
232 GaimAccount *account; /**< The user using this conversation. */
233
234
235 char *name; /**< The name of the conversation. */
236 char *title; /**< The window title. */
237
238 gboolean logging; /**< The status of logging. */
239
240 GList *logs; /**< This conversation's logs */
241
242 union
243 {
244 GaimConvIm *im; /**< IM-specific data. */
245 GaimConvChat *chat; /**< Chat-specific data. */
246 void *misc; /**< Misc. data. */
247
248 } u;
249
250 GaimConversationUiOps *ui_ops; /**< UI-specific operations. */
251 void *ui_data; /**< UI-specific data. */
252
253 GHashTable *data; /**< Plugin-specific data. */
254
255 GaimConnectionFlags features; /**< The supported features */
256
257 };
258
259 #ifdef __cplusplus
260 extern "C" {
261 #endif
262
263 /**************************************************************************/
264 /** @name Conversation API */
265 /**************************************************************************/
266 /*@{*/
267
268 /**
269 * Creates a new conversation of the specified type.
270 *
271 * @param type The type of conversation.
272 * @param account The account opening the conversation window on the gaim
273 * user's end.
274 * @param name The name of the conversation.
275 *
276 * @return The new conversation.
277 */
278 GaimConversation *gaim_conversation_new(GaimConversationType type,
279 GaimAccount *account,
280 const char *name);
281
282 /**
283 * Destroys the specified conversation and removes it from the parent
284 * window.
285 *
286 * If this conversation is the only one contained in the parent window,
287 * that window is also destroyed.
288 *
289 * @param conv The conversation to destroy.
290 */
291 void gaim_conversation_destroy(GaimConversation *conv);
292
293
294 /**
295 * Present a conversation to the user. This allows core code to initiate a
296 * conversation by displaying the IM dialog.
297 * @param conv The conversation to present
298 */
299 void gaim_conversation_present(GaimConversation *conv);
300
301
302 /**
303 * Returns the specified conversation's type.
304 *
305 * @param conv The conversation.
306 *
307 * @return The conversation's type.
308 */
309 GaimConversationType gaim_conversation_get_type(const GaimConversation *conv);
310
311 /**
312 * Sets the specified conversation's UI operations structure.
313 *
314 * @param conv The conversation.
315 * @param ops The UI conversation operations structure.
316 */
317 void gaim_conversation_set_ui_ops(GaimConversation *conv,
318 GaimConversationUiOps *ops);
319
320 /**
321 * Sets the default conversation UI operations structure.
322 *
323 * @param ops The UI conversation operations structure.
324 */
325 void gaim_conversations_set_ui_ops(GaimConversationUiOps *ops);
326
327 /**
328 * Returns the specified conversation's UI operations structure.
329 *
330 * @param conv The conversation.
331 *
332 * @return The operations structure.
333 */
334 GaimConversationUiOps *gaim_conversation_get_ui_ops(
335 const GaimConversation *conv);
336
337 /**
338 * Sets the specified conversation's gaim_account.
339 *
340 * This gaim_account represents the user using gaim, not the person the user
341 * is having a conversation/chat/flame with.
342 *
343 * @param conv The conversation.
344 * @param account The gaim_account.
345 */
346 void gaim_conversation_set_account(GaimConversation *conv,
347 GaimAccount *account);
348
349 /**
350 * Returns the specified conversation's gaim_account.
351 *
352 * This gaim_account represents the user using gaim, not the person the user
353 * is having a conversation/chat/flame with.
354 *
355 * @param conv The conversation.
356 *
357 * @return The conversation's gaim_account.
358 */
359 GaimAccount *gaim_conversation_get_account(const GaimConversation *conv);
360
361 /**
362 * Returns the specified conversation's gaim_connection.
363 *
364 * This is the same as gaim_conversation_get_user(conv)->gc.
365 *
366 * @param conv The conversation.
367 *
368 * @return The conversation's gaim_connection.
369 */
370 GaimConnection *gaim_conversation_get_gc(const GaimConversation *conv);
371
372 /**
373 * Sets the specified conversation's title.
374 *
375 * @param conv The conversation.
376 * @param title The title.
377 */
378 void gaim_conversation_set_title(GaimConversation *conv, const char *title);
379
380 /**
381 * Returns the specified conversation's title.
382 *
383 * @param conv The conversation.
384 *
385 * @return The title.
386 */
387 const char *gaim_conversation_get_title(const GaimConversation *conv);
388
389 /**
390 * Automatically sets the specified conversation's title.
391 *
392 * This function takes OPT_IM_ALIAS_TAB into account, as well as the
393 * user's alias.
394 *
395 * @param conv The conversation.
396 */
397 void gaim_conversation_autoset_title(GaimConversation *conv);
398
399 /**
400 * Sets the specified conversation's name.
401 *
402 * @param conv The conversation.
403 * @param name The conversation's name.
404 */
405 void gaim_conversation_set_name(GaimConversation *conv, const char *name);
406
407 /**
408 * Returns the specified conversation's name.
409 *
410 * @param conv The conversation.
411 *
412 * @return The conversation's name.
413 */
414 const char *gaim_conversation_get_name(const GaimConversation *conv);
415
416 /**
417 * Enables or disables logging for this conversation.
418 *
419 * @param conv The conversation.
420 * @param log @c TRUE if logging should be enabled, or @c FALSE otherwise.
421 */
422 void gaim_conversation_set_logging(GaimConversation *conv, gboolean log);
423
424 /**
425 * Returns whether or not logging is enabled for this conversation.
426 *
427 * @param conv The conversation.
428 *
429 * @return @c TRUE if logging is enabled, or @c FALSE otherwise.
430 */
431 gboolean gaim_conversation_is_logging(const GaimConversation *conv);
432
433 /**
434 * Closes any open logs for this conversation.
435 *
436 * Note that new logs will be opened as necessary (e.g. upon receipt of a
437 * message, if the conversation has logging enabled. To disable logging for
438 * the remainder of the conversation, use gaim_conversation_set_logging().
439 *
440 * @param conv The conversation.
441 */
442 void gaim_conversation_close_logs(GaimConversation *conv);
443
444 /**
445 * Returns the specified conversation's IM-specific data.
446 *
447 * If the conversation type is not GAIM_CONV_TYPE_IM, this will return @c NULL.
448 *
449 * @param conv The conversation.
450 *
451 * @return The IM-specific data.
452 */
453 GaimConvIm *gaim_conversation_get_im_data(const GaimConversation *conv);
454
455 #define GAIM_CONV_IM(c) (gaim_conversation_get_im_data(c))
456
457 /**
458 * Returns the specified conversation's chat-specific data.
459 *
460 * If the conversation type is not GAIM_CONV_TYPE_CHAT, this will return @c NULL.
461 *
462 * @param conv The conversation.
463 *
464 * @return The chat-specific data.
465 */
466 GaimConvChat *gaim_conversation_get_chat_data(const GaimConversation *conv);
467
468 #define GAIM_CONV_CHAT(c) (gaim_conversation_get_chat_data(c))
469
470 /**
471 * Sets extra data for a conversation.
472 *
473 * @param conv The conversation.
474 * @param key The unique key.
475 * @param data The data to assign.
476 */
477 void gaim_conversation_set_data(GaimConversation *conv, const char *key,
478 gpointer data);
479
480 /**
481 * Returns extra data in a conversation.
482 *
483 * @param conv The conversation.
484 * @param key The unqiue key.
485 *
486 * @return The data associated with the key.
487 */
488 gpointer gaim_conversation_get_data(GaimConversation *conv, const char *key);
489
490 /**
491 * Returns a list of all conversations.
492 *
493 * This list includes both IMs and chats.
494 *
495 * @return A GList of all conversations.
496 */
497 GList *gaim_get_conversations(void);
498
499 /**
500 * Returns a list of all IMs.
501 *
502 * @return A GList of all IMs.
503 */
504 GList *gaim_get_ims(void);
505
506 /**
507 * Returns a list of all chats.
508 *
509 * @return A GList of all chats.
510 */
511 GList *gaim_get_chats(void);
512
513 /**
514 * Finds a conversation with the specified type, name, and Gaim account.
515 *
516 * @param type The type of the conversation.
517 * @param name The name of the conversation.
518 * @param account The gaim_account associated with the conversation.
519 *
520 * @return The conversation if found, or @c NULL otherwise.
521 */
522 GaimConversation *gaim_find_conversation_with_account(
523 GaimConversationType type, const char *name,
524 const GaimAccount *account);
525
526 /**
527 * Writes to a conversation window.
528 *
529 * This function should not be used to write IM or chat messages. Use
530 * gaim_conv_im_write() and gaim_conv_chat_write() instead. Those functions will
531 * most likely call this anyway, but they may do their own formatting,
532 * sound playback, etc.
533 *
534 * This can be used to write generic messages, such as "so and so closed
535 * the conversation window."
536 *
537 * @param conv The conversation.
538 * @param who The user who sent the message.
539 * @param message The message.
540 * @param flags The message flags.
541 * @param mtime The time the message was sent.
542 *
543 * @see gaim_conv_im_write()
544 * @see gaim_conv_chat_write()
545 */
546 void gaim_conversation_write(GaimConversation *conv, const char *who,
547 const char *message, GaimMessageFlags flags,
548 time_t mtime);
549
550
551 /**
552 Set the features as supported for the given conversation.
553 @param conv The conversation
554 @param features Bitset defining supported features
555 */
556 void gaim_conversation_set_features(GaimConversation *conv,
557 GaimConnectionFlags features);
558
559
560 /**
561 Get the features supported by the given conversation.
562 @param conv The conversation
563 */
564 GaimConnectionFlags gaim_conversation_get_features(GaimConversation *conv);
565
566 /**
567 * Determines if a conversation has focus
568 *
569 * @param conv The conversation.
570 *
571 * @return @c TRUE if the conversation has focus, @c FALSE if
572 * it does not or the UI does not have a concept of conversation focus
573 */
574 gboolean gaim_conversation_has_focus(GaimConversation *conv);
575
576 /**
577 * Updates the visual status and UI of a conversation.
578 *
579 * @param conv The conversation.
580 * @param type The update type.
581 */
582 void gaim_conversation_update(GaimConversation *conv, GaimConvUpdateType type);
583
584 /**
585 * Calls a function on each conversation.
586 *
587 * @param func The function.
588 */
589 void gaim_conversation_foreach(void (*func)(GaimConversation *conv));
590
591 /*@}*/
592
593
594 /**************************************************************************/
595 /** @name IM Conversation API */
596 /**************************************************************************/
597 /*@{*/
598
599 /**
600 * Gets an IM's parent conversation.
601 *
602 * @param im The IM.
603 *
604 * @return The parent conversation.
605 */
606 GaimConversation *gaim_conv_im_get_conversation(const GaimConvIm *im);
607
608 /**
609 * Sets the IM's buddy icon.
610 *
611 * This should only be called from within Gaim. You probably want to
612 * call gaim_buddy_icon_set_data().
613 *
614 * @param im The IM.
615 * @param icon The buddy icon.
616 *
617 * @see gaim_buddy_icon_set_data()
618 */
619 void gaim_conv_im_set_icon(GaimConvIm *im, GaimBuddyIcon *icon);
620
621 /**
622 * Returns the IM's buddy icon.
623 *
624 * @param im The IM.
625 *
626 * @return The buddy icon.
627 */
628 GaimBuddyIcon *gaim_conv_im_get_icon(const GaimConvIm *im);
629
630 /**
631 * Sets the IM's typing state.
632 *
633 * @param im The IM.
634 * @param state The typing state.
635 */
636 void gaim_conv_im_set_typing_state(GaimConvIm *im, GaimTypingState state);
637
638 /**
639 * Returns the IM's typing state.
640 *
641 * @param im The IM.
642 *
643 * @return The IM's typing state.
644 */
645 GaimTypingState gaim_conv_im_get_typing_state(const GaimConvIm *im);
646
647 /**
648 * Starts the IM's typing timeout.
649 *
650 * @param im The IM.
651 * @param timeout The timeout.
652 */
653 void gaim_conv_im_start_typing_timeout(GaimConvIm *im, int timeout);
654
655 /**
656 * Stops the IM's typing timeout.
657 *
658 * @param im The IM.
659 */
660 void gaim_conv_im_stop_typing_timeout(GaimConvIm *im);
661
662 /**
663 * Returns the IM's typing timeout.
664 *
665 * @param im The IM.
666 *
667 * @return The timeout.
668 */
669 guint gaim_conv_im_get_typing_timeout(const GaimConvIm *im);
670
671 /**
672 * Sets the quiet-time when no GAIM_TYPING messages will be sent.
673 * Few protocols need this (maybe only MSN). If the user is still
674 * typing after this quiet-period, then another GAIM_TYPING message
675 * will be sent.
676 *
677 * @param im The IM.
678 * @param val The number of seconds to wait before allowing another
679 * GAIM_TYPING message to be sent to the user. Or 0 to
680 * not send another GAIM_TYPING message.
681 */
682 void gaim_conv_im_set_type_again(GaimConvIm *im, unsigned int val);
683
684 /**
685 * Returns the time after which another GAIM_TYPING message should be sent.
686 *
687 * @param im The IM.
688 *
689 * @return The time in seconds since the epoch. Or 0 if no additional
690 * GAIM_TYPING message should be sent.
691 */
692 time_t gaim_conv_im_get_type_again(const GaimConvIm *im);
693
694 /**
695 * Starts the IM's type again timeout.
696 *
697 * @param im The IM.
698 */
699 void gaim_conv_im_start_send_typed_timeout(GaimConvIm *im);
700
701 /**
702 * Stops the IM's type again timeout.
703 *
704 * @param im The IM.
705 */
706 void gaim_conv_im_stop_send_typed_timeout(GaimConvIm *im);
707
708 /**
709 * Returns the IM's type again timeout interval.
710 *
711 * @param im The IM.
712 *
713 * @return The type again timeout interval.
714 */
715 guint gaim_conv_im_get_send_typed_timeout(const GaimConvIm *im);
716
717 /**
718 * Updates the visual typing notification for an IM conversation.
719 *
720 * @param im The IM.
721 */
722 void gaim_conv_im_update_typing(GaimConvIm *im);
723
724 /**
725 * Writes to an IM.
726 *
727 * @param im The IM.
728 * @param who The user who sent the message.
729 * @param message The message to write.
730 * @param flags The message flags.
731 * @param mtime The time the message was sent.
732 */
733 void gaim_conv_im_write(GaimConvIm *im, const char *who,
734 const char *message, GaimMessageFlags flags,
735 time_t mtime);
736
737 /**
738 * Presents an IM-error to the user
739 *
740 * This is a helper function to find a conversation, write an error to it, and
741 * raise the window. If a conversation with this user doesn't already exist,
742 * the function will return FALSE and the calling function can attempt to present
743 * the error another way (gaim_notify_error, most likely)
744 *
745 * @param who The user this error is about
746 * @param account The account this error is on
747 * @param what The error
748 * @return TRUE if the error was presented, else FALSE
749 */
750 gboolean gaim_conv_present_error(const char *who, GaimAccount *account, const char *what);
751
752 /**
753 * Sends a message to this IM conversation.
754 *
755 * @param im The IM.
756 * @param message The message to send.
757 */
758 void gaim_conv_im_send(GaimConvIm *im, const char *message);
759
760 /**
761 * Sends a message to this IM conversation with specified flags.
762 *
763 * @param im The IM.
764 * @param message The message to send.
765 * @param flags The GaimMessageFlags flags to use in addition to GAIM_MESSAGE_SEND.
766 */
767 void gaim_conv_im_send_with_flags(GaimConvIm *im, const char *message, GaimMessageFlags flags);
768
769 /**
770 * Adds a smiley to the conversation's smiley tree. If this returns
771 * @c TRUE you should call gaim_conv_custom_smiley_write() one or more
772 * times, and then gaim_conv_custom_smiley_close(). If this returns
773 * @c FALSE, either the conv or smile were invalid, or the icon was
774 * found in the cache. In either case, calling write or close would
775 * be an error.
776 *
777 * @param conv The conversation to associate the smiley with.
778 * @param smile The text associated with the smiley
779 * @param cksum_type The type of checksum.
780 * @param chksum The checksum, as a NUL terminated base64 string.
781 * @param remote @c TRUE if the custom smiley is set by the remote user (buddy).
782 * @return @c TRUE if an icon is expected, else FALSE. Note that
783 * it is an error to never call gaim_conv_custom_smiley_close if
784 * this function returns @c TRUE, but an error to call it if
785 * @c FALSE is returned.
786 */
787
788 gboolean gaim_conv_custom_smiley_add(GaimConversation *conv, const char *smile,
789 const char *cksum_type, const char *chksum,
790 gboolean remote);
791
792
793 /**
794 * Updates the image associated with the current smiley.
795 *
796 * @param conv The conversation associated with the smiley.
797 * @param smile The text associated with the smiley.
798 * @param data The actual image data.
799 * @param size The length of the data.
800 */
801
802 void gaim_conv_custom_smiley_write(GaimConversation *conv,
803 const char *smile,
804 const guchar *data,
805 gsize size);
806
807 /**
808 * Close the custom smiley, all data has been written with
809 * gaim_conv_custom_smiley_write, and it is no longer valid
810 * to call that function on that smiley.
811 *
812 * @param conv The gaim conversation associated with the smiley.
813 * @param smile The text associated with the smiley
814 */
815
816 void gaim_conv_custom_smiley_close(GaimConversation *conv, const char *smile);
817
818 /*@}*/
819
820
821 /**************************************************************************/
822 /** @name Chat Conversation API */
823 /**************************************************************************/
824 /*@{*/
825
826 /**
827 * Gets a chat's parent conversation.
828 *
829 * @param chat The chat.
830 *
831 * @return The parent conversation.
832 */
833 GaimConversation *gaim_conv_chat_get_conversation(const GaimConvChat *chat);
834
835 /**
836 * Sets the list of users in the chat room.
837 *
838 * @note Calling this function will not update the display of the users.
839 * Please use gaim_conv_chat_add_user(), gaim_conv_chat_add_users(),
840 * gaim_conv_chat_remove_user(), and gaim_conv_chat_remove_users() instead.
841 *
842 * @param chat The chat.
843 * @param users The list of users.
844 *
845 * @return The list passed.
846 */
847 GList *gaim_conv_chat_set_users(GaimConvChat *chat, GList *users);
848
849 /**
850 * Returns a list of users in the chat room.
851 *
852 * @param chat The chat.
853 *
854 * @return The list of users.
855 */
856 GList *gaim_conv_chat_get_users(const GaimConvChat *chat);
857
858 /**
859 * Ignores a user in a chat room.
860 *
861 * @param chat The chat.
862 * @param name The name of the user.
863 */
864 void gaim_conv_chat_ignore(GaimConvChat *chat, const char *name);
865
866 /**
867 * Unignores a user in a chat room.
868 *
869 * @param chat The chat.
870 * @param name The name of the user.
871 */
872 void gaim_conv_chat_unignore(GaimConvChat *chat, const char *name);
873
874 /**
875 * Sets the list of ignored users in the chat room.
876 *
877 * @param chat The chat.
878 * @param ignored The list of ignored users.
879 *
880 * @return The list passed.
881 */
882 GList *gaim_conv_chat_set_ignored(GaimConvChat *chat, GList *ignored);
883
884 /**
885 * Returns the list of ignored users in the chat room.
886 *
887 * @param chat The chat.
888 *
889 * @return The list of ignored users.
890 */
891 GList *gaim_conv_chat_get_ignored(const GaimConvChat *chat);
892
893 /**
894 * Returns the actual name of the specified ignored user, if it exists in
895 * the ignore list.
896 *
897 * If the user found contains a prefix, such as '+' or '\@', this is also
898 * returned. The username passed to the function does not have to have this
899 * formatting.
900 *
901 * @param chat The chat.
902 * @param user The user to check in the ignore list.
903 *
904 * @return The ignored user if found, complete with prefixes, or @c NULL
905 * if not found.
906 */
907 const char *gaim_conv_chat_get_ignored_user(const GaimConvChat *chat,
908 const char *user);
909
910 /**
911 * Returns @c TRUE if the specified user is ignored.
912 *
913 * @param chat The chat.
914 * @param user The user.
915 *
916 * @return @c TRUE if the user is in the ignore list; @c FALSE otherwise.
917 */
918 gboolean gaim_conv_chat_is_user_ignored(const GaimConvChat *chat,
919 const char *user);
920
921 /**
922 * Sets the chat room's topic.
923 *
924 * @param chat The chat.
925 * @param who The user that set the topic.
926 * @param topic The topic.
927 */
928 void gaim_conv_chat_set_topic(GaimConvChat *chat, const char *who,
929 const char *topic);
930
931 /**
932 * Returns the chat room's topic.
933 *
934 * @param chat The chat.
935 *
936 * @return The chat's topic.
937 */
938 const char *gaim_conv_chat_get_topic(const GaimConvChat *chat);
939
940 /**
941 * Sets the chat room's ID.
942 *
943 * @param chat The chat.
944 * @param id The ID.
945 */
946 void gaim_conv_chat_set_id(GaimConvChat *chat, int id);
947
948 /**
949 * Returns the chat room's ID.
950 *
951 * @param chat The chat.
952 *
953 * @return The ID.
954 */
955 int gaim_conv_chat_get_id(const GaimConvChat *chat);
956
957 /**
958 * Writes to a chat.
959 *
960 * @param chat The chat.
961 * @param who The user who sent the message.
962 * @param message The message to write.
963 * @param flags The flags.
964 * @param mtime The time the message was sent.
965 */
966 void gaim_conv_chat_write(GaimConvChat *chat, const char *who,
967 const char *message, GaimMessageFlags flags,
968 time_t mtime);
969
970 /**
971 * Sends a message to this chat conversation.
972 *
973 * @param chat The chat.
974 * @param message The message to send.
975 */
976 void gaim_conv_chat_send(GaimConvChat *chat, const char *message);
977
978 /**
979 * Sends a message to this chat conversation with specified flags.
980 *
981 * @param chat The chat.
982 * @param message The message to send.
983 * @param flags The GaimMessageFlags flags to use.
984 */
985 void gaim_conv_chat_send_with_flags(GaimConvChat *chat, const char *message, GaimMessageFlags flags);
986
987 /**
988 * Adds a user to a chat.
989 *
990 * @param chat The chat.
991 * @param user The user to add.
992 * @param extra_msg An extra message to display with the join message.
993 * @param flags The users flags
994 * @param new_arrival Decides whether or not to show a join notice.
995 */
996 void gaim_conv_chat_add_user(GaimConvChat *chat, const char *user,
997 const char *extra_msg, GaimConvChatBuddyFlags flags,
998 gboolean new_arrival);
999
1000 /**
1001 * Adds a list of users to a chat.
1002 *
1003 * The data is copied from @a users, @a extra_msgs, and @a flags, so it is up to
1004 * the caller to free this list after calling this function.
1005 *
1006 * @param chat The chat.
1007 * @param users The list of users to add.
1008 * @param extra_msgs An extra message to display with the join message for each
1009 * user. This list may be shorter than @a users, in which
1010 * case, the users after the end of extra_msgs will not have
1011 * an extra message. By extension, this means that extra_msgs
1012 * can simply be @c NULL and none of the users will have an
1013 * extra message.
1014 * @param flags The list of flags for each user.
1015 * @param new_arrivals Decides whether or not to show join notices.
1016 */
1017 void gaim_conv_chat_add_users(GaimConvChat *chat, GList *users, GList *extra_msgs,
1018 GList *flags, gboolean new_arrivals);
1019
1020 /**
1021 * Renames a user in a chat.
1022 *
1023 * @param chat The chat.
1024 * @param old_user The old username.
1025 * @param new_user The new username.
1026 */
1027 void gaim_conv_chat_rename_user(GaimConvChat *chat, const char *old_user,
1028 const char *new_user);
1029
1030 /**
1031 * Removes a user from a chat, optionally with a reason.
1032 *
1033 * It is up to the developer to free this list after calling this function.
1034 *
1035 * @param chat The chat.
1036 * @param user The user that is being removed.
1037 * @param reason The optional reason given for the removal. Can be @c NULL.
1038 */
1039 void gaim_conv_chat_remove_user(GaimConvChat *chat, const char *user,
1040 const char *reason);
1041
1042 /**
1043 * Removes a list of users from a chat, optionally with a single reason.
1044 *
1045 * @param chat The chat.
1046 * @param users The users that are being removed.
1047 * @param reason The optional reason given for the removal. Can be @c NULL.
1048 */
1049 void gaim_conv_chat_remove_users(GaimConvChat *chat, GList *users,
1050 const char *reason);
1051
1052 /**
1053 * Finds a user in a chat
1054 *
1055 * @param chat The chat.
1056 * @param user The user to look for.
1057 *
1058 * @return TRUE if the user is in the chat, FALSE if not
1059 */
1060 gboolean gaim_conv_chat_find_user(GaimConvChat *chat, const char *user);
1061
1062 /**
1063 * Set a users flags in a chat
1064 *
1065 * @param chat The chat.
1066 * @param user The user to update.
1067 * @param flags The new flags.
1068 */
1069 void gaim_conv_chat_user_set_flags(GaimConvChat *chat, const char *user,
1070 GaimConvChatBuddyFlags flags);
1071
1072 /**
1073 * Get the flags for a user in a chat
1074 *
1075 * @param chat The chat.
1076 * @param user The user to find the flags for
1077 *
1078 * @return The flags for the user
1079 */
1080 GaimConvChatBuddyFlags gaim_conv_chat_user_get_flags(GaimConvChat *chat,
1081 const char *user);
1082
1083 /**
1084 * Clears all users from a chat.
1085 *
1086 * @param chat The chat.
1087 */
1088 void gaim_conv_chat_clear_users(GaimConvChat *chat);
1089
1090 /**
1091 * Sets your nickname (used for hilighting) for a chat.
1092 *
1093 * @param chat The chat.
1094 * @param nick The nick.
1095 */
1096 void gaim_conv_chat_set_nick(GaimConvChat *chat, const char *nick);
1097
1098 /**
1099 * Gets your nickname (used for hilighting) for a chat.
1100 *
1101 * @param chat The chat.
1102 * @return The nick.
1103 */
1104 const char *gaim_conv_chat_get_nick(GaimConvChat *chat);
1105
1106 /**
1107 * Finds a chat with the specified chat ID.
1108 *
1109 * @param gc The gaim_connection.
1110 * @param id The chat ID.
1111 *
1112 * @return The chat conversation.
1113 */
1114 GaimConversation *gaim_find_chat(const GaimConnection *gc, int id);
1115
1116 /**
1117 * Lets the core know we left a chat, without destroying it.
1118 * Called from serv_got_chat_left().
1119 *
1120 * @param chat The chat.
1121 */
1122 void gaim_conv_chat_left(GaimConvChat *chat);
1123
1124 /**
1125 * Returns true if we're no longer in this chat,
1126 * and just left the window open.
1127 *
1128 * @param chat The chat.
1129 *
1130 * @return @c TRUE if we left the chat already, @c FALSE if
1131 * we're still there.
1132 */
1133 gboolean gaim_conv_chat_has_left(GaimConvChat *chat);
1134
1135 /**
1136 * Creates a new chat buddy
1137 *
1138 * @param name The name.
1139 * @param alias The alias.
1140 * @param flags The flags.
1141 *
1142 * @return The new chat buddy
1143 */
1144 GaimConvChatBuddy *gaim_conv_chat_cb_new(const char *name, const char *alias,
1145 GaimConvChatBuddyFlags flags);
1146
1147 /**
1148 * Find a chat buddy in a chat
1149 *
1150 * @param chat The chat.
1151 * @param name The name of the chat buddy to find.
1152 */
1153 GaimConvChatBuddy *gaim_conv_chat_cb_find(GaimConvChat *chat, const char *name);
1154
1155 /**
1156 * Get the name of a chat buddy
1157 *
1158 * @param cb The chat buddy.
1159 *
1160 * @return The name of the chat buddy.
1161 */
1162 const char *gaim_conv_chat_cb_get_name(GaimConvChatBuddy *cb);
1163
1164 /**
1165 * Destroys a chat buddy
1166 *
1167 * @param cb The chat buddy to destroy
1168 */
1169 void gaim_conv_chat_cb_destroy(GaimConvChatBuddy *cb);
1170
1171 /*@}*/
1172
1173 /**************************************************************************/
1174 /** @name Conversations Subsystem */
1175 /**************************************************************************/
1176 /*@{*/
1177
1178 /**
1179 * Returns the conversation subsystem handle.
1180 *
1181 * @return The conversation subsystem handle.
1182 */
1183 void *gaim_conversations_get_handle(void);
1184
1185 /**
1186 * Initializes the conversation subsystem.
1187 */
1188 void gaim_conversations_init(void);
1189
1190 /**
1191 * Uninitializes the conversation subsystem.
1192 */
1193 void gaim_conversations_uninit(void);
1194
1195 /*@}*/
1196
1197 #ifdef __cplusplus
1198 }
1199 #endif
1200
1201 #endif /* _GAIM_CONVERSATION_H_ */