removed LinkCloud files from main executable

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4395 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2011-07-05 20:56:58 +00:00
parent 367d1aa790
commit cca2962116
12 changed files with 0 additions and 4185 deletions

View file

@ -1,253 +0,0 @@
/*
* libretroshare/src/serialiser: rsbaseitems.cc
*
* RetroShare Serialiser.
*
* Copyright 2007-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "serialiser/rsbaseserial.h"
#include "serialiser/rsrankitems.h"
#include "serialiser/rstlvbase.h"
#define RSSERIAL_DEBUG 1
#include <iostream>
/*************************************************************************/
void RsRankMsg::clear()
{
rid.clear();
timestamp = 0;
title.clear();
comment.clear();
}
std::ostream &RsRankMsg::print(std::ostream &out, uint16_t indent)
{
printRsItemBase(out, "RsRankMsg", indent);
uint16_t int_Indent = indent + 2;
printIndent(out, int_Indent);
out << "rid: " << rid << std::endl;
printIndent(out, int_Indent);
out << "timestamp: " << timestamp << std::endl;
printIndent(out, int_Indent);
std::string cnv_title(title.begin(), title.end());
out << "msg: " << cnv_title << std::endl;
printIndent(out, int_Indent);
std::string cnv_comment(comment.begin(), comment.end());
out << "comment: " << cnv_comment << std::endl;
printIndent(out, int_Indent);
out << "score: " << score << std::endl;
printRsItemEnd(out, "RsRankMsg", indent);
return out;
}
/*************************************************************************/
void RsRankLinkMsg::clear()
{
rid.clear();
pid.clear();
timestamp = 0;
title.clear();
comment.clear();
score = 0;
linktype = 0;
link.clear();
}
std::ostream &RsRankLinkMsg::print(std::ostream &out, uint16_t indent)
{
printRsItemBase(out, "RsRankLinkMsg", indent);
uint16_t int_Indent = indent + 2;
printIndent(out, int_Indent);
out << "rid: " << rid << std::endl;
printIndent(out, int_Indent);
out << "pid: " << pid << std::endl;
printIndent(out, int_Indent);
out << "timestamp: " << timestamp << std::endl;
printIndent(out, int_Indent);
std::string cnv_title(title.begin(), title.end());
out << "msg: " << cnv_title << std::endl;
printIndent(out, int_Indent);
std::string cnv_comment(comment.begin(), comment.end());
out << "comment: " << cnv_comment << std::endl;
printIndent(out, int_Indent);
out << "score: " << score << std::endl;
printIndent(out, int_Indent);
out << "linktype: " << linktype << std::endl;
printIndent(out, int_Indent);
std::string cnv_link(link.begin(), link.end());
out << "link: " << cnv_link << std::endl;
printRsItemEnd(out, "RsRankLinkMsg", indent);
return out;
}
uint32_t RsRankSerialiser::sizeLink(RsRankLinkMsg *item)
{
uint32_t s = 8; /* header */
s += GetTlvStringSize(item->rid);
s += GetTlvStringSize(item->pid);
s += 4; /* timestamp */
s += GetTlvWideStringSize(item->title);
s += GetTlvWideStringSize(item->comment);
s += 4; /* score */
s += 4; /* linktype */
s += GetTlvWideStringSize(item->link);
return s;
}
/* serialise the data to the buffer */
bool RsRankSerialiser::serialiseLink(RsRankLinkMsg *item, void *data, uint32_t *pktsize)
{
uint32_t tlvsize = sizeLink(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 mandatory parts first */
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_GENID, item->rid);
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_PEERID, item->pid);
ok &= setRawUInt32(data, tlvsize, &offset, item->timestamp);
ok &= SetTlvWideString(data, tlvsize, &offset, TLV_TYPE_WSTR_TITLE, item->title);
ok &= SetTlvWideString(data, tlvsize, &offset, TLV_TYPE_WSTR_COMMENT, item->comment);
ok &= setRawUInt32(data, tlvsize, &offset, *((uint32_t *) &(item->score)));
ok &= setRawUInt32(data, tlvsize, &offset, item->linktype);
ok &= SetTlvWideString(data, tlvsize, &offset, TLV_TYPE_WSTR_LINK, item->link);
if (offset != tlvsize)
{
ok = false;
std::cerr << "RsRankLinkSerialiser::serialiseLink() Size Error! " << std::endl;
}
return ok;
}
RsRankLinkMsg *RsRankSerialiser::deserialiseLink(void *data, uint32_t *pktsize)
{
/* 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)) ||
(RS_SERVICE_TYPE_RANK != getRsItemService(rstype)) ||
(RS_PKT_SUBTYPE_RANK_LINK3 != 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 */
RsRankLinkMsg *item = new RsRankLinkMsg();
item->clear();
/* skip the header */
offset += 8;
/* get mandatory parts first */
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_GENID, item->rid);
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_PEERID, item->pid);
ok &= getRawUInt32(data, rssize, &offset, &(item->timestamp));
ok &= GetTlvWideString(data, rssize, &offset, TLV_TYPE_WSTR_TITLE, item->title);
ok &= GetTlvWideString(data, rssize, &offset, TLV_TYPE_WSTR_COMMENT, item->comment);
ok &= getRawUInt32(data, rssize, &offset, (uint32_t *) &(item->score));
ok &= getRawUInt32(data, rssize, &offset, &(item->linktype));
ok &= GetTlvWideString(data, rssize, &offset, TLV_TYPE_WSTR_LINK, item->link);
if (offset != rssize)
{
/* error */
delete item;
return NULL;
}
if (!ok)
{
delete item;
return NULL;
}
return item;
}
uint32_t RsRankSerialiser::size(RsItem *item)
{
return sizeLink((RsRankLinkMsg *) item);
}
bool RsRankSerialiser::serialise(RsItem *item, void *data, uint32_t *pktsize)
{
return serialiseLink((RsRankLinkMsg *) item, data, pktsize);
}
RsItem *RsRankSerialiser::deserialise(void *data, uint32_t *pktsize)
{
return deserialiseLink(data, pktsize);
}
/*************************************************************************/

View file

@ -1,115 +0,0 @@
#ifndef RS_RANK_ITEMS_H
#define RS_RANK_ITEMS_H
/*
* libretroshare/src/serialiser: rsrankitems.h
*
* RetroShare Serialiser.
*
* Copyright 2007-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include <map>
#include "serialiser/rsserviceids.h"
#include "serialiser/rsserial.h"
#include "serialiser/rstlvtypes.h"
const uint8_t RS_PKT_SUBTYPE_RANK_OLD_LINK = 0x02; /* defunct - don't use! */
const uint8_t RS_PKT_SUBTYPE_RANK_OLD_LINK2 = 0x03;
const uint8_t RS_PKT_SUBTYPE_RANK_LINK3 = 0x04;
const uint8_t RS_PKT_SUBTYPE_RANK_PHOTO = 0x05;
/**************************************************************************/
class RsRankMsg: public RsItem
{
public:
RsRankMsg(uint8_t subtype)
:RsItem(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_RANK,
subtype) { return; }
virtual ~RsRankMsg() { return; }
virtual void clear();
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
std::string rid; /* Random Id */
std::string pid; /* Peer Id (cannot use RsItem::PeerId - as FoF transport!) */
uint32_t timestamp;
std::wstring title;
std::wstring comment;
int32_t score;
};
/* Flags */
const uint32_t RS_LINK_TYPE_WEB = 0x0001;
const uint32_t RS_LINK_TYPE_OFF = 0x0002;
class RsRankLinkMsg: public RsRankMsg
{
public:
RsRankLinkMsg()
:RsRankMsg(RS_PKT_SUBTYPE_RANK_LINK3) { return; }
virtual ~RsRankLinkMsg() { return; }
virtual void clear();
virtual std::ostream& print(std::ostream &out, uint16_t indent = 0);
/**** SAME as RsRankMsg ****
std::string rid;
uint32_t timestamp;
std::wstring title;
std::wstring comment;
int32_t score;
***************************/
/* Link specific Fields */
uint32_t linktype; /* to be used later! */
std::wstring link;
};
class RsRankSerialiser: public RsSerialType
{
public:
RsRankSerialiser()
:RsSerialType(RS_PKT_VERSION_SERVICE, RS_SERVICE_TYPE_RANK)
{ return; }
virtual ~RsRankSerialiser()
{ return; }
virtual uint32_t size(RsItem *);
virtual bool serialise (RsItem *item, void *data, uint32_t *size);
virtual RsItem * deserialise(void *data, uint32_t *size);
private:
/* For RS_PKT_SUBTYPE_RANK_LINK */
virtual uint32_t sizeLink(RsRankLinkMsg *);
virtual bool serialiseLink (RsRankLinkMsg *item, void *data, uint32_t *size);
virtual RsRankLinkMsg *deserialiseLink(void *data, uint32_t *size);
};
/**************************************************************************/
#endif /* RS_RANK_ITEMS_H */