Commit f3a7dfce authored by smorlat's avatar smorlat

work in progress: add an optional screen login.

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@638 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
parent 87f568ad
......@@ -25,7 +25,8 @@ liblinphone_la_SOURCES=\
lpconfig.c lpconfig.h \
chat.c \
general_state.c \
sipsetup.c sipsetup.h
sipsetup.c sipsetup.h \
siplogin.c
liblinphone_la_LDFLAGS= -version-info $(LIBLINPHONE_SO_VERSION) -no-undefined
......
......@@ -2,7 +2,7 @@
* authentication.c
*
* Fri Jul 16 12:08:34 2004
* Copyright 2004 Simon MORLAT
* Copyright 2004-2009 Simon MORLAT
* simon.morlat@linphone.org
****************************************************************************/
......
......@@ -776,6 +776,7 @@ void linphone_core_get_local_ip(LinphoneCore *lc, const char *dest, char *result
strncpy(result,linphone_core_get_nat_address(lc),LINPHONE_IPADDR_SIZE);
return;
}
if (dest==NULL) dest="87.98.157.38"; /*a public IP address*/
if (linphone_core_get_local_ip_for(dest,result)==0)
return;
/*else fallback to exosip routine that will attempt to find the most realistic interface */
......
......@@ -332,6 +332,7 @@ LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(struct _LpConfig
void linphone_proxy_config_write_to_config_file(struct _LpConfig* config,LinphoneProxyConfig *obj, int index);
void linphone_proxy_config_set_sip_setup(LinphoneProxyConfig *cfg, const char *type);
SipSetupContext *linphone_proxy_config_get_sip_setup_context(LinphoneProxyConfig *cfg);
SipSetup *linphone_proxy_config_get_sip_setup(LinphoneProxyConfig *cfg);
typedef struct _LinphoneAccountCreator{
struct _LinphoneCore *lc;
......
......@@ -648,6 +648,14 @@ static void linphone_proxy_config_activate_sip_setup(LinphoneProxyConfig *cfg){
}
SipSetup *linphone_proxy_config_get_sip_setup(LinphoneProxyConfig *cfg){
if (cfg->ssctx!=NULL) return cfg->ssctx->funcs;
if (cfg->type!=NULL){
return sip_setup_lookup(cfg->type);
}
return NULL;
}
void linphone_proxy_config_update(LinphoneProxyConfig *cfg){
if (cfg->commit){
if (cfg->type && cfg->ssctx==NULL){
......
/*
linphone
Copyright (C) 2009 Simon MORLAT (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 HAVE_CONFIG_H
#include "../config.h"
#endif
#include "linphonecore.h"
static void sip_login_init_instance(SipSetupContext *ctx){
LinphoneProxyConfig *cfg=sip_setup_context_get_proxy_config(ctx);
/*disable registration until the user logs in*/
linphone_proxy_config_enable_register(cfg,FALSE);
}
static int sip_login_do_login(SipSetupContext * ctx, const char *uri, const char *passwd){
LinphoneProxyConfig *cfg=sip_setup_context_get_proxy_config(ctx);
LinphoneCore *lc=linphone_proxy_config_get_core(cfg);
LinphoneAuthInfo *auth=linphone_auth_info_new(ctx->username,NULL,passwd,NULL,NULL);
linphone_proxy_config_set_identity(cfg,uri);
linphone_core_add_auth_info(lc,auth);
linphone_proxy_config_enable_register(cfg,TRUE);
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,
};
/*
linphone
Copyright (C) 2000 Simon MORLAT (simon.morlat@linphone.org)
Copyright (C) 2009 Simon MORLAT (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
......@@ -23,7 +23,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "linphonecore.h"
extern SipSetup linphone_sip_login;
static SipSetup *all_sip_setups[]={
&linphone_sip_login,
NULL
};
......@@ -38,6 +41,7 @@ void sip_setup_register_all(void){
ms_load_plugins(LINPHONE_PLUGINS_DIR);
while(*p!=NULL){
sip_setup_register(*p);
p++;
}
}
......
......@@ -42,7 +42,8 @@ typedef struct _SipSetupContext SipSetupContext;
#define SIP_SETUP_CAP_STUN_PROVIDER (1<<1)
#define SIP_SETUP_CAP_RELAY_PROVIDER (1<<2)
#define SIP_SETUP_CAP_BUDDY_LOOKUP (1<<3)
#define SIP_SETUP_CAP_ACCOUNT_MANAGER (1<<4)
#define SIP_SETUP_CAP_ACCOUNT_MANAGER (1<<4) /*can create accounts*/
#define SIP_SETUP_CAP_LOGIN (1<<5) /*can login to any account for a given proxy */
typedef enum _BuddyLookupStatus{
BuddyLookupNone,
......
......@@ -17,8 +17,7 @@ PIXMAPS= linphone2.png \
EXTRA_DIST= $(PIXMAPS) \
$(GLADE_FILES) \
linphone.iss \
linphone.dev
linphone.iss
if BUILD_GLADE_UI
......@@ -39,6 +38,7 @@ linphone_3_SOURCES= \
utils.c \
setupwizard.c\
incall_view.c \
loginframe.c \
linphone.h
linphone_3_LDADD=$(top_builddir)/oRTP/src/libortp.la \
......
......@@ -76,10 +76,11 @@ gchar *linphone_gtk_get_display_name(const char *sip_uri);
void linphone_gtk_show_directory_search(void);
/*functions controlling the in-call view*/
/*functions controlling the different views*/
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);
void linphone_gtk_in_call_view_set_in_call(const char *uri);
void linphone_gtk_in_call_view_update_duration(int duration);
void linphone_gtk_in_call_view_terminate(const char *error_msg);
void linphone_gtk_show_login_frame(LinphoneProxyConfig *cfg);
/*
linphone, gtk-glade interface.
Copyright (C) 2009 Simon MORLAT (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.
*/
#include "linphone.h"
void linphone_gtk_show_login_frame(LinphoneProxyConfig *cfg){
GtkWidget *mw=linphone_gtk_get_main_window();
GtkWidget *label=linphone_gtk_get_widget(mw,"login_label");
gchar *str;
gtk_widget_hide(linphone_gtk_get_widget(mw,"idle_view"));
gtk_widget_show(linphone_gtk_get_widget(mw,"login_frame"));
gtk_widget_set_sensitive(linphone_gtk_get_widget(mw,"main_menu"),FALSE);
gtk_widget_set_sensitive(linphone_gtk_get_widget(mw,"modes"),FALSE);
str=g_strdup_printf(_("Please enter login information for %s"),linphone_proxy_config_get_domain(cfg));
gtk_label_set_text(GTK_LABEL(label),str);
g_free(str);
}
void linphone_gtk_exit_login_frame(void){
GtkWidget *mw=linphone_gtk_get_main_window();
gtk_widget_show(linphone_gtk_get_widget(mw,"idle_view"));
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);
}
enum {
NetworkKindAdsl,
NetworkKindOpticalFiber
};
void linphone_gtk_login_frame_connect_clicked(GtkWidget *button){
GtkWidget *mw=gtk_widget_get_toplevel(button);
const char *username;
const char *password;
int netkind_id;
LinphoneCore *lc=linphone_gtk_get_core();
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")));
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);
}
}
......@@ -963,6 +963,18 @@ static void linphone_gtk_configure_main_window(){
gtk_widget_hide(linphone_gtk_get_widget(w,"run_assistant"));
}
void linphone_gtk_manage_login(void){
LinphoneCore *lc=linphone_gtk_get_core();
LinphoneProxyConfig *cfg=NULL;
linphone_core_get_default_proxy(lc,&cfg);
if (cfg){
SipSetup *ss=linphone_proxy_config_get_sip_setup(cfg);
if (ss && (sip_setup_get_capabilities(ss) & SIP_SETUP_CAP_LOGIN)){
linphone_gtk_show_login_frame(cfg);
}
}
}
static void linphone_gtk_init_main_window(){
linphone_gtk_configure_main_window();
load_uri_history();
......
......@@ -88,7 +88,7 @@
<property name="label" translatable="yes">_Modes</property>
<property name="use_underline">True</property>
<child>
<widget class="GtkMenu" id="menu1">
<widget class="GtkMenu" id="menu_mode">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
......@@ -1118,6 +1118,154 @@ Online users</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="login_frame">
<property name="label_xalign">0</property>
<child>
<widget class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
<widget class="GtkFrame" id="frame5">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<child>
<widget class="GtkAlignment" id="alignment3">
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="n_rows">3</property>
<property name="n_columns">2</property>
<child>
<widget class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="label" translatable="yes">Username</property>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label10">
<property name="visible">True</property>
<property name="label" translatable="yes">Password</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="label" translatable="yes">Internet connection:</property>
</widget>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="login_username">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">&#x25CF;</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="login_password">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="visibility">False</property>
<property name="invisible_char">&#x25CF;</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="login_internet_kind">
<property name="visible">True</property>
<property name="items" translatable="yes">ADSL
Fiber Channel</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="login_label">
<property name="visible">True</property>
<property name="label" translatable="yes">Login information</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkHButtonBox" id="hbuttonbox3">
<property name="visible">True</property>
<child>
<widget class="GtkButton" id="button1">
<property name="label" translatable="yes">gtk-connect</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Welcome !&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
</widget>
<packing>
<property name="position">1</property>
......
/*
linphone, gtk-glade interface.
Copyright (C) 2008 Simon MORLAT (simon.morlat@linphone.org)
Copyright (C) 2008-2009 Simon MORLAT (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
......
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