From 33f785f2004a17c5d939b6b60a48b6f5687cfee0 Mon Sep 17 00:00:00 2001 From: thunder2 Date: Thu, 13 Nov 2014 22:03:12 +0000 Subject: [PATCH] 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 --- libretroshare/src/retroshare/rsnotify.h | 15 ++ libretroshare/src/services/p3gxschannels.cc | 73 +++++- libretroshare/src/services/p3gxsforums.cc | 47 ++++ retroshare-gui/src/gui/NewsFeed.cpp | 246 ++++++++---------- retroshare-gui/src/gui/NewsFeed.h | 101 ++++--- .../src/gui/settings/NotifyPage.cpp | 10 +- 6 files changed, 281 insertions(+), 211 deletions(-) diff --git a/libretroshare/src/retroshare/rsnotify.h b/libretroshare/src/retroshare/rsnotify.h index 6e8ad4fe4..b496c20d6 100644 --- a/libretroshare/src/retroshare/rsnotify.h +++ b/libretroshare/src/retroshare/rsnotify.h @@ -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; diff --git a/libretroshare/src/services/p3gxschannels.cc b/libretroshare/src/services/p3gxschannels.cc index 7ad7aac28..791da701d 100644 --- a/libretroshare/src/services/p3gxschannels.cc +++ b/libretroshare/src/services/p3gxschannels.cc @@ -33,6 +33,9 @@ #include "retroshare/rsgxsflags.h" #include "retroshare/rsfiles.h" +#include "rsserver/p3face.h" +#include "retroshare/rsnotify.h" + #include // For Dummy Msgs. @@ -128,6 +131,12 @@ void p3GxsChannels::notifyChanges(std::vector &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 unprocessedGroups; @@ -135,26 +144,64 @@ void p3GxsChannels::notifyChanges(std::vector &changes) for(it = changes.begin(); it != changes.end(); ++it) { RsGxsMsgChange *msgChange = dynamic_cast(*it); - if (msgChange && !msgChange->metaChange()) + if (msgChange) { - std::cerr << "p3GxsChannels::notifyChanges() Found Message Change Notification"; - std::cerr << std::endl; - - std::map > &msgChangeMap = msgChange->msgChangeMap; - std::map >::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 > &msgChangeMap = msgChange->msgChangeMap; + std::map >::iterator mit; + for (mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit) + { + std::vector::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 > &msgChangeMap = msgChange->msgChangeMap; + std::map >::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(*it); + if (grpChange) + { + /* group received */ + std::list &grpList = grpChange->mGrpIdList; + std::list::iterator git; + for (git = grpList.begin(); git != grpList.end(); ++git) + { + notify->AddFeedItem(RS_FEED_ITEM_CHANNEL_NEW, git->toStdString()); + } } } } diff --git a/libretroshare/src/services/p3gxsforums.cc b/libretroshare/src/services/p3gxsforums.cc index f995beace..4befc4f70 100644 --- a/libretroshare/src/services/p3gxsforums.cc +++ b/libretroshare/src/services/p3gxsforums.cc @@ -28,6 +28,8 @@ #include +#include "rsserver/p3face.h" +#include "retroshare/rsnotify.h" #include "retroshare/rsgxsflags.h" #include @@ -98,6 +100,51 @@ uint32_t p3GxsForums::forumsAuthenPolicy() void p3GxsForums::notifyChanges(std::vector &changes) { + if (!changes.empty()) + { + p3Notify *notify = RsServer::notify(); + + if (notify) + { + std::vector::iterator it; + for(it = changes.begin(); it != changes.end(); ++it) + { + RsGxsNotify *c = *it; + if (c->getType() == RsGxsNotify::TYPE_RECEIVE) + { + RsGxsMsgChange *msgChange = dynamic_cast(c); + if (msgChange) + { + std::map > &msgChangeMap = msgChange->msgChangeMap; + std::map >::iterator mit; + for (mit = msgChangeMap.begin(); mit != msgChangeMap.end(); ++mit) + { + std::vector::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(*it); + if (grpChange) + { + /* group received */ + std::list &grpList = grpChange->mGrpIdList; + std::list::iterator git; + for (git = grpList.begin(); git != grpList.end(); ++git) + { + notify->AddFeedItem(RS_FEED_ITEM_FORUM_NEW, git->toStdString()); + } + continue; + } + } + } + } + } + RsGxsIfaceHelper::receiveChanges(changes); } diff --git a/retroshare-gui/src/gui/NewsFeed.cpp b/retroshare-gui/src/gui/NewsFeed.cpp index cebe1f54b..aa9d01664 100644 --- a/retroshare-gui/src/gui/NewsFeed.cpp +++ b/retroshare-gui/src/gui/NewsFeed.cpp @@ -30,12 +30,10 @@ #include #include -#if 0 -#include "feeds/ChanNewItem.h" -#include "feeds/ChanMsgItem.h" -#include "feeds/ForumNewItem.h" -#include "feeds/ForumMsgItem.h" -#endif +//#include "feeds/ChanNewItem.h" +#include "feeds/GxsChannelPostItem.h" +//#include "feeds/ForumNewItem.h" +//#include "feeds/ForumMsgItem.h" #include "settings/rsettingswin.h" #ifdef BLOGS @@ -54,20 +52,20 @@ #include "msgs/MessageComposer.h" #include "common/FeedNotify.h" -const uint32_t NEWSFEED_PEERLIST = 0x0001; +const uint32_t NEWSFEED_PEERLIST = 0x0001; +const uint32_t NEWSFEED_FORUMNEWLIST = 0x0002; +const uint32_t NEWSFEED_FORUMMSGLIST = 0x0003; +const uint32_t NEWSFEED_CHANNELNEWLIST = 0x0004; +const uint32_t NEWSFEED_CHANNELMSGLIST = 0x0005; #if 0 -const uint32_t NEWSFEED_FORUMNEWLIST = 0x0002; -const uint32_t NEWSFEED_FORUMMSGLIST = 0x0003; -const uint32_t NEWSFEED_CHANNEWLIST = 0x0004; -const uint32_t NEWSFEED_CHANMSGLIST = 0x0005; -const uint32_t NEWSFEED_BLOGNEWLIST = 0x0006; -const uint32_t NEWSFEED_BLOGMSGLIST = 0x0007; +const uint32_t NEWSFEED_BLOGNEWLIST = 0x0006; +const uint32_t NEWSFEED_BLOGMSGLIST = 0x0007; #endif -const uint32_t NEWSFEED_MESSAGELIST = 0x0008; -const uint32_t NEWSFEED_CHATMSGLIST = 0x0009; -const uint32_t NEWSFEED_SECLIST = 0x000a; +const uint32_t NEWSFEED_MESSAGELIST = 0x0008; +const uint32_t NEWSFEED_CHATMSGLIST = 0x0009; +const uint32_t NEWSFEED_SECLIST = 0x000a; /***** * #define NEWS_DEBUG 1 @@ -174,33 +172,33 @@ void NewsFeed::updateDisplay() addFeedItemSecurityUnknownOut(fi); break; -#if 0 - case RS_FEED_ITEM_CHAN_NEW: - if (flags & RS_FEED_TYPE_CHAN) - addFeedItemChanNew(fi); + case RS_FEED_ITEM_CHANNEL_NEW: + if (flags & RS_FEED_TYPE_CHANNEL) + addFeedItemChannelNew(fi); break; - case RS_FEED_ITEM_CHAN_UPDATE: - if (flags & RS_FEED_TYPE_CHAN) - addFeedItemChanUpdate(fi); - break; - case RS_FEED_ITEM_CHAN_MSG: - if (flags & RS_FEED_TYPE_CHAN) - addFeedItemChanMsg(fi); +// case RS_FEED_ITEM_CHANNEL_UPDATE: +// if (flags & RS_FEED_TYPE_CHANNEL) +// addFeedItemChannelUpdate(fi); +// break; + case RS_FEED_ITEM_CHANNEL_MSG: + if (flags & RS_FEED_TYPE_CHANNEL) + addFeedItemChannelMsg(fi); break; case RS_FEED_ITEM_FORUM_NEW: if (flags & RS_FEED_TYPE_FORUM) addFeedItemForumNew(fi); break; - case RS_FEED_ITEM_FORUM_UPDATE: - if (flags & RS_FEED_TYPE_FORUM) - addFeedItemForumUpdate(fi); - break; +// case RS_FEED_ITEM_FORUM_UPDATE: +// if (flags & RS_FEED_TYPE_FORUM) +// addFeedItemForumUpdate(fi); +// break; case RS_FEED_ITEM_FORUM_MSG: if (flags & RS_FEED_TYPE_FORUM) addFeedItemForumMsg(fi); break; +#if 0 case RS_FEED_ITEM_BLOG_NEW: if (flags & RS_FEED_TYPE_BLOG) addFeedItemBlogNew(fi); @@ -284,7 +282,7 @@ void NewsFeed::testFeeds(uint notifyFlags) break; #if 0 - case RS_FEED_TYPE_CHAN: + case RS_FEED_TYPE_CHANNEL: { std::list channelList; rsChannels->getChannelList(channelList); @@ -516,12 +514,10 @@ void NewsFeed::addFeedItemIfUnique(QWidget *item, int itemType, const RsPeerId & addFeedItem(item); } -void NewsFeed::addFeedItemPeerConnect(RsFeedItem &fi) +void NewsFeed::addFeedItemPeerConnect(RsFeedItem &fi) { /* make new widget */ - PeerItem *pi = new PeerItem(this, NEWSFEED_PEERLIST, RsPeerId(fi.mId1), PEER_TYPE_CONNECT, false); - - /* store */ + PeerItem *pi = new PeerItem(this, NEWSFEED_PEERLIST, RsPeerId(fi.mId1), PEER_TYPE_CONNECT, false); /* add to layout */ addFeedItem(pi); @@ -533,12 +529,10 @@ void NewsFeed::addFeedItemPeerConnect(RsFeedItem &fi) } -void NewsFeed::addFeedItemPeerDisconnect(RsFeedItem &fi) +void NewsFeed::addFeedItemPeerDisconnect(RsFeedItem &fi) { /* make new widget */ - PeerItem *pi = new PeerItem(this, NEWSFEED_PEERLIST, RsPeerId(fi.mId1), PEER_TYPE_STD, false); - - /* store */ + PeerItem *pi = new PeerItem(this, NEWSFEED_PEERLIST, RsPeerId(fi.mId1), PEER_TYPE_STD, false); /* add to layout */ addFeedItem(pi); @@ -549,12 +543,10 @@ void NewsFeed::addFeedItemPeerDisconnect(RsFeedItem &fi) #endif } -void NewsFeed::addFeedItemPeerHello(RsFeedItem &fi) +void NewsFeed::addFeedItemPeerHello(RsFeedItem &fi) { /* make new widget */ - PeerItem *pi = new PeerItem(this, NEWSFEED_PEERLIST, RsPeerId(fi.mId1), PEER_TYPE_HELLO, false); - - /* store */ + PeerItem *pi = new PeerItem(this, NEWSFEED_PEERLIST, RsPeerId(fi.mId1), PEER_TYPE_HELLO, false); /* add to layout */ addFeedItem(pi); @@ -565,12 +557,10 @@ void NewsFeed::addFeedItemPeerHello(RsFeedItem &fi) #endif } -void NewsFeed::addFeedItemPeerNew(RsFeedItem &fi) +void NewsFeed::addFeedItemPeerNew(RsFeedItem &fi) { /* make new widget */ - PeerItem *pi = new PeerItem(this, NEWSFEED_PEERLIST, RsPeerId(fi.mId1), PEER_TYPE_NEW_FOF, false); - - /* store */ + PeerItem *pi = new PeerItem(this, NEWSFEED_PEERLIST, RsPeerId(fi.mId1), PEER_TYPE_NEW_FOF, false); /* add to layout */ addFeedItem(pi); @@ -581,15 +571,13 @@ void NewsFeed::addFeedItemPeerNew(RsFeedItem &fi) #endif } -void NewsFeed::addFeedItemSecurityConnectAttempt(RsFeedItem &fi) +void NewsFeed::addFeedItemSecurityConnectAttempt(RsFeedItem &fi) { /* make new widget */ - SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, RsPgpId(fi.mId1), RsPeerId(fi.mId2), fi.mId3, fi.mId4, fi.mType, false); - - /* store */ + SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, RsPgpId(fi.mId1), RsPeerId(fi.mId2), fi.mId3, fi.mId4, fi.mType, false); /* add to layout */ - addFeedItemIfUnique(pi, fi.mType, RsPeerId(fi.mId2), false); + addFeedItemIfUnique(pi, fi.mType, RsPeerId(fi.mId2), false); #ifdef NEWS_DEBUG std::cerr << "NewsFeed::addFeedItemSecurityConnectAttempt()"; @@ -597,15 +585,13 @@ void NewsFeed::addFeedItemSecurityConnectAttempt(RsFeedItem &fi) #endif } -void NewsFeed::addFeedItemSecurityAuthDenied(RsFeedItem &fi) +void NewsFeed::addFeedItemSecurityAuthDenied(RsFeedItem &fi) { /* make new widget */ - SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, RsPgpId(fi.mId1), RsPeerId(fi.mId2), fi.mId3, fi.mId4, fi.mType, false); - - /* store */ + SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, RsPgpId(fi.mId1), RsPeerId(fi.mId2), fi.mId3, fi.mId4, fi.mType, false); /* add to layout */ - addFeedItemIfUnique(pi, RS_FEED_ITEM_SEC_AUTH_DENIED, RsPeerId(fi.mId2), false); + addFeedItemIfUnique(pi, RS_FEED_ITEM_SEC_AUTH_DENIED, RsPeerId(fi.mId2), false); #ifdef NEWS_DEBUG std::cerr << "NewsFeed::addFeedItemSecurityAuthDenied()"; @@ -613,15 +599,13 @@ void NewsFeed::addFeedItemSecurityAuthDenied(RsFeedItem &fi) #endif } -void NewsFeed::addFeedItemSecurityUnknownIn(RsFeedItem &fi) +void NewsFeed::addFeedItemSecurityUnknownIn(RsFeedItem &fi) { /* make new widget */ - SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, RsPgpId(fi.mId1), RsPeerId(fi.mId2), fi.mId3, fi.mId4, RS_FEED_ITEM_SEC_UNKNOWN_IN, false); - - /* store */ + SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, RsPgpId(fi.mId1), RsPeerId(fi.mId2), fi.mId3, fi.mId4, RS_FEED_ITEM_SEC_UNKNOWN_IN, false); /* add to layout */ - addFeedItemIfUnique(pi, RS_FEED_ITEM_SEC_UNKNOWN_IN, RsPeerId(fi.mId2), false); + addFeedItemIfUnique(pi, RS_FEED_ITEM_SEC_UNKNOWN_IN, RsPeerId(fi.mId2), false); #ifdef NEWS_DEBUG std::cerr << "NewsFeed::addFeedItemSecurityUnknownIn()"; @@ -629,15 +613,13 @@ void NewsFeed::addFeedItemSecurityUnknownIn(RsFeedItem &fi) #endif } -void NewsFeed::addFeedItemSecurityUnknownOut(RsFeedItem &fi) +void NewsFeed::addFeedItemSecurityUnknownOut(RsFeedItem &fi) { /* make new widget */ - SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, RsPgpId(fi.mId1), RsPeerId(fi.mId2), fi.mId3, fi.mId4, RS_FEED_ITEM_SEC_UNKNOWN_OUT, false); - - /* store */ + SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, RsPgpId(fi.mId1), RsPeerId(fi.mId2), fi.mId3, fi.mId4, RS_FEED_ITEM_SEC_UNKNOWN_OUT, false); /* add to layout */ - addFeedItemIfUnique(pi, RS_FEED_ITEM_SEC_UNKNOWN_OUT, RsPeerId(fi.mId2), false); + addFeedItemIfUnique(pi, RS_FEED_ITEM_SEC_UNKNOWN_OUT, RsPeerId(fi.mId2), false); #ifdef NEWS_DEBUG std::cerr << "NewsFeed::addFeedItemSecurityUnknownOut()"; @@ -645,17 +627,13 @@ void NewsFeed::addFeedItemSecurityUnknownOut(RsFeedItem &fi) #endif } -#if 0 -void NewsFeed::addFeedItemChanNew(RsFeedItem &fi) +void NewsFeed::addFeedItemChannelNew(RsFeedItem &fi) { - /* make new widget */ - ChanNewItem *cni = new ChanNewItem(this, NEWSFEED_CHANNEWLIST, fi.mId1, false, true); - - /* store in list */ +// ChanNewItem *cni = new ChanNewItem(this, NEWSFEED_CHANNEWLIST, fi.mId1, false, true); /* add to layout */ - addFeedItem(cni); +// addFeedItem(cni); #ifdef NEWS_DEBUG std::cerr << "NewsFeed::addFeedItemChanNew()"; @@ -663,31 +641,34 @@ void NewsFeed::addFeedItemChanNew(RsFeedItem &fi) #endif } -void NewsFeed::addFeedItemChanUpdate(RsFeedItem &fi) -{ - /* make new widget */ - ChanNewItem *cni = new ChanNewItem(this, NEWSFEED_CHANNEWLIST, fi.mId1, false, false); +//void NewsFeed::addFeedItemChannelUpdate(RsFeedItem &fi) +//{ +// /* make new widget */ +// ChanNewItem *cni = new ChanNewItem(this, NEWSFEED_CHANNEWLIST, fi.mId1, false, false); - /* store in list */ +// /* add to layout */ +// addFeedItem(cni); + +//#ifdef NEWS_DEBUG +// std::cerr << "NewsFeed::addFeedItemChanUpdate()"; +// std::cerr << std::endl; +//#endif +//} + +void NewsFeed::addFeedItemChannelMsg(RsFeedItem &fi) +{ + RsGxsGroupId grpId(fi.mId1); + RsGxsMessageId msgId(fi.mId2); + + if (grpId.isNull() || msgId.isNull()) { + return; + } + + /* make new widget */ + GxsChannelPostItem *item = new GxsChannelPostItem(this, NEWSFEED_CHANNELNEWLIST, grpId, msgId, false, true); /* add to layout */ - addFeedItem(cni); - -#ifdef NEWS_DEBUG - std::cerr << "NewsFeed::addFeedItemChanUpdate()"; - std::cerr << std::endl; -#endif -} - -void NewsFeed::addFeedItemChanMsg(RsFeedItem &fi) -{ - /* make new widget */ - ChanMsgItem *cm = new ChanMsgItem(this, NEWSFEED_CHANMSGLIST, fi.mId1, fi.mId2, false); - - /* store in forum list */ - - /* add to layout */ - addFeedItem(cm); + addFeedItem(item); #ifdef NEWS_DEBUG std::cerr << "NewsFeed::addFeedItemChanMsg()"; @@ -695,16 +676,13 @@ void NewsFeed::addFeedItemChanMsg(RsFeedItem &fi) #endif } -void NewsFeed::addFeedItemForumNew(RsFeedItem &fi) +void NewsFeed::addFeedItemForumNew(RsFeedItem &fi) { /* make new widget */ - ForumNewItem *fni = new ForumNewItem(this, NEWSFEED_FORUMNEWLIST, fi.mId1, false, true); - - /* store in forum list */ - mForumNewItems.push_back(fni); +// ForumNewItem *fni = new ForumNewItem(this, NEWSFEED_FORUMNEWLIST, fi.mId1, false, true); /* add to layout */ - addFeedItem(fni); +// addFeedItem(fni); #ifdef NEWS_DEBUG std::cerr << "NewsFeed::addFeedItemForumNew()"; @@ -712,32 +690,27 @@ void NewsFeed::addFeedItemForumNew(RsFeedItem &fi) #endif } -void NewsFeed::addFeedItemForumUpdate(RsFeedItem &fi) +//void NewsFeed::addFeedItemForumUpdate(RsFeedItem &fi) +//{ +// /* make new widget */ +// ForumNewItem *fni = new ForumNewItem(this, NEWSFEED_FORUMNEWLIST, fi.mId1, false, false); + +// /* add to layout */ +// addFeedItem(fni); + +//#ifdef NEWS_DEBUG +// std::cerr << "NewsFeed::addFeedItemForumUpdate()"; +// std::cerr << std::endl; +//#endif +//} + +void NewsFeed::addFeedItemForumMsg(RsFeedItem &fi) { /* make new widget */ - ForumNewItem *fni = new ForumNewItem(this, NEWSFEED_FORUMNEWLIST, fi.mId1, false, false); - - /* store in forum list */ - mForumNewItems.push_back(fni); +// ForumMsgItem *fm = new ForumMsgItem(this, NEWSFEED_FORUMMSGLIST, fi.mId1, fi.mId2, false); /* add to layout */ - addFeedItem(fni); - -#ifdef NEWS_DEBUG - std::cerr << "NewsFeed::addFeedItemForumUpdate()"; - std::cerr << std::endl; -#endif -} - -void NewsFeed::addFeedItemForumMsg(RsFeedItem &fi) -{ - /* make new widget */ - ForumMsgItem *fm = new ForumMsgItem(this, NEWSFEED_FORUMMSGLIST, fi.mId1, fi.mId2, false); - - /* store in forum list */ - - /* add to layout */ - addFeedItem(fm); +// addFeedItem(fm); #ifdef NEWS_DEBUG std::cerr << "NewsFeed::addFeedItemForumMsg()"; @@ -745,14 +718,13 @@ void NewsFeed::addFeedItemForumMsg(RsFeedItem &fi) #endif } -void NewsFeed::addFeedItemBlogNew(RsFeedItem &fi) +#if 0 +void NewsFeed::addFeedItemBlogNew(RsFeedItem &fi) { #ifdef BLOGS /* make new widget */ BlogNewItem *bni = new BlogNewItem(this, NEWSFEED_BLOGNEWLIST, fi.mId1, false, true); - /* store in list */ - /* add to layout */ addFeedItem(bni); #else @@ -765,14 +737,12 @@ void NewsFeed::addFeedItemBlogNew(RsFeedItem &fi) #endif } -void NewsFeed::addFeedItemBlogMsg(RsFeedItem &fi) +void NewsFeed::addFeedItemBlogMsg(RsFeedItem &fi) { #ifdef BLOGS /* make new widget */ BlogMsgItem *bm = new BlogMsgItem(this, NEWSFEED_BLOGMSGLIST, fi.mId1, fi.mId2, false); - /* store in forum list */ - /* add to layout */ addFeedItem(bm); #else @@ -787,7 +757,7 @@ void NewsFeed::addFeedItemBlogMsg(RsFeedItem &fi) #endif -void NewsFeed::addFeedItemChatNew(RsFeedItem &fi, bool addWithoutCheck) +void NewsFeed::addFeedItemChatNew(RsFeedItem &fi, bool addWithoutCheck) { #ifdef NEWS_DEBUG std::cerr << "NewsFeed::addFeedItemChatNew()"; @@ -800,21 +770,17 @@ void NewsFeed::addFeedItemChatNew(RsFeedItem &fi, bool addWithoutCheck) } /* make new widget */ - ChatMsgItem *cm = new ChatMsgItem(this, NEWSFEED_CHATMSGLIST, RsPeerId(fi.mId1), fi.mId2); - - /* store in forum list */ + ChatMsgItem *cm = new ChatMsgItem(this, NEWSFEED_CHATMSGLIST, RsPeerId(fi.mId1), fi.mId2); /* add to layout */ addFeedItem(cm); } -void NewsFeed::addFeedItemMessage(RsFeedItem &fi) +void NewsFeed::addFeedItemMessage(RsFeedItem &fi) { /* make new widget */ MsgItem *mi = new MsgItem(this, NEWSFEED_MESSAGELIST, fi.mId1, false); - /* store in list */ - /* add to layout */ addFeedItem(mi); @@ -824,7 +790,7 @@ void NewsFeed::addFeedItemMessage(RsFeedItem &fi) #endif } -void NewsFeed::addFeedItemFilesNew(RsFeedItem &/*fi*/) +void NewsFeed::addFeedItemFilesNew(RsFeedItem &/*fi*/) { #ifdef NEWS_DEBUG std::cerr << "NewsFeed::addFeedItemFilesNew()"; @@ -857,7 +823,7 @@ void NewsFeed::openChat(const RsPeerId &peerId) std::cerr << std::endl; #endif - ChatDialog::chatFriend(peerId); + ChatDialog::chatFriend(peerId); } void NewsFeed::openComments(uint32_t /*type*/, const RsGxsGroupId &/*groupId*/, const RsGxsMessageId &/*msgId*/, const QString &/*title*/) diff --git a/retroshare-gui/src/gui/NewsFeed.h b/retroshare-gui/src/gui/NewsFeed.h index 3146bb94e..6987ea647 100644 --- a/retroshare-gui/src/gui/NewsFeed.h +++ b/retroshare-gui/src/gui/NewsFeed.h @@ -32,84 +32,77 @@ class RsFeedItem; -class ForumNewItem; -class ChanMsgItem; -class ChatMsgItem; class FeedNotify; class NewsFeed : public RsAutoUpdatePage, public FeedHolder, private Ui::NewsFeed { - Q_OBJECT + Q_OBJECT public: - /** Default Constructor */ - NewsFeed(QWidget *parent = 0); - /** Default Destructor */ - virtual ~NewsFeed(); + /** Default Constructor */ + NewsFeed(QWidget *parent = 0); + /** Default Destructor */ + virtual ~NewsFeed(); - virtual QIcon iconPixmap() const { return QIcon(IMAGE_NEWSFEED) ; } //MainPage - virtual QString pageName() const { return tr("News feed") ; } //MainPage - virtual QString helpText() const { return ""; } //MainPage + virtual QIcon iconPixmap() const { return QIcon(IMAGE_NEWSFEED) ; } //MainPage + virtual QString pageName() const { return tr("News feed") ; } //MainPage + virtual QString helpText() const { return ""; } //MainPage - virtual UserNotify *getUserNotify(QObject *parent); + virtual UserNotify *getUserNotify(QObject *parent); - /* FeedHolder Functions (for FeedItem functionality) */ - virtual QScrollArea *getScrollArea(); - virtual void deleteFeedItem(QWidget *item, uint32_t type); - virtual void openChat(const RsPeerId& peerId); - virtual void openComments(uint32_t type, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &title); + /* FeedHolder Functions (for FeedItem functionality) */ + virtual QScrollArea *getScrollArea(); + virtual void deleteFeedItem(QWidget *item, uint32_t type); + virtual void openChat(const RsPeerId& peerId); + virtual void openComments(uint32_t type, const RsGxsGroupId &groupId, const RsGxsMessageId &msgId, const QString &title); - static void testFeeds(uint notifyFlags); - static void testFeed(FeedNotify *feedNotify); + static void testFeeds(uint notifyFlags); + static void testFeed(FeedNotify *feedNotify); + + virtual void updateDisplay(); - virtual void updateDisplay(); signals: - void newsFeedChanged(int count); + void newsFeedChanged(int count); private slots: - // void toggleChanMsgItems(bool on); - void feedoptions(); - - void removeAll(); - void itemDestroyed(QObject*); +// void toggleChanMsgItems(bool on); + void feedoptions(); + + void removeAll(); + void itemDestroyed(QObject*); private: - void addFeedItem(QWidget *item); - void addFeedItemIfUnique(QWidget *item, int itemType, const RsPeerId &sslId, bool replace); + void addFeedItem(QWidget *item); + void addFeedItemIfUnique(QWidget *item, int itemType, const RsPeerId &sslId, bool replace); - void addFeedItemPeerConnect(RsFeedItem &fi); - void addFeedItemPeerDisconnect(RsFeedItem &fi); - void addFeedItemPeerNew(RsFeedItem &fi); - void addFeedItemPeerHello(RsFeedItem &fi); + void addFeedItemPeerConnect(RsFeedItem &fi); + void addFeedItemPeerDisconnect(RsFeedItem &fi); + void addFeedItemPeerNew(RsFeedItem &fi); + void addFeedItemPeerHello(RsFeedItem &fi); - void addFeedItemSecurityConnectAttempt(RsFeedItem &fi); - void addFeedItemSecurityAuthDenied(RsFeedItem &fi); - void addFeedItemSecurityUnknownIn(RsFeedItem &fi); - void addFeedItemSecurityUnknownOut(RsFeedItem &fi); + void addFeedItemSecurityConnectAttempt(RsFeedItem &fi); + void addFeedItemSecurityAuthDenied(RsFeedItem &fi); + void addFeedItemSecurityUnknownIn(RsFeedItem &fi); + void addFeedItemSecurityUnknownOut(RsFeedItem &fi); + void addFeedItemChannelNew(RsFeedItem &fi); +// void addFeedItemChannelUpdate(RsFeedItem &fi); + void addFeedItemChannelMsg(RsFeedItem &fi); + void addFeedItemForumNew(RsFeedItem &fi); +// void addFeedItemForumUpdate(RsFeedItem &fi); + void addFeedItemForumMsg(RsFeedItem &fi); #if 0 - void addFeedItemChanNew(RsFeedItem &fi); - void addFeedItemChanUpdate(RsFeedItem &fi); - void addFeedItemChanMsg(RsFeedItem &fi); - void addFeedItemForumNew(RsFeedItem &fi); - void addFeedItemForumUpdate(RsFeedItem &fi); - void addFeedItemForumMsg(RsFeedItem &fi); - void addFeedItemBlogNew(RsFeedItem &fi); - void addFeedItemBlogMsg(RsFeedItem &fi); + void addFeedItemBlogNew(RsFeedItem &fi); + void addFeedItemBlogMsg(RsFeedItem &fi); #endif - void addFeedItemChatNew(RsFeedItem &fi, bool addWithoutCheck); - void addFeedItemMessage(RsFeedItem &fi); - void addFeedItemFilesNew(RsFeedItem &fi); + void addFeedItemChatNew(RsFeedItem &fi, bool addWithoutCheck); + void addFeedItemMessage(RsFeedItem &fi); + void addFeedItemFilesNew(RsFeedItem &fi); - void sendNewsFeedChanged(); + void sendNewsFeedChanged(); - std::list widgets; - - /* lists of feedItems */ - std::list mForumNewItems; - - std::list mChanMsgItems; + std::list widgets; }; #endif diff --git a/retroshare-gui/src/gui/settings/NotifyPage.cpp b/retroshare-gui/src/gui/settings/NotifyPage.cpp index b6f34d521..9f4429c2a 100755 --- a/retroshare-gui/src/gui/settings/NotifyPage.cpp +++ b/retroshare-gui/src/gui/settings/NotifyPage.cpp @@ -44,6 +44,8 @@ NotifyPage::NotifyPage(QWidget * parent, Qt::WindowFlags flags) connect(ui.pushButtonDisableAll,SIGNAL(toggled(bool)), NotifyQt::getInstance(), SLOT(SetDisableAll(bool))); connect(NotifyQt::getInstance(),SIGNAL(disableAllChanged(bool)), ui.pushButtonDisableAll, SLOT(setChecked(bool))); + ui.notify_Blogs->hide(); + QFont font = ui.notify_Peers->font(); // use font from existing checkbox /* add feed notify */ @@ -112,11 +114,11 @@ uint NotifyPage::getNewsFlags() if (ui.notify_Peers->isChecked()) newsFlags |= RS_FEED_TYPE_PEER; -#if 0 if (ui.notify_Channels->isChecked()) - newsFlags |= RS_FEED_TYPE_CHAN; + newsFlags |= RS_FEED_TYPE_CHANNEL; if (ui.notify_Forums->isChecked()) newsFlags |= RS_FEED_TYPE_FORUM; +#if 0 if (ui.notify_Blogs->isChecked()) newsFlags |= RS_FEED_TYPE_BLOG; #endif @@ -224,9 +226,9 @@ void NotifyPage::load() ui.popup_ConnectAttempt->setChecked(notifyflags & RS_POPUP_CONNECT_ATTEMPT); ui.notify_Peers->setChecked(newsflags & RS_FEED_TYPE_PEER); -#if 0 - ui.notify_Channels->setChecked(newsflags & RS_FEED_TYPE_CHAN); + ui.notify_Channels->setChecked(newsflags & RS_FEED_TYPE_CHANNEL); ui.notify_Forums->setChecked(newsflags & RS_FEED_TYPE_FORUM); +#if 0 ui.notify_Blogs->setChecked(newsflags & RS_FEED_TYPE_BLOG); #endif ui.notify_Chat->setChecked(newsflags & RS_FEED_TYPE_CHAT);