diff --git a/sflphone-common/src/config/yamlnode.cpp b/sflphone-common/src/config/yamlnode.cpp index 00a3aa1d8db8a99ea4baf13e922ec37c4c7e4732..e0d97cdf94619e44df7c24d94b382f86bbfa1056 100644 --- a/sflphone-common/src/config/yamlnode.cpp +++ b/sflphone-common/src/config/yamlnode.cpp @@ -74,6 +74,7 @@ void MappingNode::removeKeyValue (Key key) YamlNode *MappingNode::getValue (Key key) { + Mapping::iterator it = map.find (key); if (it != map.end()) { diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index de54ca7dfb88d3eb315ccffc0ccfe915f53d8cfb..33e1a644dc2acdb4d2f94fb8063a30de87f5e1a8 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -62,6 +62,7 @@ #include <sstream> #include <sys/types.h> // mkdir(2) #include <sys/stat.h> // mkdir(2) + #include <pwd.h> // getpwuid #define DIRECT_IP_CALL "IP CALL" @@ -3807,15 +3808,33 @@ short ManagerImpl::loadAccountMap() while (iterSeq != seq->getSequence()->end()) { + // Pointer to the account and account preferences map Account *tmpAccount = NULL; Conf::MappingNode *map = (Conf::MappingNode *) (*iterSeq); - Conf::ScalarNode * val = (Conf::ScalarNode *) (map->getValue (accTypeKey)); - Conf::Value accountType = val->getValue(); + // Scalar node from yaml configuration + Conf::ScalarNode * val = NULL; + + // Search for account types (IAX/IP2IP) + val = (Conf::ScalarNode *) (map->getValue (accTypeKey)); + Conf::Value accountType; + if(val) + accountType = val->getValue(); + else + accountType = "SIP"; // Assume type is SIP if not specified + // search for account id + val = NULL; val = (Conf::ScalarNode *) (map->getValue (accID)); - Conf::Value accountid = val->getValue(); + Conf::Value accountid; + if(val) + accountid = val->getValue(); + + // do not insert in account map if id is empty + if (accountid.empty()) + continue; + // Create a default account for specific type if (accountType == "SIP" && accountid != "IP2IP") { _debug ("Manager: Create SIP account: %s", accountid.c_str()); tmpAccount = AccountCreator::createAccount (AccountCreator::SIP_ACCOUNT, accountid); @@ -3824,10 +3843,11 @@ short ManagerImpl::loadAccountMap() tmpAccount = AccountCreator::createAccount (AccountCreator::IAX_ACCOUNT, accountid); } - + // Fill account with configuration preferences if (tmpAccount != NULL) { try { + tmpAccount->unserialize (map); } catch (SipAccountException &e) { _error ("Manager: %s", e.what()); diff --git a/sflphone-common/src/preferences.cpp b/sflphone-common/src/preferences.cpp index 2354ad15bc62c0b0414c8ea1ecb46d8e907ed5a0..daf723ff6a8f36fe24f81199317ead0fdbe149fb 100644 --- a/sflphone-common/src/preferences.cpp +++ b/sflphone-common/src/preferences.cpp @@ -102,8 +102,10 @@ void Preferences::unserialize (Conf::MappingNode *map) Conf::ScalarNode *val; - if (!map) + if (!map) { + _debug("Preference: Did not find general preferences"); return; + } val = (Conf::ScalarNode *) (map->getValue (orderKey)); @@ -230,8 +232,10 @@ void VoipPreference::unserialize (Conf::MappingNode *map) Conf::ScalarNode *val = NULL; - if (!map) + if (!map) { + _debug("VoipPreference: Did not find voip preference"); return; + } val = (Conf::ScalarNode *) (map->getValue (playDtmfKey)); @@ -319,8 +323,10 @@ void AddressbookPreference::unserialize (Conf::MappingNode *map) Conf::ScalarNode *val = NULL; - if (!map) + if (!map) { + _debug("Addressbook: Did not find addressbook preferences"); return; + } val = (Conf::ScalarNode *) (map->getValue (photoKey)); @@ -415,8 +421,10 @@ void HookPreference::unserialize (Conf::MappingNode *map) _debug ("Hook: Unserialize preference"); - if (!map) + if (!map) { + _debug("Hook: Did not find hook preference"); return; + } val = (Conf::ScalarNode *) (map->getValue (iax2EnabledKey)); @@ -551,8 +559,10 @@ void AudioPreference::unserialize (Conf::MappingNode *map) { _debug ("AudioPreference: Unserialize configuration"); - if (!map) + if (!map) { + _debug("AudioPreference: Did not find audio preferences"); return; + } Conf::MappingNode *alsamap = NULL; Conf::MappingNode *pulsemap = NULL; @@ -702,6 +712,9 @@ void ShortcutPreferences::setShortcuts (std::map<std::string, std::string> map_c // std::map<std::string, int> map_cpy = shortcut; std::map<std::string, std::string>::iterator it; + _debug ("ShortcutPreferences: Set shortcuts"); + + it = map_cpy.find (hangupShortKey); if (it != map_cpy.end()) { @@ -768,10 +781,12 @@ void ShortcutPreferences::serialize (Conf::YamlEmitter *emitter) void ShortcutPreferences::unserialize (Conf::MappingNode *map) { - _debug ("ShortcutPreference: Unserialize configuration"); + _debug ("ShortcutPreference: Unserialize shortcut"); - if (!map) + if (!map) { + _debug("ShortcutPreference: Could not find shortcut preferences"); return; + } Conf::ScalarNode *val = NULL; @@ -809,4 +824,5 @@ void ShortcutPreferences::unserialize (Conf::MappingNode *map) _togglePickupHangup = val->getValue(); val = NULL; } + } diff --git a/sflphone-common/src/sip/sipaccount.cpp b/sflphone-common/src/sip/sipaccount.cpp index 4f5fe36890bccb1397f22963ff6c63dfd93d7d67..7a6a07e64214a5f38f94faf630556fa9dfc4183b 100644 --- a/sflphone-common/src/sip/sipaccount.cpp +++ b/sflphone-common/src/sip/sipaccount.cpp @@ -66,7 +66,7 @@ void Credentials::unserialize (Conf::MappingNode *map) Conf::ScalarNode *val = NULL; - _debug ("SipAccount: Unserialize"); + _debug ("SipAccount: Unserialize credentials"); val = (Conf::ScalarNode *) (map->getValue (credentialCountKey)); @@ -442,10 +442,13 @@ void SIPAccount::unserialize (Conf::MappingNode *map) val = NULL; } + // Init stun server name with default server name _stunServerName = pj_str ( (char*) _stunServer.data()); credMap = (Conf::MappingNode *) (map->getValue (credKey)); - credentials.unserialize (credMap); + + if(credMap) + credentials.unserialize (credMap); val = (Conf::ScalarNode *) (map->getValue (displayNameKey));