mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -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
@ -27,6 +27,9 @@
|
||||
|
||||
#include "pqinetwork.h"
|
||||
|
||||
/******************** notify of new Cert **************************/
|
||||
#include "pqinotify.h"
|
||||
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/evp.h>
|
||||
#include <openssl/pem.h>
|
||||
@ -1202,6 +1205,14 @@ bool AuthXPGP::ProcessXPGP(XPGP *xpgp, std::string &id)
|
||||
mToSaveCerts = true;
|
||||
xpgpMtx.unlock(); /**** UNLOCK ****/
|
||||
|
||||
/******************** notify of new Cert **************************/
|
||||
pqiNotify *pqinotify = getPqiNotify();
|
||||
if (pqinotify)
|
||||
{
|
||||
pqinotify->AddFeedItem(RS_FEED_ITEM_PEER_NEW, xpgpid, "","");
|
||||
}
|
||||
/******************** notify of new Cert **************************/
|
||||
|
||||
id = xpgpid;
|
||||
|
||||
return true;
|
||||
|
@ -1056,6 +1056,19 @@ void p3ConnectMgr::tickMonitors()
|
||||
{
|
||||
notify->AddPopupMessage(RS_POPUP_CONNECT,
|
||||
peer.id, "Peer Online: ");
|
||||
|
||||
|
||||
notify->AddFeedItem(RS_FEED_ITEM_PEER_CONNECT, peer.id, "", "");
|
||||
}
|
||||
}
|
||||
if (peer.actions & RS_PEER_DISCONNECTED)
|
||||
{
|
||||
pqiNotify *notify = getPqiNotify();
|
||||
if (notify)
|
||||
{
|
||||
notify->AddFeedItem(RS_FEED_ITEM_PEER_DISCONNECT, peer.id, "", "");
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -132,3 +132,27 @@ bool p3Notify::AddSysMessage(uint32_t sysid, uint32_t type,
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool p3Notify::GetFeedItem(RsFeedItem &item)
|
||||
{
|
||||
RsStackMutex stack(noteMtx); /************* LOCK MUTEX ************/
|
||||
if (pendingNewsFeed.size() > 0)
|
||||
{
|
||||
item = pendingNewsFeed.front();
|
||||
pendingNewsFeed.pop_front();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool p3Notify::AddFeedItem(uint32_t type, std::string id1, std::string id2, std::string id3)
|
||||
{
|
||||
RsStackMutex stack(noteMtx); /************* LOCK MUTEX ************/
|
||||
pendingNewsFeed.push_back(RsFeedItem(type, id1, id2, id3));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -70,10 +70,12 @@ virtual bool GetPopupMessageList(std::map<uint32_t, std::string> &list);
|
||||
virtual bool SetSysMessageMode(uint32_t sysid, uint32_t mode);
|
||||
virtual bool SetPopupMessageMode(uint32_t ptype, uint32_t mode);
|
||||
|
||||
virtual bool GetFeedItem(RsFeedItem &item);
|
||||
|
||||
/* Overloaded from pqiNotify */
|
||||
virtual bool AddPopupMessage(uint32_t ptype, std::string name, std::string msg);
|
||||
virtual bool AddSysMessage(uint32_t sysid, uint32_t type, std::string title, std::string msg);
|
||||
virtual bool AddFeedItem(uint32_t type, std::string id1, std::string id2, std::string id3);
|
||||
|
||||
private:
|
||||
|
||||
@ -81,6 +83,7 @@ virtual bool AddSysMessage(uint32_t sysid, uint32_t type, std::string title, std
|
||||
|
||||
std::list<p3NotifySysMsg> pendingSysMsgs;
|
||||
std::list<p3NotifyPopupMsg> pendingPopupMsgs;
|
||||
std::list<RsFeedItem> pendingNewsFeed;
|
||||
};
|
||||
|
||||
|
||||
|
@ -42,6 +42,7 @@ virtual ~pqiNotify() { return; }
|
||||
/* Input from libretroshare */
|
||||
virtual bool AddPopupMessage(uint32_t ptype, std::string name, std::string msg) = 0;
|
||||
virtual bool AddSysMessage(uint32_t sysid, uint32_t type, std::string title, std::string msg) = 0;
|
||||
virtual bool AddFeedItem(uint32_t type, std::string id1, std::string id2, std::string id3) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
@ -106,6 +106,7 @@ virtual bool forumsChanged(std::list<std::string> &forumIds) = 0;
|
||||
|
||||
virtual std::string createForum(std::wstring forumName, std::wstring forumDesc, uint32_t forumFlags) = 0;
|
||||
|
||||
virtual bool getForumInfo(std::string fId, ForumInfo &fi) = 0;
|
||||
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;
|
||||
|
@ -46,6 +46,50 @@ const uint32_t RS_POPUP_CALL = 0x0004;
|
||||
const uint32_t RS_POPUP_CONNECT = 0x0008;
|
||||
|
||||
|
||||
|
||||
const uint32_t RS_FEED_TYPE_PEER = 0x0010;
|
||||
const uint32_t RS_FEED_TYPE_CHAN = 0x0020;
|
||||
const uint32_t RS_FEED_TYPE_FORUM = 0x0040;
|
||||
const uint32_t RS_FEED_TYPE_BLOG = 0x0080;
|
||||
const uint32_t RS_FEED_TYPE_CHAT = 0x0100;
|
||||
const uint32_t RS_FEED_TYPE_MSG = 0x0200;
|
||||
const uint32_t RS_FEED_TYPE_FILES = 0x0400;
|
||||
|
||||
const uint32_t RS_FEED_ITEM_PEER_CONNECT = RS_FEED_TYPE_PEER | 0x0001;
|
||||
const uint32_t RS_FEED_ITEM_PEER_DISCONNECT = RS_FEED_TYPE_PEER | 0x0002;
|
||||
const uint32_t RS_FEED_ITEM_PEER_NEW = RS_FEED_TYPE_PEER | 0x0003;
|
||||
const uint32_t RS_FEED_ITEM_PEER_HELLO = RS_FEED_TYPE_PEER | 0x0004;
|
||||
|
||||
const uint32_t RS_FEED_ITEM_CHAN_NEW = RS_FEED_TYPE_CHAN | 0x0001;
|
||||
const uint32_t RS_FEED_ITEM_CHAN_UPDATE = RS_FEED_TYPE_CHAN | 0x0002;
|
||||
const uint32_t RS_FEED_ITEM_CHAN_MSG = RS_FEED_TYPE_CHAN | 0x0003;
|
||||
|
||||
const uint32_t RS_FEED_ITEM_FORUM_NEW = RS_FEED_TYPE_FORUM | 0x0001;
|
||||
const uint32_t RS_FEED_ITEM_FORUM_UPDATE = RS_FEED_TYPE_FORUM | 0x0002;
|
||||
const uint32_t RS_FEED_ITEM_FORUM_MSG = RS_FEED_TYPE_FORUM | 0x0003;
|
||||
|
||||
const uint32_t RS_FEED_ITEM_BLOG_MSG = RS_FEED_TYPE_BLOG | 0x0001;
|
||||
const uint32_t RS_FEED_ITEM_CHAT_NEW = RS_FEED_TYPE_CHAT | 0x0001;
|
||||
const uint32_t RS_FEED_ITEM_MESSAGE = RS_FEED_TYPE_MSG | 0x0001;
|
||||
const uint32_t RS_FEED_ITEM_FILES_NEW = RS_FEED_TYPE_FILES | 0x0001;
|
||||
|
||||
|
||||
class RsFeedItem
|
||||
{
|
||||
public:
|
||||
RsFeedItem(uint32_t type, std::string id1, std::string id2, std::string id3)
|
||||
:mType(type), mId1(id1), mId2(id2), mId3(id3)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RsFeedItem() :mType(0) { return; }
|
||||
|
||||
uint32_t mType;
|
||||
std::string mId1, mId2, mId3;
|
||||
};
|
||||
|
||||
|
||||
class RsNotify
|
||||
{
|
||||
public:
|
||||
@ -65,6 +109,9 @@ virtual bool GetPopupMessageList(std::map<uint32_t, std::string> &list) = 0;
|
||||
virtual bool SetSysMessageMode(uint32_t sysid, uint32_t mode) = 0;
|
||||
virtual bool SetPopupMessageMode(uint32_t ptype, uint32_t mode) = 0;
|
||||
|
||||
/* Feed Output */
|
||||
virtual bool GetFeedItem(RsFeedItem &item) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
@ -78,8 +78,6 @@
|
||||
#define RS_RELEASE 1
|
||||
****/
|
||||
|
||||
#define RS_RELEASE 1
|
||||
|
||||
/**************** PQI_USE_XPGP ******************/
|
||||
#if defined(PQI_USE_XPGP)
|
||||
#include "pqi/authxpgp.h"
|
||||
|
@ -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…
Reference in New Issue
Block a user