put consts behind serial_size() and serialise() in turtle items and ft items

This commit is contained in:
mr-alice 2016-10-29 18:18:02 +02:00
parent babc126be3
commit d843c1c1a6
8 changed files with 75 additions and 54 deletions

View File

@ -2167,7 +2167,18 @@ bool ftController::loadConfigMap(std::map<std::string, std::string> &configMap)
return true;
}
void ftController::setFreeDiskSpaceLimit(uint32_t size_in_mb)
void ftController::setDefaultEncryptionPolicy(uint32_t p)
{
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
mDefaultEncryptionPolicy = p ;
IndicateConfigChanged();
}
uint32_t ftController::defaultEncryptionPolicy()
{
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
return mDefaultEncryptionPolicy ;
}
void ftController::setFreeDiskSpaceLimit(uint32_t size_in_mb)
{
RsDiscSpace::setFreeSpaceLimit(size_in_mb) ;

View File

@ -140,9 +140,11 @@ class ftController: public RsTickingThread, public pqiServiceMonitor, public p3C
bool setChunkStrategy(const RsFileHash& hash,FileChunksInfo::ChunkStrategy s);
void setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy s);
FileChunksInfo::ChunkStrategy defaultChunkStrategy();
void setDefaultEncryptionPolicy(uint32_t s);
FileChunksInfo::ChunkStrategy defaultChunkStrategy();
uint32_t freeDiskSpaceLimit() const ;
void setFreeDiskSpaceLimit(uint32_t size_in_mb) ;
uint32_t defaultEncryptionPolicy();
bool FileCancel(const RsFileHash& hash);
bool FileControl(const RsFileHash& hash, uint32_t flags);

View File

@ -294,6 +294,14 @@ void ftServer::setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy s)
{
mFtController->setDefaultChunkStrategy(s) ;
}
uint32_t ftServer::defaultEncryptionPolicy()
{
return mFtController->defaultEncryptionPolicy() ;
}
void ftServer::setDefaultEncryptionPolicy(uint32_t s)
{
mFtController->setDefaultEncryptionPolicy(s) ;
}
FileChunksInfo::ChunkStrategy ftServer::defaultChunkStrategy()
{
return mFtController->defaultChunkStrategy() ;

View File

@ -135,7 +135,8 @@ public:
virtual FileChunksInfo::ChunkStrategy defaultChunkStrategy() ;
virtual uint32_t freeDiskSpaceLimit() const ;
virtual void setFreeDiskSpaceLimit(uint32_t size_in_mb) ;
virtual void setDefaultEncryptionPolicy(uint32_t policy) ; // RS_FILE_CTRL_ENCRYPTION_POLICY_STRICT/PERMISSIVE
virtual uint32_t defaultEncryptionPolicy() ;
/***
* Control of Downloads Priority.

View File

@ -30,7 +30,7 @@
#include <serialiser/itempriorities.h>
#include <ft/ftturtlefiletransferitem.h>
uint32_t RsTurtleFileRequestItem::serial_size()
uint32_t RsTurtleFileRequestItem::serial_size() const
{
uint32_t s = 0 ;
@ -42,7 +42,7 @@ uint32_t RsTurtleFileRequestItem::serial_size()
return s ;
}
uint32_t RsTurtleFileDataItem::serial_size()
uint32_t RsTurtleFileDataItem::serial_size() const
{
uint32_t s = 0 ;
@ -55,7 +55,7 @@ uint32_t RsTurtleFileDataItem::serial_size()
return s ;
}
uint32_t RsTurtleFileMapRequestItem::serial_size()
uint32_t RsTurtleFileMapRequestItem::serial_size() const
{
uint32_t s = 0 ;
@ -66,7 +66,7 @@ uint32_t RsTurtleFileMapRequestItem::serial_size()
return s ;
}
uint32_t RsTurtleFileMapItem::serial_size()
uint32_t RsTurtleFileMapItem::serial_size() const
{
uint32_t s = 0 ;
@ -80,7 +80,7 @@ uint32_t RsTurtleFileMapItem::serial_size()
return s ;
}
uint32_t RsTurtleChunkCrcItem::serial_size()
uint32_t RsTurtleChunkCrcItem::serial_size() const
{
uint32_t s = 0 ;
@ -91,7 +91,7 @@ uint32_t RsTurtleChunkCrcItem::serial_size()
return s ;
}
uint32_t RsTurtleChunkCrcRequestItem::serial_size()
uint32_t RsTurtleChunkCrcRequestItem::serial_size() const
{
uint32_t s = 0 ;
@ -101,7 +101,7 @@ uint32_t RsTurtleChunkCrcRequestItem::serial_size()
return s ;
}
bool RsTurtleFileMapRequestItem::serialize(void *data,uint32_t& pktsize)
bool RsTurtleFileMapRequestItem::serialize(void *data,uint32_t& pktsize) const
{
uint32_t tlvsize = serial_size();
uint32_t offset = 0;
@ -134,7 +134,7 @@ bool RsTurtleFileMapRequestItem::serialize(void *data,uint32_t& pktsize)
return ok;
}
bool RsTurtleFileMapItem::serialize(void *data,uint32_t& pktsize)
bool RsTurtleFileMapItem::serialize(void *data,uint32_t& pktsize) const
{
uint32_t tlvsize = serial_size();
uint32_t offset = 0;
@ -171,7 +171,7 @@ bool RsTurtleFileMapItem::serialize(void *data,uint32_t& pktsize)
return ok;
}
bool RsTurtleChunkCrcRequestItem::serialize(void *data,uint32_t& pktsize)
bool RsTurtleChunkCrcRequestItem::serialize(void *data,uint32_t& pktsize) const
{
#ifdef P3TURTLE_DEBUG
std::cerr << "RsTurtleChunkCrcRequestItem::serialize(): serializing packet:" << std::endl ;
@ -206,7 +206,7 @@ bool RsTurtleChunkCrcRequestItem::serialize(void *data,uint32_t& pktsize)
return ok;
}
bool RsTurtleChunkCrcItem::serialize(void *data,uint32_t& pktsize)
bool RsTurtleChunkCrcItem::serialize(void *data,uint32_t& pktsize) const
{
#ifdef P3TURTLE_DEBUG
std::cerr << "RsTurtleChunkCrcRequestItem::serialize(): serializing packet:" << std::endl ;
@ -345,7 +345,7 @@ RsTurtleChunkCrcRequestItem::RsTurtleChunkCrcRequestItem(void *data,uint32_t pkt
throw std::runtime_error("Unknown error while deserializing.") ;
#endif
}
bool RsTurtleFileRequestItem::serialize(void *data,uint32_t& pktsize)
bool RsTurtleFileRequestItem::serialize(void *data,uint32_t& pktsize) const
{
uint32_t tlvsize = serial_size();
uint32_t offset = 0;
@ -459,7 +459,7 @@ RsTurtleFileDataItem::RsTurtleFileDataItem(void *data,uint32_t pktsize)
#endif
}
bool RsTurtleFileDataItem::serialize(void *data,uint32_t& pktsize)
bool RsTurtleFileDataItem::serialize(void *data,uint32_t& pktsize) const
{
uint32_t tlvsize = serial_size();
uint32_t offset = 0;

View File

@ -44,8 +44,8 @@ class RsTurtleFileRequestItem: public RsTurtleGenericTunnelItem
virtual std::ostream& print(std::ostream& o, uint16_t) ;
protected:
virtual bool serialize(void *data,uint32_t& size) ;
virtual uint32_t serial_size() ;
virtual bool serialize(void *data,uint32_t& size) const;
virtual uint32_t serial_size() const;
};
class RsTurtleFileDataItem: public RsTurtleGenericTunnelItem
@ -64,8 +64,8 @@ class RsTurtleFileDataItem: public RsTurtleGenericTunnelItem
virtual std::ostream& print(std::ostream& o, uint16_t) ;
virtual bool serialize(void *data,uint32_t& size) ;
virtual uint32_t serial_size() ;
virtual bool serialize(void *data,uint32_t& size) const;
virtual uint32_t serial_size() const;
};
class RsTurtleFileMapRequestItem: public RsTurtleGenericTunnelItem
@ -78,8 +78,8 @@ class RsTurtleFileMapRequestItem: public RsTurtleGenericTunnelItem
virtual std::ostream& print(std::ostream& o, uint16_t) ;
virtual bool serialize(void *data,uint32_t& size) ;
virtual uint32_t serial_size() ;
virtual bool serialize(void *data,uint32_t& size) const;
virtual uint32_t serial_size() const;
};
class RsTurtleFileMapItem: public RsTurtleGenericTunnelItem
@ -96,8 +96,8 @@ class RsTurtleFileMapItem: public RsTurtleGenericTunnelItem
virtual std::ostream& print(std::ostream& o, uint16_t) ;
virtual bool serialize(void *data,uint32_t& size) ;
virtual uint32_t serial_size() ;
virtual bool serialize(void *data,uint32_t& size) const;
virtual uint32_t serial_size() const;
};
class RsTurtleChunkCrcRequestItem: public RsTurtleGenericTunnelItem
@ -113,8 +113,8 @@ class RsTurtleChunkCrcRequestItem: public RsTurtleGenericTunnelItem
virtual std::ostream& print(std::ostream& o, uint16_t) ;
virtual bool serialize(void *data,uint32_t& size) ;
virtual uint32_t serial_size() ;
virtual bool serialize(void *data,uint32_t& size) const;
virtual uint32_t serial_size() const;
};
class RsTurtleChunkCrcItem: public RsTurtleGenericTunnelItem
@ -130,6 +130,6 @@ class RsTurtleChunkCrcItem: public RsTurtleGenericTunnelItem
Sha1CheckSum check_sum ;
virtual std::ostream& print(std::ostream& o, uint16_t) ;
virtual bool serialize(void *data,uint32_t& size) ;
virtual uint32_t serial_size() ;
virtual bool serialize(void *data,uint32_t& size) const;
virtual uint32_t serial_size() const;
};

View File

@ -16,7 +16,7 @@
// ---------------------------------- Packet sizes -----------------------------------//
//
uint32_t RsTurtleStringSearchRequestItem::serial_size()
uint32_t RsTurtleStringSearchRequestItem::serial_size() const
{
uint32_t s = 0 ;
@ -27,7 +27,7 @@ uint32_t RsTurtleStringSearchRequestItem::serial_size()
return s ;
}
uint32_t RsTurtleRegExpSearchRequestItem::serial_size()
uint32_t RsTurtleRegExpSearchRequestItem::serial_size() const
{
uint32_t s = 0 ;
@ -48,7 +48,7 @@ uint32_t RsTurtleRegExpSearchRequestItem::serial_size()
return s ;
}
uint32_t RsTurtleSearchResultItem::serial_size()
uint32_t RsTurtleSearchResultItem::serial_size()const
{
uint32_t s = 0 ;
@ -67,7 +67,7 @@ uint32_t RsTurtleSearchResultItem::serial_size()
return s ;
}
uint32_t RsTurtleOpenTunnelItem::serial_size()
uint32_t RsTurtleOpenTunnelItem::serial_size()const
{
uint32_t s = 0 ;
@ -80,7 +80,7 @@ uint32_t RsTurtleOpenTunnelItem::serial_size()
return s ;
}
uint32_t RsTurtleTunnelOkItem::serial_size()
uint32_t RsTurtleTunnelOkItem::serial_size() const
{
uint32_t s = 0 ;
@ -91,7 +91,7 @@ uint32_t RsTurtleTunnelOkItem::serial_size()
return s ;
}
uint32_t RsTurtleGenericDataItem::serial_size()
uint32_t RsTurtleGenericDataItem::serial_size() const
{
uint32_t s = 0 ;
@ -159,7 +159,7 @@ RsItem *RsTurtleSerialiser::deserialise(void *data, uint32_t *size)
}
bool RsTurtleStringSearchRequestItem::serialize(void *data,uint32_t& pktsize)
bool RsTurtleStringSearchRequestItem::serialize(void *data,uint32_t& pktsize) const
{
uint32_t tlvsize = serial_size();
uint32_t offset = 0;
@ -193,7 +193,7 @@ bool RsTurtleStringSearchRequestItem::serialize(void *data,uint32_t& pktsize)
return ok;
}
bool RsTurtleRegExpSearchRequestItem::serialize(void *data,uint32_t& pktsize)
bool RsTurtleRegExpSearchRequestItem::serialize(void *data,uint32_t& pktsize) const
{
uint32_t tlvsize = serial_size();
uint32_t offset = 0;
@ -313,7 +313,7 @@ RsTurtleRegExpSearchRequestItem::RsTurtleRegExpSearchRequestItem(void *data,uint
#endif
}
bool RsTurtleSearchResultItem::serialize(void *data,uint32_t& pktsize)
bool RsTurtleSearchResultItem::serialize(void *data,uint32_t& pktsize) const
{
uint32_t tlvsize = serial_size();
uint32_t offset = 0;
@ -398,7 +398,7 @@ RsTurtleSearchResultItem::RsTurtleSearchResultItem(void *data,uint32_t pktsize)
#endif
}
bool RsTurtleOpenTunnelItem::serialize(void *data,uint32_t& pktsize)
bool RsTurtleOpenTunnelItem::serialize(void *data,uint32_t& pktsize) const
{
uint32_t tlvsize = serial_size();
uint32_t offset = 0;
@ -464,7 +464,7 @@ RsTurtleOpenTunnelItem::RsTurtleOpenTunnelItem(void *data,uint32_t pktsize)
#endif
}
bool RsTurtleTunnelOkItem::serialize(void *data,uint32_t& pktsize)
bool RsTurtleTunnelOkItem::serialize(void *data,uint32_t& pktsize) const
{
uint32_t tlvsize = serial_size();
uint32_t offset = 0;
@ -572,7 +572,7 @@ RsTurtleGenericDataItem::RsTurtleGenericDataItem(void *data,uint32_t pktsize)
#endif
}
bool RsTurtleGenericDataItem::serialize(void *data,uint32_t& pktsize)
bool RsTurtleGenericDataItem::serialize(void *data,uint32_t& pktsize) const
{
uint32_t tlvsize = serial_size();
uint32_t offset = 0;

View File

@ -35,9 +35,8 @@ class RsTurtleItem: public RsItem
public:
RsTurtleItem(uint8_t turtle_subtype) : RsItem(RS_PKT_VERSION_SERVICE,RS_SERVICE_TYPE_TURTLE,turtle_subtype) {}
#warning we need some consts here
virtual bool serialize(void *data,uint32_t& size) = 0 ; // Isn't it better that items can serialize themselves ?
virtual uint32_t serial_size() = 0 ; // deserialise is handled using a constructor
virtual bool serialize(void *data,uint32_t& size) const = 0 ; // Isn't it better that items can serialize themselves ?
virtual uint32_t serial_size() const = 0 ; // deserialise is handled using a constructor
virtual void clear() {}
};
@ -64,8 +63,8 @@ class RsTurtleSearchResultItem: public RsTurtleItem
virtual std::ostream& print(std::ostream& o, uint16_t) ;
protected:
virtual bool serialize(void *data,uint32_t& size) ;
virtual uint32_t serial_size() ;
virtual bool serialize(void *data,uint32_t& size) const ;
virtual uint32_t serial_size() const ;
};
class RsTurtleSearchRequestItem: public RsTurtleItem
@ -93,8 +92,8 @@ class RsTurtleStringSearchRequestItem: public RsTurtleSearchRequestItem
virtual std::ostream& print(std::ostream& o, uint16_t) ;
protected:
virtual bool serialize(void *data,uint32_t& size) ;
virtual uint32_t serial_size() ;
virtual bool serialize(void *data,uint32_t& size) const ;
virtual uint32_t serial_size() const ;
};
class RsTurtleRegExpSearchRequestItem: public RsTurtleSearchRequestItem
@ -110,8 +109,8 @@ class RsTurtleRegExpSearchRequestItem: public RsTurtleSearchRequestItem
virtual std::ostream& print(std::ostream& o, uint16_t) ;
protected:
virtual bool serialize(void *data,uint32_t& size) ;
virtual uint32_t serial_size() ;
virtual bool serialize(void *data,uint32_t& size) const ;
virtual uint32_t serial_size() const ;
};
/***********************************************************************************/
@ -132,8 +131,8 @@ class RsTurtleOpenTunnelItem: public RsTurtleItem
virtual std::ostream& print(std::ostream& o, uint16_t) ;
protected:
virtual bool serialize(void *data,uint32_t& size) ;
virtual uint32_t serial_size() ;
virtual bool serialize(void *data,uint32_t& size) const ;
virtual uint32_t serial_size() const ;
};
class RsTurtleTunnelOkItem: public RsTurtleItem
@ -148,8 +147,8 @@ class RsTurtleTunnelOkItem: public RsTurtleItem
virtual std::ostream& print(std::ostream& o, uint16_t) ;
protected:
virtual bool serialize(void *data,uint32_t& size) ;
virtual uint32_t serial_size() ;
virtual bool serialize(void *data,uint32_t& size) const ;
virtual uint32_t serial_size() const ;
};
/***********************************************************************************/
@ -209,8 +208,8 @@ class RsTurtleGenericDataItem: public RsTurtleGenericTunnelItem
virtual std::ostream& print(std::ostream& o, uint16_t) ;
protected:
virtual bool serialize(void *data,uint32_t& size) ;
virtual uint32_t serial_size() ;
virtual bool serialize(void *data,uint32_t& size) const ;
virtual uint32_t serial_size() const ;
};
/***********************************************************************************/