merged with upstream/master

This commit is contained in:
csoler 2015-12-22 18:33:01 -05:00
commit 5d9272055f
2052 changed files with 8495 additions and 3638 deletions

View file

@ -85,6 +85,8 @@ public:
struct MsgUpdateInfo
{
MsgUpdateInfo(): time_stamp(0), message_count(0) {}
uint32_t time_stamp ;
uint32_t message_count ;
};
@ -105,7 +107,7 @@ public:
virtual std::ostream &print(std::ostream &out, uint16_t indent);
RsGxsGroupId grpId;
uint32_t msgUpdateTS; // the last time this group received a new msg
uint32_t msgUpdateTS; // local time stamp this group last received a new msg
};

View file

@ -38,6 +38,7 @@ uint32_t RsNxsSerialiser::size(RsItem *item) {
RsNxsGrp* ngp;
RsNxsMsg* nmg;
RsNxsSyncGrp* sg;
RsNxsSyncGrpStats* sgs;
RsNxsSyncGrpItem* sgl;
RsNxsSyncMsg* sgm;
RsNxsSyncMsgItem* sgml;
@ -52,6 +53,9 @@ uint32_t RsNxsSerialiser::size(RsItem *item) {
{
return sizeNxsSyncGrp(sg);
} else if((sgs = dynamic_cast<RsNxsSyncGrpStats*>(item)) != NULL)
{
return sizeNxsSyncGrpStats(sgs);
}else if(( ntx = dynamic_cast<RsNxsTransac*>(item)) != NULL){
return sizeNxsTrans(ntx);
}
@ -109,6 +113,8 @@ RsItem* RsNxsSerialiser::deserialise(void *data, uint32_t *size) {
return deserialNxsSyncMsgItem(data, size);
case RS_PKT_SUBTYPE_NXS_GRP:
return deserialNxsGrp(data, size);
case RS_PKT_SUBTYPE_NXS_SYNC_GRP_STATS:
return deserialNxsSyncGrpStats(data, size);
case RS_PKT_SUBTYPE_NXS_MSG:
return deserialNxsMsg(data, size);
case RS_PKT_SUBTYPE_NXS_TRANS:
@ -134,6 +140,7 @@ bool RsNxsSerialiser::serialise(RsItem *item, void *data, uint32_t *size){
RsNxsGrp* ngp;
RsNxsMsg* nmg;
RsNxsSyncGrp* sg;
RsNxsSyncGrpStats* sgs;
RsNxsSyncGrpItem* sgl;
RsNxsSyncMsg* sgm;
RsNxsSyncMsgItem* sgml;
@ -144,6 +151,10 @@ bool RsNxsSerialiser::serialise(RsItem *item, void *data, uint32_t *size){
{
return serialiseNxsSyncGrp(sg, data, size);
}else if((sgs = dynamic_cast<RsNxsSyncGrpStats*>(item)) != NULL)
{
return serialiseNxsSyncGrpStats(sgs, data, size);
}else if ((ntx = dynamic_cast<RsNxsTransac*>(item)) != NULL)
{
return serialiseNxsTrans(ntx, data, size);
@ -330,6 +341,54 @@ bool RsNxsSerialiser::serialiseNxsGrp(RsNxsGrp *item, void *data, uint32_t *size
return ok;
}
bool RsNxsSerialiser::serialiseNxsSyncGrpStats(RsNxsSyncGrpStats *item, void *data, uint32_t *size)
{
#ifdef RSSERIAL_DEBUG
std::cerr << "RsNxsSerialiser::serialiseNxsSyncGrpStats()" << std::endl;
#endif
uint32_t tlvsize = sizeNxsSyncGrpStats(item);
uint32_t offset = 0;
if(*size < tlvsize){
#ifdef RSSERIAL_DEBUG
std::cerr << "RsNxsSerialiser::serialiseNxsSyncGrpStats()" << std::endl;
#endif
return false;
}
*size = tlvsize;
bool ok = true;
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
/* skip the header */
offset += 8;
ok &= setRawUInt32(data, *size, &offset, item->request_type);
ok &= item->grpId.serialise(data, *size, offset) ;
ok &= setRawUInt32(data, *size, &offset, item->number_of_posts);
ok &= setRawUInt32(data, *size, &offset, item->last_post_TS);
if(offset != tlvsize){
#ifdef RSSERIAL_DEBUG
std::cerr << "RsNxsSerialiser::serialiseSyncGrpStats() FAIL Size Error! " << std::endl;
#endif
ok = false;
}
#ifdef RSSERIAL_DEBUG
if (!ok)
{
std::cerr << "RsNxsSerialiser::serialiseSyncGrpStats() NOK" << std::endl;
}
#endif
return ok;
}
bool RsNxsSerialiser::serialiseNxsSyncGrp(RsNxsSyncGrp *item, void *data, uint32_t *size)
{
@ -707,6 +766,71 @@ RsNxsMsg* RsNxsSerialiser::deserialNxsMsg(void *data, uint32_t *size){
return item;
}
RsNxsSyncGrpStats* RsNxsSerialiser::deserialNxsSyncGrpStats(void *data, uint32_t *size){
#ifdef RSSERIAL_DEBUG
std::cerr << "RsNxsSerialiser::deserialNxsSyncGrpStats()" << std::endl;
#endif
/* get the type and size */
uint32_t rstype = getRsItemId(data);
uint32_t rssize = getRsItemSize(data);
uint32_t offset = 0;
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) || (SERVICE_TYPE != getRsItemService(rstype)) || (RS_PKT_SUBTYPE_NXS_SYNC_GRP_STATS != getRsItemSubType(rstype)))
{
#ifdef RSSERIAL_DEBUG
std::cerr << "RsNxsSerialiser::deserialNxsSyncGrpStats() FAIL wrong type" << std::endl;
#endif
return NULL; /* wrong type */
}
if (*size < rssize) /* check size */
{
#ifdef RSSERIAL_DEBUG
std::cerr << "RsNxsSerialiser::deserialNxsSyncGrpStats() FAIL wrong size" << std::endl;
#endif
return NULL; /* not enough data */
}
/* set the packet length */
*size = rssize;
bool ok = true;
RsNxsSyncGrpStats* item = new RsNxsSyncGrpStats(getRsItemService(rstype));
/* skip the header */
offset += 8;
ok &= getRawUInt32(data, *size, &offset, &(item->request_type));
ok &= item->grpId.deserialise(data, *size, offset) ;
ok &= getRawUInt32(data, *size, &offset, &(item->number_of_posts));
ok &= getRawUInt32(data, *size, &offset, &(item->last_post_TS));
if (offset != rssize)
{
#ifdef RSSERIAL_DEBUG
std::cerr << "RsNxsSerialiser::deserialNxsSyncGrpStats() FAIL size mismatch" << std::endl;
#endif
/* error */
delete item;
return NULL;
}
if (!ok)
{
#ifdef RSSERIAL_DEBUG
std::cerr << "RsNxsSerialiser::deserialNxsSyncGrpStats() NOK" << std::endl;
#endif
delete item;
return NULL;
}
return item;
}
RsNxsSyncGrp* RsNxsSerialiser::deserialNxsSyncGrp(void *data, uint32_t *size){
@ -1166,7 +1290,17 @@ uint32_t RsNxsSerialiser::sizeNxsSyncGrp(RsNxsSyncGrp *item)
return s;
}
uint32_t RsNxsSerialiser::sizeNxsSyncGrpStats(RsNxsSyncGrpStats *item)
{
uint32_t s = 8; // header size
s += 4; // request type
s += item->grpId.serial_size();
s += 4; // number_of_posts
s += 4; // last_post_TS
return s;
}
uint32_t RsNxsSerialiser::sizeNxsSyncGrpItem(RsNxsSyncGrpItem *item)
{
@ -1260,7 +1394,6 @@ void RsNxsSyncMsg::clear()
syncHash.clear();
updateTS = 0;
}
void RsNxsSyncGrpItem::clear()
{
flag = 0;
@ -1430,7 +1563,23 @@ std::ostream& RsNxsMsg::print(std::ostream &out, uint16_t indent){
return out;
}
std::ostream& RsNxsSyncGrpStats::print(std::ostream &out, uint16_t indent){
printRsItemBase(out, "RsNxsSyncGrpStats", indent);
uint16_t int_Indent = indent + 2;
out << "available posts: " << number_of_posts << std::endl;
printIndent(out , int_Indent);
out << "last update: " << last_post_TS << std::endl;
printIndent(out , int_Indent);
out << "group ID: " << grpId << std::endl;
printIndent(out , int_Indent);
out << "request type: " << request_type << std::endl;
printIndent(out , int_Indent);
printRsItemEnd(out ,"RsNxsSyncGrpStats", indent);
return out;
}
std::ostream& RsNxsTransac::print(std::ostream &out, uint16_t indent){
printRsItemBase(out, "RsNxsTransac", indent);

View file

@ -36,15 +36,17 @@
#include "serialiser/rstlvkeys.h"
#include "gxs/rsgxsdata.h"
// These items have "flag type" numbers, but this is not used.
const uint8_t RS_PKT_SUBTYPE_NXS_SYNC_GRP = 0x0001;
const uint8_t RS_PKT_SUBTYPE_NXS_SYNC_GRP_ITEM = 0x0002;
const uint8_t RS_PKT_SUBTYPE_NXS_GRP = 0x0004;
const uint8_t RS_PKT_SUBTYPE_NXS_SYNC_MSG_ITEM = 0x0008;
const uint8_t RS_PKT_SUBTYPE_NXS_SYNC_MSG = 0x0010;
const uint8_t RS_PKT_SUBTYPE_NXS_MSG = 0x0020;
const uint8_t RS_PKT_SUBTYPE_NXS_TRANS = 0x0040;
const uint8_t RS_PKT_SUBTYPE_NXS_GRP_PUBLISH_KEY = 0x0080;
const uint8_t RS_PKT_SUBTYPE_NXS_SYNC_GRP = 0x01;
const uint8_t RS_PKT_SUBTYPE_NXS_SYNC_GRP_ITEM = 0x02;
const uint8_t RS_PKT_SUBTYPE_NXS_SYNC_GRP_STATS = 0x03;
const uint8_t RS_PKT_SUBTYPE_NXS_GRP = 0x04;
const uint8_t RS_PKT_SUBTYPE_NXS_SYNC_MSG_ITEM = 0x08;
const uint8_t RS_PKT_SUBTYPE_NXS_SYNC_MSG = 0x10;
const uint8_t RS_PKT_SUBTYPE_NXS_MSG = 0x20;
const uint8_t RS_PKT_SUBTYPE_NXS_TRANS = 0x40;
const uint8_t RS_PKT_SUBTYPE_NXS_GRP_PUBLISH_KEY = 0x80;
// possibility create second service to deal with this functionality
@ -53,7 +55,7 @@ const uint8_t RS_PKT_SUBTYPE_EXT_SEARCH_GRP = 0x0001;
const uint8_t RS_PKT_SUBTYPE_EXT_SEARCH_MSG = 0x0002;
const uint8_t RS_PKT_SUBTYPE_EXT_DELETE_GRP = 0x0004;
const uint8_t RS_PKT_SUBTYPE_EXT_DELETE_MSG = 0x0008;
const uint8_t RS_PKT_SUBTYPE_EXT_SEARCH_REQ = 0x0010;
const uint8_t RS_PKT_SUBTYPE_EXT_SEARCH_REQ = 0x0010;
/*!
@ -107,6 +109,27 @@ public:
};
/*!
* Use to request statistics about a particular group
*/
class RsNxsSyncGrpStats : public RsNxsItem
{
public:
RsNxsSyncGrpStats(uint16_t servtype) : RsNxsItem(servtype, RS_PKT_SUBTYPE_NXS_SYNC_GRP_STATS) {}
virtual void clear() {}
virtual std::ostream &print(std::ostream &out, uint16_t indent);
static const uint8_t GROUP_INFO_TYPE_REQUEST = 0x01;
static const uint8_t GROUP_INFO_TYPE_RESPONSE = 0x02;
uint32_t request_type; // used to determine the type of request
RsGxsGroupId grpId; // id of the group
uint32_t number_of_posts; // number of posts in that group
uint32_t last_post_TS; // time_stamp of last post
};
/*!
* Use to request grp list from peer
* Server may advise client peer to use sync file
@ -445,6 +468,10 @@ private:
virtual bool serialiseNxsSyncGrp(RsNxsSyncGrp *item, void *data, uint32_t *size);
virtual RsNxsSyncGrp* deserialNxsSyncGrp(void *data, uint32_t *size);
virtual uint32_t sizeNxsSyncGrpStats(RsNxsSyncGrpStats* item);
virtual bool serialiseNxsSyncGrpStats(RsNxsSyncGrpStats *item, void *data, uint32_t *size);
virtual RsNxsSyncGrpStats* deserialNxsSyncGrpStats(void *data, uint32_t *size);
/* for RS_PKT_SUBTYPE_SYNC_GRP_ITEM */
virtual uint32_t sizeNxsSyncGrpItem(RsNxsSyncGrpItem* item);

View file

@ -38,32 +38,33 @@
*/
/* These are Cache Only */
const uint16_t RS_SERVICE_TYPE_FILE_INDEX = 0x0001;
const uint16_t RS_SERVICE_TYPE_FILE_INDEX = 0x0001;
/* These are Services only */
const uint16_t RS_SERVICE_TYPE_DISC = 0x0011;
const uint16_t RS_SERVICE_TYPE_CHAT = 0x0012;
const uint16_t RS_SERVICE_TYPE_MSG = 0x0013;
const uint16_t RS_SERVICE_TYPE_TURTLE = 0x0014;
const uint16_t RS_SERVICE_TYPE_TUNNEL = 0x0015;
const uint16_t RS_SERVICE_TYPE_HEARTBEAT = 0x0016;
const uint16_t RS_SERVICE_TYPE_FILE_TRANSFER = 0x0017;
const uint16_t RS_SERVICE_TYPE_GROUTER = 0x0018;
const uint16_t RS_SERVICE_TYPE_DISC = 0x0011;
const uint16_t RS_SERVICE_TYPE_CHAT = 0x0012;
const uint16_t RS_SERVICE_TYPE_MSG = 0x0013;
const uint16_t RS_SERVICE_TYPE_TURTLE = 0x0014;
const uint16_t RS_SERVICE_TYPE_TUNNEL = 0x0015;
const uint16_t RS_SERVICE_TYPE_HEARTBEAT = 0x0016;
const uint16_t RS_SERVICE_TYPE_FILE_TRANSFER = 0x0017;
const uint16_t RS_SERVICE_TYPE_GROUTER = 0x0018;
const uint16_t RS_SERVICE_TYPE_SERVICEINFO = 0x0020;
const uint16_t RS_SERVICE_TYPE_SERVICEINFO = 0x0020;
/* Bandwidth Control */
const uint16_t RS_SERVICE_TYPE_BWCTRL = 0x0021;
// New Mail Service (replace old Msg Service)
const uint16_t RS_SERVICE_TYPE_MAIL = 0x0022;
const uint16_t RS_SERVICE_TYPE_DIRECT_MAIL = 0x0023;
const uint16_t RS_SERVICE_TYPE_DISTANT_MAIL = 0x0024;
const uint16_t RS_SERVICE_TYPE_GWEMAIL_MAIL = 0x0025;
const uint16_t RS_SERVICE_TYPE_BWCTRL = 0x0021;
// New Mail Service (replace old Msg Service)
const uint16_t RS_SERVICE_TYPE_MAIL = 0x0022;
const uint16_t RS_SERVICE_TYPE_DIRECT_MAIL = 0x0023;
const uint16_t RS_SERVICE_TYPE_DISTANT_MAIL = 0x0024;
const uint16_t RS_SERVICE_TYPE_GWEMAIL_MAIL = 0x0025;
const uint16_t RS_SERVICE_TYPE_SERVICE_CONTROL= 0x0026;
const uint16_t RS_SERVICE_TYPE_DISTANT_CHAT = 0x0027;
const uint16_t RS_SERVICE_TYPE_DISTANT_CHAT = 0x0027;
const uint16_t RS_SERVICE_TYPE_GXS_TUNNEL = 0x0028;
// Non essential services.
const uint16_t RS_SERVICE_TYPE_BANLIST = 0x0101;
const uint16_t RS_SERVICE_TYPE_STATUS = 0x0102;
const uint16_t RS_SERVICE_TYPE_BANLIST = 0x0101;
const uint16_t RS_SERVICE_TYPE_STATUS = 0x0102;
/* New Cache Services */
/* Rs Network Exchange Service */