2012-08-02 09:17:53 -04:00
|
|
|
/****************************************************************
|
|
|
|
* RetroShare GUI is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2012 by Thunder
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
#include "serialiser/rsbaseserial.h"
|
|
|
|
#include "serialiser/rstlvbase.h"
|
|
|
|
#include "rsFeedReaderItems.h"
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2012-09-04 19:53:04 -04:00
|
|
|
RsFeedReaderFeed::RsFeedReaderFeed()
|
|
|
|
: RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_PLUGIN_FEEDREADER, RS_PKT_SUBTYPE_FEEDREADER_FEED),
|
|
|
|
xpathsToUse(TLV_TYPE_STRINGSET), xpathsToRemove(TLV_TYPE_STRINGSET)
|
2012-08-02 09:17:53 -04:00
|
|
|
{
|
|
|
|
clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RsFeedReaderFeed::clear()
|
|
|
|
{
|
|
|
|
feedId.clear();
|
|
|
|
parentId.clear();
|
|
|
|
name.clear();
|
|
|
|
url.clear();
|
|
|
|
user.clear();
|
|
|
|
password.clear();
|
|
|
|
proxyAddress.clear();
|
|
|
|
proxyPort = 0;
|
|
|
|
updateInterval = 0;
|
|
|
|
lastUpdate = 0;
|
|
|
|
storageTime = 0;
|
|
|
|
flag = 0;
|
|
|
|
forumId.clear();
|
|
|
|
description.clear();
|
|
|
|
icon.clear();
|
|
|
|
errorState = RS_FEED_ERRORSTATE_OK;
|
|
|
|
errorString.clear();
|
2013-01-21 19:11:43 -05:00
|
|
|
transformationType = RS_FEED_TRANSFORMATION_TYPE_NONE;
|
2012-09-04 19:53:04 -04:00
|
|
|
xpathsToUse.ids.clear();
|
|
|
|
xpathsToRemove.ids.clear();
|
2013-01-21 19:11:43 -05:00
|
|
|
xslt.clear();
|
2012-08-02 09:17:53 -04:00
|
|
|
|
2012-08-13 17:35:11 -04:00
|
|
|
preview = false;
|
2012-08-02 09:17:53 -04:00
|
|
|
workstate = WAITING;
|
|
|
|
content.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
std::ostream &RsFeedReaderFeed::print(std::ostream &out, uint16_t /*indent*/)
|
|
|
|
{
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t RsFeedReaderSerialiser::sizeFeed(RsFeedReaderFeed *item)
|
|
|
|
{
|
|
|
|
uint32_t s = 8; /* header */
|
2012-09-04 19:53:04 -04:00
|
|
|
s += 2; /* version */
|
2012-08-02 09:17:53 -04:00
|
|
|
s += GetTlvStringSize(item->feedId);
|
|
|
|
s += GetTlvStringSize(item->parentId);
|
|
|
|
s += GetTlvStringSize(item->url);
|
|
|
|
s += GetTlvStringSize(item->name);
|
|
|
|
s += GetTlvStringSize(item->description);
|
|
|
|
s += GetTlvStringSize(item->icon);
|
|
|
|
s += GetTlvStringSize(item->user);
|
|
|
|
s += GetTlvStringSize(item->password);
|
|
|
|
s += GetTlvStringSize(item->proxyAddress);
|
|
|
|
s += sizeof(uint16_t); /* proxyPort */
|
|
|
|
s += sizeof(uint32_t); /* updateInterval */
|
2015-06-08 08:20:17 -04:00
|
|
|
s += sizeof(uint32_t); /* lastUpdate */
|
2012-08-02 09:17:53 -04:00
|
|
|
s += sizeof(uint32_t); /* storageTime */
|
|
|
|
s += sizeof(uint32_t); /* flag */
|
|
|
|
s += GetTlvStringSize(item->forumId);
|
|
|
|
s += sizeof(uint32_t); /* errorstate */
|
|
|
|
s += GetTlvStringSize(item->errorString);
|
2013-01-21 19:11:43 -05:00
|
|
|
s += sizeof(uint32_t); /* transformationType */
|
2012-09-04 19:53:04 -04:00
|
|
|
s += item->xpathsToUse.TlvSize();
|
|
|
|
s += item->xpathsToRemove.TlvSize();
|
2013-01-21 19:11:43 -05:00
|
|
|
s += GetTlvStringSize(item->xslt);
|
2012-08-02 09:17:53 -04:00
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* serialise the data to the buffer */
|
|
|
|
bool RsFeedReaderSerialiser::serialiseFeed(RsFeedReaderFeed *item, void *data, uint32_t *pktsize)
|
|
|
|
{
|
|
|
|
uint32_t tlvsize = sizeFeed(item);
|
|
|
|
uint32_t offset = 0;
|
|
|
|
|
|
|
|
if (*pktsize < tlvsize)
|
|
|
|
return false; /* not enough space */
|
|
|
|
|
|
|
|
*pktsize = tlvsize;
|
|
|
|
|
|
|
|
bool ok = true;
|
|
|
|
|
|
|
|
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
|
|
|
|
|
|
|
/* skip the header */
|
|
|
|
offset += 8;
|
|
|
|
|
|
|
|
/* add values */
|
2013-01-21 19:11:43 -05:00
|
|
|
ok &= setRawUInt16(data, tlvsize, &offset, 1); /* version */
|
2012-08-02 09:17:53 -04:00
|
|
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_GENID, item->feedId);
|
|
|
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->parentId);
|
|
|
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_LINK, item->url);
|
|
|
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, item->name);
|
|
|
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_COMMENT, item->description);
|
|
|
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->icon);
|
|
|
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->user);
|
|
|
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->password);
|
|
|
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->proxyAddress);
|
|
|
|
ok &= setRawUInt16(data, tlvsize, &offset, item->proxyPort);
|
|
|
|
ok &= setRawUInt32(data, tlvsize, &offset, item->updateInterval);
|
|
|
|
ok &= setRawUInt32(data, tlvsize, &offset, item->lastUpdate);
|
|
|
|
ok &= setRawUInt32(data, tlvsize, &offset, item->storageTime);
|
|
|
|
ok &= setRawUInt32(data, tlvsize, &offset, item->flag);
|
|
|
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->forumId);
|
|
|
|
ok &= setRawUInt32(data, tlvsize, &offset, item->errorState);
|
|
|
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->errorString);
|
2013-01-21 19:11:43 -05:00
|
|
|
ok &= setRawUInt32(data, tlvsize, &offset, item->transformationType);
|
2012-09-04 19:53:04 -04:00
|
|
|
ok &= item->xpathsToUse.SetTlv(data, tlvsize, &offset);
|
|
|
|
ok &= item->xpathsToRemove.SetTlv(data, tlvsize, &offset);
|
2013-01-21 19:11:43 -05:00
|
|
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->xslt);
|
2012-08-02 09:17:53 -04:00
|
|
|
|
|
|
|
if (offset != tlvsize)
|
|
|
|
{
|
|
|
|
ok = false;
|
|
|
|
std::cerr << "RsFeedReaderSerialiser::serialiseFeed() Size Error! " << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
RsFeedReaderFeed *RsFeedReaderSerialiser::deserialiseFeed(void *data, uint32_t *pktsize)
|
|
|
|
{
|
|
|
|
/* get the type and size */
|
|
|
|
uint32_t rstype = getRsItemId(data);
|
|
|
|
uint32_t rssize = getRsItemSize(data);
|
|
|
|
|
|
|
|
uint32_t offset = 0;
|
|
|
|
|
2012-09-04 19:53:04 -04:00
|
|
|
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
|
|
|
|
(RS_SERVICE_TYPE_PLUGIN_FEEDREADER != getRsItemService(rstype)) ||
|
2012-08-02 09:17:53 -04:00
|
|
|
(RS_PKT_SUBTYPE_FEEDREADER_FEED != getRsItemSubType(rstype)))
|
|
|
|
{
|
|
|
|
return NULL; /* wrong type */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*pktsize < rssize) /* check size */
|
|
|
|
return NULL; /* not enough data */
|
|
|
|
|
|
|
|
/* set the packet length */
|
|
|
|
*pktsize = rssize;
|
|
|
|
|
|
|
|
bool ok = true;
|
|
|
|
|
|
|
|
/* ready to load */
|
|
|
|
RsFeedReaderFeed *item = new RsFeedReaderFeed();
|
|
|
|
item->clear();
|
|
|
|
|
|
|
|
/* skip the header */
|
|
|
|
offset += 8;
|
|
|
|
|
|
|
|
/* get values */
|
2012-09-04 19:53:04 -04:00
|
|
|
uint16_t version = 0;
|
|
|
|
ok &= getRawUInt16(data, rssize, &offset, &version);
|
2012-08-02 09:17:53 -04:00
|
|
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_GENID, item->feedId);
|
|
|
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->parentId);
|
|
|
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_LINK, item->url);
|
|
|
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->name);
|
|
|
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_COMMENT, item->description);
|
|
|
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->icon);
|
|
|
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->user);
|
|
|
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->password);
|
|
|
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->proxyAddress);
|
|
|
|
ok &= getRawUInt16(data, rssize, &offset, &(item->proxyPort));
|
|
|
|
ok &= getRawUInt32(data, rssize, &offset, &(item->updateInterval));
|
|
|
|
ok &= getRawUInt32(data, rssize, &offset, (uint32_t*) &(item->lastUpdate));
|
|
|
|
ok &= getRawUInt32(data, rssize, &offset, &(item->storageTime));
|
|
|
|
ok &= getRawUInt32(data, rssize, &offset, &(item->flag));
|
|
|
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->forumId);
|
2012-08-13 17:35:11 -04:00
|
|
|
uint32_t errorState = 0;
|
|
|
|
ok &= getRawUInt32(data, rssize, &offset, &errorState);
|
|
|
|
item->errorState = (RsFeedReaderErrorState) errorState;
|
2012-08-02 09:17:53 -04:00
|
|
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->errorString);
|
2013-01-21 19:11:43 -05:00
|
|
|
if (version >= 1) {
|
|
|
|
uint32_t value = RS_FEED_TRANSFORMATION_TYPE_NONE;
|
|
|
|
ok &= getRawUInt32(data, rssize, &offset, &value);
|
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
item->transformationType = (RsFeedTransformationType) value;
|
|
|
|
}
|
|
|
|
}
|
2012-09-04 19:53:04 -04:00
|
|
|
ok &= item->xpathsToUse.GetTlv(data, rssize, &offset);
|
|
|
|
ok &= item->xpathsToRemove.GetTlv(data, rssize, &offset);
|
2013-01-21 19:11:43 -05:00
|
|
|
if (version >= 1) {
|
|
|
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->xslt);
|
|
|
|
}
|
2012-08-02 09:17:53 -04:00
|
|
|
|
2013-01-21 19:11:43 -05:00
|
|
|
if (version == 0)
|
|
|
|
{
|
|
|
|
if (!item->xpathsToUse.ids.empty() || !item->xpathsToRemove.ids.empty())
|
|
|
|
{
|
|
|
|
/* set transformation type */
|
|
|
|
item->transformationType = RS_FEED_TRANSFORMATION_TYPE_XPATH;
|
|
|
|
}
|
|
|
|
}
|
2012-08-02 09:17:53 -04:00
|
|
|
if (offset != rssize)
|
|
|
|
{
|
|
|
|
/* error */
|
|
|
|
delete item;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
delete item;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2012-09-04 19:53:04 -04:00
|
|
|
RsFeedReaderMsg::RsFeedReaderMsg() : RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_PLUGIN_FEEDREADER, RS_PKT_SUBTYPE_FEEDREADER_MSG)
|
2012-08-02 09:17:53 -04:00
|
|
|
{
|
|
|
|
clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RsFeedReaderMsg::clear()
|
|
|
|
{
|
|
|
|
msgId.clear();
|
|
|
|
feedId.clear();
|
|
|
|
title.clear();
|
|
|
|
link.clear();
|
|
|
|
author.clear();
|
|
|
|
description.clear();
|
2013-01-21 19:11:43 -05:00
|
|
|
descriptionTransformed.clear();
|
2012-08-02 09:17:53 -04:00
|
|
|
pubDate = 0;
|
|
|
|
flag = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::ostream &RsFeedReaderMsg::print(std::ostream &out, uint16_t /*indent*/)
|
|
|
|
{
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t RsFeedReaderSerialiser::sizeMsg(RsFeedReaderMsg *item)
|
|
|
|
{
|
|
|
|
uint32_t s = 8; /* header */
|
2012-09-04 19:53:04 -04:00
|
|
|
s += 2; /* version */
|
2012-08-02 09:17:53 -04:00
|
|
|
s += GetTlvStringSize(item->msgId);
|
|
|
|
s += GetTlvStringSize(item->feedId);
|
|
|
|
s += GetTlvStringSize(item->title);
|
|
|
|
s += GetTlvStringSize(item->link);
|
|
|
|
s += GetTlvStringSize(item->author);
|
|
|
|
s += GetTlvStringSize(item->description);
|
2013-01-21 19:11:43 -05:00
|
|
|
s += GetTlvStringSize(item->descriptionTransformed);
|
2015-06-08 03:56:21 -04:00
|
|
|
s += sizeof(uint32_t); /* pubDate */
|
2012-08-02 09:17:53 -04:00
|
|
|
s += sizeof(uint32_t); /* flag */
|
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* serialise the data to the buffer */
|
|
|
|
bool RsFeedReaderSerialiser::serialiseMsg(RsFeedReaderMsg *item, void *data, uint32_t *pktsize)
|
|
|
|
{
|
|
|
|
uint32_t tlvsize = sizeMsg(item);
|
|
|
|
uint32_t offset = 0;
|
|
|
|
|
|
|
|
if (*pktsize < tlvsize)
|
|
|
|
return false; /* not enough space */
|
|
|
|
|
|
|
|
*pktsize = tlvsize;
|
|
|
|
|
|
|
|
bool ok = true;
|
|
|
|
|
|
|
|
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
|
|
|
|
|
|
|
/* skip the header */
|
|
|
|
offset += 8;
|
|
|
|
|
|
|
|
/* add values */
|
2013-01-21 19:11:43 -05:00
|
|
|
ok &= setRawUInt16(data, tlvsize, &offset, 1); /* version */
|
2012-08-02 09:17:53 -04:00
|
|
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_GENID, item->msgId);
|
|
|
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->feedId);
|
|
|
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, item->title);
|
|
|
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_LINK, item->link);
|
|
|
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_VALUE, item->author);
|
|
|
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_COMMENT, item->description);
|
2013-01-21 19:11:43 -05:00
|
|
|
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_COMMENT, item->descriptionTransformed);
|
2012-08-02 09:17:53 -04:00
|
|
|
ok &= setRawUInt32(data, tlvsize, &offset, item->pubDate);
|
|
|
|
ok &= setRawUInt32(data, tlvsize, &offset, item->flag);
|
|
|
|
|
|
|
|
if (offset != tlvsize)
|
|
|
|
{
|
|
|
|
ok = false;
|
|
|
|
std::cerr << "RsFeedReaderSerialiser::serialiseMsg() Size Error! " << std::endl;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
RsFeedReaderMsg *RsFeedReaderSerialiser::deserialiseMsg(void *data, uint32_t *pktsize)
|
|
|
|
{
|
|
|
|
/* get the type and size */
|
|
|
|
uint32_t rstype = getRsItemId(data);
|
|
|
|
uint32_t rssize = getRsItemSize(data);
|
|
|
|
|
|
|
|
uint32_t offset = 0;
|
|
|
|
|
2012-09-04 19:53:04 -04:00
|
|
|
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
|
|
|
|
(RS_SERVICE_TYPE_PLUGIN_FEEDREADER != getRsItemService(rstype)) ||
|
2012-08-02 09:17:53 -04:00
|
|
|
(RS_PKT_SUBTYPE_FEEDREADER_MSG != getRsItemSubType(rstype)))
|
|
|
|
{
|
|
|
|
return NULL; /* wrong type */
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*pktsize < rssize) /* check size */
|
|
|
|
return NULL; /* not enough data */
|
|
|
|
|
|
|
|
/* set the packet length */
|
|
|
|
*pktsize = rssize;
|
|
|
|
|
|
|
|
bool ok = true;
|
|
|
|
|
|
|
|
/* ready to load */
|
|
|
|
RsFeedReaderMsg *item = new RsFeedReaderMsg();
|
|
|
|
item->clear();
|
|
|
|
|
|
|
|
/* skip the header */
|
|
|
|
offset += 8;
|
|
|
|
|
|
|
|
/* get values */
|
2012-09-04 19:53:04 -04:00
|
|
|
uint16_t version = 0;
|
|
|
|
ok &= getRawUInt16(data, rssize, &offset, &version);
|
2012-08-02 09:17:53 -04:00
|
|
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_GENID, item->msgId);
|
|
|
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->feedId);
|
|
|
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_NAME, item->title);
|
|
|
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_LINK, item->link);
|
|
|
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_VALUE, item->author);
|
|
|
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_COMMENT, item->description);
|
2013-01-21 19:11:43 -05:00
|
|
|
if (version >= 1) {
|
|
|
|
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_COMMENT, item->descriptionTransformed);
|
|
|
|
}
|
2012-08-02 09:17:53 -04:00
|
|
|
ok &= getRawUInt32(data, rssize, &offset, (uint32_t*) &(item->pubDate));
|
|
|
|
ok &= getRawUInt32(data, rssize, &offset, &(item->flag));
|
|
|
|
|
|
|
|
if (offset != rssize)
|
|
|
|
{
|
|
|
|
/* error */
|
|
|
|
delete item;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
delete item;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
uint32_t RsFeedReaderSerialiser::size(RsItem *item)
|
|
|
|
{
|
|
|
|
RsFeedReaderFeed *fi;
|
|
|
|
RsFeedReaderMsg *ei;
|
|
|
|
|
|
|
|
if (NULL != (fi = dynamic_cast<RsFeedReaderFeed*>(item)))
|
|
|
|
{
|
|
|
|
return sizeFeed((RsFeedReaderFeed*) item);
|
|
|
|
}
|
|
|
|
if (NULL != (ei = dynamic_cast<RsFeedReaderMsg*>(item)))
|
|
|
|
{
|
|
|
|
return sizeMsg((RsFeedReaderMsg*) item);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RsFeedReaderSerialiser::serialise(RsItem *item, void *data, uint32_t *pktsize)
|
|
|
|
{
|
|
|
|
RsFeedReaderFeed *fi;
|
|
|
|
RsFeedReaderMsg *ei;
|
|
|
|
|
|
|
|
if (NULL != (fi = dynamic_cast<RsFeedReaderFeed*>(item)))
|
|
|
|
{
|
|
|
|
return serialiseFeed((RsFeedReaderFeed*) item, data, pktsize);
|
|
|
|
}
|
|
|
|
if (NULL != (ei = dynamic_cast<RsFeedReaderMsg*>(item)))
|
|
|
|
{
|
|
|
|
return serialiseMsg((RsFeedReaderMsg*) item, data, pktsize);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
RsItem *RsFeedReaderSerialiser::deserialise(void *data, uint32_t *pktsize)
|
|
|
|
{
|
|
|
|
/* get the type and size */
|
|
|
|
uint32_t rstype = getRsItemId(data);
|
|
|
|
|
2012-09-04 19:53:04 -04:00
|
|
|
if ((RS_PKT_VERSION_SERVICE != getRsItemVersion(rstype)) ||
|
|
|
|
(RS_SERVICE_TYPE_PLUGIN_FEEDREADER != getRsItemService(rstype)))
|
2012-08-02 09:17:53 -04:00
|
|
|
{
|
|
|
|
return NULL; /* wrong type */
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (getRsItemSubType(rstype))
|
|
|
|
{
|
|
|
|
case RS_PKT_SUBTYPE_FEEDREADER_FEED:
|
|
|
|
return deserialiseFeed(data, pktsize);
|
|
|
|
case RS_PKT_SUBTYPE_FEEDREADER_MSG:
|
|
|
|
return deserialiseMsg(data, pktsize);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|