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 utf8): The list of ignored users.
382 * Sets the list of ignored users in the chat room.
384 * Returns: (element-type utf8) (transfer none): The list passed.
386 GList
*purple_chat_conversation_set_ignored(PurpleChatConversation
*chat
, GList
*ignored
);
389 * purple_chat_conversation_get_ignored:
392 * Returns the list of ignored users in the chat room.
394 * Returns: (element-type utf8) (transfer none): The list of ignored users.
396 GList
*purple_chat_conversation_get_ignored(PurpleChatConversation
*chat
);
399 * purple_chat_conversation_get_ignored_user:
401 * @user: The user to check in the ignore list.
403 * Returns the actual name of the specified ignored user, if it exists in
406 * If the user found contains a prefix, such as '+' or '\@', this is also
407 * returned. The username passed to the function does not have to have this
410 * Returns: The ignored user if found, complete with prefixes, or %NULL
413 const char *purple_chat_conversation_get_ignored_user(PurpleChatConversation
*chat
,
417 * purple_chat_conversation_is_ignored_user:
421 * Returns %TRUE if the specified user is ignored.
423 * Returns: %TRUE if the user is in the ignore list; %FALSE otherwise.
425 gboolean
purple_chat_conversation_is_ignored_user(PurpleChatConversation
*chat
,
429 * purple_chat_conversation_set_topic:
431 * @who: The user that set the topic.
434 * Sets the chat room's topic.
436 void purple_chat_conversation_set_topic(PurpleChatConversation
*chat
, const char *who
,
440 * purple_chat_conversation_get_topic:
443 * Returns the chat room's topic.
445 * Returns: The chat's topic.
447 const char *purple_chat_conversation_get_topic(PurpleChatConversation
*chat
);
450 * purple_chat_conversation_get_topic_who:
453 * Returns who set the chat room's topic.
455 * Returns: Who set the topic.
457 const char *purple_chat_conversation_get_topic_who(PurpleChatConversation
*chat
);
460 * purple_chat_conversation_set_id:
464 * Sets the chat room's ID.
466 void purple_chat_conversation_set_id(PurpleChatConversation
*chat
, int id
);
469 * purple_chat_conversation_get_id:
472 * Returns the chat room's ID.
476 int purple_chat_conversation_get_id(PurpleChatConversation
*chat
);
479 * purple_chat_conversation_add_user:
481 * @user: The user to add.
482 * @extra_msg: An extra message to display with the join message.
483 * @flags: The users flags
484 * @new_arrival: Decides whether or not to show a join notice.
486 * Adds a user to a chat.
488 void purple_chat_conversation_add_user(PurpleChatConversation
*chat
, const char *user
,
489 const char *extra_msg
, PurpleChatUserFlags flags
,
490 gboolean new_arrival
);
493 * purple_chat_conversation_add_users:
495 * @users: (element-type utf8): The list of users to add.
496 * @extra_msgs: (element-type utf8) (nullable): An extra message to display
497 * with the join message for each user. This list may be shorter
498 * than @users, in which case, the users after the end of
499 * extra_msgs will not have an extra message. By extension, this
500 * means that extra_msgs can simply be %NULL and none of the users
501 * will have an extra message.
502 * @flags: (element-type PurpleChatUserFlags): The list of flags for each user.
503 * This list data should be an int converted to pointer using
504 * GINT_TO_POINTER(flag)
505 * @new_arrivals: Decides whether or not to show join notices.
507 * Adds a list of users to a chat.
509 * The data is copied from @users, @extra_msgs, and @flags, so it is up to
510 * the caller to free this list after calling this function.
512 void purple_chat_conversation_add_users(PurpleChatConversation
*chat
,
513 GList
*users
, GList
*extra_msgs
, GList
*flags
, gboolean new_arrivals
);
516 * purple_chat_conversation_rename_user:
518 * @old_user: The old username.
519 * @new_user: The new username.
521 * Renames a user in a chat.
523 void purple_chat_conversation_rename_user(PurpleChatConversation
*chat
,
524 const char *old_user
, const char *new_user
);
527 * purple_chat_conversation_remove_user:
529 * @user: The user that is being removed.
530 * @reason: The optional reason given for the removal. Can be %NULL.
532 * Removes a user from a chat, optionally with a reason.
534 * It is up to the developer to free this list after calling this function.
536 void purple_chat_conversation_remove_user(PurpleChatConversation
*chat
,
537 const char *user
, const char *reason
);
540 * purple_chat_conversation_remove_users:
542 * @users: (element-type utf8): The users that are being removed.
543 * @reason: The optional reason given for the removal. Can be %NULL.
545 * Removes a list of users from a chat, optionally with a single reason.
547 void purple_chat_conversation_remove_users(PurpleChatConversation
*chat
,
548 GList
*users
, const char *reason
);
551 * purple_chat_conversation_has_user:
553 * @user: The user to look for.
555 * Checks if a user is in a chat
557 * Returns: TRUE if the user is in the chat, FALSE if not
559 gboolean
purple_chat_conversation_has_user(PurpleChatConversation
*chat
,
563 * purple_chat_conversation_clear_users:
566 * Clears all users from a chat.
568 void purple_chat_conversation_clear_users(PurpleChatConversation
*chat
);
571 * purple_chat_conversation_set_nick:
575 * Sets your nickname (used for hilighting) for a chat.
577 void purple_chat_conversation_set_nick(PurpleChatConversation
*chat
,
581 * purple_chat_conversation_get_nick:
584 * Gets your nickname (used for hilighting) for a chat.
588 const char *purple_chat_conversation_get_nick(PurpleChatConversation
*chat
);
591 * purple_chat_conversation_leave:
594 * Lets the core know we left a chat, without destroying it.
595 * Called from purple_serv_got_chat_left().
597 void purple_chat_conversation_leave(PurpleChatConversation
*chat
);
600 * purple_chat_conversation_find_user:
602 * @name: The name of the chat user to find.
604 * Find a chat user in a chat
606 * Returns: (transfer none):
607 * The @PurpleChatUser with the name refered by @name.
609 PurpleChatUser
*purple_chat_conversation_find_user(PurpleChatConversation
*chat
,
613 * purple_chat_conversation_invite_user:
615 * @user: The user to invite to the chat.
616 * @message: The message to send with the invitation.
617 * @confirm: Prompt before sending the invitation. The user is always
618 * prompted if either \a user or \a message is %NULL.
620 * Invite a user to a chat.
621 * The user will be prompted to enter the user's name or a message if one is
624 void purple_chat_conversation_invite_user(PurpleChatConversation
*chat
,
625 const char *user
, const char *message
, gboolean confirm
);
628 * purple_chat_conversation_has_left:
631 * Returns true if we're no longer in this chat,
632 * and just left the window open.
634 * Returns: %TRUE if we left the chat already, %FALSE if
637 gboolean
purple_chat_conversation_has_left(PurpleChatConversation
*chat
);
639 /**************************************************************************/
640 /* Chat Conversation User API */
641 /**************************************************************************/
643 #define PURPLE_TYPE_CHAT_USER purple_chat_user_get_type()
646 * purple_chat_user_get_type:
648 * Returns: The #GType for the ChatConversationBuddy object.
650 G_DECLARE_FINAL_TYPE(PurpleChatUser
, purple_chat_user
, PURPLE
, CHAT_USER
,
654 * purple_chat_user_set_chat:
656 * @chat: The chat conversation that the buddy belongs to.
658 * Set the chat conversation associated with this chat user.
660 void purple_chat_user_set_chat(PurpleChatUser
*cb
,
661 PurpleChatConversation
*chat
);
664 * purple_chat_user_get_chat:
665 * @cb: The chat user.
667 * Get the chat conversation associated with this chat user.
669 * Returns: (transfer none):
670 * The chat conversation that the buddy belongs to.
672 PurpleChatConversation
*purple_chat_user_get_chat(PurpleChatUser
*cb
);
675 * purple_chat_user_new:
676 * @chat: The chat that the buddy belongs to.
681 * Creates a new chat user
683 * Returns: The new chat user
685 PurpleChatUser
*purple_chat_user_new(PurpleChatConversation
*chat
,
686 const char *name
, const char *alias
, PurpleChatUserFlags flags
);
689 * purple_chat_user_set_ui_data:
691 * @ui_data: A pointer to associate with this chat user.
693 * Set the UI data associated with this chat user.
695 void purple_chat_user_set_ui_data(PurpleChatUser
*cb
, gpointer ui_data
);
698 * purple_chat_user_get_ui_data:
699 * @cb: The chat user.
701 * Get the UI data associated with this chat user.
703 * Returns: (transfer none):
704 * The UI data associated with this chat user. This is a
705 * convenience field provided to the UIs--it is not
706 * used by the libpurple core.
708 gpointer
purple_chat_user_get_ui_data(PurpleChatUser
*cb
);
711 * purple_chat_user_get_alias:
712 * @cb: The chat user.
714 * Get the alias of a chat user
716 * Returns: The alias of the chat user.
718 const char *purple_chat_user_get_alias(PurpleChatUser
*cb
);
721 * purple_chat_user_get_name:
722 * @cb: The chat user.
724 * Get the name of a chat user
726 * Returns: The name of the chat user.
728 const char *purple_chat_user_get_name(PurpleChatUser
*cb
);
731 * purple_chat_user_set_flags:
732 * @cb: The chat user.
733 * @flags: The new flags.
735 * Set the flags of a chat user.
737 void purple_chat_user_set_flags(PurpleChatUser
*cb
, PurpleChatUserFlags flags
);
740 * purple_chat_user_get_flags:
741 * @cb: The chat user.
743 * Get the flags of a chat user.
745 * Returns: The flags of the chat user.
747 PurpleChatUserFlags
purple_chat_user_get_flags(PurpleChatUser
*cb
);
750 * purple_chat_user_is_buddy:
751 * @cb: The chat user.
753 * Indicates if this chat user is on the buddy list.
755 * Returns: TRUE if the chat user is on the buddy list.
757 gboolean
purple_chat_user_is_buddy(PurpleChatUser
*cb
);
761 #endif /* PURPLE_CONVERSATION_TYPES_H */