]> sjero.net Git - linphone/commitdiff
Merge branch 'master' into dev_multicall
authorSimon Morlat <simon.morlat@linphone.org>
Wed, 12 May 2010 08:00:49 +0000 (10:00 +0200)
committerSimon Morlat <simon.morlat@linphone.org>
Wed, 12 May 2010 08:00:49 +0000 (10:00 +0200)
Conflicts:
coreapi/callbacks.c
coreapi/linphonecore.c

20 files changed:
console/commands.c
console/linphonec.c
coreapi/Makefile.am
coreapi/callbacks.c
coreapi/chat.c
coreapi/linphonecall.c [new file with mode: 0644]
coreapi/linphonecore.c
coreapi/linphonecore.h
coreapi/private.h
coreapi/sal.h
coreapi/sal_eXosip2.c
coreapi/sal_eXosip2_sdp.c
gtk-glade/incall_view.c
gtk-glade/linphone.h
gtk-glade/main.c
gtk-glade/main.glade
mediastreamer2
pixmaps/Makefile.am
pixmaps/hold_off.png [new file with mode: 0644]
pixmaps/hold_on.png [new file with mode: 0644]

index d52a0e8402024fe4b3850a3d466cd974d1f248b0..73e1b2b5425a49cacb2143b3b8c20701e26afbeb 100644 (file)
@@ -78,6 +78,8 @@ static int lpc_cmd_ports(LinphoneCore *lc, char *args);
 static int lpc_cmd_speak(LinphoneCore *lc, char *args);
 static int lpc_cmd_codec(LinphoneCore *lc, char *args);
 static int lpc_cmd_echocancellation(LinphoneCore *lc, char *args);
+static int lpc_cmd_pause(LinphoneCore *lc, char *args);
+static int lpc_cmd_resume(LinphoneCore *lc, char *args);
 
 /* Command handler helpers */
 static void linphonec_proxy_add(LinphoneCore *lc);
@@ -120,17 +122,21 @@ void linphonec_out(const char *fmt,...);
 LPC_COMMAND commands[] = {
        { "help", lpc_cmd_help, "Print commands help", NULL },
        { "call", lpc_cmd_call, "Call a SIP uri",
-               "'call <sip-url>' "
-               ": initiate a call to the specified destination."
+               "'call <sip-url>' \t: initiate a call to the specified destination.\n"
+               "'call show' \t: show all the current calls status.\n"
                },
        { "chat", lpc_cmd_chat, "Chat with a SIP uri",
                "'chat <sip-url> \"message\"' "
                ": send a chat message \"message\" to the specified destination."
                },
-       { "terminate", lpc_cmd_terminate, "Terminate the current call",
-               NULL },
+       { "terminate", lpc_cmd_terminate, "Terminate a call",
+               "'terminate' : Terminate the current call\n"
+               "'terminate <sip:XXX@XXX.XXX.XXX.XXX>' : Terminate the call with remote address\n"
+               "'terminate <all>' : Terminate all the current calls\n"
+               },
        { "answer", lpc_cmd_answer, "Answer a call",
-               "Accept an incoming call."
+               "'answer' : Answer the current incoming call\n"
+               "'answer <sip:XXX@XXX.XXX.XXX.XXX>' : Answer the call with remote address\n"
        },
        { "autoanswer", lpc_cmd_autoanswer, "Show/set auto-answer mode",
                "'autoanswer'       \t: show current autoanswer mode\n"
@@ -223,7 +229,12 @@ LPC_COMMAND commands[] = {
             "'ec on [<delay>] [<tail>] [<framesize>]' : turn EC on with given delay, tail length and framesize\n"
             "'ec off' : turn echo cancellation (EC) off\n"
             "'ec show' : show EC status" },
-       { (char *)NULL, (lpc_cmd_handler)NULL, (char *)NULL, (char *)NULL }
+    { "pause", lpc_cmd_pause, "pause a call",
+               "'pause' : pause the current call\n"},
+    { "resume", lpc_cmd_resume, "resume a call",
+               "'resume' : resume the unique call\n"
+               "'resume <sip:XXX@XXX.XXX.XXX.XXX>' : hold off the call with cid <cid>\n"},
+    { (char *)NULL, (lpc_cmd_handler)NULL, (char *)NULL, (char *)NULL }
 };
 
 /***************************************************************************
@@ -374,14 +385,35 @@ lpc_cmd_call(LinphoneCore *lc, char *args)
        {
                return 0;
        }
-
-       if ( lc->call != NULL )
+       if(!strcmp(args,"show"))
        {
-               linphonec_out("Terminate current call first.\n");
+               MSList *calls = linphone_core_get_calls(lc);
+               if(calls)
+               {
+                       MSList *p_calls = calls;
+                       linphonec_out("<remote>\t\t\t\t<status>\r\n");
+                       while(p_calls != NULL)                  
+                       {
+                               linphonec_out("%s\t\t\t%s\r\n",
+                                               linphone_call_get_remote_address_as_string(p_calls->data),
+                                               (((LinphoneCall *)p_calls->data)==linphone_core_get_current_call(lc))?"yes":"no");
+                               p_calls = p_calls->next;
+                       }
+                       ms_list_free(calls);
+               }
+               else
+               {
+                       linphonec_out("No active call.\n");
+               }
        }
        else
        {
-               if ( -1 == linphone_core_invite(lc, args) )
+               if ( linphone_core_in_call(lc) )
+               {
+                       linphonec_out("Terminate or hold on the current call first.\n");
+                       return 1;
+               }
+               if ( NULL == linphone_core_invite(lc, args) )
                {
                        linphonec_out("Error from linphone_core_invite.\n");
                }
@@ -438,7 +470,7 @@ static int
 lpc_cmd_refer(LinphoneCore *lc, char *args)
 {
        if (args)
-               linphone_core_refer(lc, args);
+               linphone_core_refer(lc, linphone_core_get_current_call(lc), args);
        else{
                linphonec_out("refer needs an argument\n");
        }
@@ -448,21 +480,98 @@ lpc_cmd_refer(LinphoneCore *lc, char *args)
 static int
 lpc_cmd_terminate(LinphoneCore *lc, char *args)
 {
-       if ( -1 == linphone_core_terminate_call(lc, NULL) )
+       char *arg1 = args;
+       char *arg2 = NULL;
+       char *ptr = args;
+
+       if (!args)
        {
-               linphonec_out("No active call.\n");
+               if(linphone_core_in_call(lc))
+               {
+                       if ( -1 == linphone_core_terminate_call(lc, linphone_core_get_current_call(lc)) )
+                       {
+                               linphonec_out("Could not stop the active call.\n");
+                       }
+               }
+               else
+               {
+                       linphonec_out("No active call.\n");
+               }
+               return 1;
        }
-       return 1;
+       
+       /* Isolate first and second arg */
+       while(*ptr && !isspace(*ptr)) ++ptr;
+       if ( *ptr )
+       {
+               *ptr='\0';
+               arg2=ptr+1;
+               while(*arg2 && isspace(*arg2)) ++arg2;
+       }
+       if (arg1 != 0)
+       {
+               if(strcmp(arg1,"all")==0)
+               {
+                       linphonec_out("We are going to stop all the calls.\n");
+                       return (linphone_core_terminate_all_calls(lc)==0)?1:0;
+               }
+               else
+               {
+                       char the_remote_address[255];
+                       int n = sscanf(arg1, "%s", the_remote_address);
+                       if (n == 1)
+                       {
+                               if ( -1 == linphone_core_terminate_call(lc,linphone_core_get_call_by_remote_address(lc,the_remote_address)))
+                               {
+                                       linphonec_out("Cannot stop the call with %s.\n",the_remote_address);
+                               }
+                               return 1;
+                       }
+               }
+       }
+       return 0;
+       
 }
 
 static int
 lpc_cmd_answer(LinphoneCore *lc, char *args)
 {
-       if ( -1 == linphone_core_accept_call(lc, NULL) )
+       char *arg1 = args;
+       char *arg2 = NULL;
+       char *ptr = args;
+
+       if (!args)
        {
-               linphonec_out("No incoming call.\n");
+               //if just one call is present answer the only one in passing NULL to the linphone_core_accept_call ...
+               if ( -1 == linphone_core_accept_call(lc, NULL) )
+               {
+                       linphonec_out("No incoming call.\n");
+               }
+               return 1;
        }
-       return 1;
+
+       // Isolate first and second arg
+       while(*ptr && !isspace(*ptr)) ++ptr;
+       if ( *ptr )
+       {
+               *ptr='\0';
+               arg2=ptr+1;
+               while(*arg2 && isspace(*arg2)) ++arg2;
+       }
+       if (arg1 != 0)
+       {
+               char the_remote_address[256];
+               int n = sscanf(arg1, "%s", the_remote_address);
+               if (n == 1)
+               {
+                       if ( -1 == linphone_core_accept_call(lc, linphone_core_get_call_by_remote_address(lc,the_remote_address)) )
+                       {
+                               linphonec_out("Cannot answer the call from %s.\n",the_remote_address);
+                       }
+                       return 1;
+               }
+       }
+       return 0;
 }
 
 static int
@@ -1063,7 +1172,62 @@ lpc_cmd_staticpic(LinphoneCore *lc, char *args)
        return 0; /* Syntax error */
 }
 
+static int lpc_cmd_pause(LinphoneCore *lc, char *args){
 
+       if(linphone_core_in_call(lc))
+       {
+               linphone_core_pause_call(lc,linphone_core_get_current_call(lc));
+               return 1;
+       }
+       linphonec_out("you can only pause when a call is in process\n");
+    return 0;
+}
+
+static int lpc_cmd_resume(LinphoneCore *lc, char *args){
+       
+       if(linphone_core_in_call(lc))
+       {
+               linphonec_out("There is already a call in process pause or stop it first");
+       }
+       if (args)
+       {
+               char the_remote_address[255];
+               int n = sscanf(args, "%s", the_remote_address);
+               if (n == 1)
+               {
+                       if(linphone_core_resume_call(lc,linphone_core_get_call_by_remote_address(lc,the_remote_address)) < 0)
+                       {
+                               linphonec_out("There was a problem to resume the call check the remote address you gave %s\n",args);
+                               return 0;
+                       }
+                       else
+                       {
+                               return 1;
+                       }
+               }
+       }
+       else
+       {
+               int returned = 0;
+               MSList *calls = linphone_core_get_calls(lc);
+               if(ms_list_size(calls) == 1)
+               {
+                       if(linphone_core_resume_call(lc,calls->data) < 0)
+                       {
+                               linphonec_out("There was a problem to resume the unique call \n");
+                               returned = 0;
+                       }
+                       else
+                       {
+                               returned = 1;
+                       }
+                       ms_list_free(calls);
+                       return returned;
+               }
+       }
+       return 0;
+    
+}
 
 /***************************************************************************
  *
index 2d1ce98b31640c079acac2d24c5b4973fd20973b..86187ad7cceafc4ec65ddf00e9e885a93d0b9428 100644 (file)
@@ -112,10 +112,12 @@ static char **linephonec_readline_completion(const char *text,
 #endif
 
 /* These are callback for linphone core */
-static void linphonec_call_received(LinphoneCore *lc, const char *from);
+static void linphonec_call_received(LinphoneCore *lc, LinphoneCall *call);
+static void linphonec_paused_received(LinphoneCore *lc, LinphoneCall *call);
+static void linphonec_resumed_received(LinphoneCore *lc, LinphoneCall *call);
 static void linphonec_prompt_for_auth(LinphoneCore *lc, const char *realm,
        const char *username);
-static void linphonec_display_refer (LinphoneCore * lc,const char *refer_to);
+static void linphonec_display_refer (LinphoneCore * lc,LinphoneCall *call, const char *refer_to);
 static void linphonec_display_something (LinphoneCore * lc, const char *something);
 static void linphonec_display_url (LinphoneCore * lc, const char *something, const char *url);
 static void linphonec_display_warning (LinphoneCore * lc, const char *something);
@@ -124,13 +126,14 @@ static void linphonec_notify_received(LinphoneCore *lc,const char *from,const ch
 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);
+static void linphonec_bye_received(LinphoneCore *lc, LinphoneCall *call);
 static void linphonec_text_received(LinphoneCore *lc, LinphoneChatRoom *cr,
                const char *from, const char *msg);
 static void linphonec_display_status (LinphoneCore * lc, const char *something);
 static void linphonec_general_state (LinphoneCore * lc, LinphoneGeneralState *gstate);
 static void linphonec_dtmf_received(LinphoneCore *lc, int dtmf);
 static void print_prompt(LinphoneCore *opm);
+void linphonec_out(const char *fmt,...);
 /***************************************************************************
  *
  * Global variables
@@ -176,6 +179,11 @@ LinphoneCoreVTable linphonec_vtable
        .show =(ShowInterfaceCb) stub,
        .inv_recv = linphonec_call_received,
        .bye_recv = linphonec_bye_received,
+       .ringing_recv = (RingingReceivedCb) stub,
+       .connected_recv = (ConnectedReceivedCb) stub,
+       .failure_recv = (FailureReceivedCb) stub,
+       .paused_recv = linphonec_paused_received,
+       .resumed_recv = linphonec_resumed_received,
        .notify_recv = linphonec_notify_received,
        .notify_presence_recv = linphonec_notify_presence_received,
        .new_unknown_subscriber = linphonec_new_unknown_subscriber,
@@ -209,7 +217,7 @@ LinphoneCoreVTable linphonec_vtable
  * Linphone core callback
  */
 static void
-linphonec_display_refer (LinphoneCore * lc,const char *refer_to)
+linphonec_display_refer (LinphoneCore * lc,LinphoneCall *call, const char *refer_to)
 {
        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);
@@ -259,13 +267,43 @@ linphonec_display_url (LinphoneCore * lc, const char *something, const char *url
  * Linphone core callback
  */
 static void
-linphonec_call_received(LinphoneCore *lc, const char *from)
+linphonec_call_received(LinphoneCore *lc, LinphoneCall *call)
 {
+       char *from=linphone_call_get_remote_address_as_string(call);
        linphonec_set_caller(from);
+       ms_free(from);
        if ( auto_answer)  {
                answer_call=TRUE;
        }
 }
+/*
+ * Linphone core callback
+ */
+static void
+linphonec_paused_received(LinphoneCore *lc, LinphoneCall *call)
+{
+       char *from=linphone_call_get_remote_address_as_string(call);
+       if(from)
+       {
+               linphonec_out("the call from %s have been paused\n",from);
+               ms_free(from);
+       }
+}
+/*
+ * Linphone core callback
+ */
+static void
+linphonec_resumed_received(LinphoneCore *lc, LinphoneCall *call)
+{
+       char *from=linphone_call_get_remote_address_as_string(call);
+       if(from)
+       {
+               linphonec_out("the call from %s have been resumed\n",from);
+               ms_free(from);
+       }
+}
+
+
 
 /*
  * Linphone core callback
@@ -336,13 +374,15 @@ linphonec_new_unknown_subscriber(LinphoneCore *lc, LinphoneFriend *lf,
  * Linphone core callback
  */
 static void
-linphonec_bye_received(LinphoneCore *lc, const char *from)
+linphonec_bye_received(LinphoneCore *lc, LinphoneCall *call)
 {
        // Should change prompt back to original maybe
 
        // printing this is unneeded as we'd get a "Communication ended"
        // message trough display_status callback anyway
-       //printf("Bye received from %s\n", from);
+       char *from=linphone_call_get_remote_address_as_string(call);
+       printf("Bye received from %s\n", from);
+       ms_free(from);
 }
 
 /*
index 014ae308e0398d154b22e3feabb51b6b1e7c6901..b497c1ea1817bca30c99393cd1ca72b6715a9151 100644 (file)
@@ -33,6 +33,7 @@ liblinphone_la_SOURCES=\
        lpconfig.c lpconfig.h \
        chat.c \
        general_state.c \
+       linphonecall.c \
        sipsetup.c sipsetup.h \
        siplogin.c
 
index f15404dbf8b56051942462abdccc9cffd9daa8eb..67611e2e32ed4946b7cd8c9b1126efa8c8bc8d81 100644 (file)
@@ -30,12 +30,15 @@ static void linphone_connect_incoming(LinphoneCore *lc, LinphoneCall *call){
                lc->vtable.show(lc);
        if (lc->vtable.display_status)
                lc->vtable.display_status(lc,_("Connected."));
-       call->state=LCStateAVRunning;
+       if (lc->vtable.connected_recv)
+               lc->vtable.connected_recv(lc,call);
+       call->state=LinphoneCallAVRunning;
        if (lc->ringstream!=NULL){
                ring_stop(lc->ringstream);
                lc->ringstream=NULL;
        }
-       linphone_core_start_media_streams(lc,call);
+       if(call == linphone_core_get_current_call(lc))
+               linphone_core_start_media_streams(lc,call);
 }
 
 static void call_received(SalOp *h){
@@ -66,7 +69,7 @@ static void call_received(SalOp *h){
                sal_op_release(h);
                return;
        }
-       if (lc->call!=NULL){/*busy*/
+       if (!linphone_core_can_we_add_call(lc)){/*busy*/
                sal_call_decline(h,SalReasonBusy,NULL);
                sal_op_release(h);
                return;
@@ -75,15 +78,26 @@ static void call_received(SalOp *h){
        to=sal_op_get_to(h);
        
        call=linphone_call_new_incoming(lc,linphone_address_new(from),linphone_address_new(to),h);
-       lc->call=call;
+       if(linphone_core_add_call(lc,call)!= 0)
+       {
+               ms_warning("we cannot have more calls\n");
+               sal_call_decline(h,SalReasonMedia,NULL);
+               linphone_call_unref(call);
+               return;
+       }
+       if(linphone_core_get_current_call(lc)!=NULL) //we are already in call just inform that an incoming call is going on
+       {
+               char temp[256];
+               snprintf(temp,sizeof(temp),"A new incoming call from %s during call",from);
+               lc->vtable.display_status(lc,temp);
+       }
        sal_call_set_local_media_description(h,call->localdesc);
        call->resultdesc=sal_call_get_final_media_description(h);
        if (call->resultdesc)
                sal_media_description_ref(call->resultdesc);
        if (call->resultdesc && sal_media_description_empty(call->resultdesc)){
                sal_call_decline(h,SalReasonMedia,NULL);
-               linphone_call_destroy(call);
-               lc->call=NULL;
+               linphone_call_unref(call);
                return;
        }
        
@@ -99,25 +113,27 @@ static void call_received(SalOp *h){
            lc->vtable.display_status(lc,barmesg);
 
        /* play the ring */
-       if (lc->sound_conf.ring_sndcard!=NULL){
+       if (lc->sound_conf.ring_sndcard!=NULL && !linphone_core_in_call(lc)){
                ms_message("Starting local ring...");
                lc->ringstream=ring_start(lc->sound_conf.local_ring,2000,lc->sound_conf.ring_sndcard);
        }
-       linphone_call_set_state(call,LCStateRinging);
+       call->state=LinphoneCallRinging;
        sal_call_notify_ringing(h);
-       linphone_core_init_media_streams(lc,lc->call);
-       if (lc->vtable.inv_recv) lc->vtable.inv_recv(lc,tmp);
+       linphone_core_init_media_streams(lc,call);
+       if (lc->vtable.inv_recv) lc->vtable.inv_recv(lc,call);
        ms_free(barmesg);
        ms_free(tmp);
 }
 
 static void call_ringing(SalOp *h){
        LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(h));
-       LinphoneCall *call=lc->call;
+       LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(h);
        SalMediaDescription *md;
        if (call==NULL) return;
        if (lc->vtable.display_status)
                lc->vtable.display_status(lc,_("Remote ringing."));
+       if (lc->vtable.ringing_recv)
+               lc->vtable.ringing_recv(lc,call);
        md=sal_call_get_final_media_description(h);
        if (md==NULL){
                if (lc->ringstream!=NULL) return;       /*already ringing !*/
@@ -143,30 +159,30 @@ static void call_ringing(SalOp *h){
                        lc->ringstream=NULL;
                }
                ms_message("Doing early media...");
-               linphone_core_start_media_streams(lc,call);
+               if(call == linphone_core_get_current_call(lc))
+                       linphone_core_start_media_streams(lc,call);
                call->media_pending=TRUE;
        }
-       call->state=LCStateRinging;
+       call->state=LinphoneCallRinging;
 }
 
 static void call_accepted(SalOp *op){
        LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
-       LinphoneCall *call=lc->call;
+       LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
        if (call==NULL){
                ms_warning("No call to accept.");
                return ;
        }
-       if (sal_op_get_user_pointer(op)!=lc->call){
-               ms_warning("call_accepted: ignoring.");
-               return;
-       }
-       if (call->state==LCStateAVRunning){
+       if (call->state==LinphoneCallAVRunning){
                return ; /*already accepted*/
        }
-       if (lc->audiostream->ticker!=NULL){
+       if ((lc->audiostream!=NULL) && (lc->audiostream->ticker!=NULL)){
                /*case where we accepted early media */
-               linphone_core_stop_media_streams(lc,call);
-               linphone_core_init_media_streams(lc,call);
+               if(call == linphone_core_get_current_call(lc))
+               {
+                       linphone_core_stop_media_streams(lc,call);
+                       linphone_core_init_media_streams(lc,call);
+               }
        }
        if (call->resultdesc)
                sal_media_description_unref(call->resultdesc);
@@ -187,20 +203,19 @@ static void call_accepted(SalOp *op){
 
 static void call_ack(SalOp *op){
        LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
-       LinphoneCall *call=lc->call;
+       LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
        if (call==NULL){
                ms_warning("No call to be ACK'd");
                return ;
        }
-       if (sal_op_get_user_pointer(op)!=lc->call){
-               ms_warning("call_ack: ignoring.");
-               return;
-       }
        if (call->media_pending){
                if (lc->audiostream->ticker!=NULL){
                        /*case where we accepted early media */
-                       linphone_core_stop_media_streams(lc,call);
-                       linphone_core_init_media_streams(lc,call);
+                       if(call == linphone_core_get_current_call(lc))
+                       {
+                               linphone_core_stop_media_streams(lc,call);
+                               linphone_core_init_media_streams(lc,call);
+                       }
                }
                if (call->resultdesc)
                        sal_media_description_unref(call->resultdesc);
@@ -222,14 +237,45 @@ static void call_ack(SalOp *op){
 static void call_updated(SalOp *op){
        LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
        LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
-       linphone_core_stop_media_streams(lc,call);
-       linphone_core_init_media_streams(lc,call);
        if (call->resultdesc)
                sal_media_description_unref(call->resultdesc);
        call->resultdesc=sal_call_get_final_media_description(op);
-       if (call->resultdesc){
+       if (call->resultdesc)
                sal_media_description_ref(call->resultdesc);
-               if (sal_media_description_empty(call->resultdesc)){
+
+       if (call->resultdesc && !sal_media_description_empty(call->resultdesc))
+       {
+               if( (call->state == LinphoneCallPaused) && strcmp(call->resultdesc->addr,"0.0.0.0"))
+               {
+                       if(lc->vtable.display_status)
+                               lc->vtable.display_status(lc,"we have been resumed...");
+                       call->state = LinphoneCallAVRunning;
+                       lc->vtable.resumed_recv(lc,call);
+                       //we have to keep sending when holded
+                       //linphone_core_start_media_streams(lc,call);
+               }
+               else if( (call->state != LinphoneCallPaused) && !strcmp(call->resultdesc->addr,"0.0.0.0"))
+               {
+                       if(lc->vtable.display_status)
+                               lc->vtable.display_status(lc,"we have been paused...");
+                       call->state = LinphoneCallPaused;
+                       lc->vtable.paused_recv(lc,call);
+                       //we have to keep sending when holded
+                       /*
+                       if(call == linphone_core_get_current_call(lc))
+                       {
+                               linphone_core_stop_media_streams(lc,call);
+                               linphone_core_init_media_streams(lc,call);
+                       }
+                       */
+               }
+               else
+               {
+                       if(call == linphone_core_get_current_call(lc))
+                       {
+                               linphone_core_stop_media_streams(lc,call);
+                               linphone_core_init_media_streams(lc,call);
+                       }
                        linphone_connect_incoming(lc,call);
                }
        }
@@ -237,7 +283,8 @@ static void call_updated(SalOp *op){
 
 static void call_terminated(SalOp *op, const char *from){
        LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
-       if (sal_op_get_user_pointer(op)!=lc->call){
+       LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
+       if (linphone_call_get_state(call)==LinphoneCallTerminated){
                ms_warning("call_terminated: ignoring.");
                return;
        }
@@ -246,24 +293,25 @@ static void call_terminated(SalOp *op, const char *from){
                ring_stop(lc->ringstream);
                lc->ringstream=NULL;
        }
-       linphone_core_stop_media_streams(lc,lc->call);
+       if(call == linphone_core_get_current_call(lc))
+               linphone_core_stop_media_streams(lc,call);
        lc->vtable.show(lc);
        lc->vtable.display_status(lc,_("Call terminated."));
+       linphone_call_set_terminated(call);
        gstate_new_state(lc, GSTATE_CALL_END, NULL);
        if (lc->vtable.bye_recv!=NULL){
                LinphoneAddress *addr=linphone_address_new(from);
                char *tmp;
                linphone_address_clean(addr);
                tmp=linphone_address_as_string(addr);
-               lc->vtable.bye_recv(lc,tmp);
+               lc->vtable.bye_recv(lc,call);
                ms_free(tmp);
                linphone_address_destroy(addr);
        }
-       linphone_call_destroy(lc->call);
-       lc->call=NULL;
+       linphone_call_unref(call);
 }
 
-static void call_failure(SalOp *op, SalError error, SalReason sr, const char *details){
+static void call_failure(SalOp *op, SalError error, SalReason sr, const char *details, int code){
        LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(op));
        char *msg486=_("User is busy.");
        char *msg480=_("User is temporarily unavailable.");
@@ -271,12 +319,8 @@ static void call_failure(SalOp *op, SalError error, SalReason sr, const char *de
        char *msg600=_("User does not want to be disturbed.");
        char *msg603=_("Call declined.");
        char *msg=NULL;
-       LinphoneCall *call=lc->call;
+       LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
 
-       if (sal_op_get_user_pointer(op)!=lc->call){
-               ms_warning("call_failure: ignoring.");
-               return;
-       }
        if (lc->vtable.show) lc->vtable.show(lc);
 
        if (error==SalErrorNoResponse){
@@ -327,16 +371,19 @@ static void call_failure(SalOp *op, SalError error, SalReason sr, const char *de
                                        lc->vtable.display_status(lc,_("Call failed."));
                }
        }
+       if (lc->vtable.failure_recv)
+               lc->vtable.failure_recv(lc,call,code);
        if (lc->ringstream!=NULL) {
                ring_stop(lc->ringstream);
                lc->ringstream=NULL;
        }
-       linphone_core_stop_media_streams(lc,call);
+       if(call == linphone_core_get_current_call(lc))
+               linphone_core_stop_media_streams(lc,call);
        if (call!=NULL) {
-               linphone_call_destroy(call);
+               linphone_call_set_terminated(call);
+               linphone_call_unref(call);//TODO not an unref here ???//AUREL
                if (sr!=SalReasonDeclined) gstate_new_state(lc, GSTATE_CALL_ERROR, msg);
                else gstate_new_state(lc, GSTATE_CALL_END, NULL);
-               lc->call=NULL;
        }
 }
 
@@ -405,8 +452,9 @@ static void dtmf_received(SalOp *op, char dtmf){
 
 static void refer_received(Sal *sal, SalOp *op, const char *referto){
        LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal);
+       LinphoneCall *call=(LinphoneCall*)sal_op_get_user_pointer(op);
        if (lc->vtable.refer_received){
-               lc->vtable.refer_received(lc,referto);
+               lc->vtable.refer_received(lc,call,referto);
                if (op) sal_refer_accept(op);
        }
 }
@@ -449,7 +497,7 @@ static void ping_reply(SalOp *op){
        LinphoneCall *call=(LinphoneCall*) sal_op_get_user_pointer(op);
        ms_message("ping reply !");
        if (call){
-               if (call->state==LCStatePreEstablishing){
+               if (call->state==LinphoneCallPreEstablishing){
                        linphone_core_start_invite(call->core,call,NULL);
                }
        }
index 73a5f7c9a1ef08205c46d87613de7adbe253ab94..9ee70482c1b2e938d424582e9ef40c6953927628 100644 (file)
@@ -55,7 +55,7 @@ void linphone_chat_room_send_message(LinphoneChatRoom *cr, const char *msg){
        if(linphone_core_is_in_communication_with(cr->lc,cr->peer))
        {
                ms_message("send SIP message into the call\n");
-               op = cr->lc->call->op;
+               op = (linphone_core_get_current_call(cr->lc))->op;
        }
        else
        {
diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c
new file mode 100644 (file)
index 0000000..26ece22
--- /dev/null
@@ -0,0 +1,243 @@
+
+/*
+linphone
+Copyright (C) 2010  Belledonne Communications SARL 
+ (simon.morlat@linphone.org)
+
+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.
+*/
+#ifdef WIN32
+#include <time.h>
+#endif
+#include "linphonecore.h"
+#include "sipsetup.h"
+#include "lpconfig.h"
+#include "private.h"
+
+
+
+
+static MSList *make_codec_list(LinphoneCore *lc, const MSList *codecs, bool_t only_one_codec){
+       MSList *l=NULL;
+       const MSList *it;
+       for(it=codecs;it!=NULL;it=it->next){
+               PayloadType *pt=(PayloadType*)it->data;
+               if ((pt->flags & PAYLOAD_TYPE_ENABLED) && linphone_core_check_payload_type_usability(lc,pt)){
+                       l=ms_list_append(l,payload_type_clone(pt));
+                       if (only_one_codec) break;
+               }
+       }
+       return l;
+}
+
+static SalMediaDescription *create_local_media_description(LinphoneCore *lc, 
+               const char *localip, const char *username, bool_t only_one_codec){
+       MSList *l;
+       PayloadType *pt;
+       SalMediaDescription *md=sal_media_description_new();
+       md->nstreams=1;
+       strncpy(md->addr,localip,sizeof(md->addr));
+       strncpy(md->username,username,sizeof(md->username));
+       md->bandwidth=linphone_core_get_download_bandwidth(lc);
+       /*set audio capabilities */
+       strncpy(md->streams[0].addr,localip,sizeof(md->streams[0].addr));
+       md->streams[0].port=linphone_core_get_audio_port(lc);
+       md->streams[0].proto=SalProtoRtpAvp;
+       md->streams[0].type=SalAudio;
+       md->streams[0].ptime=lc->net_conf.down_ptime;
+       l=make_codec_list(lc,lc->codecs_conf.audio_codecs,only_one_codec);
+       pt=payload_type_clone(rtp_profile_get_payload_from_mime(&av_profile,"telephone-event"));
+       l=ms_list_append(l,pt);
+       md->streams[0].payloads=l;
+       
+       if (lc->dw_audio_bw>0)
+               md->streams[0].bandwidth=lc->dw_audio_bw;
+
+       if (linphone_core_video_enabled (lc)){
+               md->nstreams++;
+               md->streams[1].port=linphone_core_get_video_port(lc);
+               md->streams[1].proto=SalProtoRtpAvp;
+               md->streams[1].type=SalVideo;
+               l=make_codec_list(lc,lc->codecs_conf.video_codecs,only_one_codec);
+               md->streams[1].payloads=l;
+               if (lc->dw_video_bw)
+                       md->streams[1].bandwidth=lc->dw_video_bw;
+       }
+       return md;
+}
+
+static void linphone_call_init_common(LinphoneCall *call, LinphoneAddress *from, LinphoneAddress *to){
+       call->refcnt=1;
+       call->state=LinphoneCallInit;
+       call->start_time=time(NULL);
+       call->media_start_time=0;
+       call->log=linphone_call_log_new(call, from, to);
+       linphone_core_notify_all_friends(call->core,LINPHONE_STATUS_ONTHEPHONE);
+       if (linphone_core_get_firewall_policy(call->core)==LINPHONE_POLICY_USE_STUN)
+               linphone_core_run_stun_tests(call->core,call);
+}
+
+static void discover_mtu(LinphoneCore *lc, const char *remote){
+       int mtu;
+       if (lc->net_conf.mtu==0 ){
+               /*attempt to discover mtu*/
+               mtu=ms_discover_mtu(remote);
+               if (mtu>0){
+                       ms_set_mtu(mtu);
+                       ms_message("Discovered mtu is %i, RTP payload max size is %i",
+                               mtu, ms_get_payload_max_size());
+               }
+       }
+}
+
+LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, LinphoneAddress *from, LinphoneAddress *to)
+{
+       LinphoneCall *call=ms_new0(LinphoneCall,1);
+       call->dir=LinphoneCallOutgoing;
+       call->op=sal_op_new(lc->sal);
+       sal_op_set_user_pointer(call->op,call);
+       call->core=lc;
+       linphone_core_get_local_ip(lc,linphone_address_get_domain(to),call->localip);
+       call->localdesc=create_local_media_description (lc,call->localip,
+               linphone_address_get_username(from),FALSE);
+       linphone_call_init_common(call,from,to);
+       discover_mtu(lc,linphone_address_get_domain (to));
+       return call;
+}
+
+LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *from, LinphoneAddress *to, SalOp *op){
+       LinphoneCall *call=ms_new0(LinphoneCall,1);
+       LinphoneAddress *me=linphone_core_get_primary_contact_parsed(lc);
+       char *to_str;
+       char *from_str;
+
+       call->dir=LinphoneCallIncoming;
+       sal_op_set_user_pointer(op,call);
+       call->op=op;
+       call->core=lc;
+
+       if (lc->sip_conf.ping_with_options){
+               /*the following sends an option request back to the caller so that
+                we get a chance to discover our nat'd address before answering.*/
+               call->ping_op=sal_op_new(lc->sal);
+               to_str=linphone_address_as_string(to);
+               from_str=linphone_address_as_string(from);
+               sal_op_set_route(call->ping_op,sal_op_get_network_origin(call->op));
+               sal_op_set_user_pointer(call->ping_op,call);
+               sal_ping(call->ping_op,to_str,from_str);
+               ms_free(to_str);
+               ms_free(from_str);
+       }
+       
+       linphone_address_clean(from);
+       linphone_core_get_local_ip(lc,linphone_address_get_domain(from),call->localip);
+       call->localdesc=create_local_media_description (lc,call->localip,
+           linphone_address_get_username(me),lc->sip_conf.only_one_codec);
+       linphone_call_init_common(call, from, to);
+       discover_mtu(lc,linphone_address_get_domain(from));
+       linphone_address_destroy(me);
+       return call;
+}
+
+void linphone_call_set_terminated(LinphoneCall *call){
+       LinphoneCallStatus status=LinphoneCallAborted;
+       if (call->state==LinphoneCallAVRunning){
+               status=LinphoneCallSuccess;
+       }
+       linphone_call_log_completed(call->log,call, status);
+       call->state=LinphoneCallTerminated;
+}
+
+static void linphone_call_destroy(LinphoneCall *obj)
+{
+       linphone_core_notify_all_friends(obj->core,obj->core->prev_mode);
+       
+       linphone_core_update_allocated_audio_bandwidth(obj->core);
+       if (obj->op!=NULL) {
+               sal_op_release(obj->op);
+               obj->op=NULL;
+       }
+       if (obj->resultdesc!=NULL) {
+               sal_media_description_unref(obj->resultdesc);
+               obj->resultdesc=NULL;
+       }
+       if (obj->localdesc!=NULL) {
+               sal_media_description_unref(obj->localdesc);
+               obj->localdesc=NULL;
+       }
+       if (obj->ping_op) {
+               sal_op_release(obj->ping_op);
+       }
+       if(linphone_core_del_call(obj->core,obj) != 0)
+       {
+               ms_error("could not remove the call from the list !!!");
+       }
+       if(obj == linphone_core_get_current_call(obj->core))
+       {
+               ms_message("destroying the current call\n");
+               linphone_core_unset_the_current_call(obj->core);
+       }
+       ms_free(obj);
+}
+
+void linphone_call_ref(LinphoneCall *obj){
+       obj->refcnt++;
+}
+
+void linphone_call_unref(LinphoneCall *obj){
+       obj->refcnt--;
+       if (obj->refcnt==0)
+               linphone_call_destroy(obj);
+}
+
+bool_t linphone_call_paused(LinphoneCall *call){
+       return call->state==LinphoneCallPaused;
+}
+
+const LinphoneAddress * linphone_call_get_remote_address(const LinphoneCall *call){
+       return call->dir==LinphoneCallIncoming ? call->log->from : call->log->to;
+}
+
+char *linphone_call_get_remote_address_as_string(const LinphoneCall *call){
+       return linphone_address_as_string(linphone_call_get_remote_address(call));
+}
+
+LinphoneCallState linphone_call_get_state(const LinphoneCall *call){
+       return call->state;
+}
+
+/**
+ * Get the user_pointer in the LinphoneCall
+ *
+ * @ingroup call_control
+ *
+ * return user_pointer an opaque user pointer that can be retrieved at any time
+**/
+void *linphone_call_get_user_pointer(LinphoneCall *call)
+{
+       return call->user_pointer;
+}
+
+/**
+ * Set the user_pointer in the LinphoneCall
+ *
+ * @ingroup call_control
+ *
+ * the user_pointer is an opaque user pointer that can be retrieved at any time in the LinphoneCall
+**/
+void linphone_call_set_user_pointer(LinphoneCall *call, void *user_pointer)
+{
+       call->user_pointer = user_pointer;
+}
index 6bb231242e5591a0198687c7bb3b788f1430cc46..5b4779680d2bb599af9506db83d79549586bc190 100644 (file)
@@ -62,151 +62,7 @@ int lc_callback_obj_invoke(LCCallbackObj *obj, LinphoneCore *lc){
        return 0;
 }
 
-
-static MSList *make_codec_list(LinphoneCore *lc, const MSList *codecs, bool_t only_one_codec){
-       MSList *l=NULL;
-       const MSList *it;
-       for(it=codecs;it!=NULL;it=it->next){
-               PayloadType *pt=(PayloadType*)it->data;
-               if ((pt->flags & PAYLOAD_TYPE_ENABLED) && linphone_core_check_payload_type_usability(lc,pt)){
-                       l=ms_list_append(l,payload_type_clone(pt));
-                       if (only_one_codec) break;
-               }
-       }
-       return l;
-}
-
-static SalMediaDescription *create_local_media_description(LinphoneCore *lc, 
-               const char *localip, const char *username, bool_t only_one_codec){
-       MSList *l;
-       PayloadType *pt;
-       SalMediaDescription *md=sal_media_description_new();
-       md->nstreams=1;
-       strncpy(md->addr,localip,sizeof(md->addr));
-       strncpy(md->username,username,sizeof(md->username));
-       md->bandwidth=linphone_core_get_download_bandwidth(lc);
-       /*set audio capabilities */
-       strncpy(md->streams[0].addr,localip,sizeof(md->streams[0].addr));
-       md->streams[0].port=linphone_core_get_audio_port(lc);
-       md->streams[0].proto=SalProtoRtpAvp;
-       md->streams[0].type=SalAudio;
-       md->streams[0].ptime=lc->net_conf.down_ptime;
-       l=make_codec_list(lc,lc->codecs_conf.audio_codecs,only_one_codec);
-       pt=payload_type_clone(rtp_profile_get_payload_from_mime(&av_profile,"telephone-event"));
-       l=ms_list_append(l,pt);
-       md->streams[0].payloads=l;
-       
-       if (lc->dw_audio_bw>0)
-               md->streams[0].bandwidth=lc->dw_audio_bw;
-
-       if (linphone_core_video_enabled (lc)){
-               md->nstreams++;
-               md->streams[1].port=linphone_core_get_video_port(lc);
-               md->streams[1].proto=SalProtoRtpAvp;
-               md->streams[1].type=SalVideo;
-               l=make_codec_list(lc,lc->codecs_conf.video_codecs,only_one_codec);
-               md->streams[1].payloads=l;
-               if (lc->dw_video_bw)
-                       md->streams[1].bandwidth=lc->dw_video_bw;
-       }
-       return md;
-}
-
-static void linphone_call_init_common(LinphoneCall *call, LinphoneAddress *from, LinphoneAddress *to){
-       call->state=LCStateInit;
-       call->start_time=time(NULL);
-       call->media_start_time=0;
-       call->log=linphone_call_log_new(call, from, to);
-       linphone_core_notify_all_friends(call->core,LINPHONE_STATUS_ONTHEPHONE);
-       if (linphone_core_get_firewall_policy(call->core)==LINPHONE_POLICY_USE_STUN)
-               linphone_core_run_stun_tests(call->core,call);
-}
-
-static void discover_mtu(LinphoneCore *lc, const char *remote){
-       int mtu;
-       if (lc->net_conf.mtu==0 ){
-               /*attempt to discover mtu*/
-               mtu=ms_discover_mtu(remote);
-               if (mtu>0){
-                       ms_set_mtu(mtu);
-                       ms_message("Discovered mtu is %i, RTP payload max size is %i",
-                               mtu, ms_get_payload_max_size());
-               }
-       }
-}
-
-LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, LinphoneAddress *from, LinphoneAddress *to)
-{
-       LinphoneCall *call=ms_new0(LinphoneCall,1);
-       call->dir=LinphoneCallOutgoing;
-       call->op=sal_op_new(lc->sal);
-       sal_op_set_user_pointer(call->op,call);
-       call->core=lc;
-       linphone_core_get_local_ip(lc,linphone_address_get_domain(to),call->localip);
-       call->localdesc=create_local_media_description (lc,call->localip,
-               linphone_address_get_username(from),FALSE);
-       linphone_call_init_common(call,from,to);
-       discover_mtu(lc,linphone_address_get_domain (to));
-       return call;
-}
-
-LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *from, LinphoneAddress *to, SalOp *op){
-       LinphoneCall *call=ms_new0(LinphoneCall,1);
-       LinphoneAddress *me=linphone_core_get_primary_contact_parsed(lc);
-       char *to_str;
-       char *from_str;
-
-       call->dir=LinphoneCallIncoming;
-       sal_op_set_user_pointer(op,call);
-       call->op=op;
-       call->core=lc;
-
-       if (lc->sip_conf.ping_with_options){
-               /*the following sends an option request back to the caller so that
-                we get a chance to discover our nat'd address before answering.*/
-               call->ping_op=sal_op_new(lc->sal);
-               to_str=linphone_address_as_string(to);
-               from_str=linphone_address_as_string(from);
-               sal_op_set_route(call->ping_op,sal_op_get_network_origin(call->op));
-               sal_op_set_user_pointer(call->ping_op,call);
-               sal_ping(call->ping_op,to_str,from_str);
-               ms_free(to_str);
-               ms_free(from_str);
-       }
-       
-       linphone_address_clean(from);
-       linphone_core_get_local_ip(lc,linphone_address_get_domain(from),call->localip);
-       call->localdesc=create_local_media_description (lc,call->localip,
-           linphone_address_get_username(me),lc->sip_conf.only_one_codec);
-       linphone_call_init_common(call, from, to);
-       discover_mtu(lc,linphone_address_get_domain(from));
-       linphone_address_destroy(me);
-       return call;
-}
-
-void linphone_call_destroy(LinphoneCall *obj)
-{
-       linphone_core_notify_all_friends(obj->core,obj->core->prev_mode);
-       linphone_call_log_completed(obj->log,obj);
-       linphone_core_update_allocated_audio_bandwidth(obj->core);
-       if (obj->op!=NULL) {
-               sal_op_release(obj->op);
-               obj->op=NULL;
-       }
-       if (obj->resultdesc!=NULL) {
-               sal_media_description_unref(obj->resultdesc);
-               obj->resultdesc=NULL;
-       }
-       if (obj->localdesc!=NULL) {
-               sal_media_description_unref(obj->localdesc);
-               obj->localdesc=NULL;
-       }
-       if (obj->ping_op) {
-               sal_op_release(obj->ping_op);
-       }
-       ms_free(obj);
-}
-
+               
 /*prevent a gcc bug with %c*/
 static size_t my_strftime(char *s, size_t max, const char  *fmt,  const struct tm *tm){
 #if !defined(_WIN32_WCE)
@@ -295,32 +151,20 @@ static void call_logs_read_from_config_file(LinphoneCore *lc){
 }
 
 
-void linphone_call_log_completed(LinphoneCallLog *calllog, LinphoneCall *call){
+void linphone_call_log_completed(LinphoneCallLog *calllog, LinphoneCall *call, LinphoneCallStatus status){
        LinphoneCore *lc=call->core;
        
        calllog->duration=time(NULL)-call->start_time;
-       switch(call->state){
-               case LCStateInit:
-               case LCStatePreEstablishing:
-                       calllog->status=LinphoneCallAborted;
-                       break;
-               case LCStateRinging:
-                       if (calllog->dir==LinphoneCallIncoming){
-                               char *info;
-                               calllog->status=LinphoneCallMissed;
-                               lc->missed_calls++;
-                               info=ortp_strdup_printf(ngettext("You have missed %i call.",
-                            "You have missed %i calls.", lc->missed_calls),
-                        lc->missed_calls);
-                               lc->vtable.display_status(lc,info);
-                               ms_free(info);
-                       }
-                       else calllog->status=LinphoneCallAborted;
-                       break;
-               case LCStateAVRunning:
-                       calllog->status=LinphoneCallSuccess;
-                       break;
-       }
+       
+       if (status==LinphoneCallMissed){
+               char *info;
+               lc->missed_calls++;
+               info=ortp_strdup_printf(ngettext("You have missed %i call.",
+                    "You have missed %i calls.", lc->missed_calls),
+                lc->missed_calls);
+               lc->vtable.display_status(lc,info);
+               ms_free(info);
+       }else calllog->status=status;
        lc->call_logs=ms_list_prepend(lc->call_logs,(void *)calllog);
        if (ms_list_size(lc->call_logs)>lc->max_call_logs){
                MSList *elem,*prevelem=NULL;
@@ -437,17 +281,21 @@ bool_t linphone_call_asked_to_autoanswer(LinphoneCall *call){
                return FALSE;
 }
 
-int linphone_core_get_current_call_duration(const LinphoneCore *lc){
-       LinphoneCall *call=lc->call;
+int linphone_core_get_call_duration(LinphoneCall *call){
        if (call==NULL) return 0;
        if (call->media_start_time==0) return 0;
        return time(NULL)-call->media_start_time;
 }
 
-const LinphoneAddress *linphone_core_get_remote_uri(LinphoneCore *lc){
-       LinphoneCall *call=lc->call;
+int linphone_core_get_current_call_duration(const LinphoneCore *lc){
+       LinphoneCall *call=linphone_core_get_current_call((LinphoneCore *)lc);
+       return linphone_core_get_call_duration(call);
+}
+
+const LinphoneAddress *linphone_core_get_current_call_remote_address(struct _LinphoneCore *lc){
+       LinphoneCall *call=linphone_core_get_current_call(lc);
        if (call==NULL) return 0;
-       return call->dir==LinphoneCallIncoming ? call->log->from : call->log->to;
+       return linphone_call_get_remote_address(call);
 }
 
 /**
@@ -1651,20 +1499,20 @@ void linphone_core_iterate(LinphoneCore *lc){
        if (lc->auto_net_state_mon) monitor_network_state(lc,curtime);
 
        proxy_update(lc);
-
-       if (lc->call!=NULL){
-               LinphoneCall *call=lc->call;
-               if (call->state==LCStatePreEstablishing && (curtime-call->start_time>=2)){
+       LinphoneCall *call = linphone_core_get_current_call(lc);
+       if(call){
+               if (call->state==LinphoneCallPreEstablishing && (curtime-call->start_time>=2)){
                        /*start the call even if the OPTIONS reply did not arrive*/
                        linphone_core_start_invite(lc,call,NULL);
                }
-               if (call->dir==LinphoneCallIncoming && call->state==LCStateRinging){
+               if (call->dir==LinphoneCallIncoming && call->state==LinphoneCallRinging){
                        elapsed=curtime-call->start_time;
                        ms_message("incoming call ringing for %i seconds",elapsed);
                        if (elapsed>lc->sip_conf.inc_timeout){
+                               call->log->status=LinphoneCallMissed;
                                linphone_core_terminate_call(lc,NULL);
                        }
-               }else if (call->state==LCStateAVRunning){
+               }else if (call->state==LinphoneCallAVRunning){
                        if (one_second_elapsed){
                                RtpSession *as=NULL,*vs=NULL;
                                lc->prevtime=curtime;
@@ -1727,6 +1575,8 @@ LinphoneAddress * linphone_core_interpret_url(LinphoneCore *lc, const char *url)
                lc->vtable.display_status(lc,_("Looking for telephone number destination..."));
                if (enum_lookup(enum_domain,&enumres)<0){
                        lc->vtable.display_status(lc,_("Could not resolve this number."));
+                       if(lc->vtable.failure_recv)
+                               lc->vtable.failure_recv(lc,NULL,400);
                        ms_free(enum_domain);
                        return NULL;
                }
@@ -1809,7 +1659,7 @@ bool_t linphone_core_is_in_communication_with(LinphoneCore *lc, const char *to)
 {
        char *tmp;
        bool_t returned;
-       const LinphoneAddress *la=linphone_core_get_remote_uri(lc);
+       const LinphoneAddress *la=linphone_core_get_current_call_remote_address(lc);
        if(la == NULL)
        {
                return FALSE;
@@ -1853,7 +1703,6 @@ static char *get_fixed_contact(LinphoneCore *lc, LinphoneCall *call , LinphonePr
        if (call->op && sal_op_get_contact(call->op)!=NULL){
                return NULL;
        }
-       
        /* if the ping OPTIONS request succeeded use the contact guessed from the
         received, rport*/
        if (call->ping_op){
@@ -1899,8 +1748,8 @@ int linphone_core_start_invite(LinphoneCore *lc, LinphoneCall *call, LinphonePro
                sal_op_set_contact(call->op, contact);
                ms_free(contact);
        }
-       call->state=LCStateInit;
-       linphone_core_init_media_streams(lc,lc->call);
+       call->state=LinphoneCallInit;
+       linphone_core_init_media_streams(lc,call);
        if (!lc->sip_conf.sdp_200_ack){ 
                call->media_pending=TRUE;
                sal_call_set_local_media_description(call->op,call->localdesc);
@@ -1920,9 +1769,9 @@ int linphone_core_start_invite(LinphoneCore *lc, LinphoneCall *call, LinphonePro
        if (err<0){
                ms_warning("Could not initiate call.");
                lc->vtable.display_status(lc,_("could not call"));
-               linphone_core_stop_media_streams(lc,call);
-               linphone_call_destroy(call);
-               lc->call=NULL;
+               if(call == linphone_core_get_current_call(lc))
+                       linphone_core_stop_media_streams(lc,call);
+               linphone_call_unref(call);
        }else gstate_new_state(lc, GSTATE_CALL_OUT_INVITE, real_url);
        ms_free(real_url);
        ms_free(from);
@@ -1936,15 +1785,15 @@ int linphone_core_start_invite(LinphoneCore *lc, LinphoneCall *call, LinphonePro
  * @param lc the LinphoneCore object
  * @param url the destination of the call (sip address, or phone number).
 **/
-int linphone_core_invite(LinphoneCore *lc, const char *url){
+LinphoneCall * linphone_core_invite(LinphoneCore *lc, const char *url){
        LinphoneAddress *addr=linphone_core_interpret_url(lc,url);
        if (addr){
-               int err;
-               err=linphone_core_invite_address(lc,addr);
+               LinphoneCall *call;
+               call=linphone_core_invite_address(lc,addr);
                linphone_address_destroy(addr);
-               return err;
+               return call;
        }
-       return -1;
+       return NULL;
 }
 
 /**
@@ -1954,7 +1803,7 @@ int linphone_core_invite(LinphoneCore *lc, const char *url){
  * @param lc the LinphoneCore object
  * @param url the destination of the call (sip address).
 **/
-int linphone_core_invite_address(LinphoneCore *lc, const LinphoneAddress *real_parsed_url)
+LinphoneCall * linphone_core_invite_address(LinphoneCore *lc, const LinphoneAddress *real_parsed_url)
 {
        int err=0;
        const char *route=NULL;
@@ -1965,11 +1814,14 @@ int linphone_core_invite_address(LinphoneCore *lc, const LinphoneAddress *real_p
        LinphoneProxyConfig *dest_proxy=NULL;
        LinphoneCall *call;
        
-       if (lc->call!=NULL){
-               lc->vtable.display_warning(lc,_("Sorry, having multiple simultaneous calls is not supported yet !"));
-               return -1;
+       if (linphone_core_in_call(lc)){
+               lc->vtable.display_warning(lc,_("Sorry, you have to pause or stop the current call first !"));
+               return NULL;
+       }
+       if(!linphone_core_can_we_add_call(lc)){
+               lc->vtable.display_warning(lc,_("Sorry, we have reached the maximum number of simultaneous calls"));
+               return NULL;
        }
-
        linphone_core_get_default_proxy(lc,&proxy);
        route=linphone_core_get_route(lc);
        
@@ -1994,32 +1846,36 @@ int linphone_core_invite_address(LinphoneCore *lc, const LinphoneAddress *real_p
        call=linphone_call_new_outgoing(lc,parsed_url2,linphone_address_clone(real_parsed_url));
        sal_op_set_route(call->op,route);
        
-       lc->call=call;
+       if(linphone_core_add_call(lc,call)!= 0)
+       {
+               ms_warning("we had a problem in adding the call into the invite ... weird\n");
+               linphone_call_unref(call);
+               return NULL;
+       }
+       linphone_core_set_as_current_call(lc,call);
        if (dest_proxy!=NULL || lc->sip_conf.ping_with_options==FALSE){
                err=linphone_core_start_invite(lc,call,dest_proxy);
        }else{
                /*defer the start of the call after the OPTIONS ping*/
-               call->state=LCStatePreEstablishing;
+               call->state=LinphoneCallPreEstablishing;
                call->ping_op=sal_op_new(lc->sal);
                sal_ping(call->ping_op,from,real_url);
                call->start_time=time(NULL);
        }
        
        if (real_url!=NULL) ms_free(real_url);
-       return err;
+       return call;
 }
 
-int linphone_core_refer(LinphoneCore *lc, const char *url)
+int linphone_core_refer(LinphoneCore *lc, LinphoneCall *call, const char *url)
 {
        char *real_url=NULL;
        LinphoneAddress *real_parsed_url=linphone_core_interpret_url(lc,url);
-       LinphoneCall *call;
 
        if (!real_parsed_url){
                /* bad url */
                return -1;
        }
-       call=lc->call;
        if (call==NULL){
                ms_warning("No established call to refer.");
                return -1;
@@ -2032,13 +1888,16 @@ int linphone_core_refer(LinphoneCore *lc, const char *url)
 }
 
 /**
- * Returns true if in incoming call is pending, ie waiting for being answered or declined.
+ * Returns true if an incoming call is pending, ie waiting for being answered or declined.
  *
  * @ingroup call_control
 **/
 bool_t linphone_core_inc_invite_pending(LinphoneCore*lc){
-       if (lc->call!=NULL && lc->call->dir==LinphoneCallIncoming){
-               return TRUE;
+       LinphoneCall *call = linphone_core_get_current_call(lc);
+       if(call != NULL)
+       {
+               if(call->dir==LinphoneCallIncoming)
+                       return TRUE;
        }
        return FALSE;
 }
@@ -2293,7 +2152,7 @@ void linphone_core_start_media_streams(LinphoneCore *lc, LinphoneCall *call){
        end:
                ms_free(cname);
                linphone_address_destroy(me);
-               lc->call->state=LCStateAVRunning;
+               call->state=LinphoneCallAVRunning;
 }
 
 void linphone_core_stop_media_streams(LinphoneCore *lc, LinphoneCall *call){
@@ -2343,17 +2202,20 @@ void linphone_core_stop_media_streams(LinphoneCore *lc, LinphoneCall *call){
  *            however this feature is not supported yet.
  *            Using NULL will accept the unique incoming call in progress.
 **/
-int linphone_core_accept_call(LinphoneCore *lc, const char *url)
+int linphone_core_accept_call(LinphoneCore *lc, LinphoneCall *call)
 {
-       LinphoneCall *call=lc->call;
        LinphoneProxyConfig *cfg=NULL;
        const char *contact=NULL;
        
        if (call==NULL){
-               return -1;
+               //if just one call is present answer the only one ...
+               if(ms_list_size(linphone_core_get_calls(lc)) != 1)
+                       return -1;
+               else
+                       call = linphone_core_get_calls(lc)->data;
        }
 
-       if (call->state==LCStateAVRunning){
+       if (call->state==LinphoneCallAVRunning){
                /*call already accepted*/
                return -1;
        }
@@ -2365,7 +2227,11 @@ int linphone_core_accept_call(LinphoneCore *lc, const char *url)
                ms_message("ring stopped");
                lc->ringstream=NULL;
        }
-
+       if(linphone_core_set_as_current_call(lc,call)!=0)
+       {
+               ms_message("another call is already in process\n");
+       }
+       
        linphone_core_get_default_proxy(lc,&cfg);
        /*try to be best-effort in giving real local or routable contact address*/
        contact=get_fixed_contact(lc,call,cfg);
@@ -2378,7 +2244,8 @@ int linphone_core_accept_call(LinphoneCore *lc, const char *url)
        call->resultdesc=sal_call_get_final_media_description(call->op);
        if (call->resultdesc){
                sal_media_description_ref(call->resultdesc);
-               linphone_core_start_media_streams(lc, call);
+               if(call == linphone_core_get_current_call(lc))
+                       linphone_core_start_media_streams(lc, call);
        }else call->media_pending=TRUE;
        ms_message("call answered.");
        return 0;
@@ -2392,13 +2259,20 @@ int linphone_core_accept_call(LinphoneCore *lc, const char *url)
  * @param url the destination of the call to be terminated, use NULL if there is
  *            only one call (which is case in this version of liblinphone).
 **/
-int linphone_core_terminate_call(LinphoneCore *lc, const char *url)
+int linphone_core_terminate_call(LinphoneCore *lc, LinphoneCall *the_call)
 {
-       LinphoneCall *call=lc->call;
-       if (call==NULL){
-               return -1;
+       LinphoneCall *call;
+       if (the_call == NULL){
+               call = linphone_core_get_current_call(lc);
+               if(call == NULL)
+               {
+                       return -1;
+               }
+       }
+       else
+       {
+               call = the_call;
        }
-       lc->call=NULL;
        sal_call_terminate(call->op);
 
        /*stop ringing*/
@@ -2406,20 +2280,51 @@ int linphone_core_terminate_call(LinphoneCore *lc, const char *url)
                ring_stop(lc->ringstream);
                lc->ringstream=NULL;
        }
-       linphone_core_stop_media_streams(lc,call);
+       if(call == linphone_core_get_current_call(lc))
+               linphone_core_stop_media_streams(lc,call);
        lc->vtable.display_status(lc,_("Call ended") );
        gstate_new_state(lc, GSTATE_CALL_END, NULL);
-       linphone_call_destroy(call);
+       linphone_call_set_terminated(call);
+       linphone_call_unref(call);
        return 0;
 }
 
+/**
+ * Terminates all the calls.
+ *
+ * @ingroup call_control
+ * @param lc The LinphoneCore
+**/
+int linphone_core_terminate_all_calls(LinphoneCore *lc){
+       MSList *calls;
+
+       calls = lc->calls;
+       while(calls->next != NULL)
+       {
+               linphone_core_terminate_call(lc,(LinphoneCall *)calls->data);
+               calls = calls->next;
+       }
+       ms_list_free(lc->calls);
+       return -1;
+}
+
+/**
+ * Returns the calls MSList
+ *
+ * @ingroup call_control
+**/
+MSList *linphone_core_get_calls(LinphoneCore *lc)
+{
+       return ms_list_copy(lc->calls);
+}
+
 /**
  * Returns TRUE if there is a call running or pending.
  *
  * @ingroup call_control
 **/
 bool_t linphone_core_in_call(const LinphoneCore *lc){
-       return lc->call!=NULL;
+       return linphone_core_get_current_call((LinphoneCore *)lc)!=NULL;
 }
 
 /**
@@ -2427,12 +2332,134 @@ bool_t linphone_core_in_call(const LinphoneCore *lc){
  *
  * @ingroup call_control
 **/
-struct _LinphoneCall *linphone_core_get_current_call(LinphoneCore *lc)
+LinphoneCall *linphone_core_get_current_call(LinphoneCore *lc)
 {
-       if(linphone_core_in_call(lc))
-               return lc->call;
-       else
-               return NULL;
+       if(lc->current_call != NULL)
+               return lc->current_call;
+       return NULL;
+}
+
+/**
+ * Permits to pause the call
+ *
+ * @ingroup call_control
+**/
+int linphone_core_pause_call(LinphoneCore *lc, LinphoneCall *the_call)
+{
+       LinphoneCall *call = the_call;
+       if(lc == NULL)
+       {
+               ms_error("LinphoneCore was null\n");
+               return -1;
+       }
+       if(call == NULL)
+       {
+               if(linphone_core_in_call(lc))
+               {
+                       call = linphone_core_get_current_call(lc);
+               }
+               else
+               {
+                       ms_error("LinphoneCall was null\n");
+                       return -2;
+               }
+       }
+       if(linphone_core_get_current_call(lc) != call)
+       {
+               ms_error("The call asked to be paused was not the current on\n");
+               return -3;
+       }
+       sal_call_hold(call->op,TRUE);
+       call->state = LinphoneCallPaused;
+       linphone_core_unset_the_current_call(lc);
+       linphone_core_stop_media_streams(lc,call);
+       lc->vtable.display_status(lc,_("Pause the current call"));
+       return 0;
+}
+
+/**
+ * Permits to resume the call
+ *
+ * @ingroup call_control
+**/
+int linphone_core_resume_call(LinphoneCore *lc, LinphoneCall *the_call)
+{
+       char temp[255];
+       LinphoneCall *call = the_call;
+       if(lc == NULL)
+       {
+               ms_error("LinphoneCore was null\n");
+               return -1;
+       }
+       if(call == NULL)
+       {
+               MSList *calls = linphone_core_get_calls(lc);
+               if(ms_list_size(calls) == 1)
+               {
+                       call = ((LinphoneCall *)calls->data);
+                       ms_list_free(calls);
+               }
+               else
+               {
+                       ms_error("LinphoneCall was null\n");
+                       ms_list_free(calls);
+                       return -2;
+               }
+       }
+       if(linphone_core_get_current_call(lc) != NULL)
+       {
+               ms_error("There is already a call in process pause or stop it first\n");
+               return -3;
+       }
+       linphone_core_init_media_streams(lc,call);
+       sal_call_hold(call->op,FALSE);
+       call->state = LinphoneCallAVRunning;
+       linphone_core_set_as_current_call(lc,call);
+       linphone_core_start_media_streams(lc,call);
+       snprintf(temp,sizeof(temp),"Resume the call with %s",linphone_call_get_remote_address_as_string(call));
+       lc->vtable.display_status(lc,temp);
+       
+       return 0;
+}
+
+/**
+ * Compare the remote address with the one in call
+ * 
+ * @param a the call
+ * @param b the remote address to compare with
+ * @return 0 if it's the good call else 1
+ */
+static int linphone_call_remote_address_compare(const void * a, const void * b)
+{
+       if(b == NULL || a ==NULL)
+               return 1;
+       char *the_remote_address = ((char *)b);
+       LinphoneCall *call = ((LinphoneCall *)a);
+#ifdef DEBUG 
+       ms_message("the remote address:%s\n",the_remote_address);
+       ms_message("the call:%p => %s\n",call,linphone_call_get_remote_address_as_string(call));
+#endif
+       if(!strcmp(linphone_call_get_remote_address_as_string(call),the_remote_address))
+       {
+               return 0;
+       }
+       return 1;
+}
+
+/**
+ * Get the call with the remote_address specified
+ * @param lc
+ * @param remote_address
+ * @return the LinphoneCall of the call if found
+ */
+LinphoneCall *linphone_core_get_call_by_remote_address(LinphoneCore *lc, const char *remote_address){
+
+       MSList *the_call = ms_list_find_custom(lc->calls,linphone_call_remote_address_compare,(void *)remote_address);
+       if(the_call != NULL)
+       {
+               return ((LinphoneCall *)the_call->data);
+       }
+       return NULL;
 }
 
 int linphone_core_send_publish(LinphoneCore *lc,
@@ -2906,7 +2933,7 @@ void linphone_core_send_dtmf(LinphoneCore *lc, char dtmf)
        }
        if (linphone_core_get_use_info_for_dtmf(lc)!=0){
                /* Out of Band DTMF (use INFO method) */
-               LinphoneCall *call=lc->call;
+               LinphoneCall *call=linphone_core_get_current_call(lc);
                if (call==NULL){
                        return;
                }
@@ -3516,9 +3543,9 @@ LpConfig *linphone_core_get_config(LinphoneCore *lc){
 
 static void linphone_core_uninit(LinphoneCore *lc)
 {
-       if (lc->call){
+       if(linphone_core_get_calls_nb(lc)){
                int i;
-               linphone_core_terminate_call(lc,NULL);
+               linphone_core_terminate_all_calls(lc);
                for(i=0;i<10;++i){
 #ifndef WIN32
                        usleep(50000);
@@ -3600,4 +3627,105 @@ void linphone_core_destroy(LinphoneCore *lc){
        linphone_core_uninit(lc);
        ms_free(lc);
 }
+/**
+ * Get the number of Call
+ *
+ * @ingroup call_control
+**/
+int linphone_core_get_calls_nb(const LinphoneCore *lc)
+{
+       int returned;
+       if(lc->calls == NULL)
+       {
+               returned = 0;
+       }
+       else
+       {
+               returned = ms_list_size(lc->calls);
+       }
+       return returned;
+}
+
+/**
+ * Check if we do not have exceed the number of simultaneous call
+ *
+ * @ingroup call_control
+**/
+bool_t linphone_core_can_we_add_call(LinphoneCore *lc)
+{
+       if(linphone_core_get_calls_nb(lc) < NB_MAX_CALLS)
+               return TRUE;
+       return FALSE;
+}
+
+/**
+ * Unset the current call
+ *
+ * @ingroup call_control
+**/
+int linphone_core_unset_the_current_call(LinphoneCore *lc)
+{
+       if(lc->current_call == NULL)
+               return -1;
+       lc->current_call = NULL;
+       ms_message("Current call unset\n");
+       return 0;
+}
 
+/**
+ * Set the call in parameter as the new current call
+ *
+ * @ingroup call_control
+**/
+int linphone_core_set_as_current_call(LinphoneCore *lc, LinphoneCall *call)
+{
+       if(lc->current_call != NULL)
+               return -1;
+       lc->current_call = call;
+       return 0;
+}
+
+/**
+ * Add the call in the LinphoneCall list
+ *
+ * @ingroup call_control
+**/
+int linphone_core_add_call( LinphoneCore *lc, LinphoneCall *call)
+{
+       if(linphone_core_can_we_add_call(lc))
+       {
+               MSList *the_calls = lc->calls;
+               the_calls = ms_list_append(the_calls,(void *)call);
+               lc->calls = the_calls;
+               return 0;
+       }
+       return -1;
+}
+
+/**
+ * Add the call in the LinphoneCall list
+ *
+ * @ingroup call_control
+**/
+int linphone_core_del_call( LinphoneCore *lc, LinphoneCall *call)
+{
+       MSList *it;
+
+       MSList *the_calls = lc->calls;
+       if(call == linphone_core_get_current_call(lc))
+       {
+               linphone_core_unset_the_current_call(lc);
+       }       
+       it=ms_list_find(the_calls,call);
+       if (it) 
+       {
+               the_calls = ms_list_remove_link(the_calls,it);
+       }
+       else
+       {
+               ms_warning("could not find the call into the list\n");
+               return -1;
+       }
+       lc->calls = the_calls;
+       return 0;
+}
index 945ea25eaa321191d2678d0b65c69b48dc27538a..5c250731f2c2884ff23e253655b603e424ad7502 100644 (file)
@@ -85,8 +85,25 @@ struct _SipSetupContext;
 struct _LinphoneCall;
 typedef struct _LinphoneCall LinphoneCall;
 
-bool_t linphone_call_asked_to_autoanswer(struct _LinphoneCall *call);
-       
+typedef enum _LinphoneCallState{
+       LinphoneCallInit,
+       LinphoneCallPreEstablishing,
+       LinphoneCallRinging,
+       LinphoneCallAVRunning,
+       LinphoneCallPaused,
+       LinphoneCallTerminated
+}LinphoneCallState;
+
+LinphoneCallState linphone_call_get_state(const LinphoneCall *call);
+bool_t linphone_call_asked_to_autoanswer(LinphoneCall *call);
+bool_t linphone_call_paused(LinphoneCall *call);
+const LinphoneAddress * linphone_core_get_current_call_remote_address(struct _LinphoneCore *lc);
+const LinphoneAddress * linphone_call_get_remote_address(const LinphoneCall *call);
+char *linphone_call_get_remote_address_as_string(const LinphoneCall *call);
+void linphone_call_ref(LinphoneCall *call);
+void linphone_call_unref(LinphoneCall *call);
+
+
 /**
  * Enum representing the direction of a call.
  * @ingroup call_logs
@@ -377,9 +394,19 @@ void gstate_initialize(struct _LinphoneCore *lc) ;
 /** Callback prototype */
 typedef void (*ShowInterfaceCb)(struct _LinphoneCore *lc);
 /** Callback prototype */
-typedef void (*InviteReceivedCb)(struct _LinphoneCore *lc, const char *from);
+typedef void (*InviteReceivedCb)(struct _LinphoneCore *lc, LinphoneCall *call);
+/** Callback prototype */
+typedef void (*ByeReceivedCb)(struct _LinphoneCore *lc, LinphoneCall *call);
+/** Callback prototype */
+typedef void (*RingingReceivedCb)(struct _LinphoneCore *lc, LinphoneCall *call);
+/** Callback prototype */
+typedef void (*ConnectedReceivedCb)(struct _LinphoneCore *lc, LinphoneCall *call);
+/** Callback prototype */
+typedef void (*FailureReceivedCb)(struct _LinphoneCore *lc, LinphoneCall *call, int error_code);
 /** Callback prototype */
-typedef void (*ByeReceivedCb)(struct _LinphoneCore *lc, const char *from);
+typedef void (*PausedReceivedCb)(struct _LinphoneCore *lc, LinphoneCall *call);
+/** Callback prototype */
+typedef void (*ResumedReceivedCb)(struct _LinphoneCore *lc, LinphoneCall *call);
 /** Callback prototype */
 typedef void (*DisplayStatusCb)(struct _LinphoneCore *lc, const char *message);
 /** Callback prototype */
@@ -407,7 +434,7 @@ typedef void (*GeneralStateChange)(struct _LinphoneCore *lc, LinphoneGeneralStat
 /** Callback prototype */
 typedef void (*DtmfReceived)(struct _LinphoneCore* lc, int dtmf);
 /** Callback prototype */
-typedef void (*ReferReceived)(struct _LinphoneCore *lc, const char *refer_to);
+typedef void (*ReferReceived)(struct _LinphoneCore *lc, LinphoneCall *call, const char *refer_to);
 /** Callback prototype */
 typedef void (*BuddyInfoUpdated)(struct _LinphoneCore *lc, LinphoneFriend *lf);
 
@@ -420,6 +447,11 @@ typedef struct _LinphoneVTable
        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*/
+       RingingReceivedCb ringing_recv; /**< Notify that the distant phone is ringing*/
+       ConnectedReceivedCb connected_recv; /**< Notify that the distant phone answered the call*/
+       FailureReceivedCb failure_recv; /**< Notify that the call failed*/
+       PausedReceivedCb paused_recv; /**< Notify that the call failed*/
+       ResumedReceivedCb resumed_recv; /**< Notify that the call failed*/
        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 */
@@ -481,11 +513,11 @@ void linphone_core_iterate(LinphoneCore *lc);
 
 LinphoneAddress * linphone_core_interpret_url(LinphoneCore *lc, const char *url);
 
-int linphone_core_invite(LinphoneCore *lc, const char *url);
+LinphoneCall * linphone_core_invite(LinphoneCore *lc, const char *url);
 
-int linphone_core_invite_address(LinphoneCore *lc, const LinphoneAddress *addr);
+LinphoneCall * linphone_core_invite_address(LinphoneCore *lc, const LinphoneAddress *addr);
 
-int linphone_core_refer(LinphoneCore *lc, const char *url);
+int linphone_core_refer(LinphoneCore *lc, LinphoneCall *call, const char *url);
 
 bool_t linphone_core_inc_invite_pending(LinphoneCore*lc);
 
@@ -493,9 +525,17 @@ bool_t linphone_core_in_call(const LinphoneCore *lc);
 
 LinphoneCall *linphone_core_get_current_call(LinphoneCore *lc);
 
-int linphone_core_accept_call(LinphoneCore *lc, const char *url);
+int linphone_core_accept_call(LinphoneCore *lc, LinphoneCall *call);
+
+int linphone_core_terminate_call(LinphoneCore *lc, LinphoneCall *call);
+
+int linphone_core_terminate_all_calls(LinphoneCore *lc);
+
+int linphone_core_pause_call(LinphoneCore *lc, LinphoneCall *call);
+
+int linphone_core_resume_call(LinphoneCore *lc, LinphoneCall *call);
 
-int linphone_core_terminate_call(LinphoneCore *lc, const char *url);
+LinphoneCall *linphone_core_get_call_by_remote_address(LinphoneCore *lc, const char *remote_address);
 
 void linphone_core_send_dtmf(LinphoneCore *lc,char dtmf);
 
@@ -741,7 +781,7 @@ void linphone_core_set_record_file(LinphoneCore *lc, const char *file);
 
 gstate_t linphone_core_get_state(const LinphoneCore *lc, gstate_group_t group);
 int linphone_core_get_current_call_duration(const LinphoneCore *lc);
-const LinphoneAddress *linphone_core_get_remote_uri(LinphoneCore *lc);
+const LinphoneAddress *linphone_core_get_remote_address(LinphoneCore *lc);
 
 int linphone_core_get_mtu(const LinphoneCore *lc);
 void linphone_core_set_mtu(LinphoneCore *lc, int mtu);
@@ -788,5 +828,8 @@ void linphone_core_set_audio_transports(LinphoneCore *lc, RtpTransport *rtp, Rtp
 #ifdef __cplusplus
 }
 #endif
+MSList *linphone_core_get_calls(LinphoneCore *lc);
+void *linphone_call_get_user_pointer(LinphoneCall *call);
+void linphone_call_set_user_pointer(LinphoneCall *call, void *user_pointer);
 
 #endif
index 4a3c1dbaa3bd33ce0c818b14a5da5a4901f19b51..f4e308f6502e8516ecf4c3fb5cd56bc8c58fb245 100644 (file)
 #endif
 #endif
 
-typedef enum _LCState{
-       LCStateInit,
-       LCStatePreEstablishing,
-       LCStateRinging,
-       LCStateAVRunning
-}LCState;
+
 
 
 struct _LinphoneCall
@@ -76,18 +71,19 @@ struct _LinphoneCall
        char localip[LINPHONE_IPADDR_SIZE]; /* our best guess for local ipaddress for this call */
        time_t start_time; /*time at which the call was initiated*/
        time_t media_start_time; /*time at which it was accepted, media streams established*/
-       LCState state;
+       LinphoneCallState       state;
+       int refcnt;
        bool_t media_pending;
+       void * user_pointer;
 };
 
 LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, LinphoneAddress *from, LinphoneAddress *to);
 LinphoneCall * linphone_call_new_incoming(struct _LinphoneCore *lc, LinphoneAddress *from, LinphoneAddress *to, SalOp *op);
-#define linphone_call_set_state(lcall,st)      (lcall)->state=(st)
-void linphone_call_destroy(struct _LinphoneCall *obj);
+void linphone_call_set_terminated(LinphoneCall *call);
 
 /* private: */
 LinphoneCallLog * linphone_call_log_new(LinphoneCall *call, LinphoneAddress *local, LinphoneAddress * remote);
-void linphone_call_log_completed(LinphoneCallLog *calllog, LinphoneCall *call);
+void linphone_call_log_completed(LinphoneCallLog *calllog, LinphoneCall *call, LinphoneCallStatus status);
 void linphone_call_log_destroy(LinphoneCallLog *cl);
 
 
@@ -360,7 +356,8 @@ struct _LinphoneCore
        MSList *auth_info;
        struct _RingStream *ringstream;
        LCCallbackObj preview_finished_cb;
-       struct _LinphoneCall *call;   /* the current call, in the future it will be a list of calls (conferencing)*/
+       LinphoneCall *current_call;   /* the current call */
+       MSList *calls;                          /* all the processed calls */
        MSList *queued_calls;   /* used by the autoreplier */
        MSList *call_logs;
        MSList *chatrooms;
@@ -399,4 +396,18 @@ struct _LinphoneCore
        bool_t network_reachable;
 };
 
+bool_t linphone_core_can_we_add_call(LinphoneCore *lc);
+int linphone_core_add_call( LinphoneCore *lc, LinphoneCall *call);
+int linphone_core_del_call( LinphoneCore *lc, LinphoneCall *call);
+int linphone_core_set_as_current_call(LinphoneCore *lc, LinphoneCall *call);
+int linphone_core_unset_the_current_call(LinphoneCore *lc);
+int linphone_core_get_calls_nb(const LinphoneCore *lc);
+
+#define HOLD_OFF       (0)
+#define HOLD_ON                (1)
+
+#ifndef NB_MAX_CALLS
+#define NB_MAX_CALLS   (10)
+#endif
+
 #endif /* _PRIVATE_H */
index 882761ffb3c7fc86fff68d33b35096d1f91689f9..7643ab7da171e8837f27bb57e6b73c53cc1cfc36 100644 (file)
@@ -98,6 +98,7 @@ typedef struct SalStreamDescription{
        int bandwidth;
        int ptime;
        SalEndpointCandidate candidates[SAL_ENDPOINT_CANDIDATE_MAX];
+       bool_t notsending;
 } SalStreamDescription;
 
 #define SAL_MEDIA_DESCRIPTION_MAX_STREAMS 4
@@ -109,6 +110,7 @@ typedef struct SalMediaDescription{
        int nstreams;
        int bandwidth;
        SalStreamDescription streams[SAL_MEDIA_DESCRIPTION_MAX_STREAMS];
+       bool_t notsending;
 } SalMediaDescription;
 
 SalMediaDescription *sal_media_description_new();
@@ -175,7 +177,7 @@ typedef void (*SalOnCallAccepted)(SalOp *op);
 typedef void (*SalOnCallAck)(SalOp *op);
 typedef void (*SalOnCallUpdated)(SalOp *op);
 typedef void (*SalOnCallTerminated)(SalOp *op, const char *from);
-typedef void (*SalOnCallFailure)(SalOp *op, SalError error, SalReason reason, const char *details);
+typedef void (*SalOnCallFailure)(SalOp *op, SalError error, SalReason reason, const char *details, int code);
 typedef void (*SalOnAuthRequested)(SalOp *op, const char *realm, const char *username);
 typedef void (*SalOnAuthSuccess)(SalOp *op, const char *realm, const char *username);
 typedef void (*SalOnRegisterSuccess)(SalOp *op, bool_t registered);
@@ -258,6 +260,7 @@ int sal_call(SalOp *h, const char *from, const char *to);
 int sal_call_notify_ringing(SalOp *h);
 int sal_call_accept(SalOp*h);
 int sal_call_decline(SalOp *h, SalReason reason, const char *redirection /*optional*/);
+int sal_call_hold(SalOp *h, bool_t holdon);
 SalMediaDescription * sal_call_get_final_media_description(SalOp *h);
 int sal_refer(SalOp *h, const char *refer_to);
 int sal_refer_accept(SalOp *h);
@@ -299,5 +302,4 @@ void __sal_op_init(SalOp *b, Sal *sal);
 void __sal_op_set_network_origin(SalOp *op, const char *origin /*a sip uri*/);
 void __sal_op_free(SalOp *b);
 
-
 #endif
index d1ade9af2d25f8a0b7e7f8355a262cef44e09ef7..94a51fa2405458a5a53c5b4c442e0435a770a317 100644 (file)
@@ -398,6 +398,19 @@ static void set_sdp(osip_message_t *sip,sdp_message_t *msg){
        osip_free(sdp);
 }
 
+static void set_hold_status_to_desc(SalMediaDescription *desc, bool_t holdon)
+{
+       int i;
+       if(desc == NULL)
+               return;
+       desc->notsending = holdon;
+       for(i = 0; i < SAL_MEDIA_DESCRIPTION_MAX_STREAMS; i++)
+       {
+               if(desc->streams != NULL)
+                       desc->streams[i].notsending = holdon;//Audio
+       }
+}
+
 static void set_sdp_from_desc(osip_message_t *sip, const SalMediaDescription *desc){
        sdp_message_t *msg=media_description_to_sdp(desc);
        if (msg==NULL) {
@@ -902,7 +915,7 @@ static void call_released(Sal *sal, eXosip_event_t *ev){
        }
        op->cid=-1;
        if (op->did==-1) 
-               sal->callbacks.call_failure(op,SalErrorNoResponse,SalReasonUnknown,NULL);
+               sal->callbacks.call_failure(op,SalErrorNoResponse,SalReasonUnknown,NULL, 487);
 }
 
 static int get_auth_data_from_response(osip_message_t *resp, const char **realm, const char **username){
@@ -1053,7 +1066,7 @@ static bool_t call_failure(Sal *sal, eXosip_event_t *ev){
                                sr=SalReasonUnknown;
                        }else error=SalErrorNoResponse;
        }
-       sal->callbacks.call_failure(op,error,sr,reason);
+       sal->callbacks.call_failure(op,error,sr,reason,code);
        return TRUE;
 }
 
@@ -1691,3 +1704,35 @@ void sal_address_destroy(SalAddress *u){
        osip_from_free((osip_from_t*)u);
 }
 
+/**
+ * Send a re-Invite used to hold the current call
+ *
+ * @ingroup call_control
+ * @param lc the LinphoneCore object
+ * @param url the destination of the call (sip address).
+**/
+int sal_call_hold(SalOp *h, bool_t holdon)
+{
+       int err=0;
+
+       osip_message_t *reinvite;
+       eXosip_call_build_request(h->did,"INVITE",&reinvite);
+       osip_message_set_subject(reinvite,osip_strdup("Phone Call Hold"));
+       osip_message_set_allow(reinvite, "INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO");
+       if (h->base.root->session_expires!=0){
+               osip_message_set_header(reinvite, "Session-expires", "200");
+               osip_message_set_supported(reinvite, "timer");
+       }
+       //add something to say that the distant sip phone will be in sendonly/sendrecv mode
+       if (h->base.local_media){
+               h->sdp_offering=TRUE;
+               set_hold_status_to_desc(h->base.local_media,holdon);
+               set_sdp_from_desc(reinvite,h->base.local_media);
+       }else h->sdp_offering=FALSE;
+       eXosip_lock();
+       err = eXosip_call_send_request(h->did, reinvite);
+       eXosip_unlock();
+       
+       return err;
+}
+
index 2165708b17711e0b31991891db5906a1c8d18798..2c27c523694b7991c3696b793bed979624659890 100644 (file)
@@ -121,12 +121,21 @@ static sdp_message_t *create_generic_sdp(const SalMediaDescription *desc)
                          osip_strdup ("IN"), inet6 ? osip_strdup("IP6") : osip_strdup ("IP4"),
                          osip_strdup (desc->addr));
        sdp_message_s_name_set (local, osip_strdup ("A conversation"));
-       sdp_message_c_connection_add (local, -1,
-                             osip_strdup ("IN"), inet6 ? osip_strdup ("IP6") : osip_strdup ("IP4"),
-                             osip_strdup (desc->addr), NULL, NULL);
+       if(!desc->notsending)
+       {
+               sdp_message_c_connection_add (local, -1,
+                               osip_strdup ("IN"), inet6 ? osip_strdup ("IP6") : osip_strdup ("IP4"),
+                                               osip_strdup (desc->addr), NULL, NULL);
+       }
+       else
+       {
+               sdp_message_c_connection_add (local, -1,
+                               osip_strdup ("IN"), inet6 ? osip_strdup ("IP6") : osip_strdup ("IP4"),
+                                               inet6 ? osip_strdup ("0.0.0.0.0.0") : osip_strdup ("0.0.0.0"), NULL, NULL);
+       }               
        sdp_message_t_time_descr_add (local, osip_strdup ("0"), osip_strdup ("0"));
        if (desc->bandwidth>0) sdp_message_b_bandwidth_add (local, -1, osip_strdup ("AS"),
-                                    int_2char(desc->bandwidth));
+                       int_2char(desc->bandwidth));
        return local;
 }
 
@@ -186,6 +195,10 @@ static void add_line(sdp_message_t *msg, int lineno, const SalStreamDescription
        for(elem=desc->payloads;elem!=NULL;elem=elem->next){
                add_payload(msg, lineno, (PayloadType*)elem->data);
        }
+       if(desc->notsending)//to hold the distant SIP endpoint
+               sdp_message_a_attribute_add (msg, lineno, osip_strdup ("sendonly"),NULL);
+       else
+               sdp_message_a_attribute_add (msg, lineno, osip_strdup ("sendrecv"),NULL);
 }
 
 sdp_message_t *media_description_to_sdp(const SalMediaDescription *desc){
index c3c95eabebb2984a202414dd94c4b5a9bdb8661c..c3da047e10b3ad184f391e12cbfa4f65cb281a32 100644 (file)
@@ -128,7 +128,7 @@ void linphone_gtk_in_call_view_set_in_call(){
        GtkWidget *duration=linphone_gtk_get_widget(main_window,"in_call_duration");
        GtkWidget *animation=linphone_gtk_get_widget(main_window,"in_call_animation");
        GdkPixbufAnimation *pbuf=create_pixbuf_animation("incall_anim.gif");
-       const LinphoneAddress *uri=linphone_core_get_remote_uri(lc);
+       const LinphoneAddress *uri=linphone_core_get_current_call_remote_address(lc);
        char *tmp=linphone_address_as_string(uri);
        display_peer_name_in_label(callee,tmp);
        ms_free(tmp);
@@ -141,7 +141,9 @@ void linphone_gtk_in_call_view_set_in_call(){
                g_object_unref(G_OBJECT(pbuf));
        }else gtk_image_set_from_stock(GTK_IMAGE(animation),GTK_STOCK_INFO,GTK_ICON_SIZE_DIALOG);
        linphone_gtk_enable_mute_button(
-               GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(main_window,"incall_mute")),TRUE);
+                                       GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(main_window,"incall_mute")),TRUE);
+       linphone_gtk_enable_hold_button(
+               GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(main_window,"hold_call")),TRUE);
 }
 
 void linphone_gtk_in_call_view_update_duration(int duration){
@@ -179,6 +181,8 @@ void linphone_gtk_in_call_view_terminate(const char *error_msg){
        }
        linphone_gtk_enable_mute_button(
                GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(main_window,"incall_mute")),FALSE);
+       linphone_gtk_enable_hold_button(
+               GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(main_window,"hold_call")),FALSE);
        g_timeout_add_seconds(2,(GSourceFunc)in_call_view_terminated,NULL);
 }
 
@@ -206,7 +210,50 @@ void linphone_gtk_mute_toggled(GtkToggleButton *button){
        linphone_gtk_draw_mute_button(button,active);
 }
 
-void linphone_gtk_enable_mute_button(GtkToggleButton *button, gboolean sensitive){
+void linphone_gtk_enable_mute_button(GtkToggleButton *button, gboolean sensitive)
+{
        gtk_widget_set_sensitive(GTK_WIDGET(button),sensitive);
        linphone_gtk_draw_mute_button(button,FALSE);
 }
+
+void linphone_gtk_draw_hold_button(GtkToggleButton *button, gboolean active){
+       GtkWidget *status=linphone_gtk_get_widget(linphone_gtk_get_main_window(),"in_call_status");
+       if (active){
+               GtkWidget *image=create_pixmap("hold_off.png");
+               gtk_button_set_label(GTK_BUTTON(button),_("HoldOff"));
+               gtk_label_set_markup(GTK_LABEL(status),_("<b>In call holded with</b>"));
+               if (image!=NULL) {
+                       gtk_button_set_image(GTK_BUTTON(button),image);
+                       gtk_widget_show(image);
+               }
+       }else{
+               GtkWidget *image=create_pixmap("hold_on.png");
+               gtk_button_set_label(GTK_BUTTON(button),_("HoldOn"));
+               gtk_label_set_markup(GTK_LABEL(status),_("<b>In call with</b>"));
+               if (image!=NULL) {
+                       gtk_button_set_image(GTK_BUTTON(button),image);
+                       gtk_widget_show(image);
+               }
+       }
+}
+
+void linphone_gtk_hold_toggled(GtkToggleButton *button){
+       GtkWidget *mw=linphone_gtk_get_main_window();
+       gboolean active=gtk_toggle_button_get_active(button);
+       if(active)
+       {
+               linphone_core_pause_call(linphone_gtk_get_core(),NULL);
+               gtk_widget_set_sensitive(linphone_gtk_get_widget(mw,"terminate_call"),FALSE);
+       }
+       else
+       {
+               linphone_core_resume_call(linphone_gtk_get_core(),NULL);
+               gtk_widget_set_sensitive(linphone_gtk_get_widget(mw,"terminate_call"),TRUE);
+       }
+       linphone_gtk_draw_hold_button(button,active);
+}
+
+void linphone_gtk_enable_hold_button(GtkToggleButton *button, gboolean sensitive){
+       gtk_widget_set_sensitive(GTK_WIDGET(button),sensitive);
+       linphone_gtk_hold_toggled(button);
+}
index b6dcd5df18212ed017f8ee329c3d643ff4dae467..85027715570c3572ece370ebb6bf27185f5e3f68 100644 (file)
@@ -92,6 +92,7 @@ void linphone_gtk_in_call_view_set_in_call(void);
 void linphone_gtk_in_call_view_update_duration(int duration);
 void linphone_gtk_in_call_view_terminate(const char *error_msg);
 void linphone_gtk_enable_mute_button(GtkToggleButton *button, gboolean sensitive);
+void linphone_gtk_enable_hold_button(GtkToggleButton *button, gboolean sensitive);
 
 void linphone_gtk_show_login_frame(LinphoneProxyConfig *cfg);
 
index 3ce841ad0bd2d97eb884375d921139e0e06c77e1..87db8fb2a4889c2c28e263003b6d981f056f0a4d 100644 (file)
@@ -42,8 +42,8 @@ static LinphoneCore *the_core=NULL;
 static GtkWidget *the_ui=NULL;
 
 static void linphone_gtk_show(LinphoneCore *lc);
-static void linphone_gtk_inv_recv(LinphoneCore *lc, const char *from);
-static void linphone_gtk_bye_recv(LinphoneCore *lc, const char *from);
+static void linphone_gtk_inv_recv(LinphoneCore *lc, LinphoneCall *call);
+static void linphone_gtk_bye_recv(LinphoneCore *lc, LinphoneCall *call);
 static void linphone_gtk_notify_recv(LinphoneCore *lc, LinphoneFriend * fid);
 static void linphone_gtk_new_unknown_subscriber(LinphoneCore *lc, LinphoneFriend *lf, const char *url);
 static void linphone_gtk_auth_info_requested(LinphoneCore *lc, const char *realm, const char *username);
@@ -54,7 +54,7 @@ static void linphone_gtk_display_url(LinphoneCore *lc, const char *msg, const ch
 static void linphone_gtk_display_question(LinphoneCore *lc, const char *question);
 static void linphone_gtk_call_log_updated(LinphoneCore *lc, LinphoneCallLog *cl);
 static void linphone_gtk_general_state(LinphoneCore *lc, LinphoneGeneralState *gstate);
-static void linphone_gtk_refer_received(LinphoneCore *lc, const char *refer_to);
+static void linphone_gtk_refer_received(LinphoneCore *lc, LinphoneCall *call, const char  *refer_to);
 static gboolean linphone_gtk_auto_answer(GtkWidget *incall_window);
 
 static LinphoneCoreVTable vtable={
@@ -390,7 +390,7 @@ static void set_video_window_decorations(GdkWindow *w){
                gdk_window_set_keep_above(w, FALSE);
        }else{
                LinphoneAddress *uri =
-                       linphone_address_clone(linphone_core_get_remote_uri(linphone_gtk_get_core()));
+                       linphone_address_clone(linphone_core_get_current_call_remote_address(linphone_gtk_get_core()));
                char *display_name;
 
                linphone_address_clean(uri);
@@ -588,7 +588,7 @@ static void linphone_gtk_call_started(GtkWidget *mw){
 
 static gboolean linphone_gtk_start_call_do(GtkWidget *uri_bar){
        const char *entered=gtk_entry_get_text(GTK_ENTRY(uri_bar));
-       if (linphone_core_invite(linphone_gtk_get_core(),entered)==0) {
+       if (linphone_core_invite(linphone_gtk_get_core(),entered)!=NULL) {
                completion_add_text(GTK_ENTRY(uri_bar),entered);
        }else{
                linphone_gtk_call_terminated(NULL);
@@ -704,10 +704,11 @@ static void linphone_gtk_show(LinphoneCore *lc){
        linphone_gtk_show_main_window();
 }
 
-static void linphone_gtk_inv_recv(LinphoneCore *lc, const char *from){
+static void linphone_gtk_inv_recv(LinphoneCore *lc, LinphoneCall *call){
        GtkWidget *w=linphone_gtk_create_window("incoming_call");
        GtkWidget *label;
        gchar *msg;
+       char *from=linphone_call_get_remote_address_as_string(call);
 
        if (auto_answer){
                g_timeout_add(2000,(GSourceFunc)linphone_gtk_auto_answer,w);
@@ -727,9 +728,10 @@ static void linphone_gtk_inv_recv(LinphoneCore *lc, const char *from){
        g_object_set_data(G_OBJECT(linphone_gtk_get_main_window()),"incoming_call",w);
        gtk_entry_set_text(GTK_ENTRY(linphone_gtk_get_widget(linphone_gtk_get_main_window(),"uribar")),
                        from);
+       ms_free(from);
 }
 
-static void linphone_gtk_bye_recv(LinphoneCore *lc, const char *from){
+static void linphone_gtk_bye_recv(LinphoneCore *lc, LinphoneCall *call){
        
 }
 
@@ -1145,6 +1147,8 @@ static void linphone_gtk_init_main_window(){
                                        "main_mute")),FALSE);
        linphone_gtk_enable_mute_button(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(main_window,
                                        "incall_mute")),FALSE);
+       linphone_gtk_enable_hold_button(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(main_window,
+                                       "hold_call")),FALSE);
        if (!linphone_gtk_use_in_call_view()) {
                gtk_widget_show(linphone_gtk_get_widget(main_window, "main_mute"));
        }
@@ -1206,7 +1210,7 @@ void linphone_gtk_log_handler(OrtpLogLevel lev, const char *fmt, va_list args){
 }
 
 
-static void linphone_gtk_refer_received(LinphoneCore *lc, const char *refer_to){
+static void linphone_gtk_refer_received(LinphoneCore *lc, LinphoneCall *call, const char *refer_to){
     GtkEntry * uri_bar =GTK_ENTRY(linphone_gtk_get_widget(
                linphone_gtk_get_main_window(), "uribar"));
        linphone_gtk_show_main_window();
index b858892fbddf963b593f5b7b7d155150eff240d0..67701fb238830f20818ce17956c243db7727d3ab 100644 (file)
@@ -1190,6 +1190,7 @@ Fiber Channel</property>
                                 <child>
                                   <widget class="GtkHButtonBox" id="hbuttonbox4">
                                     <property name="visible">True</property>
+                                    <property name="layout_style">spread</property>
                                     <child>
                                       <widget class="GtkToggleButton" id="incall_mute">
                                         <property name="label" translatable="yes">Mute</property>
@@ -1205,6 +1206,21 @@ Fiber Channel</property>
                                         <property name="position">0</property>
                                       </packing>
                                     </child>
+                                    <child>
+                                      <widget class="GtkToggleButton" id="hold_call">
+                                        <property name="label" translatable="yes">HoldOn</property>
+                                        <property name="visible">True</property>
+                                        <property name="sensitive">False</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="receives_default">True</property>
+                                        <signal name="toggled" handler="linphone_gtk_hold_toggled"/>
+                                      </widget>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">False</property>
+                                        <property name="position">1</property>
+                                      </packing>
+                                    </child>
                                   </widget>
                                   <packing>
                                     <property name="expand">False</property>
index 4882634280c82ca495d5bebec482d2744ddb7f61..bc6c0ed4c16db22c9d7cecec9d0c309c722e08ea 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 4882634280c82ca495d5bebec482d2744ddb7f61
+Subproject commit bc6c0ed4c16db22c9d7cecec9d0c309c722e08ea
index 6247f4d277e89b0a55484deac45ff07fbfc70ed7..47d2f51ab350d6eb3c4b5e17dad20b51d3267bcd 100644 (file)
@@ -3,6 +3,7 @@
 pixmapdir=$(datadir)/pixmaps/linphone
 
 pixmap_DATA= \
+hold_on.png hold_off.png \
 mic_muted.png mic_active.png \
 linphone-3-250x130.png linphone-3.png linphone2-57x57.png \
 linphone.png linphone-banner.png \
diff --git a/pixmaps/hold_off.png b/pixmaps/hold_off.png
new file mode 100644 (file)
index 0000000..61ab330
Binary files /dev/null and b/pixmaps/hold_off.png differ
diff --git a/pixmaps/hold_on.png b/pixmaps/hold_on.png
new file mode 100644 (file)
index 0000000..94469b2
Binary files /dev/null and b/pixmaps/hold_on.png differ