summaryrefslogtreecommitdiff
path: root/libpurple/server.h
blob: 78a7be7fad34ab85e3b9c53e643c93f90e557f33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
/*
 * Purple - Internet Messaging Library
 * Copyright (C) Pidgin Developers <devel@pidgin.im>
 *
 * Purple is the legal property of its developers, whose names are too numerous
 * to list here.  Please refer to the COPYRIGHT file distributed with this
 * source distribution.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <https://www.gnu.org/licenses/>.
 */

#if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION)
# error "only <purple.h> may be included directly"
#endif

#ifndef PURPLE_SERVER_H
#define PURPLE_SERVER_H

#include "accounts.h"
#include "conversations.h"
#include "group.h"
#include "protocols.h"
#include "purpleimconversation.h"
#include "purplemessage.h"

G_BEGIN_DECLS

/**
 * purple_serv_send_typing:
 * @gc:    The connection over which to send the typing notification.
 * @name:  The user to send the typing notification to.
 * @state: One of PURPLE_IM_TYPING, PURPLE_IM_TYPED, or PURPLE_IM_NOT_TYPING.
 *
 * Send a typing message to a given user over a given connection.
 *
 * Returns: A quiet-period, specified in seconds, where Purple will not
 *         send any additional typing notification messages.  Most
 *         protocols should return 0, which means that no additional
 *         PURPLE_IM_TYPING messages need to be sent.  If this is 5, for
 *         example, then Purple will wait five seconds, and if the Purple
 *         user is still typing then Purple will send another PURPLE_IM_TYPING
 *         message.
 */
/* TODO Could probably move this into the conversation API. */
unsigned int purple_serv_send_typing(PurpleConnection *gc, const char *name, PurpleIMTypingState state);

/**
 * purple_serv_move_buddy:
 * @buddy:  The Buddy.
 * @orig:   Original group.
 * @dest:   Destiny group.
 *
 * Move a buddy from one group to another on server.
 */
void purple_serv_move_buddy(PurpleBuddy *buddy, PurpleGroup *orig, PurpleGroup *dest);

/**
 * purple_serv_send_im:
 * @gc:     The connection over which to send the typing notification.
 * @msg:    The message.
 *
 * Sends the message to the user through the required protocol.
 *
 * Returns: The error value returned from the protocol interface function.
 */
int  purple_serv_send_im(PurpleConnection *gc, PurpleMessage *msg);

/******************************************************************************
 * Chat Interface
 *****************************************************************************/

/**
 * purple_serv_chat_invite
 * @gc:     The connection over which to send the typing notification.
 * @id:     The id of the chat to invite the user to.
 * @message:A message displayed to the user when the invitation.
 * @name:   The name of the remote user to send the invitation to.
 *
 * Invite a user to join a chat.
 */
void purple_serv_chat_invite(PurpleConnection *gc, int id, const char *message, const char *name);

/**
 * purple_serv_chat_leave:
 * @gc:     The connection over which to send the typing notification.
 * @id:     The id of the chat to leave.
 *
 * Called when the user requests leaving a chat.
 */
void purple_serv_chat_leave(PurpleConnection *gc, int id);

/**
 * purple_serv_chat_send:
 * @gc:     The connection over which to send the typing notification.
 * @id:     The id of the chat to send the message to.
 * @msg:    The message to send to the chat.
 *
 * Send a message to a chat.
 *
 * This protocol function should return a positive value on
 * success. If the message is too big to be sent, return
 * <literal>-E2BIG</literal>. If the account is not connected,
 * return <literal>-ENOTCONN</literal>. If the protocol is unable
 * to send the message for another reason, return some other
 * negative value. You can use one of the valid #errno values, or
 * just big something.
 *
 * Returns:  A positive number or 0 in case of success, a
 *           negative error number in case of failure.
 */
int  purple_serv_chat_send(PurpleConnection *gc, int id, PurpleMessage *msg);

/******************************************************************************
 * Server Interface
 *****************************************************************************/

/**
 * purple_serv_alias_buddy:
 * @buddy:  The Buddy.
 *
 * Save/store buddy's alias on server list/roster
 */
void purple_serv_alias_buddy(PurpleBuddy *buddy);

/**
 * purple_serv_got_alias:
 * @gc:     The connection over which to send the typing notification.
 * @who: The name of the buddy whose alias was received.
 * @alias: The alias that was received.
 *
 * Protocol should call this function when it retrieves an alias form the server.
 *
 */
void purple_serv_got_alias(PurpleConnection *gc, const char *who, const char *alias);

/**
 * purple_serv_got_private_alias:
 * @gc: The connection on which the alias was received.
 * @who: The name of the buddy whose alias was received.
 * @alias: The alias that was received.
 *
 * A protocol should call this when it retrieves a private alias from
 * the server.  Private aliases are the aliases the user sets, while public
 * aliases are the aliases or display names that buddies set for themselves.
 */
void purple_serv_got_private_alias(PurpleConnection *gc, const char *who, const char *alias);


/**
 * purple_serv_got_typing:
 * @gc:      The connection on which the typing message was received.
 * @name:    The name of the remote user.
 * @timeout: If this is a number greater than 0, then
 *        Purple will wait this number of seconds and then
 *        set this buddy to the PURPLE_IM_NOT_TYPING state.  This
 *        is used by protocols that send repeated typing messages
 *        while the user is composing the message.
 * @state:   The typing state received
 *
 * Receive a typing message from a remote user.  Either PURPLE_IM_TYPING
 * or PURPLE_IM_TYPED.  If the user has stopped typing then use
 * purple_serv_got_typing_stopped instead.
 *
 * @todo Could probably move this into the conversation API.
 */
void purple_serv_got_typing(PurpleConnection *gc, const char *name, int timeout,
					 PurpleIMTypingState state);

/**
 * purple_serv_got_typing_stopped:
 * @gc: The #PurpleConnection
 * @name: The name of the person that stopped typing.
 *
 * Called from a protocol when it has received a type stopped.
 *
 * @todo Could probably move this into the conversation API.
 */
void purple_serv_got_typing_stopped(PurpleConnection *gc, const char *name);

/**
 * purple_serv_got_im:
 * @gc:     The connection on which the typing message was received.
 * @who:    The username of the buddy that sent the message.
 * @msg:    The actual message received.
 * @flags:  The flags applicable to this message.
 * @mtime:  The timestamp of the message.
 *
 * This function is called by the protocol when it receives an IM message.
 */
void purple_serv_got_im(PurpleConnection *gc, const char *who, const char *msg,
				 PurpleMessageFlags flags, time_t mtime);

/**
 * purple_serv_join_chat:
 * @gc:   The #PurpleConnection
 * @data: The hash function should be g_str_hash() and the equal
 *             function should be g_str_equal().
 */
void purple_serv_join_chat(PurpleConnection *gc, GHashTable *data);

/**
 * purple_serv_reject_chat:
 * @gc: The #PurpleConnection 
 * @data: The hash function should be g_str_hash() and the equal
 *             function should be g_str_equal().
 */
void purple_serv_reject_chat(PurpleConnection *gc, GHashTable *data);

/**
 * purple_serv_got_chat_invite:
 * @gc:      The connection on which the invite arrived.
 * @name:    The name of the chat you're being invited to.
 * @who:     The username of the person inviting the account.
 * @message: The optional invite message.
 * @data:    The components necessary if you want to call purple_serv_join_chat().
 *                The hash function should be g_str_hash() and the equal
 *                function should be g_str_equal().
 *
 * Called by a protocol when an account is invited into a chat.
 */
void purple_serv_got_chat_invite(PurpleConnection *gc, const char *name,
						  const char *who, const char *message,
						  GHashTable *data);

/**
 * purple_serv_got_joined_chat:
 * @gc:   The connection on which the chat was joined.
 * @id:   The id of the chat, assigned by the protocol.
 * @name: The name of the chat.
 *
 * Called by a protocol when an account has joined a chat.
 *
 * Returns: (transfer none): The resulting conversation.
 */
PurpleConversation *purple_serv_got_joined_chat(PurpleConnection *gc,
									   int id, const char *name);
/**
 * purple_serv_got_join_chat_failed:
 * @gc:      The connection on which chat joining failed
 * @data:    The components passed to purple_serv_join_chat() originally.
 *                The hash function should be g_str_hash() and the equal
 *                function should be g_str_equal().
 *
 * Called by a protocol when an attempt to join a chat via purple_serv_join_chat()
 * fails.
 */
void purple_serv_got_join_chat_failed(PurpleConnection *gc, GHashTable *data);

/**
 * purple_serv_got_chat_left:
 * @g:  The connection on which the chat was left.
 * @id: The id of the chat, as assigned by the protocol.
 *
 * Called by a protocol when an account has left a chat.
 */
void purple_serv_got_chat_left(PurpleConnection *g, int id);

/**
 * purple_serv_got_chat_in:
 * @g:       The connection on which the message was received.
 * @id:      The id of the chat, as assigned by the protocol.
 * @who:     The name of the user who sent the message.
 * @flags:   The flags of the message.
 * @message: The message received in the chat.
 * @mtime:   The time when the message was received.
 *
 * Called by a protocol when a message has been received in a chat.
 */
void purple_serv_got_chat_in(PurpleConnection *g, int id, const char *who,
					  PurpleMessageFlags flags, const char *message, time_t mtime);

/**
 * purple_serv_send_file:
 * @gc:     The connection on which the message was received.
 * @who:    The name of the user to who send the file.
 * @file:   The filename to send.
 *
 * Send a filename to a given contact.
 */
void purple_serv_send_file(PurpleConnection *gc, const char *who, const char *file);

G_END_DECLS

#endif /* PURPLE_SERVER_H */