mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-19 11:54:22 -04:00
moved rspluginitems to rsitems/
This commit is contained in:
parent
d32a8caf06
commit
c33c34b175
4 changed files with 4 additions and 141 deletions
|
@ -143,7 +143,7 @@ PUBLIC_HEADERS = retroshare/rsdisc.h \
|
||||||
|
|
||||||
HEADERS += plugins/pluginmanager.h \
|
HEADERS += plugins/pluginmanager.h \
|
||||||
plugins/dlfcn_win32.h \
|
plugins/dlfcn_win32.h \
|
||||||
serialiser/rspluginitems.h \
|
rsitems/rspluginitems.h \
|
||||||
util/rsinitedptr.h
|
util/rsinitedptr.h
|
||||||
|
|
||||||
HEADERS += $$PUBLIC_HEADERS
|
HEADERS += $$PUBLIC_HEADERS
|
||||||
|
@ -605,8 +605,7 @@ SOURCES += grouter/p3grouter.cc \
|
||||||
grouter/groutermatrix.cc
|
grouter/groutermatrix.cc
|
||||||
|
|
||||||
SOURCES += plugins/pluginmanager.cc \
|
SOURCES += plugins/pluginmanager.cc \
|
||||||
plugins/dlfcn_win32.cc \
|
plugins/dlfcn_win32.cc
|
||||||
serialiser/rspluginitems.cc
|
|
||||||
|
|
||||||
SOURCES += serialiser/rsbaseserial.cc \
|
SOURCES += serialiser/rsbaseserial.cc \
|
||||||
rsitems/rsfiletransferitems.cc \
|
rsitems/rsfiletransferitems.cc \
|
||||||
|
|
|
@ -9,8 +9,7 @@
|
||||||
#include <serialiser/rstlvtypes.h>
|
#include <serialiser/rstlvtypes.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <serialiser/rspluginitems.h>
|
#include <rsitems/rspluginitems.h>
|
||||||
|
|
||||||
|
|
||||||
#include <rsserver/p3face.h>
|
#include <rsserver/p3face.h>
|
||||||
#include <util/rsdir.h>
|
#include <util/rsdir.h>
|
||||||
|
@ -34,7 +33,7 @@
|
||||||
|
|
||||||
std::string RsPluginManager::_plugin_entry_symbol = "RETROSHARE_PLUGIN_provide" ;
|
std::string RsPluginManager::_plugin_entry_symbol = "RETROSHARE_PLUGIN_provide" ;
|
||||||
std::string RsPluginManager::_plugin_revision_symbol = "RETROSHARE_PLUGIN_revision" ;
|
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::_local_cache_dir ;
|
||||||
std::string RsPluginManager::_remote_cache_dir ;
|
std::string RsPluginManager::_remote_cache_dir ;
|
||||||
|
|
|
@ -1,135 +0,0 @@
|
||||||
#include "rspluginitems.h"
|
|
||||||
|
|
||||||
#ifdef TO_REMOVE
|
|
||||||
#ifndef WINDOWS_SYS
|
|
||||||
#include <stdexcept>
|
|
||||||
#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<Sha1CheckSum>::const_iterator it(hashes.ids.begin());it!=hashes.ids.end();++it)
|
|
||||||
o << " " << *it << std::endl;
|
|
||||||
|
|
||||||
return o ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Add table
Add a link
Reference in a new issue