linphonefriend.h 12.9 KB
Newer Older
jehan's avatar
jehan committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/*
linphonefriend.h
Copyright (C) 2010  Belledonne Communications SARL

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, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

#ifndef LINPHONEFRIEND_H_
#define LINPHONEFRIEND_H_
22 23 24

#include "linphonepresence.h"

jehan's avatar
jehan committed
25 26 27
#ifdef __cplusplus
extern "C" {
#endif
28

jehan's avatar
jehan committed
29 30 31 32 33 34 35 36
/**
 * @addtogroup buddy_list
 * @{
 */
/**
 * Enum controlling behavior for incoming subscription request.
 * <br> Use by linphone_friend_set_inc_subscribe_policy()
 */
37
typedef enum _LinphoneSubscribePolicy {
jehan's avatar
jehan committed
38 39
	/**
	 * Does not automatically accept an incoming subscription request.
40
	 * This policy implies that a decision has to be taken for each incoming subscription request notified by callback LinphoneCoreVTable.new_subscription_requested
jehan's avatar
jehan committed
41 42 43 44 45 46 47 48 49 50 51
	 *
	 */
	LinphoneSPWait,
	/**
	 * Rejects incoming subscription request.
	 */
	LinphoneSPDeny,
	/**
	 * Automatically accepts a subscription request.
	 */
	LinphoneSPAccept
52
} LinphoneSubscribePolicy;
jehan's avatar
jehan committed
53 54 55

/**
 * Enum describing remote friend status
56
 * @deprecated Use #LinphonePresenceModel and #LinphonePresenceActivity instead
jehan's avatar
jehan committed
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
 */
typedef enum _LinphoneOnlineStatus{
	/**
	 * Offline
	 */
	LinphoneStatusOffline,
	/**
	 * Online
	 */
	LinphoneStatusOnline,
	/**
	 * Busy
	 */
	LinphoneStatusBusy,
	/**
	 * Be right back
	 */
	LinphoneStatusBeRightBack,
	/**
	 * Away
	 */
	LinphoneStatusAway,
	/**
	 * On the phone
	 */
	LinphoneStatusOnThePhone,
	/**
	 * Out to lunch
	 */
	LinphoneStatusOutToLunch,
	/**
	 * Do not disturb
	 */
	LinphoneStatusDoNotDisturb,
	/**
	 * Moved in this sate, call can be redirected if an alternate contact address has been set using function linphone_core_set_presence_info()
	 */
	LinphoneStatusMoved,
	/**
	 * Using another messaging service
	 */
	LinphoneStatusAltService,
	/**
	 * Pending
	 */
	LinphoneStatusPending,
103 104 105 106
	/**
	 * Vacation
	 */
	LinphoneStatusVacation,
Simon Morlat's avatar
Simon Morlat committed
107

jehan's avatar
jehan committed
108 109 110 111 112 113 114 115 116 117 118 119 120 121
	LinphoneStatusEnd
}LinphoneOnlineStatus;


struct _LinphoneFriend;
/**
 * Represents a buddy, all presence actions like subscription and status change notification are performed on this object
 */
typedef struct _LinphoneFriend LinphoneFriend;

/**
 * Contructor
 * @return a new empty #LinphoneFriend
 */
122
LINPHONE_PUBLIC LinphoneFriend * linphone_friend_new(void);
Ghislain MARY's avatar
Ghislain MARY committed
123

jehan's avatar
jehan committed
124
/**
Ghislain MARY's avatar
Ghislain MARY committed
125
 * Contructor same as linphone_friend_new() + linphone_friend_set_address()
jehan's avatar
jehan committed
126 127 128
 * @param addr a buddy address, must be a sip uri like sip:joe@sip.linphone.org
 * @return a new #LinphoneFriend with \link linphone_friend_get_address() address initialized \endlink
 */
Ghislain MARY's avatar
Ghislain MARY committed
129 130 131 132 133 134 135
LINPHONE_PUBLIC	LinphoneFriend *linphone_friend_new_with_address(const char *addr);

/**
 * Contructor same as linphone_friend_new() + linphone_friend_set_address()
 * @deprecated Use #linphone_friend_new_with_address instead
 */
#define linphone_friend_new_with_addr linphone_friend_new_with_address
jehan's avatar
jehan committed
136

jehan's avatar
jehan committed
137
/**
138 139 140
 * Destroy a LinphoneFriend.
 * @param lf LinphoneFriend object
 * @deprecated Use linphone_friend_unref() instead.
jehan's avatar
jehan committed
141
 */
Ghislain MARY's avatar
Ghislain MARY committed
142
LINPHONE_PUBLIC void linphone_friend_destroy(LinphoneFriend *lf);
jehan's avatar
jehan committed
143

jehan's avatar
jehan committed
144
/**
145
 * Set #LinphoneAddress for this friend
jehan's avatar
jehan committed
146
 * @param fr #LinphoneFriend object
jehan's avatar
jehan committed
147 148
 * @param address #LinphoneAddress
 */
149 150 151 152 153 154 155
LINPHONE_PUBLIC int linphone_friend_set_address(LinphoneFriend *fr, const LinphoneAddress* address);

/**
 * Set #LinphoneAddress for this friend
 * @deprecated Use #linphone_friend_set_address instead
 */
#define linphone_friend_set_addr linphone_friend_set_address
jehan's avatar
jehan committed
156

157
/**
158 159 160 161 162 163 164 165
 * Get address of this friend
 * @param lf #LinphoneFriend object
 * @return #LinphoneAddress
 */
LINPHONE_PUBLIC	const LinphoneAddress *linphone_friend_get_address(const LinphoneFriend *lf);

/**
 * Set the display name for this friend
166 167 168
 * @param lf #LinphoneFriend object
 * @param name 
 */
Ghislain MARY's avatar
Ghislain MARY committed
169
LINPHONE_PUBLIC int linphone_friend_set_name(LinphoneFriend *lf, const char *name);
170

jehan's avatar
jehan committed
171
/**
172
 * Get the display name for this friend
jehan's avatar
jehan committed
173
 * @param lf #LinphoneFriend object
174
 * @return The display name of this friend
jehan's avatar
jehan committed
175
 */
176 177
LINPHONE_PUBLIC const char * linphone_friend_get_name(const LinphoneFriend *lf);

jehan's avatar
jehan committed
178 179 180 181
/**
 * get subscription flag value
 * @param lf #LinphoneFriend object
 * @return returns true is subscription is activated for this friend
jehan's avatar
jehan committed
182 183
 *
 */
Ghislain MARY's avatar
Ghislain MARY committed
184
LINPHONE_PUBLIC bool_t linphone_friend_subscribes_enabled(const LinphoneFriend *lf);
jehan's avatar
jehan committed
185 186
#define linphone_friend_get_send_subscribe linphone_friend_subscribes_enabled

jehan's avatar
jehan committed
187 188 189 190 191 192
/**
 * Configure #LinphoneFriend to subscribe to presence information
 * @param fr #LinphoneFriend object
 * @param val if TRUE this friend will receive subscription message
 */

193
LINPHONE_PUBLIC	int linphone_friend_enable_subscribes(LinphoneFriend *fr, bool_t val);
jehan's avatar
jehan committed
194
#define linphone_friend_send_subscribe linphone_friend_enable_subscribes
Ghislain MARY's avatar
Ghislain MARY committed
195

jehan's avatar
jehan committed
196 197 198 199 200
/**
 * Configure incoming subscription policy for this friend.
 * @param fr #LinphoneFriend object
 * @param pol #LinphoneSubscribePolicy policy to apply.
 */
Ghislain MARY's avatar
Ghislain MARY committed
201
LINPHONE_PUBLIC int linphone_friend_set_inc_subscribe_policy(LinphoneFriend *fr, LinphoneSubscribePolicy pol);
Ghislain MARY's avatar
Ghislain MARY committed
202

jehan's avatar
jehan committed
203 204 205 206 207 208
/**
 * get current subscription policy for this #LinphoneFriend
 * @param lf #LinphoneFriend object
 * @return #LinphoneSubscribePolicy
 *
 */
Ghislain MARY's avatar
Ghislain MARY committed
209
LINPHONE_PUBLIC LinphoneSubscribePolicy linphone_friend_get_inc_subscribe_policy(const LinphoneFriend *lf);
jehan's avatar
jehan committed
210

jehan's avatar
jehan committed
211 212 213 214 215
/**
 * Starts editing a friend configuration.
 *
 * Because friend configuration must be consistent, applications MUST
 * call linphone_friend_edit() before doing any attempts to modify
Ghislain MARY's avatar
Ghislain MARY committed
216
 * friend configuration (such as \link linphone_friend_set_address() address \endlink  or \link linphone_friend_set_inc_subscribe_policy() subscription policy\endlink  and so on).
jehan's avatar
jehan committed
217 218 219
 * Once the modifications are done, then the application must call
 * linphone_friend_done() to commit the changes.
**/
220
LINPHONE_PUBLIC	void linphone_friend_edit(LinphoneFriend *fr);
Ghislain MARY's avatar
Ghislain MARY committed
221

jehan's avatar
jehan committed
222 223 224 225
/**
 * Commits modification made to the friend configuration.
 * @param fr #LinphoneFriend object
**/
226
LINPHONE_PUBLIC	void linphone_friend_done(LinphoneFriend *fr);
jehan's avatar
jehan committed
227

jehan's avatar
jehan committed
228
/**
229
 * Get the status of a friend
230
 * @param[in] lf A #LinphoneFriend object
jehan's avatar
jehan committed
231
 * @return #LinphoneOnlineStatus
232
 * @deprecated Use linphone_friend_get_presence_model() instead
jehan's avatar
jehan committed
233
 */
Ghislain MARY's avatar
Ghislain MARY committed
234
LINPHONE_PUBLIC LinphoneOnlineStatus linphone_friend_get_status(const LinphoneFriend *lf);
235

236
/**
237
 * Get the presence model of a friend
238
 * @param[in] lf A #LinphoneFriend object
Ghislain MARY's avatar
Ghislain MARY committed
239
 * @return A #LinphonePresenceModel object, or NULL if the friend do not have presence information (in which case he is considered offline)
240
 */
Ghislain MARY's avatar
Ghislain MARY committed
241
LINPHONE_PUBLIC const LinphonePresenceModel * linphone_friend_get_presence_model(LinphoneFriend *lf);
242

Simon Morlat's avatar
Simon Morlat committed
243 244 245 246 247 248 249 250 251 252
/**
 * Store user pointer to friend object.
**/
LINPHONE_PUBLIC void linphone_friend_set_user_data(LinphoneFriend *lf, void *data);

/**
 * Retrieve user data associated with friend.
**/
LINPHONE_PUBLIC void* linphone_friend_get_user_data(const LinphoneFriend *lf);

Ghislain MARY's avatar
Ghislain MARY committed
253
LINPHONE_PUBLIC BuddyInfo * linphone_friend_get_info(const LinphoneFriend *lf);
Ghislain MARY's avatar
Ghislain MARY committed
254 255 256 257 258 259

/**
 * Set the reference key of a friend.
 * @param[in] lf #LinphoneFriend object.
 * @param[in] key The reference key to use for the friend.
**/
Ghislain MARY's avatar
Ghislain MARY committed
260
LINPHONE_PUBLIC void linphone_friend_set_ref_key(LinphoneFriend *lf, const char *key);
Ghislain MARY's avatar
Ghislain MARY committed
261 262 263 264

/**
 * Get the reference key of a friend.
 * @param[in] lf #LinphoneFriend object.
265
 * @return The reference key of the friend.
Ghislain MARY's avatar
Ghislain MARY committed
266
**/
Ghislain MARY's avatar
Ghislain MARY committed
267
LINPHONE_PUBLIC const char *linphone_friend_get_ref_key(const LinphoneFriend *lf);
Ghislain MARY's avatar
Ghislain MARY committed
268 269 270 271

/**
 * Check that the given friend is in a friend list.
 * @param[in] lf #LinphoneFriend object.
272
 * @return TRUE if the friend is in a friend list, FALSE otherwise.
Ghislain MARY's avatar
Ghislain MARY committed
273
**/
Ghislain MARY's avatar
Ghislain MARY committed
274
LINPHONE_PUBLIC bool_t linphone_friend_in_list(const LinphoneFriend *lf);
jehan's avatar
jehan committed
275 276


jehan's avatar
jehan committed
277
/**
278
 * Return humain readable presence status
jehan's avatar
jehan committed
279
 * @param ss
280
 * @deprecated Use #LinphonePresenceModel, #LinphonePresenceActivity and linphone_presence_activity_to_string() instead.
jehan's avatar
jehan committed
281
 */
Ghislain MARY's avatar
Ghislain MARY committed
282
LINPHONE_PUBLIC const char *linphone_online_status_to_string(LinphoneOnlineStatus ss);
jehan's avatar
jehan committed
283 284


jehan's avatar
jehan committed
285
/**
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301
 * Create a default LinphoneFriend.
 * @param[in] lc #LinphoneCore object
 * @return The created #LinphoneFriend object
 */
LINPHONE_PUBLIC LinphoneFriend * linphone_core_create_friend(LinphoneCore *lc);

/**
 * Create a LinphoneFriend from the given address.
 * @param[in] lc #LinphoneCore object
 * @param[in] address A string containing the address to create the LinphoneFriend from
 * @return The created #LinphoneFriend object
 */
LINPHONE_PUBLIC LinphoneFriend * linphone_core_create_friend_with_address(LinphoneCore *lc, const char *address);

/**
 * Set my presence status
302 303 304 305 306
 * @param[in] lc #LinphoneCore object
 * @param[in] minutes_away how long in away
 * @param[in] alternative_contact sip uri used to redirect call in state #LinphoneStatusMoved
 * @param[in] os #LinphoneOnlineStatus
 * @deprecated Use linphone_core_set_presence_model() instead
jehan's avatar
jehan committed
307
 */
308
LINPHONE_PUBLIC void linphone_core_set_presence_info(LinphoneCore *lc,int minutes_away,const char *alternative_contact,LinphoneOnlineStatus os);
309 310

/**
311
 * Set my presence model
312 313
 * @param[in] lc #LinphoneCore object
 * @param[in] presence #LinphonePresenceModel
314
 */
315
LINPHONE_PUBLIC void linphone_core_set_presence_model(LinphoneCore *lc, LinphonePresenceModel *presence);
316

jehan's avatar
jehan committed
317
/**
318
 * Get my presence status
319
 * @param[in] lc #LinphoneCore object
jehan's avatar
jehan committed
320
 * @return #LinphoneOnlineStatus
321
 * @deprecated Use linphone_core_get_presence_model() instead
jehan's avatar
jehan committed
322
 */
Ghislain MARY's avatar
Ghislain MARY committed
323
LINPHONE_PUBLIC LinphoneOnlineStatus linphone_core_get_presence_info(const LinphoneCore *lc);
jehan's avatar
jehan committed
324

325
/**
326
 * Get my presence model
327 328
 * @param[in] lc #LinphoneCore object
 * @return A #LinphonePresenceModel object, or NULL if no presence model has been set.
329
 */
Ghislain MARY's avatar
Ghislain MARY committed
330
LINPHONE_PUBLIC LinphonePresenceModel * linphone_core_get_presence_model(const LinphoneCore *lc);
331

Ghislain MARY's avatar
Ghislain MARY committed
332 333 334
/**
 * @deprecated Use linphone_core_interpret_url() instead
 */
Ghislain MARY's avatar
Ghislain MARY committed
335
LINPHONE_PUBLIC void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char **result);
Ghislain MARY's avatar
Ghislain MARY committed
336

jehan's avatar
jehan committed
337 338 339 340 341
/**
 * Add a friend to the current buddy list, if \link linphone_friend_enable_subscribes() subscription attribute \endlink is set, a SIP SUBSCRIBE message is sent.
 * @param lc #LinphoneCore object
 * @param fr #LinphoneFriend to add
 */
342
LINPHONE_PUBLIC	void linphone_core_add_friend(LinphoneCore *lc, LinphoneFriend *fr);
Ghislain MARY's avatar
Ghislain MARY committed
343

jehan's avatar
jehan committed
344 345 346 347 348
/**
 * remove a friend from the buddy list
 * @param lc #LinphoneCore object
 * @param fr #LinphoneFriend to add
 */
Ghislain MARY's avatar
Ghislain MARY committed
349
LINPHONE_PUBLIC void linphone_core_remove_friend(LinphoneCore *lc, LinphoneFriend *fr);
Ghislain MARY's avatar
Ghislain MARY committed
350

jehan's avatar
jehan committed
351 352 353
/**
 * Black list a friend. same as linphone_friend_set_inc_subscribe_policy() with #LinphoneSPDeny policy;
 * @param lc #LinphoneCore object
jehan's avatar
jehan committed
354
 * @param lf #LinphoneFriend to add
jehan's avatar
jehan committed
355
 */
Ghislain MARY's avatar
Ghislain MARY committed
356
LINPHONE_PUBLIC void linphone_core_reject_subscriber(LinphoneCore *lc, LinphoneFriend *lf);
Ghislain MARY's avatar
Ghislain MARY committed
357

jehan's avatar
jehan committed
358
/**
Ghislain MARY's avatar
Ghislain MARY committed
359
 * Get Buddy list of LinphoneFriend
360 361
 * @param[in] lc #LinphoneCore object
 * @return \mslist{LinphoneFriend}
Ghislain MARY's avatar
Ghislain MARY committed
362
 */
363
LINPHONE_PUBLIC	const MSList * linphone_core_get_friend_list(const LinphoneCore *lc);
Ghislain MARY's avatar
Ghislain MARY committed
364

jehan's avatar
jehan committed
365
/**
Ghislain MARY's avatar
Ghislain MARY committed
366
 * Notify all friends that have subscribed
jehan's avatar
jehan committed
367
 * @param lc #LinphoneCore object
Ghislain MARY's avatar
Ghislain MARY committed
368
 * @param presence #LinphonePresenceModel to notify
Ghislain MARY's avatar
Ghislain MARY committed
369
 */
Ghislain MARY's avatar
Ghislain MARY committed
370
LINPHONE_PUBLIC void linphone_core_notify_all_friends(LinphoneCore *lc, LinphonePresenceModel *presence);
Ghislain MARY's avatar
Ghislain MARY committed
371

Ghislain MARY's avatar
Ghislain MARY committed
372 373 374 375
/**
 * Search a LinphoneFriend by its address.
 * @param[in] lc #LinphoneCore object.
 * @param[in] addr The address to use to search the friend.
376
 * @return The #LinphoneFriend object corresponding to the given address.
Simon Morlat's avatar
Simon Morlat committed
377
 * @deprecated use linphone_core_find_friend() instead.
Ghislain MARY's avatar
Ghislain MARY committed
378
 */
Ghislain MARY's avatar
Ghislain MARY committed
379
LINPHONE_PUBLIC LinphoneFriend *linphone_core_get_friend_by_address(const LinphoneCore *lc, const char *addr);
Ghislain MARY's avatar
Ghislain MARY committed
380

Simon Morlat's avatar
Simon Morlat committed
381 382 383 384
/**
 * Search a LinphoneFriend by its address.
 * @param[in] lc #LinphoneCore object.
 * @param[in] addr The address to use to search the friend.
385
 * @return The #LinphoneFriend object corresponding to the given address.
Simon Morlat's avatar
Simon Morlat committed
386 387 388
 */
LINPHONE_PUBLIC LinphoneFriend *linphone_core_find_friend(const LinphoneCore *lc, const LinphoneAddress *addr);

Ghislain MARY's avatar
Ghislain MARY committed
389 390 391 392
/**
 * Search a LinphoneFriend by its reference key.
 * @param[in] lc #LinphoneCore object.
 * @param[in] key The reference key to use to search the friend.
393
 * @return The #LinphoneFriend object corresponding to the given reference key.
Ghislain MARY's avatar
Ghislain MARY committed
394
 */
Ghislain MARY's avatar
Ghislain MARY committed
395
LINPHONE_PUBLIC LinphoneFriend *linphone_core_get_friend_by_ref_key(const LinphoneCore *lc, const char *key);
jehan's avatar
jehan committed
396

397 398 399 400 401 402 403 404 405 406 407 408
/**
 * Acquire a reference to the linphone friend.
 * @param[in] lf LinphoneFriend object
 * @return The same LinphoneFriend object
**/
LINPHONE_PUBLIC LinphoneFriend * linphone_friend_ref(LinphoneFriend *lf);

/**
 * Release a reference to the linphone friend.
 * @param[in] lf LinohoneFriend object
**/
LINPHONE_PUBLIC void linphone_friend_unref(LinphoneFriend *lf);
409 410 411 412 413

/**
 * Returns the LinphoneCore object managing this friend, if any.
 */
LINPHONE_PUBLIC LinphoneCore *linphone_friend_get_core(const LinphoneFriend *fr);
jehan's avatar
jehan committed
414 415 416 417 418 419 420 421 422
/**
 * @}
 */

#ifdef __cplusplus
}
#endif

#endif /* LINPHONEFRIEND_H_ */