2 * @file conversation.h Conversation API
4 * @see @ref conversation-signals
9 * Purple is the legal property of its developers, whose names are too numerous
10 * to list here. Please refer to the COPYRIGHT file distributed with this
11 * source distribution.
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
27 #ifndef _PURPLE_CONVERSATION_H_
28 #define _PURPLE_CONVERSATION_H_
30 /**************************************************************************/
31 /** Data Structures */
32 /**************************************************************************/
35 /** @copydoc _PurpleConversationUiOps */
36 typedef struct _PurpleConversationUiOps PurpleConversationUiOps
;
37 /** @copydoc _PurpleConversation */
38 typedef struct _PurpleConversation PurpleConversation
;
39 /** @copydoc _PurpleConvIm */
40 typedef struct _PurpleConvIm PurpleConvIm
;
41 /** @copydoc _PurpleConvChat */
42 typedef struct _PurpleConvChat PurpleConvChat
;
43 /** @copydoc _PurpleConvChatBuddy */
44 typedef struct _PurpleConvChatBuddy PurpleConvChatBuddy
;
45 /** @copydoc _PurpleConvMessage */
46 typedef struct _PurpleConvMessage PurpleConvMessage
;
49 * A type of conversation.
53 PURPLE_CONV_TYPE_UNKNOWN
= 0, /**< Unknown conversation type. */
54 PURPLE_CONV_TYPE_IM
, /**< Instant Message. */
55 PURPLE_CONV_TYPE_CHAT
, /**< Chat room. */
56 PURPLE_CONV_TYPE_MISC
, /**< A misc. conversation. */
57 PURPLE_CONV_TYPE_ANY
/**< Any type of conversation. */
59 } PurpleConversationType
;
62 * Conversation update type.
66 PURPLE_CONV_UPDATE_ADD
= 0, /**< The buddy associated with the conversation
68 PURPLE_CONV_UPDATE_REMOVE
, /**< The buddy associated with the conversation
70 PURPLE_CONV_UPDATE_ACCOUNT
, /**< The purple_account was changed. */
71 PURPLE_CONV_UPDATE_TYPING
, /**< The typing state was updated. */
72 PURPLE_CONV_UPDATE_UNSEEN
, /**< The unseen state was updated. */
73 PURPLE_CONV_UPDATE_LOGGING
, /**< Logging for this conversation was
74 enabled or disabled. */
75 PURPLE_CONV_UPDATE_TOPIC
, /**< The topic for a chat was updated. */
77 * XXX These need to go when we implement a more generic core/UI event
80 PURPLE_CONV_ACCOUNT_ONLINE
, /**< One of the user's accounts went online. */
81 PURPLE_CONV_ACCOUNT_OFFLINE
, /**< One of the user's accounts went offline. */
82 PURPLE_CONV_UPDATE_AWAY
, /**< The other user went away. */
83 PURPLE_CONV_UPDATE_ICON
, /**< The other user's buddy icon changed. */
84 PURPLE_CONV_UPDATE_TITLE
,
85 PURPLE_CONV_UPDATE_CHATLEFT
,
87 PURPLE_CONV_UPDATE_FEATURES
/**< The features for a chat have changed */
89 } PurpleConvUpdateType
;
92 * The typing state of a user.
96 PURPLE_NOT_TYPING
= 0, /**< Not typing. */
97 PURPLE_TYPING
, /**< Currently typing. */
98 PURPLE_TYPED
/**< Stopped typing momentarily. */
103 * Flags applicable to a message. Most will have send, recv or system.
107 PURPLE_MESSAGE_SEND
= 0x0001, /**< Outgoing message. */
108 PURPLE_MESSAGE_RECV
= 0x0002, /**< Incoming message. */
109 PURPLE_MESSAGE_SYSTEM
= 0x0004, /**< System message. */
110 PURPLE_MESSAGE_AUTO_RESP
= 0x0008, /**< Auto response. */
111 PURPLE_MESSAGE_ACTIVE_ONLY
= 0x0010, /**< Hint to the UI that this
112 message should not be
113 shown in conversations
114 which are only open for
116 (e.g. for contact-aware
118 PURPLE_MESSAGE_NICK
= 0x0020, /**< Contains your nick. */
119 PURPLE_MESSAGE_NO_LOG
= 0x0040, /**< Do not log. */
120 PURPLE_MESSAGE_WHISPER
= 0x0080, /**< Whispered message. */
121 PURPLE_MESSAGE_ERROR
= 0x0200, /**< Error message. */
122 PURPLE_MESSAGE_DELAYED
= 0x0400, /**< Delayed message. */
123 PURPLE_MESSAGE_RAW
= 0x0800, /**< "Raw" message - don't
125 PURPLE_MESSAGE_IMAGES
= 0x1000, /**< Message contains images */
126 PURPLE_MESSAGE_NOTIFY
= 0x2000, /**< Message is a notification */
127 PURPLE_MESSAGE_NO_LINKIFY
= 0x4000, /**< Message should not be auto-
128 linkified @since 2.1.0 */
129 PURPLE_MESSAGE_INVISIBLE
= 0x8000 /**< Message should not be displayed */
130 } PurpleMessageFlags
;
133 * Flags applicable to users in Chats.
137 PURPLE_CBFLAGS_NONE
= 0x0000, /**< No flags */
138 PURPLE_CBFLAGS_VOICE
= 0x0001, /**< Voiced user or "Participant" */
139 PURPLE_CBFLAGS_HALFOP
= 0x0002, /**< Half-op */
140 PURPLE_CBFLAGS_OP
= 0x0004, /**< Channel Op or Moderator */
141 PURPLE_CBFLAGS_FOUNDER
= 0x0008, /**< Channel Founder */
142 PURPLE_CBFLAGS_TYPING
= 0x0010, /**< Currently typing */
143 PURPLE_CBFLAGS_AWAY
= 0x0020 /**< Currently away. @since 2.8.0 */
145 } PurpleConvChatBuddyFlags
;
148 #include "buddyicon.h"
153 * Conversation operations and events.
155 * Any UI representing a conversation must assign a filled-out
156 * PurpleConversationUiOps structure to the PurpleConversation.
158 struct _PurpleConversationUiOps
160 /** Called when @a conv is created (but before the @ref
161 * conversation-created signal is emitted).
163 void (*create_conversation
)(PurpleConversation
*conv
);
165 /** Called just before @a conv is freed. */
166 void (*destroy_conversation
)(PurpleConversation
*conv
);
167 /** Write a message to a chat. If this field is @c NULL, libpurple will
168 * fall back to using #write_conv.
169 * @see purple_conv_chat_write()
171 void (*write_chat
)(PurpleConversation
*conv
, const char *who
,
172 const char *message
, PurpleMessageFlags flags
,
174 /** Write a message to an IM conversation. If this field is @c NULL,
175 * libpurple will fall back to using #write_conv.
176 * @see purple_conv_im_write()
178 void (*write_im
)(PurpleConversation
*conv
, const char *who
,
179 const char *message
, PurpleMessageFlags flags
,
181 /** Write a message to a conversation. This is used rather than the
182 * chat- or im-specific ops for errors, system messages (such as "x is
183 * now know as y"), and as the fallback if #write_im and #write_chat
184 * are not implemented. It should be implemented, or the UI will miss
185 * conversation error messages and your users will hate you.
187 * @see purple_conversation_write()
189 void (*write_conv
)(PurpleConversation
*conv
,
193 PurpleMessageFlags flags
,
196 /** Add @a cbuddies to a chat.
197 * @param cbuddies A @c GList of #PurpleConvChatBuddy structs.
198 * @param new_arrivals Whether join notices should be shown.
199 * (Join notices are actually written to the
200 * conversation by #purple_conv_chat_add_users().)
202 void (*chat_add_users
)(PurpleConversation
*conv
,
204 gboolean new_arrivals
);
205 /** Rename the user in this chat named @a old_name to @a new_name. (The
206 * rename message is written to the conversation by libpurple.)
207 * @param new_alias @a new_name's new alias, if they have one.
208 * @see purple_conv_chat_add_users()
210 void (*chat_rename_user
)(PurpleConversation
*conv
, const char *old_name
,
211 const char *new_name
, const char *new_alias
);
212 /** Remove @a users from a chat.
213 * @param users A @c GList of <tt>const char *</tt>s.
214 * @see purple_conv_chat_rename_user()
216 void (*chat_remove_users
)(PurpleConversation
*conv
, GList
*users
);
217 /** Called when a user's flags are changed.
218 * @see purple_conv_chat_user_set_flags()
220 void (*chat_update_user
)(PurpleConversation
*conv
, const char *user
);
222 /** Present this conversation to the user; for example, by displaying
225 void (*present
)(PurpleConversation
*conv
);
227 /** If this UI has a concept of focus (as in a windowing system) and
228 * this conversation has the focus, return @c TRUE; otherwise, return
231 gboolean (*has_focus
)(PurpleConversation
*conv
);
234 gboolean (*custom_smiley_add
)(PurpleConversation
*conv
, const char *smile
, gboolean remote
);
235 void (*custom_smiley_write
)(PurpleConversation
*conv
, const char *smile
,
236 const guchar
*data
, gsize size
);
237 void (*custom_smiley_close
)(PurpleConversation
*conv
, const char *smile
);
239 /** Prompt the user for confirmation to send @a message. This function
240 * should arrange for the message to be sent if the user accepts. If
241 * this field is @c NULL, libpurple will fall back to using
242 * #purple_request_action().
244 void (*send_confirm
)(PurpleConversation
*conv
, const char *message
);
246 void (*_purple_reserved1
)(void);
247 void (*_purple_reserved2
)(void);
248 void (*_purple_reserved3
)(void);
249 void (*_purple_reserved4
)(void);
253 * Data specific to Instant Messages.
257 PurpleConversation
*conv
; /**< The parent conversation. */
259 PurpleTypingState typing_state
; /**< The current typing state. */
260 guint typing_timeout
; /**< The typing timer handle. */
261 time_t type_again
; /**< The type again time. */
262 guint send_typed_timeout
; /**< The type again timer handle. */
264 PurpleBuddyIcon
*icon
; /**< The buddy icon. */
268 * Data specific to Chats.
270 struct _PurpleConvChat
272 PurpleConversation
*conv
; /**< The parent conversation. */
274 GList
*in_room
; /**< The users in the room. */
275 GList
*ignored
; /**< Ignored users. */
276 char *who
; /**< The person who set the topic. */
277 char *topic
; /**< The topic. */
278 int id
; /**< The chat ID. */
279 char *nick
; /**< Your nick in this chat. */
281 gboolean left
; /**< We left the chat and kept the window open */
285 * Data for "Chat Buddies"
287 struct _PurpleConvChatBuddy
289 char *name
; /**< The chat participant's name in the chat. */
290 char *alias
; /**< The chat participant's alias, if known;
293 char *alias_key
; /**< A string by which this buddy will be sorted,
294 * or @c NULL if the buddy should be sorted by
295 * its @c name. (This is currently always @c
298 gboolean buddy
; /**< @a TRUE if this chat participant is on the
299 * buddy list; @a FALSE otherwise.
301 PurpleConvChatBuddyFlags flags
; /**< A bitwise OR of flags for this participant,
302 * such as whether they are a channel operator.
304 GHashTable
*attributes
; /**< A hash table of attributes about the user, such as
305 * real name, user@host, etc.
310 * Description of a conversation message
314 struct _PurpleConvMessage
318 PurpleMessageFlags flags
;
320 PurpleConversation
*conv
; /**< @since 2.3.0 */
321 char *alias
; /**< @since 2.3.0 */
325 * A core representation of a conversation between two or more people.
327 * The conversation can be an IM or a chat.
329 struct _PurpleConversation
331 PurpleConversationType type
; /**< The type of conversation. */
333 PurpleAccount
*account
; /**< The user using this conversation. */
336 char *name
; /**< The name of the conversation. */
337 char *title
; /**< The window title. */
339 gboolean logging
; /**< The status of logging. */
341 GList
*logs
; /**< This conversation's logs */
345 PurpleConvIm
*im
; /**< IM-specific data. */
346 PurpleConvChat
*chat
; /**< Chat-specific data. */
347 void *misc
; /**< Misc. data. */
351 PurpleConversationUiOps
*ui_ops
; /**< UI-specific operations. */
352 void *ui_data
; /**< UI-specific data. */
354 GHashTable
*data
; /**< Plugin-specific data. */
356 PurpleConnectionFlags features
; /**< The supported features */
357 GList
*message_history
; /**< Message history, as a GList of PurpleConvMessage's */
364 /**************************************************************************/
365 /** @name Conversation API */
366 /**************************************************************************/
370 * Creates a new conversation of the specified type.
372 * @param type The type of conversation.
373 * @param account The account opening the conversation window on the purple
375 * @param name The name of the conversation. For PURPLE_CONV_TYPE_IM,
376 * this is the name of the buddy.
378 * @return The new conversation.
380 PurpleConversation
*purple_conversation_new(PurpleConversationType type
,
381 PurpleAccount
*account
,
385 * Destroys the specified conversation and removes it from the parent
388 * If this conversation is the only one contained in the parent window,
389 * that window is also destroyed.
391 * @param conv The conversation to destroy.
393 void purple_conversation_destroy(PurpleConversation
*conv
);
397 * Present a conversation to the user. This allows core code to initiate a
398 * conversation by displaying the IM dialog.
399 * @param conv The conversation to present
401 void purple_conversation_present(PurpleConversation
*conv
);
405 * Returns the specified conversation's type.
407 * @param conv The conversation.
409 * @return The conversation's type.
411 PurpleConversationType
purple_conversation_get_type(const PurpleConversation
*conv
);
414 * Sets the specified conversation's UI operations structure.
416 * @param conv The conversation.
417 * @param ops The UI conversation operations structure.
419 void purple_conversation_set_ui_ops(PurpleConversation
*conv
,
420 PurpleConversationUiOps
*ops
);
423 * Sets the default conversation UI operations structure.
425 * @param ops The UI conversation operations structure.
427 void purple_conversations_set_ui_ops(PurpleConversationUiOps
*ops
);
430 * Returns the specified conversation's UI operations structure.
432 * @param conv The conversation.
434 * @return The operations structure.
436 PurpleConversationUiOps
*purple_conversation_get_ui_ops(
437 const PurpleConversation
*conv
);
440 * Sets the specified conversation's purple_account.
442 * This purple_account represents the user using purple, not the person the user
443 * is having a conversation/chat/flame with.
445 * @param conv The conversation.
446 * @param account The purple_account.
448 void purple_conversation_set_account(PurpleConversation
*conv
,
449 PurpleAccount
*account
);
452 * Returns the specified conversation's purple_account.
454 * This purple_account represents the user using purple, not the person the user
455 * is having a conversation/chat/flame with.
457 * @param conv The conversation.
459 * @return The conversation's purple_account.
461 PurpleAccount
*purple_conversation_get_account(const PurpleConversation
*conv
);
464 * Returns the specified conversation's purple_connection.
466 * This is the same as purple_conversation_get_user(conv)->gc.
468 * @param conv The conversation.
470 * @return The conversation's purple_connection.
472 PurpleConnection
*purple_conversation_get_gc(const PurpleConversation
*conv
);
475 * Sets the specified conversation's title.
477 * @param conv The conversation.
478 * @param title The title.
480 void purple_conversation_set_title(PurpleConversation
*conv
, const char *title
);
483 * Returns the specified conversation's title.
485 * @param conv The conversation.
489 const char *purple_conversation_get_title(const PurpleConversation
*conv
);
492 * Automatically sets the specified conversation's title.
494 * This function takes OPT_IM_ALIAS_TAB into account, as well as the
497 * @param conv The conversation.
499 void purple_conversation_autoset_title(PurpleConversation
*conv
);
502 * Sets the specified conversation's name.
504 * @param conv The conversation.
505 * @param name The conversation's name.
507 void purple_conversation_set_name(PurpleConversation
*conv
, const char *name
);
510 * Returns the specified conversation's name.
512 * @param conv The conversation.
514 * @return The conversation's name. If the conversation is an IM with a PurpleBuddy,
515 * then it's the name of the PurpleBuddy.
517 const char *purple_conversation_get_name(const PurpleConversation
*conv
);
520 * Get an attribute of a chat buddy
522 * @param cb The chat buddy.
523 * @param key The key of the attribute.
525 * @return The value of the attribute key.
527 const char *purple_conv_chat_cb_get_attribute(PurpleConvChatBuddy
*cb
, const char *key
);
530 * Get the keys of all atributes of a chat buddy
532 * @param cb The chat buddy.
534 * @return A list of the attributes of a chat buddy.
536 GList
*purple_conv_chat_cb_get_attribute_keys(PurpleConvChatBuddy
*cb
);
539 * Set an attribute of a chat buddy
541 * @param chat The chat.
542 * @param cb The chat buddy.
543 * @param key The key of the attribute.
544 * @param value The value of the attribute.
546 void purple_conv_chat_cb_set_attribute(PurpleConvChat
*chat
, PurpleConvChatBuddy
*cb
, const char *key
, const char *value
);
549 * Set attributes of a chat buddy
551 * @param chat The chat.
552 * @param cb The chat buddy.
553 * @param keys A GList of the keys.
554 * @param values A GList of the values.
557 purple_conv_chat_cb_set_attributes(PurpleConvChat
*chat
, PurpleConvChatBuddy
*cb
, GList
*keys
, GList
*values
);
560 * Enables or disables logging for this conversation.
562 * @param conv The conversation.
563 * @param log @c TRUE if logging should be enabled, or @c FALSE otherwise.
565 void purple_conversation_set_logging(PurpleConversation
*conv
, gboolean log
);
568 * Returns whether or not logging is enabled for this conversation.
570 * @param conv The conversation.
572 * @return @c TRUE if logging is enabled, or @c FALSE otherwise.
574 gboolean
purple_conversation_is_logging(const PurpleConversation
*conv
);
577 * Closes any open logs for this conversation.
579 * Note that new logs will be opened as necessary (e.g. upon receipt of a
580 * message, if the conversation has logging enabled. To disable logging for
581 * the remainder of the conversation, use purple_conversation_set_logging().
583 * @param conv The conversation.
585 void purple_conversation_close_logs(PurpleConversation
*conv
);
588 * Returns the specified conversation's IM-specific data.
590 * If the conversation type is not PURPLE_CONV_TYPE_IM, this will return @c NULL.
592 * @param conv The conversation.
594 * @return The IM-specific data.
596 PurpleConvIm
*purple_conversation_get_im_data(const PurpleConversation
*conv
);
598 #define PURPLE_CONV_IM(c) (purple_conversation_get_im_data(c))
601 * Returns the specified conversation's chat-specific data.
603 * If the conversation type is not PURPLE_CONV_TYPE_CHAT, this will return @c NULL.
605 * @param conv The conversation.
607 * @return The chat-specific data.
609 PurpleConvChat
*purple_conversation_get_chat_data(const PurpleConversation
*conv
);
611 #define PURPLE_CONV_CHAT(c) (purple_conversation_get_chat_data(c))
614 * Sets extra data for a conversation.
616 * @param conv The conversation.
617 * @param key The unique key.
618 * @param data The data to assign.
620 void purple_conversation_set_data(PurpleConversation
*conv
, const char *key
,
624 * Returns extra data in a conversation.
626 * @param conv The conversation.
627 * @param key The unqiue key.
629 * @return The data associated with the key.
631 gpointer
purple_conversation_get_data(PurpleConversation
*conv
, const char *key
);
634 * Returns a list of all conversations.
636 * This list includes both IMs and chats.
638 * @constreturn A GList of all conversations.
640 GList
*purple_get_conversations(void);
643 * Returns a list of all IMs.
645 * @constreturn A GList of all IMs.
647 GList
*purple_get_ims(void);
650 * Returns a list of all chats.
652 * @constreturn A GList of all chats.
654 GList
*purple_get_chats(void);
657 * Finds a conversation with the specified type, name, and Purple account.
659 * @param type The type of the conversation.
660 * @param name The name of the conversation.
661 * @param account The purple_account associated with the conversation.
663 * @return The conversation if found, or @c NULL otherwise.
665 PurpleConversation
*purple_find_conversation_with_account(
666 PurpleConversationType type
, const char *name
,
667 const PurpleAccount
*account
);
670 * Writes to a conversation window.
672 * This function should not be used to write IM or chat messages. Use
673 * purple_conv_im_write() and purple_conv_chat_write() instead. Those functions will
674 * most likely call this anyway, but they may do their own formatting,
675 * sound playback, etc.
677 * This can be used to write generic messages, such as "so and so closed
678 * the conversation window."
680 * @param conv The conversation.
681 * @param who The user who sent the message.
682 * @param message The message.
683 * @param flags The message flags.
684 * @param mtime The time the message was sent.
686 * @see purple_conv_im_write()
687 * @see purple_conv_chat_write()
689 void purple_conversation_write(PurpleConversation
*conv
, const char *who
,
690 const char *message
, PurpleMessageFlags flags
,
694 Set the features as supported for the given conversation.
695 @param conv The conversation
696 @param features Bitset defining supported features
698 void purple_conversation_set_features(PurpleConversation
*conv
,
699 PurpleConnectionFlags features
);
703 Get the features supported by the given conversation.
704 @param conv The conversation
706 PurpleConnectionFlags
purple_conversation_get_features(PurpleConversation
*conv
);
709 * Determines if a conversation has focus
711 * @param conv The conversation.
713 * @return @c TRUE if the conversation has focus, @c FALSE if
714 * it does not or the UI does not have a concept of conversation focus
716 gboolean
purple_conversation_has_focus(PurpleConversation
*conv
);
719 * Updates the visual status and UI of a conversation.
721 * @param conv The conversation.
722 * @param type The update type.
724 void purple_conversation_update(PurpleConversation
*conv
, PurpleConvUpdateType type
);
727 * Calls a function on each conversation.
729 * @param func The function.
731 void purple_conversation_foreach(void (*func
)(PurpleConversation
*conv
));
734 * Retrieve the message history of a conversation.
736 * @param conv The conversation
738 * @return A GList of PurpleConvMessage's. The must not modify the list or the data within.
739 * The list contains the newest message at the beginning, and the oldest message at
744 GList
*purple_conversation_get_message_history(PurpleConversation
*conv
);
747 * Clear the message history of a conversation.
749 * @param conv The conversation
753 void purple_conversation_clear_message_history(PurpleConversation
*conv
);
756 * Get the sender from a PurpleConvMessage
758 * @param msg A PurpleConvMessage
760 * @return The name of the sender of the message
764 const char *purple_conversation_message_get_sender(PurpleConvMessage
*msg
);
767 * Get the message from a PurpleConvMessage
769 * @param msg A PurpleConvMessage
771 * @return The name of the sender of the message
775 const char *purple_conversation_message_get_message(PurpleConvMessage
*msg
);
778 * Get the message-flags of a PurpleConvMessage
780 * @param msg A PurpleConvMessage
782 * @return The message flags
786 PurpleMessageFlags
purple_conversation_message_get_flags(PurpleConvMessage
*msg
);
789 * Get the timestamp of a PurpleConvMessage
791 * @param msg A PurpleConvMessage
793 * @return The timestamp of the message
797 time_t purple_conversation_message_get_timestamp(PurpleConvMessage
*msg
);
802 /**************************************************************************/
803 /** @name IM Conversation API */
804 /**************************************************************************/
808 * Gets an IM's parent conversation.
812 * @return The parent conversation.
814 PurpleConversation
*purple_conv_im_get_conversation(const PurpleConvIm
*im
);
817 * Sets the IM's buddy icon.
819 * This should only be called from within Purple. You probably want to
820 * call purple_buddy_icon_set_data().
823 * @param icon The buddy icon.
825 * @see purple_buddy_icon_set_data()
827 void purple_conv_im_set_icon(PurpleConvIm
*im
, PurpleBuddyIcon
*icon
);
830 * Returns the IM's buddy icon.
834 * @return The buddy icon.
836 PurpleBuddyIcon
*purple_conv_im_get_icon(const PurpleConvIm
*im
);
839 * Sets the IM's typing state.
842 * @param state The typing state.
844 void purple_conv_im_set_typing_state(PurpleConvIm
*im
, PurpleTypingState state
);
847 * Returns the IM's typing state.
851 * @return The IM's typing state.
853 PurpleTypingState
purple_conv_im_get_typing_state(const PurpleConvIm
*im
);
856 * Starts the IM's typing timeout.
859 * @param timeout The timeout.
861 void purple_conv_im_start_typing_timeout(PurpleConvIm
*im
, int timeout
);
864 * Stops the IM's typing timeout.
868 void purple_conv_im_stop_typing_timeout(PurpleConvIm
*im
);
871 * Returns the IM's typing timeout.
875 * @return The timeout.
877 guint
purple_conv_im_get_typing_timeout(const PurpleConvIm
*im
);
880 * Sets the quiet-time when no PURPLE_TYPING messages will be sent.
881 * Few protocols need this (maybe only MSN). If the user is still
882 * typing after this quiet-period, then another PURPLE_TYPING message
886 * @param val The number of seconds to wait before allowing another
887 * PURPLE_TYPING message to be sent to the user. Or 0 to
888 * not send another PURPLE_TYPING message.
890 void purple_conv_im_set_type_again(PurpleConvIm
*im
, unsigned int val
);
893 * Returns the time after which another PURPLE_TYPING message should be sent.
897 * @return The time in seconds since the epoch. Or 0 if no additional
898 * PURPLE_TYPING message should be sent.
900 time_t purple_conv_im_get_type_again(const PurpleConvIm
*im
);
903 * Starts the IM's type again timeout.
907 void purple_conv_im_start_send_typed_timeout(PurpleConvIm
*im
);
910 * Stops the IM's type again timeout.
914 void purple_conv_im_stop_send_typed_timeout(PurpleConvIm
*im
);
917 * Returns the IM's type again timeout interval.
921 * @return The type again timeout interval.
923 guint
purple_conv_im_get_send_typed_timeout(const PurpleConvIm
*im
);
926 * Updates the visual typing notification for an IM conversation.
930 void purple_conv_im_update_typing(PurpleConvIm
*im
);
936 * @param who The user who sent the message.
937 * @param message The message to write.
938 * @param flags The message flags.
939 * @param mtime The time the message was sent.
941 void purple_conv_im_write(PurpleConvIm
*im
, const char *who
,
942 const char *message
, PurpleMessageFlags flags
,
946 * Presents an IM-error to the user
948 * This is a helper function to find a conversation, write an error to it, and
949 * raise the window. If a conversation with this user doesn't already exist,
950 * the function will return FALSE and the calling function can attempt to present
951 * the error another way (purple_notify_error, most likely)
953 * @param who The user this error is about
954 * @param account The account this error is on
955 * @param what The error
956 * @return TRUE if the error was presented, else FALSE
958 gboolean
purple_conv_present_error(const char *who
, PurpleAccount
*account
, const char *what
);
961 * Sends a message to this IM conversation.
964 * @param message The message to send.
966 void purple_conv_im_send(PurpleConvIm
*im
, const char *message
);
969 * Sends a message to a conversation after confirming with
972 * This function is intended for use in cases where the user
973 * hasn't explicitly and knowingly caused a message to be sent.
974 * The confirmation ensures that the user isn't sending a
975 * message by mistake.
977 * @param conv The conversation.
978 * @param message The message to send.
980 void purple_conv_send_confirm(PurpleConversation
*conv
, const char *message
);
983 * Sends a message to this IM conversation with specified flags.
986 * @param message The message to send.
987 * @param flags The PurpleMessageFlags flags to use in addition to PURPLE_MESSAGE_SEND.
989 void purple_conv_im_send_with_flags(PurpleConvIm
*im
, const char *message
, PurpleMessageFlags flags
);
992 * Adds a smiley to the conversation's smiley tree. If this returns
993 * @c TRUE you should call purple_conv_custom_smiley_write() one or more
994 * times, and then purple_conv_custom_smiley_close(). If this returns
995 * @c FALSE, either the conv or smile were invalid, or the icon was
996 * found in the cache. In either case, calling write or close would
999 * @param conv The conversation to associate the smiley with.
1000 * @param smile The text associated with the smiley
1001 * @param cksum_type The type of checksum.
1002 * @param chksum The checksum, as a NUL terminated base64 string.
1003 * @param remote @c TRUE if the custom smiley is set by the remote user (buddy).
1004 * @return @c TRUE if an icon is expected, else FALSE. Note that
1005 * it is an error to never call purple_conv_custom_smiley_close if
1006 * this function returns @c TRUE, but an error to call it if
1007 * @c FALSE is returned.
1010 gboolean
purple_conv_custom_smiley_add(PurpleConversation
*conv
, const char *smile
,
1011 const char *cksum_type
, const char *chksum
,
1016 * Updates the image associated with the current smiley.
1018 * @param conv The conversation associated with the smiley.
1019 * @param smile The text associated with the smiley.
1020 * @param data The actual image data.
1021 * @param size The length of the data.
1024 void purple_conv_custom_smiley_write(PurpleConversation
*conv
,
1030 * Close the custom smiley, all data has been written with
1031 * purple_conv_custom_smiley_write, and it is no longer valid
1032 * to call that function on that smiley.
1034 * @param conv The purple conversation associated with the smiley.
1035 * @param smile The text associated with the smiley
1038 void purple_conv_custom_smiley_close(PurpleConversation
*conv
, const char *smile
);
1043 /**************************************************************************/
1044 /** @name Chat Conversation API */
1045 /**************************************************************************/
1049 * Gets a chat's parent conversation.
1051 * @param chat The chat.
1053 * @return The parent conversation.
1055 PurpleConversation
*purple_conv_chat_get_conversation(const PurpleConvChat
*chat
);
1058 * Sets the list of users in the chat room.
1060 * @note Calling this function will not update the display of the users.
1061 * Please use purple_conv_chat_add_user(), purple_conv_chat_add_users(),
1062 * purple_conv_chat_remove_user(), and purple_conv_chat_remove_users() instead.
1064 * @param chat The chat.
1065 * @param users The list of users.
1067 * @return The list passed.
1069 GList
*purple_conv_chat_set_users(PurpleConvChat
*chat
, GList
*users
);
1072 * Returns a list of users in the chat room. The members of the list
1073 * are PurpleConvChatBuddy objects.
1075 * @param chat The chat.
1077 * @constreturn The list of users.
1079 GList
*purple_conv_chat_get_users(const PurpleConvChat
*chat
);
1082 * Ignores a user in a chat room.
1084 * @param chat The chat.
1085 * @param name The name of the user.
1087 void purple_conv_chat_ignore(PurpleConvChat
*chat
, const char *name
);
1090 * Unignores a user in a chat room.
1092 * @param chat The chat.
1093 * @param name The name of the user.
1095 void purple_conv_chat_unignore(PurpleConvChat
*chat
, const char *name
);
1098 * Sets the list of ignored users in the chat room.
1100 * @param chat The chat.
1101 * @param ignored The list of ignored users.
1103 * @return The list passed.
1105 GList
*purple_conv_chat_set_ignored(PurpleConvChat
*chat
, GList
*ignored
);
1108 * Returns the list of ignored users in the chat room.
1110 * @param chat The chat.
1112 * @constreturn The list of ignored users.
1114 GList
*purple_conv_chat_get_ignored(const PurpleConvChat
*chat
);
1117 * Returns the actual name of the specified ignored user, if it exists in
1120 * If the user found contains a prefix, such as '+' or '\@', this is also
1121 * returned. The username passed to the function does not have to have this
1124 * @param chat The chat.
1125 * @param user The user to check in the ignore list.
1127 * @return The ignored user if found, complete with prefixes, or @c NULL
1130 const char *purple_conv_chat_get_ignored_user(const PurpleConvChat
*chat
,
1134 * Returns @c TRUE if the specified user is ignored.
1136 * @param chat The chat.
1137 * @param user The user.
1139 * @return @c TRUE if the user is in the ignore list; @c FALSE otherwise.
1141 gboolean
purple_conv_chat_is_user_ignored(const PurpleConvChat
*chat
,
1145 * Sets the chat room's topic.
1147 * @param chat The chat.
1148 * @param who The user that set the topic.
1149 * @param topic The topic.
1151 void purple_conv_chat_set_topic(PurpleConvChat
*chat
, const char *who
,
1155 * Returns the chat room's topic.
1157 * @param chat The chat.
1159 * @return The chat's topic.
1161 const char *purple_conv_chat_get_topic(const PurpleConvChat
*chat
);
1164 * Sets the chat room's ID.
1166 * @param chat The chat.
1169 void purple_conv_chat_set_id(PurpleConvChat
*chat
, int id
);
1172 * Returns the chat room's ID.
1174 * @param chat The chat.
1178 int purple_conv_chat_get_id(const PurpleConvChat
*chat
);
1183 * @param chat The chat.
1184 * @param who The user who sent the message.
1185 * @param message The message to write.
1186 * @param flags The flags.
1187 * @param mtime The time the message was sent.
1189 void purple_conv_chat_write(PurpleConvChat
*chat
, const char *who
,
1190 const char *message
, PurpleMessageFlags flags
,
1194 * Sends a message to this chat conversation.
1196 * @param chat The chat.
1197 * @param message The message to send.
1199 void purple_conv_chat_send(PurpleConvChat
*chat
, const char *message
);
1202 * Sends a message to this chat conversation with specified flags.
1204 * @param chat The chat.
1205 * @param message The message to send.
1206 * @param flags The PurpleMessageFlags flags to use.
1208 void purple_conv_chat_send_with_flags(PurpleConvChat
*chat
, const char *message
, PurpleMessageFlags flags
);
1211 * Adds a user to a chat.
1213 * @param chat The chat.
1214 * @param user The user to add.
1215 * @param extra_msg An extra message to display with the join message.
1216 * @param flags The users flags
1217 * @param new_arrival Decides whether or not to show a join notice.
1219 void purple_conv_chat_add_user(PurpleConvChat
*chat
, const char *user
,
1220 const char *extra_msg
, PurpleConvChatBuddyFlags flags
,
1221 gboolean new_arrival
);
1224 * Adds a list of users to a chat.
1226 * The data is copied from @a users, @a extra_msgs, and @a flags, so it is up to
1227 * the caller to free this list after calling this function.
1229 * @param chat The chat.
1230 * @param users The list of users to add.
1231 * @param extra_msgs An extra message to display with the join message for each
1232 * user. This list may be shorter than @a users, in which
1233 * case, the users after the end of extra_msgs will not have
1234 * an extra message. By extension, this means that extra_msgs
1235 * can simply be @c NULL and none of the users will have an
1237 * @param flags The list of flags for each user.
1238 * @param new_arrivals Decides whether or not to show join notices.
1240 void purple_conv_chat_add_users(PurpleConvChat
*chat
, GList
*users
, GList
*extra_msgs
,
1241 GList
*flags
, gboolean new_arrivals
);
1244 * Renames a user in a chat.
1246 * @param chat The chat.
1247 * @param old_user The old username.
1248 * @param new_user The new username.
1250 void purple_conv_chat_rename_user(PurpleConvChat
*chat
, const char *old_user
,
1251 const char *new_user
);
1254 * Removes a user from a chat, optionally with a reason.
1256 * It is up to the developer to free this list after calling this function.
1258 * @param chat The chat.
1259 * @param user The user that is being removed.
1260 * @param reason The optional reason given for the removal. Can be @c NULL.
1262 void purple_conv_chat_remove_user(PurpleConvChat
*chat
, const char *user
,
1263 const char *reason
);
1266 * Removes a list of users from a chat, optionally with a single reason.
1268 * @param chat The chat.
1269 * @param users The users that are being removed.
1270 * @param reason The optional reason given for the removal. Can be @c NULL.
1272 void purple_conv_chat_remove_users(PurpleConvChat
*chat
, GList
*users
,
1273 const char *reason
);
1276 * Finds a user in a chat
1278 * @param chat The chat.
1279 * @param user The user to look for.
1281 * @return TRUE if the user is in the chat, FALSE if not
1283 gboolean
purple_conv_chat_find_user(PurpleConvChat
*chat
, const char *user
);
1286 * Set a users flags in a chat
1288 * @param chat The chat.
1289 * @param user The user to update.
1290 * @param flags The new flags.
1292 void purple_conv_chat_user_set_flags(PurpleConvChat
*chat
, const char *user
,
1293 PurpleConvChatBuddyFlags flags
);
1296 * Get the flags for a user in a chat
1298 * @param chat The chat.
1299 * @param user The user to find the flags for
1301 * @return The flags for the user
1303 PurpleConvChatBuddyFlags
purple_conv_chat_user_get_flags(PurpleConvChat
*chat
,
1307 * Clears all users from a chat.
1309 * @param chat The chat.
1311 void purple_conv_chat_clear_users(PurpleConvChat
*chat
);
1314 * Sets your nickname (used for hilighting) for a chat.
1316 * @param chat The chat.
1317 * @param nick The nick.
1319 void purple_conv_chat_set_nick(PurpleConvChat
*chat
, const char *nick
);
1322 * Gets your nickname (used for hilighting) for a chat.
1324 * @param chat The chat.
1327 const char *purple_conv_chat_get_nick(PurpleConvChat
*chat
);
1330 * Finds a chat with the specified chat ID.
1332 * @param gc The purple_connection.
1333 * @param id The chat ID.
1335 * @return The chat conversation.
1337 PurpleConversation
*purple_find_chat(const PurpleConnection
*gc
, int id
);
1340 * Lets the core know we left a chat, without destroying it.
1341 * Called from serv_got_chat_left().
1343 * @param chat The chat.
1345 void purple_conv_chat_left(PurpleConvChat
*chat
);
1348 * Invite a user to a chat.
1349 * The user will be prompted to enter the user's name or a message if one is
1352 * @param chat The chat.
1353 * @param user The user to invite to the chat.
1354 * @param message The message to send with the invitation.
1355 * @param confirm Prompt before sending the invitation. The user is always
1356 * prompted if either \a user or \a message is @c NULL.
1360 void purple_conv_chat_invite_user(PurpleConvChat
*chat
, const char *user
,
1361 const char *message
, gboolean confirm
);
1364 * Returns true if we're no longer in this chat,
1365 * and just left the window open.
1367 * @param chat The chat.
1369 * @return @c TRUE if we left the chat already, @c FALSE if
1370 * we're still there.
1372 gboolean
purple_conv_chat_has_left(PurpleConvChat
*chat
);
1375 * Creates a new chat buddy
1377 * @param name The name.
1378 * @param alias The alias.
1379 * @param flags The flags.
1381 * @return The new chat buddy
1383 PurpleConvChatBuddy
*purple_conv_chat_cb_new(const char *name
, const char *alias
,
1384 PurpleConvChatBuddyFlags flags
);
1387 * Find a chat buddy in a chat
1389 * @param chat The chat.
1390 * @param name The name of the chat buddy to find.
1392 PurpleConvChatBuddy
*purple_conv_chat_cb_find(PurpleConvChat
*chat
, const char *name
);
1395 * Get the name of a chat buddy
1397 * @param cb The chat buddy.
1399 * @return The name of the chat buddy.
1401 const char *purple_conv_chat_cb_get_name(PurpleConvChatBuddy
*cb
);
1404 * Destroys a chat buddy
1406 * @param cb The chat buddy to destroy
1408 void purple_conv_chat_cb_destroy(PurpleConvChatBuddy
*cb
);
1411 * Retrieves the extended menu items for the conversation.
1413 * @param conv The conversation.
1415 * @return A list of PurpleMenuAction items, harvested by the
1416 * chat-extended-menu signal. The list and the menuaction
1417 * items should be freed by the caller.
1421 GList
* purple_conversation_get_extended_menu(PurpleConversation
*conv
);
1424 * Perform a command in a conversation. Similar to @see purple_cmd_do_command
1426 * @param conv The conversation.
1427 * @param cmdline The entire command including the arguments.
1428 * @param markup @c NULL, or the formatted command line.
1429 * @param error If the command failed errormsg is filled in with the appropriate error
1430 * message, if not @c NULL. It must be freed by the caller with g_free().
1432 * @return @c TRUE if the command was executed successfully, @c FALSE otherwise.
1436 gboolean
purple_conversation_do_command(PurpleConversation
*conv
, const gchar
*cmdline
, const gchar
*markup
, gchar
**error
);
1440 /**************************************************************************/
1441 /** @name Conversations Subsystem */
1442 /**************************************************************************/
1446 * Returns the conversation subsystem handle.
1448 * @return The conversation subsystem handle.
1450 void *purple_conversations_get_handle(void);
1453 * Initializes the conversation subsystem.
1455 void purple_conversations_init(void);
1458 * Uninitializes the conversation subsystem.
1460 void purple_conversations_uninit(void);
1468 #endif /* _PURPLE_CONVERSATION_H_ */