Commit 047b3f4c authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

Merge branch 'debug_threads'

parents 7fbc7001 5cf03fa3
/* 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
......
......@@ -39,6 +39,7 @@ DBusGConnection * connection;
DBusGProxy * callManagerProxy;
DBusGProxy * configurationManagerProxy;
DBusGProxy * instanceProxy;
DBusGProxy * nameOwnerProxy;
static void
incoming_call_cb (DBusGProxy *proxy UNUSED,
......@@ -172,18 +173,32 @@ error_alert(DBusGProxy *proxy UNUSED,
sflphone_throw_exception( errCode );
}
static void nameOwnerChanged(DBusGProxy *proxy, char *name, char *old_owner, char *new_owner, gpointer data )
{
g_print("******************************************************************\n");
g_print("Owner name of the service %s changed from %s to %s\n", name, old_owner, new_owner);
g_print("******************************************************************\n");
if (strcmp(name, "org.sflphone.SFLphone")!=0) return;
}
gboolean
dbus_connect ()
{
GError *error = NULL;
connection = NULL;
instanceProxy = NULL;
nameOwnerProxy = NULL;
g_type_init ();
connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (connection == NULL)
if (error)
{
g_printerr ("Failed to open connection to bus: %s\n",
error->message);
......@@ -191,13 +206,32 @@ dbus_connect ()
return FALSE;
}
nameOwnerProxy = dbus_g_proxy_new_for_name( connection,
DBUS_SERVICE_DBUS,
DBUS_PATH_DBUS,
DBUS_INTERFACE_DBUS);
if( nameOwnerProxy==NULL)
{
g_printerr ("Failed to get proxy to NameOwner\n");
return FALSE;
}
dbus_g_proxy_add_signal( nameOwnerProxy, "NameOwnerChanged",
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID);
dbus_g_proxy_connect_signal (nameOwnerProxy, "NameOwnerChanged",
G_CALLBACK (nameOwnerChanged), NULL, NULL);
/* Create a proxy object for the "bus driver" (name "org.freedesktop.DBus") */
instanceProxy = dbus_g_proxy_new_for_name (connection,
"org.sflphone.SFLphone",
"/org/sflphone/SFLphone/Instance",
"org.sflphone.SFLphone.Instance");
if (!instanceProxy)
if (instanceProxy==NULL)
{
g_printerr ("Failed to get proxy to Instance\n");
return FALSE;
......@@ -210,7 +244,8 @@ dbus_connect ()
"org.sflphone.SFLphone",
"/org/sflphone/SFLphone/CallManager",
"org.sflphone.SFLphone.CallManager");
if (!callManagerProxy)
if (callManagerProxy==NULL)
{
g_printerr ("Failed to get proxy to CallManagers\n");
return FALSE;
......@@ -256,6 +291,7 @@ dbus_connect ()
"org.sflphone.SFLphone",
"/org/sflphone/SFLphone/ConfigurationManager",
"org.sflphone.SFLphone.ConfigurationManager");
if (!configurationManagerProxy)
{
g_printerr ("Failed to get proxy to ConfigurationManager\n");
......@@ -1505,3 +1541,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\" \
......@@ -62,6 +61,8 @@ sflphoned_LDADD = \
@PULSEAUDIO_LIBS@ \
@SAMPLERATE_LIBS@
#sflphoned_LDFLAGS=-pg
noinst_LTLIBRARIES = libsflphone.la
noinst_HEADERS = \
......@@ -78,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,28 @@ 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 );
/* inline functions */
/* They should be treated like macro definitions by the C++ compiler */
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 +153,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 +191,11 @@ class Account{
*/
bool _enabled;
/*
* The registration state of the account
*/
RegistrationState _registrationState;
};
#endif
......@@ -30,6 +30,7 @@ libaudio_la_SOURCES = \
dtmf.cpp \
tone.cpp \
alsalayer.cpp \
audiolayer.cpp \
pulselayer.cpp \
audiodevice.cpp \
dtmfgenerator.cpp \
......
This diff is collapsed.
......@@ -21,8 +21,8 @@
#define _ALSA_LAYER_H
#include "audiolayer.h"
#include <pthread.h>
#include "eventthread.h"
#include <alsa/asoundlib.h>
class RingBuffer;
class ManagerImpl;
......@@ -48,8 +48,6 @@ class AlsaLayer : public AudioLayer {
*/
~AlsaLayer(void);
void trigger_thread(void);
void closeLayer( void );
/**
......@@ -81,52 +79,6 @@ class AlsaLayer : public AudioLayer {
*/
void stopStream(void);
/**
* Check if the playback is running
* @return true if the state of the playback handle equals SND_PCM_STATE_RUNNING
* false otherwise
*/
bool isPlaybackActive( void );
/**