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 */
144 } PurpleConvChatBuddyFlags;
147 #include "buddyicon.h"
152 * Conversation operations and events.
154 * Any UI representing a conversation must assign a filled-out
155 * PurpleConversationUiOps structure to the PurpleConversation.
157 struct _PurpleConversationUiOps
159 /** Called when @a conv is created (but before the @ref
160 * conversation-created signal is emitted).
162 void (*create_conversation)(PurpleConversation *conv);
164 /** Called just before @a conv is freed. */
165 void (*destroy_conversation)(PurpleConversation *conv);
166 /** Write a message to a chat. If this field is @c NULL, libpurple will
167 * fall back to using #write_conv.
168 * @see purple_conv_chat_write()
170 void (*write_chat)(PurpleConversation *conv, const char *who,
171 const char *message, PurpleMessageFlags flags,
173 /** Write a message to an IM conversation. If this field is @c NULL,
174 * libpurple will fall back to using #write_conv.
175 * @see purple_conv_im_write()
177 void (*write_im)(PurpleConversation *conv, const char *who,
178 const char *message, PurpleMessageFlags flags,
180 /** Write a message to a conversation. This is used rather than the
181 * chat- or im-specific ops for errors, system messages (such as "x is
182 * now know as y"), and as the fallback if #write_im and #write_chat
183 * are not implemented. It should be implemented, or the UI will miss
184 * conversation error messages and your users will hate you.
186 * @see purple_conversation_write()
188 void (*write_conv)(PurpleConversation *conv,
192 PurpleMessageFlags flags,
195 /** Add @a cbuddies to a chat.
196 * @param cbuddies A @c GList of #PurpleConvChatBuddy structs.
197 * @param new_arrivals Whether join notices should be shown.
198 * (Join notices are actually written to the
199 * conversation by #purple_conv_chat_add_users().)
201 void (*chat_add_users)(PurpleConversation *conv,
203 gboolean new_arrivals);
204 /** Rename the user in this chat named @a old_name to @a new_name. (The
205 * rename message is written to the conversation by libpurple.)
206 * @param new_alias @a new_name's new alias, if they have one.
207 * @see purple_conv_chat_add_users()
209 void (*chat_rename_user)(PurpleConversation *conv, const char *old_name,
210 const char *new_name, const char *new_alias);
211 /** Remove @a users from a chat.
212 * @param users A @c GList of <tt>const char *</tt>s.
213 * @see purple_conv_chat_rename_user()
215 void (*chat_remove_users)(PurpleConversation *conv, GList *users);
216 /** Called when a user's flags are changed.
217 * @see purple_conv_chat_user_set_flags()
219 void (*chat_update_user)(PurpleConversation *conv, const char *user);
221 /** Present this conversation to the user; for example, by displaying
224 void (*present)(PurpleConversation *conv);
226 /** If this UI has a concept of focus (as in a windowing system) and
227 * this conversation has the focus, return @c TRUE; otherwise, return
230 gboolean (*has_focus)(PurpleConversation *conv);
233 gboolean (*custom_smiley_add)(PurpleConversation *conv, const char *smile, gboolean remote);
234 void (*custom_smiley_write)(PurpleConversation *conv, const char *smile,
235 const guchar *data, gsize size);
236 void (*custom_smiley_close)(PurpleConversation *conv, const char *smile);
238 /** Prompt the user for confirmation to send @a message. This function
239 * should arrange for the message to be sent if the user accepts. If
240 * this field is @c NULL, libpurple will fall back to using
241 * #purple_request_action().
243 void (*send_confirm)(PurpleConversation *conv, const char *message);
245 void (*_purple_reserved1)(void);
246 void (*_purple_reserved2)(void);
247 void (*_purple_reserved3)(void);
248 void (*_purple_reserved4)(void);
252 * Data specific to Instant Messages.
256 PurpleConversation *conv; /**< The parent conversation. */
258 PurpleTypingState typing_state; /**< The current typing state. */
259 guint typing_timeout; /**< The typing timer handle. */
260 time_t type_again; /**< The type again time. */
261 guint send_typed_timeout; /**< The type again timer handle. */
263 PurpleBuddyIcon *icon; /**< The buddy icon. */
267 * Data specific to Chats.
269 struct _PurpleConvChat
271 PurpleConversation *conv; /**< The parent conversation. */
273 GList *in_room; /**< The users in the room. */
274 GList *ignored; /**< Ignored users. */
275 char *who; /**< The person who set the topic. */
276 char *topic; /**< The topic. */
277 int id; /**< The chat ID. */
278 char *nick; /**< Your nick in this chat. */
280 gboolean left; /**< We left the chat and kept the window open */
284 * Data for "Chat Buddies"
286 struct _PurpleConvChatBuddy
288 char *name; /**< The chat participant's name in the chat. */
289 char *collate_key; /**< A string by which this buddy can be compared with other collate keys. */
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.
377 * @return The new conversation.
379 PurpleConversation *purple_conversation_new(PurpleConversationType type,
380 PurpleAccount *account,
384 * Destroys the specified conversation and removes it from the parent
387 * If this conversation is the only one contained in the parent window,
388 * that window is also destroyed.
390 * @param conv The conversation to destroy.
392 void purple_conversation_destroy(PurpleConversation *conv);
396 * Present a conversation to the user. This allows core code to initiate a
397 * conversation by displaying the IM dialog.
398 * @param conv The conversation to present
400 void purple_conversation_present(PurpleConversation *conv);
404 * Returns the specified conversation's type.
406 * @param conv The conversation.
408 * @return The conversation's type.
410 PurpleConversationType purple_conversation_get_type(const PurpleConversation *conv);
413 * Sets the specified conversation's UI operations structure.
415 * @param conv The conversation.
416 * @param ops The UI conversation operations structure.
418 void purple_conversation_set_ui_ops(PurpleConversation *conv,
419 PurpleConversationUiOps *ops);
422 * Sets the default conversation UI operations structure.
424 * @param ops The UI conversation operations structure.
426 void purple_conversations_set_ui_ops(PurpleConversationUiOps *ops);
429 * Returns the specified conversation's UI operations structure.
431 * @param conv The conversation.
433 * @return The operations structure.
435 PurpleConversationUiOps *purple_conversation_get_ui_ops(
436 const PurpleConversation *conv);
439 * Sets the specified conversation's purple_account.
441 * This purple_account represents the user using purple, not the person the user
442 * is having a conversation/chat/flame with.
444 * @param conv The conversation.
445 * @param account The purple_account.
447 void purple_conversation_set_account(PurpleConversation *conv,
448 PurpleAccount *account);
451 * Returns the specified conversation's purple_account.
453 * This purple_account represents the user using purple, not the person the user
454 * is having a conversation/chat/flame with.
456 * @param conv The conversation.
458 * @return The conversation's purple_account.
460 PurpleAccount *purple_conversation_get_account(const PurpleConversation *conv);
463 * Returns the specified conversation's purple_connection.
465 * This is the same as purple_conversation_get_user(conv)->gc.
467 * @param conv The conversation.
469 * @return The conversation's purple_connection.
471 PurpleConnection *purple_conversation_get_gc(const PurpleConversation *conv);
474 * Sets the specified conversation's title.
476 * @param conv The conversation.
477 * @param title The title.
479 void purple_conversation_set_title(PurpleConversation *conv, const char *title);
482 * Returns the specified conversation's title.
484 * @param conv The conversation.
488 const char *purple_conversation_get_title(const PurpleConversation *conv);
491 * Automatically sets the specified conversation's title.
493 * This function takes OPT_IM_ALIAS_TAB into account, as well as the
496 * @param conv The conversation.
498 void purple_conversation_autoset_title(PurpleConversation *conv);
501 * Sets the specified conversation's name.
503 * @param conv The conversation.
504 * @param name The conversation's name.
506 void purple_conversation_set_name(PurpleConversation *conv, const char *name);
509 * Returns the specified conversation's name.
511 * @param conv The conversation.
513 * @return The conversation's name. If the conversation is an IM with a PurpleBuddy,
514 * then it's the name of the PurpleBuddy.
516 const char *purple_conversation_get_name(const PurpleConversation *conv);
519 * Enables or disables logging for this conversation.
521 * @param conv The conversation.
522 * @param log @c TRUE if logging should be enabled, or @c FALSE otherwise.
524 void purple_conversation_set_logging(PurpleConversation *conv, gboolean log);
527 * Returns whether or not logging is enabled for this conversation.
529 * @param conv The conversation.
531 * @return @c TRUE if logging is enabled, or @c FALSE otherwise.
533 gboolean purple_conversation_is_logging(const PurpleConversation *conv);
536 * Closes any open logs for this conversation.
538 * Note that new logs will be opened as necessary (e.g. upon receipt of a
539 * message, if the conversation has logging enabled. To disable logging for
540 * the remainder of the conversation, use purple_conversation_set_logging().
542 * @param conv The conversation.
544 void purple_conversation_close_logs(PurpleConversation *conv);
547 * Returns the specified conversation's IM-specific data.
549 * If the conversation type is not PURPLE_CONV_TYPE_IM, this will return @c NULL.
551 * @param conv The conversation.
553 * @return The IM-specific data.
555 PurpleConvIm *purple_conversation_get_im_data(const PurpleConversation *conv);
557 #define PURPLE_CONV_IM(c) (purple_conversation_get_im_data(c))
560 * Returns the specified conversation's chat-specific data.
562 * If the conversation type is not PURPLE_CONV_TYPE_CHAT, this will return @c NULL.
564 * @param conv The conversation.
566 * @return The chat-specific data.
568 PurpleConvChat *purple_conversation_get_chat_data(const PurpleConversation *conv);
570 #define PURPLE_CONV_CHAT(c) (purple_conversation_get_chat_data(c))
573 * Sets extra data for a conversation.
575 * @param conv The conversation.
576 * @param key The unique key.
577 * @param data The data to assign.
579 void purple_conversation_set_data(PurpleConversation *conv, const char *key,
583 * Returns extra data in a conversation.
585 * @param conv The conversation.
586 * @param key The unqiue key.
588 * @return The data associated with the key.
590 gpointer purple_conversation_get_data(PurpleConversation *conv, const char *key);
593 * Returns a list of all conversations.
595 * This list includes both IMs and chats.
597 * @constreturn A GList of all conversations.
599 GList *purple_get_conversations(void);
602 * Returns a list of all IMs.
604 * @constreturn A GList of all IMs.
606 GList *purple_get_ims(void);
609 * Returns a list of all chats.
611 * @constreturn A GList of all chats.
613 GList *purple_get_chats(void);
616 * Finds a conversation with the specified type, name, and Purple account.
618 * @param type The type of the conversation.
619 * @param name The name of the conversation.
620 * @param account The purple_account associated with the conversation.
622 * @return The conversation if found, or @c NULL otherwise.
624 PurpleConversation *purple_find_conversation_with_account(
625 PurpleConversationType type, const char *name,
626 const PurpleAccount *account);
629 * Writes to a conversation window.
631 * This function should not be used to write IM or chat messages. Use
632 * purple_conv_im_write() and purple_conv_chat_write() instead. Those functions will
633 * most likely call this anyway, but they may do their own formatting,
634 * sound playback, etc.
636 * This can be used to write generic messages, such as "so and so closed
637 * the conversation window."
639 * @param conv The conversation.
640 * @param who The user who sent the message.
641 * @param message The message.
642 * @param flags The message flags.
643 * @param mtime The time the message was sent.
645 * @see purple_conv_im_write()
646 * @see purple_conv_chat_write()
648 void purple_conversation_write(PurpleConversation *conv, const char *who,
649 const char *message, PurpleMessageFlags flags,
654 Set the features as supported for the given conversation.
655 @param conv The conversation
656 @param features Bitset defining supported features
658 void purple_conversation_set_features(PurpleConversation *conv,
659 PurpleConnectionFlags features);
663 Get the features supported by the given conversation.
664 @param conv The conversation
666 PurpleConnectionFlags purple_conversation_get_features(PurpleConversation *conv);
669 * Determines if a conversation has focus
671 * @param conv The conversation.
673 * @return @c TRUE if the conversation has focus, @c FALSE if
674 * it does not or the UI does not have a concept of conversation focus
676 gboolean purple_conversation_has_focus(PurpleConversation *conv);
679 * Updates the visual status and UI of a conversation.
681 * @param conv The conversation.
682 * @param type The update type.
684 void purple_conversation_update(PurpleConversation *conv, PurpleConvUpdateType type);
687 * Calls a function on each conversation.
689 * @param func The function.
691 void purple_conversation_foreach(void (*func)(PurpleConversation *conv));
694 * Retrieve the message history of a conversation.
696 * @param conv The conversation
698 * @return A GList of PurpleConvMessage's. The must not modify the list or the data within.
699 * The list contains the newest message at the beginning, and the oldest message at
704 GList *purple_conversation_get_message_history(PurpleConversation *conv);
707 * Clear the message history of a conversation.
709 * @param conv The conversation
713 void purple_conversation_clear_message_history(PurpleConversation *conv);
716 * Get the sender from a PurpleConvMessage
718 * @param msg A PurpleConvMessage
720 * @return The name of the sender of the message
724 const char *purple_conversation_message_get_sender(PurpleConvMessage *msg);
727 * Get the message from a PurpleConvMessage
729 * @param msg A PurpleConvMessage
731 * @return The name of the sender of the message
735 const char *purple_conversation_message_get_message(PurpleConvMessage *msg);
738 * Get the message-flags of a PurpleConvMessage
740 * @param msg A PurpleConvMessage
742 * @return The message flags
746 PurpleMessageFlags purple_conversation_message_get_flags(PurpleConvMessage *msg);
749 * Get the timestamp of a PurpleConvMessage
751 * @param msg A PurpleConvMessage
753 * @return The timestamp of the message
757 time_t purple_conversation_message_get_timestamp(PurpleConvMessage *msg);
762 /**************************************************************************/
763 /** @name IM Conversation API */
764 /**************************************************************************/
768 * Gets an IM's parent conversation.
772 * @return The parent conversation.
774 PurpleConversation *purple_conv_im_get_conversation(const PurpleConvIm *im);
777 * Sets the IM's buddy icon.
779 * This should only be called from within Purple. You probably want to
780 * call purple_buddy_icon_set_data().
783 * @param icon The buddy icon.
785 * @see purple_buddy_icon_set_data()
787 void purple_conv_im_set_icon(PurpleConvIm *im, PurpleBuddyIcon *icon);
790 * Returns the IM's buddy icon.
794 * @return The buddy icon.
796 PurpleBuddyIcon *purple_conv_im_get_icon(const PurpleConvIm *im);
799 * Sets the IM's typing state.
802 * @param state The typing state.
804 void purple_conv_im_set_typing_state(PurpleConvIm *im, PurpleTypingState state);
807 * Returns the IM's typing state.
811 * @return The IM's typing state.
813 PurpleTypingState purple_conv_im_get_typing_state(const PurpleConvIm *im);
816 * Starts the IM's typing timeout.
819 * @param timeout The timeout.
821 void purple_conv_im_start_typing_timeout(PurpleConvIm *im, int timeout);
824 * Stops the IM's typing timeout.
828 void purple_conv_im_stop_typing_timeout(PurpleConvIm *im);
831 * Returns the IM's typing timeout.
835 * @return The timeout.
837 guint purple_conv_im_get_typing_timeout(const PurpleConvIm *im);
840 * Sets the quiet-time when no PURPLE_TYPING messages will be sent.
841 * Few protocols need this (maybe only MSN). If the user is still
842 * typing after this quiet-period, then another PURPLE_TYPING message
846 * @param val The number of seconds to wait before allowing another
847 * PURPLE_TYPING message to be sent to the user. Or 0 to
848 * not send another PURPLE_TYPING message.
850 void purple_conv_im_set_type_again(PurpleConvIm *im, unsigned int val);
853 * Returns the time after which another PURPLE_TYPING message should be sent.
857 * @return The time in seconds since the epoch. Or 0 if no additional
858 * PURPLE_TYPING message should be sent.
860 time_t purple_conv_im_get_type_again(const PurpleConvIm *im);
863 * Starts the IM's type again timeout.
867 void purple_conv_im_start_send_typed_timeout(PurpleConvIm *im);
870 * Stops the IM's type again timeout.
874 void purple_conv_im_stop_send_typed_timeout(PurpleConvIm *im);
877 * Returns the IM's type again timeout interval.
881 * @return The type again timeout interval.
883 guint purple_conv_im_get_send_typed_timeout(const PurpleConvIm *im);
886 * Updates the visual typing notification for an IM conversation.
890 void purple_conv_im_update_typing(PurpleConvIm *im);
896 * @param who The user who sent the message.
897 * @param message The message to write.
898 * @param flags The message flags.
899 * @param mtime The time the message was sent.
901 void purple_conv_im_write(PurpleConvIm *im, const char *who,
902 const char *message, PurpleMessageFlags flags,
906 * Presents an IM-error to the user
908 * This is a helper function to find a conversation, write an error to it, and
909 * raise the window. If a conversation with this user doesn't already exist,
910 * the function will return FALSE and the calling function can attempt to present
911 * the error another way (purple_notify_error, most likely)
913 * @param who The user this error is about
914 * @param account The account this error is on
915 * @param what The error
916 * @return TRUE if the error was presented, else FALSE
918 gboolean purple_conv_present_error(const char *who, PurpleAccount *account, const char *what);
921 * Sends a message to this IM conversation.
924 * @param message The message to send.
926 void purple_conv_im_send(PurpleConvIm *im, const char *message);
929 * Sends a message to a conversation after confirming with
932 * This function is intended for use in cases where the user
933 * hasn't explicitly and knowingly caused a message to be sent.
934 * The confirmation ensures that the user isn't sending a
935 * message by mistake.
937 * @param conv The conversation.
938 * @param message The message to send.
940 void purple_conv_send_confirm(PurpleConversation *conv, const char *message);
943 * Sends a message to this IM conversation with specified flags.
946 * @param message The message to send.
947 * @param flags The PurpleMessageFlags flags to use in addition to PURPLE_MESSAGE_SEND.
949 void purple_conv_im_send_with_flags(PurpleConvIm *im, const char *message, PurpleMessageFlags flags);
952 * Adds a smiley to the conversation's smiley tree. If this returns
953 * @c TRUE you should call purple_conv_custom_smiley_write() one or more
954 * times, and then purple_conv_custom_smiley_close(). If this returns
955 * @c FALSE, either the conv or smile were invalid, or the icon was
956 * found in the cache. In either case, calling write or close would
959 * @param conv The conversation to associate the smiley with.
960 * @param smile The text associated with the smiley
961 * @param cksum_type The type of checksum.
962 * @param chksum The checksum, as a NUL terminated base64 string.
963 * @param remote @c TRUE if the custom smiley is set by the remote user (buddy).
964 * @return @c TRUE if an icon is expected, else FALSE. Note that
965 * it is an error to never call purple_conv_custom_smiley_close if
966 * this function returns @c TRUE, but an error to call it if
967 * @c FALSE is returned.
970 gboolean purple_conv_custom_smiley_add(PurpleConversation *conv, const char *smile,
971 const char *cksum_type, const char *chksum,
976 * Updates the image associated with the current smiley.
978 * @param conv The conversation associated with the smiley.
979 * @param smile The text associated with the smiley.
980 * @param data The actual image data.
981 * @param size The length of the data.
984 void purple_conv_custom_smiley_write(PurpleConversation *conv,
990 * Close the custom smiley, all data has been written with
991 * purple_conv_custom_smiley_write, and it is no longer valid
992 * to call that function on that smiley.
994 * @param conv The purple conversation associated with the smiley.
995 * @param smile The text associated with the smiley
998 void purple_conv_custom_smiley_close(PurpleConversation *conv, const char *smile);
1003 /**************************************************************************/
1004 /** @name Chat Conversation API */
1005 /**************************************************************************/
1009 * Gets a chat's parent conversation.
1011 * @param chat The chat.
1013 * @return The parent conversation.
1015 PurpleConversation *purple_conv_chat_get_conversation(const PurpleConvChat *chat);
1018 * Sets the list of users in the chat room.
1020 * @note Calling this function will not update the display of the users.
1021 * Please use purple_conv_chat_add_user(), purple_conv_chat_add_users(),
1022 * purple_conv_chat_remove_user(), and purple_conv_chat_remove_users() instead.
1024 * @param chat The chat.
1025 * @param users The list of users.
1027 * @return The list passed.
1029 GList *purple_conv_chat_set_users(PurpleConvChat *chat, GList *users);
1032 * Returns a list of users in the chat room.
1034 * @param chat The chat.
1036 * @constreturn The list of users.
1038 GList *purple_conv_chat_get_users(const PurpleConvChat *chat);
1041 * Ignores a user in a chat room.
1043 * @param chat The chat.
1044 * @param name The name of the user.
1046 void purple_conv_chat_ignore(PurpleConvChat *chat, const char *name);
1049 * Unignores a user in a chat room.
1051 * @param chat The chat.
1052 * @param name The name of the user.
1054 void purple_conv_chat_unignore(PurpleConvChat *chat, const char *name);
1057 * Sets the list of ignored users in the chat room.
1059 * @param chat The chat.
1060 * @param ignored The list of ignored users.
1062 * @return The list passed.
1064 GList *purple_conv_chat_set_ignored(PurpleConvChat *chat, GList *ignored);
1067 * Returns the list of ignored users in the chat room.
1069 * @param chat The chat.
1071 * @constreturn The list of ignored users.
1073 GList *purple_conv_chat_get_ignored(const PurpleConvChat *chat);
1076 * Returns the actual name of the specified ignored user, if it exists in
1079 * If the user found contains a prefix, such as '+' or '\@', this is also
1080 * returned. The username passed to the function does not have to have this
1083 * @param chat The chat.
1084 * @param user The user to check in the ignore list.
1086 * @return The ignored user if found, complete with prefixes, or @c NULL
1089 const char *purple_conv_chat_get_ignored_user(const PurpleConvChat *chat,
1093 * Returns @c TRUE if the specified user is ignored.
1095 * @param chat The chat.
1096 * @param user The user.
1098 * @return @c TRUE if the user is in the ignore list; @c FALSE otherwise.
1100 gboolean purple_conv_chat_is_user_ignored(const PurpleConvChat *chat,
1104 * Sets the chat room's topic.
1106 * @param chat The chat.
1107 * @param who The user that set the topic.
1108 * @param topic The topic.
1110 void purple_conv_chat_set_topic(PurpleConvChat *chat, const char *who,
1114 * Returns the chat room's topic.
1116 * @param chat The chat.
1118 * @return The chat's topic.
1120 const char *purple_conv_chat_get_topic(const PurpleConvChat *chat);
1123 * Sets the chat room's ID.
1125 * @param chat The chat.
1128 void purple_conv_chat_set_id(PurpleConvChat *chat, int id);
1131 * Returns the chat room's ID.
1133 * @param chat The chat.
1137 int purple_conv_chat_get_id(const PurpleConvChat *chat);
1142 * @param chat The chat.
1143 * @param who The user who sent the message.
1144 * @param message The message to write.
1145 * @param flags The flags.
1146 * @param mtime The time the message was sent.
1148 void purple_conv_chat_write(PurpleConvChat *chat, const char *who,
1149 const char *message, PurpleMessageFlags flags,
1153 * Sends a message to this chat conversation.
1155 * @param chat The chat.
1156 * @param message The message to send.
1158 void purple_conv_chat_send(PurpleConvChat *chat, const char *message);
1161 * Sends a message to this chat conversation with specified flags.
1163 * @param chat The chat.
1164 * @param message The message to send.
1165 * @param flags The PurpleMessageFlags flags to use.
1167 void purple_conv_chat_send_with_flags(PurpleConvChat *chat, const char *message, PurpleMessageFlags flags);
1170 * Adds a user to a chat.
1172 * @param chat The chat.
1173 * @param user The user to add.
1174 * @param extra_msg An extra message to display with the join message.
1175 * @param flags The users flags
1176 * @param new_arrival Decides whether or not to show a join notice.
1178 void purple_conv_chat_add_user(PurpleConvChat *chat, const char *user,
1179 const char *extra_msg, PurpleConvChatBuddyFlags flags,
1180 gboolean new_arrival);
1183 * Adds a list of users to a chat.
1185 * The data is copied from @a users, @a extra_msgs, and @a flags, so it is up to
1186 * the caller to free this list after calling this function.
1188 * @param chat The chat.
1189 * @param users The list of users to add.
1190 * @param extra_msgs An extra message to display with the join message for each
1191 * user. This list may be shorter than @a users, in which
1192 * case, the users after the end of extra_msgs will not have
1193 * an extra message. By extension, this means that extra_msgs
1194 * can simply be @c NULL and none of the users will have an
1196 * @param flags The list of flags for each user.
1197 * @param new_arrivals Decides whether or not to show join notices.
1199 void purple_conv_chat_add_users(PurpleConvChat *chat, GList *users, GList *extra_msgs,
1200 GList *flags, gboolean new_arrivals);
1203 * Renames a user in a chat.
1205 * @param chat The chat.
1206 * @param old_user The old username.
1207 * @param new_user The new username.
1209 void purple_conv_chat_rename_user(PurpleConvChat *chat, const char *old_user,
1210 const char *new_user);
1213 * Removes a user from a chat, optionally with a reason.
1215 * It is up to the developer to free this list after calling this function.
1217 * @param chat The chat.
1218 * @param user The user that is being removed.
1219 * @param reason The optional reason given for the removal. Can be @c NULL.
1221 void purple_conv_chat_remove_user(PurpleConvChat *chat, const char *user,
1222 const char *reason);
1225 * Removes a list of users from a chat, optionally with a single reason.
1227 * @param chat The chat.
1228 * @param users The users that are being removed.
1229 * @param reason The optional reason given for the removal. Can be @c NULL.
1231 void purple_conv_chat_remove_users(PurpleConvChat *chat, GList *users,
1232 const char *reason);
1235 * Finds a user in a chat
1237 * @param chat The chat.
1238 * @param user The user to look for.
1240 * @return TRUE if the user is in the chat, FALSE if not
1242 gboolean purple_conv_chat_find_user(PurpleConvChat *chat, const char *user);
1245 * Set a users flags in a chat
1247 * @param chat The chat.
1248 * @param user The user to update.
1249 * @param flags The new flags.
1251 void purple_conv_chat_user_set_flags(PurpleConvChat *chat, const char *user,
1252 PurpleConvChatBuddyFlags flags);
1255 * Get the flags for a user in a chat
1257 * @param chat The chat.
1258 * @param user The user to find the flags for
1260 * @return The flags for the user
1262 PurpleConvChatBuddyFlags purple_conv_chat_user_get_flags(PurpleConvChat *chat,
1266 * Clears all users from a chat.
1268 * @param chat The chat.
1270 void purple_conv_chat_clear_users(PurpleConvChat *chat);
1273 * Sets your nickname (used for hilighting) for a chat.
1275 * @param chat The chat.
1276 * @param nick The nick.
1278 void purple_conv_chat_set_nick(PurpleConvChat *chat, const char *nick);
1281 * Gets your nickname (used for hilighting) for a chat.
1283 * @param chat The chat.
1286 const char *purple_conv_chat_get_nick(PurpleConvChat *chat);
1289 * Finds a chat with the specified chat ID.
1291 * @param gc The purple_connection.
1292 * @param id The chat ID.
1294 * @return The chat conversation.
1296 PurpleConversation *purple_find_chat(const PurpleConnection *gc, int id);
1299 * Lets the core know we left a chat, without destroying it.
1300 * Called from serv_got_chat_left().
1302 * @param chat The chat.
1304 void purple_conv_chat_left(PurpleConvChat *chat);
1307 * Invite a user to a chat.
1308 * The user will be prompted to enter the user's name or a message if one is
1311 * @param chat The chat.
1312 * @param user The user to invite to the chat.
1313 * @param message The message to send with the invitation.
1314 * @param confirm Prompt before sending the invitation. The user is always
1315 * prompted if either #user or #message is @c NULL.
1319 void purple_conv_chat_invite_user(PurpleConvChat *chat, const char *user,
1320 const char *message, gboolean confirm);
1323 * Returns true if we're no longer in this chat,
1324 * and just left the window open.
1326 * @param chat The chat.
1328 * @return @c TRUE if we left the chat already, @c FALSE if
1329 * we're still there.
1331 gboolean purple_conv_chat_has_left(PurpleConvChat *chat);
1334 * Creates a new chat buddy
1336 * @param name The name.
1337 * @param alias The alias.
1338 * @param flags The flags.
1340 * @return The new chat buddy
1342 PurpleConvChatBuddy *purple_conv_chat_cb_new(const char *name, const char *alias,
1343 PurpleConvChatBuddyFlags flags);
1346 * Find a chat buddy in a chat
1348 * @param chat The chat.
1349 * @param name The name of the chat buddy to find.
1351 PurpleConvChatBuddy *purple_conv_chat_cb_find(PurpleConvChat *chat, const char *name);
1354 * Get the name of a chat buddy
1356 * @param cb The chat buddy.
1358 * @return The name of the chat buddy.
1360 const char *purple_conv_chat_cb_get_name(PurpleConvChatBuddy *cb);
1363 * Get an attribute of a chat buddy
1365 * @param cb The chat buddy.
1366 * @param key The key of the attribute.
1368 * @return The value of the attribute key.
1370 const char *purple_conv_chat_cb_get_attribute(PurpleConvChatBuddy *cb, const char *key);
1373 * Get the keys of all atributes of a chat buddy
1375 * @param cb The chat buddy.
1377 * @return A list of the attributes of a chat buddy.
1379 GList *purple_conv_chat_cb_get_attribute_keys(PurpleConvChatBuddy *cb);
1382 * Set an attribute of a chat buddy
1384 * @param chat The chat.
1385 * @param cb The chat buddy.
1386 * @param key The key of the attribute.
1387 * @param value The value of the attribute.
1389 void purple_conv_chat_cb_set_attribute(PurpleConvChat *chat, PurpleConvChatBuddy *cb, const char *key, const char *value);
1392 * Set attributes of a chat buddy
1394 * @param chat The chat.
1395 * @param cb The chat buddy.
1396 * @param keys A GList of the keys.
1397 * @param values A GList of the values.
1400 purple_conv_chat_cb_set_attributes(PurpleConvChat *chat, PurpleConvChatBuddy *cb, GList *keys, GList *values);
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_ */