Commit 4a1abced authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Merge branch 'plug-in' of ssh://manu@192.168.1.105/~/dev/sflphone into plugins

Conflicts:

	configure.ac
	src/plug-in/pluginmanager.cpp
	src/plug-in/pluginmanager.h
	test/pluginmanagerTest.cpp
parents 88c73791 f6d2fbf1
......@@ -39,7 +39,8 @@ AC_CONFIG_FILES([src/Makefile \
src/dbus/Makefile \
src/zeroconf/Makefile \
src/plug-in/audiorecorder/Makefile \
src/plug-in/Makefile])
src/plug-in/Makefile \
src/plug-in/test/Makefile])
dnl Unitary test section
AC_CONFIG_FILES([test/Makefile])
......
/* 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
......@@ -39,8 +39,7 @@ sflphoned_SOURCES = \
call.cpp \
account.cpp \
sipcall.cpp \
$(IAXSOURCES) \
useragent.cpp
$(IAXSOURCES)
sflphoned_CXXFLAGS = \
-DPREFIX=\"$(prefix)\" -DPROGSHAREDIR=\"${datadir}/sflphone\" \
......@@ -60,7 +59,6 @@ sflphoned_LDADD = \
@CCRTP_LIBS@ \
@ALSA_LIBS@ \
@PULSEAUDIO_LIBS@ \
-luuid \
@SAMPLERATE_LIBS@
#sflphoned_LDFLAGS=-pg
......@@ -81,8 +79,7 @@ noinst_HEADERS = \
accountcreator.h \
sipvoiplink.h \
call.h \
sipcall.h \
useragent.h
sipcall.h
libsflphone_la_LIBADD = \
$(src)/libs/stund/libstun.la \
......
......@@ -22,9 +22,10 @@
#include "account.h"
#include "manager.h"
Account::Account(const AccountID& accountID) :
_accountID(accountID), _link(NULL), _enabled(false)
Account::Account(const AccountID& accountID, std::string type) :
_accountID(accountID), _link(NULL), _enabled(false), _type(type)
{
setRegistrationState(Unregistered);
}
Account::~Account()
......@@ -46,3 +47,9 @@ void Account::loadConfig()
#endif
}
void Account::setRegistrationState( RegistrationState state ) {
_registrationState = state;
// Notify the client
Manager::instance().connectionStatusNotification( );
}
......@@ -38,6 +38,19 @@ class VoIPLink;
typedef std::string AccountID;
/** Contains all the state an Voip can be in */
typedef enum RegistrationState {
Unregistered,
Trying,
Registered,
Error,
ErrorAuth ,
ErrorNetwork ,
ErrorHost,
ErrorExistStun,
ErrorConfStun
} RegistrationState;
#define AccountNULL ""
// Common account parameters
......@@ -59,7 +72,7 @@ class Account{
public:
Account(const AccountID& accountID);
Account(const AccountID& accountID, std::string type);
/**
* Virtual destructor
......@@ -106,10 +119,27 @@ class Account{
* Get the registration state of the specified link
* @return RegistrationState The registration state of underlying VoIPLink
*/
VoIPLink::RegistrationState getRegistrationState() { return _link->getRegistrationState(); }
inline RegistrationState getRegistrationState() { return _registrationState; }
private:
void setRegistrationState( RegistrationState state );
//TODO inline?
inline std::string getUsername( void ) { return _username; }
inline void setUsername( std::string username) { _username = username; }
inline std::string getHostname( void ) { return _hostname; }
inline void setHostname( std::string hostname) { _hostname = hostname; }
inline std::string getPassword( void ) { return _password; }
inline void setPassword( std::string password ) { _password = password; }
inline std::string getAlias( void ) { return _alias; }
inline void setAlias( std::string alias ) { _alias = alias; }
inline std::string getType( void ) { return _type; }
inline void setType( std::string type ) { _type = type; }
private:
// copy constructor
Account(const Account& rh);
......@@ -122,6 +152,32 @@ class Account{
*/
AccountID _accountID;
/**
* Account login information: username
*/
std::string _username;
/**
* Account login information: hostname
*/
std::string _hostname;
/**
* Account login information: password
*/
std::string _password;
/**
* Account login information: Alias
*/
std::string _alias;
/*
* The account type
* IAX2 or SIP
*/
std::string _type;
/**
* Voice over IP Link contains a listener thread and calls
*/
......@@ -134,6 +190,11 @@ class Account{
*/
bool _enabled;
/*
* The registration state of the account
*/
RegistrationState _registrationState;
};
#endif
......@@ -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;
}
};
} }