Commit dba5a233 authored by Simon Morlat's avatar Simon Morlat

gtk app remote provisioning in progress

parent 8367c0fe
......@@ -2280,9 +2280,29 @@ typedef struct _LinphoneContactProvider LinphoneContactProvider;
typedef void (*ContactSearchCallback)( LinphoneContactSearch* id, MSList* friends, void* data );
/** Remote provisioning
/*
* Remote provisioning
*/
/**
* Set URI where to download xml configuration file at startup.
* This can also be set from configuration file or factory config file, from [misc] section, item "config-uri".
* Calling this function does not load the configuration. It will write the value into configuration so that configuration
* from remote URI will take place at next LinphoneCore start.
* @param lc the linphone core
* @param uri the http or https uri to use in order to download the configuration.
* @ingroup initializing
**/
LINPHONE_PUBLIC void linphone_core_set_provisioning_uri(LinphoneCore *lc, const char*uri);
/**
* Get provisioning URI.
* @param lc the linphone core
* @return the provisioning URI.
* @ingroup initializing
**/
LINPHONE_PUBLIC const char* linphone_core_get_provisioning_uri(const LinphoneCore *lc);
typedef void (*ConfiguringCallback)(LinphoneCore *lc, LinphoneConfiguringState state, const char *message);
/**
......
......@@ -16,8 +16,7 @@ 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.
*/
#include "linphonecore.h"
#include "bellesip_sal/sal_impl.h"
#include "private.h"
#include "xml2lpc.h"
#define XML2LPC_CALLBACK_BUFFER_SIZE 1024
......@@ -137,4 +136,14 @@ static void linphone_remote_provisioning_download(LinphoneCore *lc, const char *
void linphone_remote_provisioning_download_and_apply(LinphoneCore *lc, const char *remote_provisioning_uri, ConfiguringCallback cb) {
linphone_callback = cb;
linphone_remote_provisioning_download(lc, remote_provisioning_uri);
}
\ No newline at end of file
}
void linphone_core_set_provisioning_uri(LinphoneCore *lc, const char*uri){
if (linphone_core_ready(lc)){
lp_config_set_string(lc->config,"misc","config-uri",uri);
}
}
const char*linphone_core_get_provisioning_uri(const LinphoneCore *lc){
return lp_config_get_string(lc->config,"misc","config-uri",NULL);
}
......@@ -23,6 +23,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
void linphone_gtk_set_configuration_uri(GtkWidget *item){
GtkWidget *w=linphone_gtk_create_window("config-uri");
GtkWidget *entry=linphone_gtk_get_widget(w,"uri_entry");
const char *uri=linphone_core_get_provisioning_uri(linphone_gtk_get_core());
gtk_entry_set_text(GTK_ENTRY(entry),uri);
gtk_widget_show(w);
}
......@@ -30,8 +33,9 @@ void linphone_gtk_config_uri_changed(GtkWidget *button){
GtkWidget *w=gtk_widget_get_toplevel(button);
GtkWidget *entry=linphone_gtk_get_widget(w,"uri_entry");
const char *uri=gtk_entry_get_text(GTK_ENTRY(entry));
if (uri){
if (uri && strcmp(uri,"https://")!=0){/*not just the hint text*/
/*set provisionning uri to the core*/
linphone_core_set_provisioning_uri(linphone_gtk_get_core(),uri);
gtk_widget_destroy(w);
}
......@@ -46,3 +50,29 @@ void linphone_gtk_config_uri_cancel(GtkWidget *button){
gtk_widget_destroy(w);
}
GtkWidget * linphone_gtk_show_config_fetching(void){
LinphoneCore *lc=linphone_gtk_get_core();
GtkWidget *w=linphone_gtk_create_window("provisioning-fetch");
g_message("Fetching started");
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(w),_("fetching from %s"),linphone_core_get_provisioning_uri(lc));
#if GTK_CHECK_VERSION(2,20,0)
{
GtkWidget *spinner=gtk_spinner_new();
gtk_message_dialog_set_image(GTK_MESSAGE_DIALOG(w),spinner);
}
#endif
gtk_widget_show(w);
return w;
}
void linphone_gtk_close_config_fetching(GtkWidget *w, LinphoneConfiguringState state){
LinphoneCore *lc=linphone_gtk_get_core();
gtk_widget_destroy(w);
g_message("Fetching finished");
if (state==LinphoneConfiguringFailed){
GtkWidget *msg=gtk_message_dialog_new(NULL,0,GTK_MESSAGE_ERROR,GTK_BUTTONS_CLOSE,_("Downloading of remote configuration from %s failed."),
linphone_core_get_provisioning_uri(lc));
gtk_widget_show(msg);
}
}
......@@ -165,4 +165,8 @@ void linphone_gtk_monitor_usb(void);
void linphone_gtk_unmonitor_usb(void);
gchar *linphone_gtk_get_record_path(const LinphoneAddress *address, gboolean is_conference);
void linphone_gtk_schedule_restart(void);
\ No newline at end of file
void linphone_gtk_schedule_restart(void);
GtkWidget * linphone_gtk_show_config_fetching(void);
void linphone_gtk_close_config_fetching(GtkWidget *w, LinphoneConfiguringState state);
......@@ -90,6 +90,7 @@ gchar *linphone_logfile=NULL;
static gboolean workaround_gtk_entry_chinese_bug=FALSE;
static gchar *custom_config_file=NULL;
static gboolean restart=FALSE;
static GtkWidget *config_fetching_dialog=NULL;
static GOptionEntry linphone_options[]={
{
......@@ -1248,7 +1249,8 @@ static void linphone_gtk_display_status(LinphoneCore *lc, const char *status){
}
static void linphone_gtk_configuring_status(LinphoneCore *lc, LinphoneConfiguringState status, const char *message) {
if (config_fetching_dialog) linphone_gtk_close_config_fetching(config_fetching_dialog, status);
config_fetching_dialog=NULL;
}
static void linphone_gtk_display_message(LinphoneCore *lc, const char *msg){
......@@ -1362,8 +1364,16 @@ void linphone_gtk_notify(LinphoneCall *call, const char *msg){
static void linphone_gtk_global_state_changed(LinphoneCore *lc, LinphoneGlobalState state, const char*str){
switch(state){
case LinphoneGlobalStartup:
the_core=lc;
break;
case LinphoneGlobalConfiguring:
if (linphone_core_get_provisioning_uri(lc)){
config_fetching_dialog=linphone_gtk_show_config_fetching();
}
break;
case LinphoneGlobalOn:
if (the_core) linphone_gtk_init_ui();
linphone_gtk_init_ui();
break;
default:
break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment