completed status setting and getting for forums

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3351 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2010-08-08 13:52:29 +00:00
parent 9ff6849a55
commit 1ad871a3e9
3 changed files with 47 additions and 43 deletions

View File

@ -36,6 +36,9 @@
#define RS_FORUMMSG_NEW 0x0010
#define FORUM_MSG_STATUS_MASK 0x000f
#define FORUM_MSG_STATUS_READ 0x0001
#define FORUM_MSG_STATUS_UNREADY_BY_USER 0x0002
class ForumInfo
{
@ -133,7 +136,8 @@ virtual bool getForumList(std::list<ForumInfo> &forumList) = 0;
virtual bool getForumThreadList(std::string fId, std::list<ThreadInfoSummary> &msgs) = 0;
virtual bool getForumThreadMsgList(std::string fId, std::string pId, std::list<ThreadInfoSummary> &msgs) = 0;
virtual bool getForumMessage(std::string fId, std::string mId, ForumMsgInfo &msg) = 0;
virtual bool setMessageStatus(const std::string& fId,const std::string& mId,const uint32_t status) = 0;
virtual bool setMessageStatus(const std::string& fId,const std::string& mId, const uint32_t status, const uint32_t statusMask) = 0;
virtual bool getMessageStatus(const std::string& fId, const std::string& mId, uint32_t& status, const uint32_t statusMask) = 0;
virtual bool ForumMessageSend(ForumMsgInfo &info) = 0;
virtual bool forumSubscribe(std::string fId, bool subscribe) = 0;

View File

@ -266,18 +266,54 @@ bool p3Forums::ForumMessageSend(ForumMsgInfo &info)
return false;
}
setMessageStatus(info.forumId, mId, FORUM_MSG_STATUS_READ);
return setMessageStatus(info.forumId, mId, FORUM_MSG_STATUS_READ, FORUM_MSG_STATUS_MASK);
}
bool p3Forums::setMessageStatus(const std::string& fId,const std::string& mId,const uint32_t status, const uint32_t statusMask)
{
setReadStatus(fId, mId, (status & statusMask));
return true;
}
bool p3Forums::setMessageStatus(const std::string& fId,const std::string& mId,const uint32_t status)
bool p3Forums::getMessageStatus(const std::string& fId, const std::string& mId, uint32_t& status, uint32_t statusMask)
{
setReadStatus(fId, mId, status);
RsStackMutex stack(distribMtx);
std::list<RsForumReadStatus *>::iterator lit = mReadStatus.begin();
for(; lit != mReadStatus.end(); lit++)
{
if((*lit)->forumId == fId)
{
break;
}
}
std::map<std::string, uint32_t >::iterator mit;
if(lit == mReadStatus.end())
{
return false;
}
else
{
mit = (*lit)->msgReadStatus.find(mId);
if(mit != (*lit)->msgReadStatus.end())
{
status = (mit->second & statusMask);
return true;
}
}
return false;
}
std::string p3Forums::createForum(std::wstring forumName, std::wstring forumDesc, uint32_t forumFlags)
{

View File

@ -30,44 +30,7 @@
#include "services/p3distrib.h"
#include "serialiser/rsforumitems.h"
#if 0
class RsForumGrp: public RsDistribGrp
{
public:
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
const uint32_t FORUM_MSG_STATUS_READ = 1;
class p3Forums: public p3GroupDistrib, public RsForums
{
@ -93,7 +56,8 @@ virtual bool getForumThreadMsgList(std::string fId, std::string tId, std::list<T
virtual bool getForumMessage(std::string fId, std::string mId, ForumMsgInfo &msg);
virtual void setReadStatus(const std::string& forumId,const std::string& msgId,const uint32_t status);
virtual bool ForumMessageSend(ForumMsgInfo &info);
virtual bool setMessageStatus(const std::string& fId, const std::string& mId,const uint32_t status);
virtual bool setMessageStatus(const std::string& fId, const std::string& mId, const uint32_t status, const uint32_t statusMask);
virtual bool getMessageStatus(const std::string& fId, const std::string& mId, uint32_t& status, const uint32_t statusMask);
virtual bool forumSubscribe(std::string fId, bool subscribe);