Added notify of received groups and messages for forums and channels to libretroshare.

Show GxsChannelPostItem in NewsFeed.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7675 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2014-11-13 22:03:12 +00:00
parent 67215c7ffe
commit 33f785f200
6 changed files with 281 additions and 211 deletions

View file

@ -63,6 +63,9 @@ const uint32_t RS_CHAT_TABBED_WINDOW = 0x0008;
const uint32_t RS_CHAT_BLINK = 0x0010;
const uint32_t RS_FEED_TYPE_PEER = 0x0010;
const uint32_t RS_FEED_TYPE_CHANNEL = 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;
@ -82,6 +85,18 @@ const uint32_t RS_FEED_ITEM_SEC_BAD_CERTIFICATE = RS_FEED_TYPE_SECURITY | 0
const uint32_t RS_FEED_ITEM_SEC_INTERNAL_ERROR = RS_FEED_TYPE_SECURITY | 0x0007;
const uint32_t RS_FEED_ITEM_SEC_MISSING_CERTIFICATE = RS_FEED_TYPE_SECURITY | 0x0008;
const uint32_t RS_FEED_ITEM_CHANNEL_NEW = RS_FEED_TYPE_CHANNEL | 0x0001;
//const uint32_t RS_FEED_ITEM_CHANNEL_UPDATE = RS_FEED_TYPE_CHANNEL | 0x0002;
const uint32_t RS_FEED_ITEM_CHANNEL_MSG = RS_FEED_TYPE_CHANNEL | 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_NEW = RS_FEED_TYPE_BLOG | 0x0001;
//const uint32_t RS_FEED_ITEM_BLOG_UPDATE = RS_FEED_TYPE_BLOG | 0x0002;
//const uint32_t RS_FEED_ITEM_BLOG_MSG = RS_FEED_TYPE_BLOG | 0x0003;
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;

View file

@ -33,6 +33,9 @@
#include "retroshare/rsgxsflags.h"
#include "retroshare/rsfiles.h"
#include "rsserver/p3face.h"
#include "retroshare/rsnotify.h"
#include <stdio.h>
// For Dummy Msgs.
@ -128,6 +131,12 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
std::cerr << "p3GxsChannels::notifyChanges()";
std::cerr << std::endl;
p3Notify *notify = NULL;
if (!changes.empty())
{
notify = RsServer::notify();
}
/* iterate through and grab any new messages */
std::list<RsGxsGroupId> unprocessedGroups;
@ -135,26 +144,64 @@ void p3GxsChannels::notifyChanges(std::vector<RsGxsNotify *> &changes)
for(it = changes.begin(); it != changes.end(); ++it)
{
RsGxsMsgChange *msgChange = dynamic_cast<RsGxsMsgChange *>(*it);
if (msgChange && !msgChange->metaChange())
if (msgChange)
{
std::cerr << "p3GxsChannels::notifyChanges() Found Message Change Notification";
std::cerr << std::endl;
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator mit;
for(mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
if (msgChange->getType() == RsGxsNotify::TYPE_RECEIVE)
{
std::cerr << "p3GxsChannels::notifyChanges() Msgs for Group: " << mit->first;
/* message received */
if (notify)
{
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator mit;
for (mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
{
std::vector<RsGxsMessageId>::iterator mit1;
for (mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
{
notify->AddFeedItem(RS_FEED_ITEM_CHANNEL_MSG, mit->first.toStdString(), mit1->toStdString());
}
}
}
}
if (!msgChange->metaChange())
{
std::cerr << "p3GxsChannels::notifyChanges() Found Message Change Notification";
std::cerr << std::endl;
if (autoDownloadEnabled(mit->first))
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator mit;
for(mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
{
std::cerr << "p3GxsChannels::notifyChanges() AutoDownload for Group: " << mit->first;
std::cerr << "p3GxsChannels::notifyChanges() Msgs for Group: " << mit->first;
std::cerr << std::endl;
/* problem is most of these will be comments and votes,
* should make it occasional - every 5mins / 10minutes TODO */
unprocessedGroups.push_back(mit->first);
if (autoDownloadEnabled(mit->first))
{
std::cerr << "p3GxsChannels::notifyChanges() AutoDownload for Group: " << mit->first;
std::cerr << std::endl;
/* problem is most of these will be comments and votes,
* should make it occasional - every 5mins / 10minutes TODO */
unprocessedGroups.push_back(mit->first);
}
}
}
}
else
{
if (notify && (*it)->getType() == RsGxsNotify::TYPE_RECEIVE)
{
RsGxsGroupChange *grpChange = dynamic_cast<RsGxsGroupChange *>(*it);
if (grpChange)
{
/* group received */
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
std::list<RsGxsGroupId>::iterator git;
for (git = grpList.begin(); git != grpList.end(); ++git)
{
notify->AddFeedItem(RS_FEED_ITEM_CHANNEL_NEW, git->toStdString());
}
}
}
}

View file

@ -28,6 +28,8 @@
#include <retroshare/rsidentity.h>
#include "rsserver/p3face.h"
#include "retroshare/rsnotify.h"
#include "retroshare/rsgxsflags.h"
#include <stdio.h>
@ -98,6 +100,51 @@ uint32_t p3GxsForums::forumsAuthenPolicy()
void p3GxsForums::notifyChanges(std::vector<RsGxsNotify *> &changes)
{
if (!changes.empty())
{
p3Notify *notify = RsServer::notify();
if (notify)
{
std::vector<RsGxsNotify*>::iterator it;
for(it = changes.begin(); it != changes.end(); ++it)
{
RsGxsNotify *c = *it;
if (c->getType() == RsGxsNotify::TYPE_RECEIVE)
{
RsGxsMsgChange *msgChange = dynamic_cast<RsGxsMsgChange*>(c);
if (msgChange)
{
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> > &msgChangeMap = msgChange->msgChangeMap;
std::map<RsGxsGroupId, std::vector<RsGxsMessageId> >::iterator mit;
for (mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit)
{
std::vector<RsGxsMessageId>::iterator mit1;
for (mit1 = mit->second.begin(); mit1 != mit->second.end(); ++mit1)
{
notify->AddFeedItem(RS_FEED_ITEM_FORUM_MSG, mit->first.toStdString(), mit1->toStdString());
}
}
continue;
}
RsGxsGroupChange *grpChange = dynamic_cast<RsGxsGroupChange *>(*it);
if (grpChange)
{
/* group received */
std::list<RsGxsGroupId> &grpList = grpChange->mGrpIdList;
std::list<RsGxsGroupId>::iterator git;
for (git = grpList.begin(); git != grpList.end(); ++git)
{
notify->AddFeedItem(RS_FEED_ITEM_FORUM_NEW, git->toStdString());
}
continue;
}
}
}
}
}
RsGxsIfaceHelper::receiveChanges(changes);
}