diff --git a/README.macos.md b/README.macos.md index 4028bb40a..20660a5a0 100644 --- a/README.macos.md +++ b/README.macos.md @@ -5,8 +5,7 @@ * Xcode (download from apple or using appstore application) * [Java SE](http://www.oracle.com/technetwork/java/javase/downloads/index.html) or openJDK This is required to generate a C sourcefile from SIP grammar using [antlr3](http://www.antlr3.org/) generator. - * [HomeBrew](http://brew.sh) or [Macports](http://www.macports.org/). - * [XQuartz](https://xquartz.macosforge.org) for GTK version. +* [HomeBrew](http://brew.sh) or [Macports](http://www.macports.org/). ### Dependencies diff --git a/coreapi/bellesip_sal/sal_impl.c b/coreapi/bellesip_sal/sal_impl.c index 84964ecf1..3b3c24955 100644 --- a/coreapi/bellesip_sal/sal_impl.c +++ b/coreapi/bellesip_sal/sal_impl.c @@ -1135,6 +1135,16 @@ void sal_cancel_timer(Sal *sal, belle_sip_source_t *timer) { belle_sip_main_loop_t *ml = belle_sip_stack_get_main_loop(sal->stack); belle_sip_main_loop_remove_source(ml, timer); } + +unsigned long sal_begin_background_task(const char *name, void (*max_time_reached)(void *), void *data){ + return belle_sip_begin_background_task(name, max_time_reached, data); +} + +void sal_end_background_task(unsigned long id){ + belle_sip_end_background_task(id); +} + + void sal_enable_sip_update_method(Sal *ctx,bool_t value) { ctx->enable_sip_update=value; } diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index 3eacb34ea..47032e22e 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -336,6 +336,8 @@ static void call_received(SalOp *h){ linphone_core_add_call(lc,call); linphone_call_ref(call); /*prevent the call from being destroyed while we are notifying, if the user declines within the state callback */ + call->bg_task_id=sal_begin_background_task("liblinphone call notification", NULL, NULL); + if ((linphone_core_get_firewall_policy(lc) == LinphonePolicyUseIce) && (call->ice_session != NULL)) { /* Defer ringing until the end of the ICE candidates gathering process. */ ms_message("Defer ringing to gather ICE candidates"); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 537ff51d9..923731619 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -3292,6 +3292,12 @@ void linphone_core_notify_incoming_call(LinphoneCore *lc, LinphoneCall *call){ } linphone_call_set_state(call,LinphoneCallIncomingReceived,"Incoming call"); + /*from now on, the application is aware of the call and supposed to take background task or already submitted notification to the user. + We can then drop our background task.*/ + if (call->bg_task_id!=0) { + sal_end_background_task(call->bg_task_id); + call->bg_task_id=0; + } if (call->state==LinphoneCallIncomingReceived){ /*try to be best-effort in giving real local or routable contact address for 100Rel case*/ diff --git a/coreapi/private.h b/coreapi/private.h index 56ddf2dc8..36fc09b1b 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -257,6 +257,7 @@ struct _LinphoneCall{ LinphoneCall *transfer_target;/*if this call received a transfer request, then transfer_target points to the new call created to the refer target */ int localdesc_changed;/*not a boolean, contains a mask representing changes*/ LinphonePlayer *player; + unsigned long bg_task_id; /*used to prevent device to suspend app while a call is received in background*/ char *dtmf_sequence; /*DTMF sequence needed to be sent using #dtmfs_timer*/ belle_sip_source_t *dtmfs_timer; /*DTMF timer needed to send a DTMF sequence*/ diff --git a/gtk/logging.c b/gtk/logging.c index 26027251f..c5eb883c0 100644 --- a/gtk/logging.c +++ b/gtk/logging.c @@ -164,7 +164,6 @@ static FILE *linphone_gtk_log_init() static void linphone_gtk_log_file(OrtpLogLevel lev, const char *msg) { - time_t now; FILE *outlog; outlog = linphone_gtk_log_init(); @@ -176,12 +175,11 @@ static void linphone_gtk_log_file(OrtpLogLevel lev, const char *msg) logfile_date_format in the GtkUi section of the config file, but it defaults to something compact, but yet readable. */ const char *lname="undef"; - char date[256]; /* Convert level constant to text */ switch(lev){ case ORTP_DEBUG: - lname="debug"; + lname="debug "; break; case ORTP_MESSAGE: lname="message"; @@ -190,23 +188,16 @@ static void linphone_gtk_log_file(OrtpLogLevel lev, const char *msg) lname="warning"; break; case ORTP_ERROR: - lname="error"; + lname="error "; break; case ORTP_FATAL: - lname="fatal"; + lname="fatal "; break; default: - lname="undef"; + lname="undef "; break; } - /* Get current time and format it properly */ - now = time(NULL); - strftime(date, sizeof(date), dateformat, localtime(&now)); - /* Now print out the message to the logfile. We don't flush, - maybe we should do to ensure that we have all the messages in - case of a crash (which is one of the main reasons we have a - log facility in the first place). */ - fprintf(outlog, "[%s] [%s] %s\n", date, lname, msg); + fprintf(outlog, "[%s] %s\n", lname, msg); fflush(outlog); } } @@ -335,13 +326,24 @@ gboolean linphone_gtk_check_logs(){ * Called from any linphone thread. */ void linphone_gtk_log_push(OrtpLogLevel lev, const char *fmt, va_list args){ - gchar *msg=g_strdup_vprintf(fmt,args); LinphoneGtkLog *lgl=g_new(LinphoneGtkLog,1); + gchar *msg=g_strdup_vprintf(fmt,args); + gchar *dated_msg; + struct timeval tp; + struct tm *lt; + time_t tt; + + ortp_gettimeofday(&tp, NULL); + tt = (time_t)tp.tv_sec; + lt = localtime((const time_t*)&tt); + dated_msg=g_strdup_printf("%i-%.2i-%.2i %.2i:%.2i:%.2i:%.3i %s", + 1900 + lt->tm_year, lt->tm_mon + 1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec, (int)(tp.tv_usec / 1000), msg); + g_free(msg); lgl->lev=lev; - lgl->msg=msg; + lgl->msg=dated_msg; + linphone_gtk_log_file(lev, dated_msg); g_static_mutex_lock(&log_mutex); log_queue=g_list_append(log_queue,lgl); - linphone_gtk_log_file(lev, msg); g_static_mutex_unlock(&log_mutex); } diff --git a/include/sal/sal.h b/include/sal/sal.h index 666671674..4eedb23ab 100644 --- a/include/sal/sal.h +++ b/include/sal/sal.h @@ -811,4 +811,10 @@ int sal_lines_get_value(const char *data, const char *key, char *value, size_t v belle_sip_stack_t *sal_get_belle_sip_stack(Sal *sal); char* sal_op_get_public_uri(SalOp *sal); + +unsigned long sal_begin_background_task(const char *name, void (*max_time_reached)(void *), void *data); +void sal_end_background_task(unsigned long id); + #endif + +