mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-18 10:58:43 -04:00
Changes to support the new NewsFeed.
* added interface to rsnotify/p3notify/pqinotify * added getForumInfo() to forum interface. * added virtual functions to p3distrib for event feedback. New NewsFeed Notification. * Peer Connection/Disconnection. * Failed Certificate connection. * New/Updated Forums and Forum Msgs. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@616 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
971ad4fe9b
commit
9f024eaee7
12 changed files with 192 additions and 16 deletions
|
@ -354,6 +354,7 @@ void p3GroupDistrib::loadGroup(RsDistribGrp *newGrp)
|
|||
|
||||
/* look for duplicate */
|
||||
bool checked = false;
|
||||
bool isNew = false;
|
||||
std::map<std::string, GroupInfo>::iterator it;
|
||||
it = mGroups.find(gid);
|
||||
|
||||
|
@ -383,6 +384,8 @@ void p3GroupDistrib::loadGroup(RsDistribGrp *newGrp)
|
|||
mGroups[gid] = gi;
|
||||
|
||||
it = mGroups.find(gid);
|
||||
|
||||
isNew = true;
|
||||
}
|
||||
|
||||
/* at this point - always in the map */
|
||||
|
@ -428,6 +431,9 @@ void p3GroupDistrib::loadGroup(RsDistribGrp *newGrp)
|
|||
}
|
||||
else
|
||||
{
|
||||
/* Callback for any derived classes */
|
||||
locked_eventUpdateGroup(&(it->second), isNew);
|
||||
|
||||
locked_notifyGroupChanged(it->second);
|
||||
}
|
||||
|
||||
|
@ -608,6 +614,9 @@ void p3GroupDistrib::loadMsg(RsDistribSignedMsg *newMsg, std::string src, bool l
|
|||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
/* Callback for any derived classes to play with */
|
||||
locked_eventNewMsg(msg);
|
||||
|
||||
/* else if group = subscribed | listener -> publish */
|
||||
/* if it has come from us... then it has been published already */
|
||||
if ((!local) && (git->second.flags & (RS_DISTRIB_SUBSCRIBED)))
|
||||
|
@ -2464,6 +2473,14 @@ bool p3GroupDistrib::locked_checkDistribMsg(
|
|||
#ifdef DISTRIB_DEBUG
|
||||
std::cerr << "p3GroupDistrib::locked_checkDistribMsg() TS out of range";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "p3GroupDistrib::locked_checkDistribMsg() msg->timestamp: " << msg->timestamp;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "p3GroupDistrib::locked_checkDistribMsg() = " << now - msg->timestamp << " secs ago";
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "p3GroupDistrib::locked_checkDistribMsg() max TS: " << max;
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "p3GroupDistrib::locked_checkDistribMsg() min TS: " << min;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
/* if outside range -> remove */
|
||||
return false;
|
||||
|
|
|
@ -276,8 +276,12 @@ RsDistribMsg *locked_getGroupMsg(std::string grpId, std::string msgId);
|
|||
/* Filter Messages */
|
||||
|
||||
/***************************************************************************************/
|
||||
/***************************** Event Feedback ******************************************/
|
||||
/***************************************************************************************/
|
||||
|
||||
virtual bool locked_eventUpdateGroup(GroupInfo *, bool isNew) = 0;
|
||||
virtual bool locked_eventNewMsg(RsDistribMsg *) = 0;
|
||||
|
||||
/***************************************************************************************/
|
||||
/********************************* p3Config ********************************************/
|
||||
/***************************************************************************************/
|
||||
|
|
|
@ -94,6 +94,28 @@ bool p3Forums::forumsChanged(std::list<std::string> &forumIds)
|
|||
return groupsChanged(forumIds);
|
||||
}
|
||||
|
||||
bool p3Forums::getForumInfo(std::string fId, ForumInfo &fi)
|
||||
{
|
||||
RsStackMutex stack(distribMtx); /***** STACK LOCKED MUTEX *****/
|
||||
|
||||
/* extract details */
|
||||
GroupInfo *gi = locked_getGroupInfo(fId);
|
||||
|
||||
if (!gi)
|
||||
return false;
|
||||
|
||||
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;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool p3Forums::getForumList(std::list<ForumInfo> &forumList)
|
||||
{
|
||||
|
@ -102,23 +124,13 @@ bool p3Forums::getForumList(std::list<ForumInfo> &forumList)
|
|||
|
||||
getAllGroupList(grpIds);
|
||||
|
||||
RsStackMutex stack(distribMtx); /***** STACK LOCKED MUTEX *****/
|
||||
for(it = grpIds.begin(); it != grpIds.end(); 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);
|
||||
if (getForumInfo(*it, fi))
|
||||
{
|
||||
forumList.push_back(fi);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -341,6 +353,42 @@ bool p3Forums::forumSubscribe(std::string fId, bool subscribe)
|
|||
}
|
||||
|
||||
|
||||
/***************************************************************************************/
|
||||
/****************** Event Feedback (Overloaded form p3distrib) *************************/
|
||||
/***************************************************************************************/
|
||||
|
||||
#include "pqi/pqinotify.h"
|
||||
|
||||
bool p3Forums::locked_eventUpdateGroup(GroupInfo *info, bool isNew)
|
||||
{
|
||||
std::string grpId = info->grpId;
|
||||
std::string msgId;
|
||||
std::string nullId;
|
||||
|
||||
if (isNew)
|
||||
{
|
||||
getPqiNotify()->AddFeedItem(RS_FEED_ITEM_FORUM_NEW, grpId, msgId, nullId);
|
||||
}
|
||||
else
|
||||
{
|
||||
getPqiNotify()->AddFeedItem(RS_FEED_ITEM_FORUM_UPDATE, grpId, msgId, nullId);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3Forums::locked_eventNewMsg(RsDistribMsg *msg)
|
||||
{
|
||||
std::string grpId = msg->grpId;
|
||||
std::string msgId = msg->msgId;
|
||||
std::string nullId;
|
||||
|
||||
getPqiNotify()->AddFeedItem(RS_FEED_ITEM_FORUM_MSG, grpId, msgId, nullId);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************************************/
|
||||
|
||||
void p3Forums::loadDummyData()
|
||||
|
|
|
@ -85,6 +85,7 @@ virtual bool forumsChanged(std::list<std::string> &forumIds);
|
|||
|
||||
virtual std::string createForum(std::wstring forumName, std::wstring forumDesc, uint32_t forumFlags);
|
||||
|
||||
virtual bool getForumInfo(std::string fId, ForumInfo &fi);
|
||||
virtual bool getForumList(std::list<ForumInfo> &forumList);
|
||||
virtual bool getForumThreadList(std::string fId, std::list<ThreadInfoSummary> &msgs);
|
||||
virtual bool getForumThreadMsgList(std::string fId, std::string tId, std::list<ThreadInfoSummary> &msgs);
|
||||
|
@ -94,6 +95,14 @@ virtual bool ForumMessageSend(ForumMsgInfo &info);
|
|||
|
||||
virtual bool forumSubscribe(std::string fId, bool subscribe);
|
||||
|
||||
/***************************************************************************************/
|
||||
/****************** Event Feedback (Overloaded form p3distrib) *************************/
|
||||
/***************************************************************************************/
|
||||
|
||||
virtual bool locked_eventUpdateGroup(GroupInfo *, bool isNew);
|
||||
virtual bool locked_eventNewMsg(RsDistribMsg *);
|
||||
|
||||
|
||||
/****************************************/
|
||||
/********* Overloaded Functions *********/
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue