Commit 01759a84 authored by smorlat's avatar smorlat

gui modifications

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@668 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
parent 2d355a2a
dnl Process this file with autoconf to produce a configure script.
AC_INIT([linphone],[3.2.0],[linphone-developers@nongnu.org])
AC_INIT([linphone],[3.2.0.99],[linphone-developers@nongnu.org])
AC_CANONICAL_SYSTEM
dnl Source packaging numbers
......
......@@ -965,19 +965,23 @@ void linphone_registration_success(LinphoneCore *lc,eXosip_event_t *ev){
char *msg;
char *ru;
osip_header_t *h=NULL;
osip_uri_to_str(requri,&ru);
msg=ms_strdup_printf(_("Registration on %s successful."),ru);
lc->vtable.display_status(lc,msg);
ms_free(msg);
osip_free(ru);
cfg=linphone_core_get_proxy_config_from_rid(lc,ev->rid);
ms_return_if_fail(cfg!=NULL);
gstate_new_state(lc, GSTATE_REG_OK, NULL);
osip_message_get_expires(ev->request,0,&h);
if (h!=NULL && atoi(h->hvalue)!=0){
cfg->registered=TRUE;
linphone_proxy_config_register_again_with_updated_contact(cfg,ev->request,ev->response);
}else cfg->registered=FALSE;
osip_uri_to_str(requri,&ru);
if (cfg->registered) msg=ms_strdup_printf(_("Registration on %s successful."),ru);
else msg=ms_strdup_printf(_("Unregistration on %s done."),ru);
lc->vtable.display_status(lc,msg);
ms_free(msg);
osip_free(ru);
}
static bool_t comes_from_local_if(osip_message_t *msg){
......
......@@ -66,8 +66,10 @@ static int sip_login_do_login(SipSetupContext * ctx, const char *uri, const char
}
osip_from_to_str(parsed_uri,&tmp);
linphone_proxy_config_set_identity(cfg,tmp);
auth=linphone_auth_info_new(parsed_uri->url->username,NULL,passwd,NULL,NULL);
linphone_core_add_auth_info(lc,auth);
if (passwd ) {
auth=linphone_auth_info_new(parsed_uri->url->username,NULL,passwd,NULL,NULL);
linphone_core_add_auth_info(lc,auth);
}
linphone_proxy_config_enable_register(cfg,TRUE);
linphone_proxy_config_done(cfg);
osip_free(tmp);
......@@ -76,11 +78,19 @@ static int sip_login_do_login(SipSetupContext * ctx, const char *uri, const char
return 0;
}
static int sip_login_do_logout(SipSetupContext * ctx){
LinphoneProxyConfig *cfg=sip_setup_context_get_proxy_config(ctx);
linphone_proxy_config_enable_register(cfg,FALSE);
linphone_proxy_config_done(cfg);
return 0;
}
/* a simple SipSetup built-in plugin to allow specify the user/password for proxy config at runtime*/
SipSetup linphone_sip_login={
.name="SipLogin",
.capabilities=SIP_SETUP_CAP_LOGIN,
.init_instance=sip_login_init_instance,
.login_account=sip_login_do_login,
.logout_account=sip_login_do_logout
};
......@@ -180,6 +180,13 @@ void sip_setup_context_free_results(MSList *results){
ms_list_free(results);
}
int sip_setup_context_logout(SipSetupContext *ctx){
if (ctx->funcs->logout_account){
return ctx->funcs->logout_account(ctx);
}
return -1;
}
void sip_setup_context_free(SipSetupContext *ctx){
if (ctx->funcs->uninit_instance){
ctx->funcs->uninit_instance(ctx);
......
......@@ -90,6 +90,7 @@ struct _SipSetup{
int (*get_buddy_lookup_results)(SipSetupContext *ctx, MSList **results);
const char * (*get_notice)(SipSetupContext *ctx);
const char ** (*get_domains)(SipSetupContext *ctx);
int (*logout_account)(SipSetupContext *ctx);
};
typedef struct _SipSetup SipSetup;
......@@ -122,6 +123,8 @@ const char ** sip_setup_context_get_domains(SipSetupContext *ctx);
void sip_setup_context_free_results(MSList *results);
void sip_setup_context_free(SipSetupContext *ctx);
int sip_setup_context_logout(SipSetupContext *ctx);
/*internal methods*/
struct _LinphoneProxyConfig *sip_setup_context_get_proxy_config(const SipSetupContext *ctx);
......
......@@ -12,6 +12,12 @@
#include "linphone.h"
gboolean linphone_gtk_use_in_call_view(){
static int val=-1;
if (val==-1) val=linphone_gtk_get_ui_config_int("use_incall_view",1);
return val;
}
void linphone_gtk_show_in_call_view(void){
GtkWidget *main_window=linphone_gtk_get_main_window();
GtkWidget *idle_frame=linphone_gtk_get_widget(main_window,"idle_frame");
......@@ -33,6 +39,11 @@ void display_peer_name_in_label(GtkWidget *label, const char *uri){
char *displayname=NULL,*id=NULL;
char *uri_label;
if (uri==NULL) {
ms_error("Strange: in call with nobody ?");
return;
}
osip_from_init(&from);
if (osip_from_parse(from,uri)==0){
......
......@@ -64,6 +64,8 @@ void linphone_gtk_destroy_log_window(void);
gboolean linphone_gtk_check_logs();
const gchar *linphone_gtk_get_ui_config(const char *key, const char *def);
int linphone_gtk_get_ui_config_int(const char *key, int def);
void linphone_gtk_set_ui_config_int(const char *key , int val);
void linphone_gtk_open_browser(const char *url);
void linphone_gtk_check_for_new_version(void);
const char *linphone_gtk_get_lang(const char *config_file);
......@@ -77,6 +79,7 @@ gchar *linphone_gtk_get_display_name(const char *sip_uri);
void linphone_gtk_show_directory_search(void);
/*functions controlling the different views*/
gboolean linphone_gtk_use_in_call_view();
void linphone_gtk_show_in_call_view(void);
void linphone_gtk_show_idle_view(void);
void linphone_gtk_in_call_view_set_calling(const char *uri);
......
......@@ -19,11 +19,39 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "linphone.h"
void linphone_gtk_login_frame_connect_clicked(GtkWidget *button);
void linphone_gtk_exit_login_frame(void);
enum {
NetworkKindAdsl,
NetworkKindOpticalFiber
};
static gboolean check_login_ok(LinphoneProxyConfig *cfg){
if (linphone_proxy_config_is_registered(cfg)){
linphone_gtk_exit_login_frame();
return FALSE;
}
return TRUE;
}
static void do_login(SipSetupContext *ssctx, const char *identity, const char * passwd){
GtkWidget *mw=linphone_gtk_get_main_window();
if (sip_setup_context_login_account(ssctx,identity,passwd)==0){
guint t=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(mw),"login_tout"));
if (t!=0) g_source_remove(t);
t=g_timeout_add(50,(GSourceFunc)check_login_ok,sip_setup_context_get_proxy_config(ssctx));
g_object_set_data(G_OBJECT(mw),"login_tout",GINT_TO_POINTER(t));
}
}
static gboolean do_login_noprompt(LinphoneProxyConfig *cfg){
SipSetupContext *ssctx=linphone_proxy_config_get_sip_setup_context(cfg);
if (ssctx==NULL) return TRUE;/*not ready ?*/
do_login(ssctx,linphone_proxy_config_get_identity(cfg),NULL);
return FALSE;
}
void linphone_gtk_show_login_frame(LinphoneProxyConfig *cfg){
GtkWidget *mw=linphone_gtk_get_main_window();
GtkWidget *label=linphone_gtk_get_widget(mw,"login_label");
......@@ -33,6 +61,12 @@ void linphone_gtk_show_login_frame(LinphoneProxyConfig *cfg){
LinphoneCore *lc=linphone_gtk_get_core();
int nettype;
if (linphone_gtk_get_ui_config_int("automatic_login",0) ){
g_timeout_add(250,(GSourceFunc)do_login_noprompt,cfg);
return;
}
gtk_widget_hide(linphone_gtk_get_widget(mw,"logout"));
gtk_widget_hide(linphone_gtk_get_widget(mw,"idle_frame"));
gtk_widget_show(linphone_gtk_get_widget(mw,"login_frame"));
gtk_widget_set_sensitive(linphone_gtk_get_widget(mw,"main_menu"),FALSE);
......@@ -66,52 +100,61 @@ void linphone_gtk_exit_login_frame(void){
gtk_widget_hide(linphone_gtk_get_widget(mw,"login_frame"));
gtk_widget_set_sensitive(linphone_gtk_get_widget(mw,"main_menu"),TRUE);
gtk_widget_set_sensitive(linphone_gtk_get_widget(mw,"modes"),TRUE);
gtk_widget_show(linphone_gtk_get_widget(mw,"logout"));
}
gboolean check_login_ok(LinphoneProxyConfig *cfg){
if (linphone_proxy_config_is_registered(cfg)){
linphone_gtk_exit_login_frame();
return FALSE;
void linphone_gtk_logout_clicked(){
LinphoneCore *lc=linphone_gtk_get_core();
LinphoneProxyConfig *cfg=NULL;
linphone_core_get_default_proxy(lc,&cfg);
if (cfg){
SipSetupContext *ss=linphone_proxy_config_get_sip_setup_context(cfg);
if (ss){
sip_setup_context_logout(ss);
linphone_gtk_set_ui_config_int("automatic_login",FALSE);
linphone_gtk_show_login_frame(cfg);
}
}
return TRUE;
}
void linphone_gtk_login_frame_connect_clicked(GtkWidget *button){
GtkWidget *mw=gtk_widget_get_toplevel(button);
const char *username;
const char *password;
char *identity;
int netkind_id;
LinphoneCore *lc=linphone_gtk_get_core();
gboolean autologin;
LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)g_object_get_data(G_OBJECT(mw),"login_proxy_config");
SipSetupContext *ssctx=linphone_proxy_config_get_sip_setup_context(cfg);
osip_from_t *from;
SipSetupContext *ssctx=linphone_proxy_config_get_sip_setup_context(cfg);
username=gtk_entry_get_text(GTK_ENTRY(linphone_gtk_get_widget(mw,"login_username")));
password=gtk_entry_get_text(GTK_ENTRY(linphone_gtk_get_widget(mw,"login_password")));
netkind_id=gtk_combo_box_get_active(GTK_COMBO_BOX(linphone_gtk_get_widget(mw,"login_internet_kind")));
autologin=gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(linphone_gtk_get_widget(mw,"automatic_login")));
linphone_gtk_set_ui_config_int("automatic_login",autologin);
if (netkind_id==NetworkKindAdsl){
linphone_core_set_upload_bandwidth(lc,256);
linphone_core_set_download_bandwidth(lc,512);
}else if (netkind_id==NetworkKindOpticalFiber){
/*infinite*/
linphone_core_set_upload_bandwidth(lc,0);
linphone_core_set_download_bandwidth(lc,0);
}
osip_from_init(&from);
osip_from_parse(from,linphone_proxy_config_get_identity(cfg));
osip_free(from->url->username);
from->url->username=osip_strdup(username);
osip_from_to_str(from,&identity);
osip_from_free(from);
if (sip_setup_context_login_account(ssctx,identity,password)==0){
guint t=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(mw),"login_tout"));
if (t!=0) g_source_remove(t);
t=g_timeout_add(50,(GSourceFunc)check_login_ok,cfg);
g_object_set_data(G_OBJECT(mw),"login_tout",GINT_TO_POINTER(t));
}
do_login(ssctx,identity,password);
/*we need to refresh the identities since the proxy config may have changed.*/
linphone_gtk_load_identities();
}
void linphone_gtk_internet_kind_changed(GtkWidget *combo){
int netkind_id=gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
LinphoneCore *lc=linphone_gtk_get_core();
if (netkind_id==NetworkKindAdsl){
linphone_core_set_upload_bandwidth(lc,256);
linphone_core_set_download_bandwidth(lc,512);
}else if (netkind_id==NetworkKindOpticalFiber){
/*infinite*/
linphone_core_set_upload_bandwidth(lc,0);
linphone_core_set_download_bandwidth(lc,0);
}
}
......@@ -135,6 +135,7 @@ static GOptionEntry linphone_options[]={
static char _config_file[1024];
const char *linphone_gtk_get_config_file(){
/*try accessing a local file first if exists*/
if (access(CONFIG_FILE,F_OK)==0){
......@@ -172,7 +173,7 @@ GtkWidget *linphone_gtk_get_main_window(){
return the_ui;
}
static void parse_item(const char *item, const char *window_name, GtkWidget *w){
static void parse_item(const char *item, const char *window_name, GtkWidget *w, gboolean show){
char tmp[64];
char *dot;
strcpy(tmp,item);
......@@ -182,12 +183,15 @@ static void parse_item(const char *item, const char *window_name, GtkWidget *w){
dot++;
if (strcmp(window_name,tmp)==0){
GtkWidget *wd=linphone_gtk_get_widget(w,dot);
if (wd) gtk_widget_hide(wd);
if (wd) {
if (!show) gtk_widget_hide(wd);
else gtk_widget_show(wd);
}
}
}
}
static void parse_hiddens(const char *hiddens, const char *window_name, GtkWidget *w){
static void parse_widgets(const char *hiddens, const char *window_name, GtkWidget *w, gboolean show){
char item[64];
const char *i;
const char *b;
......@@ -198,30 +202,33 @@ static void parse_hiddens(const char *hiddens, const char *window_name, GtkWidge
strncpy(item,b,len);
item[len]='\0';
b=i+1;
parse_item(item,window_name,w);
parse_item(item,window_name,w,show);
}
}
len=MIN(i-b,sizeof(item)-1);
if (len>0){
strncpy(item,b,len);
item[len]='\0';
parse_item(item,window_name,w);
parse_item(item,window_name,w,show);
}
}
static void linphone_gtk_configure_window(GtkWidget *w, const char *window_name){
static const char *icon_path=0;
static const char *hiddens=0;
static const char *icon_path=NULL;
static const char *hiddens=NULL;
static const char *shown=NULL;
static bool_t config_loaded=FALSE;
if (linphone_gtk_get_core()==NULL) return;
if (config_loaded==FALSE){
hiddens=linphone_gtk_get_ui_config("hidden_widgets",NULL);
shown=linphone_gtk_get_ui_config("shown_widgets",NULL);
icon_path=linphone_gtk_get_ui_config("icon",NULL);
config_loaded=TRUE;
}
if (hiddens){
parse_hiddens(hiddens,window_name,w);
}
if (hiddens)
parse_widgets(hiddens,window_name,w,FALSE);
if (shown)
parse_widgets(shown,window_name,w,TRUE);
if (icon_path) {
GdkPixbuf *pbuf=create_pixbuf(icon_path);
gtk_window_set_icon(GTK_WINDOW(w),pbuf);
......@@ -513,7 +520,8 @@ void linphone_gtk_call_terminated(const char *error){
gtk_widget_set_sensitive(linphone_gtk_get_widget(mw,"terminate_call"),FALSE);
gtk_widget_set_sensitive(linphone_gtk_get_widget(mw,"start_call"),TRUE);
gtk_widget_hide_all(linphone_gtk_get_widget(mw,"go_to_call_view_box"));
linphone_gtk_in_call_view_terminate(error);
if (linphone_gtk_use_in_call_view())
linphone_gtk_in_call_view_terminate(error);
update_video_title();
g_object_set_data(G_OBJECT(mw),"incoming_call",NULL);
......@@ -533,7 +541,8 @@ static void linphone_gtk_call_started(GtkWidget *mw){
gtk_widget_set_sensitive(linphone_gtk_get_widget(mw,"terminate_call"),TRUE);
gtk_widget_show_all(linphone_gtk_get_widget(mw,"go_to_call_view_box"));
update_video_title();
g_timeout_add(250,(GSourceFunc)in_call_timer,NULL);
if (linphone_gtk_use_in_call_view())
g_timeout_add(250,(GSourceFunc)in_call_timer,NULL);
}
static gboolean linphone_gtk_start_call_do(GtkWidget *uri_bar){
......@@ -555,8 +564,10 @@ void linphone_gtk_start_call(GtkWidget *w){
GtkWidget *uri_bar=linphone_gtk_get_widget(mw,"uribar");
const char *entered=gtk_entry_get_text(GTK_ENTRY(uri_bar));
linphone_gtk_call_started(mw);
linphone_gtk_in_call_view_set_calling(entered);
linphone_gtk_show_in_call_view();
if (linphone_gtk_use_in_call_view()){
linphone_gtk_in_call_view_set_calling(entered);
linphone_gtk_show_in_call_view();
}
g_timeout_add(100,(GSourceFunc)linphone_gtk_start_call_do,uri_bar);
}
}
......@@ -584,8 +595,10 @@ void linphone_gtk_accept_call(GtkWidget *button){
g_object_set_data(G_OBJECT(linphone_gtk_get_main_window()),"incoming_call",NULL);
gtk_widget_destroy(gtk_widget_get_toplevel(button));
linphone_gtk_call_started(linphone_gtk_get_main_window());
linphone_gtk_in_call_view_set_in_call();
linphone_gtk_show_in_call_view();
if (linphone_gtk_use_in_call_view()){
linphone_gtk_in_call_view_set_in_call();
linphone_gtk_show_in_call_view();
}
}
static gboolean linphone_gtk_auto_answer(GtkWidget *incall_window){
......@@ -794,7 +807,8 @@ static void linphone_gtk_general_state(LinphoneCore *lc, LinphoneGeneralState *g
switch(gstate->new_state){
case GSTATE_CALL_OUT_CONNECTED:
case GSTATE_CALL_IN_CONNECTED:
linphone_gtk_in_call_view_set_in_call();
if (linphone_gtk_use_in_call_view())
linphone_gtk_in_call_view_set_in_call();
break;
case GSTATE_CALL_ERROR:
linphone_gtk_call_terminated(gstate->message);
......
This diff is collapsed.
......@@ -188,4 +188,9 @@ int linphone_gtk_get_ui_config_int(const char *key, int def){
return lp_config_get_int(cfg,"GtkUi",key,def);
}
void linphone_gtk_set_ui_config_int(const char *key , int val){
LpConfig *cfg=linphone_core_get_config(linphone_gtk_get_core());
lp_config_set_int(cfg,"GtkUi",key,val);
}
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