mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 16:39:29 -05:00
removed old/unreferenced gxs source files. Moved unfinished ideas for wire+acadb to unfinished/
This commit is contained in:
parent
5f86ac1e3c
commit
b53e75ae82
@ -1,454 +0,0 @@
|
||||
/*
|
||||
* libretroshare/src/ft: ftdbase.cc
|
||||
*
|
||||
* File Transfer for RetroShare.
|
||||
*
|
||||
* Copyright 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 "ft/ftdbase.h"
|
||||
#include "util/rsdir.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
|
||||
#include "serialiser/rsconfigitems.h"
|
||||
|
||||
//#define DB_DEBUG 1
|
||||
|
||||
ftFiStore::ftFiStore(CacheStrapper *cs, CacheTransfer *cft, p3PeerMgr *pm,
|
||||
RsPeerId ownid, std::string cachedir)
|
||||
:FileIndexStore(cs, cft, pm, ownid, cachedir)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool ftFiStore::search(const RsFileHash &hash, FileSearchFlags hintflags, FileInfo &info) const
|
||||
{
|
||||
/* could use hintflags to specify which bits of fileinfo to use additionally.
|
||||
eg. hintflags & FT_SEARCH_PEER_ID, then only return matching peers + hash.
|
||||
eg. hintflags & FT_SEARCH_NAME, then only return matching name + hash.
|
||||
*
|
||||
* Still to see if concept is worthwhle
|
||||
*/
|
||||
|
||||
/* remove unused parameter warnings */
|
||||
(void) hintflags;
|
||||
|
||||
#ifdef DB_DEBUG
|
||||
std::cerr << "ftFiStore::search(" << hash << "," << hintflags;
|
||||
std::cerr << ")";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::list<FileDetail> results;
|
||||
std::list<FileDetail>::iterator it;
|
||||
|
||||
if (SearchHash(hash, results))
|
||||
{
|
||||
bool first = true;
|
||||
for(it = results.begin(); it != results.end(); ++it)
|
||||
{
|
||||
#ifdef DB_DEBUG
|
||||
std::cerr << "ftFiStore::search() found: ";
|
||||
std::cerr << it->name << " (" << it->size;
|
||||
std::cerr << ") @ " << it->id << " = " << hash;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
bool fullmatch = true;
|
||||
|
||||
// if (it->size != size)
|
||||
// fullmatch = false;
|
||||
|
||||
|
||||
#if 0
|
||||
if (hintflags & FT_SEARCH_PEER_ID)
|
||||
{
|
||||
pit = std::find(info.srcIds.begin(),
|
||||
info.srcId.end(). it->id);
|
||||
if (pit == info.srcIds.end())
|
||||
{
|
||||
fullmatch = false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if (fullmatch)
|
||||
{
|
||||
if (first)
|
||||
{
|
||||
first = false;
|
||||
info.fname = it->name;
|
||||
info.size = it->size;
|
||||
info.hash = it->hash;
|
||||
|
||||
}
|
||||
|
||||
TransferInfo ti;
|
||||
ti.peerId = it->id;
|
||||
ti.name = it->name;
|
||||
ti.tfRate = 0;
|
||||
info.peers.push_back(ti);
|
||||
}
|
||||
}
|
||||
|
||||
/**** DEPENDS ON SOURCES!
|
||||
info.downloadStatus = FT_STATE_COMPLETE:
|
||||
****/
|
||||
|
||||
/* if the first flag is cleared, we've definitely
|
||||
* had a full match!.
|
||||
*/
|
||||
|
||||
if (!first)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
ftFiMonitor::ftFiMonitor(CacheStrapper *cs,std::string cachedir, const RsPeerId& pid,const std::string& config_dir)
|
||||
:FileIndexMonitor(cs,cachedir, pid,config_dir), p3Config()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool ftFiMonitor::search(const RsFileHash &hash, FileSearchFlags hintflags, FileInfo &info) const
|
||||
{
|
||||
return search(hash,hintflags,RsPeerId(),info) ;
|
||||
}
|
||||
bool ftFiMonitor::search(const RsFileHash &hash, FileSearchFlags hintflags, const RsPeerId& peer_id,FileInfo &info) const
|
||||
{
|
||||
#ifdef DB_DEBUG
|
||||
std::cerr << "ftFiMonitor::search(" << hash << "," << hintflags;
|
||||
std::cerr << ")";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
// Setup search flags according to hintflags. Originally flags was 0. I (cyril) don't know
|
||||
// why we don't just pass hintflags there, so I tried to keep the idea.
|
||||
//
|
||||
FileSearchFlags flags = hintflags ;
|
||||
flags &= (RS_FILE_HINTS_BROWSABLE | RS_FILE_HINTS_NETWORK_WIDE);
|
||||
|
||||
if(findLocalFile(hash, flags,peer_id,info.path, info.size,info.storage_permission_flags,info.parent_groups))
|
||||
{
|
||||
/* fill in details */
|
||||
#ifdef DB_DEBUG
|
||||
std::cerr << "ftFiMonitor::search() found: ";
|
||||
std::cerr << path;
|
||||
std::cerr << " = " << hash << "," << fsize;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
info.fname = RsDirUtil::getTopDir(info.path);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
int ftFiMonitor::watchPeriod() const
|
||||
{
|
||||
return getPeriod() ;
|
||||
}
|
||||
void ftFiMonitor::setWatchPeriod(int seconds)
|
||||
{
|
||||
setPeriod(seconds) ;// call FileIndexMonitor
|
||||
IndicateConfigChanged() ;
|
||||
}
|
||||
|
||||
void ftFiMonitor::setRememberHashCacheDuration(uint32_t days)
|
||||
{
|
||||
setRememberHashFilesDuration(days) ; // calls FileIndexMonitor
|
||||
IndicateConfigChanged() ;
|
||||
}
|
||||
uint32_t ftFiMonitor::rememberHashCacheDuration() const
|
||||
{
|
||||
return rememberHashFilesDuration() ; // calls FileIndexMonitor
|
||||
}
|
||||
void ftFiMonitor::setRememberHashCache(bool b)
|
||||
{
|
||||
setRememberHashFiles(b) ; // calls FileIndexMonitor
|
||||
IndicateConfigChanged() ;
|
||||
}
|
||||
bool ftFiMonitor::rememberHashCache()
|
||||
{
|
||||
return rememberHashFiles() ; // calls FileIndexMonitor
|
||||
}
|
||||
void ftFiMonitor::clearHashCache()
|
||||
{
|
||||
clearHashFiles() ;
|
||||
}
|
||||
|
||||
/******* LOAD / SAVE CONFIG List.
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
RsSerialiser *ftFiMonitor::setupSerialiser()
|
||||
{
|
||||
RsSerialiser *rss = new RsSerialiser();
|
||||
|
||||
/* add in the types we need! */
|
||||
rss->addSerialType(new RsFileConfigSerialiser());
|
||||
rss->addSerialType(new RsGeneralConfigSerialiser());
|
||||
|
||||
return rss;
|
||||
}
|
||||
|
||||
const std::string hash_cache_duration_ss("HASH_CACHE_DURATION");
|
||||
const std::string hash_cache_ss("HASH_CACHE");
|
||||
const std::string watch_file_duration_ss("WATCH_FILES_DELAY");
|
||||
|
||||
bool ftFiMonitor::saveList(bool &cleanup, std::list<RsItem *>& sList)
|
||||
{
|
||||
|
||||
|
||||
cleanup = true;
|
||||
|
||||
#ifdef DB_DEBUG
|
||||
std::cerr << "ftFiMonitor::saveList()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
/* get list of directories */
|
||||
std::list<SharedDirInfo> dirList;
|
||||
std::list<SharedDirInfo>::iterator it;
|
||||
|
||||
getSharedDirectories(dirList);
|
||||
|
||||
for(it = dirList.begin(); it != dirList.end(); ++it)
|
||||
{
|
||||
RsFileConfigItem *fi = new RsFileConfigItem();
|
||||
fi->file.path = (*it).filename ;
|
||||
fi->file.name = (*it).virtualname ;
|
||||
fi->flags = (*it).shareflags.toUInt32() ;
|
||||
|
||||
for(std::list<RsNodeGroupId>::const_iterator it2( (*it).parent_groups.begin());it2!=(*it).parent_groups.end();++it2)
|
||||
fi->parent_groups.ids.insert(*it2) ;
|
||||
|
||||
sList.push_back(fi);
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> configMap;
|
||||
|
||||
/* basic control parameters */
|
||||
{
|
||||
std::string s ;
|
||||
rs_sprintf(s, "%lu", rememberHashFilesDuration()) ;
|
||||
|
||||
configMap[hash_cache_duration_ss] = s ;
|
||||
}
|
||||
configMap[hash_cache_ss] = rememberHashFiles()?"YES":"NO" ;
|
||||
|
||||
{
|
||||
std::string s ;
|
||||
rs_sprintf(s, "%d", watchPeriod()) ;
|
||||
|
||||
configMap[watch_file_duration_ss] = s ;
|
||||
}
|
||||
|
||||
RsConfigKeyValueSet *rskv = new RsConfigKeyValueSet();
|
||||
|
||||
/* Convert to TLV */
|
||||
for(std::map<std::string,std::string>::const_iterator mit = configMap.begin(); mit != configMap.end(); ++mit)
|
||||
{
|
||||
RsTlvKeyValue kv;
|
||||
kv.key = mit->first;
|
||||
kv.value = mit->second;
|
||||
|
||||
rskv->tlvkvs.pairs.push_back(kv);
|
||||
}
|
||||
|
||||
/* Add KeyValue to saveList */
|
||||
sList.push_back(rskv);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool ftFiMonitor::loadList(std::list<RsItem *>& load)
|
||||
{
|
||||
/* for each item, check it exists ....
|
||||
* - remove any that are dead (or flag?)
|
||||
*/
|
||||
static const FileStorageFlags PERMISSION_MASK = DIR_FLAGS_BROWSABLE_OTHERS | DIR_FLAGS_NETWORK_WIDE_OTHERS | DIR_FLAGS_BROWSABLE_GROUPS | DIR_FLAGS_NETWORK_WIDE_GROUPS ;
|
||||
|
||||
#ifdef DEBUG_ELIST
|
||||
std::cerr << "ftFiMonitor::loadList()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
std::list<SharedDirInfo> dirList;
|
||||
|
||||
std::list<RsItem *>::iterator it;
|
||||
for(it = load.begin(); it != load.end(); ++it)
|
||||
{
|
||||
RsConfigKeyValueSet *rskv ;
|
||||
/* switch on type */
|
||||
if (NULL != (rskv = dynamic_cast<RsConfigKeyValueSet *>(*it)))
|
||||
{
|
||||
/* make into map */
|
||||
std::map<std::string, std::string> configMap;
|
||||
std::map<std::string, std::string>::const_iterator mit ;
|
||||
|
||||
for(std::list<RsTlvKeyValue>::const_iterator kit = rskv->tlvkvs.pairs.begin(); kit != rskv->tlvkvs.pairs.end(); ++kit)
|
||||
{
|
||||
configMap[kit->key] = kit->value;
|
||||
}
|
||||
|
||||
if (configMap.end() != (mit = configMap.find(hash_cache_duration_ss)))
|
||||
{
|
||||
uint32_t t=0 ;
|
||||
if(sscanf(mit->second.c_str(),"%d",&t) == 1)
|
||||
setRememberHashFilesDuration(t);
|
||||
}
|
||||
if(configMap.end() != (mit = configMap.find(hash_cache_ss)))
|
||||
setRememberHashFiles( mit->second == "YES") ;
|
||||
|
||||
if(configMap.end() != (mit = configMap.find(watch_file_duration_ss)))
|
||||
{
|
||||
int t=0 ;
|
||||
if(sscanf(mit->second.c_str(),"%d",&t) == 1)
|
||||
setWatchPeriod(t);
|
||||
}
|
||||
delete *it ;
|
||||
continue ;
|
||||
}
|
||||
|
||||
// 07/05/2016 - This ensures backward compatibility. Can be removed in a few weeks.
|
||||
RsFileConfigItem_deprecated *fib = dynamic_cast<RsFileConfigItem_deprecated *>(*it);
|
||||
if (fib)
|
||||
{
|
||||
/* ensure that it exists? */
|
||||
|
||||
SharedDirInfo info ;
|
||||
info.filename = RsDirUtil::convertPathToUnix(fib->file.path);
|
||||
info.virtualname = fib->file.name;
|
||||
info.shareflags = FileStorageFlags(fib->flags) ;
|
||||
info.shareflags &= PERMISSION_MASK ;
|
||||
info.shareflags &= ~DIR_FLAGS_NETWORK_WIDE_GROUPS ; // disabling this flag for know, for consistency reasons
|
||||
|
||||
for(std::list<std::string>::const_iterator itt(fib->parent_groups.begin());itt!=fib->parent_groups.end();++itt)
|
||||
{
|
||||
RsGroupInfo ginfo;
|
||||
|
||||
if(rsPeers->getGroupInfoByName(*itt,ginfo) )
|
||||
{
|
||||
info.parent_groups.push_back(ginfo.id) ;
|
||||
std::cerr << "(II) converted old group ID \"" << *itt << "\" into corresponding new group id " << ginfo.id << std::endl;
|
||||
}
|
||||
else
|
||||
std::cerr << "(EE) cannot convert old group ID \"" << *itt << "\" into corresponding new group id: no candidate found. " << std::endl;
|
||||
}
|
||||
|
||||
dirList.push_back(info) ;
|
||||
}
|
||||
|
||||
RsFileConfigItem *fi = dynamic_cast<RsFileConfigItem *>(*it);
|
||||
if (fi)
|
||||
{
|
||||
/* ensure that it exists? */
|
||||
|
||||
SharedDirInfo info ;
|
||||
info.filename = RsDirUtil::convertPathToUnix(fi->file.path);
|
||||
info.virtualname = fi->file.name;
|
||||
info.shareflags = FileStorageFlags(fi->flags) ;
|
||||
info.shareflags &= PERMISSION_MASK ;
|
||||
info.shareflags &= ~DIR_FLAGS_NETWORK_WIDE_GROUPS ; // disabling this flag for know, for consistency reasons
|
||||
|
||||
for(std::set<RsNodeGroupId>::const_iterator itt(fi->parent_groups.ids.begin());itt!=fi->parent_groups.ids.end();++itt)
|
||||
info.parent_groups.push_back(*itt) ;
|
||||
|
||||
dirList.push_back(info) ;
|
||||
}
|
||||
|
||||
delete *it ;
|
||||
}
|
||||
|
||||
/* set directories */
|
||||
setSharedDirectories(dirList);
|
||||
load.clear() ;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ftFiMonitor::updateShareFlags(const SharedDirInfo& info)
|
||||
{
|
||||
std::cerr << "Updating share flags:" << std::endl;
|
||||
std::cerr << " Directory : " << info.filename << std::endl;
|
||||
std::cerr << " Virtual : " << info.virtualname << std::endl;
|
||||
std::cerr << " Flags : " << info.shareflags << std::endl;
|
||||
|
||||
FileIndexMonitor::updateShareFlags(info);
|
||||
|
||||
/* flag for config */
|
||||
IndicateConfigChanged();
|
||||
}
|
||||
|
||||
void ftFiMonitor::setSharedDirectories(const std::list<SharedDirInfo>& dirList)
|
||||
{
|
||||
FileIndexMonitor::setSharedDirectories(dirList);
|
||||
|
||||
/* flag for config */
|
||||
IndicateConfigChanged();
|
||||
}
|
||||
|
||||
|
||||
|
||||
ftCacheStrapper::ftCacheStrapper(p3ServiceControl *sc, uint32_t ftServiceId)
|
||||
:CacheStrapper(sc, ftServiceId)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* overloaded search function */
|
||||
bool ftCacheStrapper::search(const RsFileHash &hash, FileSearchFlags hintflags, FileInfo &info) const
|
||||
{
|
||||
/* remove unused parameter warnings */
|
||||
(void) hintflags;
|
||||
|
||||
#ifdef DB_DEBUG
|
||||
std::cerr << "ftCacheStrapper::search(" << hash << "," << hintflags;
|
||||
std::cerr << ")";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
RsCacheData data;
|
||||
if (findCache(hash, data))
|
||||
{
|
||||
#ifdef DB_DEBUG
|
||||
std::cerr << "ftCacheStrapper::search() found: ";
|
||||
std::cerr << data.path << "/" << data.name;
|
||||
std::cerr << " = " << data.hash << "," << data.size;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
/* ... */
|
||||
info.size = data.size;
|
||||
info.fname = data.name;
|
||||
info.path = data.path + "/" + data.name;
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1,104 +0,0 @@
|
||||
/*
|
||||
* libretroshare/src/ft: ftdbase.h
|
||||
*
|
||||
* File Transfer for RetroShare.
|
||||
*
|
||||
* Copyright 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 FT_DBASE_INTERFACE_HEADER
|
||||
#define FT_DBASE_INTERFACE_HEADER
|
||||
|
||||
/*
|
||||
* ftdbase.
|
||||
*
|
||||
* Wrappers for the Cache/FiStore/FiMonitor classes.
|
||||
* So they work in the ft world.
|
||||
*/
|
||||
|
||||
class p3LinkMgr ;
|
||||
class p3PeerMgr ;
|
||||
class p3ServiceControl ;
|
||||
|
||||
|
||||
#include "ft/ftsearch.h"
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
|
||||
#include "dbase/fistore.h"
|
||||
#include "dbase/fimonitor.h"
|
||||
#include "dbase/cachestrapper.h"
|
||||
|
||||
|
||||
class ftFiStore: public FileIndexStore, public ftSearch
|
||||
{
|
||||
public:
|
||||
ftFiStore(CacheStrapper *cs, CacheTransfer *cft, p3PeerMgr *pm,
|
||||
RsPeerId ownid, std::string cachedir);
|
||||
|
||||
/* overloaded search function */
|
||||
virtual bool search(const RsFileHash &hash, FileSearchFlags hintflags, FileInfo &info) const;
|
||||
};
|
||||
|
||||
class ftFiMonitor: public FileIndexMonitor, public ftSearch, public p3Config
|
||||
{
|
||||
public:
|
||||
ftFiMonitor(CacheStrapper *cs,std::string cachedir, const RsPeerId& pid,const std::string& config_dir);
|
||||
|
||||
/* overloaded search function */
|
||||
virtual bool search(const RsFileHash &hash, FileSearchFlags hintflags, FileInfo &info) const;
|
||||
virtual bool search(const RsFileHash &hash, FileSearchFlags hintflags, const RsPeerId& peer_id, FileInfo &info) const;
|
||||
|
||||
/* overloaded set dirs enables config indication */
|
||||
virtual void setSharedDirectories(const std::list<SharedDirInfo>& dirList);
|
||||
virtual void updateShareFlags(const SharedDirInfo& info) ;
|
||||
|
||||
void setRememberHashCacheDuration(uint32_t days) ;
|
||||
uint32_t rememberHashCacheDuration() const ;
|
||||
void setRememberHashCache(bool) ;
|
||||
bool rememberHashCache() ;
|
||||
void clearHashCache() ;
|
||||
void setWatchPeriod(int seconds) ; // can be negative, which means auto-check disabled.
|
||||
int watchPeriod() const ;
|
||||
|
||||
/***
|
||||
* Configuration - store shared directories
|
||||
*/
|
||||
protected:
|
||||
|
||||
virtual RsSerialiser *setupSerialiser();
|
||||
virtual bool saveList(bool &cleanup, std::list<RsItem *>&);
|
||||
virtual bool loadList(std::list<RsItem *>& load);
|
||||
|
||||
|
||||
};
|
||||
|
||||
class ftCacheStrapper: public CacheStrapper, public ftSearch
|
||||
{
|
||||
public:
|
||||
ftCacheStrapper(p3ServiceControl *cm, uint32_t ftServiceId);
|
||||
|
||||
/* overloaded search function */
|
||||
virtual bool search(const RsFileHash &hash, FileSearchFlags hintflags, FileInfo &info) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,158 +0,0 @@
|
||||
/*
|
||||
* libretroshare/src/gxp: gxp.h
|
||||
*
|
||||
* General Exchange Protocol interface for RetroShare.
|
||||
*
|
||||
* Copyright 2011-2011 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 RS_GIXP_H
|
||||
#define RS_GIXP_H
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* GIXP: General Identity Exchange Protocol.
|
||||
*
|
||||
* As we're always running into troubles with GPG signatures... we are going to
|
||||
* create a layer of RSA Keys for the following properties:
|
||||
*
|
||||
* 1) RSA Keys can be Anonymous, Self-Signed with Pseudonym, Signed by GPG Key.
|
||||
* - Anonymous & Pseudonym Keys will be shared network-wide (Hop by Hop).
|
||||
- GPG signed Keys will only be shared if we can validate the signature
|
||||
(providing similar behaviour to existing GPG Keys).
|
||||
- GPG signed Keys can optionally be marked for Network-wide sharing.
|
||||
* 2) These keys can be used anywhere, specifically in the protocols described below.
|
||||
* 3) These keys can be used to sign, encrypt, verify & decrypt
|
||||
* 4) Keys will never need to be directly accessed - stored in this class.
|
||||
* 5) They will be cached locally and exchanged p2p, by pull request.
|
||||
* 6) This class will use the generalised packet storage for efficient caching & loading.
|
||||
* 7) Data will be stored encrypted.
|
||||
*
|
||||
*
|
||||
*****/
|
||||
|
||||
|
||||
class gixp::key
|
||||
{
|
||||
gxip::keyref mKeyId;
|
||||
|
||||
PubKey *pubKey;
|
||||
PrivateKey *privKey; /* NULL if non-existant */
|
||||
};
|
||||
|
||||
|
||||
/* As we want GPG signed profiles, to be usable as PSEUDONYMS further afield,
|
||||
* we will split them out, and distribute them seperately.
|
||||
*
|
||||
* So a key can have multiple profiles associated with it.
|
||||
* - They should always have a self-signed one.
|
||||
* - optionally have a gpg-signed one.
|
||||
*/
|
||||
|
||||
class gixp::profile
|
||||
{
|
||||
public:
|
||||
|
||||
gxip::keyref mKeyId;
|
||||
|
||||
std::string mName;
|
||||
rstime_t mTimestamp; /* superseded by newer timestamps */
|
||||
uint32_t mProfileType; /* ANONYMOUS (no name, self-signed), PSEUDONYM (self-signed), GPG (name=gpgid, gpgsigned), REVOCATION?? */
|
||||
gpp::permissions mPermissions;
|
||||
|
||||
gxip::signature mSignature;
|
||||
};
|
||||
|
||||
|
||||
class gxip::keyref
|
||||
{
|
||||
std::string keyId;
|
||||
}
|
||||
|
||||
class gxip::keyrefset
|
||||
{
|
||||
std::list<gxip::keyref> keyIds;
|
||||
}
|
||||
|
||||
class gxip::signature
|
||||
{
|
||||
gxip::keyref signer;
|
||||
std::string signature;
|
||||
}
|
||||
|
||||
class gxip::signset
|
||||
{
|
||||
std::list<gxip::signature> signs;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* We will pinch an idea from Amplify & Briar... of using reputations to decide
|
||||
* if we display or distribute messages.
|
||||
*
|
||||
* The Reputation will be associated with the Profile - It has to be stored
|
||||
* independently of the messages - which will not be touched.
|
||||
*
|
||||
* This part of the code will have to be worked out.
|
||||
*/
|
||||
|
||||
class gxip::reputation
|
||||
{
|
||||
gxip::keyref;
|
||||
|
||||
int16_t score; /* -1000 => 1000 ??? */
|
||||
std::string comment;
|
||||
|
||||
gxip::signature sign;
|
||||
};
|
||||
|
||||
|
||||
/*******
|
||||
* NOTES:
|
||||
* 1) much of this is already implemented in libretroshare/src/distrib/distribsecurity.cc
|
||||
* 2) Data types will need to be shoehorned into gxmp::signedmsg format for transport.
|
||||
* 3) Likewise this class will sit above a gdp/gnp/gsp data handling.
|
||||
*/
|
||||
|
||||
class p3gixp
|
||||
{
|
||||
bool createKey(gixp::profile, bool doGpgAlso); /* fills in mKeyId, and signature */
|
||||
|
||||
bool haveKey(keyId);
|
||||
bool havePrivateKey(keyId);
|
||||
bool requestKey(keyId);
|
||||
|
||||
bool getProfile(keyId, gixp::profile &prof); /* generic profile - that can be distributed far and wide */
|
||||
bool getGpgProfile(keyId, gixp::profile &prof); /* personal profile - (normally) only shared with friends */
|
||||
|
||||
bool getReputations(keyId, std::list<gxip::reputation> &reps);
|
||||
int16_t getRepScore(keyId, uint32_t flags);
|
||||
|
||||
/*** process data ***/
|
||||
bool sign(KeyId, Data, signature);
|
||||
bool verify(KeyId, Data, signature);
|
||||
bool decrypt(KeyId, Data, decryptedData);
|
||||
bool encrypt(KeyId, Data, decryptedData);
|
||||
|
||||
};
|
||||
|
||||
#endif /* RS_GIXP_H */
|
||||
|
||||
|
@ -1,214 +0,0 @@
|
||||
/*
|
||||
* libretroshare/src/gxp: gxp.h
|
||||
*
|
||||
* General Exchange Protocol interface for RetroShare.
|
||||
*
|
||||
* Copyright 2011-2011 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 RS_GMXP_H
|
||||
#define RS_GMXP_H
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* GMXP: General Message Exchange Protocol.
|
||||
*
|
||||
* The existing experiences of Forums & Channels have highlighted some
|
||||
* significant limitations of the Cache-Based exchange system. Based
|
||||
* on this initial understandings - an improved transport system will
|
||||
* be design to provide a generalised message exchange foundation,
|
||||
* which can be used to build new services...
|
||||
*
|
||||
*
|
||||
* Key Properties:
|
||||
*
|
||||
* 1) Message independent: Should be able to be used for Forums, Channels
|
||||
* Twitter, Photos, Task Tracking, Link Cloud, etc.
|
||||
* 2) Easy to Use: Specify(Msg, Permissions, KeyId) only.
|
||||
* 3) Efficient Network Transport. (in common with GIXP)
|
||||
* 4) Efficient Cache System (in common with GIXP).
|
||||
* 5) Uses Groups Feature (in common with GIXP).
|
||||
* 6) Search Protocols. ( might need overloading at higher level).
|
||||
*
|
||||
*****/
|
||||
|
||||
|
||||
/******
|
||||
* NOTES:
|
||||
* 1) Based on Forum/Channel Groups.
|
||||
* 2) Will likely need to extend to handle info for other services.
|
||||
* 3) Perhaps a more generalised class like gxmp::msg would be best with extra data.
|
||||
*
|
||||
*/
|
||||
|
||||
class gxmp::group
|
||||
{
|
||||
gxp::id grpId;
|
||||
uint32_t grpType; /* FORUM, CHANNEL, TWITTER, etc */
|
||||
|
||||
uint32_t timestamp;
|
||||
uint32_t grpFlags;
|
||||
std::string grpName;
|
||||
std::string grpDesc;
|
||||
std::string grpCategory;
|
||||
|
||||
RsTlvImage grpPixmap;
|
||||
|
||||
gpp::permissions grpPermissions;
|
||||
|
||||
gxip::keyref adminKey;
|
||||
gxip::keyrefset publishKeys;
|
||||
|
||||
gxip::signature adminSignature;
|
||||
};
|
||||
|
||||
|
||||
/******
|
||||
* NOTES:
|
||||
* 1) This represents the base of the Unpacked Msgs, it will be overloaded by all classes
|
||||
* that want to use the service. It is difficult to go from gxmp::msg => gxmp::signedmsg
|
||||
* so data should be stored in the signedmsg format.
|
||||
* 2) All services will fundamentally use data types derived from this.
|
||||
* 3) This packet is only serialised once at post time, typically it is deserialised by all nodes.
|
||||
*/
|
||||
class gmxp::link
|
||||
{
|
||||
uint32_t linktype;
|
||||
gxp::id msgId;
|
||||
}
|
||||
|
||||
class gmxp::msg
|
||||
{
|
||||
gxp::id groupId;
|
||||
gxp::id msgId;
|
||||
|
||||
gxp::id parentId; /* for full threading */
|
||||
gxp::id threadId; /* top of thread Id */
|
||||
|
||||
gxp::id origMsgId; /* if a replacement msg, otherwise == msgId */
|
||||
gxp::id replacingMsgId; /* if a replacement msg, otherwise == NULL (for ordering) */
|
||||
|
||||
uint32_t msgtype; /* FORUM, CHANNEL, EVENT, COMMENT, VOTE, etc */
|
||||
uint32_t flags; /* Is this needed? */
|
||||
uint32_t timestamp;
|
||||
|
||||
// New extensions - put these in the generic message, so we can handle search / linking for all services.
|
||||
std::list<std::string> hashtags;
|
||||
std::list<gmxp::link> linked;
|
||||
|
||||
gpp::permissions msgPermissions;
|
||||
|
||||
gxip::signset signatures; // should this be a set, or a singleton?
|
||||
};
|
||||
|
||||
class gmxp::group: public gxp::group
|
||||
{
|
||||
???
|
||||
};
|
||||
|
||||
|
||||
/******
|
||||
* NOTES:
|
||||
* 1) This class will be based on p3distrib - which does most of this stuff already!
|
||||
* 2) There are lots of virtual functions - which can be overloaded to customise behaviour.
|
||||
* for clarity - these have not been shown here.
|
||||
*
|
||||
* 3) We need to extend this class to add search functionality... so you can discover new
|
||||
* stuff from your friends. This will need to be an overloaded functionality as the
|
||||
* search will be service specific.
|
||||
*/
|
||||
|
||||
|
||||
/* General Interface class which is extended by specific versions.
|
||||
*
|
||||
* This provides most of the generic search, and access functions.
|
||||
* As we are going to end up with diamond style double inheritance.
|
||||
* This function needs to be pure virtual.. so there is no disambiugation issues.
|
||||
*/
|
||||
|
||||
class rsGmxp
|
||||
{
|
||||
/* create content */
|
||||
std::string createGroup(std::wstring name, std::wstring desc, uint32_t flags, unsigned char *pngImageData, uint32_t imageSize);
|
||||
std::string publishMsg(RsDistribMsg *msg, bool personalSign);
|
||||
|
||||
/* indicate interest in info */
|
||||
bool subscribeToGroup(const std::string &grpId, bool subscribe);
|
||||
|
||||
/* search messages (TO DEFINE) */
|
||||
|
||||
/* extract messages (From p3Distrib Existing Methods) */
|
||||
|
||||
bool getAllGroupList(std::list<std::string> &grpids);
|
||||
bool getSubscribedGroupList(std::list<std::string> &grpids);
|
||||
bool getPublishGroupList(std::list<std::string> &grpids);
|
||||
void getPopularGroupList(uint32_t popMin, uint32_t popMax, std::list<std::string> &grpids);
|
||||
|
||||
bool getAllMsgList(const std::string& grpId, std::list<std::string> &msgIds);
|
||||
bool getParentMsgList(const std::string& grpId,
|
||||
const std::string& pId, std::list<std::string> &msgIds);
|
||||
bool getTimePeriodMsgList(const std::string& grpId, uint32_t timeMin,
|
||||
uint32_t timeMax, std::list<std::string> &msgIds);
|
||||
|
||||
GroupInfo *locked_getGroupInfo(const std::string& grpId);
|
||||
RsDistribMsg *locked_getGroupMsg(const std::string& grpId, const std::string& msgId);
|
||||
|
||||
void getGrpListPubKeyAvailable(std::list<std::string>& grpList);
|
||||
|
||||
};
|
||||
|
||||
|
||||
class p3gmxp
|
||||
{
|
||||
p3gmxp(int serviceType, serialiser *);
|
||||
|
||||
/* create content */
|
||||
std::string createGroup(std::wstring name, std::wstring desc, uint32_t flags, unsigned char *pngImageData, uint32_t imageSize);
|
||||
std::string publishMsg(RsDistribMsg *msg, bool personalSign);
|
||||
|
||||
/* indicate interest in info */
|
||||
bool subscribeToGroup(const std::string &grpId, bool subscribe);
|
||||
|
||||
/* search messages (TO DEFINE) */
|
||||
|
||||
/* extract messages (From p3Distrib Existing Methods) */
|
||||
|
||||
bool getAllGroupList(std::list<std::string> &grpids);
|
||||
bool getSubscribedGroupList(std::list<std::string> &grpids);
|
||||
bool getPublishGroupList(std::list<std::string> &grpids);
|
||||
void getPopularGroupList(uint32_t popMin, uint32_t popMax, std::list<std::string> &grpids);
|
||||
|
||||
bool getAllMsgList(const std::string& grpId, std::list<std::string> &msgIds);
|
||||
bool getParentMsgList(const std::string& grpId,
|
||||
const std::string& pId, std::list<std::string> &msgIds);
|
||||
bool getTimePeriodMsgList(const std::string& grpId, uint32_t timeMin,
|
||||
uint32_t timeMax, std::list<std::string> &msgIds);
|
||||
|
||||
GroupInfo *locked_getGroupInfo(const std::string& grpId);
|
||||
RsDistribMsg *locked_getGroupMsg(const std::string& grpId, const std::string& msgId);
|
||||
|
||||
void getGrpListPubKeyAvailable(std::list<std::string>& grpList);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* RS_GMXP_H */
|
||||
|
||||
|
@ -1,443 +0,0 @@
|
||||
/*
|
||||
* libretroshare/src/gxp: gxp.h
|
||||
*
|
||||
* General Exchange Protocol interface for RetroShare.
|
||||
*
|
||||
* Copyright 2011-2011 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 RS_GXP_H
|
||||
#define RS_GXP_H
|
||||
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* This File describes the following components for a generalised exchange protocol (GXP).
|
||||
*
|
||||
* GPP: General Permissions Protocol: Who is allowed access to what?
|
||||
* GDP: General Data Protocol: High Level Interface for exchanging data.
|
||||
* GSP: General Storage Protocol: Class implementing GDP for disk access.
|
||||
* GNP: General Network Protocol: Class implementing GDP for network exchange.
|
||||
*
|
||||
* This will be the mechanism to enforce groups.
|
||||
* No idea what the data types will look like.
|
||||
*
|
||||
*****/
|
||||
|
||||
/************************************************************************
|
||||
* GPP: General Permissions Protocol
|
||||
*
|
||||
* This will be the mechanism to enforce groups.
|
||||
* No idea what the data types will look like.
|
||||
* The real challenge here is to ensure that the permissions are universal,
|
||||
* so they can be baked into the messages.
|
||||
*
|
||||
* PUBLIC:
|
||||
*
|
||||
* RESTRICTED:
|
||||
*
|
||||
* PUBLISHER_ONLY_SHARE:
|
||||
*
|
||||
* GROUP: list<gpgid>
|
||||
*
|
||||
* GROUP: signed by list<keyid>
|
||||
*
|
||||
* SAME AS GROUP_DESCRIPTION: (for messages)
|
||||
*
|
||||
* These permissions will need to be coupled to local permissions...
|
||||
* eg. I don't want Party Photos going to Work Collegues.
|
||||
*
|
||||
* The combination of both permissions will determine who things are shared with.
|
||||
*
|
||||
*****/
|
||||
|
||||
class gpp::group
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
class gpp::Permissions
|
||||
{
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* GDP: General Data Protocol
|
||||
*
|
||||
* Generic Data Interface used for both GNP and GSP
|
||||
*
|
||||
* Permissions are handled at this level... totally generic to all messages.
|
||||
*
|
||||
* gxmp::signedmsg represents the "original data" container format that will
|
||||
* be tranported and stored by GSP / GNP cmodules.
|
||||
*****/
|
||||
|
||||
class gxp::id
|
||||
{
|
||||
std::string id;
|
||||
};
|
||||
|
||||
/******
|
||||
* NOTES:
|
||||
* 1) Based on Forum/Channel Groups.
|
||||
* 2) Will likely need to extend to handle info for other services.
|
||||
* 3) Perhaps a more generalised class like gxmp::msg would be best with extra data.
|
||||
*
|
||||
*/
|
||||
|
||||
class gxmp::group
|
||||
{
|
||||
gxp::id grpId;
|
||||
uint32_t grpType; /* FORUM, CHANNEL, TWITTER, etc */
|
||||
|
||||
uint32_t timestamp;
|
||||
uint32_t grpFlags;
|
||||
std::string grpName;
|
||||
std::string grpDesc;
|
||||
std::string grpCategory;
|
||||
|
||||
RsTlvImage grpPixmap;
|
||||
|
||||
gpp::permissions grpPermissions;
|
||||
|
||||
gxip::keyref adminKey;
|
||||
gxip::keyrefset publishKeys;
|
||||
|
||||
gxip::signature adminSignature;
|
||||
};
|
||||
|
||||
/******
|
||||
* NOTES:
|
||||
* 1) It is possible for the packet to be encrypted, rather than just signed.
|
||||
* so the uncrypted data mustn't give away too much about whats in the msg.
|
||||
* 2) This is based on the DistribSignedMsg format.
|
||||
* 3) Combined signatures instead of explict publish/personal signs -
|
||||
* to make it more general. Expect first signature == msgId.
|
||||
* 4) Should the permissions be only a group level, or for individual msgs as well?
|
||||
*
|
||||
*/
|
||||
|
||||
class gxp::signedmsg
|
||||
{
|
||||
gxp::id groupId; /* high level groupings, e.g. specific forum, channel, or twitter user, etc. */
|
||||
gxp::id msgId; /* unique msgId within that group, normally signature of the message */
|
||||
|
||||
uint32_t timestamp;
|
||||
gpp::permissions grpPermissions;
|
||||
|
||||
gxp::data packet; /* compressed data */
|
||||
|
||||
gxip::signset signatures;
|
||||
};
|
||||
|
||||
|
||||
class gdp::interface
|
||||
{
|
||||
/* query for available groups & messages */
|
||||
int listgroups(std::list<gdb::id> &grpIds);
|
||||
/* response from listmsgs: -1 = invalid parameters, 0 = incomplete list, 1 = all known msgs */
|
||||
int listmsgs(const gdp::id grpId, std::list<gdb::id> &msgIds, const rstime_t from, const rstime_t to, const int maxmsgs);
|
||||
|
||||
/* response from requestMsg: YES (available immediately), RETRIEVING (known to exist),
|
||||
* IN_REQUEST (might exist), NOT_AVAILABLE (still might exist)
|
||||
* NB: NOT_AVAILABLE could mean that it will be retrievable later when other peers come online, or possibilly we are not allowed it.
|
||||
*/
|
||||
|
||||
int requestMsg(gdp::id groupId, gdp::id msgId, double &delay);
|
||||
int getMsg(gdp::id groupId, gdp::id msgId, gdp::message &msg);
|
||||
int storeMsg(const gdp::message &msg);
|
||||
|
||||
/* search interface, is it here? or next level up */
|
||||
|
||||
};
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* GSP: General Storage Protocol
|
||||
*
|
||||
* This will be the mechanism used to store both GIXP and GMXP data.
|
||||
*
|
||||
* This will have a decent index system - which is loaded immediately.
|
||||
* meaning we know if a message exists or not.
|
||||
*
|
||||
* We will also implement a cache system, meaning recently accessed data
|
||||
* is available immediately.
|
||||
*
|
||||
*
|
||||
*
|
||||
*****/
|
||||
|
||||
class gsp::storage: public gdp::interface
|
||||
{
|
||||
/*** gdp::iterface *****/
|
||||
int requestMsg(gdp::id groupId, gdp::id msgId, double &delay);
|
||||
|
||||
int getMsg(gdp::id groupId, gdp::id msgId, gdp::message &msg);
|
||||
int storeMsg(const gdp::message &msg);
|
||||
|
||||
int flagMsg(gxp::id grpId, gxp::id msgId, bool pleaseCache);
|
||||
|
||||
|
||||
/*** IMPLEMENTATION DETAILS ****/
|
||||
|
||||
loadIndex();
|
||||
loadCache();
|
||||
|
||||
bool isInCache(gdp::id grpId, gdp::id msgId);
|
||||
bool isInIndex(gdp::id grpId, gdp::id msgId);
|
||||
void fetchToCache(gdp::id grpId, gdp::id msgId);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* GNP: General Network Protocol
|
||||
*
|
||||
* This will be the mechanism share data with peers.
|
||||
* It will be designed and closely couple to GSP for effective data managment.
|
||||
*
|
||||
* This part will effectively interface with librs Network Service.
|
||||
* This will also push message ids around - to indicate new messages.
|
||||
*
|
||||
* This would sit above the GSP, and push things into storage
|
||||
* as they come over the network
|
||||
*
|
||||
*
|
||||
*****/
|
||||
|
||||
|
||||
class gnp::exchange: public gdp::interface
|
||||
{
|
||||
/*** gdp::iterface *****/
|
||||
int requestMsg(gdp::id groupId, gdp::id msgId, double &delay);
|
||||
|
||||
int getMsg(gdp::id groupId, gdp::id msgId, gdp::message &msg);
|
||||
int storeMsg(const gdp::message &msg);
|
||||
|
||||
/*** IMPLEMENTATION DETAILS ****/
|
||||
|
||||
/* Get/Send Messages */
|
||||
getAvailableMsgs(gdp::id grpId, rstime_t from, rstime_t to); /* request over the network */
|
||||
sendAvailableMsgs(std::string peerId, gdp::id grpId, rstime_t from, rstime_t to); /* send to peers */
|
||||
|
||||
requestMessages(std::string peerId, gdp::id grpId, std::list<gdp::id> msgIds);
|
||||
sendMessages(std::string peerId, gdp::id grpId, std::list<gdp::id> msgIds); /* send to peer, obviously permissions have been checked first */
|
||||
|
||||
/* Search the network */
|
||||
|
||||
};
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* GIXP: General Identity Exchange Protocol.
|
||||
*
|
||||
* As we're always running into troubles with GPG signatures... we are going to
|
||||
* create a layer of RSA Keys for the following properties:
|
||||
*
|
||||
* 1) RSA Keys can be Anonymous, Self-Signed with Pseudonym, Signed by GPG Key.
|
||||
* - Anonymous & Pseudonym Keys will be shared network-wide (Hop by Hop).
|
||||
- GPG signed Keys will only be shared if we can validate the signature
|
||||
(providing similar behaviour to existing GPG Keys).
|
||||
- GPG signed Keys can optionally be marked for Network-wide sharing.
|
||||
* 2) These keys can be used anywhere, specifically in the protocols described below.
|
||||
* 3) These keys can be used to sign, encrypt, verify & decrypt
|
||||
* 4) Keys will never need to be directly accessed - stored in this class.
|
||||
* 5) They will be cached locally and exchanged p2p, by pull request.
|
||||
* 6) This class will use the generalised packet storage for efficient caching & loading.
|
||||
* 7) Data will be stored encrypted.
|
||||
*****/
|
||||
|
||||
class gixp::key
|
||||
{
|
||||
gxip::keyref mKeyId;
|
||||
|
||||
PubKey *pubKey;
|
||||
PrivateKey *privKey; /* NULL if non-existant */
|
||||
};
|
||||
|
||||
class gixp::profile
|
||||
{
|
||||
public:
|
||||
|
||||
gxip::keyref mKeyId;
|
||||
|
||||
std::string mPseudonym;
|
||||
rstime_t mTimestamp; /* superseded by newer timestamps */
|
||||
uint32_t mProfileType; /* ANONYMOUS (no name, self-signed), PSEUDONYM (self-signed), GPG (name=gpgname, gpgsigned), REVOCATION?? */
|
||||
gpp::permissions mPermissions;
|
||||
|
||||
gxip::signature mSignature;
|
||||
};
|
||||
|
||||
class gxip::keyref
|
||||
{
|
||||
std::string keyId;
|
||||
}
|
||||
|
||||
class gxip::keyrefset
|
||||
{
|
||||
std::list<gxip::keyref> keyIds;
|
||||
}
|
||||
|
||||
class gxip::signature
|
||||
{
|
||||
gxip::keyref signer;
|
||||
std::string signature;
|
||||
}
|
||||
|
||||
class gxip::signset
|
||||
{
|
||||
std::list<gxip::signature> signs;
|
||||
};
|
||||
|
||||
/*******
|
||||
* NOTES:
|
||||
* 1) much of this is already implemented in libretroshare/src/distrib/distribsecurity.cc
|
||||
* 2) Data types will need to be shoehorned into gxmp::signedmsg format for transport.
|
||||
* 3) Likewise this class will sit above a gdp/gnp/gsp data handling.
|
||||
*/
|
||||
|
||||
class p3gixp
|
||||
{
|
||||
bool createKey(gixp::profile); /* fills in mKeyId, and signature */
|
||||
|
||||
bool haveKey(keyId);
|
||||
bool havePrivateKey(keyId);
|
||||
bool requestKey(keyId);
|
||||
|
||||
gixp::profile getProfile(keyId);
|
||||
|
||||
/*** process data ***/
|
||||
bool sign(KeyId, Data, signature);
|
||||
bool verify(KeyId, Data, signature);
|
||||
bool decrypt(KeyId, Data, decryptedData);
|
||||
bool encrypt(KeyId, Data, decryptedData);
|
||||
|
||||
};
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* GMXP: General Message Exchange Protocol.
|
||||
*
|
||||
* The existing experiences of Forums & Channels have highlighted some
|
||||
* significant limitations of the Cache-Based exchange system. Based
|
||||
* on this initial understandings - an improved transport system will
|
||||
* be design to provide a generalised message exchange foundation,
|
||||
* which can be used to build new services...
|
||||
*
|
||||
*
|
||||
* Key Properties:
|
||||
*
|
||||
* 1) Message independent: Should be able to be used for Forums, Channels
|
||||
* Twitter, Photos, Task Tracking, Link Cloud, etc.
|
||||
* 2) Easy to Use: Specify(Msg, Permissions, KeyId) only.
|
||||
* 3) Efficient Network Transport. (in common with GIXP)
|
||||
* 4) Efficient Cache System (in common with GIXP).
|
||||
* 5) Uses Groups Feature (in common with GIXP).
|
||||
* 6) Search Protocols. ( might need overloading at higher level).
|
||||
*
|
||||
*****/
|
||||
|
||||
|
||||
/******
|
||||
* NOTES:
|
||||
* 1) This represents the base of the Unpacked Msgs, it will be overloaded by all classes
|
||||
* that want to use the service. It is difficult to go from gxmp::msg => gxmp::signedmsg
|
||||
* so data should be stored in the signedmsg format.
|
||||
* 2) All services will fundamentally use data types derived from this.
|
||||
* 3) This packet is only serialised once at post time, typically it is deserialised be all nodes.
|
||||
*/
|
||||
|
||||
class gxmp::msg
|
||||
{
|
||||
gxp::id groupId;
|
||||
gxp::id msgId;
|
||||
|
||||
gxp::id parentId; /* for full threading */
|
||||
gxp::id threadId; /* top of thread Id */
|
||||
|
||||
gxp::id origMsgId; /* if a replacement msg, otherwise == msgId */
|
||||
gxp::id replacingMsgId; /* if a replacement msg, otherwise == NULL (for ordering) */
|
||||
|
||||
uint32_t type; /* FORUM, CHANNEL, EVENT, COMMENT, VOTE, etc */
|
||||
uint32_t flags; /* Is this needed? */
|
||||
uint32_t timestamp;
|
||||
|
||||
gpp::permissions msgPermissions;
|
||||
|
||||
gxip::signset signatures;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/******
|
||||
* NOTES:
|
||||
* 1) This class will be based on p3distrib - which does most of this stuff already!
|
||||
* 2) There are lots of virtual functions - which can be overloaded to customise behaviour.
|
||||
* for clarity - these have not been shown here.
|
||||
*
|
||||
* 3) We need to extend this class to add search functionality... so you can discover new
|
||||
* stuff from your friends. This will need to be an overloaded functionality as the
|
||||
* search will be service specific.
|
||||
*/
|
||||
|
||||
|
||||
class p3gmxp
|
||||
{
|
||||
p3gmxp(int serviceType, serialiser *);
|
||||
|
||||
/* create content */
|
||||
std::string createGroup(std::wstring name, std::wstring desc, uint32_t flags, unsigned char *pngImageData, uint32_t imageSize);
|
||||
std::string publishMsg(RsDistribMsg *msg, bool personalSign);
|
||||
|
||||
/* indicate interest in info */
|
||||
bool subscribeToGroup(const std::string &grpId, bool subscribe);
|
||||
|
||||
/* search messages (TO DEFINE) */
|
||||
|
||||
/* extract messages (From p3Distrib Existing Methods) */
|
||||
|
||||
bool getAllGroupList(std::list<std::string> &grpids);
|
||||
bool getSubscribedGroupList(std::list<std::string> &grpids);
|
||||
bool getPublishGroupList(std::list<std::string> &grpids);
|
||||
void getPopularGroupList(uint32_t popMin, uint32_t popMax, std::list<std::string> &grpids);
|
||||
|
||||
bool getAllMsgList(const std::string& grpId, std::list<std::string> &msgIds);
|
||||
bool getParentMsgList(const std::string& grpId,
|
||||
const std::string& pId, std::list<std::string> &msgIds);
|
||||
bool getTimePeriodMsgList(const std::string& grpId, uint32_t timeMin,
|
||||
uint32_t timeMax, std::list<std::string> &msgIds);
|
||||
|
||||
GroupInfo *locked_getGroupInfo(const std::string& grpId);
|
||||
RsDistribMsg *locked_getGroupMsg(const std::string& grpId, const std::string& msgId);
|
||||
|
||||
void getGrpListPubKeyAvailable(std::list<std::string>& grpList);
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* RS_GXP_H */
|
||||
|
||||
|
@ -1,385 +0,0 @@
|
||||
/*
|
||||
* libretroshare/src/gxp: gxp_apps.h
|
||||
*
|
||||
* General Exchange Protocol interface for RetroShare.
|
||||
*
|
||||
* Copyright 2011-2011 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 RS_GXP_APPS_H
|
||||
#define RS_GXP_APPS_H
|
||||
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* This File describes applications that will use the GXP protocols.
|
||||
*
|
||||
*****/
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Forums / Channels.
|
||||
*
|
||||
* The existing experiences of Forums & Channels have highlighted some
|
||||
* significant limitations of the Cache-Based exchange system. The new
|
||||
* and improved system will be based on GMXP.
|
||||
*
|
||||
* Existing Issues to deal with:
|
||||
* 1) GPG Signatures take too long to verify (GPGme/gpg.exe issue)
|
||||
* 2) Signatures are re-verified each startup.
|
||||
* 3) Forum Messages are broadcast to all peers - excessive traffic/disk space.
|
||||
* 4) Impossible to Edit Messages, or Comment on Channel Posts.
|
||||
*
|
||||
* Most of these issues (1-3) will be dealt with via GMXP GIXP system
|
||||
*
|
||||
* The data structures below are closely modelled on existing types.
|
||||
*
|
||||
*****/
|
||||
|
||||
class gxp::forum::msg: public gmxp::msg
|
||||
{
|
||||
/**** PROVIDED BY PARENT ***/
|
||||
//gxp::id groupId;
|
||||
//gxp::id msgId;
|
||||
|
||||
//gxp::id parentId;
|
||||
//gxp::id threadId;
|
||||
|
||||
//gxp::id origMsgId;
|
||||
//gxp::id replacingMsgId;
|
||||
|
||||
//uint32_t timestamp;
|
||||
//uint32_t type;
|
||||
//uint32_t flags;
|
||||
|
||||
//gpp::permissions msgPermissions;
|
||||
//gxp::signset signatures;
|
||||
|
||||
/**** SPECIFIC FOR FORUM MSG ****/
|
||||
|
||||
std::string srcId;
|
||||
std::string title;
|
||||
std::string msg;
|
||||
|
||||
};
|
||||
|
||||
class gxp::channel::msg: public gmxp::msg
|
||||
{
|
||||
/**** PROVIDED BY PARENT ***/
|
||||
//gxp::id groupId;
|
||||
//gxp::id msgId;
|
||||
|
||||
//gxp::id parentId; // NOT USED.
|
||||
//gxp::id threadId; // NOT USED.
|
||||
|
||||
//gxp::id origMsgId;
|
||||
//gxp::id replacingMsgId;
|
||||
|
||||
//uint32_t timestamp;
|
||||
//uint32_t type;
|
||||
//uint32_t flags;
|
||||
|
||||
//gpp::permissions msgPermissions;
|
||||
//gxp::signset signatures;
|
||||
|
||||
/**** SPECIFIC FOR CHANNEL MSG ****/
|
||||
|
||||
std::wstring subject;
|
||||
std::wstring message;
|
||||
|
||||
RsTlvFileSet attachment;
|
||||
RsTlvImage thumbnail;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Events.
|
||||
*
|
||||
* It is well known that Events & Photos are the two primary uses for
|
||||
* Facebook. It is imperative that these are implemented in GXP.
|
||||
*
|
||||
*****/
|
||||
|
||||
class gxp::events::event: public gmxp::msg
|
||||
{
|
||||
/**** PROVIDED BY PARENT ***/
|
||||
//gxp::id groupId;
|
||||
//gxp::id msgId;
|
||||
|
||||
//gxp::id parentId;
|
||||
//gxp::id threadId;
|
||||
|
||||
//gxp::id origMsgId;
|
||||
//gxp::id replacingMsgId;
|
||||
|
||||
//uint32_t timestamp;
|
||||
//uint32_t type;
|
||||
//uint32_t flags;
|
||||
|
||||
//gpp::permissions msgPermissions;
|
||||
//gxp::signset signatures;
|
||||
|
||||
/**** SPECIFIC FOR EVENT MSG ****/
|
||||
|
||||
location
|
||||
time
|
||||
repeats
|
||||
invite list
|
||||
number of places.
|
||||
host
|
||||
|
||||
|
||||
};
|
||||
|
||||
class gxp::events::reply: public gmxp::msg
|
||||
{
|
||||
/**** PROVIDED BY PARENT ***/
|
||||
//gxp::id groupId;
|
||||
//gxp::id msgId;
|
||||
|
||||
//gxp::id parentId;
|
||||
//gxp::id threadId;
|
||||
|
||||
//gxp::id origMsgId;
|
||||
//gxp::id replacingMsgId;
|
||||
|
||||
//uint32_t timestamp;
|
||||
//uint32_t type;
|
||||
//uint32_t flags;
|
||||
|
||||
//gpp::permissions msgPermissions;
|
||||
//gxp::signset signatures;
|
||||
|
||||
/**** SPECIFIC FOR REPLY MSG ****/
|
||||
|
||||
bool amcoming;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Photos.
|
||||
*
|
||||
*****/
|
||||
|
||||
class gxp::PhotoAlbum: public gmxp::group
|
||||
{
|
||||
Location
|
||||
Period
|
||||
Type
|
||||
Photographer
|
||||
Comments
|
||||
};
|
||||
|
||||
|
||||
|
||||
class gxp::photos::photo: public gmxp::msg
|
||||
{
|
||||
/**** PROVIDED BY PARENT ***/
|
||||
//gxp::id groupId;
|
||||
//gxp::id msgId;
|
||||
|
||||
//gxp::id parentId;
|
||||
//gxp::id threadId;
|
||||
|
||||
//gxp::id origMsgId;
|
||||
//gxp::id replacingMsgId;
|
||||
|
||||
//uint32_t timestamp;
|
||||
//uint32_t type;
|
||||
//uint32_t flags;
|
||||
|
||||
//gpp::permissions msgPermissions;
|
||||
//gxp::signset signatures;
|
||||
|
||||
/**** SPECIFIC FOR PHOTO MSG ****/
|
||||
|
||||
Location
|
||||
Time
|
||||
Type
|
||||
Photographer
|
||||
Comment
|
||||
|
||||
FileLink.
|
||||
};
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Wiki.
|
||||
*
|
||||
* Wiki pages are very similar to Forums... Just they are editable
|
||||
* but anyone, and will replace the earlier version.
|
||||
*
|
||||
*****/
|
||||
|
||||
|
||||
class gxp::wiki::topic: public gmxp::group
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
class gxp::wiki::page: public gmxp::msg
|
||||
{
|
||||
/**** PROVIDED BY PARENT ***/
|
||||
//gxp::id groupId;
|
||||
//gxp::id msgId;
|
||||
|
||||
//gxp::id parentId;
|
||||
//gxp::id threadId;
|
||||
|
||||
//gxp::id origMsgId;
|
||||
//gxp::id replacingMsgId;
|
||||
|
||||
//uint32_t timestamp;
|
||||
//uint32_t type;
|
||||
//uint32_t flags;
|
||||
|
||||
//gpp::permissions msgPermissions;
|
||||
//gxp::signset signatures;
|
||||
|
||||
/**** SPECIFIC FOR FORUM MSG ****/
|
||||
|
||||
Title
|
||||
Format
|
||||
Page
|
||||
|
||||
Links
|
||||
References
|
||||
|
||||
};
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Links.
|
||||
*
|
||||
*****/
|
||||
|
||||
class gxp::Link
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Comments.
|
||||
*
|
||||
*****/
|
||||
|
||||
class gxp::Comment
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Vote.
|
||||
*
|
||||
*****/
|
||||
|
||||
class gxp::Vote
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Status
|
||||
*
|
||||
*****/
|
||||
|
||||
class gxp::Status
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Tasks
|
||||
*
|
||||
*****/
|
||||
|
||||
class gxp::Task
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Tweet
|
||||
*
|
||||
*****/
|
||||
|
||||
class gxp::Tweet
|
||||
{
|
||||
HashTags
|
||||
|
||||
Content
|
||||
|
||||
Links
|
||||
};
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* Library.
|
||||
*
|
||||
*****/
|
||||
|
||||
class gxp::Paper
|
||||
{
|
||||
KeyWords
|
||||
|
||||
Journal
|
||||
|
||||
Authors
|
||||
|
||||
Abstract
|
||||
|
||||
References
|
||||
|
||||
Similar Papers
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* RS_GXP_H */
|
||||
|
||||
|
@ -1,104 +0,0 @@
|
||||
|
||||
/* Generalised Service Base Class.
|
||||
* The base class interfaces with gixp, disk, net services.
|
||||
*/
|
||||
|
||||
class RsGxpLink
|
||||
{
|
||||
uint32_t type;
|
||||
std::string msgId;
|
||||
}
|
||||
|
||||
class RsGxpItem
|
||||
{
|
||||
std::string msgId;
|
||||
std::string origMsgId;
|
||||
std::string groupId;
|
||||
gxpTime time;
|
||||
std::list<std::string> hashtags;
|
||||
std::list<RsGxpLink> linked;
|
||||
|
||||
RsGxpSignature mSignature;
|
||||
};
|
||||
|
||||
class RsGxpGroup
|
||||
{
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
class gxp_service
|
||||
{
|
||||
public:
|
||||
|
||||
requestItem(msgId);
|
||||
|
||||
recv(RsGxpItem *item);
|
||||
send(RsGxpItem *item);
|
||||
|
||||
/****************************************************************************************************/
|
||||
// Event Callback for the service.
|
||||
/****************************************************************************************************/
|
||||
|
||||
notify_groupChanged(); // Mainly for GUI display.
|
||||
notify_newMessage(); // used for newsFeeds.
|
||||
notify_duplicateMessage(); // Channels needs this for Downloading stuff, can probably be moved above.
|
||||
locked_checkDistribMsg(); // required overload?
|
||||
/****************************************************************************************************/
|
||||
// Must worry about sharing keys.
|
||||
// Can gixp handle it?
|
||||
// What interfaces do we need here?
|
||||
/****************************************************************************************************/
|
||||
|
||||
/****************************************************************************************************/
|
||||
// Interface for Message Read Status
|
||||
// At the moment this is overloaded to handle autodownload flags too.
|
||||
// This is a configuration thing.
|
||||
/****************************************************************************************************/
|
||||
|
||||
int flagItemRead(std::string id);
|
||||
int flagItemUnread(std::string id);
|
||||
int flagGroupRead(std::string id);
|
||||
int flagGroupUnread(std::string id);
|
||||
|
||||
/****************************************************************************************************/
|
||||
// External Interface for Data.
|
||||
/****************************************************************************************************/
|
||||
|
||||
// Mesage Creation.
|
||||
int createGroup(RsGxpGroup *grp);
|
||||
int createItem(RsGxpItem *item);
|
||||
|
||||
// Group Lists & Message Lists.
|
||||
int getGroupsChanged(std::list<std::string> &groupIds);
|
||||
int getGroups(std::list<std::string> &groupIds);
|
||||
int getGroupList(std::string grpId, std::list<std::string> &groupIds);
|
||||
int getTimeRange(GxpTime from, GxpTime to, std::list<std::string> &msgIds);
|
||||
int getGroupTimeRange(std::string grpId, GxpTime from, GxpTime to, std::list<std::string> &msgIds);
|
||||
int getReplacementMsgs(std::string origId, std::list<std::string> replaceIds);
|
||||
|
||||
// Getting the Actual Data.
|
||||
int haveItem(std::string msgId);
|
||||
int requestItem(std::string msgId);
|
||||
RsGxpItem *getMsg_locked(std::string msgId);
|
||||
RsGxpGroup *getGroup_locked(std::string msgId);
|
||||
|
||||
// Interface with GIXP Stuff... everything else should be behind the scenes.
|
||||
RsGixpProfile *getProfile_locked(std::string id);
|
||||
|
||||
// Immediate Search...
|
||||
int searchReferringLinks(RsGxpLink link, std::list<std::string> &msgIds);
|
||||
int searchHashTags(std::list<std::string>, std::list<std::string> &msgIds);
|
||||
|
||||
// Remote Search...
|
||||
|
||||
private:
|
||||
|
||||
// Reversed Index: for hash searching.
|
||||
std::map<std::string, std::list<ids> > mSearchMap;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user