2012-06-26 15:52:01 -04:00
|
|
|
|
|
|
|
#include "rsgxsdata.h"
|
|
|
|
#include "serialiser/rsbaseserial.h"
|
|
|
|
|
|
|
|
RsGxsGrpMetaData::RsGxsGrpMetaData()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t RsGxsGrpMetaData::serial_size()
|
|
|
|
{
|
|
|
|
uint32_t s = 8; // header size
|
|
|
|
|
|
|
|
s += GetTlvStringSize(mGroupId);
|
|
|
|
s += GetTlvStringSize(mOrigGrpId);
|
|
|
|
s += GetTlvStringSize(mGroupName);
|
|
|
|
s += 4;
|
|
|
|
s += 4;
|
|
|
|
s += GetTlvStringSize(mAuthorId);
|
|
|
|
s += adminSign.TlvSize();
|
|
|
|
s += keys.TlvSize();
|
|
|
|
s += idSign.TlvSize();
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2012-06-28 17:22:55 -04:00
|
|
|
void RsGxsGrpMetaData::clear(){
|
|
|
|
|
|
|
|
mGroupId.clear();
|
|
|
|
mOrigGrpId.clear();
|
|
|
|
mAuthorId.clear();
|
|
|
|
mGroupName.clear();
|
|
|
|
mPublishTs = 0;
|
|
|
|
mGroupFlags = 0;
|
|
|
|
mPop = 0;
|
|
|
|
mMsgCount = 0;
|
|
|
|
mGroupStatus = 0;
|
|
|
|
mLastPost = 0;
|
|
|
|
mSubscribeFlags = 0;
|
|
|
|
|
|
|
|
adminSign.TlvClear();
|
|
|
|
keys.TlvClear();
|
|
|
|
idSign.TlvClear();
|
|
|
|
}
|
|
|
|
|
2012-06-26 15:52:01 -04:00
|
|
|
bool RsGxsGrpMetaData::serialise(void *data, uint32_t &pktsize)
|
|
|
|
{
|
|
|
|
|
|
|
|
uint32_t tlvsize = serial_size() ;
|
|
|
|
uint32_t offset = 0;
|
|
|
|
|
|
|
|
if (pktsize < tlvsize)
|
|
|
|
return false; /* not enough space */
|
|
|
|
|
|
|
|
pktsize = tlvsize;
|
|
|
|
|
|
|
|
bool ok = true;
|
|
|
|
|
|
|
|
ok &= setRsItemHeader(data, tlvsize, 0, tlvsize);
|
|
|
|
|
|
|
|
#ifdef GXS_DEBUG
|
|
|
|
std::cerr << "RsGxsGrpMetaData serialise()" << std::endl;
|
|
|
|
std::cerr << "RsGxsGrpMetaData serialise(): Header: " << ok << std::endl;
|
|
|
|
std::cerr << "RsGxsGrpMetaData serialise(): Size: " << tlvsize << std::endl;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* skip header */
|
|
|
|
offset += 8;
|
|
|
|
|
|
|
|
ok &= SetTlvString(data, tlvsize, &offset, 0, mGroupId);
|
|
|
|
ok &= SetTlvString(data, tlvsize, &offset, 0, mOrigGrpId);
|
|
|
|
ok &= SetTlvString(data, tlvsize, &offset, 0, mGroupName);
|
|
|
|
ok &= setRawUInt32(data, tlvsize, &offset, mGroupFlags);
|
|
|
|
ok &= setRawUInt32(data, tlvsize, &offset, mPublishTs);
|
|
|
|
ok &= SetTlvString(data, tlvsize, &offset, 0, mAuthorId);
|
|
|
|
|
|
|
|
ok &= adminSign.SetTlv(data, tlvsize, &offset);
|
|
|
|
ok &= keys.SetTlv(data, tlvsize, &offset);
|
|
|
|
ok &= idSign.SetTlv(data, tlvsize, &offset);
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RsGxsGrpMetaData::deserialise(void *data, uint32_t &pktsize)
|
|
|
|
{
|
|
|
|
|
|
|
|
uint32_t offset = 8; // skip the header
|
|
|
|
uint32_t rssize = getRsItemSize(data);
|
|
|
|
|
|
|
|
bool ok = true ;
|
|
|
|
|
2012-06-28 17:22:55 -04:00
|
|
|
ok &= rssize == pktsize;
|
2012-06-26 15:52:01 -04:00
|
|
|
|
|
|
|
if(!ok) return false;
|
|
|
|
|
|
|
|
ok &= GetTlvString(data, pktsize, &offset, 0, mGroupId);
|
|
|
|
ok &= GetTlvString(data, pktsize, &offset, 0, mOrigGrpId);
|
2012-06-28 17:22:55 -04:00
|
|
|
ok &= GetTlvString(data, pktsize, &offset, 0, mGroupName);
|
2012-06-26 15:52:01 -04:00
|
|
|
ok &= getRawUInt32(data, pktsize, &offset, &mGroupFlags);
|
|
|
|
ok &= getRawUInt32(data, pktsize, &offset, &mPublishTs);
|
|
|
|
ok &= GetTlvString(data, pktsize, &offset, 0, mAuthorId);
|
|
|
|
|
|
|
|
ok &= adminSign.GetTlv(data, pktsize, &offset);
|
2012-06-28 17:22:55 -04:00
|
|
|
ok &= keys.GetTlv(data, pktsize, &offset);
|
|
|
|
ok &= idSign.GetTlv(data, pktsize, &offset);
|
2012-06-26 15:52:01 -04:00
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
2012-06-28 17:22:55 -04:00
|
|
|
RsGxsMsgMetaData::RsGxsMsgMetaData(){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-06-26 15:52:01 -04:00
|
|
|
uint32_t RsGxsMsgMetaData::serial_size()
|
|
|
|
{
|
|
|
|
|
|
|
|
uint32_t s = 8; // header size
|
|
|
|
|
|
|
|
s += GetTlvStringSize(mGroupId);
|
|
|
|
s += GetTlvStringSize(mMsgId);
|
|
|
|
s += GetTlvStringSize(mThreadId);
|
|
|
|
s += GetTlvStringSize(mParentId);
|
|
|
|
s += GetTlvStringSize(mOrigMsgId);
|
2012-06-28 17:22:55 -04:00
|
|
|
s += GetTlvStringSize(mAuthorId);
|
2012-06-26 15:52:01 -04:00
|
|
|
|
|
|
|
s += pubSign.TlvSize();
|
|
|
|
s += idSign.TlvSize();
|
|
|
|
s += GetTlvStringSize(mMsgName);
|
|
|
|
s += 4;
|
|
|
|
s += 4;
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2012-06-28 17:22:55 -04:00
|
|
|
void RsGxsMsgMetaData::clear()
|
|
|
|
{
|
|
|
|
mGroupId.clear();
|
|
|
|
mMsgId.clear();
|
|
|
|
mThreadId.clear();
|
|
|
|
mParentId.clear();
|
|
|
|
mAuthorId.clear();
|
|
|
|
mOrigMsgId.clear();
|
|
|
|
mMsgName.clear();
|
|
|
|
|
|
|
|
pubSign.TlvClear();
|
|
|
|
idSign.TlvClear();
|
|
|
|
|
|
|
|
mPublishTs = 0;
|
|
|
|
mMsgFlags = 0;
|
|
|
|
mMsgStatus = 0;
|
|
|
|
mChildTs = 0;
|
|
|
|
}
|
|
|
|
|
2012-06-26 15:52:01 -04:00
|
|
|
bool RsGxsMsgMetaData::serialise(void *data, uint32_t *size)
|
|
|
|
{
|
|
|
|
uint32_t tlvsize = serial_size() ;
|
|
|
|
uint32_t offset = 0;
|
|
|
|
|
|
|
|
if (*size < tlvsize)
|
|
|
|
return false; /* not enough space */
|
|
|
|
|
|
|
|
*size = tlvsize;
|
|
|
|
|
|
|
|
bool ok = true;
|
|
|
|
|
|
|
|
ok &= setRsItemHeader(data, tlvsize, 0, tlvsize);
|
|
|
|
|
|
|
|
#ifdef GXS_DEBUG
|
|
|
|
std::cerr << "RsGxsGrpMetaData serialise()" << std::endl;
|
|
|
|
std::cerr << "RsGxsGrpMetaData serialise(): Header: " << ok << std::endl;
|
|
|
|
std::cerr << "RsGxsGrpMetaData serialise(): Size: " << tlvsize << std::endl;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* skip header */
|
|
|
|
offset += 8;
|
|
|
|
|
|
|
|
ok &= SetTlvString(data, *size, &offset, 0, mGroupId);
|
|
|
|
ok &= SetTlvString(data, *size, &offset, 0, mMsgId);
|
|
|
|
ok &= SetTlvString(data, *size, &offset, 0, mThreadId);
|
|
|
|
ok &= SetTlvString(data, *size, &offset, 0, mParentId);
|
|
|
|
ok &= SetTlvString(data, *size, &offset, 0, mOrigMsgId);
|
2012-06-28 17:22:55 -04:00
|
|
|
ok &= SetTlvString(data, *size, &offset, 0, mAuthorId);
|
2012-06-26 15:52:01 -04:00
|
|
|
|
|
|
|
ok &= pubSign.SetTlv(data, *size, &offset);
|
|
|
|
ok &= idSign.SetTlv(data, *size, &offset);
|
|
|
|
ok &= SetTlvString(data, *size, &offset, 0, mMsgName);
|
|
|
|
ok &= setRawUInt32(data, *size, &offset, mPublishTs);
|
|
|
|
ok &= setRawUInt32(data, *size, &offset, mMsgFlags);
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool RsGxsMsgMetaData::deserialise(void *data, uint32_t *size)
|
|
|
|
{
|
|
|
|
uint32_t offset = 8; // skip the header
|
|
|
|
uint32_t rssize = getRsItemSize(data);
|
|
|
|
|
|
|
|
bool ok = true ;
|
|
|
|
|
2012-06-28 17:22:55 -04:00
|
|
|
ok &= rssize == *size;
|
2012-06-26 15:52:01 -04:00
|
|
|
|
|
|
|
if(!ok) return false;
|
|
|
|
|
|
|
|
ok &= GetTlvString(data, *size, &offset, 0, mGroupId);
|
|
|
|
ok &= GetTlvString(data, *size, &offset, 0, mMsgId);
|
|
|
|
ok &= GetTlvString(data, *size, &offset, 0, mThreadId);
|
|
|
|
ok &= GetTlvString(data, *size, &offset, 0, mParentId);
|
|
|
|
ok &= GetTlvString(data, *size, &offset, 0, mOrigMsgId);
|
2012-06-28 17:22:55 -04:00
|
|
|
ok &= GetTlvString(data, *size, &offset, 0, mAuthorId);
|
2012-06-26 15:52:01 -04:00
|
|
|
|
|
|
|
ok &= pubSign.GetTlv(data, *size, &offset);
|
|
|
|
ok &= idSign.GetTlv(data, *size, &offset);
|
|
|
|
ok &= GetTlvString(data, *size, &offset, 0, mMsgName);
|
|
|
|
uint32_t t;
|
|
|
|
ok &= getRawUInt32(data, *size, &offset, &t);
|
|
|
|
mPublishTs = t;
|
|
|
|
ok &= getRawUInt32(data, *size, &offset, &mMsgFlags);
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
2012-07-26 17:48:54 -04:00
|
|
|
|
|
|
|
void RsGxsGrpMetaData::operator =(const RsGroupMetaData& rMeta)
|
|
|
|
{
|
|
|
|
this->mAuthorId = rMeta.mAuthorId;
|
|
|
|
this->mGroupFlags = rMeta.mGroupFlags;
|
|
|
|
this->mGroupId = rMeta.mGroupId;
|
|
|
|
this->mGroupStatus = rMeta.mGroupStatus ;
|
|
|
|
this->mLastPost = rMeta.mLastPost;
|
|
|
|
this->mMsgCount = rMeta.mMsgCount ;
|
|
|
|
this->mPop = rMeta.mPop;
|
|
|
|
this->mPublishTs = rMeta.mPublishTs;
|
|
|
|
this->mSubscribeFlags = rMeta.mSubscribeFlags;
|
|
|
|
this->mGroupName = rMeta.mGroupName;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RsGxsMsgMetaData::operator =(const RsMsgMetaData& rMeta)
|
|
|
|
{
|
|
|
|
this->mAuthorId = rMeta.mAuthorId;
|
|
|
|
this->mChildTs = rMeta.mChildTs ;
|
|
|
|
this->mGroupId = rMeta.mGroupId;
|
|
|
|
this->mMsgFlags = rMeta.mMsgFlags ;
|
|
|
|
this->mMsgId = rMeta.mMsgId ;
|
|
|
|
this->mMsgName = rMeta.mMsgName;
|
|
|
|
this->mMsgStatus = rMeta.mMsgStatus;
|
|
|
|
this->mOrigMsgId = rMeta.mOrigMsgId;
|
|
|
|
this->mParentId = rMeta.mParentId ;
|
|
|
|
this->mPublishTs = rMeta.mPublishTs ;
|
|
|
|
this->mThreadId = rMeta.mThreadId;
|
|
|
|
}
|
|
|
|
|
|
|
|
|