Commit 0f45206f authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

SIP part redesign almost done

parent 9aa98b7b
/* Generated by dbus-binding-tool; do not edit! */
#include <glib/gtypes.h>
#include <glib/gerror.h>
#include <glib.h>
#include <dbus/dbus-glib.h>
G_BEGIN_DECLS
......@@ -2001,6 +2000,156 @@ org_sflphone_SFLphone_ConfigurationManager_get_sip_port_async (DBusGProxy *proxy
stuff->userdata = userdata;
return dbus_g_proxy_begin_call (proxy, "getSipPort", org_sflphone_SFLphone_ConfigurationManager_get_sip_port_async_callback, stuff, g_free, G_TYPE_INVALID);
}
static
#ifdef G_HAVE_INLINE
inline
#endif
gboolean
org_sflphone_SFLphone_ConfigurationManager_set_stun_server (DBusGProxy *proxy, const char * IN_server, GError **error)
{
return dbus_g_proxy_call (proxy, "setStunServer", error, G_TYPE_STRING, IN_server, G_TYPE_INVALID, G_TYPE_INVALID);
}
typedef void (*org_sflphone_SFLphone_ConfigurationManager_set_stun_server_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
static void
org_sflphone_SFLphone_ConfigurationManager_set_stun_server_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
{
DBusGAsyncData *data = (DBusGAsyncData*) user_data;
GError *error = NULL;
dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
(*(org_sflphone_SFLphone_ConfigurationManager_set_stun_server_reply)data->cb) (proxy, error, data->userdata);
return;
}
static
#ifdef G_HAVE_INLINE
inline
#endif
DBusGProxyCall*
org_sflphone_SFLphone_ConfigurationManager_set_stun_server_async (DBusGProxy *proxy, const char * IN_server, org_sflphone_SFLphone_ConfigurationManager_set_stun_server_reply callback, gpointer userdata)
{
DBusGAsyncData *stuff;
stuff = g_new (DBusGAsyncData, 1);
stuff->cb = G_CALLBACK (callback);
stuff->userdata = userdata;
return dbus_g_proxy_begin_call (proxy, "setStunServer", org_sflphone_SFLphone_ConfigurationManager_set_stun_server_async_callback, stuff, g_free, G_TYPE_STRING, IN_server, G_TYPE_INVALID);
}
static
#ifdef G_HAVE_INLINE
inline
#endif
gboolean
org_sflphone_SFLphone_ConfigurationManager_get_stun_server (DBusGProxy *proxy, char ** OUT_server, GError **error)
{
return dbus_g_proxy_call (proxy, "getStunServer", error, G_TYPE_INVALID, G_TYPE_STRING, OUT_server, G_TYPE_INVALID);
}
typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_stun_server_reply) (DBusGProxy *proxy, char * OUT_server, GError *error, gpointer userdata);
static void
org_sflphone_SFLphone_ConfigurationManager_get_stun_server_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
{
DBusGAsyncData *data = (DBusGAsyncData*) user_data;
GError *error = NULL;
char * OUT_server;
dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_STRING, &OUT_server, G_TYPE_INVALID);
(*(org_sflphone_SFLphone_ConfigurationManager_get_stun_server_reply)data->cb) (proxy, OUT_server, error, data->userdata);
return;
}
static
#ifdef G_HAVE_INLINE
inline
#endif
DBusGProxyCall*
org_sflphone_SFLphone_ConfigurationManager_get_stun_server_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_get_stun_server_reply callback, gpointer userdata)
{
DBusGAsyncData *stuff;
stuff = g_new (DBusGAsyncData, 1);
stuff->cb = G_CALLBACK (callback);
stuff->userdata = userdata;
return dbus_g_proxy_begin_call (proxy, "getStunServer", org_sflphone_SFLphone_ConfigurationManager_get_stun_server_async_callback, stuff, g_free, G_TYPE_INVALID);
}
static
#ifdef G_HAVE_INLINE
inline
#endif
gboolean
org_sflphone_SFLphone_ConfigurationManager_enable_stun (DBusGProxy *proxy, GError **error)
{
return dbus_g_proxy_call (proxy, "enableStun", error, G_TYPE_INVALID, G_TYPE_INVALID);
}
typedef void (*org_sflphone_SFLphone_ConfigurationManager_enable_stun_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
static void
org_sflphone_SFLphone_ConfigurationManager_enable_stun_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
{
DBusGAsyncData *data = (DBusGAsyncData*) user_data;
GError *error = NULL;
dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID);
(*(org_sflphone_SFLphone_ConfigurationManager_enable_stun_reply)data->cb) (proxy, error, data->userdata);
return;
}
static
#ifdef G_HAVE_INLINE
inline
#endif
DBusGProxyCall*
org_sflphone_SFLphone_ConfigurationManager_enable_stun_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_enable_stun_reply callback, gpointer userdata)
{
DBusGAsyncData *stuff;
stuff = g_new (DBusGAsyncData, 1);
stuff->cb = G_CALLBACK (callback);
stuff->userdata = userdata;
return dbus_g_proxy_begin_call (proxy, "enableStun", org_sflphone_SFLphone_ConfigurationManager_enable_stun_async_callback, stuff, g_free, G_TYPE_INVALID);
}
static
#ifdef G_HAVE_INLINE
inline
#endif
gboolean
org_sflphone_SFLphone_ConfigurationManager_is_stun_enabled (DBusGProxy *proxy, gint* OUT_state, GError **error)
{
return dbus_g_proxy_call (proxy, "isStunEnabled", error, G_TYPE_INVALID, G_TYPE_INT, OUT_state, G_TYPE_INVALID);
}
typedef void (*org_sflphone_SFLphone_ConfigurationManager_is_stun_enabled_reply) (DBusGProxy *proxy, gint OUT_state, GError *error, gpointer userdata);
static void
org_sflphone_SFLphone_ConfigurationManager_is_stun_enabled_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
{
DBusGAsyncData *data = (DBusGAsyncData*) user_data;
GError *error = NULL;
gint OUT_state;
dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INT, &OUT_state, G_TYPE_INVALID);
(*(org_sflphone_SFLphone_ConfigurationManager_is_stun_enabled_reply)data->cb) (proxy, OUT_state, error, data->userdata);
return;
}
static
#ifdef G_HAVE_INLINE
inline
#endif
DBusGProxyCall*
org_sflphone_SFLphone_ConfigurationManager_is_stun_enabled_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_is_stun_enabled_reply callback, gpointer userdata)
{
DBusGAsyncData *stuff;
stuff = g_new (DBusGAsyncData, 1);
stuff->cb = G_CALLBACK (callback);
stuff->userdata = userdata;
return dbus_g_proxy_begin_call (proxy, "isStunEnabled", org_sflphone_SFLphone_ConfigurationManager_is_stun_enabled_async_callback, stuff, g_free, G_TYPE_INVALID);
}
#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_sflphone_SFLphone_ConfigurationManager */
G_END_DECLS
......@@ -109,7 +109,7 @@ config_window_fill_account_list()
* Delete an account
*/
static void
delete_account(GtkWidget *widget, gpointer data UNUSED)
delete_account(GtkWidget *widget UNUSED, gpointer data UNUSED)
{
if(selectedAccount)
{
......@@ -449,24 +449,15 @@ create_accounts_tab()
void stun_state( void )
{
guint i, size;
gchar * stun_enabled = "FALSE";
account_t * account;
guint stun_enabled = 0;
gboolean stunActive = (gboolean)gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON( stunEnable ));
gtk_widget_set_sensitive( GTK_WIDGET( stunServer ) , stunActive );
// Check if we actually change the state
size = account_list_get_size();
for(i=0; i<size; i++)
{
account = account_list_get_nth(i);
if( strcmp(g_hash_table_lookup(account->properties, ACCOUNT_TYPE), "SIP" ) == 0 )
{
stun_enabled = g_hash_table_lookup(account->properties, ACCOUNT_SIP_STUN_ENABLED);
break;
}
}
if( (stunActive && strcmp(stun_enabled, "FALSE")==0) || (!stunActive && strcmp(stun_enabled, "TRUE")==0) )
stun_enabled = dbus_stun_is_enabled();
if( (stunActive && stun_enabled ==0 ) || (!stunActive && stun_enabled ==1))
{
gtk_widget_set_sensitive( GTK_WIDGET( applyButton ) , TRUE );
}
......@@ -477,24 +468,8 @@ void stun_state( void )
void update_registration( void )
{
guint nb_accounts, i;
account_t *current;
nb_accounts = account_list_get_size();
for(i=0; i<nb_accounts;i++){
current = account_list_get_nth(i);
// If SIP account, then set the new value
if( strcmp(g_hash_table_lookup(current->properties, ACCOUNT_TYPE), "SIP" ) == 0 )
{
g_hash_table_replace(current->properties, g_strdup(ACCOUNT_SIP_STUN_SERVER),
g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(stunServer))));
g_hash_table_replace(current->properties, g_strdup(ACCOUNT_SIP_STUN_ENABLED),
g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(stunEnable)) ? "TRUE": "FALSE"));
dbus_set_account_details(current);
}
}
dbus_set_stun_server((gchar *)gtk_entry_get_text(GTK_ENTRY(stunServer)));
dbus_enable_stun();
gtk_widget_set_sensitive(GTK_WIDGET( applyButton ) , FALSE );
}
......@@ -505,23 +480,11 @@ GtkWidget* create_stun_tab()
gchar * stun_server= "stun.fwdnet.net:3478";
gchar * stun_enabled = "FALSE";
GtkWidget * label;
account_t * account;
guint i, size;
// All SIP accounts are supposed to have the same STUN configuration
// So let's take the first SIP account we find
size = account_list_get_size();
for(i=0; i<size; i++)
{
account = account_list_get_nth(i);
if( strcmp(g_hash_table_lookup(account->properties, ACCOUNT_TYPE), "SIP" ) == 0 )
{
stun_enabled = g_hash_table_lookup(account->properties, ACCOUNT_SIP_STUN_ENABLED);
stun_server = g_hash_table_lookup(account->properties, ACCOUNT_SIP_STUN_SERVER);
break;
}
}
/* Retrieve the STUN configuration */
stun_enabled = (dbus_stun_is_enabled()==1)?"TRUE":"FALSE";
stun_server = dbus_get_stun_server();
tableNat = gtk_table_new ( 3, 2 , FALSE/* homogeneous */);
// NAT detection code section
......
......@@ -1542,3 +1542,58 @@ dbus_get_sip_port( void )
return (guint)portNum;
}
gchar* dbus_get_stun_server (void)
{
GError* error = NULL;
gchar* server;
org_sflphone_SFLphone_ConfigurationManager_get_stun_server(
configurationManagerProxy,
&server,
&error);
if(error)
{
g_error_free(error);
}
return server;
}
void dbus_set_stun_server( gchar* server)
{
GError* error = NULL;
org_sflphone_SFLphone_ConfigurationManager_set_stun_server(
configurationManagerProxy,
server,
&error);
if(error)
{
g_error_free(error);
}
}
guint dbus_stun_is_enabled (void)
{
GError* error = NULL;
guint stun;
org_sflphone_SFLphone_ConfigurationManager_is_stun_enabled(
configurationManagerProxy,
&stun,
&error);
if(error)
{
g_error_free(error);
}
return stun;
}
void dbus_enable_stun (void)
{
GError* error = NULL;
org_sflphone_SFLphone_ConfigurationManager_enable_stun(
configurationManagerProxy,
&error);
if(error)
{
g_error_free(error);
}
}
......@@ -429,4 +429,10 @@ void dbus_set_sip_port(const guint portNum);
guint dbus_get_sip_port();
gchar* dbus_get_stun_server (void);
void dbus_set_stun_server( gchar* server);
guint dbus_stun_is_enabled (void);
void dbus_enable_stun (void);
#endif
......@@ -25,7 +25,7 @@
Account::Account(const AccountID& accountID, std::string type) :
_accountID(accountID), _link(NULL), _enabled(false), _type(type)
{
setRegistrationState(VoIPLink::Unregistered);
setRegistrationState(Unregistered);
}
Account::~Account()
......@@ -47,3 +47,9 @@ void Account::loadConfig()
#endif
}
void Account::setRegistrationState( RegistrationState state ) {
_registrationState = state;
// Notify the client
Manager::instance().connectionStatusNotification( );
}
......@@ -39,7 +39,7 @@ class VoIPLink;
typedef std::string AccountID;
/** Contains all the state an Voip can be in */
typedef enum RegistrationState {
typedef enum RegistrationState {
Unregistered,
Trying,
Registered,
......@@ -49,7 +49,7 @@ typedef std::string AccountID;
ErrorHost,
ErrorExistStun,
ErrorConfStun
} RegistrationState;
} RegistrationState;
#define AccountNULL ""
......@@ -121,13 +121,9 @@ class Account{
*/
inline RegistrationState getRegistrationState() { return _registrationState; }
inline void setRegistrationState( RegistrationState state ) {
_registrationState = state;
// Notify the client
Manager::instance().connectionStatusNotification( );
}
void setRegistrationState( RegistrationState state );
//TODO inline?
inline std::string getUsername( void ) { return _username; }
inline void setUsername( std::string username) { _username = username; }
......
......@@ -7,7 +7,6 @@ noinst_LTLIBRARIES = libdbus.la
libdbus_la_SOURCES = \
callmanager.cpp \
configurationmanager.cpp \
contactmanager.cpp \
instance.cpp \
dbusmanagerimpl.cpp
......@@ -20,8 +19,6 @@ noinst_HEADERS = \
callmanager.h \
configurationmanager.h \
configurationmanager-glue.h \
contactmanager.h \
contactmanager-glue.h \
instance.h \
instance-glue.h \
dbusmanager.h \
......
......@@ -73,6 +73,10 @@ public:
register_method(ConfigurationManager_adaptor, getPulseAppVolumeControl, _getPulseAppVolumeControl_stub);
register_method(ConfigurationManager_adaptor, setSipPort, _setSipPort_stub);
register_method(ConfigurationManager_adaptor, getSipPort, _getSipPort_stub);
register_method(ConfigurationManager_adaptor, setStunServer, _setStunServer_stub);
register_method(ConfigurationManager_adaptor, getStunServer, _getStunServer_stub);
register_method(ConfigurationManager_adaptor, enableStun, _enableStun_stub);
register_method(ConfigurationManager_adaptor, isStunEnabled, _isStunEnabled_stub);
}
::DBus::IntrospectedInterface *const introspect() const
......@@ -338,6 +342,25 @@ public:
{ "port", "i", false },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument setStunServer_args[] =
{
{ "server", "s", true },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument getStunServer_args[] =
{
{ "server", "s", false },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument enableStun_args[] =
{
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument isStunEnabled_args[] =
{
{ "state", "i", false },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument parametersChanged_args[] =
{
{ "list", "a{ss}", false },
......@@ -407,6 +430,10 @@ public:
{ "getPulseAppVolumeControl", getPulseAppVolumeControl_args },
{ "setSipPort", setSipPort_args },
{ "getSipPort", getSipPort_args },
{ "setStunServer", setStunServer_args },
{ "getStunServer", getStunServer_args },
{ "enableStun", enableStun_args },
{ "isStunEnabled", isStunEnabled_args },
{ 0, 0 }
};
static ::DBus::IntrospectedMethod ConfigurationManager_adaptor_signals[] =
......@@ -494,6 +521,10 @@ public:
virtual int32_t getPulseAppVolumeControl() = 0;
virtual void setSipPort(const int32_t& port) = 0;
virtual int32_t getSipPort() = 0;
virtual void setStunServer(const std::string& server) = 0;
virtual std::string getStunServer() = 0;
virtual void enableStun() = 0;
virtual int32_t isStunEnabled() = 0;
public:
......@@ -1027,6 +1058,43 @@ private:
wi << argout1;
return reply;
}
::DBus::Message _setStunServer_stub(const ::DBus::CallMessage &call)
{
::DBus::MessageIter ri = call.reader();
std::string argin1; ri >> argin1;
setStunServer(argin1);
::DBus::ReturnMessage reply(call);
return reply;
}
::DBus::Message _getStunServer_stub(const ::DBus::CallMessage &call)
{
::DBus::MessageIter ri = call.reader();
std::string argout1 = getStunServer();
::DBus::ReturnMessage reply(call);
::DBus::MessageIter wi = reply.writer();
wi << argout1;
return reply;
}
::DBus::Message _enableStun_stub(const ::DBus::CallMessage &call)
{
::DBus::MessageIter ri = call.reader();
enableStun();
::DBus::ReturnMessage reply(call);
return reply;
}
::DBus::Message _isStunEnabled_stub(const ::DBus::CallMessage &call)
{
::DBus::MessageIter ri = call.reader();
int32_t argout1 = isStunEnabled();
::DBus::ReturnMessage reply(call);
::DBus::MessageIter wi = reply.writer();
wi << argout1;
return reply;
}
};
} } }
......
......@@ -218,6 +218,21 @@
<arg type="i" name="port" direction="out"/>
</method>
<method name="setStunServer">
<arg type="s" name="server" direction="in"/>
</method>
<method name="getStunServer">
<arg type="s" name="server" direction="out"/>
</method>
<method name="enableStun">
</method>
<method name="isStunEnabled">
<arg type="i" name="state" direction="out"/>
</method>
<!-- ///////////////////////////// -->
<signal name="parametersChanged">
<arg type="a{ss}" name="list" direction="out"/>
......
......@@ -395,3 +395,22 @@ ConfigurationManager::setSipPort( const int32_t& portNum )
Manager::instance().setSipPort(portNum);
}
std::string ConfigurationManager::getStunServer( void )
{
return Manager::instance().getStunServer();
}
void ConfigurationManager::setStunServer( const std::string& server )
{
Manager::instance().setStunServer( server );
}
void ConfigurationManager::enableStun (void)
{
Manager::instance().enableStun();
}
int32_t ConfigurationManager::isStunEnabled (void)
{
return Manager::instance().isStunEnabled();
}
......@@ -96,7 +96,11 @@ public:
int32_t getPulseAppVolumeControl( void );
void setPulseAppVolumeControl( void );
int32_t getSipPort( void );
void setSipPort( const int32_t& portNum );
void setSipPort( const int32_t& portNum);
std::string getStunServer( void );
void setStunServer( const std::string& server );
void enableStun (void);
int32_t isStunEnabled (void);
};
......
......@@ -26,6 +26,9 @@
#include <stdio.h>
#include <libintl.h>
#include <locale.h>
#include <string>
#include <stdlib.h>
#include <sstream>
#define SFLPHONED_VERSION "0.9.2-4" /** Version number */
......@@ -98,6 +101,7 @@ typedef short int16;
#define WINDOW_POPUP 1 /** Popup mode */
#define NOTIFY_ALL 1 /** Desktop notification level 0: never notify */
#define NOTIFY_MAILS 1 /** Desktop mail notification level 0: never notify */
#define STUN_ENABLED 1
// Error codes for error handling
#define NO_ERROR 0x0000 /** No error - Everything alright */
......
......@@ -49,7 +49,7 @@ int IAXAccount::registerVoIPLink()
thislink->setPass(Manager::instance().getConfigString(_accountID, PASSWORD));
}
_link->sendRegister();
_link->sendRegister( _accountID );
return SUCCESS;
}
......@@ -57,7 +57,7 @@ int IAXAccount::registerVoIPLink()
int
IAXAccount::unregisterVoIPLink()
{
_link->sendUnregister();
_link->sendUnregister( _accountID );
_link->terminate();
return SUCCESS;
......
......@@ -21,6 +21,7 @@
#include "global.h" // for _debug
#include "iaxcall.h"
#include "eventthread.h"
#include "iaxaccount.h"
#include "manager.h"
#include "audio/audiolayer.h"
......@@ -207,7 +208,7 @@ IAXVoIPLink::getEvent()