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,96 +0,0 @@
#ifndef RETROSHARE_RANKING_GUI_INTERFACE_H
#define RETROSHARE_RANKING_GUI_INTERFACE_H
/*
* libretroshare/src/rsiface: rsrank.h
*
* RetroShare C++ Interface.
*
* 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 <inttypes.h>
#include <string>
#include <list>
/* The Main Interface Class - for information about your Peers */
class RsRanks;
extern RsRanks *rsRanks;
class RsRankComment
{
public:
std::string id;
std::wstring comment;
int32_t score;
time_t timestamp;
};
class RsRankDetails
{
public:
std::string rid;
std::wstring link;
std::wstring title;
float rank;
bool ownTag;
std::list<RsRankComment> comments;
};
const uint32_t RS_RANK_SCORE = 0x0001;
const uint32_t RS_RANK_TIME = 0x0002;
const uint32_t RS_RANK_ALG = 0x0003;
std::ostream &operator<<(std::ostream &out, const RsRankDetails &detail);
class RsRanks
{
public:
RsRanks() { return; }
virtual ~RsRanks() { return; }
/* needs update? */
virtual bool updated() = 0;
/* Set Sort Methods */
virtual bool setSortPeriod(uint32_t period) = 0;
virtual bool setSortMethod(uint32_t type) = 0;
virtual bool clearPeerFilter() = 0;
virtual bool setPeerFilter(std::list<std::string> peers) = 0;
/* get Ids */
virtual uint32_t getRankingsCount() = 0;
virtual float getMaxRank() = 0;
virtual bool getRankings(uint32_t first, uint32_t count, std::list<std::string> &rids) = 0;
virtual bool getRankDetails(std::string rid, RsRankDetails &details) = 0;
/* Add New Comment / Msg */
virtual std::string newRankMsg(std::wstring link, std::wstring title, std::wstring comment, int32_t score) = 0;
virtual bool updateComment(std::string rid, std::wstring comment, int32_t score) = 0;
virtual std::string anonRankMsg(std::string rid, std::wstring link, std::wstring title) = 0;
};
#endif

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 */

File diff suppressed because it is too large Load diff

View file

@ -1,167 +0,0 @@
/*
* libretroshare/src/services: p3ranking.h
*
* 3P/PQI network interface for RetroShare.
*
* 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".
*
*/
#ifndef P3_GENERIC_RANKING_HEADER
#define P3_GENERIC_RANKING_HEADER
#include "dbase/cachestrapper.h"
#include "pqi/pqiservice.h"
#include "pqi/pqistore.h"
#include "pqi/p3connmgr.h"
#include "pqi/p3cfgmgr.h"
#include "serialiser/rsserial.h"
#include "retroshare/rsrank.h"
/*
* A Generic Ranking system.
* Each User provides one cache...
*
* can be overloaded for specific types
* (links, shares, photos etc)
*
* This is not generic yet!!!
*/
class RsRankMsg;
class RsRankLinkMsg;
class RankGroup
{
public:
std::string rid; /* Random Id */
std::wstring link;
std::wstring title;
float rank;
bool ownTag;
std::map<std::string, RsRankLinkMsg *> comments;
};
class p3Ranking: public CacheSource, public CacheStore, public p3Config
{
public:
p3Ranking(p3ConnectMgr *connMgr,
uint16_t type, CacheStrapper *cs, CacheTransfer *cft,
std::string sourcedir, std::string storedir,
uint32_t storePeriod);
/******************************* CACHE SOURCE / STORE Interface *********************/
/* overloaded functions from Cache Source */
virtual bool loadLocalCache(const CacheData &data);
/* overloaded functions from Cache Store */
virtual int loadCache(const CacheData &data);
/******************************* CACHE SOURCE / STORE Interface *********************/
public:
/************* Extern Interface *******/
/* changed */
virtual bool updated();
/* Set Sort Methods */
virtual bool setSortPeriod(uint32_t period);
virtual bool setSortMethod(uint32_t type);
virtual bool clearPeerFilter();
virtual bool setPeerFilter(std::list<std::string> peers);
/* get Ids */
virtual uint32_t getRankingsCount();
virtual float getMaxRank();
virtual bool getRankings(uint32_t first, uint32_t count, std::list<std::string> &rids);
virtual bool getRankDetails(std::string rid, RsRankDetails &details);
/* Add New Comment / Msg */
virtual std::string newRankMsg(std::wstring link, std::wstring title, std::wstring comment, int32_t score);
virtual bool updateComment(std::string rid, std::wstring comment, int32_t score);
virtual std::string anonRankMsg(std::string rid, std::wstring link, std::wstring title);
void tick();
void loadRankFile(std::string filename, std::string src);
void addRankMsg(RsRankLinkMsg *msg);
void publishMsgs(bool own);
float locked_calcRank(RankGroup &grp); /* returns 0->100 */
void locked_reSortGroup(RankGroup &grp);
void sortAllMsgs();
pqistore *createStore(std::string file, std::string src, bool reading);
/****************** p3Config STUFF *******************/
protected:
bool addAnonToList(RsRankLinkMsg *msg);
virtual RsSerialiser *setupSerialiser();
virtual bool saveList(bool &cleanup, std::list<RsItem *>&);
virtual bool loadList(std::list<RsItem *>& load);
virtual void saveDone();
private:
void createDummyData();
p3ConnectMgr *mConnMgr;
RsMutex mRankMtx;
/***** below here is locked *****/
bool mRepublish;
bool mRepublishFriends;
time_t mRepublishFriendTS;
uint32_t mStorePeriod;
std::string mOwnId;
bool mUpdated;
bool mRepost;
std::map<std::string, RankGroup> mData;
std::multimap<float, std::string> mRankings;
/* Filter/Sort params */
std::list<std::string> mPeerFilter;
uint32_t mViewPeriod;
uint32_t mSortType;
/* Anonymous Link List */
std::list<RsRankLinkMsg *> mAnon;
};
#endif