From c33c34b17527081b15abcbd6d9622f4ccfa6643e Mon Sep 17 00:00:00 2001 From: csoler Date: Fri, 28 Apr 2017 16:44:04 +0200 Subject: [PATCH] moved rspluginitems to rsitems/ --- libretroshare/src/libretroshare.pro | 5 +- libretroshare/src/plugins/pluginmanager.cc | 5 +- .../{serialiser => rsitems}/rspluginitems.h | 0 libretroshare/src/serialiser/rspluginitems.cc | 135 ------------------ 4 files changed, 4 insertions(+), 141 deletions(-) rename libretroshare/src/{serialiser => rsitems}/rspluginitems.h (100%) delete mode 100644 libretroshare/src/serialiser/rspluginitems.cc diff --git a/libretroshare/src/libretroshare.pro b/libretroshare/src/libretroshare.pro index ca5a07442..2b7a1b96f 100644 --- a/libretroshare/src/libretroshare.pro +++ b/libretroshare/src/libretroshare.pro @@ -143,7 +143,7 @@ PUBLIC_HEADERS = retroshare/rsdisc.h \ HEADERS += plugins/pluginmanager.h \ plugins/dlfcn_win32.h \ - serialiser/rspluginitems.h \ + rsitems/rspluginitems.h \ util/rsinitedptr.h HEADERS += $$PUBLIC_HEADERS @@ -605,8 +605,7 @@ SOURCES += grouter/p3grouter.cc \ grouter/groutermatrix.cc SOURCES += plugins/pluginmanager.cc \ - plugins/dlfcn_win32.cc \ - serialiser/rspluginitems.cc + plugins/dlfcn_win32.cc SOURCES += serialiser/rsbaseserial.cc \ rsitems/rsfiletransferitems.cc \ diff --git a/libretroshare/src/plugins/pluginmanager.cc b/libretroshare/src/plugins/pluginmanager.cc index 431b6c2f8..bbc1761fb 100644 --- a/libretroshare/src/plugins/pluginmanager.cc +++ b/libretroshare/src/plugins/pluginmanager.cc @@ -9,8 +9,7 @@ #include #endif -#include - +#include #include #include @@ -34,7 +33,7 @@ std::string RsPluginManager::_plugin_entry_symbol = "RETROSHARE_PLUGIN_provide" ; std::string RsPluginManager::_plugin_revision_symbol = "RETROSHARE_PLUGIN_revision" ; -std::string RsPluginManager::_plugin_API_symbol = "RETROSHARE_PLUGIN_api" ; +std::string RsPluginManager::_plugin_API_symbol = "RETROSHARE_PLUGIN_api" ; std::string RsPluginManager::_local_cache_dir ; std::string RsPluginManager::_remote_cache_dir ; diff --git a/libretroshare/src/serialiser/rspluginitems.h b/libretroshare/src/rsitems/rspluginitems.h similarity index 100% rename from libretroshare/src/serialiser/rspluginitems.h rename to libretroshare/src/rsitems/rspluginitems.h diff --git a/libretroshare/src/serialiser/rspluginitems.cc b/libretroshare/src/serialiser/rspluginitems.cc deleted file mode 100644 index f09046d9f..000000000 --- a/libretroshare/src/serialiser/rspluginitems.cc +++ /dev/null @@ -1,135 +0,0 @@ -#include "rspluginitems.h" - -#ifdef TO_REMOVE -#ifndef WINDOWS_SYS -#include -#endif - -bool RsPluginHashSetItem::serialise(void *data,uint32_t& pktsize) -{ - uint32_t tlvsize = serial_size(); - uint32_t offset = 0; - -#ifdef P3TURTLE_DEBUG - std::cerr << "RsPluginSerialiser::serialising HashSet packet (size=" << tlvsize << ")" << std::endl; -#endif - if (pktsize < tlvsize) - return false; /* not enough space */ - - pktsize = tlvsize; - - bool ok = true; - - ok &= setRsItemHeader(data,tlvsize,PacketId(), tlvsize); - - /* skip the header */ - offset += 8; - - /* add mandatory parts first */ - - ok &= hashes.SetTlv(data,tlvsize,&offset) ; - - if (offset != tlvsize) - { - ok = false; -#ifdef P3TURTLE_DEBUG - std::cerr << "RsPluginHashSetItem::serialise() Size Error! (offset=" << offset << ", tlvsize=" << tlvsize << ")" << std::endl; -#endif - } - - return ok ; -} - -RsPluginHashSetItem::RsPluginHashSetItem(void *data,uint32_t size) - : RsPluginItem(RS_PKT_CLASS_PLUGIN_SUBTYPE_HASHSET) -{ - uint32_t offset = 8; // skip the header - uint32_t rssize = getRsItemSize(data); - bool ok = true ; - - hashes.ids.clear() ; - - ok &= hashes.GetTlv(data,size,&offset) ; - - if (offset != rssize) - { -#ifdef TLV_DEBUG - std::cerr << "RsTlvPeerIdSet::GetTlv() Warning extra bytes at end of item"; - std::cerr << std::endl; -#endif - ok = false ; - } - -#ifdef WINDOWS_SYS // No Exceptions in Windows compile. (drbobs). - UNREFERENCED_LOCAL_VARIABLE(rssize); -#else - if (!ok) - throw std::runtime_error("Unknown error while deserializing.") ; -#endif - -} - -RsItem *RsPluginSerialiser::deserialise(void *data, uint32_t *size) -{ - // look what we have... - - /* get the type */ - uint32_t rstype = getRsItemId(data); -#ifdef P3TURTLE_DEBUG - std::cerr << "p3turtle: deserialising packet: " << std::endl ; -#endif - if ( (RS_PKT_VERSION1 != getRsItemVersion(rstype)) - || (RS_PKT_CLASS_CONFIG != getRsItemClass(rstype)) - || (RS_PKT_TYPE_PLUGIN_CONFIG != getRsItemType(rstype))) - { -#ifdef P3TURTLE_DEBUG - std::cerr << " Wrong type !!" << std::endl ; -#endif - return NULL; /* wrong type */ - } - -#ifndef WINDOWS_SYS - try - { -#endif - switch(getRsItemSubType(rstype)) - { - case RS_PKT_CLASS_PLUGIN_SUBTYPE_HASHSET : return new RsPluginHashSetItem(data,*size) ; - - default: - std::cerr << "Unknown packet type in RsPluginSerialiser. Type = " << rstype << std::endl; - return NULL ; - } -#ifndef WINDOWS_SYS - } - catch(std::exception& e) - { - std::cerr << "Exception raised: " << e.what() << std::endl ; - return NULL ; - } -#endif -} - -uint32_t RsPluginHashSetItem::serial_size() -{ - uint32_t size = 8 ; - - size += hashes.TlvSize() ; - - return size ; -} - -std::ostream& RsPluginHashSetItem::print(std::ostream& o, uint16_t) -{ - o << "Item type: RsPluginHashSetItem" << std::endl; - o << " Hash list: " << std::endl; - - for(std::set::const_iterator it(hashes.ids.begin());it!=hashes.ids.end();++it) - o << " " << *it << std::endl; - - return o ; -} - - - -#endif