From 8b1ffdb5d93524826774b191525d04834b1e78e8 Mon Sep 17 00:00:00 2001 From: chrisparker126 Date: Tue, 21 Sep 2010 22:02:35 +0000 Subject: [PATCH] fixed transitioning of msg service config files from global signature format git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3522 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/pqi/p3cfgmgr.cc | 30 +++++++++++++++++++++++++++--- libretroshare/src/pqi/p3cfgmgr.h | 3 +++ libretroshare/src/pqi/pqiarchive.h | 2 +- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/libretroshare/src/pqi/p3cfgmgr.cc b/libretroshare/src/pqi/p3cfgmgr.cc index 9ce964f73..6a21901c6 100644 --- a/libretroshare/src/pqi/p3cfgmgr.cc +++ b/libretroshare/src/pqi/p3cfgmgr.cc @@ -29,6 +29,7 @@ #include "pqi/authssl.h" #include "pqi/pqibin.h" #include "pqi/pqistore.h" +#include "pqi/pqiarchive.h" #include "pqi/pqinotify.h" #include #include @@ -820,10 +821,32 @@ bool p3Config::getHashAttempt(const std::string& loadHash, std::string& hashstr, uint32_t stream_flags = BIN_FLAGS_READABLE; BinInterface *bio = new BinFileInterface(cfg_fname.c_str(), bioflags); - pqistore stream(setupSerialiser(), "CONFIG", bio, stream_flags); + PQInterface *stream = NULL; + + std::string tempString, msgConfigFileName; + std::string::reverse_iterator rit = Filename().rbegin(); + + + // get the msgconfig file name + for(int i =0; (i <= 7) && (rit != Filename().rend()); i++) + { + tempString.push_back(*rit); + rit++; + } + + rit = tempString.rbegin(); + + for(; rit !=tempString.rend(); rit++) + msgConfigFileName.push_back(*rit); + + if(msgConfigFileName == "msgs.cfg") + stream = new pqiarchive(setupSerialiser(), bio, bioflags); + else + stream = new pqistore(setupSerialiser(), "CONFIG", bio, bioflags); + RsItem *item = NULL; - while(NULL != (item = stream.GetItem())) + while(NULL != (item = stream->GetItem())) { #ifdef CONFIG_DEBUG std::cerr << "p3Config::loadConfiguration() loaded item:"; @@ -862,7 +885,8 @@ bool p3Config::getHashAttempt(const std::string& loadHash, std::string& hashstr, return false; } - //delete bio; + + delete stream; return true; } diff --git a/libretroshare/src/pqi/p3cfgmgr.h b/libretroshare/src/pqi/p3cfgmgr.h index 745df8cd9..84e06d6ab 100644 --- a/libretroshare/src/pqi/p3cfgmgr.h +++ b/libretroshare/src/pqi/p3cfgmgr.h @@ -325,6 +325,9 @@ virtual RsSerialiser *setupSerialiser() = 0; /** * saves list of derived object + * @param cleanup this inform you if you need to call saveDone() to unlock/allow + * access to resources pointed to by handles (list) returned by function: thus false, call saveDone after returned list finished with + * and vice versa * @return list of config items derived object wants to saves */ virtual std::list saveList(bool &cleanup) = 0; diff --git a/libretroshare/src/pqi/pqiarchive.h b/libretroshare/src/pqi/pqiarchive.h index 830bf3449..1c329bd33 100644 --- a/libretroshare/src/pqi/pqiarchive.h +++ b/libretroshare/src/pqi/pqiarchive.h @@ -41,7 +41,7 @@ * */ -class pqiarchive: PQInterface +class pqiarchive: public PQInterface { public: pqiarchive(RsSerialiser *rss, BinInterface *bio_in, int bio_flagsin);