Early pass at defining new message exchange (cache replacement system)

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-new_cache_system@4805 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2012-01-17 01:09:21 +00:00
parent cf5158d2b0
commit aa64617142
5 changed files with 1259 additions and 0 deletions

View File

@ -0,0 +1,158 @@
/*
* 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;
time_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 */

View File

@ -0,0 +1,132 @@
/*
* 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) 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 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 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_GMXP_H */

View File

@ -0,0 +1,437 @@
/*
* 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 gxmp::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
{
/* very basic interface */
/* 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);
};
/************************************************************************
* 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, time_t from, time_t to); /* request over the network */
sendAvailableMsgs(std::string peerId, gdp::id grpId, time_t from, time_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;
time_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 */

View File

@ -0,0 +1,385 @@
/*
* 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 */

View File

@ -0,0 +1,147 @@
//
// This is a first attempt at managing groups and group permissions
// in libretroshare.
//
// Rules:
// 1 - Groups are handled GPG-wise, and not SSLId wise, but we need to provide functions
// for SSLIds since that's what peers are represented by.
//
// 2 - A peer can be in different groups. That will be useful for e.g. file sharing.
//
// 3 - Global permissions always prevail over permissions given at the group level. For
// instance for discovery between two peers that belong to groups G1 and G2:
//
// | Global discovery flag ON | Global disc flag OFF |
// --------------------+--------------------------+----------------------+
// Group disc(G1,G2)=1 | Allow | Don't allow |
// Group disc(G1,G2)=0 | Don't allow | Don't allow |
//
// 4 - Binary group permissions are OR-ed between pairs of groups. If peers (A,B) can be matched to
// two different pairs of groups, the flags are combined with an OR.
//
// libretroshare side
// ==================
// We need a matrix for binary group flags, i.e. flags for pair of groups, for:
//
// Turtle traffic:
// * does the turtle traffic can go from peers of a group to another
// * default: yes
//
// Discovery:
// * does the turtle traffic can go from peers of a group to another
// * default: yes. Overriden by discovery status in config.
//
// Public chat lobby advertisement:
// * public lobby coming from peers of a group go to peers of another group
// * default: yes
//
// Relay connexions:
// * allow relay connexions between people of group A and group B.
//
// We need per-group permission flags for:
//
// File download permission:
// * each shared directory belongs to a list of groups
// * each shared directory has a set of DL flags (browsable B,network wide N) for groups and for global.
// * files are listed with unix-like permissions style:
// ---- : file can't be transfered at all.
// bn-- : file is browsable and turtle-able by friends of its groups only.
// b-b- : file is browsable by everybody
// --b- : file is browsable by everybody that does not belong to its groups (can be useful to isolate people in a group)
// -n-- : file is turtle-able by people that belong to its groups only.
// bnbn : file is always accessible in any ways. That's what file sharing is about. Should be the default ;-)
//
// We need to propose some pre-initialized settings to the user, so that he won't have to bother with flags, but we
// need to allow precisely tweaking them as well:
// Directory is
// - Accessible for this group only (allow select a group)
// - Fully shared anonymously
// - [...]
//
// If the shared directory has no groups, than the first two flags are meaningless.
//
// GUI side
// ========
// - we need a tab in config to manage groups and group flag permission matrix
// - when sharing a directory, the user can act on permissions: setting which groups a
// directory belongs to.
//
// Classes for groups. To be displatched in rstypes.h ?
//
#pragma once
typedef std::string SSLId ;
typedef std::string GPGId ;
typedef uint64_t RsGroupId ;
class RsPeerGroupInfo
{
public:
RsGroupId group_id ; // Id of the group, should be random and unique in the RS session.
std::string group_name ; // user-defined name of the group ("parents", "friends", etc)
std::set<GPGId> elements ; // people in the group. GPG-wise.
};
class GroupFlagsMatrix
{
public:
// flags
static const uint32_t GROUP_MATRIX_FLAG_DISCOVERY = 0x1 ;
static const uint32_t GROUP_MATRIX_FLAG_TURTLE = 0x2 ;
static const uint32_t GROUP_MATRIX_FLAG_PUBLIC_LOBBY = 0x4 ;
static const uint32_t GROUP_MATRIX_FLAG_RELAY = 0x8 ;
// returns/set all flags for a given pair of groups. Used by the
// GUI to draw/modify group flags.
//
uint32_t getGroupFlags(RsGroupId grp1,RsGroupId grp2) const ;
void setGroupFlags(uint32_t flags,RsGroupId grp1,RsGroupId grp2) const ;
// Returns a given flag for two people in particular. Used by services to
// know what to do or not do.
//
bool groupPermission(uint32_t group_flag,GPGId peer_1,GPGId peer2) const ;
private:
std::vector<uint32_t> _flags ; // vector of size number_of_groups^2
std::map<RsGroupId,int> _group_entries ; // index to read the flags vector.
};
// Interface class for Groups. Should go in libretroshare/stc/retroshare/rsgroups.h
//
class RsGroupManagement
{
public:
// Group handling
// Returns false is the group does not exist. Otherwise, fills the GroupInfo struct.
//
virtual bool getGroupInfo(const RsGroupId& id,RsPeerGroupInfo& info) = 0 ;
// Adds a friend to a group.
virtual bool getGroupInfo(const RsGroupId& id,RsPeerGroupInfo& info) = 0 ;
// Group permission handling
//
virtual bool allow_TwoPeers_TurtleTraffic (const SSLId& p1,const SSLId& p2) = 0 ;
virtual bool allow_TwoPeers_Discovery (const SSLId& p1,const SSLId& p2) = 0 ;
virtual bool allow_TwoPeers_LobbyAdvertisement(const SSLId& p1,const SSLId& p2) = 0 ;
// [...]
};
class p3GroupManagement: public RsGroupManagement, public p3Config
{
public:
// [...]
private:
std::map<RsPeerGroupInfo> _groups ;
};
// This is the entry point for external interface.
//
extern RsGroupManagement *rsGroups ;