2008-06-20 08:43:23 -04:00
|
|
|
/****************************************************************
|
|
|
|
* RetroShare is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Robert Fernie
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2013-01-08 17:07:52 -05:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
2008-06-20 08:43:23 -04:00
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
|
|
|
|
2010-07-23 14:52:58 -04:00
|
|
|
#include <QTimer>
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2010-07-23 14:52:58 -04:00
|
|
|
#include "NewsFeed.h"
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2010-08-06 05:40:23 -04:00
|
|
|
#include <retroshare/rsnotify.h>
|
2010-08-31 18:42:40 -04:00
|
|
|
#include <retroshare/rspeers.h>
|
2012-09-04 16:04:49 -04:00
|
|
|
#include <retroshare/rschannels.h>
|
|
|
|
#include <retroshare/rsforums.h>
|
|
|
|
#include <retroshare/rsmsgs.h>
|
2013-01-08 17:07:52 -05:00
|
|
|
#include <retroshare/rsplugin.h>
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2008-07-04 10:41:24 -04:00
|
|
|
#include "feeds/ChanNewItem.h"
|
2008-06-20 08:43:23 -04:00
|
|
|
#include "feeds/ChanMsgItem.h"
|
|
|
|
#include "feeds/ForumNewItem.h"
|
|
|
|
#include "feeds/ForumMsgItem.h"
|
2011-03-26 18:17:15 -04:00
|
|
|
#include "settings/rsettingswin.h"
|
2010-07-31 14:19:12 -04:00
|
|
|
|
|
|
|
#ifdef BLOGS
|
2010-05-20 17:00:59 -04:00
|
|
|
#include "feeds/BlogNewItem.h"
|
2008-06-20 08:43:23 -04:00
|
|
|
#include "feeds/BlogMsgItem.h"
|
2010-07-31 14:19:12 -04:00
|
|
|
#endif
|
|
|
|
|
2008-07-04 10:41:24 -04:00
|
|
|
#include "feeds/MsgItem.h"
|
2010-05-20 17:00:59 -04:00
|
|
|
#include "feeds/PeerItem.h"
|
2010-08-31 13:13:52 -04:00
|
|
|
#include "feeds/ChatMsgItem.h"
|
2011-07-11 11:53:41 -04:00
|
|
|
#include "feeds/SecurityItem.h"
|
2013-06-21 20:05:02 -04:00
|
|
|
#include "feeds/NewsFeedUserNotify.h"
|
2011-07-11 11:53:41 -04:00
|
|
|
|
2009-12-14 12:13:10 -05:00
|
|
|
#include "settings/rsharesettings.h"
|
2012-01-17 15:36:36 -05:00
|
|
|
#include "chat/ChatDialog.h"
|
2012-04-26 19:41:14 -04:00
|
|
|
#include "msgs/MessageComposer.h"
|
2013-01-08 17:07:52 -05:00
|
|
|
#include "common/FeedNotify.h"
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
const uint32_t NEWSFEED_PEERLIST = 0x0001;
|
|
|
|
const uint32_t NEWSFEED_FORUMNEWLIST = 0x0002;
|
|
|
|
const uint32_t NEWSFEED_FORUMMSGLIST = 0x0003;
|
|
|
|
const uint32_t NEWSFEED_CHANNEWLIST = 0x0004;
|
|
|
|
const uint32_t NEWSFEED_CHANMSGLIST = 0x0005;
|
2010-05-20 17:00:59 -04:00
|
|
|
const uint32_t NEWSFEED_BLOGNEWLIST = 0x0006;
|
|
|
|
const uint32_t NEWSFEED_BLOGMSGLIST = 0x0007;
|
|
|
|
const uint32_t NEWSFEED_MESSAGELIST = 0x0008;
|
2010-08-31 13:13:52 -04:00
|
|
|
const uint32_t NEWSFEED_CHATMSGLIST = 0x0009;
|
2011-07-11 11:53:41 -04:00
|
|
|
const uint32_t NEWSFEED_SECLIST = 0x000a;
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
/*****
|
|
|
|
* #define NEWS_DEBUG 1
|
|
|
|
****/
|
|
|
|
|
2012-09-04 16:04:49 -04:00
|
|
|
static NewsFeed *instance = NULL;
|
|
|
|
|
2008-06-20 08:43:23 -04:00
|
|
|
/** Constructor */
|
|
|
|
NewsFeed::NewsFeed(QWidget *parent)
|
2013-04-21 18:20:11 -04:00
|
|
|
: RsAutoUpdatePage(1000,parent)
|
2008-06-20 08:43:23 -04:00
|
|
|
{
|
2013-01-08 17:07:52 -05:00
|
|
|
/* Invoke the Qt Designer generated object setup routine */
|
|
|
|
setupUi(this);
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2013-06-21 20:05:02 -04:00
|
|
|
setUpdateWhenInvisible(true);
|
|
|
|
|
2012-09-04 16:04:49 -04:00
|
|
|
if (!instance) {
|
|
|
|
instance = this;
|
|
|
|
}
|
|
|
|
|
2010-11-06 15:13:33 -04:00
|
|
|
connect(removeAllButton, SIGNAL(clicked()), this, SLOT(removeAll()));
|
2011-03-24 15:43:52 -04:00
|
|
|
connect(feedOptionsButton, SIGNAL(clicked()), this, SLOT(feedoptions()));
|
2013-07-18 15:32:12 -04:00
|
|
|
connect(helpButton, SIGNAL(toggled(bool)), (MainPage*)this, SLOT(showHelp(bool)));
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
|
2012-09-04 16:04:49 -04:00
|
|
|
NewsFeed::~NewsFeed()
|
|
|
|
{
|
|
|
|
if (instance == this) {
|
|
|
|
instance = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-18 15:32:12 -04:00
|
|
|
const QString& NewsFeed::helpHtmlText() const
|
|
|
|
{
|
|
|
|
static const QString str = tr(
|
|
|
|
" <h1><img width=\"32\" src=\":/images/64px_help.png\"> News Feed</h1> \
|
|
|
|
<p>The News Feed displays the last events on your network, sorted by the time you received them. \
|
|
|
|
This gives you a summary of the activity of your friends. \
|
|
|
|
You can configure which events to show by pressing on <b>Options</b>. </p> \
|
|
|
|
<p>The various events shown are: \
|
|
|
|
<ul> \
|
|
|
|
<li>Connection attempts (useful to make friends with new people and control who's trying to reach you)</li> \
|
|
|
|
<li>Channel and Forum posts</li> \
|
|
|
|
<li>New Channels and Forums you can subscribe to</li> \
|
|
|
|
<li>Private messages from your friends</li> \
|
|
|
|
</ul> </p> \
|
|
|
|
") ;
|
|
|
|
|
|
|
|
return str ;
|
|
|
|
}
|
|
|
|
|
2013-06-21 20:05:02 -04:00
|
|
|
UserNotify *NewsFeed::getUserNotify(QObject *parent)
|
|
|
|
{
|
|
|
|
return new NewsFeedUserNotify(this, parent);
|
|
|
|
}
|
|
|
|
|
2013-04-21 18:20:11 -04:00
|
|
|
void NewsFeed::updateDisplay()
|
2008-06-20 08:43:23 -04:00
|
|
|
{
|
|
|
|
if (!rsNotify)
|
|
|
|
return;
|
|
|
|
|
2010-05-20 17:53:27 -04:00
|
|
|
uint flags = Settings->getNewsFeedFlags();
|
2008-12-07 09:19:13 -05:00
|
|
|
|
2008-06-20 08:43:23 -04:00
|
|
|
/* check for new messages */
|
|
|
|
RsFeedItem fi;
|
|
|
|
if (rsNotify->GetFeedItem(fi))
|
|
|
|
{
|
|
|
|
switch(fi.mType)
|
|
|
|
{
|
|
|
|
case RS_FEED_ITEM_PEER_CONNECT:
|
2008-12-07 09:19:13 -05:00
|
|
|
if (flags & RS_FEED_TYPE_PEER)
|
|
|
|
addFeedItemPeerConnect(fi);
|
2008-06-20 08:43:23 -04:00
|
|
|
break;
|
|
|
|
case RS_FEED_ITEM_PEER_DISCONNECT:
|
2008-12-07 09:19:13 -05:00
|
|
|
if (flags & RS_FEED_TYPE_PEER)
|
|
|
|
addFeedItemPeerDisconnect(fi);
|
2008-06-20 08:43:23 -04:00
|
|
|
break;
|
|
|
|
case RS_FEED_ITEM_PEER_NEW:
|
2008-12-07 09:19:13 -05:00
|
|
|
if (flags & RS_FEED_TYPE_PEER)
|
|
|
|
addFeedItemPeerNew(fi);
|
2008-06-20 08:43:23 -04:00
|
|
|
break;
|
|
|
|
case RS_FEED_ITEM_PEER_HELLO:
|
2008-12-07 09:19:13 -05:00
|
|
|
if (flags & RS_FEED_TYPE_PEER)
|
|
|
|
addFeedItemPeerHello(fi);
|
2008-06-20 08:43:23 -04:00
|
|
|
break;
|
2011-07-11 11:53:41 -04:00
|
|
|
|
|
|
|
case RS_FEED_ITEM_SEC_CONNECT_ATTEMPT:
|
2012-04-26 19:41:14 -04:00
|
|
|
if (Settings->getMessageFlags() & RS_MESSAGE_CONNECT_ATTEMPT) {
|
2012-05-01 05:18:55 -04:00
|
|
|
MessageComposer::sendConnectAttemptMsg(fi.mId1, fi.mId2, QString::fromUtf8(fi.mId3.c_str()));
|
2012-04-26 19:41:14 -04:00
|
|
|
}
|
2011-07-11 11:53:41 -04:00
|
|
|
if (flags & RS_FEED_TYPE_SECURITY)
|
|
|
|
addFeedItemSecurityConnectAttempt(fi);
|
2011-07-10 21:08:01 -04:00
|
|
|
break;
|
2011-07-11 11:53:41 -04:00
|
|
|
case RS_FEED_ITEM_SEC_AUTH_DENIED:
|
|
|
|
if (flags & RS_FEED_TYPE_SECURITY)
|
|
|
|
addFeedItemSecurityAuthDenied(fi);
|
2011-07-10 21:08:01 -04:00
|
|
|
break;
|
2011-07-11 11:53:41 -04:00
|
|
|
case RS_FEED_ITEM_SEC_UNKNOWN_IN:
|
|
|
|
if (flags & RS_FEED_TYPE_SECURITY)
|
|
|
|
addFeedItemSecurityUnknownIn(fi);
|
|
|
|
break;
|
|
|
|
case RS_FEED_ITEM_SEC_UNKNOWN_OUT:
|
|
|
|
if (flags & RS_FEED_TYPE_SECURITY)
|
|
|
|
addFeedItemSecurityUnknownOut(fi);
|
2011-07-10 21:08:01 -04:00
|
|
|
break;
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
case RS_FEED_ITEM_CHAN_NEW:
|
2008-12-07 09:19:13 -05:00
|
|
|
if (flags & RS_FEED_TYPE_CHAN)
|
|
|
|
addFeedItemChanNew(fi);
|
2008-06-20 08:43:23 -04:00
|
|
|
break;
|
|
|
|
case RS_FEED_ITEM_CHAN_UPDATE:
|
2008-12-07 09:19:13 -05:00
|
|
|
if (flags & RS_FEED_TYPE_CHAN)
|
|
|
|
addFeedItemChanUpdate(fi);
|
2008-06-20 08:43:23 -04:00
|
|
|
break;
|
|
|
|
case RS_FEED_ITEM_CHAN_MSG:
|
2008-12-07 09:19:13 -05:00
|
|
|
if (flags & RS_FEED_TYPE_CHAN)
|
|
|
|
addFeedItemChanMsg(fi);
|
2008-06-20 08:43:23 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case RS_FEED_ITEM_FORUM_NEW:
|
2008-12-07 09:19:13 -05:00
|
|
|
if (flags & RS_FEED_TYPE_FORUM)
|
|
|
|
addFeedItemForumNew(fi);
|
2008-06-20 08:43:23 -04:00
|
|
|
break;
|
|
|
|
case RS_FEED_ITEM_FORUM_UPDATE:
|
2008-12-07 09:19:13 -05:00
|
|
|
if (flags & RS_FEED_TYPE_FORUM)
|
|
|
|
addFeedItemForumUpdate(fi);
|
2008-06-20 08:43:23 -04:00
|
|
|
break;
|
|
|
|
case RS_FEED_ITEM_FORUM_MSG:
|
2008-12-07 09:19:13 -05:00
|
|
|
if (flags & RS_FEED_TYPE_FORUM)
|
|
|
|
addFeedItemForumMsg(fi);
|
2008-06-20 08:43:23 -04:00
|
|
|
break;
|
|
|
|
|
2010-05-20 17:00:59 -04:00
|
|
|
case RS_FEED_ITEM_BLOG_NEW:
|
|
|
|
if (flags & RS_FEED_TYPE_BLOG)
|
|
|
|
addFeedItemBlogNew(fi);
|
|
|
|
break;
|
2008-06-20 08:43:23 -04:00
|
|
|
case RS_FEED_ITEM_BLOG_MSG:
|
2008-12-07 09:19:13 -05:00
|
|
|
if (flags & RS_FEED_TYPE_BLOG)
|
|
|
|
addFeedItemBlogMsg(fi);
|
2008-06-20 08:43:23 -04:00
|
|
|
break;
|
2012-09-04 16:04:49 -04:00
|
|
|
|
2008-06-20 08:43:23 -04:00
|
|
|
case RS_FEED_ITEM_CHAT_NEW:
|
2008-12-07 09:19:13 -05:00
|
|
|
if (flags & RS_FEED_TYPE_CHAT)
|
2012-09-04 16:04:49 -04:00
|
|
|
addFeedItemChatNew(fi, false);
|
2008-06-20 08:43:23 -04:00
|
|
|
break;
|
2012-09-04 16:04:49 -04:00
|
|
|
|
2008-06-20 08:43:23 -04:00
|
|
|
case RS_FEED_ITEM_MESSAGE:
|
2008-12-07 09:19:13 -05:00
|
|
|
if (flags & RS_FEED_TYPE_MSG)
|
|
|
|
addFeedItemMessage(fi);
|
2008-06-20 08:43:23 -04:00
|
|
|
break;
|
2012-09-04 16:04:49 -04:00
|
|
|
|
2008-06-20 08:43:23 -04:00
|
|
|
case RS_FEED_ITEM_FILES_NEW:
|
2008-12-07 09:19:13 -05:00
|
|
|
if (flags & RS_FEED_TYPE_FILES)
|
|
|
|
addFeedItemFilesNew(fi);
|
2008-06-20 08:43:23 -04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2013-01-08 17:07:52 -05:00
|
|
|
} else {
|
|
|
|
/* process plugin feeds */
|
|
|
|
int pluginCount = rsPlugins->nbPlugins();
|
|
|
|
for (int i = 0; i < pluginCount; ++i) {
|
|
|
|
RsPlugin *rsPlugin = rsPlugins->plugin(i);
|
|
|
|
if (rsPlugin) {
|
|
|
|
FeedNotify *feedNotify = rsPlugin->qt_feedNotify();
|
|
|
|
if (feedNotify && feedNotify->notifyEnabled()) {
|
|
|
|
QWidget *item = feedNotify->feedItem(this);
|
|
|
|
if (item) {
|
|
|
|
addFeedItem(item);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-04 16:04:49 -04:00
|
|
|
void NewsFeed::testFeeds(uint notifyFlags)
|
|
|
|
{
|
|
|
|
if (!instance) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint pos = 0;
|
|
|
|
|
|
|
|
while (notifyFlags) {
|
|
|
|
uint type = notifyFlags & (1 << pos);
|
|
|
|
notifyFlags &= ~(1 << pos);
|
|
|
|
++pos;
|
|
|
|
|
|
|
|
RsFeedItem fi;
|
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case RS_FEED_TYPE_PEER:
|
|
|
|
fi.mId1 = rsPeers->getOwnId();
|
|
|
|
|
|
|
|
instance->addFeedItemPeerConnect(fi);
|
|
|
|
instance->addFeedItemPeerDisconnect(fi);
|
|
|
|
instance->addFeedItemPeerNew(fi);
|
|
|
|
instance->addFeedItemPeerHello(fi);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RS_FEED_TYPE_SECURITY:
|
|
|
|
fi.mId1 = rsPeers->getGPGOwnId();
|
|
|
|
fi.mId2 = rsPeers->getOwnId();
|
|
|
|
|
|
|
|
instance->addFeedItemSecurityConnectAttempt(fi);
|
|
|
|
instance->addFeedItemSecurityAuthDenied(fi);
|
|
|
|
instance->addFeedItemSecurityUnknownIn(fi);
|
|
|
|
instance->addFeedItemSecurityUnknownOut(fi);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RS_FEED_TYPE_CHAN:
|
|
|
|
{
|
|
|
|
std::list<ChannelInfo> channelList;
|
|
|
|
rsChannels->getChannelList(channelList);
|
|
|
|
|
|
|
|
std::list<ChannelInfo>::iterator channelIt;
|
|
|
|
for (channelIt = channelList.begin(); channelIt != channelList.end(); ++channelIt) {
|
|
|
|
if (fi.mId1.empty()) {
|
|
|
|
/* store first channel */
|
|
|
|
fi.mId1 = channelIt->channelId;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!channelIt->channelDesc.empty()) {
|
|
|
|
/* take channel with description */
|
|
|
|
fi.mId1 = channelIt->channelId;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
instance->addFeedItemChanNew(fi);
|
|
|
|
instance->addFeedItemChanUpdate(fi);
|
|
|
|
|
|
|
|
RsFeedItem fiMsg;
|
|
|
|
bool bFound = false;
|
|
|
|
|
|
|
|
for (channelIt = channelList.begin(); channelIt != channelList.end(); ++channelIt) {
|
|
|
|
std::list<ChannelMsgSummary> channelMsgs;
|
|
|
|
rsChannels->getChannelMsgList(channelIt->channelId, channelMsgs);
|
|
|
|
|
|
|
|
std::list<ChannelMsgSummary>::iterator msgIt;
|
|
|
|
for (msgIt = channelMsgs.begin(); msgIt != channelMsgs.end(); ++msgIt) {
|
|
|
|
if (fiMsg.mId2.empty()) {
|
|
|
|
/* store first channel message */
|
|
|
|
fiMsg.mId1 = msgIt->channelId;
|
|
|
|
fiMsg.mId2 = msgIt->msgId;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!msgIt->msg.empty()) {
|
|
|
|
/* take channel message with description */
|
|
|
|
fiMsg.mId1 = msgIt->channelId;
|
|
|
|
fiMsg.mId2 = msgIt->msgId;
|
|
|
|
bFound = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bFound) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
instance->addFeedItemChanMsg(fiMsg);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case RS_FEED_TYPE_FORUM:
|
|
|
|
{
|
|
|
|
std::list<ForumInfo> forumList;
|
|
|
|
rsForums->getForumList(forumList);
|
|
|
|
|
|
|
|
std::list<ForumInfo>::iterator forumIt;
|
|
|
|
for (forumIt = forumList.begin(); forumIt != forumList.end(); ++forumIt) {
|
|
|
|
if (fi.mId1.empty()) {
|
|
|
|
/* store first forum */
|
|
|
|
fi.mId1 = forumIt->forumId;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!forumIt->forumDesc.empty()) {
|
|
|
|
/* take forum with description */
|
|
|
|
fi.mId1 = forumIt->forumId;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
instance->addFeedItemForumNew(fi);
|
|
|
|
instance->addFeedItemForumUpdate(fi);
|
|
|
|
|
|
|
|
RsFeedItem fiMsg;
|
|
|
|
bool bFound = false;
|
|
|
|
|
|
|
|
for (forumIt = forumList.begin(); forumIt != forumList.end(); ++forumIt) {
|
|
|
|
std::list<ThreadInfoSummary> forumMsgs;
|
|
|
|
rsForums->getForumThreadList(forumIt->forumId, forumMsgs);
|
|
|
|
|
|
|
|
std::list<ThreadInfoSummary>::iterator msgIt;
|
|
|
|
for (msgIt = forumMsgs.begin(); msgIt != forumMsgs.end(); ++msgIt) {
|
|
|
|
if (fiMsg.mId2.empty()) {
|
|
|
|
/* store first forum message */
|
|
|
|
fiMsg.mId1 = msgIt->forumId;
|
|
|
|
fiMsg.mId2 = msgIt->msgId;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!msgIt->msg.empty()) {
|
|
|
|
/* take channel message with description */
|
|
|
|
fiMsg.mId1 = msgIt->forumId;
|
|
|
|
fiMsg.mId2 = msgIt->msgId;
|
|
|
|
bFound = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bFound) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
instance->addFeedItemForumMsg(fiMsg);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case RS_FEED_TYPE_BLOG:
|
|
|
|
// not used
|
|
|
|
// instance->addFeedItemBlogNew(fi);
|
|
|
|
// instance->addFeedItemBlogMsg(fi);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RS_FEED_TYPE_CHAT:
|
|
|
|
fi.mId1 = rsPeers->getOwnId();
|
|
|
|
fi.mId2 = tr("This is a test.").toUtf8().constData();
|
|
|
|
|
|
|
|
instance->addFeedItemChatNew(fi, true);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RS_FEED_TYPE_MSG:
|
|
|
|
{
|
|
|
|
std::list<MsgInfoSummary> msgList;
|
|
|
|
rsMsgs->getMessageSummaries(msgList);
|
|
|
|
|
|
|
|
std::list<MsgInfoSummary>::const_iterator msgIt;
|
|
|
|
for (msgIt = msgList.begin(); msgIt != msgList.end(); ++msgIt) {
|
|
|
|
if (fi.mId1.empty()) {
|
|
|
|
/* store first message */
|
|
|
|
fi.mId1 = msgIt->msgId;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (msgIt->msgflags & RS_MSG_TRASH) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((msgIt->msgflags & RS_MSG_BOXMASK) == RS_MSG_INBOX) {
|
|
|
|
/* take message from inbox */
|
|
|
|
fi.mId1 = msgIt->msgId;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
instance->addFeedItemMessage(fi);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case RS_FEED_TYPE_FILES:
|
|
|
|
// not used
|
|
|
|
// instance->addFeedItemFilesNew(fi);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-14 17:41:31 -05:00
|
|
|
void NewsFeed::testFeed(FeedNotify *feedNotify)
|
|
|
|
{
|
|
|
|
if (!instance) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!feedNotify) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QWidget *feedItem = feedNotify->testFeedItem(instance);
|
|
|
|
if (!feedItem) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
instance->addFeedItem(feedItem);
|
|
|
|
}
|
|
|
|
|
2010-09-01 16:54:24 -04:00
|
|
|
void NewsFeed::addFeedItem(QWidget *item)
|
|
|
|
{
|
2010-11-06 15:13:33 -04:00
|
|
|
item->setAttribute(Qt::WA_DeleteOnClose, true);
|
|
|
|
|
|
|
|
connect(item, SIGNAL(destroyed(QObject*)), this, SLOT(itemDestroyed(QObject*)));
|
2012-02-01 07:21:14 -05:00
|
|
|
widgets.insert(item);
|
2010-11-06 15:13:33 -04:00
|
|
|
|
2010-11-10 07:24:36 -05:00
|
|
|
sendNewsFeedChanged();
|
|
|
|
|
2012-10-08 19:06:34 -04:00
|
|
|
lockLayout(NULL, true);
|
|
|
|
|
2010-09-01 16:54:24 -04:00
|
|
|
if (Settings->getAddFeedsAtEnd()) {
|
|
|
|
verticalLayout->addWidget(item);
|
|
|
|
} else {
|
|
|
|
verticalLayout->insertWidget(0, item);
|
|
|
|
}
|
2012-10-08 19:06:34 -04:00
|
|
|
item->show();
|
|
|
|
|
|
|
|
lockLayout(item, false);
|
2010-09-01 16:54:24 -04:00
|
|
|
}
|
|
|
|
|
2012-02-01 07:21:14 -05:00
|
|
|
void NewsFeed::addFeedItemIfUnique(QWidget *item, int itemType, const std::string &sslId, bool replace)
|
2011-07-11 11:53:41 -04:00
|
|
|
{
|
2012-02-01 07:21:14 -05:00
|
|
|
foreach (QObject *itemObject, widgets) {
|
|
|
|
SecurityItem *secitem = dynamic_cast<SecurityItem*>(itemObject);
|
2011-07-11 11:53:41 -04:00
|
|
|
if ((secitem) && (secitem->isSame(sslId, itemType)))
|
|
|
|
{
|
|
|
|
if (!replace)
|
2012-02-01 07:21:14 -05:00
|
|
|
{
|
2011-07-11 11:53:41 -04:00
|
|
|
delete item;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
secitem->close();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-01-08 17:07:52 -05:00
|
|
|
|
2011-07-11 11:53:41 -04:00
|
|
|
addFeedItem(item);
|
|
|
|
}
|
|
|
|
|
2008-06-20 08:43:23 -04:00
|
|
|
void NewsFeed::addFeedItemPeerConnect(RsFeedItem &fi)
|
|
|
|
{
|
|
|
|
/* make new widget */
|
|
|
|
PeerItem *pi = new PeerItem(this, NEWSFEED_PEERLIST, fi.mId1, PEER_TYPE_CONNECT, false);
|
|
|
|
|
|
|
|
/* store */
|
|
|
|
|
|
|
|
/* add to layout */
|
2010-09-01 16:54:24 -04:00
|
|
|
addFeedItem(pi);
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef NEWS_DEBUG
|
2008-06-20 08:43:23 -04:00
|
|
|
std::cerr << "NewsFeed::addFeedItemPeerConnect()";
|
|
|
|
std::cerr << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
|
|
|
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void NewsFeed::addFeedItemPeerDisconnect(RsFeedItem &fi)
|
|
|
|
{
|
|
|
|
/* make new widget */
|
|
|
|
PeerItem *pi = new PeerItem(this, NEWSFEED_PEERLIST, fi.mId1, PEER_TYPE_STD, false);
|
|
|
|
|
|
|
|
/* store */
|
|
|
|
|
|
|
|
/* add to layout */
|
2010-09-01 16:54:24 -04:00
|
|
|
addFeedItem(pi);
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef NEWS_DEBUG
|
2008-06-20 08:43:23 -04:00
|
|
|
std::cerr << "NewsFeed::addFeedItemPeerDisconnect()";
|
|
|
|
std::cerr << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void NewsFeed::addFeedItemPeerHello(RsFeedItem &fi)
|
|
|
|
{
|
|
|
|
/* make new widget */
|
|
|
|
PeerItem *pi = new PeerItem(this, NEWSFEED_PEERLIST, fi.mId1, PEER_TYPE_HELLO, false);
|
|
|
|
|
|
|
|
/* store */
|
|
|
|
|
|
|
|
/* add to layout */
|
2010-09-01 16:54:24 -04:00
|
|
|
addFeedItem(pi);
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef NEWS_DEBUG
|
2008-06-20 08:43:23 -04:00
|
|
|
std::cerr << "NewsFeed::addFeedItemPeerHello()";
|
|
|
|
std::cerr << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void NewsFeed::addFeedItemPeerNew(RsFeedItem &fi)
|
|
|
|
{
|
|
|
|
/* make new widget */
|
|
|
|
PeerItem *pi = new PeerItem(this, NEWSFEED_PEERLIST, fi.mId1, PEER_TYPE_NEW_FOF, false);
|
|
|
|
|
|
|
|
/* store */
|
|
|
|
|
|
|
|
/* add to layout */
|
2010-09-01 16:54:24 -04:00
|
|
|
addFeedItem(pi);
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef NEWS_DEBUG
|
2008-06-20 08:43:23 -04:00
|
|
|
std::cerr << "NewsFeed::addFeedItemPeerNew()";
|
|
|
|
std::cerr << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
|
2011-07-11 11:53:41 -04:00
|
|
|
void NewsFeed::addFeedItemSecurityConnectAttempt(RsFeedItem &fi)
|
2011-07-10 21:08:01 -04:00
|
|
|
{
|
|
|
|
/* make new widget */
|
2013-01-19 14:24:08 -05:00
|
|
|
SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, fi.mId1, fi.mId2, fi.mId3, fi.mId4, SEC_TYPE_CONNECT_ATTEMPT, false);
|
2011-07-10 21:08:01 -04:00
|
|
|
|
|
|
|
/* store */
|
|
|
|
|
|
|
|
/* add to layout */
|
2011-07-11 11:53:41 -04:00
|
|
|
addFeedItemIfUnique(pi, SEC_TYPE_CONNECT_ATTEMPT, fi.mId2, false);
|
2011-07-10 21:08:01 -04:00
|
|
|
|
|
|
|
#ifdef NEWS_DEBUG
|
2011-07-11 11:53:41 -04:00
|
|
|
std::cerr << "NewsFeed::addFeedItemSecurityConnectAttempt()";
|
2011-07-10 21:08:01 -04:00
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-07-11 11:53:41 -04:00
|
|
|
void NewsFeed::addFeedItemSecurityAuthDenied(RsFeedItem &fi)
|
2011-07-10 21:08:01 -04:00
|
|
|
{
|
|
|
|
/* make new widget */
|
2013-01-19 14:24:08 -05:00
|
|
|
SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, fi.mId1, fi.mId2, fi.mId3, fi.mId4, SEC_TYPE_AUTH_DENIED, false);
|
2011-07-10 21:08:01 -04:00
|
|
|
|
|
|
|
/* store */
|
|
|
|
|
|
|
|
/* add to layout */
|
2011-07-11 11:53:41 -04:00
|
|
|
addFeedItemIfUnique(pi, SEC_TYPE_AUTH_DENIED, fi.mId2, false);
|
2011-07-10 21:08:01 -04:00
|
|
|
|
|
|
|
#ifdef NEWS_DEBUG
|
2011-07-11 11:53:41 -04:00
|
|
|
std::cerr << "NewsFeed::addFeedItemSecurityAuthDenied()";
|
2011-07-10 21:08:01 -04:00
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-07-11 11:53:41 -04:00
|
|
|
void NewsFeed::addFeedItemSecurityUnknownIn(RsFeedItem &fi)
|
2011-07-10 21:08:01 -04:00
|
|
|
{
|
|
|
|
/* make new widget */
|
2013-01-19 14:24:08 -05:00
|
|
|
SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, fi.mId1, fi.mId2, fi.mId3, fi.mId4, SEC_TYPE_UNKNOWN_IN, false);
|
2011-07-10 21:08:01 -04:00
|
|
|
|
|
|
|
/* store */
|
|
|
|
|
|
|
|
/* add to layout */
|
2011-07-11 11:53:41 -04:00
|
|
|
addFeedItemIfUnique(pi, SEC_TYPE_UNKNOWN_IN, fi.mId2, false);
|
2011-07-10 21:08:01 -04:00
|
|
|
|
|
|
|
#ifdef NEWS_DEBUG
|
2011-07-11 11:53:41 -04:00
|
|
|
std::cerr << "NewsFeed::addFeedItemSecurityUnknownIn()";
|
2011-07-10 21:08:01 -04:00
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2011-07-11 11:53:41 -04:00
|
|
|
void NewsFeed::addFeedItemSecurityUnknownOut(RsFeedItem &fi)
|
|
|
|
{
|
|
|
|
/* make new widget */
|
2013-01-19 14:24:08 -05:00
|
|
|
SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, fi.mId1, fi.mId2, fi.mId3, fi.mId4, SEC_TYPE_UNKNOWN_OUT, false);
|
2013-01-08 17:07:52 -05:00
|
|
|
|
2011-07-11 11:53:41 -04:00
|
|
|
/* store */
|
2013-01-08 17:07:52 -05:00
|
|
|
|
2011-07-11 11:53:41 -04:00
|
|
|
/* add to layout */
|
|
|
|
addFeedItemIfUnique(pi, SEC_TYPE_UNKNOWN_OUT, fi.mId2, false);
|
2013-01-08 17:07:52 -05:00
|
|
|
|
2011-07-11 11:53:41 -04:00
|
|
|
#ifdef NEWS_DEBUG
|
|
|
|
std::cerr << "NewsFeed::addFeedItemSecurityUnknownOut()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2008-06-20 08:43:23 -04:00
|
|
|
void NewsFeed::addFeedItemChanNew(RsFeedItem &fi)
|
|
|
|
{
|
2008-07-04 10:41:24 -04:00
|
|
|
/* make new widget */
|
|
|
|
ChanNewItem *cni = new ChanNewItem(this, NEWSFEED_CHANNEWLIST, fi.mId1, false, true);
|
|
|
|
|
|
|
|
/* store in list */
|
|
|
|
|
|
|
|
/* add to layout */
|
2010-09-01 16:54:24 -04:00
|
|
|
addFeedItem(cni);
|
2008-07-04 10:41:24 -04:00
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef NEWS_DEBUG
|
2008-06-20 08:43:23 -04:00
|
|
|
std::cerr << "NewsFeed::addFeedItemChanNew()";
|
|
|
|
std::cerr << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void NewsFeed::addFeedItemChanUpdate(RsFeedItem &fi)
|
|
|
|
{
|
2008-07-04 10:41:24 -04:00
|
|
|
/* make new widget */
|
|
|
|
ChanNewItem *cni = new ChanNewItem(this, NEWSFEED_CHANNEWLIST, fi.mId1, false, false);
|
|
|
|
|
|
|
|
/* store in list */
|
|
|
|
|
|
|
|
/* add to layout */
|
2010-09-01 16:54:24 -04:00
|
|
|
addFeedItem(cni);
|
2008-07-04 10:41:24 -04:00
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef NEWS_DEBUG
|
2008-06-20 08:43:23 -04:00
|
|
|
std::cerr << "NewsFeed::addFeedItemChanUpdate()";
|
|
|
|
std::cerr << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void NewsFeed::addFeedItemChanMsg(RsFeedItem &fi)
|
|
|
|
{
|
2008-06-24 00:36:45 -04:00
|
|
|
/* make new widget */
|
|
|
|
ChanMsgItem *cm = new ChanMsgItem(this, NEWSFEED_CHANMSGLIST, fi.mId1, fi.mId2, false);
|
|
|
|
|
|
|
|
/* store in forum list */
|
|
|
|
|
|
|
|
/* add to layout */
|
2010-09-01 16:54:24 -04:00
|
|
|
addFeedItem(cm);
|
2008-06-24 00:36:45 -04:00
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef NEWS_DEBUG
|
2008-06-20 08:43:23 -04:00
|
|
|
std::cerr << "NewsFeed::addFeedItemChanMsg()";
|
|
|
|
std::cerr << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
/* add to layout */
|
2010-09-01 16:54:24 -04:00
|
|
|
addFeedItem(fni);
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef NEWS_DEBUG
|
2008-06-20 08:43:23 -04:00
|
|
|
std::cerr << "NewsFeed::addFeedItemForumNew()";
|
|
|
|
std::cerr << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void NewsFeed::addFeedItemForumUpdate(RsFeedItem &fi)
|
|
|
|
{
|
|
|
|
/* make new widget */
|
|
|
|
ForumNewItem *fni = new ForumNewItem(this, NEWSFEED_FORUMNEWLIST, fi.mId1, false, false);
|
|
|
|
|
|
|
|
/* store in forum list */
|
|
|
|
mForumNewItems.push_back(fni);
|
|
|
|
|
|
|
|
/* add to layout */
|
2010-09-01 16:54:24 -04:00
|
|
|
addFeedItem(fni);
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef NEWS_DEBUG
|
2008-06-20 08:43:23 -04:00
|
|
|
std::cerr << "NewsFeed::addFeedItemForumUpdate()";
|
|
|
|
std::cerr << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void NewsFeed::addFeedItemForumMsg(RsFeedItem &fi)
|
|
|
|
{
|
|
|
|
/* make new widget */
|
2011-01-26 16:36:13 -05:00
|
|
|
ForumMsgItem *fm = new ForumMsgItem(this, NEWSFEED_FORUMMSGLIST, fi.mId1, fi.mId2, false);
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
/* store in forum list */
|
|
|
|
|
|
|
|
/* add to layout */
|
2010-09-01 16:54:24 -04:00
|
|
|
addFeedItem(fm);
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef NEWS_DEBUG
|
2008-06-20 08:43:23 -04:00
|
|
|
std::cerr << "NewsFeed::addFeedItemForumMsg()";
|
|
|
|
std::cerr << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
|
2010-05-20 17:00:59 -04:00
|
|
|
void NewsFeed::addFeedItemBlogNew(RsFeedItem &fi)
|
|
|
|
{
|
2010-07-31 14:19:12 -04:00
|
|
|
#ifdef BLOGS
|
2010-05-20 17:00:59 -04:00
|
|
|
/* make new widget */
|
|
|
|
BlogNewItem *bni = new BlogNewItem(this, NEWSFEED_BLOGNEWLIST, fi.mId1, false, true);
|
|
|
|
|
|
|
|
/* store in list */
|
|
|
|
|
|
|
|
/* add to layout */
|
2010-09-01 16:54:24 -04:00
|
|
|
addFeedItem(bni);
|
2011-08-12 10:06:29 -04:00
|
|
|
#else
|
|
|
|
Q_UNUSED(fi);
|
2010-07-31 14:19:12 -04:00
|
|
|
#endif
|
2010-05-20 17:00:59 -04:00
|
|
|
|
|
|
|
#ifdef NEWS_DEBUG
|
|
|
|
std::cerr << "NewsFeed::addFeedItemBlogNew()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
}
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
void NewsFeed::addFeedItemBlogMsg(RsFeedItem &fi)
|
|
|
|
{
|
2010-07-31 14:19:12 -04:00
|
|
|
#ifdef BLOGS
|
2008-06-20 08:43:23 -04:00
|
|
|
/* make new widget */
|
|
|
|
BlogMsgItem *bm = new BlogMsgItem(this, NEWSFEED_BLOGMSGLIST, fi.mId1, fi.mId2, false);
|
|
|
|
|
|
|
|
/* store in forum list */
|
|
|
|
|
|
|
|
/* add to layout */
|
2010-09-01 16:54:24 -04:00
|
|
|
addFeedItem(bm);
|
2011-08-12 10:06:29 -04:00
|
|
|
#else
|
|
|
|
Q_UNUSED(fi);
|
2010-07-31 14:19:12 -04:00
|
|
|
#endif
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef NEWS_DEBUG
|
2008-06-20 08:43:23 -04:00
|
|
|
std::cerr << "NewsFeed::addFeedItemBlogMsg()";
|
|
|
|
std::cerr << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
|
2012-09-04 16:04:49 -04:00
|
|
|
void NewsFeed::addFeedItemChatNew(RsFeedItem &fi, bool addWithoutCheck)
|
2008-06-20 08:43:23 -04:00
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef NEWS_DEBUG
|
2008-06-20 08:43:23 -04:00
|
|
|
std::cerr << "NewsFeed::addFeedItemChatNew()";
|
|
|
|
std::cerr << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2012-09-04 16:04:49 -04:00
|
|
|
if (!addWithoutCheck && fi.mId1 == rsPeers->getOwnId()) {
|
2010-08-31 18:42:40 -04:00
|
|
|
/* chat message from myself */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-08-31 13:13:52 -04:00
|
|
|
/* make new widget */
|
2012-02-01 07:21:14 -05:00
|
|
|
ChatMsgItem *cm = new ChatMsgItem(this, NEWSFEED_CHATMSGLIST, fi.mId1, fi.mId2);
|
2010-08-31 13:13:52 -04:00
|
|
|
|
|
|
|
/* store in forum list */
|
|
|
|
|
|
|
|
/* add to layout */
|
2010-09-01 16:54:24 -04:00
|
|
|
addFeedItem(cm);
|
2010-08-31 13:13:52 -04:00
|
|
|
}
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
void NewsFeed::addFeedItemMessage(RsFeedItem &fi)
|
|
|
|
{
|
2008-07-04 10:41:24 -04:00
|
|
|
/* make new widget */
|
2011-01-26 18:09:25 -05:00
|
|
|
MsgItem *mi = new MsgItem(this, NEWSFEED_MESSAGELIST, fi.mId1, false);
|
2008-07-04 10:41:24 -04:00
|
|
|
|
|
|
|
/* store in list */
|
|
|
|
|
|
|
|
/* add to layout */
|
2010-09-01 16:54:24 -04:00
|
|
|
addFeedItem(mi);
|
2008-07-04 10:41:24 -04:00
|
|
|
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef NEWS_DEBUG
|
2008-06-20 08:43:23 -04:00
|
|
|
std::cerr << "NewsFeed::addFeedItemMessage()";
|
|
|
|
std::cerr << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
|
2011-08-12 10:06:29 -04:00
|
|
|
void NewsFeed::addFeedItemFilesNew(RsFeedItem &/*fi*/)
|
2008-06-20 08:43:23 -04:00
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef NEWS_DEBUG
|
2008-06-20 08:43:23 -04:00
|
|
|
std::cerr << "NewsFeed::addFeedItemFilesNew()";
|
|
|
|
std::cerr << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* FeedHolder Functions (for FeedItem functionality) */
|
2012-10-08 19:06:34 -04:00
|
|
|
QScrollArea *NewsFeed::getScrollArea()
|
|
|
|
{
|
|
|
|
return scrollArea;
|
|
|
|
}
|
|
|
|
|
2011-08-12 10:06:29 -04:00
|
|
|
void NewsFeed::deleteFeedItem(QWidget *item, uint32_t /*type*/)
|
2008-06-20 08:43:23 -04:00
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef NEWS_DEBUG
|
2008-06-20 08:43:23 -04:00
|
|
|
std::cerr << "NewsFeed::deleteFeedItem()";
|
|
|
|
std::cerr << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2010-05-04 20:05:36 -04:00
|
|
|
|
2011-08-21 18:28:19 -04:00
|
|
|
if (item) {
|
|
|
|
item->close ();
|
|
|
|
}
|
2008-06-20 08:43:23 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void NewsFeed::openChat(std::string peerId)
|
|
|
|
{
|
2008-07-09 05:53:47 -04:00
|
|
|
#ifdef NEWS_DEBUG
|
2008-06-20 08:43:23 -04:00
|
|
|
std::cerr << "NewsFeed::openChat()";
|
|
|
|
std::cerr << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2012-01-17 15:36:36 -05:00
|
|
|
ChatDialog::chatFriend(peerId);
|
2010-08-12 15:45:15 -04:00
|
|
|
}
|
2010-11-06 15:13:33 -04:00
|
|
|
|
2013-06-10 09:27:24 -04:00
|
|
|
void NewsFeed::openComments(uint32_t /*type*/, const RsGxsGroupId &/*groupId*/, const RsGxsMessageId &/*msgId*/, const QString &/*title*/)
|
2013-03-11 16:53:15 -04:00
|
|
|
{
|
|
|
|
std::cerr << "NewsFeed::openComments() Not Handled Yet";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
}
|
|
|
|
|
2010-11-06 15:13:33 -04:00
|
|
|
void NewsFeed::itemDestroyed(QObject *item)
|
|
|
|
{
|
2012-02-01 07:21:14 -05:00
|
|
|
widgets.remove(item);
|
2010-11-10 07:24:36 -05:00
|
|
|
sendNewsFeedChanged();
|
2010-11-06 15:13:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void NewsFeed::removeAll()
|
|
|
|
{
|
|
|
|
#ifdef NEWS_DEBUG
|
|
|
|
std::cerr << "NewsFeed::removeAll()" << std::endl;
|
|
|
|
#endif
|
|
|
|
|
2012-02-01 07:21:14 -05:00
|
|
|
foreach (QObject *item, widgets) {
|
2010-11-06 15:13:33 -04:00
|
|
|
if (item) {
|
|
|
|
item->deleteLater();
|
|
|
|
}
|
|
|
|
}
|
2012-02-01 07:21:14 -05:00
|
|
|
widgets.clear();
|
2010-11-06 15:13:33 -04:00
|
|
|
}
|
2010-11-10 07:24:36 -05:00
|
|
|
|
|
|
|
void NewsFeed::sendNewsFeedChanged()
|
|
|
|
{
|
|
|
|
int count = 0;
|
|
|
|
|
2012-02-01 07:21:14 -05:00
|
|
|
foreach (QObject *item, widgets) {
|
|
|
|
if (dynamic_cast<PeerItem*>(item) == NULL) {
|
2010-11-10 07:24:36 -05:00
|
|
|
/* don't count PeerItem's */
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
emit newsFeedChanged(count);
|
|
|
|
}
|
2011-03-24 15:43:52 -04:00
|
|
|
|
|
|
|
void NewsFeed::feedoptions()
|
|
|
|
{
|
2012-02-01 07:21:14 -05:00
|
|
|
RSettingsWin::showYourself(this, RSettingsWin::Notify);
|
2011-03-24 15:43:52 -04:00
|
|
|
}
|