Commit f92683df authored by jehan's avatar jehan
Browse files

fix for fried api dicumentation

parent 4fa2a209
...@@ -171,8 +171,13 @@ LinphoneFriend * linphone_friend_new(){ ...@@ -171,8 +171,13 @@ LinphoneFriend * linphone_friend_new(){
} }
LinphoneFriend *linphone_friend_new_with_addr(const char *addr){ 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(); 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); linphone_friend_destroy(fr);
return NULL; return NULL;
} }
...@@ -216,8 +221,8 @@ void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char ...@@ -216,8 +221,8 @@ void linphone_core_interpret_friend_uri(LinphoneCore *lc, const char *uri, char
linphone_address_destroy(fr); linphone_address_destroy(fr);
} }
int linphone_friend_set_sip_addr(LinphoneFriend *lf, const char *addr){ int linphone_friend_set_addr(LinphoneFriend *lf, const LinphoneAddress *addr){
LinphoneAddress *fr=linphone_address_new(addr); LinphoneAddress *fr=linphone_address_clone(addr);
if (fr==NULL) { if (fr==NULL) {
ms_warning("Invalid friend sip uri: %s",addr); ms_warning("Invalid friend sip uri: %s",addr);
return -1; return -1;
......
...@@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/** /**
* @defgroup buddy_tutorials Basic buddy status notification * @defgroup buddy_tutorials Basic buddy status notification
* @ingroup tutorials * @ingroup tutorials
*This program is a _very_ simple usage example of liblinphone. *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. *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>Argument must be like sip:jehan@sip.linphone.org .
*<br> *<br>
*ex budy_list sip:jehan@sip.linphone.org *ex budy_list sip:jehan@sip.linphone.org
...@@ -76,7 +76,7 @@ int main(int argc, char *argv[]){ ...@@ -76,7 +76,7 @@ int main(int argc, char *argv[]){
} }
signal(SIGINT,stop); signal(SIGINT,stop);
#define DEBUG //#define DEBUG
#ifdef DEBUG #ifdef DEBUG
linphone_core_enable_logs(NULL); /*enable liblinphone logs.*/ linphone_core_enable_logs(NULL); /*enable liblinphone logs.*/
#endif #endif
...@@ -102,11 +102,7 @@ int main(int argc, char *argv[]){ ...@@ -102,11 +102,7 @@ int main(int argc, char *argv[]){
} }
linphone_friend_enable_subscribes(my_friend,TRUE); /*configure this friend to emit SUBSCRIBE message after being added to LinphoneCore*/ 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_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*/ linphone_core_add_friend(lc,my_friend); /* add my friend to the buddy list, initiate SUBSCRIBE message*/
} }
......
...@@ -109,14 +109,13 @@ ...@@ -109,14 +109,13 @@
* @defgroup buddy_list Managing Buddies and buddy list and presence * @defgroup buddy_list Managing Buddies and buddy list and presence
<b>Buddies and buddy list</b> <b>Buddies and buddy list</b>
<br>Each buddy is represented by a #LinphoneFriend object created by function linphone_friend_new(). <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>Here under a typical buddy creation:
<br> <br>
\code \code
LinphoneFriend* my_friend=linphone_friend_new_with_addr("sip:joe@sip.linphone.org"); /*creates friend object for buddy joe*/ 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_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_friend_set_inc_subscribe_policy(my_friend,LinphoneSPAccept); /* Incoming subscription request for this friend*/
\endcode \endcode
\link #LinphoneFriend friends \endlink status changes are reported by callback LinphoneCoreVTable.notify_presence_recv \link #LinphoneFriend friends \endlink status changes are reported by callback LinphoneCoreVTable.notify_presence_recv
\code \code
...@@ -129,7 +128,7 @@ static void notify_presence_recv_updated (struct _LinphoneCore *lc, LinphoneFri ...@@ -129,7 +128,7 @@ static void notify_presence_recv_updated (struct _LinphoneCore *lc, LinphoneFri
\endcode \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>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> <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 \code
linphone_friend_edit(my_friend); /* start editing friend */ linphone_friend_edit(my_friend); /* start editing friend */
linphone_friend_enable_subscribes(my_friend,FALSE); /*disable subscription for this friend*/ linphone_friend_enable_subscribes(my_friend,FALSE); /*disable subscription for this friend*/
...@@ -138,11 +137,11 @@ linphone_friend_done(my_friend); /*commit changes triggering an UNSUBSCRIBE mess ...@@ -138,11 +137,11 @@ linphone_friend_done(my_friend); /*commit changes triggering an UNSUBSCRIBE mess
<b> Publishing presence status </b> <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> <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> 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> 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" <br> A complete tutorial can be found at : \ref buddy_tutorials "Registration tutorial"
......
...@@ -34,7 +34,7 @@ extern "C" { ...@@ -34,7 +34,7 @@ extern "C" {
typedef enum { typedef enum {
/** /**
* Does not automatically accept an incoming subscription request. * 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, LinphoneSPWait,
...@@ -99,11 +99,6 @@ typedef enum _LinphoneOnlineStatus{ ...@@ -99,11 +99,6 @@ typedef enum _LinphoneOnlineStatus{
LinphoneStatusEnd LinphoneStatusEnd
}LinphoneOnlineStatus; }LinphoneOnlineStatus;
/**
* return humain readable presence status
* @param ss
*/
const char *linphone_online_status_to_string(LinphoneOnlineStatus ss);
struct _LinphoneFriend; struct _LinphoneFriend;
...@@ -118,25 +113,40 @@ typedef struct _LinphoneFriend LinphoneFriend; ...@@ -118,25 +113,40 @@ typedef struct _LinphoneFriend LinphoneFriend;
*/ */
LinphoneFriend * linphone_friend_new(); 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 * @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 * @return a new #LinphoneFriend with \link linphone_friend_get_address() address initialized \endlink
*/ */
LinphoneFriend *linphone_friend_new_with_addr(const char *addr); LinphoneFriend *linphone_friend_new_with_addr(const char *addr);
/** /**
* Configure #LinphoneFriend with a new address. * Destructor
* @param uri a buddy address, must be a sip uri like sip:joe@sip.linphone.org * @param lf #LinphoneFriend object
* @return 0 if succeed
*/ */
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 fr #LinphoneFriend object
* @param new name * @param address #LinphoneAddress
* @return 0 if succeed */
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 * Configure #LinphoneFriend to subscribe to presence information
* @param fr #LinphoneFriend object * @param fr #LinphoneFriend object
...@@ -152,12 +162,20 @@ int linphone_friend_enable_subscribes(LinphoneFriend *fr, bool_t val); ...@@ -152,12 +162,20 @@ int linphone_friend_enable_subscribes(LinphoneFriend *fr, bool_t val);
* @param pol #LinphoneSubscribePolicy policy to apply. * @param pol #LinphoneSubscribePolicy policy to apply.
*/ */
int linphone_friend_set_inc_subscribe_policy(LinphoneFriend *fr, LinphoneSubscribePolicy pol); 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. * Starts editing a friend configuration.
* *
* Because friend configuration must be consistent, applications MUST * Because friend configuration must be consistent, applications MUST
* call linphone_friend_edit() before doing any attempts to modify * 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 * Once the modifications are done, then the application must call
* linphone_friend_done() to commit the changes. * linphone_friend_done() to commit the changes.
**/ **/
...@@ -167,32 +185,10 @@ void linphone_friend_edit(LinphoneFriend *fr); ...@@ -167,32 +185,10 @@ void linphone_friend_edit(LinphoneFriend *fr);
* @param fr #LinphoneFriend object * @param fr #LinphoneFriend object
**/ **/
void linphone_friend_done(LinphoneFriend *fr); 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 * get friend status
* @return #LinphoneOnlineStatus * @return #LinphoneOnlineStatus
...@@ -205,6 +201,13 @@ bool_t linphone_friend_in_list(const LinphoneFriend *lf); ...@@ -205,6 +201,13 @@ bool_t linphone_friend_in_list(const LinphoneFriend *lf);
#define linphone_friend_url(lf) ((lf)->url) #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 * Set my presence status
* @param lc #LinphoneCore object * @param lc #LinphoneCore object
...@@ -236,7 +239,7 @@ void linphone_core_remove_friend(LinphoneCore *lc, LinphoneFriend *fr); ...@@ -236,7 +239,7 @@ void linphone_core_remove_friend(LinphoneCore *lc, LinphoneFriend *fr);
/** /**
* Black list a friend. same as linphone_friend_set_inc_subscribe_policy() with #LinphoneSPDeny policy; * Black list a friend. same as linphone_friend_set_inc_subscribe_policy() with #LinphoneSPDeny policy;
* @param lc #LinphoneCore object * @param lc #LinphoneCore object
* @param fr #LinphoneFriend to add * @param lf #LinphoneFriend to add
*/ */
void linphone_core_reject_subscriber(LinphoneCore *lc, LinphoneFriend *lf); void linphone_core_reject_subscriber(LinphoneCore *lc, LinphoneFriend *lf);
/** /**
......
...@@ -450,9 +450,12 @@ void linphone_gtk_contact_ok(GtkWidget *button){ ...@@ -450,9 +450,12 @@ void linphone_gtk_contact_ok(GtkWidget *button){
linphone_gtk_display_something(GTK_MESSAGE_WARNING,_("Invalid sip contact !")); linphone_gtk_display_something(GTK_MESSAGE_WARNING,_("Invalid sip contact !"));
return ; 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); ms_free(fixed_uri);
linphone_friend_set_name(lf,name); linphone_address_destroy(friend_address);
linphone_friend_send_subscribe(lf,show_presence); linphone_friend_send_subscribe(lf,show_presence);
linphone_friend_set_inc_subscribe_policy(lf,allow_presence==TRUE ? LinphoneSPAccept : LinphoneSPDeny); linphone_friend_set_inc_subscribe_policy(lf,allow_presence==TRUE ? LinphoneSPAccept : LinphoneSPDeny);
if (linphone_friend_in_list(lf)) { if (linphone_friend_in_list(lf)) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment