Commit e130b4b1 authored by Emmanuel Milou's avatar Emmanuel Milou

Register/Unregister accounts from the confgi window

Still can't unregister!!
parent f0b42760
......@@ -122,6 +122,7 @@ show_account_window (account_t * a)
{
curAccountID = a->accountID;
curAccountType = g_hash_table_lookup(currentAccount->properties, ACCOUNT_TYPE);
g_print("account window = %s\n" , g_hash_table_lookup(currentAccount->properties, ACCOUNT_ENABLED));
curAccountEnabled = g_hash_table_lookup(currentAccount->properties, ACCOUNT_ENABLED);
if (strcmp(curAccountType, "IAX") == 0) {
......@@ -150,7 +151,7 @@ show_account_window (account_t * a)
dialog = GTK_DIALOG(gtk_dialog_new_with_buttons (_("Account settings"),
GTK_WINDOW(get_main_window()),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_SAVE,
GTK_STOCK_APPLY,
GTK_RESPONSE_ACCEPT,
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL,
......@@ -176,8 +177,9 @@ show_account_window (account_t * a)
entryEnabled = gtk_check_button_new_with_mnemonic(_("_Enabled"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(entryEnabled),
strcmp(curAccountEnabled,"TRUE") == 0 ? TRUE: FALSE);
g_strcasecmp(curAccountEnabled,"TRUE") == 0 ? TRUE: FALSE);
gtk_table_attach ( GTK_TABLE( table ), entryEnabled, 0, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_widget_set_sensitive( GTK_WIDGET( entryEnabled ) , TRUE );
//entryRegister = gtk_check_button_new_with_mnemonic("_Register on startup ");
//gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(entryRegister),
......@@ -311,8 +313,8 @@ show_account_window (account_t * a)
gchar* proto = (gchar *)gtk_combo_box_get_active_text(GTK_COMBO_BOX(entryProtocol));
g_hash_table_replace(currentAccount->properties,
g_strdup(ACCOUNT_ENABLED),
g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(entryEnabled)) ? "TRUE": "FALSE"));
g_strdup(ACCOUNT_ENABLED),
g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(entryEnabled)) ? "TRUE": "FALSE"));
// g_hash_table_replace(currentAccount->properties,
// g_strdup(ACCOUNT_REGISTER),
// g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(entryRegister)) ? "TRUE": "FALSE"));
......
......@@ -76,7 +76,6 @@ enum {
void
config_window_fill_account_list()
{
gchar* stock_id;
if(dialogOpen)
{
GtkTreeIter iter;
......@@ -88,12 +87,13 @@ config_window_fill_account_list()
account_t * a = account_list_get_nth (i);
if (a)
{
g_print("fill account list : %s\n" , g_hash_table_lookup(a->properties, ACCOUNT_ENABLED));
gtk_list_store_append (accountStore, &iter);
gtk_list_store_set(accountStore, &iter,
0, g_hash_table_lookup(a->properties, ACCOUNT_ALIAS), // Name
1, g_hash_table_lookup(a->properties, ACCOUNT_TYPE), // Protocol
2, account_state_name(a->state), // Status
3, g_hash_table_lookup(a->properties, ACCOUNT_ENABLED), // Enable/Disable
3, (g_strcasecmp(g_hash_table_lookup(a->properties, ACCOUNT_ENABLED),"TRUE") == 0)? TRUE:FALSE, // Enable/Disable
4, a, // Pointer
-1);
}
......@@ -107,7 +107,7 @@ config_window_fill_account_list()
/**
* Fills the tree list with supported codecs
*/
*/
void
config_window_fill_codec_list()
{
......@@ -647,7 +647,6 @@ enable_account(GtkCellRendererToggle *rend , gchar* path, gpointer data )
3, &enable,
4, &acc,
-1);
enable = !enable;
// Store value
......@@ -658,15 +657,13 @@ enable_account(GtkCellRendererToggle *rend , gchar* path, gpointer data )
gtk_tree_path_free(treePath);
// Modify account state
g_print("ENABLE = %s - %i\n" , g_hash_table_lookup( acc->properties , g_strdup(ACCOUNT_ENABLED)) , enable);
g_hash_table_replace( acc->properties , g_strdup(ACCOUNT_ENABLED) , g_strdup(g_hash_table_lookup(acc->properties, ACCOUNT_ENABLED)? "FALSE" : "TRUE"));
g_print("ENABLE = %s - %i\n" , g_hash_table_lookup( acc->properties , g_strdup(ACCOUNT_ENABLED)) , enable);
g_hash_table_replace( acc->properties , g_strdup(ACCOUNT_ENABLED) , g_strdup((enable == 1)? "TRUE":"FALSE"));
dbus_set_account_details(acc);
}
/**
* Move codec in list depending on direction and selected codec and
* update changes in the deamon list and the configuration files
* update changes in the daemon list and the configuration files
*/
static void
codec_move(gboolean moveUp, gpointer data)
......
......@@ -440,6 +440,7 @@ ManagerImpl::initRegisterAccounts()
if ( iter->second) {
iter->second->loadConfig();
if ( iter->second->isEnabled() ) {
_debug("Init register accounts\n" );
// NOW
iter->second->registerVoIPLink();
iter->second->loadContacts();
......@@ -798,6 +799,7 @@ ManagerImpl::registrationSucceed(const AccountID& accountid)
Account* acc = getAccount(accountid);
if ( acc ) {
//acc->setState(true);
_debug("REGISTRATION SUCCEED\n");
if (_dbus) _dbus->getConfigurationManager()->accountsChanged();
}
}
......@@ -809,6 +811,7 @@ ManagerImpl::registrationFailed(const AccountID& accountid)
Account* acc = getAccount(accountid);
if ( acc ) {
//acc->setState(false);
_debug("REGISTRATION FAILED\n");
if (_dbus) _dbus->getConfigurationManager()->accountsChanged();
}
}
......@@ -1936,6 +1939,7 @@ ManagerImpl::getAccountDetails(const AccountID& accountID)
getConfigString(accountID, CONFIG_ACCOUNT_AUTO_REGISTER)== "1" ? "TRUE": "FALSE"
)
);*/
_debug("Get account details: %s\n" , getConfigString(accountID, CONFIG_ACCOUNT_ENABLE).c_str());
a.insert(
std::pair<std::string, std::string>(
CONFIG_ACCOUNT_ENABLE,
......@@ -2045,6 +2049,7 @@ ManagerImpl::getAccountDetails(const AccountID& accountID)
ManagerImpl::setAccountDetails( const ::DBus::String& accountID,
const std::map< ::DBus::String, ::DBus::String >& details )
{
std::string accountType = (*details.find(CONFIG_ACCOUNT_TYPE)).second;
setConfig(accountID, CONFIG_ACCOUNT_ALIAS, (*details.find(CONFIG_ACCOUNT_ALIAS)).second);
......@@ -2085,13 +2090,17 @@ ManagerImpl::setAccountDetails( const ::DBus::String& accountID,
acc->loadConfig();
if (acc->isEnabled()) {
// Verify we aren't already registered, then register
if (acc->getRegistrationState() == VoIPLink::Unregistered) {
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);
}
}
......@@ -2127,6 +2136,7 @@ ManagerImpl::addAccount(const std::map< ::DBus::String, ::DBus::String >& detail
saveConfig();
_debug("ADD ACCOUNT\n");
if (_dbus) _dbus->getConfigurationManager()->accountsChanged();
}
......@@ -2146,6 +2156,7 @@ ManagerImpl::removeAccount(const AccountID& accountID)
saveConfig();
_debug("REMOVE ACCOUNT\n");
if (_dbus) _dbus->getConfigurationManager()->accountsChanged();
}
......
......@@ -53,7 +53,6 @@ SIPAccount::registerVoIPLink()
thislink->setUserPart(Manager::instance().getConfigString(_accountID,SIP_USER_PART));
thislink->setAuthName(Manager::instance().getConfigString(_accountID,SIP_AUTH_NAME));
thislink->setPassword(Manager::instance().getConfigString(_accountID,SIP_PASSWORD));
_debug("sipaccount --> sendRegister\n");
_link->sendRegister();
}
......
......@@ -212,6 +212,7 @@ SIPVoIPLink::loadSIPLocalIP()
void
SIPVoIPLink::getEvent()
{
osip_message_t *req;
char* tmp2;
eXosip_event_t* event = eXosip_event_wait(0, 50);
eXosip_lock();
......@@ -230,8 +231,12 @@ SIPVoIPLink::getEvent()
_debugMid(" !EXOSIP_REGISTRATION_NEW event is not implemented\n");
break;
case EXOSIP_REGISTRATION_SUCCESS: /** 01 < user is successfully registred. */
setRegistrationState(Registered);
_debugMid(" !EXOSIP_REGISTRATION_SUCCES\n");
_debugMid(" !EXOSIP_REGISTRATION_SUCCESS : %i\n", getRegistrationState());
//if(getRegistrationState() == Registered){
//setRegistrationState(Unregistered);
//}
//else
setRegistrationState(Registered);
//Manager::instance().registrationSucceed(getAccountID());
break;
case EXOSIP_REGISTRATION_FAILURE: /** 02 < user is not registred. */
......@@ -442,6 +447,8 @@ SIPVoIPLink::getEvent()
bool
SIPVoIPLink::sendRegister()
{
_debug("SEND REGISTER \n");
if (_eXosipRegID != EXOSIP_ERROR_STD) {
Manager::instance().displayError("! SIP Error: Registration already sent. Try to unregister");
return false;
......@@ -539,6 +546,7 @@ SIPVoIPLink::sendSIPAuthentification()
bool
SIPVoIPLink::sendUnregister()
{
_debug("SEND UNREGISTER\n");
if ( _eXosipRegID == EXOSIP_ERROR_STD) return false;
int eXosipErr = EXOSIP_ERROR_NO;
osip_message_t *reg = NULL;
......@@ -552,6 +560,8 @@ SIPVoIPLink::sendUnregister()
return false;
}
_debug("osip_message_t = %s\n" , reg);
eXosip_lock();
_debug("< Sending REGISTER (expire=0)\n");
eXosipErr = eXosip_register_send_register (_eXosipRegID, reg);
......
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