From b348e1aae5a01f829cbfdb836aabd178301ead2e Mon Sep 17 00:00:00 2001 From: Alexandre Savard <alexandre.savard@savoirfairelinux.com> Date: Wed, 7 Jul 2010 18:19:01 -0400 Subject: [PATCH] [#3648] Implement save configuration method --- sflphone-common/src/managerimpl.cpp | 22 ++++++++++++++++++++++ sflphone-common/src/managerimpl.h | 2 ++ sflphone-common/src/sip/sipaccount.cpp | 8 +++++++- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index 5d0b79c92f..bc208691da 100755 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -1413,6 +1413,28 @@ bool ManagerImpl::saveConfig (void) { setConfig(AUDIO, VOLUME_SPKR, getSpkrVolume()); setConfig(AUDIO, VOLUME_MICRO, getMicVolume()); + AccountMap::iterator iter = _accountMap.begin(); + + try{ + emitter = new Conf::YamlEmitter("/tmp/sequenceEmiter.txt"); + + // emitter->writeAccount(&accountmap); + // emitter->writeAccount(&accountmap); + emitter->serializeData(); + + while(iter != _accountMap.end()) { + iter->second->serialize(emitter); + iter++; + } + + preferences.serialize(emitter); + + delete emitter; + } + catch (Conf::YamlEmitterException &e) { + _error("ConfigTree: %s", e.what()); + } + _setupLoaded = _config.saveConfigTree(_path.data()); return _setupLoaded; } diff --git a/sflphone-common/src/managerimpl.h b/sflphone-common/src/managerimpl.h index 608f369524..1f79de5c5d 100755 --- a/sflphone-common/src/managerimpl.h +++ b/sflphone-common/src/managerimpl.h @@ -55,6 +55,7 @@ #include "audio/codecs/codecDescriptor.h" // CodecDescriptor class contained by value here #include "audio/mainbuffer.h" +#include "yamlemitter.h" #include "yamlparser.h" #include "preferences.h" @@ -1347,6 +1348,7 @@ private: void check_call_configuration (const CallID& id, const std::string& to, Call::CallConfiguration *callConfig); Conf::YamlParser *parser; + Conf::YamlEmitter *emitter; #ifdef TEST bool testCallAccountMap(); diff --git a/sflphone-common/src/sip/sipaccount.cpp b/sflphone-common/src/sip/sipaccount.cpp index 699e21f2a6..49667c5105 100755 --- a/sflphone-common/src/sip/sipaccount.cpp +++ b/sflphone-common/src/sip/sipaccount.cpp @@ -134,6 +134,8 @@ SIPAccount::~SIPAccount() void SIPAccount::serialize(Conf::YamlEmitter *emitter) { + _debug("SipAccount: serialize %s", _accountID.c_str()); + Conf::MappingNode accountmap(NULL); Conf::MappingNode credentialmap(NULL); @@ -152,6 +154,7 @@ void SIPAccount::serialize(Conf::YamlEmitter *emitter) { Conf::ScalarNode interface(_interface); std::stringstream portstr; portstr << _localPort; Conf::ScalarNode port(portstr.str()); + Conf::ScalarNode mailbox("97"); Conf::ScalarNode publishAddr(_publishedIpAddress); std::stringstream publicportstr; publicportstr << _publishedPort; @@ -166,7 +169,7 @@ void SIPAccount::serialize(Conf::YamlEmitter *emitter) { std::stringstream countstr; countstr << _credentialCount; Conf::ScalarNode count(countstr.str()); - + Conf::ScalarNode srtpenabled(_srtpEnabled ? "true" : "false"); Conf::ScalarNode keyExchange(_srtpKeyExchange); Conf::ScalarNode rtpFallback(_srtpFallback ? "true" : "false"); @@ -496,6 +499,9 @@ int SIPAccount::registerVoIPLink() _transportType = PJSIP_TRANSPORT_START_OTHER; initStunConfiguration (); } + else { + _stunServerName = pj_str ((char*) _stunServer.data()); + } // In our definition of the // ip2ip profile (aka Direct IP Calls), -- GitLab