libpurple/purpleprotocolchat.h

changeset 40697
81f81f5d2f39
child 41010
d0abbb616bea
equal deleted inserted replaced
40696:cf58ec89b1e4 40697:81f81f5d2f39
1 /*
2 * Purple - Internet Messaging Library
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
4 *
5 * Purple is the legal property of its developers, whose names are too numerous
6 * to list here. Please refer to the COPYRIGHT file distributed with this
7 * source distribution.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, see <https://www.gnu.org/licenses/>.
21 */
22
23 #if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION)
24 # error "only <purple.h> may be included directly"
25 #endif
26
27 #ifndef PURPLE_PROTOCOL_CHAT_H
28 #define PURPLE_PROTOCOL_CHAT_H
29
30 /**
31 * SECTION:purpleprotocolchat
32 * @section_id: libpurple-purpleprotocolchat
33 * @short_description: Protocol Chat Interface
34 * @title: ProtocolChat Interface
35 *
36 * #PurpleProtocolChat describes the API that protocols need to implement for
37 * handling multiple user conversations.
38 */
39
40 #include <glib.h>
41 #include <glib-object.h>
42
43 #include <libpurple/connection.h>
44 #include <libpurple/purplemessage.h>
45
46 #define PURPLE_TYPE_PROTOCOL_CHAT (purple_protocol_chat_get_type())
47 G_DECLARE_INTERFACE(PurpleProtocolChat, purple_protocol_chat, PURPLE, PROTOCOL_CHAT,
48 GObject)
49
50 G_BEGIN_DECLS
51
52 /**
53 * PURPLE_TYPE_PROTOCOL_CHAT:
54 *
55 * The standard _get_type method for #PurpleProtocolChat.
56 *
57 * Since: 3.0.0
58 */
59
60 /**
61 * PurpleProtocolChatInterface:
62 * @info: Returns a list of #PurpleProtocolChatEntry structs, which represent
63 * information required by the protocol to join a chat. libpurple will
64 * call join_chat along with the information filled by the user.
65 * @info_defaults: Returns a hashtable which maps #PurpleProtocolChatEntry
66 * struct identifiers to default options as strings based on
67 * @chat_name. The resulting hashtable should be created with
68 * #g_hash_table_new_full(#g_str_hash, #g_str_equal, %NULL,
69 * #g_free). Use @get_name if you instead need to extract a chat
70 * name from a hashtable.
71 * @join: Called when the user requests joining a chat. Should arrange for
72 * purple_serv_got_joined_chat() to be called.
73 * @reject: Called when the user refuses a chat invitation.
74 * @get_name: Returns a chat name based on the information in components. Use
75 * @info_defaults if you instead need to generate a hashtable from a
76 * chat name.
77 * @invite: Invite a user to join a chat.
78 * @leave: Called when the user requests leaving a chat.
79 * @send: Send a message to a chat.
80 * @get_user_real_name: Gets the real name of a participant in a chat. For
81 * example, on XMPP this turns a chat room nick
82 * <literal>foo</literal> into
83 * <literal>room\@server/foo</literal>.
84 * @set_topic: Called to set the topic for the given chat.
85 *
86 * The protocol chat interface.
87 *
88 * This interface provides callbacks needed by protocols that implement chats.
89 */
90 struct _PurpleProtocolChatInterface {
91 /*< private >*/
92 GTypeInterface parent;
93
94 /*< public >*/
95 GList *(*info)(PurpleProtocolChat *protocol_chat, PurpleConnection *connection);
96
97 GHashTable *(*info_defaults)(PurpleProtocolChat *protocol_chat, PurpleConnection *connection, const gchar *chat_name);
98
99 void (*join)(PurpleProtocolChat *protocol_chat, PurpleConnection *connection, GHashTable *components);
100
101 void (*reject)(PurpleProtocolChat *protocol_chat, PurpleConnection *connection, GHashTable *components);
102
103 gchar *(*get_name)(PurpleProtocolChat *protocol_chat, GHashTable *components);
104
105 void (*invite)(PurpleProtocolChat *protocol_chat, PurpleConnection *connection, gint id, const gchar *message, const gchar *who);
106
107 void (*leave)(PurpleProtocolChat *protocol_chat, PurpleConnection *connection, gint id);
108
109 gint (*send)(PurpleProtocolChat *protocol_chat, PurpleConnection *connection, gint id, PurpleMessage *message);
110
111 gchar *(*get_user_real_name)(PurpleProtocolChat *protocol_chat, PurpleConnection *connection, gint id, const gchar *who);
112
113 void (*set_topic)(PurpleProtocolChat *protocol_chat, PurpleConnection *connection, gint id, const gchar *topic);
114
115 /*< private >*/
116 gpointer reserved[8];
117 };
118
119 /**
120 * purple_protocol_chat_info:
121 * @protocol_chat: The #PurpleProtocolChat instance.
122 * @connection: The #PurpleConnection instance.
123 *
124 * Gets the list of #PurpleProtocolChatEntry's that are required to join a
125 * multi user chat.
126 *
127 * Returns: (transfer full) (element-type PurpleProtocolChatEntry): The list
128 * of #PurpleProtocolChatEntry's that are used to join a chat.
129 *
130 * Since: 3.0.0
131 */
132 GList *purple_protocol_chat_info(PurpleProtocolChat *protocol_chat, PurpleConnection *connection);
133
134 /**
135 * purple_protocol_chat_info_defaults:
136 * @protocol_chat: The #PurpleProtocolChat instance.
137 * @connection: The #PurpleConnection instance.
138 * @chat_name: The name of the chat.
139 *
140 * Returns a #GHashTable of the default protocol dependent components that will
141 * be passed to purple_protocol_chat_join().
142 *
143 * Returns: (transfer full) (element-type utf8 utf8): The values that will be
144 * used to join the chat.
145 *
146 * Since: 3.0.0
147 */
148 GHashTable *purple_protocol_chat_info_defaults(PurpleProtocolChat *protocol_chat, PurpleConnection *connection, const gchar *chat_name);
149
150 /**
151 * purple_protocol_chat_join:
152 * @protocol_chat: The #PurpleProtocolChat instance.
153 * @connection: The #PurpleConnection instance.
154 * @components: (element-type utf8 utf8) (transfer none): The protocol
155 * dependent join components.
156 *
157 * Joins the chat described in @components.
158 *
159 * Since: 3.0.0
160 */
161 void purple_protocol_chat_join(PurpleProtocolChat *protocol_chat, PurpleConnection *connection, GHashTable *components);
162
163 /**
164 * purple_protocol_chat_reject:
165 * @protocol_chat: The #PurpleProtocolChat instance.
166 * @connection: The #PurpleConnection instance.
167 * @components: (element-type utf8 utf8) (transfer none): The protocol
168 * dependent join components.
169 *
170 * Used to reject a chat invite.
171 *
172 * Since: 3.0.0
173 */
174 void purple_protocol_chat_reject(PurpleProtocolChat *protocol_chat, PurpleConnection *connection, GHashTable *components);
175
176 /**
177 * purple_protocol_chat_get_name:
178 * @protocol_chat: The #PurpleProtocolChat instance.
179 * @components: (element-type utf8 utf8) (transfer none): The protocol
180 * dependent join components.
181 *
182 * Gets the name from @components.
183 *
184 * Returns: (transfer full): The chat name from @components.
185 *
186 * Since: 3.0.0
187 */
188 gchar *purple_protocol_chat_get_name(PurpleProtocolChat *protocol_chat, GHashTable *components);
189
190 /**
191 * purple_protocol_chat_invite:
192 * @protocol_chat: The #PurpleProtocolChat instance.
193 * @connection: The #PurpleConnection instance.
194 * @id: The id of the chat.
195 * @message: The invite message.
196 * @who: The target of the invite.
197 *
198 * Sends an invite to @who with @message.
199 *
200 * Since: 3.0.0
201 */
202 void purple_protocol_chat_invite(PurpleProtocolChat *protocol_chat, PurpleConnection *connection, gint id, const gchar *message, const gchar *who);
203
204 /**
205 * purple_protocol_chat_leave:
206 * @protocol_chat: The #PurpleProtocolChat instance.
207 * @connection: The #PurpleConnection instance.
208 * @id: The id of the chat.
209 *
210 * Leaves the chat identified by @id.
211 *
212 * Since: 3.0.0
213 */
214 void purple_protocol_chat_leave(PurpleProtocolChat *protocol_chat, PurpleConnection *connection, gint id);
215
216 /**
217 * purple_protocol_chat_send:
218 * @protocol_chat: The #PurpleProtocolChat instance.
219 * @connection: The #PurpleConnection instance.
220 * @id: The id of the chat.
221 * @message: The message to send.
222 *
223 * Sends @message to the chat identified by @id.
224 *
225 * Returns: 0 on success, non-zero on failure.
226 *
227 * Since: 3.0.0
228 */
229 gint purple_protocol_chat_send(PurpleProtocolChat *protocol_chat, PurpleConnection *connection, gint id, PurpleMessage *message);
230
231 /**
232 * purple_protocol_chat_get_user_real_name:
233 * @protocol_chat: The #PurpleProtocolChat instance.
234 * @connection: The #PurpleConnection instance.
235 * @id: The id of the chat.
236 * @who: The username.
237 *
238 * Gets the real name of @who.
239 *
240 * Returns: (transfer full): The realname of @who.
241 *
242 * Since: 3.0.0
243 */
244 gchar *purple_protocol_chat_get_user_real_name(PurpleProtocolChat *protocol_chat, PurpleConnection *connection, gint id, const gchar *who);
245
246 /**
247 * purple_protocol_chat_set_topic:
248 * @protocol_chat: The #PurpleProtocolChat instance.
249 * @connection: The #PurpleConnection instance.
250 * @id: The id of the chat.
251 * @topic: The new topic.
252 *
253 * Sets the topic for the chat with id @id to @topic.
254 *
255 * Since: 3.0.0
256 */
257 void purple_protocol_chat_set_topic(PurpleProtocolChat *protocol_chat, PurpleConnection *connection, gint id, const gchar *topic);
258
259 G_END_DECLS
260
261 #endif /* PURPLE_PROTOCOL_CHAT_H */
262

mercurial