diff --git a/daemon/src/config/serializable.h b/daemon/src/config/serializable.h index 0299f8e5e09cd47865b735062efab6352182a235..24d008b25275a3cd1781edd37bd0b5000fa78263 100644 --- a/daemon/src/config/serializable.h +++ b/daemon/src/config/serializable.h @@ -28,8 +28,8 @@ * as that of the covered work. */ -#ifndef __SERIALIZABLE_H__ -#define __SERIALIZABLE_H__ +#ifndef SERIALIZABLE_H__ +#define SERIALIZABLE_H__ namespace Conf { class YamlEmitter; @@ -40,8 +40,8 @@ class Serializable { public: virtual ~Serializable() {}; - virtual void serialize(Conf::YamlEmitter *emitter) = 0; - virtual void unserialize(const Conf::MappingNode *map) = 0; + virtual void serialize(Conf::YamlEmitter &emitter) = 0; + virtual void unserialize(const Conf::MappingNode &map) = 0; }; #endif diff --git a/daemon/src/iax/iaxaccount.cpp b/daemon/src/iax/iaxaccount.cpp index c6bd7d62930936b07a60c4e6de9a95edf66259a6..ae4affb02915b5b4ecd3b3022893e23734fd085d 100644 --- a/daemon/src/iax/iaxaccount.cpp +++ b/daemon/src/iax/iaxaccount.cpp @@ -53,13 +53,8 @@ IAXAccount::~IAXAccount() delete link_; } -void IAXAccount::serialize(Conf::YamlEmitter *emitter) +void IAXAccount::serialize(Conf::YamlEmitter &emitter) { - if (emitter == NULL) { - ERROR("IAXAccount: Error: emitter is NULL in serialize"); - return; - } - Conf::MappingNode accountmap(NULL); Conf::ScalarNode id(accountID_); @@ -87,31 +82,26 @@ void IAXAccount::serialize(Conf::YamlEmitter *emitter) accountmap.setKeyValue(CODECS_KEY, &codecs); try { - emitter->serializeAccount(&accountmap); + emitter.serializeAccount(&accountmap); } catch (const Conf::YamlEmitterException &e) { ERROR("ConfigTree: %s", e.what()); } } -void IAXAccount::unserialize(const Conf::MappingNode *map) +void IAXAccount::unserialize(const Conf::MappingNode &map) { - if (map == NULL) { - ERROR("IAXAccount: Error: Map is NULL in unserialize"); - return; - } - - map->getValue(ALIAS_KEY, &alias_); - map->getValue(TYPE_KEY, &type_); - map->getValue(USERNAME_KEY, &username_); - map->getValue(PASSWORD_KEY, &password_); - map->getValue(HOSTNAME_KEY, &hostname_); - map->getValue(ACCOUNT_ENABLE_KEY, &enabled_); - map->getValue(MAILBOX_KEY, &mailBox_); - map->getValue(CODECS_KEY, &codecStr_); + map.getValue(ALIAS_KEY, &alias_); + map.getValue(TYPE_KEY, &type_); + map.getValue(USERNAME_KEY, &username_); + map.getValue(PASSWORD_KEY, &password_); + map.getValue(HOSTNAME_KEY, &hostname_); + map.getValue(ACCOUNT_ENABLE_KEY, &enabled_); + map.getValue(MAILBOX_KEY, &mailBox_); + map.getValue(CODECS_KEY, &codecStr_); // Update codec list which one is used for SDP offer setActiveCodecs(ManagerImpl::unserialize(codecStr_)); - map->getValue(DISPLAY_NAME_KEY, &displayName_); + map.getValue(DISPLAY_NAME_KEY, &displayName_); } void IAXAccount::setAccountDetails(std::map<std::string, std::string> details) diff --git a/daemon/src/iax/iaxaccount.h b/daemon/src/iax/iaxaccount.h index 32a9c20aed30cba5f54192e6c6e5b509fbcb2731..8d2e4fd770ed31590a0fee7eca5c2ed734cdecef 100644 --- a/daemon/src/iax/iaxaccount.h +++ b/daemon/src/iax/iaxaccount.h @@ -45,8 +45,8 @@ class IAXAccount : public Account { IAXAccount(const std::string& accountID); ~IAXAccount(); - virtual void serialize(Conf::YamlEmitter *emitter); - virtual void unserialize(const Conf::MappingNode *map); + virtual void serialize(Conf::YamlEmitter &emitter); + virtual void unserialize(const Conf::MappingNode &map); void setAccountDetails(std::map<std::string, std::string> details); diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp index cfa3965a37a43424101234405214b2cf8d7feb04..c7ee17c1267bd7ab587ff2d7216b0163f09164e1 100644 --- a/daemon/src/managerimpl.cpp +++ b/daemon/src/managerimpl.cpp @@ -1243,14 +1243,14 @@ void ManagerImpl::saveConfig() Conf::YamlEmitter emitter(path_.c_str()); for (AccountMap::iterator iter = accountMap_.begin(); iter != accountMap_.end(); ++iter) - iter->second->serialize(&emitter); + iter->second->serialize(emitter); - preferences.serialize(&emitter); - voipPreferences.serialize(&emitter); - addressbookPreference.serialize(&emitter); - hookPreference.serialize(&emitter); - audioPreference.serialize(&emitter); - shortcutPreferences.serialize(&emitter); + preferences.serialize(emitter); + voipPreferences.serialize(emitter); + addressbookPreference.serialize(emitter); + hookPreference.serialize(emitter); + audioPreference.serialize(emitter); + shortcutPreferences.serialize(emitter); emitter.serializeData(); } catch (const Conf::YamlEmitterException &e) { @@ -2570,6 +2570,11 @@ namespace { void loadAccount(const Conf::YamlNode *item, AccountMap &accountMap) { const Conf::MappingNode *node = dynamic_cast<const Conf::MappingNode *>(item); + if (!node) { + ERROR("ManagerImpl: could not load account"); + return; + } + std::string accountType; node->getValue("type", &accountType); @@ -2589,7 +2594,7 @@ namespace { a = new SIPAccount(accountid); accountMap[accountid] = a; - a->unserialize(node); + a->unserialize(*node); } } @@ -2626,12 +2631,12 @@ void ManagerImpl::loadAccountMap(Conf::YamlParser &parser) accountMap_[SIPAccount::IP2IP_PROFILE]->registerVoIPLink(); // build preferences - preferences.unserialize(parser.getPreferenceNode()); - voipPreferences.unserialize(parser.getVoipPreferenceNode()); - addressbookPreference.unserialize(parser.getAddressbookNode()); - hookPreference.unserialize(parser.getHookNode()); - audioPreference.unserialize(parser.getAudioNode()); - shortcutPreferences.unserialize(parser.getShortcutNode()); + preferences.unserialize(*parser.getPreferenceNode()); + voipPreferences.unserialize(*parser.getVoipPreferenceNode()); + addressbookPreference.unserialize(*parser.getAddressbookNode()); + hookPreference.unserialize(*parser.getHookNode()); + audioPreference.unserialize(*parser.getAudioNode()); + shortcutPreferences.unserialize(*parser.getShortcutNode()); using namespace std::tr1; // for std::tr1::bind and std::tr1::ref using namespace std::tr1::placeholders; diff --git a/daemon/src/preferences.cpp b/daemon/src/preferences.cpp index aa7afc70cb2fb17c6d09fe8520a1d1000aa7500d..18e803ed90538543c1e839e0c7586f2e0b0785a7 100644 --- a/daemon/src/preferences.cpp +++ b/daemon/src/preferences.cpp @@ -38,7 +38,6 @@ #include "sip/sip_utils.h" #include <sstream> #include "global.h" -#include <cassert> const char * const Preferences::DFT_ZONE = "North America"; const char * const Preferences::REGISTRATION_EXPIRE_KEY = "registrationexpire"; @@ -114,7 +113,8 @@ static const char * const DFT_VOL_SPKR_STR = "100"; /** Default speaker volu static const char * const DFT_VOL_MICRO_STR = "100"; /** Default mic volume */ } // end anonymous namespace -Preferences::Preferences() : accountOrder_("") +Preferences::Preferences() : + accountOrder_("") , historyLimit_(30) , historyMaxCalls_(20) , notifyMails_(false) @@ -126,7 +126,7 @@ Preferences::Preferences() : accountOrder_("") , md5Hash_(false) {} -void Preferences::serialize(Conf::YamlEmitter *emiter) +void Preferences::serialize(Conf::YamlEmitter &emiter) { Conf::MappingNode preferencemap(NULL); @@ -160,36 +160,32 @@ void Preferences::serialize(Conf::YamlEmitter *emiter) preferencemap.setKeyValue(ZEROCONF_ENABLE_KEY, &zeroConfenable); preferencemap.setKeyValue(MD5_HASH_KEY, &md5Hash); - emiter->serializePreference(&preferencemap, "preferences"); + emiter.serializePreference(&preferencemap, "preferences"); } -void Preferences::unserialize(const Conf::MappingNode *map) +void Preferences::unserialize(const Conf::MappingNode &map) { - if (map == NULL) { - ERROR("Preference: Error: Preference map is NULL"); - return; - } - - map->getValue(ORDER_KEY, &accountOrder_); - map->getValue(HISTORY_LIMIT_KEY, &historyLimit_); - map->getValue(HISTORY_MAX_CALLS_KEY, &historyMaxCalls_); - map->getValue(NOTIFY_MAILS_KEY, ¬ifyMails_); - map->getValue(ZONE_TONE_CHOICE_KEY, &zoneToneChoice_); - map->getValue(REGISTRATION_EXPIRE_KEY, ®istrationExpire_); - map->getValue(PORT_NUM_KEY, &portNum_); - map->getValue(SEARCH_BAR_DISPLAY_KEY, &searchBarDisplay_); - map->getValue(ZEROCONF_ENABLE_KEY, &zeroConfenable_); - map->getValue(MD5_HASH_KEY, &md5Hash_); + map.getValue(ORDER_KEY, &accountOrder_); + map.getValue(HISTORY_LIMIT_KEY, &historyLimit_); + map.getValue(HISTORY_MAX_CALLS_KEY, &historyMaxCalls_); + map.getValue(NOTIFY_MAILS_KEY, ¬ifyMails_); + map.getValue(ZONE_TONE_CHOICE_KEY, &zoneToneChoice_); + map.getValue(REGISTRATION_EXPIRE_KEY, ®istrationExpire_); + map.getValue(PORT_NUM_KEY, &portNum_); + map.getValue(SEARCH_BAR_DISPLAY_KEY, &searchBarDisplay_); + map.getValue(ZEROCONF_ENABLE_KEY, &zeroConfenable_); + map.getValue(MD5_HASH_KEY, &md5Hash_); } -VoipPreference::VoipPreference() : playDtmf_(true) +VoipPreference::VoipPreference() : + playDtmf_(true) , playTones_(true) , pulseLength_(atoi(DFT_PULSE_LENGTH_STR)) , symmetricRtp_(true) , zidFile_(ZRTP_ZIDFILE) {} -void VoipPreference::serialize(Conf::YamlEmitter *emitter) +void VoipPreference::serialize(Conf::YamlEmitter &emitter) { Conf::MappingNode preferencemap(NULL); @@ -207,21 +203,16 @@ void VoipPreference::serialize(Conf::YamlEmitter *emitter) preferencemap.setKeyValue(SYMMETRIC_RTP_KEY, &symmetricRtp); preferencemap.setKeyValue(ZID_FILE_KEY, &zidFile); - emitter->serializePreference(&preferencemap, "voipPreferences"); + emitter.serializePreference(&preferencemap, "voipPreferences"); } -void VoipPreference::unserialize(const Conf::MappingNode *map) +void VoipPreference::unserialize(const Conf::MappingNode &map) { - if (!map) { - ERROR("VoipPreference: Error: Preference map is NULL"); - return; - } - - map->getValue(PLAY_DTMF_KEY, &playDtmf_); - map->getValue(PLAY_TONES_KEY, &playTones_); - map->getValue(PULSE_LENGTH_KEY, &pulseLength_); - map->getValue(SYMMETRIC_RTP_KEY, &symmetricRtp_); - map->getValue(ZID_FILE_KEY, &zidFile_); + map.getValue(PLAY_DTMF_KEY, &playDtmf_); + map.getValue(PLAY_TONES_KEY, &playTones_); + map.getValue(PULSE_LENGTH_KEY, &pulseLength_); + map.getValue(SYMMETRIC_RTP_KEY, &symmetricRtp_); + map.getValue(ZID_FILE_KEY, &zidFile_); } AddressbookPreference::AddressbookPreference() : photo_(true) @@ -233,7 +224,7 @@ AddressbookPreference::AddressbookPreference() : photo_(true) , mobile_(true) {} -void AddressbookPreference::serialize(Conf::YamlEmitter *emitter) +void AddressbookPreference::serialize(Conf::YamlEmitter &emitter) { Conf::MappingNode preferencemap(NULL); @@ -255,27 +246,22 @@ void AddressbookPreference::serialize(Conf::YamlEmitter *emitter) preferencemap.setKeyValue(HOME_KEY, &home); preferencemap.setKeyValue(MOBILE_KEY, &mobile); - emitter->serializePreference(&preferencemap, "addressbook"); - + emitter.serializePreference(&preferencemap, "addressbook"); } -void AddressbookPreference::unserialize(const Conf::MappingNode *map) +void AddressbookPreference::unserialize(const Conf::MappingNode &map) { - if (!map) { - ERROR("Addressbook: Error: Preference map is NULL"); - return; - } - - map->getValue(PHOTO_KEY, &photo_); - map->getValue(ENABLED_KEY, &enabled_); - map->getValue(LIST_KEY, &list_); - map->getValue(MAX_RESULTS_KEY, &maxResults_); - map->getValue(BUSINESS_KEY, &business_); - map->getValue(HOME_KEY, &home_); - map->getValue(MOBILE_KEY, &mobile_); + map.getValue(PHOTO_KEY, &photo_); + map.getValue(ENABLED_KEY, &enabled_); + map.getValue(LIST_KEY, &list_); + map.getValue(MAX_RESULTS_KEY, &maxResults_); + map.getValue(BUSINESS_KEY, &business_); + map.getValue(HOME_KEY, &home_); + map.getValue(MOBILE_KEY, &mobile_); } -HookPreference::HookPreference() : iax2Enabled_(false) +HookPreference::HookPreference() : + iax2Enabled_(false) , numberAddPrefix_("") , numberEnabled_(false) , sipEnabled_(false) @@ -305,7 +291,7 @@ std::map<std::string, std::string> HookPreference::toMap() const return settings; } -void HookPreference::serialize(Conf::YamlEmitter *emitter) +void HookPreference::serialize(Conf::YamlEmitter &emitter) { Conf::MappingNode preferencemap(NULL); @@ -323,22 +309,17 @@ void HookPreference::serialize(Conf::YamlEmitter *emitter) preferencemap.setKeyValue(URL_COMMAND_KEY, &urlCommand); preferencemap.setKeyValue(URL_SIP_FIELD_KEY, &urlSipField); - emitter->serializePreference(&preferencemap, "hooks"); + emitter.serializePreference(&preferencemap, "hooks"); } -void HookPreference::unserialize(const Conf::MappingNode *map) +void HookPreference::unserialize(const Conf::MappingNode &map) { - if (!map) { - ERROR("Hook: Error: Preference map is NULL"); - return; - } - - map->getValue(IAX2_ENABLED_KEY, &iax2Enabled_); - map->getValue(NUMBER_ADD_PREFIX_KEY, &numberAddPrefix_); - map->getValue(NUMBER_ENABLED_KEY, &numberEnabled_); - map->getValue(SIP_ENABLED_KEY, &sipEnabled_); - map->getValue(URL_COMMAND_KEY, &urlCommand_); - map->getValue(URL_SIP_FIELD_KEY, &urlSipField_); + map.getValue(IAX2_ENABLED_KEY, &iax2Enabled_); + map.getValue(NUMBER_ADD_PREFIX_KEY, &numberAddPrefix_); + map.getValue(NUMBER_ENABLED_KEY, &numberEnabled_); + map.getValue(SIP_ENABLED_KEY, &sipEnabled_); + map.getValue(URL_COMMAND_KEY, &urlCommand_); + map.getValue(URL_SIP_FIELD_KEY, &urlSipField_); } void HookPreference::runHook(pjsip_msg *msg) @@ -351,18 +332,18 @@ void HookPreference::runHook(pjsip_msg *msg) AudioPreference::AudioPreference() : audioApi_(PULSEAUDIO_API_STR) - , cardin_(atoi(ALSA_DFT_CARD)) // ALSA_DFT_CARD - , cardout_(atoi(ALSA_DFT_CARD)) // ALSA_DFT_CARD - , cardring_(atoi(ALSA_DFT_CARD)) // ALSA_DFT_CARD - , plugin_("default") // PCM_DEFAULT - , smplrate_(44100) // DFT_SAMPLE_RATE + , cardin_(atoi(ALSA_DFT_CARD)) + , cardout_(atoi(ALSA_DFT_CARD)) + , cardring_(atoi(ALSA_DFT_CARD)) + , plugin_("default") + , smplrate_(44100) , devicePlayback_("") , deviceRecord_("") , deviceRingtone_("") - , recordpath_("") // DFT_RECORD_PATH + , recordpath_("") , alwaysRecording_(false) - , volumemic_(atoi(DFT_VOL_SPKR_STR)) // DFT_VOL_SPKR_STR - , volumespkr_(atoi(DFT_VOL_MICRO_STR)) // DFT_VOL_MICRO_STR + , volumemic_(atoi(DFT_VOL_SPKR_STR)) + , volumespkr_(atoi(DFT_VOL_MICRO_STR)) , noisereduce_(true) , echocancel_(false) , echoCancelTailLength_(100) @@ -402,7 +383,7 @@ AudioLayer* AudioPreference::switchAndCreateAudioLayer() return createAudioLayer(); } -void AudioPreference::serialize(Conf::YamlEmitter *emitter) +void AudioPreference::serialize(Conf::YamlEmitter &emitter) { Conf::MappingNode preferencemap(NULL); Conf::MappingNode alsapreferencemap(NULL); @@ -471,22 +452,20 @@ void AudioPreference::serialize(Conf::YamlEmitter *emitter) preferencemap.setKeyValue(ECHO_TAIL_KEY, &echotail); preferencemap.setKeyValue(ECHO_DELAY_KEY, &echodelay); - emitter->serializePreference(&preferencemap, "audio"); + emitter.serializePreference(&preferencemap, "audio"); } -void AudioPreference::unserialize(const Conf::MappingNode *map) +void AudioPreference::unserialize(const Conf::MappingNode &map) { - assert(map); + map.getValue(AUDIO_API_KEY, &audioApi_); + map.getValue(RECORDPATH_KEY, &recordpath_); + map.getValue(ALWAYS_RECORDING_KEY, &alwaysRecording_); + map.getValue(VOLUMEMIC_KEY, &volumemic_); + map.getValue(VOLUMESPKR_KEY, &volumespkr_); + map.getValue(NOISE_REDUCE_KEY, &noisereduce_); + map.getValue(ECHO_CANCEL_KEY, &echocancel_); - map->getValue(AUDIO_API_KEY, &audioApi_); - map->getValue(RECORDPATH_KEY, &recordpath_); - map->getValue(ALWAYS_RECORDING_KEY, &alwaysRecording_); - map->getValue(VOLUMEMIC_KEY, &volumemic_); - map->getValue(VOLUMESPKR_KEY, &volumespkr_); - map->getValue(NOISE_REDUCE_KEY, &noisereduce_); - map->getValue(ECHO_CANCEL_KEY, &echocancel_); - - Conf::MappingNode *alsamap =(Conf::MappingNode *)(map->getValue("alsa")); + Conf::MappingNode *alsamap =(Conf::MappingNode *) map.getValue("alsa"); if (alsamap) { alsamap->getValue(CARDIN_KEY, &cardin_); @@ -496,7 +475,7 @@ void AudioPreference::unserialize(const Conf::MappingNode *map) alsamap->getValue(PLUGIN_KEY, &plugin_); } - Conf::MappingNode *pulsemap =(Conf::MappingNode *)(map->getValue("pulse")); + Conf::MappingNode *pulsemap =(Conf::MappingNode *)(map.getValue("pulse")); if (pulsemap) { pulsemap->getValue(DEVICE_PLAYBACK_KEY, &devicePlayback_); @@ -532,7 +511,7 @@ void ShortcutPreferences::setShortcuts(std::map<std::string, std::string> map) } -void ShortcutPreferences::serialize(Conf::YamlEmitter *emitter) +void ShortcutPreferences::serialize(Conf::YamlEmitter &emitter) { Conf::MappingNode preferencemap(NULL); @@ -548,20 +527,15 @@ void ShortcutPreferences::serialize(Conf::YamlEmitter *emitter) preferencemap.setKeyValue(TOGGLE_HOLD_SHORT_KEY, &toggleHold); preferencemap.setKeyValue(TOGGLE_PICKUP_HANGUP_SHORT_KEY, &togglePickupHangup); - emitter->serializePreference(&preferencemap, "shortcuts"); + emitter.serializePreference(&preferencemap, "shortcuts"); } -void ShortcutPreferences::unserialize(const Conf::MappingNode *map) +void ShortcutPreferences::unserialize(const Conf::MappingNode &map) { - if (map == NULL) { - ERROR("ShortcutPreference: Error: Preference map is NULL"); - return; - } - - map->getValue(HANGUP_SHORT_KEY, &hangup_); - map->getValue(PICKUP_SHORT_KEY, &pickup_); - map->getValue(POPUP_SHORT_KEY, &popup_); - map->getValue(TOGGLE_HOLD_SHORT_KEY, &toggleHold_); - map->getValue(TOGGLE_PICKUP_HANGUP_SHORT_KEY, &togglePickupHangup_); + map.getValue(HANGUP_SHORT_KEY, &hangup_); + map.getValue(PICKUP_SHORT_KEY, &pickup_); + map.getValue(POPUP_SHORT_KEY, &popup_); + map.getValue(TOGGLE_HOLD_SHORT_KEY, &toggleHold_); + map.getValue(TOGGLE_PICKUP_HANGUP_SHORT_KEY, &togglePickupHangup_); } diff --git a/daemon/src/preferences.h b/daemon/src/preferences.h index b9efabf7c6889253059767ea031cdd000c0a5155..2dc73f4187f43ef7b5a03b50836e0356f9b9b168 100644 --- a/daemon/src/preferences.h +++ b/daemon/src/preferences.h @@ -44,9 +44,8 @@ class Preferences : public Serializable { Preferences(); - virtual void serialize(Conf::YamlEmitter *emitter); - - virtual void unserialize(const Conf::MappingNode *map); + virtual void serialize(Conf::YamlEmitter &emitter); + virtual void unserialize(const Conf::MappingNode &map); std::string getAccountOrder() const { return accountOrder_; @@ -143,9 +142,8 @@ class VoipPreference : public Serializable { public: VoipPreference(); - virtual void serialize(Conf::YamlEmitter *emitter); - - virtual void unserialize(const Conf::MappingNode *map); + virtual void serialize(Conf::YamlEmitter &emitter); + virtual void unserialize(const Conf::MappingNode &map); bool getPlayDtmf() const { return playDtmf_; @@ -198,9 +196,8 @@ class AddressbookPreference : public Serializable { public: AddressbookPreference(); - virtual void serialize(Conf::YamlEmitter *emitter); - - virtual void unserialize(const Conf::MappingNode *map); + virtual void serialize(Conf::YamlEmitter &emitter); + virtual void unserialize(const Conf::MappingNode &map); bool getPhoto() const { return photo_; @@ -275,9 +272,8 @@ class HookPreference : public Serializable { HookPreference(); HookPreference(const std::map<std::string, std::string> &settings); - virtual void serialize(Conf::YamlEmitter *emitter); - - virtual void unserialize(const Conf::MappingNode *map); + virtual void serialize(Conf::YamlEmitter &emitter); + virtual void unserialize(const Conf::MappingNode &map); std::string getNumberAddPrefix() const { if (numberEnabled_) @@ -312,9 +308,8 @@ class AudioPreference : public Serializable { audioApi_ = api; } - virtual void serialize(Conf::YamlEmitter *emitter); - - virtual void unserialize(const Conf::MappingNode *map); + virtual void serialize(Conf::YamlEmitter &emitter); + virtual void unserialize(const Conf::MappingNode &map); // alsa preference int getCardin() const { @@ -471,8 +466,8 @@ class AudioPreference : public Serializable { class ShortcutPreferences : public Serializable { public: ShortcutPreferences(); - virtual void serialize(Conf::YamlEmitter *emitter); - virtual void unserialize(const Conf::MappingNode *map); + virtual void serialize(Conf::YamlEmitter &emitter); + virtual void unserialize(const Conf::MappingNode &map); void setShortcuts(std::map<std::string, std::string> shortcuts); std::map<std::string, std::string> getShortcuts() const; diff --git a/daemon/src/sip/sipaccount.cpp b/daemon/src/sip/sipaccount.cpp index fab7291faba1e5228e618b487452d1cfc278330f..66cfcfc64d01b12240a4a029ce25c4a6d913511a 100644 --- a/daemon/src/sip/sipaccount.cpp +++ b/daemon/src/sip/sipaccount.cpp @@ -101,7 +101,7 @@ SIPAccount::SIPAccount(const std::string& accountID) , link_(SIPVoIPLink::instance()) {} -void SIPAccount::serialize(Conf::YamlEmitter *emitter) +void SIPAccount::serialize(Conf::YamlEmitter &emitter) { using namespace Conf; MappingNode accountmap(NULL); @@ -232,7 +232,7 @@ void SIPAccount::serialize(Conf::YamlEmitter *emitter) tlsmap.setKeyValue(VERIFY_SERVER_KEY, &verifyserver); try { - emitter->serializeAccount(&accountmap); + emitter.serializeAccount(&accountmap); } catch (const YamlEmitterException &e) { ERROR("ConfigTree: %s", e.what()); } @@ -251,56 +251,54 @@ void SIPAccount::serialize(Conf::YamlEmitter *emitter) } -void SIPAccount::unserialize(const Conf::MappingNode *map) +void SIPAccount::unserialize(const Conf::MappingNode &map) { using namespace Conf; MappingNode *srtpMap; MappingNode *tlsMap; MappingNode *zrtpMap; - assert(map); - - map->getValue(ALIAS_KEY, &alias_); - map->getValue(TYPE_KEY, &type_); - map->getValue(USERNAME_KEY, &username_); - map->getValue(HOSTNAME_KEY, &hostname_); - map->getValue(ACCOUNT_ENABLE_KEY, &enabled_); - map->getValue(MAILBOX_KEY, &mailBox_); - map->getValue(CODECS_KEY, &codecStr_); + map.getValue(ALIAS_KEY, &alias_); + map.getValue(TYPE_KEY, &type_); + map.getValue(USERNAME_KEY, &username_); + map.getValue(HOSTNAME_KEY, &hostname_); + map.getValue(ACCOUNT_ENABLE_KEY, &enabled_); + map.getValue(MAILBOX_KEY, &mailBox_); + map.getValue(CODECS_KEY, &codecStr_); // Update codec list which one is used for SDP offer setActiveCodecs(ManagerImpl::unserialize(codecStr_)); - map->getValue(RINGTONE_PATH_KEY, &ringtonePath_); - map->getValue(RINGTONE_ENABLED_KEY, &ringtoneEnabled_); - map->getValue(Preferences::REGISTRATION_EXPIRE_KEY, ®istrationExpire_); - map->getValue(INTERFACE_KEY, &interface_); + map.getValue(RINGTONE_PATH_KEY, &ringtonePath_); + map.getValue(RINGTONE_ENABLED_KEY, &ringtoneEnabled_); + map.getValue(Preferences::REGISTRATION_EXPIRE_KEY, ®istrationExpire_); + map.getValue(INTERFACE_KEY, &interface_); int port; - map->getValue(PORT_KEY, &port); + map.getValue(PORT_KEY, &port); localPort_ = port; - map->getValue(PUBLISH_ADDR_KEY, &publishedIpAddress_); - map->getValue(PUBLISH_PORT_KEY, &port); + map.getValue(PUBLISH_ADDR_KEY, &publishedIpAddress_); + map.getValue(PUBLISH_PORT_KEY, &port); publishedPort_ = port; - map->getValue(SAME_AS_LOCAL_KEY, &publishedSameasLocal_); + map.getValue(SAME_AS_LOCAL_KEY, &publishedSameasLocal_); std::string dtmfType; - map->getValue(DTMF_TYPE_KEY, &dtmfType); + map.getValue(DTMF_TYPE_KEY, &dtmfType); dtmfType_ = dtmfType; - map->getValue(SERVICE_ROUTE_KEY, &serviceRoute_); - map->getValue(UPDATE_CONTACT_HEADER_KEY, &contactUpdateEnabled_); + map.getValue(SERVICE_ROUTE_KEY, &serviceRoute_); + map.getValue(UPDATE_CONTACT_HEADER_KEY, &contactUpdateEnabled_); // stun enabled - map->getValue(STUN_ENABLED_KEY, &stunEnabled_); - map->getValue(STUN_SERVER_KEY, &stunServer_); + map.getValue(STUN_ENABLED_KEY, &stunEnabled_); + map.getValue(STUN_SERVER_KEY, &stunServer_); // Init stun server name with default server name stunServerName_ = pj_str((char*) stunServer_.data()); - map->getValue(DISPLAY_NAME_KEY, &displayName_); + map.getValue(DISPLAY_NAME_KEY, &displayName_); std::vector<std::map<std::string, std::string> > creds; - YamlNode *credNode = map->getValue(CRED_KEY); + YamlNode *credNode = map.getValue(CRED_KEY); /* We check if the credential key is a sequence * because it was a mapping in a previous version of @@ -331,7 +329,7 @@ void SIPAccount::unserialize(const Conf::MappingNode *map) // migration from old file format std::map<std::string, std::string> credmap; std::string password; - map->getValue(PASSWORD_KEY, &password); + map.getValue(PASSWORD_KEY, &password); credmap[CONFIG_ACCOUNT_USERNAME] = username_; credmap[CONFIG_ACCOUNT_PASSWORD] = password; @@ -342,7 +340,7 @@ void SIPAccount::unserialize(const Conf::MappingNode *map) setCredentials(creds); // get srtp submap - srtpMap = (MappingNode *)(map->getValue(SRTP_KEY)); + srtpMap = (MappingNode *)(map.getValue(SRTP_KEY)); if (srtpMap) { srtpMap->getValue(SRTP_ENABLE_KEY, &srtpEnabled_); @@ -351,7 +349,7 @@ void SIPAccount::unserialize(const Conf::MappingNode *map) } // get zrtp submap - zrtpMap = (MappingNode *)(map->getValue(ZRTP_KEY)); + zrtpMap = (MappingNode *)(map.getValue(ZRTP_KEY)); if (zrtpMap) { zrtpMap->getValue(DISPLAY_SAS_KEY, &zrtpDisplaySas_); @@ -361,7 +359,7 @@ void SIPAccount::unserialize(const Conf::MappingNode *map) } // get tls submap - tlsMap = (MappingNode *)(map->getValue(TLS_KEY)); + tlsMap = (MappingNode *)(map.getValue(TLS_KEY)); if (tlsMap) { tlsMap->getValue(TLS_ENABLE_KEY, &tlsEnable_); diff --git a/daemon/src/sip/sipaccount.h b/daemon/src/sip/sipaccount.h index 9fdf211aee70a0eff0c84bc2b4b394cb32ec5831..2e406363ae8119b08202fbc00709c226348f56f0 100644 --- a/daemon/src/sip/sipaccount.h +++ b/daemon/src/sip/sipaccount.h @@ -125,13 +125,13 @@ class SIPAccount : public Account { * Serialize internal state of this account for configuration * @param YamlEmitter the configuration engine which generate the configuration file */ - virtual void serialize(Conf::YamlEmitter *emitter); + virtual void serialize(Conf::YamlEmitter &emitter); /** * Populate the internal state for this account based on info stored in the configuration file * @param The configuration node for this account */ - virtual void unserialize(const Conf::MappingNode *map); + virtual void unserialize(const Conf::MappingNode &map); /** * Set the internal state for this account, mainly used to manage account details from the client application.