Major work on distrib/forums system.

- Now creates Distribution Groups, with Admin + Publish Keys.
 - Distributes Groups + Public Keys in the Cache File.
 - Stores private Keys and subscribed groups in Configuration.
 - Forum Test to check basic functionality.
 - Added nullService for services that require tick(), but no instant messages.
 - removed debugging for other services (ranking/gamelauncher) 



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@593 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2008-06-13 15:32:12 +00:00
parent 602c7cc7b7
commit 14dac82c85
9 changed files with 2379 additions and 622 deletions

View File

@ -10,20 +10,22 @@ include $(RS_TOP_DIR)/scripts/config.mk
RSOBJ = p3service.o p3chatservice.o p3msgservice.o \
p3gamelauncher.o p3ranking.o p3disc.o \
p3photoservice.o \
p3forums.o \
p3distrib.o \
p3status.o \
p3Qblog.o
p3Qblog.o \
p3forums.o
# p3distrib.o
# dummy forums interface.
# p3forums-dummy.o \
#TESTOBJ =
TESTOBJ = forum_test.o
#TESTS =
TESTS = forum_test
all: librs tests
#tlvbase_test : tlvbase_test.o
# $(CC) $(CFLAGS) -o tlvbase_test tlvbase_test.o $(OBJ) $(LIBS)
forum_test : forum_test.o
$(CC) $(CFLAGS) -o forum_test forum_test.o $(OBJ) $(LIBS)
###############################################################

View File

@ -0,0 +1,75 @@
#include <assert.h>
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <ctype.h>
#include <openssl/bio.h>
#include <openssl/crypto.h>
#include <openssl/evp.h>
#include <openssl/x509.h>
#include <openssl/x509v3.h>
#include <openssl/xPGP.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <openssl/rand.h>
#include <openssl/fips.h>
static BIO *bio_err=NULL;
#include "p3forums.h"
int testForums(p3Forums *forum);
int main(int argc, char **argv)
{
/* setup SSL */
bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
/* enable memory leak checking unless explicitly disabled */
CRYPTO_malloc_debug_init();
CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
SSL_library_init();
SSL_load_error_strings();
/* setup p3Forums */
uint16_t type = 1;
CacheStrapper *cs = NULL;
CacheTransfer *cft = NULL;
std::string srcdir = "./";
std::string storedir = "./";
p3Forums *forum = new p3Forums(type, cs, cft, srcdir, storedir);
testForums(forum);
/* cleanup */
CRYPTO_cleanup_all_ex_data();
ERR_free_strings();
ERR_remove_state(0);
EVP_cleanup();
//CRYPTO_mem_leaks(bio_err);
if (bio_err != NULL) BIO_free(bio_err);
}
int testForums(p3Forums *forum)
{
std::string fId1 = forum->createForum(L"Forum 1", L"first forum", RS_DISTRIB_PUBLIC);
std::string fId2 = forum->createForum(L"Forum 2", L"next first forum", RS_DISTRIB_PRIVATE);
forum -> tick();
}

File diff suppressed because it is too large Load Diff

View File

@ -31,9 +31,10 @@
#include "pqi/p3cfgmgr.h"
#include "services/p3service.h"
#include "dbase/cachestrapper.h"
#include "serialiser/rsforumitems.h"
//#include "util/rsthreads.h"
#include <openssl/ssl.h>
#include <openssl/evp.h>
/*
* Group Messages....
@ -78,80 +79,11 @@
*
*/
/* Our Mode for the Group */
const uint32_t RS_GRPDISTRIB_SUBSCRIBED = 0x0001;
const uint32_t RS_GRPDISTRIB_PUBLISH = 0x0002;
/* Group Type */
const uint32_t RS_DISTRIB_PRIVATE = 0x0001; /* retain Private Key ( Default ) */
const uint32_t RS_DISTRIB_PUBLIC = 0x0002; /* share All Keys */
const uint32_t RS_DISTRIB_ENCRYPTED = 0x0004; /* encrypt Msgs */
class RsSignature
{
public:
uint32_t type; /* MASTER, PUBLISH, PERSONAL */
std::string signerId;
std::string signature;
};
class RsAuthMsg
{
public:
RsItem *msg;
std::string hash;
std::map<std::string, RsSignature> signs;
};
class RsKey
{
public:
uint32_t type; /* PUBLIC, PRIVATE */
uint32_t type2; /* MASTER, PUBLISH, PERSONAL (not sent) */
EVP_PKEY *key;
};
const uint32_t GROUP_MAX_FWD_OFFSET = (60 * 60 * 24 * 2); /* 2 Days */
/************* The Messages that are serialised ****************/
class RsDistribMsg: public RsItem
{
public:
RsDistribMsg(); //uint16_t type);
virtual void clear();
virtual std::ostream& print(std::ostream&, uint16_t);
std::string grpId;
std::string headId; /* head of the thread */
std::string parentId; /* parent id */
time_t timestamp;
/* This data is not Hashed (set to zero - before hash calced) */
std::string msgId; /* SHA1 Hash */
std::string grpSignature; /* sign of msgId */
std::string sourceSignature; /* sign of msgId */
};
class RsDistribGrp: public RsItem
{
public:
RsDistribGrp(); //uint16_t type);
virtual void clear();
virtual std::ostream& print(std::ostream&, uint16_t);
RsKey rsKey;
};
#if 0
class RsConfigDistrib: public RsSerialType
{
@ -169,38 +101,90 @@ class RsSerialDistrib: public RsSerialType
};
#endif
/************* The Messages that are serialised ****************/
//class PIXMAP;
#if 0
const uint32_t GROUP_KEY_TYPE_MASK = 0x000f;
const uint32_t GROUP_KEY_DISTRIB_MASK = 0x00f0;
const uint32_t GROUP_KEY_TYPE_PUBLIC_ONLY = 0x0001;
const uint32_t GROUP_KEY_TYPE_FULL = 0x0002;
const uint32_t GROUP_KEY_DISTRIB_PUBLIC = 0x0010;
const uint32_t GROUP_KEY_DISTRIB_PRIVATE = 0x0020;
const uint32_t GROUP_KEY_DISTRIB_ADMIN = 0x0040;
#endif
class GroupKey
{
public:
GroupKey()
:type(0), startTS(0), endTS(0), key(NULL) { return; }
uint32_t type;
std::string keyId;
time_t startTS, endTS;
EVP_PKEY *key;
};
class GroupInfo
{
public:
GroupInfo()
:distribGroup(NULL), grpFlags(0), pop(0), lastPost(0), flags(0), grpChanged(false)
{
return;
}
std::string grpId;
std::string grpName;
std::string grpDesc;
RsDistribGrp *distribGroup;
std::list<std::string> sources;
std::map<std::string, RsDistribMsg *> msgs;
/***********************************/
/* Copied from DistribGrp */
std::wstring grpName;
std::wstring grpDesc;
std::wstring grpCategory;
uint32_t grpFlags; /* PRIVACY & AUTHEN */
uint32_t pop; /* sources.size() */
time_t lastPost; /* modded as msgs added */
/***********************************/
uint32_t flags; /* PUBLISH, SUBSCRIBE, ADMIN */
/* current active Publish Key */
std::string publishKeyId;
std::map<std::string, GroupKey> publishKeys;
GroupKey adminKey;
/* NOT USED YET */
std::string category;
//PIXMAP *GroupIcon;
//RSA_KEY privateKey;
//RSA_KEY publicKey;
bool publisher, allowAnon, allowUnknown;
bool subscribed, listener;
uint32_t type;
uint32_t pop;
uint32_t flags;
std::list<std::string> sources;
std::map<std::string, RsDistribMsg *> msgs;
/* FLAG for GUI - set if changed */
bool grpChanged;
};
std::ostream &operator<<(std::ostream &out, const GroupInfo &info);
class GroupCache
{
public:
@ -211,7 +195,7 @@ class GroupCache
};
class p3GroupDistrib: public CacheSource, public CacheStore, public p3Config
class p3GroupDistrib: public CacheSource, public CacheStore, public p3Config, public nullService
{
public:
@ -239,9 +223,12 @@ int loadAnyCache(const CacheData &data, bool local);
void loadFileGroups(std::string filename, std::string src, bool local);
void loadFileMsgs(std::string filename, uint16_t cacheSubId, std::string src, bool local);
protected:
/* load cache msgs */
void loadMsg(RsDistribMsg *msg, std::string src, bool local);
void loadMsg(RsDistribSignedMsg *msg, std::string src, bool local);
void loadGroup(RsDistribGrp *newGrp);
void loadGroupKey(RsDistribGrpKey *newKey);
/***************************************************************************************/
/***************************************************************************************/
@ -252,11 +239,14 @@ void loadGroup(RsDistribGrp *newGrp);
/* TO FINISH */
public:
std::string createGroup(std::string name, uint32_t flags);
std::string createGroup(std::wstring name, std::wstring desc, uint32_t flags);
//std::string modGroupDescription(std::string grpId, std::string discription);
//std::string modGroupIcon(std::string grpId, PIXMAP *icon);
void publishMsg(RsDistribMsg *msg, bool personalSign);
std::string publishMsg(RsDistribMsg *msg, bool personalSign);
bool subscribeToGroup(std::string grpId, bool subscribe);
/***************************************************************************************/
/***************************************************************************************/
@ -265,6 +255,7 @@ void publishMsg(RsDistribMsg *msg, bool personalSign);
/****************************** Access Content ***************************************/
/***************************************************************************************/
public:
/* get Group Lists */
bool getAllGroupList(std::list<std::string> &grpids);
bool getSubscribedGroupList(std::list<std::string> &grpids);
@ -274,17 +265,14 @@ bool getPopularGroupList(uint32_t popMin, uint32_t popMax, std::list<std::strin
/* get Msg Lists */
bool getAllMsgList(std::string grpId, std::list<std::string> &msgIds);
bool getParentMsgList(std::string grpId, std::string pId, std::list<std::string> &msgIds);
bool getTimePeriodMsgList(std::string grpId, uint32_t timeMin,
uint32_t timeMax, std::list<std::string> &msgIds);
GroupInfo *locked_getGroupInfo(std::string grpId);
RsDistribMsg *locked_getGroupMsg(std::string grpId, std::string msgId);
/* TO FINISH DEFINITIONS */
/* get Details */
//bool getGroupDetails(std::string grpId, RsExternalDistribGroup &grp);
//bool getGroupMsgDetails(std::string grpId, std::string msgId, RsExternalDistribMsg &msg);
/* Filter Messages */
/***************************************************************************************/
@ -299,15 +287,14 @@ RsDistribMsg *locked_getGroupMsg(std::string grpId, std::string msgId);
virtual RsSerialiser *setupSerialiser();
virtual std::list<RsItem *> saveList(bool &cleanup);
virtual void saveDone();
virtual bool loadList(std::list<RsItem *> load);
/***************************************************************************************/
/***************************************************************************************/
/* TO FINISH */
public:
void tick();
virtual int tick(); /* overloaded form pqiService */
/***************************************************************************************/
/**************************** Publish Content ******************************************/
@ -316,7 +303,7 @@ void tick();
protected:
/* create/mod cache content */
void toPublishMsg(RsDistribMsg *msg);
void locked_toPublishMsg(RsDistribMsg *msg);
void publishPendingMsgs();
void publishDistribGroups();
void clear_local_caches(time_t now);
@ -328,47 +315,84 @@ uint16_t determineCacheSubId();
/***************************************************************************************/
/***************************************************************************************/
/***************************************************************************************/
/*************************** Overloaded Functions **************************************/
/***************************************************************************************/
/* Overloaded by inherited classes to Pack/UnPack their messages */
virtual RsSerialType *createSerialiser() = 0;
/* Used to Create/Load Cache Files only */
virtual pqistreamer *createStreamer(BinInterface *bio, std::string src, uint32_t bioflags);
virtual bool validateDistribGrp(RsDistribGrp *newGrp);
virtual bool locked_checkGroupInfo(GroupInfo &info, RsDistribGrp *newGrp);
virtual bool locked_updateGroupInfo(GroupInfo &info, RsDistribGrp *newGrp);
virtual bool locked_checkGroupKeys(GroupInfo &info);
virtual bool locked_updateGroupAdminKey(GroupInfo &info, RsDistribGrpKey *newKey);
virtual bool locked_updateGroupPublishKey(GroupInfo &info, RsDistribGrpKey *newKey);
virtual bool locked_validateDistribSignedMsg(GroupInfo &info, RsDistribSignedMsg *msg);
virtual RsDistribMsg* unpackDistribSignedMsg(RsDistribSignedMsg *newMsg);
virtual bool locked_checkDistribMsg(GroupInfo &info, RsDistribMsg *msg);
virtual bool locked_choosePublishKey(GroupInfo &info);
//virtual RsDistribGrp *locked_createPublicDistribGrp(GroupInfo &info);
//virtual RsDistribGrp *locked_createPrivateDistribGrp(GroupInfo &info);
/***************************************************************************************/
/***************************** Utility Functions ***************************************/
/***************************************************************************************/
/* TO FINISH */
/* utilities */
pqistreamer *createStreamer(BinInterface *bio, std::string src, uint32_t bioflags);
std::string HashRsItem(const RsItem *item);
/***************************************************************************************/
/***************************************************************************************/
/***************************************************************************************/
/***************************** Utility Functions ***************************************/
/***************************************************************************************/
public:
void printGroups(std::ostream &out);
bool groupsChanged(std::list<std::string> &groupIds);
protected:
void locked_notifyGroupChanged(GroupInfo &info);
/***************************************************************************************/
/***************************************************************************************/
/* key cache functions - we use .... (not overloaded)
*/
private:
/* storage */
protected:
RsMutex distribMtx; /* Protects All Data Below */
std::string mOwnId;
private:
std::list<GroupCache> mLocalCaches;
std::map<std::string, GroupInfo> mGroups;
uint32_t mStorePeriod, mPubPeriod;
time_t mNextPublishTime;
std::list<RsDistribMsg *> mPendingPublish;
bool mGroupsChanged;
bool mGroupsRepublish;
std::list<RsItem *> saveCleanupList; /* TEMPORARY LIST WHEN SAVING */
};
/***************************************************************************************/
/***************************************************************************************/
/*
* Structure of the Storage:
*
* map<std::string(id) -> GroupInfo>
*
*
*
*
*/
/***************************************************************************************/
/***************************************************************************************/

View File

@ -25,6 +25,9 @@
#include "services/p3forums.h"
uint32_t convertToInternalFlags(uint32_t extFlags);
uint32_t convertToExternalFlags(uint32_t intFlags);
std::ostream &operator<<(std::ostream &out, const ForumInfo &info)
{
std::string name(info.forumName.begin(), info.forumName.end());
@ -65,10 +68,17 @@ std::ostream &operator<<(std::ostream &out, const ForumMsgInfo &info)
RsForums *rsForums = NULL;
p3Forums::p3Forums()
:mForumsChanged(false)
#define FORUM_STOREPERIOD 10000
#define FORUM_PUBPERIOD 600
p3Forums::p3Forums(uint16_t type, CacheStrapper *cs, CacheTransfer *cft,
std::string srcdir, std::string storedir)
:p3GroupDistrib(type, cs, cft, srcdir, storedir,
CONFIG_TYPE_FORUMS, FORUM_STOREPERIOD, FORUM_PUBPERIOD),
mForumsChanged(false)
{
loadDummyData();
//loadDummyData();
return;
}
@ -81,68 +91,133 @@ p3Forums::~p3Forums()
bool p3Forums::forumsChanged(std::list<std::string> &forumIds)
{
bool changed = mForumsChanged;
mForumsChanged = false;
return changed;
return groupsChanged(forumIds);
}
bool p3Forums::getForumList(std::list<ForumInfo> &forumList)
{
std::list<ForumInfo>::iterator it;
for(it = mForums.begin(); it != mForums.end(); it++)
std::list<std::string> grpIds;
std::list<std::string>::iterator it;
getAllGroupList(grpIds);
RsStackMutex stack(distribMtx); /***** STACK LOCKED MUTEX *****/
for(it = grpIds.begin(); it != grpIds.end(); it++)
{
forumList.push_back(*it);
/* extract details */
GroupInfo *gi = locked_getGroupInfo(*it);
ForumInfo fi;
fi.forumId = gi->grpId;
fi.forumName = gi->grpName;
fi.forumDesc = gi->grpDesc;
fi.forumFlags = gi->flags;
fi.pop = gi->sources.size();
fi.lastPost = gi->lastPost;
forumList.push_back(fi);
}
return true;
}
bool p3Forums::getForumThreadList(std::string fId, std::list<ThreadInfoSummary> &msgs)
{
std::map<std::string, ThreadInfoSummary>::iterator it;
for(it = mForumMsgs.begin(); it != mForumMsgs.end(); it++)
std::list<std::string> msgIds;
std::list<std::string>::iterator it;
getParentMsgList(fId, "", msgIds);
RsStackMutex stack(distribMtx); /***** STACK LOCKED MUTEX *****/
for(it = msgIds.begin(); it != msgIds.end(); it++)
{
if (((it->second).forumId == fId) && ((it->second).parentId == ""))
{
msgs.push_back(it->second);
}
/* get details */
RsDistribMsg *msg = locked_getGroupMsg(fId, *it);
RsForumMsg *fmsg = dynamic_cast<RsForumMsg *>(msg);
if (!fmsg)
continue;
ThreadInfoSummary tis;
tis.forumId = msg->grpId;
tis.msgId = msg->msgId;
tis.parentId = ""; // always NULL (see request)
tis.threadId = msg->msgId; // these are the thread heads!
tis.ts = msg->timestamp;
/* the rest must be gotten from the derived Msg */
tis.title = fmsg->title;
tis.msg = fmsg->msg;
msgs.push_back(tis);
}
return true;
}
bool p3Forums::getForumThreadMsgList(std::string fId, std::string pId, std::list<ThreadInfoSummary> &msgs)
{
std::map<std::string, ThreadInfoSummary>::iterator it;
for(it = mForumMsgs.begin(); it != mForumMsgs.end(); it++)
std::list<std::string> msgIds;
std::list<std::string>::iterator it;
getParentMsgList(fId, pId, msgIds);
RsStackMutex stack(distribMtx); /***** STACK LOCKED MUTEX *****/
for(it = msgIds.begin(); it != msgIds.end(); it++)
{
if (((it->second).forumId == fId) && ((it->second).parentId == pId))
{
msgs.push_back(it->second);
}
/* get details */
RsDistribMsg *msg = locked_getGroupMsg(fId, *it);
RsForumMsg *fmsg = dynamic_cast<RsForumMsg *>(msg);
if (!fmsg)
continue;
ThreadInfoSummary tis;
tis.forumId = msg->grpId;
tis.msgId = msg->msgId;
tis.parentId = msg->parentId;
tis.threadId = msg->threadId;
tis.ts = msg->timestamp;
/* the rest must be gotten from the derived Msg */
tis.title = fmsg->title;
tis.msg = fmsg->msg;
msgs.push_back(tis);
}
return true;
}
bool p3Forums::getForumMessage(std::string fId, std::string mId, ForumMsgInfo &msg)
bool p3Forums::getForumMessage(std::string fId, std::string mId, ForumMsgInfo &info)
{
std::map<std::string, ThreadInfoSummary>::iterator it;
it = mForumMsgs.find(mId);
if (it == mForumMsgs.end())
{
std::list<std::string> msgIds;
std::list<std::string>::iterator it;
RsStackMutex stack(distribMtx); /***** STACK LOCKED MUTEX *****/
RsDistribMsg *msg = locked_getGroupMsg(fId, mId);
RsForumMsg *fmsg = dynamic_cast<RsForumMsg *>(msg);
if (!fmsg)
return false;
}
msg.forumId = (it->second).forumId;
msg.threadId = (it->second).threadId;
msg.parentId = (it->second).parentId;
msg.msgId = (it->second).msgId;
msg.title = (it->second).title;
msg.msg = (it->second).msg;
msg.ts = (it->second).ts;
info.forumId = msg->grpId;
info.msgId = msg->msgId;
info.parentId = msg->parentId;
info.threadId = msg->threadId;
msg.srcId = "SRC";
msg.ts = (it->second).ts;
info.ts = msg->timestamp;
/* the rest must be gotten from the derived Msg */
info.title = fmsg->title;
info.msg = fmsg->msg;
info.srcId = "SRC";
return true;
}
@ -157,56 +232,112 @@ bool p3Forums::ForumMessageSend(ForumMsgInfo &info)
std::string p3Forums::createForum(std::wstring forumName, std::wstring forumDesc, uint32_t forumFlags)
{
time_t now = time(NULL);
std::string id = createGroup(forumName, forumDesc,
convertToInternalFlags(forumFlags));
ForumInfo fi;
fi.lastPost = now;
fi.pop = 1;
fi.forumId = generateRandomServiceId();
fi.forumName = forumName;
fi.forumDesc = forumDesc;
fi.forumFlags = forumFlags;
fi.forumFlags |= RS_FORUM_ADMIN;
mForums.push_back(fi);
mForumsChanged = true;
return fi.forumId;
return id;
}
std::string p3Forums::createForumMsg(std::string fId, std::string pId,
std::wstring title, std::wstring msg)
{
ThreadInfoSummary tis;
tis.forumId = fId;
tis.parentId = pId;
RsForumMsg *fmsg = new RsForumMsg();
fmsg->grpId = fId;
fmsg->parentId = pId;
/* find the parent -> copy threadId */
tis.msgId = generateRandomServiceId();
std::map<std::string, ThreadInfoSummary>::iterator it;
it = mForumMsgs.find(pId);
if (it == mForumMsgs.end())
{
tis.parentId = "";
tis.threadId = tis.msgId;
RsStackMutex stack(distribMtx); /***** STACK LOCKED MUTEX *****/
RsDistribMsg *msg = locked_getGroupMsg(fId, pId);
if (!msg)
{
fmsg->parentId = "";
fmsg->threadId = "";
}
else
{
tis.threadId = (it->second).threadId;
if (msg->parentId == "")
{
fmsg->threadId = fmsg->parentId;
}
else
{
fmsg->threadId = msg->threadId;
}
}
}
tis.title = title;
tis.msg = msg;
tis.ts = time(NULL);
fmsg->title = title;
fmsg->msg = msg;
fmsg->timestamp = time(NULL);
mForumMsgs[tis.msgId] = tis;
mForumsChanged = true;
std::string msgId = publishMsg(fmsg, true);
return msgId;
}
return tis.msgId;
#if 0
/* p3Config Serialiser */
RsSerialiser *p3Forums::setupSerialiser()
{
RsSerialiser *rss = new RsSerialiser();
rss->addSerialType(new RsForumSerialiser());
return rss;
}
pqistreamer *p3Forums::createStreamer(BinInterface *bio, std::string src, uint32_t bioflags)
{
RsSerialiser *rsSerialiser = new RsSerialiser();
//rsSerialiser->addSerialType(new RsForumSerialiser());
rsSerialiser->addSerialType(new RsDistribSerialiser());
pqistreamer *streamer = new pqistreamer(rsSerialiser, src, bio, bioflags);
return streamer;
}
#endif
RsSerialType *p3Forums::createSerialiser()
{
return new RsForumSerialiser();
}
bool p3Forums::locked_checkDistribMsg(RsDistribMsg *msg)
{
return true;
}
RsDistribGrp *p3Forums::locked_createPublicDistribGrp(GroupInfo &info)
{
RsDistribGrp *grp = NULL; //new RsForumGrp();
return grp;
}
RsDistribGrp *p3Forums::locked_createPrivateDistribGrp(GroupInfo &info)
{
RsDistribGrp *grp = NULL; //new RsForumGrp();
return grp;
}
uint32_t convertToInternalFlags(uint32_t extFlags)
{
return extFlags;
}
uint32_t convertToExternalFlags(uint32_t intFlags)
{
return intFlags;
}
bool p3Forums::forumSubscribe(std::string fId, bool subscribe)
{
return subscribeToGroup(fId, subscribe);
}
@ -215,25 +346,33 @@ std::string p3Forums::createForumMsg(std::string fId, std::string pId,
void p3Forums::loadDummyData()
{
ForumInfo fi;
std::string forumId;
std::string msgId;
time_t now = time(NULL);
fi.forumId = "FID1234";
fi.forumName = L"Forum 1";
fi.forumDesc = L"Forum 1";
fi.forumFlags = RS_FORUM_ADMIN;
fi.forumFlags = RS_DISTRIB_ADMIN;
fi.pop = 2;
fi.lastPost = now - 123;
mForums.push_back(fi);
forumId = createForum(fi.forumName, fi.forumDesc, fi.forumFlags);
fi.forumId = "FID2345";
fi.forumName = L"Forum 2";
fi.forumDesc = L"Forum 2";
fi.forumFlags = RS_FORUM_SUBSCRIBED;
fi.forumFlags = RS_DISTRIB_SUBSCRIBED;
fi.pop = 3;
fi.lastPost = now - 1234;
mForums.push_back(fi);
forumId = createForum(fi.forumName, fi.forumDesc, fi.forumFlags);
msgId = createForumMsg(forumId, "", L"WELCOME TO Forum1", L"Hello!");
msgId = createForumMsg(forumId, msgId, L"Love this forum", L"Hello2!");
return;
/* ignore this */
fi.forumId = "FID3456";
fi.forumName = L"Forum 3";
@ -242,7 +381,7 @@ void p3Forums::loadDummyData()
fi.pop = 3;
fi.lastPost = now - 1234;
mForums.push_back(fi);
forumId = createForum(fi.forumName, fi.forumDesc, fi.forumFlags);
fi.forumId = "FID4567";
fi.forumName = L"Forum 4";
@ -251,7 +390,8 @@ void p3Forums::loadDummyData()
fi.pop = 5;
fi.lastPost = now - 1234;
mForums.push_back(fi);
forumId = createForum(fi.forumName, fi.forumDesc, fi.forumFlags);
fi.forumId = "FID5678";
fi.forumName = L"Forum 5";
fi.forumDesc = L"Forum 5";
@ -259,7 +399,8 @@ void p3Forums::loadDummyData()
fi.pop = 1;
fi.lastPost = now - 1234;
mForums.push_back(fi);
forumId = createForum(fi.forumName, fi.forumDesc, fi.forumFlags);
fi.forumId = "FID6789";
fi.forumName = L"Forum 6";
fi.forumDesc = L"Forum 6";
@ -267,7 +408,8 @@ void p3Forums::loadDummyData()
fi.pop = 2;
fi.lastPost = now - 1234;
mForums.push_back(fi);
forumId = createForum(fi.forumName, fi.forumDesc, fi.forumFlags);
fi.forumId = "FID7890";
fi.forumName = L"Forum 7";
fi.forumDesc = L"Forum 7";
@ -275,7 +417,8 @@ void p3Forums::loadDummyData()
fi.pop = 4;
fi.lastPost = now - 1234;
mForums.push_back(fi);
forumId = createForum(fi.forumName, fi.forumDesc, fi.forumFlags);
fi.forumId = "FID8901";
fi.forumName = L"Forum 8";
fi.forumDesc = L"Forum 8";
@ -283,7 +426,8 @@ void p3Forums::loadDummyData()
fi.pop = 3;
fi.lastPost = now - 1234;
mForums.push_back(fi);
forumId = createForum(fi.forumName, fi.forumDesc, fi.forumFlags);
fi.forumId = "FID9012";
fi.forumName = L"Forum 9";
fi.forumDesc = L"Forum 9";
@ -291,7 +435,7 @@ void p3Forums::loadDummyData()
fi.pop = 2;
fi.lastPost = now - 1234;
mForums.push_back(fi);
forumId = createForum(fi.forumName, fi.forumDesc, fi.forumFlags);
fi.forumId = "FID9123";
fi.forumName = L"Forum 10";
@ -300,7 +444,7 @@ void p3Forums::loadDummyData()
fi.pop = 1;
fi.lastPost = now - 1234;
mForums.push_back(fi);
forumId = createForum(fi.forumName, fi.forumDesc, fi.forumFlags);
mForumsChanged = true;
}

View File

@ -27,15 +27,57 @@
*/
#include "rsiface/rsforums.h"
#include "services/p3service.h"
#include "services/p3distrib.h"
#include "serialiser/rsforumitems.h"
class p3Forums: public RsForums
#if 0
class RsForumGrp: public RsDistribGrp
{
public:
p3Forums();
RsForumGrp();
/* orig data (from RsDistribMsg)
* std::string grpId
*/
std::wstring name;
std::wstring desc;
};
class RsForumMsg: public RsDistribMsg
{
public:
RsForumMsg();
/* orig data (from RsDistribMsg)
* std::string grpId
* std::string msgId
* std::string threadId
* std::string parentId
* time_t timestamp
*/
/* new data */
std::wstring title;
std::wstring msg;
std::string srcId;
};
#endif
class p3Forums: public p3GroupDistrib, public RsForums
{
public:
p3Forums(uint16_t type, CacheStrapper *cs, CacheTransfer *cft,
std::string srcdir, std::string storedir);
virtual ~p3Forums();
void loadDummyData();
/****************************************/
/********* rsForums Interface ***********/
@ -50,16 +92,28 @@ virtual bool getForumMessage(std::string fId, std::string mId, ForumMsgInfo &msg
virtual bool ForumMessageSend(ForumMsgInfo &info);
/****************************************/
virtual bool forumSubscribe(std::string fId, bool subscribe);
private:
/****************************************/
/********* Overloaded Functions *********/
//virtual RsSerialiser *setupSerialiser();
//virtual pqistreamer *createStreamer(BinInterface *bio, std::string src, uint32_t bioflags);
virtual RsSerialType *createSerialiser();
virtual bool locked_checkDistribMsg(RsDistribMsg *msg);
virtual RsDistribGrp *locked_createPublicDistribGrp(GroupInfo &info);
virtual RsDistribGrp *locked_createPrivateDistribGrp(GroupInfo &info);
/****************************************/
std::string createForumMsg(std::string fid, std::string pid,
std::wstring title, std::wstring msg);
void loadDummyData();
std::list<ForumInfo> mForums;
std::map<std::string, ThreadInfoSummary> mForumMsgs;
private:
bool mForumsChanged;
};

View File

@ -33,7 +33,10 @@
/* global variable for GUI */
RsGameLauncher *rsGameLauncher = NULL;
#define GAME_DEBUG 1
/*****
* #define GAME_DEBUG 1
*****/
#define TEST_NO_GAMES 1
/* So STATEs is always the best way to do things....

View File

@ -44,7 +44,9 @@ std::string generateRandomLinkId();
*
*/
#define RANK_DEBUG 1
/*********
* #define RANK_DEBUG 1
*********/
p3Ranking::p3Ranking(p3ConnectMgr *connMgr,
uint16_t type, CacheStrapper *cs, CacheTransfer *cft,

View File

@ -95,6 +95,35 @@ void addSerialType(RsSerialType *);
};
class nullService: public pqiService
{
protected:
nullService(uint16_t type)
:pqiService((((uint32_t) RS_PKT_VERSION_SERVICE) << 24) + (((uint32_t) type) << 8))
{
return;
}
//virtual int tick()
public:
// overloaded NULL pqiService interface.
virtual int receive(RsRawItem *item)
{
/* drop any items */
delete item;
return 1;
}
virtual RsRawItem * send()
{
return NULL;
}
};
#if 0
class p3ThreadedService: public p3Service, public RsThread