static void linphonec_display_url (LinphoneCore * lc, const char *something, const char *url);
static void linphonec_display_warning (LinphoneCore * lc, const char *something);
static void stub () {}
-static void linphonec_notify_received(LinphoneCore *lc,LinphoneFriend *fid);
+static void linphonec_notify_received(LinphoneCore *lc,const char *from,const char *msg);
+static void linphonec_notify_presence_received(LinphoneCore *lc,LinphoneFriend *fid);
static void linphonec_new_unknown_subscriber(LinphoneCore *lc,
LinphoneFriend *lf, const char *url);
static void linphonec_bye_received(LinphoneCore *lc, const char *from);
.inv_recv = linphonec_call_received,
.bye_recv = linphonec_bye_received,
.notify_recv = linphonec_notify_received,
+ .notify_presence_recv = linphonec_notify_presence_received,
.new_unknown_subscriber = linphonec_new_unknown_subscriber,
.auth_info_requested = linphonec_prompt_for_auth,
.display_status = linphonec_display_status,
static void
linphonec_display_refer (LinphoneCore * lc,const char *refer_to)
{
- fprintf (stdout, "The distant end point asked to transfer the call to %s,don't forget to terminate the call\n%s", refer_to,prompt);
+ fprintf (stdout, "The distant end point asked to transfer the call to %s,don't forget to terminate the call if not\n%s", refer_to,prompt);
fflush(stdout);
}
* Linphone core callback
*/
static void
-linphonec_notify_received(LinphoneCore *lc,LinphoneFriend *fid)
+linphonec_notify_received(LinphoneCore *lc,const char *from,const char *msg)
+{
+ printf("Notify type %s from %s\n", msg, from);
+ if(!strcmp(msg,"refer"))
+ {
+ printf("The distant SIP end point get the refer we can close the call\n");
+ linphonec_parse_command_line(linphonec, "terminate");
+ }
+}
+
+/*
+ * Linphone core callback
+ */
+static void
+linphonec_notify_presence_received(LinphoneCore *lc,LinphoneFriend *fid)
{
char *tmp=linphone_address_as_string(linphone_friend_get_address(fid));
printf("Friend %s is %s\n", tmp, linphone_online_status_to_string(linphone_friend_get_status(fid)));
linphonec_vtable.show =(ShowInterfaceCb) stub;
linphonec_vtable.inv_recv = linphonec_call_received;
linphonec_vtable.bye_recv = linphonec_bye_received;
- linphonec_vtable.notify_recv = linphonec_notify_received;
+ linphonec_vtable.notify_presence_recv = linphonec_notify_received;
linphonec_vtable.new_unknown_subscriber = linphonec_new_unknown_subscriber;
linphonec_vtable.auth_info_requested = linphonec_prompt_for_auth;
linphonec_vtable.display_status = linphonec_display_status;
}
static void refer_received(Sal *sal, SalOp *op, const char *referto){
- osip_message_t *msg;
LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal);
- if(op != NULL)
- {
- eXosip_call_build_notify(op->tid,EXOSIP_SUBCRSTATE_ACTIVE,&msg);
- if(msg != NULL)
- {
- osip_message_set_header(msg,(const char *)"event","refer");
- osip_message_set_content_type(msg,"message/sipfrag");
- osip_message_set_body(msg,"SIP/2.0 100 Trying",sizeof("SIP/2.0 100 Trying"));
- eXosip_call_send_request(op->tid,msg);
- }
- }
- if (lc->vtable.refer_received)
+ if (lc->vtable.refer_received){
lc->vtable.refer_received(lc,referto);
+ if (op) sal_refer_accept(op);
+ }
}
static void text_received(Sal *sal, const char *from, const char *msg){
linphone_core_text_received(lc,from,msg);
}
-static void notify(SalOp *op, SalSubscribeState ss, SalPresenceStatus status, const char *msg){
+static void notify(SalOp *op, const char *from, const char *msg){
+ LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
+
+ ms_message("get a %s notify from %s",msg,from);
+ if(lc->vtable.notify_recv)
+ lc->vtable.notify_recv(lc,from,msg);
+}
+
+static void notify_presence(SalOp *op, SalSubscribeState ss, SalPresenceStatus status, const char *msg){
LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
linphone_notify_recv(lc,op,ss,status);
}
refer_received,
text_received,
notify,
+ notify_presence,
subscribe_received,
subscribe_closed,
internal_message,
ms_warning("No established call to refer.");
return -1;
}
- lc->call=NULL;
+ //lc->call=NULL; //Do not do that you will lose the call afterward . . .
real_url=linphone_address_as_string (real_parsed_url);
sal_refer(call->op,real_url);
ms_free(real_url);
/** Callback prototype */
typedef void (*LinphoneCoreCbFunc)(struct _LinphoneCore *lc,void * user_data);
/** Callback prototype */
-typedef void (*NotifyReceivedCb)(struct _LinphoneCore *lc, LinphoneFriend * fid);
+typedef void (*NotifyReceivedCb)(struct _LinphoneCore *lc, const char *from, const char *msg);
+/** Callback prototype */
+typedef void (*NotifyPresenceReceivedCb)(struct _LinphoneCore *lc, LinphoneFriend * fid);
/** Callback prototype */
typedef void (*NewUnknownSubscriberCb)(struct _LinphoneCore *lc, LinphoneFriend *lf, const char *url);
/** Callback prototype */
ShowInterfaceCb show; /**< Notifies the application that it should show up*/
InviteReceivedCb inv_recv; /**< Notifies incoming calls */
ByeReceivedCb bye_recv; /**< Notify calls terminated by far end*/
- NotifyReceivedCb notify_recv; /**< Notify received presence events*/
+ NotifyPresenceReceivedCb notify_presence_recv; /**< Notify received presence events*/
NewUnknownSubscriberCb new_unknown_subscriber; /**< Notify about unknown subscriber */
AuthInfoRequested auth_info_requested; /**< Ask the application some authentication information */
DisplayStatusCb display_status; /**< Callback that notifies various events with human readable text.*/
DtmfReceived dtmf_received; /**< A dtmf has been received received */
ReferReceived refer_received; /**< A refer was received */
BuddyInfoUpdated buddy_info_updated; /**< a LinphoneFriend's BuddyInfo has changed*/
+ NotifyReceivedCb notify_recv; /**< Other notifications*/
} LinphoneCoreVTable;
/**
tmp=linphone_address_as_string(friend);
lf->status=estatus;
lf->subscribe_active=TRUE;
- lc->vtable.notify_recv(lc,(LinphoneFriend*)lf);
+ lc->vtable.notify_presence_recv(lc,(LinphoneFriend*)lf);
ms_free(tmp);
}else{
ms_message("But this person is not part of our friend list, so we don't care.");
typedef void (*SalOnDtmfReceived)(SalOp *op, char dtmf);
typedef void (*SalOnRefer)(Sal *sal, SalOp *op, const char *referto);
typedef void (*SalOnTextReceived)(Sal *sal, const char *from, const char *msg);
-typedef void (*SalOnNotify)(SalOp *op, SalSubscribeState ss, SalPresenceStatus status, const char *msg);
+typedef void (*SalOnNotify)(SalOp *op, const char *from, const char *value);
+typedef void (*SalOnNotifyPresence)(SalOp *op, SalSubscribeState ss, SalPresenceStatus status, const char *msg);
typedef void (*SalOnSubscribeReceived)(SalOp *salop, const char *from);
typedef void (*SalOnSubscribeClosed)(SalOp *salop, const char *from);
typedef void (*SalOnInternalMsg)(Sal *sal, const char *msg);
SalOnRefer refer_received;
SalOnTextReceived text_received;
SalOnNotify notify;
+ SalOnNotifyPresence notify_presence;
SalOnSubscribeReceived subscribe_received;
SalOnSubscribeClosed subscribe_closed;
SalOnInternalMsg internal_message;
int sal_call_decline(SalOp *h, SalReason reason, const char *redirection /*optional*/);
SalMediaDescription * sal_call_get_final_media_description(SalOp *h);
int sal_refer(SalOp *h, const char *refer_to);
+int sal_refer_accept(SalOp *h);
int sal_call_send_dtmf(SalOp *h, char dtmf);
int sal_call_terminate(SalOp *h);
bool_t sal_call_autoanswer_asked(SalOp *op);
ctx->callbacks.dtmf_received=(SalOnDtmfReceived)unimplemented_stub;
if (ctx->callbacks.notify==NULL)
ctx->callbacks.notify=(SalOnNotify)unimplemented_stub;
+ if (ctx->callbacks.notify_presence==NULL)
+ ctx->callbacks.notify_presence=(SalOnNotifyPresence)unimplemented_stub;
if (ctx->callbacks.subscribe_received==NULL)
ctx->callbacks.subscribe_received=(SalOnSubscribeReceived)unimplemented_stub;
if (ctx->callbacks.text_received==NULL)
return -1;
}
+int sal_refer_accept(SalOp *op){
+ osip_message_t *msg=NULL;
+ int err=0;
+ eXosip_lock();
+ err = eXosip_call_build_notify(op->did,EXOSIP_SUBCRSTATE_ACTIVE,&msg);
+ if(msg != NULL)
+ {
+ osip_message_set_header(msg,(const char *)"event","refer");
+ osip_message_set_content_type(msg,"message/sipfrag");
+ osip_message_set_body(msg,"SIP/2.0 100 Trying",sizeof("SIP/2.0 100 Trying"));
+ eXosip_call_send_request(op->did,msg);
+ }
+ else
+ {
+ ms_error("could not get a notify built\n");
+ }
+ eXosip_unlock();
+ return err;
+}
+
int sal_refer(SalOp *h, const char *refer_to){
osip_message_t *msg=NULL;
int err=0;
SalError error=SalErrorUnknown;
SalReason sr=SalReasonUnknown;
- op=(SalOp*)ev->external_reference;
+ op=(SalOp*)find_op(sal,ev);
if (op==NULL) {
ms_warning("Call failure reported for a closed call, ignored.");
static void process_media_control_xml(Sal *sal, eXosip_event_t *ev){
- SalOp *op=(SalOp*)ev->external_reference;
+ SalOp *op=find_op(sal,ev);
osip_body_t *body=NULL;
if (op==NULL){
}
static void process_dtmf_relay(Sal *sal, eXosip_event_t *ev){
- SalOp *op=(SalOp*)ev->external_reference;
+ SalOp *op=find_op(sal,ev);
osip_body_t *body=NULL;
if (op==NULL){
}
if(MSG_IS_REFER(ev->request)){
osip_header_t *h=NULL;
+ SalOp *op=find_op(sal,ev);
+
ms_message("Receiving REFER request !");
osip_message_header_get_byname(ev->request,"Refer-To",0,&h);
eXosip_lock();
eXosip_call_send_answer(ev->tid,202,ans);
eXosip_unlock();
if (h){
- SalOp *op=(SalOp*)ev->external_reference;
sal->callbacks.refer_received(sal,op,h->hvalue);
}
+ else
+ {
+ ms_warning("cannot do anything with the refer without destination\n");
+ }
}
if(MSG_IS_NOTIFY(ev->request)){
osip_header_t *h=NULL;
+ char *from=NULL;
+ SalOp *op=find_op(sal,ev);
+
ms_message("Receiving NOTIFY request !");
+ osip_from_to_str(ev->request->from,&from);
osip_message_header_get_byname(ev->request,"Event",0,&h);
- if (h){
- if(!strcmp(h->hvalue,"refer"))
- {
- ms_message("get the notify of the Refer sent");
- }
- }
+ if(h)
+ sal->callbacks.notify(op,from,h->hvalue);
+ /*answer that we received the notify*/
eXosip_lock();
eXosip_call_build_answer(ev->tid,200,&ans);
if (ans)
eXosip_call_send_answer(ev->tid,200,ans);
eXosip_unlock();
+ osip_free(from);
}
}else ms_warning("call_message_new: No request ?");
}
osip_message_header_get_byname(ev->request,"Refer-To",0,&h);
eXosip_message_send_answer(ev->tid,200,NULL);
if (h){
- SalOp *op=(SalOp*)ev->external_reference;
- sal->callbacks.refer_received(sal,op,h->hvalue);
+ sal->callbacks.refer_received(sal,NULL,h->hvalue);
}
}else ms_warning("Ignored REFER not coming from this local loopback interface.");
}else if (strncmp(ev->request->sip_method, "UPDATE", 6) == 0){
}
static bool_t process_event(Sal *sal, eXosip_event_t *ev){
+ ms_message("linphone process event get a message %d\n",ev->type);
switch(ev->type){
case EXOSIP_CALL_ANSWERED:
ms_message("CALL_ANSWERED\n");
op->did=-1;
ms_message("And outgoing subscription terminated by remote.");
}
- sal->callbacks.notify(op,op->sid!=-1 ? SalSubscribeActive : SalSubscribeTerminated, estatus,NULL);
+ sal->callbacks.notify_presence(op,op->sid!=-1 ? SalSubscribeActive : SalSubscribeTerminated, estatus,NULL);
osip_free(tmp);
}
sal_remove_out_subscribe(sal,op);
op->sid=-1;
op->did=-1;
- sal->callbacks.notify(op,SalSubscribeTerminated, SalPresenceOffline,NULL);
+ sal->callbacks.notify_presence(op,SalSubscribeTerminated, SalPresenceOffline,NULL);
}
.show=linphone_gtk_show,
.inv_recv=linphone_gtk_inv_recv,
.bye_recv=linphone_gtk_bye_recv,
- .notify_recv=linphone_gtk_notify_recv,
+ .notify_presence_recv=linphone_gtk_notify_recv,
.new_unknown_subscriber=linphone_gtk_new_unknown_subscriber,
.auth_info_requested=linphone_gtk_auth_info_requested,
.display_status=linphone_gtk_display_status,