}
LinphoneFriend *linphone_friend_new_with_addr(const char *addr){
+ LinphoneAddress* linphone_address = linphone_address_new(addr);
+ if (linphone_address == NULL) {
+ ms_error("Cannot create friend for address [%s]",addr?addr:"null");
+ return NULL;
+ }
LinphoneFriend *fr=linphone_friend_new();
- if (linphone_friend_set_sip_addr(fr,addr)<0){
+ if (linphone_friend_set_addr(fr,linphone_address)<0){
linphone_friend_destroy(fr);
return NULL;
}
linphone_address_destroy(fr);
}
-int linphone_friend_set_sip_addr(LinphoneFriend *lf, const char *addr){
- LinphoneAddress *fr=linphone_address_new(addr);
+int linphone_friend_set_addr(LinphoneFriend *lf, const LinphoneAddress *addr){
+ LinphoneAddress *fr=linphone_address_clone(addr);
if (fr==NULL) {
ms_warning("Invalid friend sip uri: %s",addr);
return -1;
/**
* @defgroup buddy_tutorials Basic buddy status notification
* @ingroup tutorials
- *This program is a _very_ simple usage example of liblinphone.
- *Desmonstrating how to initiate a SIP subscription and receive notification from a sip uri identity passed from the command line.
+ *This program is a _very_ simple usage example of liblinphone,
+ *desmonstrating how to initiate SIP subscriptions and receive notifications from a sip uri identity passed from the command line.
*<br>Argument must be like sip:jehan@sip.linphone.org .
*<br>
*ex budy_list sip:jehan@sip.linphone.org
}
signal(SIGINT,stop);
-#define DEBUG
+//#define DEBUG
#ifdef DEBUG
linphone_core_enable_logs(NULL); /*enable liblinphone logs.*/
#endif
}
linphone_friend_enable_subscribes(my_friend,TRUE); /*configure this friend to emit SUBSCRIBE message after being added to LinphoneCore*/
- linphone_friend_set_name(my_friend,"My best friend"); /* add a nickname to this buddy */
-
linphone_friend_set_inc_subscribe_policy(my_friend,LinphoneSPAccept); /* Accept incoming subscription request for this friend*/
-
-
linphone_core_add_friend(lc,my_friend); /* add my friend to the buddy list, initiate SUBSCRIBE message*/
}
* @defgroup buddy_list Managing Buddies and buddy list and presence
<b>Buddies and buddy list</b>
<br>Each buddy is represented by a #LinphoneFriend object created by function linphone_friend_new().
-Buddy configuration parameters like \link linphone_friend_set_sip_addr() sip uri \endlink or \link linphone_friend_set_inc_subscribe_policy status publication \endlink policy for this \link #LinphoneFriend friend \endlink are configurable for each buddy.
+Buddy configuration parameters like \link linphone_friend_set_addr() sip uri \endlink or \link linphone_friend_set_inc_subscribe_policy() status publication \endlink policy for this \link #LinphoneFriend friend \endlink are configurable for each buddy.
<br>Here under a typical buddy creation:
<br>
\code
LinphoneFriend* my_friend=linphone_friend_new_with_addr("sip:joe@sip.linphone.org"); /*creates friend object for buddy joe*/
linphone_friend_enable_subscribes(my_friend,TRUE); /*configure this friend to emit SUBSCRIBE message after being added to LinphoneCore*/
-linphone_friend_set_name(my_friend,"My best friend"); /* add a nickname to this buddy */
-linphone_friend_set_inc_subscribe_policy(my_friend,LinphoneSPAccept); /* Incoming subscription request for this friend*/
+linphone_friend_set_inc_subscribe_policy(my_friend,LinphoneSPAccept); /* accept Incoming subscription request for this friend*/
\endcode
\link #LinphoneFriend friends \endlink status changes are reported by callback LinphoneCoreVTable.notify_presence_recv
\code
\endcode
<br>Once created a buddy can be added to the buddy list using function linphone_core_add_friend() . Added friends will be notified about \link linphone_core_set_presence_info() local status changes \endlink
<br>
-Any subsequente modifications to #LinphoneFriend must be first started by a call to function linphone_friend_config_edit() and validated by function linphone_friend_config_done()
+Any subsequente modifications to #LinphoneFriend must be first started by a call to function linphone_friend_edit() and validated by function linphone_friend_done()
\code
linphone_friend_edit(my_friend); /* start editing friend */
linphone_friend_enable_subscribes(my_friend,FALSE); /*disable subscription for this friend*/
<b> Publishing presence status </b>
-<br>Local presence status can be changed using function linphone_core_set_presence_info() .New status is propagated to all friend \link linphone_core_add_friend() previously added \endlink to #LinphoneCore.
+<br>Local presence status can be changed using function linphone_core_set_presence_info() .New status is propagated to all friends \link linphone_core_add_friend() previously added \endlink to #LinphoneCore.
<b>Handling incoming subscription request</b>
-<br> New incoming subscription requests are process according to \link linphone_friend_set_inc_subscribe_policy() the incoming subscription policy state \endlink for subscription initiated by \link linphone_core_add_friend() members of the buddy list \endlink
-<br> For incoming request comming from an unknown buddy, the call back LinphoneCoreVTable.new_subscription_request .
+<br> New incoming subscription requests are process according to \link linphone_friend_set_inc_subscribe_policy() the incoming subscription policy state \endlink for subscription initiated by \link linphone_core_add_friend() members of the buddy list. \endlink
+<br> For incoming request comming from an unknown buddy, the call back LinphoneCoreVTable.new_subscription_request is invoked.
<br> A complete tutorial can be found at : \ref buddy_tutorials "Registration tutorial"
typedef enum {
/**
* Does not automatically accept an incoming subscription request.
- * This policy implies that a decision has to be taken for each incoming subscription request notify in callback LinphoneCoreVTable.new_subscription_request
+ * This policy implies that a decision has to be taken for each incoming subscription request notified by callback LinphoneCoreVTable.new_subscription_request
*
*/
LinphoneSPWait,
LinphoneStatusEnd
}LinphoneOnlineStatus;
-/**
- * return humain readable presence status
- * @param ss
- */
-const char *linphone_online_status_to_string(LinphoneOnlineStatus ss);
struct _LinphoneFriend;
*/
LinphoneFriend * linphone_friend_new();
/**
- * Contructor same as linphone_friend_new() + linphone_friend_set_sip_addr()
+ * Contructor same as linphone_friend_new() + linphone_friend_set_addr()
* @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
*/
LinphoneFriend *linphone_friend_new_with_addr(const char *addr);
+
/**
- * Configure #LinphoneFriend with a new address.
- * @param uri a buddy address, must be a sip uri like sip:joe@sip.linphone.org
- * @return 0 if succeed
+ * Destructor
+ * @param lf #LinphoneFriend object
*/
-int linphone_friend_set_sip_addr(LinphoneFriend *fr, const char *uri);
+void linphone_friend_destroy(LinphoneFriend *lf);
+
/**
- * modify friend nickname
+ * set #LinphoneAddress for this friend
* @param fr #LinphoneFriend object
- * @param new name
- * @return 0 if succeed
+ * @param address #LinphoneAddress
+ */
+int linphone_friend_set_addr(LinphoneFriend *fr, const LinphoneAddress* address);
+
+/**
+ * get address of this friend
+ * @param lf #LinphoneFriend object
+ * @return #LinphoneAddress
+ */
+const LinphoneAddress *linphone_friend_get_address(const LinphoneFriend *lf);
+/**
+ * get subscription flag value
+ * @param lf #LinphoneFriend object
+ * @return returns true is subscription is activated for this friend
*
*/
-int linphone_friend_set_name(LinphoneFriend *fr, const char *name);
+bool_t linphone_friend_subscribes_enabled(const LinphoneFriend *lf);
+#define linphone_friend_get_send_subscribe linphone_friend_subscribes_enabled
+
/**
* Configure #LinphoneFriend to subscribe to presence information
* @param fr #LinphoneFriend object
* @param pol #LinphoneSubscribePolicy policy to apply.
*/
int linphone_friend_set_inc_subscribe_policy(LinphoneFriend *fr, LinphoneSubscribePolicy pol);
+/**
+ * get current subscription policy for this #LinphoneFriend
+ * @param lf #LinphoneFriend object
+ * @return #LinphoneSubscribePolicy
+ *
+ */
+LinphoneSubscribePolicy linphone_friend_get_inc_subscribe_policy(const LinphoneFriend *lf);
+
/**
* Starts editing a friend configuration.
*
* Because friend configuration must be consistent, applications MUST
* call linphone_friend_edit() before doing any attempts to modify
- * friend configuration (such as \link linphone_friend_set_name() nick name \endlink , \link linphone_friend_set_sip_addr() address \endlink and so on).
+ * friend configuration (such as \link linphone_friend_set_addr() address \endlink or \link linphone_friend_set_inc_subscribe_policy() subscription policy\endlink and so on).
* Once the modifications are done, then the application must call
* linphone_friend_done() to commit the changes.
**/
* @param fr #LinphoneFriend object
**/
void linphone_friend_done(LinphoneFriend *fr);
-/**
- * Destructor
- * @param fr #LinphoneFriend object
- */
-void linphone_friend_destroy(LinphoneFriend *lf);
-/**
- * get address of this friend
- * @param lf #LinphoneFriend object
- * @return #LinphoneAddress
- */
-const LinphoneAddress *linphone_friend_get_address(const LinphoneFriend *lf);
-/**
- * get subscription flag value
- * @param lf #LinphoneFriend object
- * @return returns true is subscription is activated for this friend
- *
- */
-bool_t linphone_friend_subscribes_enabled(const LinphoneFriend *lf);
-#define linphone_friend_get_send_subscribe linphone_friend_subscribes_enabled
-/**
- * get current subscription policy for this #LinphoneFriend
- * @param lf #LinphoneFriend object
- * @return #LinphoneSubscribePolicy
- *
- */
-LinphoneSubscribePolicy linphone_friend_get_inc_subscribe_policy(const LinphoneFriend *lf);
+
+
+
+
/**
* get friend status
* @return #LinphoneOnlineStatus
#define linphone_friend_url(lf) ((lf)->url)
+/**
+ * return humain readable presence status
+ * @param ss
+ */
+const char *linphone_online_status_to_string(LinphoneOnlineStatus ss);
+
+
/**
* Set my presence status
* @param lc #LinphoneCore object
/**
* Black list a friend. same as linphone_friend_set_inc_subscribe_policy() with #LinphoneSPDeny policy;
* @param lc #LinphoneCore object
- * @param fr #LinphoneFriend to add
+ * @param lf #LinphoneFriend to add
*/
void linphone_core_reject_subscriber(LinphoneCore *lc, LinphoneFriend *lf);
/**
linphone_gtk_display_something(GTK_MESSAGE_WARNING,_("Invalid sip contact !"));
return ;
}
- linphone_friend_set_sip_addr(lf,fixed_uri);
+ LinphoneAddress* friend_address = linphone_address_new(fixed_uri);
+ linphone_address_set_display_name(friend_address,name);
+ linphone_friend_set_addr(lf,friend_address);
ms_free(fixed_uri);
- linphone_friend_set_name(lf,name);
+ linphone_address_destroy(friend_address);
+
linphone_friend_send_subscribe(lf,show_presence);
linphone_friend_set_inc_subscribe_policy(lf,allow_presence==TRUE ? LinphoneSPAccept : LinphoneSPDeny);
if (linphone_friend_in_list(lf)) {