Commit dc48ac69 authored by Yun Liu's avatar Yun Liu
Browse files

Remove the old port position and change it into preference settings

parent 08a9e830
......@@ -44,7 +44,6 @@ GtkWidget * entryProtocol;
GtkWidget * entryEnabled;
GtkWidget * entryUsername;
GtkWidget * entryHostname;
GtkWidget * entryPort;
GtkWidget * entryPassword;
GtkWidget * stunServer;
GtkWidget * stunEnable;
......@@ -61,12 +60,10 @@ change_protocol (account_t * currentAccount UNUSED)
if (strcmp(proto, "SIP") == 0) {
gtk_widget_set_sensitive( GTK_WIDGET(stunEnable), TRUE);
gtk_widget_set_sensitive( GTK_WIDGET(stunServer), TRUE);
gtk_widget_set_sensitive( GTK_WIDGET(entryPort), TRUE);
}
else if (strcmp(proto, "IAX") == 0) {
gtk_widget_set_sensitive( GTK_WIDGET(stunEnable), FALSE);
gtk_widget_set_sensitive( GTK_WIDGET(stunServer), FALSE);
gtk_widget_set_sensitive( GTK_WIDGET(entryPort), FALSE);
}
else {
// Should not get here.
......@@ -107,7 +104,6 @@ show_account_window (account_t * a)
gchar * curAlias = "";
gchar * curUsername = "";
gchar * curHostname = "";
gchar * curPort = "5060";
gchar * curPassword = "";
/* TODO: add curProxy, and add boxes for Proxy support */
gchar * stun_enabled = "FALSE";
......@@ -130,7 +126,6 @@ show_account_window (account_t * a)
}
else if (strcmp(curAccountType, "SIP") == 0) {
curHostname = g_hash_table_lookup(currentAccount->properties, ACCOUNT_SIP_HOST);
curPort = g_hash_table_lookup(currentAccount->properties, ACCOUNT_SIP_PORT);
curPassword = g_hash_table_lookup(currentAccount->properties, ACCOUNT_SIP_PASSWORD);
curUsername = g_hash_table_lookup(currentAccount->properties, ACCOUNT_SIP_USER);
stun_enabled = g_hash_table_lookup(currentAccount->properties, ACCOUNT_SIP_STUN_ENABLED);
......@@ -161,7 +156,7 @@ show_account_window (account_t * a)
gtk_box_pack_start(GTK_BOX(dialog->vbox), frame, FALSE, FALSE, 0);
gtk_widget_show(frame);
table = gtk_table_new ( 9, 2 , FALSE/* homogeneous */);
table = gtk_table_new ( 8, 2 , FALSE/* homogeneous */);
gtk_table_set_row_spacings( GTK_TABLE(table), 10);
gtk_table_set_col_spacings( GTK_TABLE(table), 10);
gtk_widget_show(table);
......@@ -229,16 +224,8 @@ show_account_window (account_t * a)
gtk_entry_set_text(GTK_ENTRY(entryHostname), curHostname);
gtk_table_attach ( GTK_TABLE( table ), entryHostname, 1, 2, 5, 6, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
label = gtk_label_new_with_mnemonic (_("_Port"));
gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 6, 7, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
entryPort = gtk_entry_new();
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryPort);
gtk_entry_set_text(GTK_ENTRY(entryPort), curPort);
gtk_table_attach ( GTK_TABLE( table ), entryPort, 1, 2, 6, 7, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
label = gtk_label_new_with_mnemonic (_("_User name"));
gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 7, 8, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 6, 7, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
entryUsername = sexy_icon_entry_new();
//image = gtk_image_new_from_stock( GTK_STOCK_DIALOG_AUTHENTICATION , GTK_ICON_SIZE_SMALL_TOOLBAR );
......@@ -246,10 +233,10 @@ show_account_window (account_t * a)
sexy_icon_entry_set_icon( SEXY_ICON_ENTRY(entryUsername), SEXY_ICON_ENTRY_PRIMARY , GTK_IMAGE(image) );
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryUsername);
gtk_entry_set_text(GTK_ENTRY(entryUsername), curUsername);
gtk_table_attach ( GTK_TABLE( table ), entryUsername, 1, 2, 7, 8, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_table_attach ( GTK_TABLE( table ), entryUsername, 1, 2, 6, 7, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
label = gtk_label_new_with_mnemonic (_("_Password"));
gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 8, 9, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 7, 8, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
entryPassword = sexy_icon_entry_new();
image = gtk_image_new_from_stock( GTK_STOCK_DIALOG_AUTHENTICATION , GTK_ICON_SIZE_SMALL_TOOLBAR );
......@@ -257,15 +244,15 @@ show_account_window (account_t * a)
gtk_entry_set_visibility(GTK_ENTRY(entryPassword), FALSE);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryPassword);
gtk_entry_set_text(GTK_ENTRY(entryPassword), curPassword);
gtk_table_attach ( GTK_TABLE( table ), entryPassword, 1, 2, 8, 9, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_table_attach ( GTK_TABLE( table ), entryPassword, 1, 2, 7, 8, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
label = gtk_label_new_with_mnemonic (_("_Voicemail box #"));
gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 9, 10, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_table_attach ( GTK_TABLE( table ), label, 0, 1, 8, 9, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_misc_set_alignment(GTK_MISC (label), 0, 0.5);
entryMailbox = gtk_entry_new();
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryMailbox);
gtk_entry_set_text(GTK_ENTRY(entryMailbox), curMailbox);
gtk_table_attach ( GTK_TABLE( table ), entryMailbox, 1, 2, 9, 10, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_table_attach ( GTK_TABLE( table ), entryMailbox, 1, 2, 8, 9, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_widget_show_all( table );
gtk_container_set_border_width (GTK_CONTAINER(table), 10);
......@@ -341,10 +328,6 @@ show_account_window (account_t * a)
g_strdup(ACCOUNT_SIP_HOST),
g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryHostname))));
g_hash_table_replace(currentAccount->properties,
g_strdup(ACCOUNT_SIP_PORT),
g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryPort))));
g_hash_table_replace(currentAccount->properties,
g_strdup(ACCOUNT_SIP_USER),
g_strdup((gchar *)gtk_entry_get_text(GTK_ENTRY(entryUsername))));
......
......@@ -1926,6 +1926,81 @@ org_sflphone_SFLphone_ConfigurationManager_get_pulse_app_volume_control_async (D
stuff->userdata = userdata;
return dbus_g_proxy_begin_call (proxy, "getPulseAppVolumeControl", org_sflphone_SFLphone_ConfigurationManager_get_pulse_app_volume_control_async_callback, stuff, g_free, G_TYPE_INVALID);
}
static
#ifdef G_HAVE_INLINE
inline
#endif
gboolean
org_sflphone_SFLphone_ConfigurationManager_set_sip_port (DBusGProxy *proxy, const gint IN_port, GError **error)
{
return dbus_g_proxy_call (proxy, "setSipPort", error, G_TYPE_INT, IN_port, G_TYPE_INVALID, G_TYPE_INVALID);
}
typedef void (*org_sflphone_SFLphone_ConfigurationManager_set_sip_port_reply) (DBusGProxy *proxy, GError *error, gpointer userdata);
static void
org_sflphone_SFLphone_ConfigurationManager_set_sip_port_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_sip_port_reply)data->cb) (proxy, error, data->userdata);
return;
}
static
#ifdef G_HAVE_INLINE
inline
#endif
DBusGProxyCall*
org_sflphone_SFLphone_ConfigurationManager_set_sip_port_async (DBusGProxy *proxy, const gint IN_port, org_sflphone_SFLphone_ConfigurationManager_set_sip_port_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, "setSipPort", org_sflphone_SFLphone_ConfigurationManager_set_sip_port_async_callback, stuff, g_free, G_TYPE_INT, IN_port, G_TYPE_INVALID);
}
static
#ifdef G_HAVE_INLINE
inline
#endif
gboolean
org_sflphone_SFLphone_ConfigurationManager_get_sip_port (DBusGProxy *proxy, gint* OUT_port, GError **error)
{
return dbus_g_proxy_call (proxy, "getSipPort", error, G_TYPE_INVALID, G_TYPE_INT, OUT_port, G_TYPE_INVALID);
}
typedef void (*org_sflphone_SFLphone_ConfigurationManager_get_sip_port_reply) (DBusGProxy *proxy, gint OUT_port, GError *error, gpointer userdata);
static void
org_sflphone_SFLphone_ConfigurationManager_get_sip_port_async_callback (DBusGProxy *proxy, DBusGProxyCall *call, void *user_data)
{
DBusGAsyncData *data = (DBusGAsyncData*) user_data;
GError *error = NULL;
gint OUT_port;
dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INT, &OUT_port, G_TYPE_INVALID);
(*(org_sflphone_SFLphone_ConfigurationManager_get_sip_port_reply)data->cb) (proxy, OUT_port, error, data->userdata);
return;
}
static
#ifdef G_HAVE_INLINE
inline
#endif
DBusGProxyCall*
org_sflphone_SFLphone_ConfigurationManager_get_sip_port_async (DBusGProxy *proxy, org_sflphone_SFLphone_ConfigurationManager_get_sip_port_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, "getSipPort", org_sflphone_SFLphone_ConfigurationManager_get_sip_port_async_callback, stuff, g_free, G_TYPE_INVALID);
}
#endif /* defined DBUS_GLIB_CLIENT_WRAPPERS_org_sflphone_SFLphone_ConfigurationManager */
G_END_DECLS
......@@ -36,6 +36,7 @@
/**
* Local variables
*/
gboolean accDialogOpen = FALSE;
gboolean dialogOpen = FALSE;
gboolean ringtoneEnabled = TRUE;
......@@ -69,7 +70,7 @@ enum {
void
config_window_fill_account_list()
{
if(dialogOpen)
if(accDialogOpen)
{
GtkTreeIter iter;
......@@ -313,6 +314,13 @@ set_pulse_app_volume_control( void )
dbus_set_pulse_app_volume_control();
}
//static void update_port( GtkSpinButton *button, void *ptr )
static void update_port( GtkSpinButton *button )
{
dbus_set_sip_port(gtk_spin_button_get_value_as_int(button));
//dbus_set_sip_port(gtk_spin_button_get_value_as_int((GtkSpinButton *)(ptr)));
}
/**
* Account settings tab
*/
......@@ -449,6 +457,7 @@ create_general_settings ()
GtkWidget *value;
GtkWidget *label;
GtkWidget *cleanButton;
GtkWidget *entryPort;
// Main widget
ret = gtk_vbox_new(FALSE, 10);
......@@ -534,6 +543,28 @@ create_general_settings ()
gtk_box_pack_start( GTK_BOX(vbox) , widg , TRUE , TRUE , 1);
g_signal_connect(G_OBJECT( widg ) , "clicked" , G_CALLBACK( set_pulse_app_volume_control ) , NULL);
/** SIP port information */
int curPort = dbus_get_sip_port();
if(curPort <= 0 || curPort > 65535)
curPort = 5060;
frame = gtk_frame_new( _("SIP Port"));
gtk_box_pack_start(GTK_BOX(ret), frame, FALSE, FALSE, 0);
gtk_widget_show( frame );
vbox = gtk_vbox_new(FALSE, 10);
gtk_widget_show( vbox );
gtk_container_add( GTK_CONTAINER(frame) , vbox);
label = gtk_label_new(_("Port number:"));
entryPort = gtk_spin_button_new_with_range(1, 65535, 1);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryPort);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(entryPort), curPort);
//gtk_table_attach ( GTK_TABLE( table ), entryPort, 1, 2, 6, 7, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
gtk_box_pack_start( GTK_BOX(vbox) , entryPort , TRUE , TRUE , 1);
g_signal_connect( G_OBJECT( entryPort) , "value-changed" , G_CALLBACK( update_port ) , NULL);
//g_signal_connect( G_OBJECT( applyButton) , "value-changed" , G_CALLBACK( update_port ) , entryPort);
gtk_widget_show_all(ret);
return ret;
......@@ -599,7 +630,7 @@ show_accounts_window( void )
GtkWidget * accountFrame;
GtkWidget * tab;
dialogOpen = TRUE;
accDialogOpen = TRUE;
dialog = GTK_DIALOG(gtk_dialog_new_with_buttons (_("Accounts"),
GTK_WINDOW(get_main_window()),
......@@ -625,7 +656,7 @@ show_accounts_window( void )
gtk_dialog_run( dialog );
dialogOpen=FALSE;
accDialogOpen=FALSE;
gtk_widget_destroy(GTK_WIDGET(dialog));
if( account_list_get_size() >0 && account_list_get_current()==NULL )
account_list_set_current_pos(0);
......
......@@ -1480,3 +1480,34 @@ dbus_get_pulse_app_volume_control( void )
return state;
}
void
dbus_set_sip_port( const guint portNum )
{
GError* error = NULL;
org_sflphone_SFLphone_ConfigurationManager_set_sip_port(
configurationManagerProxy,
portNum,
&error);
if(error)
{
g_error_free(error);
}
}
guint
dbus_get_sip_port( void )
{
GError* error = NULL;
gint portNum;
org_sflphone_SFLphone_ConfigurationManager_get_sip_port(
configurationManagerProxy,
&portNum,
&error);
if(error)
{
g_error_free(error);
}
g_print("GET MAX CALLS = %i\n" , portNum);
return (guint)portNum;
}
......@@ -425,4 +425,8 @@ void dbus_register( int pid, gchar * name);
*/
void dbus_unregister(int pid);
void dbus_set_sip_port(const guint portNum);
guint dbus_get_sip_port();
#endif
......@@ -49,8 +49,6 @@
#define ACCOUNT_SIP_USER "SIP.username"
/** SIP parameter: password */
#define ACCOUNT_SIP_PASSWORD "SIP.password"
// SIP connection port
#define ACCOUNT_SIP_PORT "SIP.port"
/** SIP parameter: proxy address */
#define ACCOUNT_SIP_PROXY "SIP.proxy"
/** SIP parameter: stun server address */
......
......@@ -56,8 +56,6 @@ typedef std::string AccountID;
#define SIP_PASSWORD "SIP.password"
/** SIP parameter : host name */
#define SIP_HOST "SIP.hostPart"
// SIP port
#define SIP_PORT "SIP.port"
/** SIP parameter : proxy address */
#define SIP_PROXY "SIP.proxy"
/** SIP parameter : stun server address */
......
......@@ -71,6 +71,8 @@ public:
register_method(ConfigurationManager_adaptor, switchPopupMode, _switchPopupMode_stub);
register_method(ConfigurationManager_adaptor, setPulseAppVolumeControl, _setPulseAppVolumeControl_stub);
register_method(ConfigurationManager_adaptor, getPulseAppVolumeControl, _getPulseAppVolumeControl_stub);
register_method(ConfigurationManager_adaptor, setSipPort, _setSipPort_stub);
register_method(ConfigurationManager_adaptor, getSipPort, _getSipPort_stub);
}
::DBus::IntrospectedInterface *const introspect() const
......@@ -326,6 +328,16 @@ public:
{ "state", "i", false },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument setSipPort_args[] =
{
{ "port", "i", true },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument getSipPort_args[] =
{
{ "port", "i", false },
{ 0, 0, 0 }
};
static ::DBus::IntrospectedArgument parametersChanged_args[] =
{
{ "list", "a{ss}", false },
......@@ -393,6 +405,8 @@ public:
{ "switchPopupMode", switchPopupMode_args },
{ "setPulseAppVolumeControl", setPulseAppVolumeControl_args },
{ "getPulseAppVolumeControl", getPulseAppVolumeControl_args },
{ "setSipPort", setSipPort_args },
{ "getSipPort", getSipPort_args },
{ 0, 0 }
};
static ::DBus::IntrospectedMethod ConfigurationManager_adaptor_signals[] =
......@@ -478,6 +492,8 @@ public:
virtual void switchPopupMode() = 0;
virtual void setPulseAppVolumeControl() = 0;
virtual int32_t getPulseAppVolumeControl() = 0;
virtual void setSipPort(const int32_t& port) = 0;
virtual int32_t getSipPort() = 0;
public:
......@@ -992,6 +1008,25 @@ private:
wi << argout1;
return reply;
}
::DBus::Message _setSipPort_stub(const ::DBus::CallMessage &call)
{
::DBus::MessageIter ri = call.reader();
int32_t argin1; ri >> argin1;
setSipPort(argin1);
::DBus::ReturnMessage reply(call);
return reply;
}
::DBus::Message _getSipPort_stub(const ::DBus::CallMessage &call)
{
::DBus::MessageIter ri = call.reader();
int32_t argout1 = getSipPort();
::DBus::ReturnMessage reply(call);
::DBus::MessageIter wi = reply.writer();
wi << argout1;
return reply;
}
};
} } }
......
......@@ -210,6 +210,14 @@
<arg type="i" name="state" direction="out"/>
</method>
<method name="setSipPort">
<arg type="i" name="port" direction="in"/>
</method>
<method name="getSipPort">
<arg type="i" name="port" direction="out"/>
</method>
<!-- ///////////////////////////// -->
<signal name="parametersChanged">
<arg type="a{ss}" name="list" direction="out"/>
......
......@@ -382,3 +382,16 @@ ConfigurationManager::setPulseAppVolumeControl( void )
Manager::instance().setPulseAppVolumeControl();
}
int32_t
ConfigurationManager::getSipPort( void )
{
return Manager::instance().getSipPort();
}
void
ConfigurationManager::setSipPort( const int32_t& portNum )
{
_debug("Manager received setSipPort: %d\n", portNum);
Manager::instance().setSipPort(portNum);
}
......@@ -95,6 +95,8 @@ public:
void setMailNotify( void );
int32_t getPulseAppVolumeControl( void );
void setPulseAppVolumeControl( void );
int32_t getSipPort( void );
void setSipPort( const int32_t& portNum );
};
......
......@@ -1070,6 +1070,7 @@ ManagerImpl::initConfigFile (void)
fill_config_int(REGISTRATION_EXPIRE , DFT_EXPIRE_VALUE);
fill_config_int(CONFIG_AUDIO , DFT_AUDIO_MANAGER);
fill_config_int(CONFIG_PA_VOLUME_CTRL , YES_STR);
fill_config_int(CONFIG_SIP_PORT, DFT_SIP_PORT);
// Loads config from ~/.sflphone/sflphonedrc or so..
if (createSettingsPath() == 1) {
......@@ -1973,12 +1974,6 @@ ManagerImpl::getAccountDetails(const AccountID& accountID)
getConfigString(accountID, SIP_HOST)
)
);
a.insert(
std::pair<std::string, std::string>(
SIP_PORT,
getConfigString(accountID, SIP_PORT)
)
);
a.insert(
std::pair<std::string, std::string>(
SIP_PROXY,
......@@ -2053,7 +2048,6 @@ ManagerImpl::setAccountDetails( const std::string& accountID,
setConfig(accountID, SIP_USER, (*details.find(SIP_USER)).second);
setConfig(accountID, SIP_PASSWORD, (*details.find(SIP_PASSWORD)).second);
setConfig(accountID, SIP_HOST, (*details.find(SIP_HOST)).second);
setConfig(accountID, SIP_PORT, (*details.find(SIP_PORT)).second);
setConfig(accountID, SIP_STUN_SERVER,(*details.find(SIP_STUN_SERVER)).second);
setConfig(accountID, CONFIG_ACCOUNT_MAILBOX,(*details.find(CONFIG_ACCOUNT_MAILBOX)).second);
setConfig(accountID, SIP_USE_STUN,
......@@ -2080,6 +2074,8 @@ ManagerImpl::setAccountDetails( const std::string& accountID,
// Update account details
if (_dbus) _dbus->getConfigurationManager()->accountsChanged();
//restartPjsip();
}
void
......@@ -2106,7 +2102,6 @@ ManagerImpl::sendRegister( const std::string& accountID , const int32_t& expire
ManagerImpl::addAccount(const std::map< std::string, std::string >& details)
{
_debug("********************** Into ManagerImpl::addAccount \n");
/** @todo Deal with both the _accountMap and the Configuration */
std::string accountType = (*details.find(CONFIG_ACCOUNT_TYPE)).second;
Account* newAccount;
......@@ -2119,6 +2114,7 @@ ManagerImpl::addAccount(const std::map< std::string, std::string >& details)
if(!_userAgentInitlized) {
// Initialize the SIP Manager
_userAgent = new UserAgent();
_userAgent->setSipPort(Manager::instance().getConfigInt(PREFERENCES , CONFIG_SIP_PORT));
}
newAccount = AccountCreator::createAccount(AccountCreator::SIP_ACCOUNT, newAccountID);
......@@ -2147,6 +2143,8 @@ ManagerImpl::addAccount(const std::map< std::string, std::string >& details)
saveConfig();
if (_dbus) _dbus->getConfigurationManager()->accountsChanged();
//restartPjsip();
}
void
......@@ -2224,15 +2222,21 @@ ManagerImpl::getNewCallID()
}
return random_id.str();
}
/*
ManagerImpl::updatePjsip()
void
ManagerImpl::restartPjsip()
{
if ( _userAgentInitlized )
delete _userAgent;
//loadAccountMap
if ( _userAgentInitlized ){
unregisterCurSIPAccounts();
_userAgent->sipDestory();
//_userAgent->setSipPort(Manager::instance().getConfigInt(PREFERENCES , CONFIG_SIP_PORT));
_userAgent->sipCreate();
_userAgent->sipInit();
registerCurSIPAccounts();
}
}
*/
short
ManagerImpl::loadAccountMap()
{
......@@ -2246,6 +2250,7 @@ ManagerImpl::loadAccountMap()
TokenList::iterator iter = sections.begin();
while(iter != sections.end()) {
_debug("***************** In Load account: into while\n");
// Check if it starts with "Account:" (SIP and IAX pour le moment)
if ((int)(iter->find("Account:")) == -1) {
iter++;
......@@ -2258,7 +2263,7 @@ ManagerImpl::loadAccountMap()
// Initialize the SIP Manager
_userAgent = new UserAgent();
_userAgentInitlized = true;
_userAgent->setRegPort(DEFAULT_SIP_PORT);
_userAgent->setSipPort(Manager::instance().getConfigInt(PREFERENCES , CONFIG_SIP_PORT));
}
tmpAccount = AccountCreator::createAccount(AccountCreator::SIP_ACCOUNT, *iter);
......@@ -2270,12 +2275,12 @@ ManagerImpl::loadAccountMap()
_userAgent->setStunServer(Manager::instance().getConfigString(tmpAccount->getAccountID(), SIP_STUN_SERVER).data());
}
// Set registration port for all accounts, The last non-5060 port will be recorded in _userAgent.
/*// Set registration port for all accounts, The last non-5060 port will be recorded in _userAgent.
port = Manager::instance().getConfigString(tmpAccount->getAccountID(), SIP_PORT);
std::istringstream is(port);
is >> iPort;
if (iPort != DEFAULT_SIP_PORT)
_userAgent->setRegPort(iPort);
_userAgent->setRegPort(iPort); */
}
else if (accountType == "IAX") {
tmpAccount = AccountCreator::createAccount(AccountCreator::IAX_ACCOUNT, *iter);
......@@ -2388,6 +2393,52 @@ UserAgent *ManagerImpl::getUserAgent()
return _userAgent;
}
int
ManagerImpl::getSipPort()
{
return _userAgent->getSipPort();
}
void
ManagerImpl::setSipPort(int portNum)
{
if(portNum != _userAgent->getSipPort()) {
_userAgent->setSipPort(portNum);
restartPjsip();
setConfig( PREFERENCES , CONFIG_SIP_PORT , portNum );
}
}
void ManagerImpl::unregisterCurSIPAccounts()
{
AccountMap::iterator iter = _accountMap.begin();
while( iter != _accountMap.end() ) {
if ( iter->second) {
std::string p = Manager::instance().getConfigString( iter->first , CONFIG_ACCOUNT_TYPE );
if ( iter->second->isEnabled() && p == "SIP") {
// NOW
iter->second->unregisterVoIPLink();
}
}
iter++;
}
}
void ManagerImpl::registerCurSIPAccounts()
{
AccountMap::iterator iter = _accountMap.begin();
while( iter != _accountMap.end() ) {
if ( iter->second) {
std::string p = Manager::instance().getConfigString( iter->first , CONFIG_ACCOUNT_TYPE );