diff --git a/sflphone-client-gnome/src/config/accountconfigdialog.c b/sflphone-client-gnome/src/config/accountconfigdialog.c index 5fd6c4cc7c0e6aab00e85adaed59ce52bf1de3e1..4f7e34ee3f2f4f3a818b7c94441fbf0d4c4056c8 100644 --- a/sflphone-client-gnome/src/config/accountconfigdialog.c +++ b/sflphone-client-gnome/src/config/accountconfigdialog.c @@ -57,6 +57,7 @@ GtkWidget * entryUsername; GtkWidget * entryHostname; GtkWidget * entryPassword; GtkWidget * entryMailbox; +GtkWidget * entryUseragent; GtkWidget * entryResolveNameOnlyOnce; GtkWidget * expireSpinBox; GtkListStore * credentialStore; @@ -208,15 +209,16 @@ static GtkWidget* create_basic_tab (account_t **a) { #endif // Default settings - gchar * curAccountID = ""; - gchar * curAccountEnabled = "true"; - gchar * curAccountType = "SIP"; - gchar * curAlias = ""; - gchar * curUsername = ""; - gchar * curHostname = ""; - gchar * curPassword = ""; + gchar *curAccountID = ""; + gchar *curAccountEnabled = "true"; + gchar *curAccountType = "SIP"; + gchar *curAlias = ""; + gchar *curUsername = ""; + gchar *curHostname = ""; + gchar *curPassword = ""; /* TODO: add curProxy, and add boxes for Proxy support */ - gchar * curMailbox = ""; + gchar *curMailbox = ""; + gchar *curUseragent = ""; currentAccount = *a; @@ -232,13 +234,14 @@ static GtkWidget* create_basic_tab (account_t **a) { curPassword = g_hash_table_lookup(currentAccount->properties, ACCOUNT_PASSWORD); curUsername = g_hash_table_lookup(currentAccount->properties, ACCOUNT_USERNAME); curMailbox = g_hash_table_lookup(currentAccount->properties, ACCOUNT_MAILBOX); + curUseragent = g_hash_table_lookup(currentAccount->properties, ACCOUNT_USERAGENT); } gnome_main_section_new (_("Account Parameters"), &frame); gtk_widget_show(frame); - table = gtk_table_new (7, 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); @@ -337,6 +340,15 @@ static GtkWidget* create_basic_tab (account_t **a) { gtk_entry_set_text(GTK_ENTRY(entryMailbox), curMailbox); gtk_table_attach ( GTK_TABLE( table ), entryMailbox, 1, 2, 6, 7, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + label = gtk_label_new_with_mnemonic (_("_User-agent")); + 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); + entryUseragent = gtk_entry_new (); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), entryUseragent); + gtk_entry_set_text (GTK_ENTRY (entryUseragent), curUseragent); + gtk_table_attach ( GTK_TABLE( table ), entryUseragent, 1, 2, 7, 8, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); + + gtk_widget_show_all( table ); gtk_container_set_border_width (GTK_CONTAINER(table), 10); @@ -1227,6 +1239,9 @@ void show_account_window (account_t * a) { if (g_strcasecmp (currentAccount->accountID, IP2IP) != 0) { + g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_USERAGENT), + g_strdup(gtk_entry_get_text (GTK_ENTRY(entryUseragent)))); + g_hash_table_replace(currentAccount->properties, g_strdup(ACCOUNT_SIP_STUN_ENABLED), g_strdup(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(useStunCheckBox)) ? "true":"false")); diff --git a/sflphone-client-gnome/src/dbus/configurationmanager-introspec.xml b/sflphone-client-gnome/src/dbus/configurationmanager-introspec.xml index fa1433399af895a581321d58aeb5bdf6034291ba..3361c16dd5a6b74dd9b6a60241b664b059fa6350 100644 --- a/sflphone-client-gnome/src/dbus/configurationmanager-introspec.xml +++ b/sflphone-client-gnome/src/dbus/configurationmanager-introspec.xml @@ -162,6 +162,8 @@ <method name="addAccount"> <!--* Add a new account to the SFLphone-daemon list. If no details are specified, default parameters are used. + A REGISTER is automatically sent and configuration is + saved if account created successfully. @param[in] input details @param[out] output accountID @@ -458,7 +460,7 @@ <method name="setWindowPositionY"> <arg type="i" name="posY" direction="in"/> </method> - + <!-- Addressbook configuration --> <method name="getAddressbookSettings"> <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="MapStringInt"/> diff --git a/sflphone-client-gnome/src/dbus/dbus.c b/sflphone-client-gnome/src/dbus/dbus.c index b07af3609ec8171210b5a43ef12aba7e14d79da9..e4d0f53bfe537a53fd62cb6e4464a79202e21fbf 100644 --- a/sflphone-client-gnome/src/dbus/dbus.c +++ b/sflphone-client-gnome/src/dbus/dbus.c @@ -2579,3 +2579,4 @@ void dbus_set_window_position_y (const guint posy) { g_error_free (error); } } + diff --git a/sflphone-client-gnome/src/dbus/dbus.h b/sflphone-client-gnome/src/dbus/dbus.h index acc961fba44646e42b5cad4e33b9646bc56e5160..c8dd014f8789afa3891afd3cdb83c69f10734ee0 100644 --- a/sflphone-client-gnome/src/dbus/dbus.h +++ b/sflphone-client-gnome/src/dbus/dbus.h @@ -606,5 +606,4 @@ guint dbus_get_window_position_y (void); void dbus_set_window_position_x (const guint posx); void dbus_set_window_position_y (const guint posy); - #endif diff --git a/sflphone-client-gnome/src/sflphone_const.h b/sflphone-client-gnome/src/sflphone_const.h index 7df3cc9144a58115e4d959dfa0b47c02af690131..7153a5f5432660eb89996128b9bcd104d6b091f0 100644 --- a/sflphone-client-gnome/src/sflphone_const.h +++ b/sflphone-client-gnome/src/sflphone_const.h @@ -57,6 +57,7 @@ #define ACCOUNT_ALIAS "Account.alias" #define ACCOUNT_ENABLED "Account.enable" #define ACCOUNT_MAILBOX "Account.mailbox" +#define ACCOUNT_USERAGENT "useragent" #define ACCOUNT_RESOLVE_ONCE "Account.resolveOnce" #define ACCOUNT_REGISTRATION_EXPIRE "Account.expire" #define ACCOUNT_SIP_STUN_SERVER "STUN.server" diff --git a/sflphone-common/src/account.h b/sflphone-common/src/account.h index f2fa54b8106556cfef2882241edde89e806f18a2..998330d0c566ed36da2d918f16b1ea1b1a135508 100644 --- a/sflphone-common/src/account.h +++ b/sflphone-common/src/account.h @@ -72,6 +72,7 @@ typedef enum RegistrationState { #define PASSWORD "password" #define REALM "realm" #define DEFAULT_REALM "*" +#define USERAGENT "useragent" #define LOCAL_INTERFACE "Account.localInterface" #define PUBLISHED_SAMEAS_LOCAL "Account.publishedSameAsLocal" diff --git a/sflphone-common/src/dbus/callmanager-introspec.xml b/sflphone-common/src/dbus/callmanager-introspec.xml index 34f4eab3ec6cf7f05cd51faf845a0c64313654dd..83a5c32acf22c3086a8f347113bc5733c2ab3be6 100644 --- a/sflphone-common/src/dbus/callmanager-introspec.xml +++ b/sflphone-common/src/dbus/callmanager-introspec.xml @@ -1,5 +1,9 @@ <?xml version="1.0" encoding="UTF-8" ?> -<node name="/org/sflphone/SFLphone"> + +<!-- Comment --> +<!--*< File comment --> + +<node name="/org/sflphone/SFLphone" xmlns:dx="http://psiamp.org/dtd/doxygen_dbusxml.dtd"> <!--* The CallManager interface is used to manage any call related actions. @@ -15,36 +19,37 @@ subscribe to the callStateChanged signal in order to be notified on updates in call status. --> - <interface name="org.sflphone.SFLphone.CallManager"> - - <method name="placeCall"> - <!--* This is the main method in order to place a new call. The + <interface name="org.sflphone.SFLphone.CallManager"> + + <!--* This is the main method in order to place a new call. The call is registered to the daemon using this method specified a unique identifier and VoIP Accout to be bound with. - The account is specified by its accountID. + The account is specified by its accountID. - If the call is to be placed whithout any account by the - means of a SIP URI (i.e. sip:num@server), the - "IP2IP_PROFILE" is passed as the accountID. For more - details about accounts see the configuration manager interface. + If the call is to be placed whithout any account by the + means of a SIP URI (i.e. sip:num@server), the + "IP2IP_PROFILE" is passed as the accountID. For more + details about accounts see the configuration manager interface. - The callID is a unique identifier that must be randomly - generated on sflphone-client's side. Any subsequent - actions refering to this call must use this callID. + The callID is a unique identifier that must be randomly + generated on sflphone-client's side. Any subsequent + actions refering to this call must use this callID. - If bound to a VoIP account, the to argument is the phone - number. In case of calls involving "IP2IP_PROFILE", a - complete SIP URI must be specified. + If bound to a VoIP account, the to argument is the phone + number. In case of calls involving "IP2IP_PROFILE", a + complete SIP URI must be specified. - @param[in] input accountID - @param[in] input callID - @param[in] input to + @param[in] input accountID + @param[in] input callID + @param[in] input to --> - <arg type="s" name="accountID" direction="in" /> - <arg type="s" name="callID" direction="in" /> - <arg type="s" name="to" direction="in" /> - </method> + + <method name="placeCall"> + <arg type="s" name="accountID" direction="in"/> + <arg type="s" name="callID" direction="in" /> + <arg type="s" name="to" direction="in" /> + </method> <method name="placeCallFirstAccount"> <arg type="s" name="callID" direction="in"/> diff --git a/sflphone-common/src/dbus/configurationmanager-introspec.xml b/sflphone-common/src/dbus/configurationmanager-introspec.xml index 33f0192c2cadb65f43f0c05abdd7e87792b94354..3361c16dd5a6b74dd9b6a60241b664b059fa6350 100644 --- a/sflphone-common/src/dbus/configurationmanager-introspec.xml +++ b/sflphone-common/src/dbus/configurationmanager-introspec.xml @@ -460,7 +460,7 @@ <method name="setWindowPositionY"> <arg type="i" name="posY" direction="in"/> </method> - + <!-- Addressbook configuration --> <method name="getAddressbookSettings"> <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="MapStringInt"/> diff --git a/sflphone-common/src/dbus/configurationmanager.cpp b/sflphone-common/src/dbus/configurationmanager.cpp index 275800cb54fbb0b9da780a59bbb331dfbd935cdf..1eb0c06ff7670e2a80ca120085566fd3a0e29328 100644 --- a/sflphone-common/src/dbus/configurationmanager.cpp +++ b/sflphone-common/src/dbus/configurationmanager.cpp @@ -868,5 +868,3 @@ void ConfigurationManager::setWindowPositionY (const int32_t& posY) { Manager::instance ().setConfig (PREFERENCES, WINDOW_POSITION_Y, posY); } - - diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index 4b2c6f8461ee6c647c0b1fdee580f4f9b03fa310..fc85025e76608bf0f11aca32ba66569b8aa7331f 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -2358,6 +2358,8 @@ ManagerImpl::initConfigFile (bool load_user_value, std::string alternate) _config.addDefaultValue (std::pair<std::string, std::string> (REALM, DEFAULT_REALM)); + _config.addDefaultValue (std::pair<std::string, std::string> (USERAGENT, DFT_USERAGENT)); + _config.addDefaultValue (std::pair<std::string, std::string> (CONFIG_ACCOUNT_REGISTRATION_EXPIRE, DFT_EXPIRE_VALUE)); _config.addDefaultValue (std::pair<std::string, std::string> (CONFIG_ACCOUNT_RESOLVE_ONCE, FALSE_STR)); @@ -3376,6 +3378,7 @@ std::map< std::string, std::string > ManagerImpl::getAccountDetails (const Accou a.insert (std::pair<std::string, std::string> (USERNAME, getConfigString (accountID, USERNAME))); a.insert (std::pair<std::string, std::string> (PASSWORD, getConfigString (accountID, PASSWORD))); a.insert (std::pair<std::string, std::string> (REALM, getConfigString (accountID, REALM))); + a.insert (std::pair<std::string, std::string> (USERAGENT, getConfigString (accountID, USERAGENT))); a.insert (std::pair<std::string, std::string> (AUTHENTICATION_USERNAME, getConfigString (accountID, AUTHENTICATION_USERNAME))); a.insert (std::pair<std::string, std::string> (CONFIG_ACCOUNT_MAILBOX, getConfigString (accountID, CONFIG_ACCOUNT_MAILBOX))); a.insert (std::pair<std::string, std::string> (CONFIG_ACCOUNT_REGISTRATION_EXPIRE, getConfigString (accountID, CONFIG_ACCOUNT_REGISTRATION_EXPIRE))); @@ -3572,6 +3575,7 @@ void ManagerImpl::setAccountDetails (const std::string& accountID, const std::ma std::string password; std::string realm; std::string voicemail_count; + std::string ua_name; if ( (iter = map_cpy.find (AUTHENTICATION_USERNAME)) != map_cpy.end()) { authenticationName = iter->second; @@ -3589,8 +3593,12 @@ void ManagerImpl::setAccountDetails (const std::string& accountID, const std::ma realm = iter->second; } - setConfig (accountID, REALM, realm); + if ( (iter = map_cpy.find (USERAGENT)) != map_cpy.end()) { + ua_name = iter->second; + } + setConfig (accountID, REALM, realm); + setConfig (accountID, USERAGENT, ua_name); setConfig (accountID, USERNAME, username); setConfig (accountID, AUTHENTICATION_USERNAME, authenticationName); diff --git a/sflphone-common/src/sip/sipvoiplink.cpp b/sflphone-common/src/sip/sipvoiplink.cpp index 9542ea46e56adf1799667f68ce796e352f773cc1..73f6f175bc86f2b710b2e3ee789529e85e607991 100644 --- a/sflphone-common/src/sip/sipvoiplink.cpp +++ b/sflphone-common/src/sip/sipvoiplink.cpp @@ -405,11 +405,19 @@ std::string SIPVoIPLink::getInterfaceAddrFromName(std::string ifaceName) { } -std::string SIPVoIPLink::get_useragent_name (void) +std::string SIPVoIPLink::get_useragent_name (const AccountID& id) { - std::ostringstream useragent; + /* useragent << PROGNAME << "/" << SFLPHONED_VERSION; return useragent.str(); + */ + std::ostringstream useragent; + + useragent << Manager::instance ().getConfigString (id, USERAGENT); + if (useragent.str() == "sflphone" || useragent.str() == "") + useragent << "/" << SFLPHONED_VERSION; + + return useragent.str (); } void @@ -592,7 +600,7 @@ int SIPVoIPLink::sendRegister (AccountID id) // Add User-Agent Header pj_list_init (&hdr_list); - useragent = pj_str ( (char*) get_useragent_name ().c_str()); + useragent = pj_str ( (char*) get_useragent_name (id).c_str()); h = pjsip_generic_string_hdr_create (_pool, &STR_USER_AGENT, &useragent); diff --git a/sflphone-common/src/sip/sipvoiplink.h b/sflphone-common/src/sip/sipvoiplink.h index 00c8171535608e3ebab48bb3c0b35e68c2c5721b..67108a7b93254b6e17bb7c428fe82ab4952f8f37 100644 --- a/sflphone-common/src/sip/sipvoiplink.h +++ b/sflphone-common/src/sip/sipvoiplink.h @@ -280,7 +280,7 @@ class SIPVoIPLink : public VoIPLink bool new_ip_to_ip_call (const CallID& id, const std::string& to); - std::string get_useragent_name (void); + std::string get_useragent_name (const AccountID& id); /** * List all the interfaces on the system and return diff --git a/sflphone-common/src/user_cfg.h b/sflphone-common/src/user_cfg.h index 91c4633e7da6a469e372b6f7cb21c598276b6ac7..096b7f11f12558fea09f48ff7bb952d2eb2d1b02 100644 --- a/sflphone-common/src/user_cfg.h +++ b/sflphone-common/src/user_cfg.h @@ -116,5 +116,6 @@ #define DFT_RECORD_PATH HOMEDIR #define DFT_WINDOW_WIDTH "240" #define DFT_WINDOW_HEIGHT "320" +#define DFT_USERAGENT "sflphone" //PROGNAME + "/" + SFLPHONED_VERSION #endif // __USER_CFG_H__