3 * Purple is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
22 #ifndef _PURPLE_CONVERSATION_TYPES_H_
23 #define _PURPLE_CONVERSATION_TYPES_H_
25 * SECTION:conversationtypes
26 * @section_id: libpurple-conversationtypes
27 * @short_description: <filename>conversationtypes.h</filename>
28 * @title: Chat and IM Conversation Objects
31 /**************************************************************************/
33 /**************************************************************************/
35 #define PURPLE_TYPE_IM_CONVERSATION (purple_im_conversation_get_type())
36 #define PURPLE_IM_CONVERSATION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_IM_CONVERSATION, PurpleIMConversation))
37 #define PURPLE_IM_CONVERSATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_IM_CONVERSATION, PurpleIMConversationClass))
38 #define PURPLE_IS_IM_CONVERSATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_IM_CONVERSATION))
39 #define PURPLE_IS_IM_CONVERSATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_IM_CONVERSATION))
40 #define PURPLE_IM_CONVERSATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_IM_CONVERSATION, PurpleIMConversationClass))
42 typedef struct _PurpleIMConversation PurpleIMConversation
;
43 typedef struct _PurpleIMConversationClass PurpleIMConversationClass
;
45 #define PURPLE_TYPE_CHAT_CONVERSATION (purple_chat_conversation_get_type())
46 #define PURPLE_CHAT_CONVERSATION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_CHAT_CONVERSATION, PurpleChatConversation))
47 #define PURPLE_CHAT_CONVERSATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_CHAT_CONVERSATION, PurpleChatConversationClass))
48 #define PURPLE_IS_CHAT_CONVERSATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_CHAT_CONVERSATION))
49 #define PURPLE_IS_CHAT_CONVERSATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_CHAT_CONVERSATION))
50 #define PURPLE_CHAT_CONVERSATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_CHAT_CONVERSATION, PurpleChatConversationClass))
52 typedef struct _PurpleChatConversation PurpleChatConversation
;
53 typedef struct _PurpleChatConversationClass PurpleChatConversationClass
;
55 #define PURPLE_TYPE_CHAT_USER (purple_chat_user_get_type())
56 #define PURPLE_CHAT_USER(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_CHAT_USER, PurpleChatUser))
57 #define PURPLE_CHAT_USER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_CHAT_USER, PurpleChatUserClass))
58 #define PURPLE_IS_CHAT_USER(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_CHAT_USER))
59 #define PURPLE_IS_CHAT_USER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_CHAT_USER))
60 #define PURPLE_CHAT_USER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_CHAT_USER, PurpleChatUserClass))
62 typedef struct _PurpleChatUser PurpleChatUser
;
63 typedef struct _PurpleChatUserClass PurpleChatUserClass
;
66 * PurpleIMTypingState:
67 * @PURPLE_IM_NOT_TYPING: Not typing.
68 * @PURPLE_IM_TYPING: Currently typing.
69 * @PURPLE_IM_TYPED: Stopped typing momentarily.
71 * The typing state of a user.
75 PURPLE_IM_NOT_TYPING
= 0,
79 } PurpleIMTypingState
;
82 * PurpleChatUserFlags:
83 * @PURPLE_CHAT_USER_NONE: No flags
84 * @PURPLE_CHAT_USER_VOICE: Voiced user or "Participant"
85 * @PURPLE_CHAT_USER_HALFOP: Half-op
86 * @PURPLE_CHAT_USER_OP: Channel Op or Moderator
87 * @PURPLE_CHAT_USER_FOUNDER: Channel Founder
88 * @PURPLE_CHAT_USER_TYPING: Currently typing
89 * @PURPLE_CHAT_USER_AWAY: Currently away.
91 * Flags applicable to users in Chats.
93 typedef enum /*< flags >*/
95 PURPLE_CHAT_USER_NONE
= 0x0000,
96 PURPLE_CHAT_USER_VOICE
= 0x0001,
97 PURPLE_CHAT_USER_HALFOP
= 0x0002,
98 PURPLE_CHAT_USER_OP
= 0x0004,
99 PURPLE_CHAT_USER_FOUNDER
= 0x0008,
100 PURPLE_CHAT_USER_TYPING
= 0x0010,
101 PURPLE_CHAT_USER_AWAY
= 0x0020
103 } PurpleChatUserFlags
;
105 #include "conversation.h"
107 /**************************************************************************/
108 /* PurpleIMConversation */
109 /**************************************************************************/
111 * PurpleIMConversation:
113 * Structure representing an IM conversation instance.
115 struct _PurpleIMConversation
117 PurpleConversation parent_object
;
121 * PurpleIMConversationClass:
123 * Base class for all #PurpleIMConversation's
125 struct _PurpleIMConversationClass
{
126 PurpleConversationClass parent_class
;
129 void (*_purple_reserved1
)(void);
130 void (*_purple_reserved2
)(void);
131 void (*_purple_reserved3
)(void);
132 void (*_purple_reserved4
)(void);
135 /**************************************************************************/
136 /* PurpleChatConversation */
137 /**************************************************************************/
139 * PurpleChatConversation:
141 * Structure representing a chat conversation instance.
143 struct _PurpleChatConversation
145 PurpleConversation parent_object
;
149 * PurpleChatConversationClass:
151 * Base class for all #PurpleChatConversation's
153 struct _PurpleChatConversationClass
{
154 PurpleConversationClass parent_class
;
157 void (*_purple_reserved1
)(void);
158 void (*_purple_reserved2
)(void);
159 void (*_purple_reserved3
)(void);
160 void (*_purple_reserved4
)(void);
163 /**************************************************************************/
165 /**************************************************************************/
168 * @ui_data: The UI data associated with this chat user. This is a convenience
169 * field provided to the UIs -- it is not used by the libpurple core.
171 * Structure representing a chat user instance.
173 struct _PurpleChatUser
182 * PurpleChatUserClass:
184 * Base class for all #PurpleChatUser's
186 struct _PurpleChatUserClass
{
187 GObjectClass parent_class
;
190 void (*_purple_reserved1
)(void);
191 void (*_purple_reserved2
)(void);
192 void (*_purple_reserved3
)(void);
193 void (*_purple_reserved4
)(void);
198 /**************************************************************************/
199 /* IM Conversation API */
200 /**************************************************************************/
203 * purple_im_conversation_get_type:
205 * Returns: The #GType for the IMConversation object.
207 GType
purple_im_conversation_get_type(void);
210 * purple_im_conversation_new:
211 * @account: The account opening the conversation window on the purple
213 * @name: Name of the buddy.
215 * Creates a new IM conversation.
217 * Returns: The new conversation.
219 PurpleIMConversation
*purple_im_conversation_new(PurpleAccount
*account
,
223 * purple_im_conversation_set_icon:
225 * @icon: The buddy icon.
227 * Sets the IM's buddy icon.
229 * This should only be called from within Purple. You probably want to
230 * call purple_buddy_icon_set_data().
232 * See purple_buddy_icon_set_data().
234 void purple_im_conversation_set_icon(PurpleIMConversation
*im
, PurpleBuddyIcon
*icon
);
237 * purple_im_conversation_get_icon:
240 * Returns the IM's buddy icon.
242 * Returns: The buddy icon.
244 PurpleBuddyIcon
*purple_im_conversation_get_icon(const PurpleIMConversation
*im
);
247 * purple_im_conversation_set_typing_state:
249 * @state: The typing state.
251 * Sets the IM's typing state.
253 void purple_im_conversation_set_typing_state(PurpleIMConversation
*im
, PurpleIMTypingState state
);
256 * purple_im_conversation_get_typing_state:
259 * Returns the IM's typing state.
261 * Returns: The IM's typing state.
263 PurpleIMTypingState
purple_im_conversation_get_typing_state(const PurpleIMConversation
*im
);
266 * purple_im_conversation_start_typing_timeout:
268 * @timeout: How long in seconds to wait before setting the typing state
269 * to PURPLE_IM_NOT_TYPING.
271 * Starts the IM's typing timeout.
273 void purple_im_conversation_start_typing_timeout(PurpleIMConversation
*im
, int timeout
);
276 * purple_im_conversation_stop_typing_timeout:
279 * Stops the IM's typing timeout.
281 void purple_im_conversation_stop_typing_timeout(PurpleIMConversation
*im
);
284 * purple_im_conversation_get_typing_timeout:
287 * Returns the IM's typing timeout.
289 * Returns: The timeout.
291 guint
purple_im_conversation_get_typing_timeout(const PurpleIMConversation
*im
);
294 * purple_im_conversation_set_type_again:
296 * @val: The number of seconds to wait before allowing another
297 * PURPLE_IM_TYPING message to be sent to the user. Or 0 to
298 * not send another PURPLE_IM_TYPING message.
300 * Sets the quiet-time when no PURPLE_IM_TYPING messages will be sent.
301 * Few protocols need this (maybe only MSN). If the user is still
302 * typing after this quiet-period, then another PURPLE_IM_TYPING message
305 void purple_im_conversation_set_type_again(PurpleIMConversation
*im
, unsigned int val
);
308 * purple_im_conversation_get_type_again:
311 * Returns the time after which another PURPLE_IM_TYPING message should be sent.
313 * Returns: The time in seconds since the epoch. Or 0 if no additional
314 * PURPLE_IM_TYPING message should be sent.
316 time_t purple_im_conversation_get_type_again(const PurpleIMConversation
*im
);
319 * purple_im_conversation_start_send_typed_timeout:
322 * Starts the IM's type again timeout.
324 void purple_im_conversation_start_send_typed_timeout(PurpleIMConversation
*im
);
327 * purple_im_conversation_stop_send_typed_timeout:
330 * Stops the IM's type again timeout.
332 void purple_im_conversation_stop_send_typed_timeout(PurpleIMConversation
*im
);
335 * purple_im_conversation_get_send_typed_timeout:
338 * Returns the IM's type again timeout interval.
340 * Returns: The type again timeout interval.
342 guint
purple_im_conversation_get_send_typed_timeout(const PurpleIMConversation
*im
);
345 * purple_im_conversation_update_typing:
348 * Updates the visual typing notification for an IM conversation.
350 void purple_im_conversation_update_typing(PurpleIMConversation
*im
);
352 /**************************************************************************/
353 /* Chat Conversation API */
354 /**************************************************************************/
357 * purple_chat_conversation_get_type:
359 * Returns: The #GType for the ChatConversation object.
361 GType
purple_chat_conversation_get_type(void);
364 * purple_chat_conversation_new:
365 * @account: The account opening the conversation window on the purple
367 * @name: The name of the conversation.
369 * Creates a new chat conversation.
371 * Returns: The new conversation.
373 PurpleChatConversation
*purple_chat_conversation_new(PurpleAccount
*account
,
377 * purple_chat_conversation_get_users:
380 * Returns a list of users in the chat room. The members of the list
381 * are PurpleChatUser objects.
383 * Returns: (element-type PurpleChatUser) (transfer container):
384 * The list of users. Use g_list_free() when done
387 GList
*purple_chat_conversation_get_users(const PurpleChatConversation
*chat
);
390 * purple_chat_conversation_get_users_count:
393 * Returns count of users in the chat room.
395 * Returns: The count of users in the chat room.
398 purple_chat_conversation_get_users_count(const PurpleChatConversation
*chat
);
401 * purple_chat_conversation_ignore:
403 * @name: The name of the user.
405 * Ignores a user in a chat room.
407 void purple_chat_conversation_ignore(PurpleChatConversation
*chat
, const char *name
);
410 * purple_chat_conversation_unignore:
412 * @name: The name of the user.
414 * Unignores a user in a chat room.
416 void purple_chat_conversation_unignore(PurpleChatConversation
*chat
, const char *name
);
419 * purple_chat_conversation_set_ignored:
421 * @ignored: (element-type char*):
422 * The list of ignored users.
424 * Sets the list of ignored users in the chat room.
426 * Returns: (element-type char*) (transfer none):
429 GList
*purple_chat_conversation_set_ignored(PurpleChatConversation
*chat
, GList
*ignored
);
432 * purple_chat_conversation_get_ignored:
435 * Returns the list of ignored users in the chat room.
437 * Returns: (element-type char*) (transfer none):
438 * The list of ignored users.
440 GList
*purple_chat_conversation_get_ignored(const PurpleChatConversation
*chat
);
443 * purple_chat_conversation_get_ignored_user:
445 * @user: The user to check in the ignore list.
447 * Returns the actual name of the specified ignored user, if it exists in
450 * If the user found contains a prefix, such as '+' or '\@', this is also
451 * returned. The username passed to the function does not have to have this
454 * Returns: The ignored user if found, complete with prefixes, or %NULL
457 const char *purple_chat_conversation_get_ignored_user(const PurpleChatConversation
*chat
,
461 * purple_chat_conversation_is_ignored_user:
465 * Returns %TRUE if the specified user is ignored.
467 * Returns: %TRUE if the user is in the ignore list; %FALSE otherwise.
469 gboolean
purple_chat_conversation_is_ignored_user(const PurpleChatConversation
*chat
,
473 * purple_chat_conversation_set_topic:
475 * @who: The user that set the topic.
478 * Sets the chat room's topic.
480 void purple_chat_conversation_set_topic(PurpleChatConversation
*chat
, const char *who
,
484 * purple_chat_conversation_get_topic:
487 * Returns the chat room's topic.
489 * Returns: The chat's topic.
491 const char *purple_chat_conversation_get_topic(const PurpleChatConversation
*chat
);
494 * purple_chat_conversation_get_topic_who:
497 * Returns who set the chat room's topic.
499 * Returns: Who set the topic.
501 const char *purple_chat_conversation_get_topic_who(const PurpleChatConversation
*chat
);
504 * purple_chat_conversation_set_id:
508 * Sets the chat room's ID.
510 void purple_chat_conversation_set_id(PurpleChatConversation
*chat
, int id
);
513 * purple_chat_conversation_get_id:
516 * Returns the chat room's ID.
520 int purple_chat_conversation_get_id(const PurpleChatConversation
*chat
);
523 * purple_chat_conversation_add_user:
525 * @user: The user to add.
526 * @extra_msg: An extra message to display with the join message.
527 * @flags: The users flags
528 * @new_arrival: Decides whether or not to show a join notice.
530 * Adds a user to a chat.
532 void purple_chat_conversation_add_user(PurpleChatConversation
*chat
, const char *user
,
533 const char *extra_msg
, PurpleChatUserFlags flags
,
534 gboolean new_arrival
);
537 * purple_chat_conversation_add_users:
539 * @users: (element-type char*):
540 * The list of users to add.
541 * @extra_msgs: (element-type char*) (nullable):
542 * An extra message to display with the join message for each
543 * user. This list may be shorter than @users, in which
544 * case, the users after the end of extra_msgs will not have
545 * an extra message. By extension, this means that extra_msgs
546 * can simply be %NULL and none of the users will have an
548 * @flags: (element-type PurpleChatUserFlags):
549 * The list of flags for each user.
550 * This list data should be an int converted to pointer using
551 * GINT_TO_POINTER(flag)
552 * @new_arrivals: Decides whether or not to show join notices.
554 * Adds a list of users to a chat.
556 * The data is copied from @users, @extra_msgs, and @flags, so it is up to
557 * the caller to free this list after calling this function.
559 void purple_chat_conversation_add_users(PurpleChatConversation
*chat
,
560 GList
*users
, GList
*extra_msgs
, GList
*flags
, gboolean new_arrivals
);
563 * purple_chat_conversation_rename_user:
565 * @old_user: The old username.
566 * @new_user: The new username.
568 * Renames a user in a chat.
570 void purple_chat_conversation_rename_user(PurpleChatConversation
*chat
,
571 const char *old_user
, const char *new_user
);
574 * purple_chat_conversation_remove_user:
576 * @user: The user that is being removed.
577 * @reason: The optional reason given for the removal. Can be %NULL.
579 * Removes a user from a chat, optionally with a reason.
581 * It is up to the developer to free this list after calling this function.
583 void purple_chat_conversation_remove_user(PurpleChatConversation
*chat
,
584 const char *user
, const char *reason
);
587 * purple_chat_conversation_remove_users:
589 * @users: (element-type char*)
590 * The users that are being removed.
591 * @reason: The optional reason given for the removal. Can be %NULL.
593 * Removes a list of users from a chat, optionally with a single reason.
595 void purple_chat_conversation_remove_users(PurpleChatConversation
*chat
,
596 GList
*users
, const char *reason
);
599 * purple_chat_conversation_has_user:
601 * @user: The user to look for.
603 * Checks if a user is in a chat
605 * Returns: TRUE if the user is in the chat, FALSE if not
607 gboolean
purple_chat_conversation_has_user(PurpleChatConversation
*chat
,
611 * purple_chat_conversation_clear_users:
614 * Clears all users from a chat.
616 void purple_chat_conversation_clear_users(PurpleChatConversation
*chat
);
619 * purple_chat_conversation_set_nick:
623 * Sets your nickname (used for hilighting) for a chat.
625 void purple_chat_conversation_set_nick(PurpleChatConversation
*chat
,
629 * purple_chat_conversation_get_nick:
632 * Gets your nickname (used for hilighting) for a chat.
636 const char *purple_chat_conversation_get_nick(PurpleChatConversation
*chat
);
639 * purple_chat_conversation_leave:
642 * Lets the core know we left a chat, without destroying it.
643 * Called from purple_serv_got_chat_left().
645 void purple_chat_conversation_leave(PurpleChatConversation
*chat
);
648 * purple_chat_conversation_find_user:
650 * @name: The name of the chat user to find.
652 * Find a chat user in a chat
654 * Returns: (transfer none):
655 * The @PurpleChatUser with the name refered by @name.
657 PurpleChatUser
*purple_chat_conversation_find_user(PurpleChatConversation
*chat
,
661 * purple_chat_conversation_invite_user:
663 * @user: The user to invite to the chat.
664 * @message: The message to send with the invitation.
665 * @confirm: Prompt before sending the invitation. The user is always
666 * prompted if either \a user or \a message is %NULL.
668 * Invite a user to a chat.
669 * The user will be prompted to enter the user's name or a message if one is
672 void purple_chat_conversation_invite_user(PurpleChatConversation
*chat
,
673 const char *user
, const char *message
, gboolean confirm
);
676 * purple_chat_conversation_has_left:
679 * Returns true if we're no longer in this chat,
680 * and just left the window open.
682 * Returns: %TRUE if we left the chat already, %FALSE if
685 gboolean
purple_chat_conversation_has_left(PurpleChatConversation
*chat
);
687 /**************************************************************************/
688 /* Chat Conversation User API */
689 /**************************************************************************/
692 * purple_chat_user_get_type:
694 * Returns: The #GType for the ChatConversationBuddy object.
696 GType
purple_chat_user_get_type(void);
699 * purple_chat_user_set_chat:
701 * @chat: The chat conversation that the buddy belongs to.
703 * Set the chat conversation associated with this chat user.
705 void purple_chat_user_set_chat(PurpleChatUser
*cb
,
706 PurpleChatConversation
*chat
);
709 * purple_chat_user_get_chat:
710 * @cb: The chat user.
712 * Get the chat conversation associated with this chat user.
714 * Returns: (transfer none):
715 * The chat conversation that the buddy belongs to.
717 PurpleChatConversation
*purple_chat_user_get_chat(const PurpleChatUser
*cb
);
720 * purple_chat_user_new:
721 * @chat: The chat that the buddy belongs to.
726 * Creates a new chat user
728 * Returns: The new chat user
730 PurpleChatUser
*purple_chat_user_new(PurpleChatConversation
*chat
,
731 const char *name
, const char *alias
, PurpleChatUserFlags flags
);
734 * purple_chat_user_set_ui_data:
736 * @ui_data: A pointer to associate with this chat user.
738 * Set the UI data associated with this chat user.
740 void purple_chat_user_set_ui_data(PurpleChatUser
*cb
, gpointer ui_data
);
743 * purple_chat_user_get_ui_data:
744 * @cb: The chat user.
746 * Get the UI data associated with this chat user.
748 * Returns: (transfer none):
749 * The UI data associated with this chat user. This is a
750 * convenience field provided to the UIs--it is not
751 * used by the libpurple core.
753 gpointer
purple_chat_user_get_ui_data(const PurpleChatUser
*cb
);
756 * purple_chat_user_get_alias:
757 * @cb: The chat user.
759 * Get the alias of a chat user
761 * Returns: The alias of the chat user.
763 const char *purple_chat_user_get_alias(const PurpleChatUser
*cb
);
766 * purple_chat_user_get_name:
767 * @cb: The chat user.
769 * Get the name of a chat user
771 * Returns: The name of the chat user.
773 const char *purple_chat_user_get_name(const PurpleChatUser
*cb
);
776 * purple_chat_user_set_flags:
777 * @cb: The chat user.
778 * @flags: The new flags.
780 * Set the flags of a chat user.
782 void purple_chat_user_set_flags(PurpleChatUser
*cb
, PurpleChatUserFlags flags
);
785 * purple_chat_user_get_flags:
786 * @cb: The chat user.
788 * Get the flags of a chat user.
790 * Returns: The flags of the chat user.
792 PurpleChatUserFlags
purple_chat_user_get_flags(const PurpleChatUser
*cb
);
795 * purple_chat_user_is_buddy:
796 * @cb: The chat user.
798 * Indicates if this chat user is on the buddy list.
800 * Returns: TRUE if the chat user is on the buddy list.
802 gboolean
purple_chat_user_is_buddy(const PurpleChatUser
*cb
);
806 #endif /* _PURPLE_CONVERSATION_TYPES_H_ */