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 typedef struct _PurpleChatUser PurpleChatUser
;
58 * PurpleIMTypingState:
59 * @PURPLE_IM_NOT_TYPING: Not typing.
60 * @PURPLE_IM_TYPING: Currently typing.
61 * @PURPLE_IM_TYPED: Stopped typing momentarily.
63 * The typing state of a user.
67 PURPLE_IM_NOT_TYPING
= 0,
71 } PurpleIMTypingState
;
74 * PurpleChatUserFlags:
75 * @PURPLE_CHAT_USER_NONE: No flags
76 * @PURPLE_CHAT_USER_VOICE: Voiced user or "Participant"
77 * @PURPLE_CHAT_USER_HALFOP: Half-op
78 * @PURPLE_CHAT_USER_OP: Channel Op or Moderator
79 * @PURPLE_CHAT_USER_FOUNDER: Channel Founder
80 * @PURPLE_CHAT_USER_TYPING: Currently typing
81 * @PURPLE_CHAT_USER_AWAY: Currently away.
83 * Flags applicable to users in Chats.
85 typedef enum /*< flags >*/
87 PURPLE_CHAT_USER_NONE
= 0x0000,
88 PURPLE_CHAT_USER_VOICE
= 0x0001,
89 PURPLE_CHAT_USER_HALFOP
= 0x0002,
90 PURPLE_CHAT_USER_OP
= 0x0004,
91 PURPLE_CHAT_USER_FOUNDER
= 0x0008,
92 PURPLE_CHAT_USER_TYPING
= 0x0010,
93 PURPLE_CHAT_USER_AWAY
= 0x0020
95 } PurpleChatUserFlags
;
97 #include "conversation.h"
99 /**************************************************************************/
100 /* PurpleIMConversation */
101 /**************************************************************************/
103 * PurpleIMConversation:
105 * Structure representing an IM conversation instance.
107 struct _PurpleIMConversation
109 PurpleConversation parent_object
;
113 * PurpleIMConversationClass:
115 * Base class for all #PurpleIMConversation's
117 struct _PurpleIMConversationClass
{
118 PurpleConversationClass parent_class
;
121 void (*_purple_reserved1
)(void);
122 void (*_purple_reserved2
)(void);
123 void (*_purple_reserved3
)(void);
124 void (*_purple_reserved4
)(void);
127 /**************************************************************************/
128 /* PurpleChatConversation */
129 /**************************************************************************/
131 * PurpleChatConversation:
133 * Structure representing a chat conversation instance.
135 struct _PurpleChatConversation
137 PurpleConversation parent_object
;
141 * PurpleChatConversationClass:
143 * Base class for all #PurpleChatConversation's
145 struct _PurpleChatConversationClass
{
146 PurpleConversationClass parent_class
;
149 void (*_purple_reserved1
)(void);
150 void (*_purple_reserved2
)(void);
151 void (*_purple_reserved3
)(void);
152 void (*_purple_reserved4
)(void);
157 /**************************************************************************/
158 /* IM Conversation API */
159 /**************************************************************************/
162 * purple_im_conversation_get_type:
164 * Returns: The #GType for the IMConversation object.
166 GType
purple_im_conversation_get_type(void);
169 * purple_im_conversation_new:
170 * @account: The account opening the conversation window on the purple
172 * @name: Name of the buddy.
174 * Creates a new IM conversation.
176 * Returns: The new conversation.
178 PurpleIMConversation
*purple_im_conversation_new(PurpleAccount
*account
,
182 * purple_im_conversation_set_icon:
184 * @icon: The buddy icon.
186 * Sets the IM's buddy icon.
188 * This should only be called from within Purple. You probably want to
189 * call purple_buddy_icon_set_data().
191 * See purple_buddy_icon_set_data().
193 void purple_im_conversation_set_icon(PurpleIMConversation
*im
, PurpleBuddyIcon
*icon
);
196 * purple_im_conversation_get_icon:
199 * Returns the IM's buddy icon.
201 * Returns: The buddy icon.
203 PurpleBuddyIcon
*purple_im_conversation_get_icon(PurpleIMConversation
*im
);
206 * purple_im_conversation_set_typing_state:
208 * @state: The typing state.
210 * Sets the IM's typing state.
212 void purple_im_conversation_set_typing_state(PurpleIMConversation
*im
, PurpleIMTypingState state
);
215 * purple_im_conversation_get_typing_state:
218 * Returns the IM's typing state.
220 * Returns: The IM's typing state.
222 PurpleIMTypingState
purple_im_conversation_get_typing_state(PurpleIMConversation
*im
);
225 * purple_im_conversation_start_typing_timeout:
227 * @timeout: How long in seconds to wait before setting the typing state
228 * to PURPLE_IM_NOT_TYPING.
230 * Starts the IM's typing timeout.
232 void purple_im_conversation_start_typing_timeout(PurpleIMConversation
*im
, int timeout
);
235 * purple_im_conversation_stop_typing_timeout:
238 * Stops the IM's typing timeout.
240 void purple_im_conversation_stop_typing_timeout(PurpleIMConversation
*im
);
243 * purple_im_conversation_get_typing_timeout:
246 * Returns the IM's typing timeout.
248 * Returns: The timeout.
250 guint
purple_im_conversation_get_typing_timeout(PurpleIMConversation
*im
);
253 * purple_im_conversation_set_type_again:
255 * @val: The number of seconds to wait before allowing another
256 * PURPLE_IM_TYPING message to be sent to the user. Or 0 to
257 * not send another PURPLE_IM_TYPING message.
259 * Sets the quiet-time when no PURPLE_IM_TYPING messages will be sent.
260 * Few protocols need this (maybe only MSN). If the user is still
261 * typing after this quiet-period, then another PURPLE_IM_TYPING message
264 void purple_im_conversation_set_type_again(PurpleIMConversation
*im
, unsigned int val
);
267 * purple_im_conversation_get_type_again:
270 * Returns the time after which another PURPLE_IM_TYPING message should be sent.
272 * Returns: The time in seconds since the epoch. Or 0 if no additional
273 * PURPLE_IM_TYPING message should be sent.
275 time_t purple_im_conversation_get_type_again(PurpleIMConversation
*im
);
278 * purple_im_conversation_start_send_typed_timeout:
281 * Starts the IM's type again timeout.
283 void purple_im_conversation_start_send_typed_timeout(PurpleIMConversation
*im
);
286 * purple_im_conversation_stop_send_typed_timeout:
289 * Stops the IM's type again timeout.
291 void purple_im_conversation_stop_send_typed_timeout(PurpleIMConversation
*im
);
294 * purple_im_conversation_get_send_typed_timeout:
297 * Returns the IM's type again timeout interval.
299 * Returns: The type again timeout interval.
301 guint
purple_im_conversation_get_send_typed_timeout(PurpleIMConversation
*im
);
304 * purple_im_conversation_update_typing:
307 * Updates the visual typing notification for an IM conversation.
309 void purple_im_conversation_update_typing(PurpleIMConversation
*im
);
311 /**************************************************************************/
312 /* Chat Conversation API */
313 /**************************************************************************/
316 * purple_chat_conversation_get_type:
318 * Returns: The #GType for the ChatConversation object.
320 GType
purple_chat_conversation_get_type(void);
323 * purple_chat_conversation_new:
324 * @account: The account opening the conversation window on the purple
326 * @name: The name of the conversation.
328 * Creates a new chat conversation.
330 * Returns: The new conversation.
332 PurpleChatConversation
*purple_chat_conversation_new(PurpleAccount
*account
,
336 * purple_chat_conversation_get_users:
339 * Returns a list of users in the chat room. The members of the list
340 * are PurpleChatUser objects.
342 * Returns: (element-type PurpleChatUser) (transfer container):
343 * The list of users. Use g_list_free() when done
346 GList
*purple_chat_conversation_get_users(PurpleChatConversation
*chat
);
349 * purple_chat_conversation_get_users_count:
352 * Returns count of users in the chat room.
354 * Returns: The count of users in the chat room.
357 purple_chat_conversation_get_users_count(PurpleChatConversation
*chat
);
360 * purple_chat_conversation_ignore:
362 * @name: The name of the user.
364 * Ignores a user in a chat room.
366 void purple_chat_conversation_ignore(PurpleChatConversation
*chat
, const char *name
);
369 * purple_chat_conversation_unignore:
371 * @name: The name of the user.
373 * Unignores a user in a chat room.
375 void purple_chat_conversation_unignore(PurpleChatConversation
*chat
, const char *name
);
378 * purple_chat_conversation_set_ignored:
380 * @ignored: (element-type char*):
381 * The list of ignored users.
383 * Sets the list of ignored users in the chat room.
385 * Returns: (element-type char*) (transfer none):
388 GList
*purple_chat_conversation_set_ignored(PurpleChatConversation
*chat
, GList
*ignored
);
391 * purple_chat_conversation_get_ignored:
394 * Returns the list of ignored users in the chat room.
396 * Returns: (element-type char*) (transfer none):
397 * The list of ignored users.
399 GList
*purple_chat_conversation_get_ignored(PurpleChatConversation
*chat
);
402 * purple_chat_conversation_get_ignored_user:
404 * @user: The user to check in the ignore list.
406 * Returns the actual name of the specified ignored user, if it exists in
409 * If the user found contains a prefix, such as '+' or '\@', this is also
410 * returned. The username passed to the function does not have to have this
413 * Returns: The ignored user if found, complete with prefixes, or %NULL
416 const char *purple_chat_conversation_get_ignored_user(PurpleChatConversation
*chat
,
420 * purple_chat_conversation_is_ignored_user:
424 * Returns %TRUE if the specified user is ignored.
426 * Returns: %TRUE if the user is in the ignore list; %FALSE otherwise.
428 gboolean
purple_chat_conversation_is_ignored_user(PurpleChatConversation
*chat
,
432 * purple_chat_conversation_set_topic:
434 * @who: The user that set the topic.
437 * Sets the chat room's topic.
439 void purple_chat_conversation_set_topic(PurpleChatConversation
*chat
, const char *who
,
443 * purple_chat_conversation_get_topic:
446 * Returns the chat room's topic.
448 * Returns: The chat's topic.
450 const char *purple_chat_conversation_get_topic(PurpleChatConversation
*chat
);
453 * purple_chat_conversation_get_topic_who:
456 * Returns who set the chat room's topic.
458 * Returns: Who set the topic.
460 const char *purple_chat_conversation_get_topic_who(PurpleChatConversation
*chat
);
463 * purple_chat_conversation_set_id:
467 * Sets the chat room's ID.
469 void purple_chat_conversation_set_id(PurpleChatConversation
*chat
, int id
);
472 * purple_chat_conversation_get_id:
475 * Returns the chat room's ID.
479 int purple_chat_conversation_get_id(PurpleChatConversation
*chat
);
482 * purple_chat_conversation_add_user:
484 * @user: The user to add.
485 * @extra_msg: An extra message to display with the join message.
486 * @flags: The users flags
487 * @new_arrival: Decides whether or not to show a join notice.
489 * Adds a user to a chat.
491 void purple_chat_conversation_add_user(PurpleChatConversation
*chat
, const char *user
,
492 const char *extra_msg
, PurpleChatUserFlags flags
,
493 gboolean new_arrival
);
496 * purple_chat_conversation_add_users:
498 * @users: (element-type char*):
499 * The list of users to add.
500 * @extra_msgs: (element-type char*) (nullable):
501 * An extra message to display with the join message for each
502 * user. This list may be shorter than @users, in which
503 * case, the users after the end of extra_msgs will not have
504 * an extra message. By extension, this means that extra_msgs
505 * can simply be %NULL and none of the users will have an
507 * @flags: (element-type PurpleChatUserFlags):
508 * The list of flags for each user.
509 * This list data should be an int converted to pointer using
510 * GINT_TO_POINTER(flag)
511 * @new_arrivals: Decides whether or not to show join notices.
513 * Adds a list of users to a chat.
515 * The data is copied from @users, @extra_msgs, and @flags, so it is up to
516 * the caller to free this list after calling this function.
518 void purple_chat_conversation_add_users(PurpleChatConversation
*chat
,
519 GList
*users
, GList
*extra_msgs
, GList
*flags
, gboolean new_arrivals
);
522 * purple_chat_conversation_rename_user:
524 * @old_user: The old username.
525 * @new_user: The new username.
527 * Renames a user in a chat.
529 void purple_chat_conversation_rename_user(PurpleChatConversation
*chat
,
530 const char *old_user
, const char *new_user
);
533 * purple_chat_conversation_remove_user:
535 * @user: The user that is being removed.
536 * @reason: The optional reason given for the removal. Can be %NULL.
538 * Removes a user from a chat, optionally with a reason.
540 * It is up to the developer to free this list after calling this function.
542 void purple_chat_conversation_remove_user(PurpleChatConversation
*chat
,
543 const char *user
, const char *reason
);
546 * purple_chat_conversation_remove_users:
548 * @users: (element-type char*)
549 * The users that are being removed.
550 * @reason: The optional reason given for the removal. Can be %NULL.
552 * Removes a list of users from a chat, optionally with a single reason.
554 void purple_chat_conversation_remove_users(PurpleChatConversation
*chat
,
555 GList
*users
, const char *reason
);
558 * purple_chat_conversation_has_user:
560 * @user: The user to look for.
562 * Checks if a user is in a chat
564 * Returns: TRUE if the user is in the chat, FALSE if not
566 gboolean
purple_chat_conversation_has_user(PurpleChatConversation
*chat
,
570 * purple_chat_conversation_clear_users:
573 * Clears all users from a chat.
575 void purple_chat_conversation_clear_users(PurpleChatConversation
*chat
);
578 * purple_chat_conversation_set_nick:
582 * Sets your nickname (used for hilighting) for a chat.
584 void purple_chat_conversation_set_nick(PurpleChatConversation
*chat
,
588 * purple_chat_conversation_get_nick:
591 * Gets your nickname (used for hilighting) for a chat.
595 const char *purple_chat_conversation_get_nick(PurpleChatConversation
*chat
);
598 * purple_chat_conversation_leave:
601 * Lets the core know we left a chat, without destroying it.
602 * Called from purple_serv_got_chat_left().
604 void purple_chat_conversation_leave(PurpleChatConversation
*chat
);
607 * purple_chat_conversation_find_user:
609 * @name: The name of the chat user to find.
611 * Find a chat user in a chat
613 * Returns: (transfer none):
614 * The @PurpleChatUser with the name refered by @name.
616 PurpleChatUser
*purple_chat_conversation_find_user(PurpleChatConversation
*chat
,
620 * purple_chat_conversation_invite_user:
622 * @user: The user to invite to the chat.
623 * @message: The message to send with the invitation.
624 * @confirm: Prompt before sending the invitation. The user is always
625 * prompted if either \a user or \a message is %NULL.
627 * Invite a user to a chat.
628 * The user will be prompted to enter the user's name or a message if one is
631 void purple_chat_conversation_invite_user(PurpleChatConversation
*chat
,
632 const char *user
, const char *message
, gboolean confirm
);
635 * purple_chat_conversation_has_left:
638 * Returns true if we're no longer in this chat,
639 * and just left the window open.
641 * Returns: %TRUE if we left the chat already, %FALSE if
644 gboolean
purple_chat_conversation_has_left(PurpleChatConversation
*chat
);
646 /**************************************************************************/
647 /* Chat Conversation User API */
648 /**************************************************************************/
650 #define PURPLE_TYPE_CHAT_USER purple_chat_user_get_type()
653 * purple_chat_user_get_type:
655 * Returns: The #GType for the ChatConversationBuddy object.
657 G_DECLARE_FINAL_TYPE(PurpleChatUser
, purple_chat_user
, PURPLE
, CHAT_USER
,
661 * purple_chat_user_set_chat:
663 * @chat: The chat conversation that the buddy belongs to.
665 * Set the chat conversation associated with this chat user.
667 void purple_chat_user_set_chat(PurpleChatUser
*cb
,
668 PurpleChatConversation
*chat
);
671 * purple_chat_user_get_chat:
672 * @cb: The chat user.
674 * Get the chat conversation associated with this chat user.
676 * Returns: (transfer none):
677 * The chat conversation that the buddy belongs to.
679 PurpleChatConversation
*purple_chat_user_get_chat(PurpleChatUser
*cb
);
682 * purple_chat_user_new:
683 * @chat: The chat that the buddy belongs to.
688 * Creates a new chat user
690 * Returns: The new chat user
692 PurpleChatUser
*purple_chat_user_new(PurpleChatConversation
*chat
,
693 const char *name
, const char *alias
, PurpleChatUserFlags flags
);
696 * purple_chat_user_set_ui_data:
698 * @ui_data: A pointer to associate with this chat user.
700 * Set the UI data associated with this chat user.
702 void purple_chat_user_set_ui_data(PurpleChatUser
*cb
, gpointer ui_data
);
705 * purple_chat_user_get_ui_data:
706 * @cb: The chat user.
708 * Get the UI data associated with this chat user.
710 * Returns: (transfer none):
711 * The UI data associated with this chat user. This is a
712 * convenience field provided to the UIs--it is not
713 * used by the libpurple core.
715 gpointer
purple_chat_user_get_ui_data(PurpleChatUser
*cb
);
718 * purple_chat_user_get_alias:
719 * @cb: The chat user.
721 * Get the alias of a chat user
723 * Returns: The alias of the chat user.
725 const char *purple_chat_user_get_alias(PurpleChatUser
*cb
);
728 * purple_chat_user_get_name:
729 * @cb: The chat user.
731 * Get the name of a chat user
733 * Returns: The name of the chat user.
735 const char *purple_chat_user_get_name(PurpleChatUser
*cb
);
738 * purple_chat_user_set_flags:
739 * @cb: The chat user.
740 * @flags: The new flags.
742 * Set the flags of a chat user.
744 void purple_chat_user_set_flags(PurpleChatUser
*cb
, PurpleChatUserFlags flags
);
747 * purple_chat_user_get_flags:
748 * @cb: The chat user.
750 * Get the flags of a chat user.
752 * Returns: The flags of the chat user.
754 PurpleChatUserFlags
purple_chat_user_get_flags(PurpleChatUser
*cb
);
757 * purple_chat_user_is_buddy:
758 * @cb: The chat user.
760 * Indicates if this chat user is on the buddy list.
762 * Returns: TRUE if the chat user is on the buddy list.
764 gboolean
purple_chat_user_is_buddy(PurpleChatUser
*cb
);
768 #endif /* PURPLE_CONVERSATION_TYPES_H */