Commit 320ba789 authored by Emmanuel Milou's avatar Emmanuel Milou

Register/Unregister - Daemon notifies the client AFTER the SIP server response

parent 2aa75780
......@@ -276,6 +276,43 @@ static
inline
#endif
gboolean
org_sflphone_SFLphone_ConfigurationManager_send_register (DBusGProxy *proxy, const char * IN_accountID, const gint IN_expire, GError **error)
{
return dbus_g_proxy_call (proxy, "sendRegister", error, G_TYPE_STRING, IN_accountID, G_TYPE_INT, IN_expire, G_TYPE_INVALID, G_TYPE_INVALID);
}
typedef void (*org_sflphone_SFLphone_ConfigurationManager_send_register_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
static void
org_sflphone_SFLphone_ConfigurationManager_send_register_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_send_register_reply)data->cb) (proxy, error, data->userdata);
return;
}
static
#ifdef G_HAVE_INLINE
inline
#endif
DBusGProxyCall*
org_sflphone_SFLphone_ConfigurationManager_send_register_async (DBusGProxy *proxy, const char * IN_accountID, const gint IN_expire, org_sflphone_SFLphone_ConfigurationManager_send_register_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, "sendRegister", org_sflphone_SFLphone_ConfigurationManager_send_register_async_callback, stuff, g_free, G_TYPE_STRING, IN_accountID, G_TYPE_INT, IN_expire, G_TYPE_INVALID);
}
static
#ifdef G_HAVE_INLINE
inline
#endif
gboolean
org_sflphone_SFLphone_ConfigurationManager_get_tone_locale_list (DBusGProxy *proxy, char *** OUT_list, GError **error)
{
......
......@@ -113,7 +113,6 @@ config_window_fill_account_list()
gtk_widget_set_sensitive( GTK_WIDGET(editButton), FALSE);
gtk_widget_set_sensitive( GTK_WIDGET(deleteButton), FALSE);
//gtk_widget_set_sensitive( GTK_WIDGET(defaultButton), FALSE);
}
}
......@@ -557,7 +556,6 @@ select_account(GtkTreeSelection *selection, GtkTreeModel *model)
{
gtk_widget_set_sensitive(GTK_WIDGET(editButton), TRUE);
gtk_widget_set_sensitive(GTK_WIDGET(deleteButton), TRUE);
//gtk_widget_set_sensitive(GTK_WIDGET(defaultButton), TRUE);
gtk_widget_set_sensitive(GTK_WIDGET(accountMoveUpButton), TRUE);
gtk_widget_set_sensitive(GTK_WIDGET(accountMoveDownButton), TRUE);
}
......@@ -660,7 +658,8 @@ enable_account(GtkCellRendererToggle *rend , gchar* path, gpointer data )
// Modify account state
g_hash_table_replace( acc->properties , g_strdup(ACCOUNT_ENABLED) , g_strdup((enable == 1)? "TRUE":"FALSE"));
dbus_set_account_details(acc);
//dbus_set_account_details(acc);
dbus_send_register( acc->accountID , enable );
}
/**
......
......@@ -272,6 +272,7 @@ dbus_clean ()
g_object_unref (configurationManagerProxy);
}
void
dbus_hold (const call_t * c)
{
......@@ -456,6 +457,23 @@ dbus_account_details(gchar * accountID)
return details;
}
void
dbus_send_register ( gchar* accountID , int expire)
{
GError *error = NULL;
org_sflphone_SFLphone_ConfigurationManager_send_register ( configurationManagerProxy, accountID, expire ,&error);
if (error)
{
g_printerr ("Failed to call send_register() on ConfigurationManager: %s\n",
error->message);
g_error_free (error);
}
else
{
g_print ("DBus called send_register() on ConfigurationManager\n");
}
}
gchar *
dbus_get_default_account( )
{
......
......@@ -48,6 +48,7 @@ void dbus_place_call (const call_t * c);
gchar ** dbus_account_list();
GHashTable * dbus_account_details(gchar * accountID);
void dbus_set_account_details(account_t *a);
void dbus_send_register( gchar* accountID , int expire );
void dbus_add_account(account_t *a);
void dbus_remove_account(gchar * accountID);
void dbus_set_volume(const gchar * device, gdouble value);
......
......@@ -27,6 +27,7 @@ public:
register_method(ConfigurationManager, getAccountList, _getAccountList_stub);
register_method(ConfigurationManager, getDefaultAccount, _getDefaultAccount_stub);
register_method(ConfigurationManager, setDefaultAccount, _setDefaultAccount_stub);
register_method(ConfigurationManager, sendRegister, _sendRegister_stub);
register_method(ConfigurationManager, getToneLocaleList, _getToneLocaleList_stub);
register_method(ConfigurationManager, getVersion, _getVersion_stub);
register_method(ConfigurationManager, getRingtoneList, _getRingtoneList_stub);
......@@ -99,6 +100,12 @@ public:
{ "accountID", "s", true },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument sendRegister_args[] =
{
{ "accountID", "s", true },
{ "expire", "i", true },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument getToneLocaleList_args[] =
{
{ "list", "as", false },
......@@ -275,6 +282,7 @@ public:
{ "getAccountList", getAccountList_args },
{ "getDefaultAccount", getDefaultAccount_args },
{ "setDefaultAccount", setDefaultAccount_args },
{ "sendRegister", sendRegister_args },
{ "getToneLocaleList", getToneLocaleList_args },
{ "getVersion", getVersion_args },
{ "getRingtoneList", getRingtoneList_args },
......@@ -347,6 +355,7 @@ public:
virtual std::vector< ::DBus::String > getAccountList( ) = 0;
virtual ::DBus::String getDefaultAccount( ) = 0;
virtual void setDefaultAccount( const ::DBus::String& accountID ) = 0;
virtual void sendRegister( const ::DBus::String& accountID, const ::DBus::Int32& expire ) = 0;
virtual std::vector< ::DBus::String > getToneLocaleList( ) = 0;
virtual ::DBus::String getVersion( ) = 0;
virtual std::vector< ::DBus::String > getRingtoneList( ) = 0;
......@@ -475,6 +484,16 @@ private:
::DBus::ReturnMessage reply(call);
return reply;
}
::DBus::Message _sendRegister_stub( const ::DBus::CallMessage& call )
{
::DBus::MessageIter ri = call.reader();
::DBus::String argin1; ri >> argin1;
::DBus::Int32 argin2; ri >> argin2;
sendRegister(argin1, argin2);
::DBus::ReturnMessage reply(call);
return reply;
}
::DBus::Message _getToneLocaleList_stub( const ::DBus::CallMessage& call )
{
::DBus::MessageIter ri = call.reader();
......
......@@ -33,6 +33,11 @@
<arg type="s" name="accountID" direction="in"/>
</method>
<method name="sendRegister">
<arg type="s" name="accountID" direction="in"/>
<arg type="i" name="expire" direction="in"/>
</method>
<!-- /////////////////////// -->
<!-- Various audio-related methods -->
......
......@@ -48,6 +48,12 @@ ConfigurationManager::setAccountDetails( const ::DBus::String& accountID,
Manager::instance().setAccountDetails(accountID, details);
}
void
ConfigurationManager::sendRegister( const ::DBus::String& accountID, const ::DBus::Int32& expire )
{
Manager::instance().sendRegister(accountID, expire);
}
void
ConfigurationManager::addAccount( const std::map< ::DBus::String, ::DBus::String >& details )
{
......
......@@ -46,6 +46,7 @@ public:
std::vector< ::DBus::String > getAccountList( );
::DBus::String getDefaultAccount( );
void setDefaultAccount( const ::DBus::String& accountID );
void sendRegister( const ::DBus::String& accoundID , const ::DBus::Int32& expire );
std::vector< ::DBus::String > getCodecList( );
std::vector< ::DBus::String > getCodecDetails( const ::DBus::Int32& payload );
......
......@@ -804,6 +804,18 @@ ManagerImpl::registrationSucceed(const AccountID& accountid)
}
}
//THREAD=VoIP
void
ManagerImpl::unregistrationSucceed(const AccountID& accountid)
{
Account* acc = getAccount(accountid);
if ( acc ) {
//acc->setState(true);
_debug("UNREGISTRATION SUCCEED\n");
if (_dbus) _dbus->getConfigurationManager()->accountsChanged();
}
}
//THREAD=VoIP
void
ManagerImpl::registrationFailed(const AccountID& accountid)
......@@ -2080,13 +2092,39 @@ ManagerImpl::setAccountDetails( const ::DBus::String& accountID,
}
saveConfig();
/*
* register if it was just enabled, and we hadn't registered
* unregister if it was enabled/registered, and we want it closed
*/
Account* acc = getAccount(accountID);
acc->loadConfig();
if (acc->isEnabled()) {
// Verify we aren't already registered, then register
if (acc->getRegistrationState() != VoIPLink::Registered) {
_debug("SET ACCOUNTS DETAILS - non registered - > registered\n");
acc->registerVoIPLink();
}
} else {
// Verify we are already registered, then unregister
if (acc->getRegistrationState() == VoIPLink::Registered) {
_debug("SET ACCOUNTS DETAILS - registered - > non registered\n");
acc->unregisterVoIPLink();
//unregisterAccount(accountID);
}
}
// Update account details
if (_dbus) _dbus->getConfigurationManager()->accountsChanged();
}
/*
* register if it was just enabled, and we hadn't registered
* unregister if it was enabled/registered, and we want it closed
* unregister <=> expire = 0 ( FALSE )
* register <=> expire = 1 ( TRUE )
*/
void
ManagerImpl::sendRegister( const ::DBus::String& accountID , bool expire )
{
// Update the active field
setConfig( accountID, CONFIG_ACCOUNT_ENABLE, expire );
Account* acc = getAccount(accountID);
acc->loadConfig();
if (acc->isEnabled()) {
// Verify we aren't already registered, then register
......@@ -2100,12 +2138,8 @@ ManagerImpl::setAccountDetails( const ::DBus::String& accountID,
_debug("SET ACCOUNTS DETAILS - registered - > non registered\n");
acc->unregisterVoIPLink();
//unregisterAccount(accountID);
}
}
/** @todo Make the daemon use the new settings */
if (_dbus) _dbus->getConfigurationManager()->accountsChanged();
}
......
......@@ -204,9 +204,11 @@ public:
/** Notify the user that registration succeeded */
void registrationSucceed(const AccountID& accountId);
/** Notify the user that registration succeeded */
/** Notify the user that unregistration succeeded */
void unregistrationSucceed(const AccountID& accountId);
/** Notify the user that registration failed */
void registrationFailed(const AccountID& accountId);
void sendRegister( const AccountID& accountId , bool expire );
// configuration function requests
/**
......
......@@ -231,11 +231,14 @@ SIPVoIPLink::getEvent()
break;
case EXOSIP_REGISTRATION_SUCCESS: /** 01 < user is successfully registred. */
_debugMid(" !EXOSIP_REGISTRATION_SUCCESS \n");
if(_eXosipRegID == EXOSIP_ERROR_STD)
if(_eXosipRegID == EXOSIP_ERROR_STD){
setRegistrationState(Unregistered);
else
Manager::instance().unregistrationSucceed(getAccountID());
}
else{
setRegistrationState(Registered);
//Manager::instance().registrationSucceed(getAccountID());
Manager::instance().registrationSucceed(getAccountID());
}
break;
case EXOSIP_REGISTRATION_FAILURE: /** 02 < user is not registred. */
setRegistrationState(Error, "SIP registration failure.");
......
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