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>
|
2014-11-15 12:24:49 -05:00
|
|
|
#include <QDateTime>
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2010-07-23 14:52:58 -04:00
|
|
|
#include "NewsFeed.h"
|
2014-11-15 12:24:49 -05:00
|
|
|
#include "ui_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>
|
2014-11-17 19:49:21 -05:00
|
|
|
#include <retroshare/rsgxschannels.h>
|
|
|
|
#include <retroshare/rsgxsforums.h>
|
2014-11-20 19:50:18 -05:00
|
|
|
#include <retroshare/rsposted.h>
|
2012-09-04 16:04:49 -04:00
|
|
|
#include <retroshare/rsmsgs.h>
|
2013-01-08 17:07:52 -05:00
|
|
|
#include <retroshare/rsplugin.h>
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2014-11-17 19:49:21 -05:00
|
|
|
#include "feeds/GxsChannelGroupItem.h"
|
2014-11-13 17:03:12 -05:00
|
|
|
#include "feeds/GxsChannelPostItem.h"
|
2014-11-19 07:40:42 -05:00
|
|
|
#include "feeds/GxsForumGroupItem.h"
|
|
|
|
#include "feeds/GxsForumMsgItem.h"
|
2014-11-20 19:50:18 -05:00
|
|
|
#include "feeds/PostedGroupItem.h"
|
|
|
|
#include "Posted/PostedItem.h"
|
|
|
|
#include "feeds/GxsForumMsgItem.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"
|
2014-11-15 12:24:49 -05:00
|
|
|
#include "notifyqt.h"
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2014-11-13 17:03:12 -05:00
|
|
|
const uint32_t NEWSFEED_PEERLIST = 0x0001;
|
2013-09-07 00:21:48 -04:00
|
|
|
|
2014-11-13 17:03:12 -05:00
|
|
|
const uint32_t NEWSFEED_FORUMNEWLIST = 0x0002;
|
|
|
|
const uint32_t NEWSFEED_FORUMMSGLIST = 0x0003;
|
|
|
|
const uint32_t NEWSFEED_CHANNELNEWLIST = 0x0004;
|
|
|
|
const uint32_t NEWSFEED_CHANNELMSGLIST = 0x0005;
|
2013-09-07 00:21:48 -04:00
|
|
|
#if 0
|
2014-11-13 17:03:12 -05:00
|
|
|
const uint32_t NEWSFEED_BLOGNEWLIST = 0x0006;
|
|
|
|
const uint32_t NEWSFEED_BLOGMSGLIST = 0x0007;
|
2013-09-07 00:21:48 -04:00
|
|
|
#endif
|
|
|
|
|
2014-11-13 17:03:12 -05:00
|
|
|
const uint32_t NEWSFEED_MESSAGELIST = 0x0008;
|
|
|
|
const uint32_t NEWSFEED_CHATMSGLIST = 0x0009;
|
|
|
|
const uint32_t NEWSFEED_SECLIST = 0x000a;
|
2014-11-20 19:50:18 -05:00
|
|
|
const uint32_t NEWSFEED_POSTEDNEWLIST = 0x000b;
|
|
|
|
const uint32_t NEWSFEED_POSTEDMSGLIST = 0x000c;
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
#define ROLE_RECEIVED FEED_TREEWIDGET_SORTROLE
|
|
|
|
|
2014-11-17 19:49:21 -05:00
|
|
|
#define TOKEN_TYPE_GROUP 1
|
|
|
|
#define TOKEN_TYPE_MESSAGE 2
|
|
|
|
|
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 */
|
2014-11-15 12:24:49 -05:00
|
|
|
NewsFeed::NewsFeed(QWidget *parent) :
|
|
|
|
RsAutoUpdatePage(1000,parent),
|
|
|
|
ui(new Ui::NewsFeed)
|
2008-06-20 08:43:23 -04:00
|
|
|
{
|
2013-01-08 17:07:52 -05:00
|
|
|
/* Invoke the Qt Designer generated object setup routine */
|
2014-11-15 12:24:49 -05:00
|
|
|
ui->setupUi(this);
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2014-11-17 19:49:21 -05:00
|
|
|
mTokenQueueChannel = NULL;
|
|
|
|
mTokenQueueForum = NULL;
|
2014-11-20 19:50:18 -05:00
|
|
|
mTokenQueuePosted = NULL;
|
2014-11-17 19:49:21 -05:00
|
|
|
|
2013-06-21 20:05:02 -04:00
|
|
|
setUpdateWhenInvisible(true);
|
|
|
|
|
2012-09-04 16:04:49 -04:00
|
|
|
if (!instance) {
|
|
|
|
instance = this;
|
|
|
|
}
|
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
ui->feedWidget->enableRemove(true);
|
|
|
|
|
|
|
|
connect(ui->removeAllButton, SIGNAL(clicked()), ui->feedWidget, SLOT(clear()));
|
|
|
|
connect(ui->feedOptionsButton, SIGNAL(clicked()), this, SLOT(feedoptions()));
|
|
|
|
connect(ui->feedWidget, SIGNAL(feedCountChanged()), this, SLOT(sendNewsFeedChanged()));
|
|
|
|
connect(NotifyQt::getInstance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged()));
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2013-09-08 11:08:36 -04:00
|
|
|
QString hlp_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> \
|
|
|
|
") ;
|
2013-07-18 15:32:12 -04:00
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
registerHelpButton(ui->helpButton,hlp_str) ;
|
|
|
|
|
|
|
|
settingsChanged();
|
2013-07-19 08:18:58 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
NewsFeed::~NewsFeed()
|
|
|
|
{
|
|
|
|
if (instance == this) {
|
|
|
|
instance = NULL;
|
|
|
|
}
|
2014-11-17 19:49:21 -05:00
|
|
|
|
|
|
|
if (mTokenQueueChannel) {
|
|
|
|
delete(mTokenQueueChannel);
|
|
|
|
}
|
|
|
|
if (mTokenQueueForum) {
|
|
|
|
delete(mTokenQueueForum);
|
|
|
|
}
|
2014-11-20 19:50:18 -05:00
|
|
|
if (mTokenQueuePosted) {
|
|
|
|
delete(mTokenQueuePosted);
|
|
|
|
}
|
2013-07-18 15:32:12 -04:00
|
|
|
}
|
|
|
|
|
2013-06-21 20:05:02 -04:00
|
|
|
UserNotify *NewsFeed::getUserNotify(QObject *parent)
|
|
|
|
{
|
|
|
|
return new NewsFeedUserNotify(this, parent);
|
|
|
|
}
|
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
void NewsFeed::settingsChanged()
|
|
|
|
{
|
|
|
|
ui->feedWidget->setSortRole(ROLE_RECEIVED, Settings->getAddFeedsAtEnd() ? Qt::AscendingOrder : Qt::DescendingOrder);
|
|
|
|
}
|
|
|
|
|
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:
|
2014-01-16 14:57:08 -05:00
|
|
|
case RS_FEED_ITEM_SEC_WRONG_SIGNATURE:
|
|
|
|
case RS_FEED_ITEM_SEC_BAD_CERTIFICATE:
|
2014-01-28 16:33:17 -05:00
|
|
|
case RS_FEED_ITEM_SEC_MISSING_CERTIFICATE:
|
2014-01-16 14:57:08 -05:00
|
|
|
case RS_FEED_ITEM_SEC_INTERNAL_ERROR:
|
2012-04-26 19:41:14 -04:00
|
|
|
if (Settings->getMessageFlags() & RS_MESSAGE_CONNECT_ATTEMPT) {
|
2014-03-17 16:56:06 -04:00
|
|
|
MessageComposer::sendConnectAttemptMsg(RsPgpId(fi.mId1), RsPeerId(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
|
|
|
|
2014-11-13 17:03:12 -05:00
|
|
|
case RS_FEED_ITEM_CHANNEL_NEW:
|
|
|
|
if (flags & RS_FEED_TYPE_CHANNEL)
|
|
|
|
addFeedItemChannelNew(fi);
|
2008-06-20 08:43:23 -04:00
|
|
|
break;
|
2014-11-13 17:03:12 -05:00
|
|
|
// 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);
|
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;
|
2014-11-13 17:03:12 -05:00
|
|
|
// case RS_FEED_ITEM_FORUM_UPDATE:
|
|
|
|
// if (flags & RS_FEED_TYPE_FORUM)
|
|
|
|
// addFeedItemForumUpdate(fi);
|
|
|
|
// break;
|
2008-06-20 08:43:23 -04:00
|
|
|
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;
|
|
|
|
|
2014-11-20 19:50:18 -05:00
|
|
|
case RS_FEED_ITEM_POSTED_NEW:
|
|
|
|
if (flags & RS_FEED_TYPE_POSTED)
|
|
|
|
addFeedItemPostedNew(fi);
|
|
|
|
break;
|
|
|
|
// case RS_FEED_ITEM_POSTED_UPDATE:
|
|
|
|
// if (flags & RS_FEED_TYPE_POSTED)
|
|
|
|
// addFeedItemPostedUpdate(fi);
|
|
|
|
// break;
|
|
|
|
case RS_FEED_ITEM_POSTED_MSG:
|
|
|
|
if (flags & RS_FEED_TYPE_POSTED)
|
|
|
|
addFeedItemPostedMsg(fi);
|
|
|
|
break;
|
|
|
|
|
2014-11-13 17:03:12 -05:00
|
|
|
#if 0
|
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;
|
2013-09-07 00:21:48 -04:00
|
|
|
#endif
|
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:
|
2014-01-15 15:19:17 -05:00
|
|
|
std::cerr << "(EE) Unknown type " << std::hex << fi.mType << std::dec << " in news feed." << std::endl;
|
2008-06-20 08:43:23 -04:00
|
|
|
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()) {
|
2014-11-15 12:24:49 -05:00
|
|
|
FeedItem *item = feedNotify->feedItem(this);
|
2013-01-08 17:07:52 -05:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
instance->ui->feedWidget->enableCountChangedSignal(false);
|
|
|
|
|
2012-09-04 16:04:49 -04:00
|
|
|
uint pos = 0;
|
|
|
|
|
|
|
|
while (notifyFlags) {
|
|
|
|
uint type = notifyFlags & (1 << pos);
|
|
|
|
notifyFlags &= ~(1 << pos);
|
|
|
|
++pos;
|
|
|
|
|
|
|
|
RsFeedItem fi;
|
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case RS_FEED_TYPE_PEER:
|
2014-03-17 16:56:06 -04:00
|
|
|
fi.mId1 = rsPeers->getOwnId().toStdString();
|
2012-09-04 16:04:49 -04:00
|
|
|
|
|
|
|
instance->addFeedItemPeerConnect(fi);
|
|
|
|
instance->addFeedItemPeerDisconnect(fi);
|
|
|
|
instance->addFeedItemPeerNew(fi);
|
|
|
|
instance->addFeedItemPeerHello(fi);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RS_FEED_TYPE_SECURITY:
|
2014-03-17 16:56:06 -04:00
|
|
|
fi.mId1 = rsPeers->getGPGOwnId().toStdString();
|
|
|
|
fi.mId2 = rsPeers->getOwnId().toStdString();
|
2012-09-04 16:04:49 -04:00
|
|
|
|
|
|
|
instance->addFeedItemSecurityConnectAttempt(fi);
|
|
|
|
instance->addFeedItemSecurityAuthDenied(fi);
|
|
|
|
instance->addFeedItemSecurityUnknownIn(fi);
|
|
|
|
instance->addFeedItemSecurityUnknownOut(fi);
|
|
|
|
break;
|
|
|
|
|
2014-11-13 17:03:12 -05:00
|
|
|
case RS_FEED_TYPE_CHANNEL:
|
2012-09-04 16:04:49 -04:00
|
|
|
{
|
2014-11-17 19:49:21 -05:00
|
|
|
if (!instance->mTokenQueueChannel) {
|
|
|
|
instance->mTokenQueueChannel = new TokenQueue(rsGxsChannels->getTokenService(), instance);
|
2012-09-04 16:04:49 -04:00
|
|
|
}
|
|
|
|
|
2014-11-17 19:49:21 -05:00
|
|
|
RsTokReqOptions opts;
|
|
|
|
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
|
|
|
uint32_t token;
|
|
|
|
instance->mTokenQueueChannel->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, TOKEN_TYPE_GROUP);
|
2012-09-04 16:04:49 -04:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case RS_FEED_TYPE_FORUM:
|
|
|
|
{
|
2014-11-17 19:49:21 -05:00
|
|
|
if (!instance->mTokenQueueForum) {
|
|
|
|
instance->mTokenQueueForum = new TokenQueue(rsGxsForums->getTokenService(), instance);
|
2012-09-04 16:04:49 -04:00
|
|
|
}
|
|
|
|
|
2014-11-17 19:49:21 -05:00
|
|
|
RsTokReqOptions opts;
|
|
|
|
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
|
|
|
uint32_t token;
|
|
|
|
instance->mTokenQueueForum->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, TOKEN_TYPE_GROUP);
|
2012-09-04 16:04:49 -04:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-11-20 19:50:18 -05:00
|
|
|
case RS_FEED_TYPE_POSTED:
|
|
|
|
{
|
|
|
|
if (!instance->mTokenQueuePosted) {
|
|
|
|
instance->mTokenQueuePosted = new TokenQueue(rsPosted->getTokenService(), instance);
|
|
|
|
}
|
|
|
|
|
|
|
|
RsTokReqOptions opts;
|
|
|
|
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
|
|
|
uint32_t token;
|
|
|
|
instance->mTokenQueuePosted->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, TOKEN_TYPE_GROUP);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-11-17 19:49:21 -05:00
|
|
|
#if 0
|
2012-09-04 16:04:49 -04:00
|
|
|
case RS_FEED_TYPE_BLOG:
|
|
|
|
// not used
|
|
|
|
// instance->addFeedItemBlogNew(fi);
|
|
|
|
// instance->addFeedItemBlogMsg(fi);
|
|
|
|
break;
|
2013-09-07 00:21:48 -04:00
|
|
|
#endif
|
2012-09-04 16:04:49 -04:00
|
|
|
|
|
|
|
case RS_FEED_TYPE_CHAT:
|
2014-03-17 16:56:06 -04:00
|
|
|
fi.mId1 = rsPeers->getOwnId().toStdString();
|
2012-09-04 16:04:49 -04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2014-11-15 12:24:49 -05:00
|
|
|
|
|
|
|
instance->ui->feedWidget->enableCountChangedSignal(true);
|
|
|
|
|
|
|
|
instance->sendNewsFeedChanged();
|
2012-09-04 16:04:49 -04:00
|
|
|
}
|
|
|
|
|
2014-11-17 19:49:21 -05:00
|
|
|
void NewsFeed::loadChannelGroup(const uint32_t &token)
|
|
|
|
{
|
|
|
|
std::vector<RsGxsChannelGroup> groups;
|
|
|
|
if (!rsGxsChannels->getGroupData(token, groups)) {
|
|
|
|
std::cerr << "NewsFeed::loadChannelGroup() ERROR getting data";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
RsFeedItem fi;
|
|
|
|
std::vector<RsGxsChannelGroup>::iterator channelIt;
|
|
|
|
for (channelIt = groups.begin(); channelIt != groups.end(); ++channelIt) {
|
|
|
|
if (fi.mId1.empty()) {
|
|
|
|
/* store first channel */
|
|
|
|
fi.mId1 = channelIt->mMeta.mGroupId.toStdString();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!channelIt->mDescription.empty()) {
|
|
|
|
/* take channel with description */
|
|
|
|
fi.mId1 = channelIt->mMeta.mGroupId.toStdString();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fi.mId1.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
instance->addFeedItemChannelNew(fi);
|
|
|
|
// instance->addFeedItemChanUpdate(fi);
|
|
|
|
|
|
|
|
/* Prepare group ids for message request */
|
|
|
|
std::list<RsGxsGroupId> grpIds;
|
|
|
|
for (channelIt = groups.begin(); channelIt != groups.end(); ++channelIt) {
|
|
|
|
grpIds.push_back(channelIt->mMeta.mGroupId);
|
|
|
|
}
|
|
|
|
RsTokReqOptions opts;
|
|
|
|
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
|
|
|
opts.mOptions = RS_TOKREQOPT_MSG_THREAD;
|
|
|
|
uint32_t msgToken;
|
|
|
|
instance->mTokenQueueChannel->requestMsgInfo(msgToken, RS_TOKREQ_ANSTYPE_SUMMARY, opts, grpIds, TOKEN_TYPE_MESSAGE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NewsFeed::loadChannelPost(const uint32_t &token)
|
|
|
|
{
|
|
|
|
std::vector<RsGxsChannelPost> posts;
|
|
|
|
if (!rsGxsChannels->getPostData(token, posts)) {
|
|
|
|
std::cerr << "NewsFeed::loadChannelPost() ERROR getting data";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
RsFeedItem fi;
|
|
|
|
std::vector<RsGxsChannelPost>::iterator postIt;
|
|
|
|
for (postIt = posts.begin(); postIt != posts.end(); ++postIt) {
|
|
|
|
if (fi.mId2.empty()) {
|
|
|
|
/* store first channel message */
|
|
|
|
fi.mId1 = postIt->mMeta.mGroupId.toStdString();
|
|
|
|
fi.mId2 = postIt->mMeta.mMsgId.toStdString();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!postIt->mMsg.empty()) {
|
|
|
|
/* take channel message with description */
|
|
|
|
fi.mId1 = postIt->mMeta.mGroupId.toStdString();
|
|
|
|
fi.mId2 = postIt->mMeta.mMsgId.toStdString();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!fi.mId1.empty()) {
|
|
|
|
instance->addFeedItemChannelMsg(fi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void NewsFeed::loadForumGroup(const uint32_t &token)
|
|
|
|
{
|
|
|
|
std::vector<RsGxsForumGroup> forums;
|
|
|
|
if (!rsGxsForums->getGroupData(token, forums)) {
|
|
|
|
std::cerr << "NewsFeed::loadForumGroup() ERROR getting data";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
RsFeedItem fi;
|
|
|
|
std::vector<RsGxsForumGroup>::iterator forumIt;
|
|
|
|
for (forumIt = forums.begin(); forumIt != forums.end(); ++forumIt) {
|
|
|
|
if (fi.mId1.empty()) {
|
|
|
|
/* store first forum */
|
|
|
|
fi.mId1 = forumIt->mMeta.mGroupId.toStdString();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!forumIt->mDescription.empty()) {
|
|
|
|
/* take forum with description */
|
|
|
|
fi.mId1 = forumIt->mMeta.mGroupId.toStdString();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fi.mId1.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
instance->addFeedItemForumNew(fi);
|
|
|
|
// instance->addFeedItemForumUpdate(fi);
|
|
|
|
|
|
|
|
/* Prepare group ids for message request */
|
|
|
|
std::list<RsGxsGroupId> grpIds;
|
|
|
|
for (forumIt = forums.begin(); forumIt != forums.end(); ++forumIt) {
|
|
|
|
grpIds.push_back(forumIt->mMeta.mGroupId);
|
|
|
|
}
|
|
|
|
RsTokReqOptions opts;
|
|
|
|
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
|
|
|
opts.mOptions = RS_TOKREQOPT_MSG_THREAD;
|
|
|
|
uint32_t msgToken;
|
|
|
|
instance->mTokenQueueForum->requestMsgInfo(msgToken, RS_TOKREQ_ANSTYPE_SUMMARY, opts, grpIds, TOKEN_TYPE_MESSAGE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NewsFeed::loadForumMessage(const uint32_t &token)
|
|
|
|
{
|
|
|
|
std::vector<RsGxsForumMsg> msgs;
|
|
|
|
if (!rsGxsForums->getMsgData(token, msgs)) {
|
2014-11-20 19:50:18 -05:00
|
|
|
std::cerr << "NewsFeed::loadForumPost() ERROR getting data";
|
2014-11-17 19:49:21 -05:00
|
|
|
std::cerr << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
RsFeedItem fi;
|
|
|
|
std::vector<RsGxsForumMsg>::iterator msgIt;
|
|
|
|
for (msgIt = msgs.begin(); msgIt != msgs.end(); ++msgIt) {
|
|
|
|
if (fi.mId2.empty()) {
|
|
|
|
/* store first forum message */
|
|
|
|
fi.mId1 = msgIt->mMeta.mGroupId.toStdString();
|
|
|
|
fi.mId2 = msgIt->mMeta.mMsgId.toStdString();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!msgIt->mMsg.empty()) {
|
|
|
|
/* take forum message with description */
|
|
|
|
fi.mId1 = msgIt->mMeta.mGroupId.toStdString();
|
|
|
|
fi.mId2 = msgIt->mMeta.mMsgId.toStdString();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!fi.mId1.empty()) {
|
|
|
|
instance->addFeedItemForumMsg(fi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-20 19:50:18 -05:00
|
|
|
void NewsFeed::loadPostedGroup(const uint32_t &token)
|
|
|
|
{
|
|
|
|
std::vector<RsPostedGroup> posted;
|
|
|
|
if (!rsPosted->getGroupData(token, posted)) {
|
|
|
|
std::cerr << "NewsFeed::loadPostedGroup() ERROR getting data";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
RsFeedItem fi;
|
|
|
|
std::vector<RsPostedGroup>::iterator postedIt;
|
|
|
|
for (postedIt = posted.begin(); postedIt != posted.end(); ++postedIt) {
|
|
|
|
if (fi.mId1.empty()) {
|
|
|
|
/* store first posted */
|
|
|
|
fi.mId1 = postedIt->mMeta.mGroupId.toStdString();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!postedIt->mDescription.empty()) {
|
|
|
|
/* take posted with description */
|
|
|
|
fi.mId1 = postedIt->mMeta.mGroupId.toStdString();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fi.mId1.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
instance->addFeedItemPostedNew(fi);
|
|
|
|
// instance->addFeedItemPostedUpdate(fi);
|
|
|
|
|
|
|
|
/* Prepare group ids for message request */
|
|
|
|
std::list<RsGxsGroupId> grpIds;
|
|
|
|
for (postedIt = posted.begin(); postedIt != posted.end(); ++postedIt) {
|
|
|
|
grpIds.push_back(postedIt->mMeta.mGroupId);
|
|
|
|
}
|
|
|
|
RsTokReqOptions opts;
|
|
|
|
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
|
|
|
opts.mOptions = RS_TOKREQOPT_MSG_THREAD;
|
|
|
|
uint32_t msgToken;
|
|
|
|
instance->mTokenQueuePosted->requestMsgInfo(msgToken, RS_TOKREQ_ANSTYPE_SUMMARY, opts, grpIds, TOKEN_TYPE_MESSAGE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NewsFeed::loadPostedMessage(const uint32_t &token)
|
|
|
|
{
|
|
|
|
std::vector<RsPostedPost> msgs;
|
|
|
|
if (!rsPosted->getPostData(token, msgs)) {
|
|
|
|
std::cerr << "NewsFeed::loadPostedPost() ERROR getting data";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
RsFeedItem fi;
|
|
|
|
std::vector<RsPostedPost>::iterator msgIt;
|
|
|
|
for (msgIt = msgs.begin(); msgIt != msgs.end(); ++msgIt) {
|
|
|
|
if (fi.mId2.empty()) {
|
|
|
|
/* store first posted message */
|
|
|
|
fi.mId1 = msgIt->mMeta.mGroupId.toStdString();
|
|
|
|
fi.mId2 = msgIt->mMeta.mMsgId.toStdString();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!msgIt->mLink.empty()) {
|
|
|
|
/* take posted message with description */
|
|
|
|
fi.mId1 = msgIt->mMeta.mGroupId.toStdString();
|
|
|
|
fi.mId2 = msgIt->mMeta.mMsgId.toStdString();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!fi.mId1.empty()) {
|
|
|
|
instance->addFeedItemPostedMsg(fi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-17 19:49:21 -05:00
|
|
|
void NewsFeed::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
|
|
|
{
|
|
|
|
if (queue == mTokenQueueChannel) {
|
|
|
|
switch (req.mUserType) {
|
|
|
|
case TOKEN_TYPE_GROUP:
|
|
|
|
loadChannelGroup(req.mToken);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOKEN_TYPE_MESSAGE:
|
|
|
|
loadChannelPost(req.mToken);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
std::cerr << "NewsFeed::loadRequest() ERROR: INVALID TYPE";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (queue == mTokenQueueForum) {
|
|
|
|
switch (req.mUserType) {
|
|
|
|
case TOKEN_TYPE_GROUP:
|
|
|
|
loadForumGroup(req.mToken);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOKEN_TYPE_MESSAGE:
|
|
|
|
loadForumMessage(req.mToken);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
std::cerr << "NewsFeed::loadRequest() ERROR: INVALID TYPE";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-11-20 19:50:18 -05:00
|
|
|
|
|
|
|
if (queue == mTokenQueuePosted) {
|
|
|
|
switch (req.mUserType) {
|
|
|
|
case TOKEN_TYPE_GROUP:
|
|
|
|
loadPostedGroup(req.mToken);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TOKEN_TYPE_MESSAGE:
|
|
|
|
loadPostedMessage(req.mToken);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
std::cerr << "NewsFeed::loadRequest() ERROR: INVALID TYPE";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-11-17 19:49:21 -05:00
|
|
|
}
|
|
|
|
|
2013-01-14 17:41:31 -05:00
|
|
|
void NewsFeed::testFeed(FeedNotify *feedNotify)
|
|
|
|
{
|
|
|
|
if (!instance) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!feedNotify) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
FeedItem *feedItem = feedNotify->testFeedItem(instance);
|
2013-01-14 17:41:31 -05:00
|
|
|
if (!feedItem) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
instance->addFeedItem(feedItem);
|
|
|
|
}
|
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
void NewsFeed::addFeedItem(FeedItem *item)
|
2010-09-01 16:54:24 -04:00
|
|
|
{
|
2014-11-17 19:49:21 -05:00
|
|
|
static const int MAX_FEEDITEM_COUNT = 500 ;
|
2014-01-16 15:51:13 -05:00
|
|
|
|
2010-11-06 15:13:33 -04:00
|
|
|
item->setAttribute(Qt::WA_DeleteOnClose, true);
|
|
|
|
|
2014-01-16 15:51:13 -05:00
|
|
|
// costly, but not really a problem here
|
2014-11-15 12:24:49 -05:00
|
|
|
int feedItemCount;
|
|
|
|
bool fromTop = Settings->getAddFeedsAtEnd();
|
|
|
|
|
|
|
|
while ((feedItemCount = ui->feedWidget->feedItemCount()) >= MAX_FEEDITEM_COUNT) {
|
|
|
|
FeedItem *feedItem = ui->feedWidget->feedItem(fromTop ? 0 : feedItemCount - 1);
|
|
|
|
if (!feedItem) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ui->feedWidget->removeFeedItem(feedItem);
|
2014-01-16 15:51:13 -05:00
|
|
|
}
|
2010-11-06 15:13:33 -04:00
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
ui->feedWidget->addFeedItem(item, ROLE_RECEIVED, QDateTime::currentDateTime());
|
|
|
|
}
|
|
|
|
|
|
|
|
struct AddFeedItemIfUniqueData
|
|
|
|
{
|
|
|
|
AddFeedItemIfUniqueData(int type, const RsPeerId &sslId) : mType(type), mSslId(sslId) {}
|
2010-11-10 07:24:36 -05:00
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
int mType;
|
|
|
|
const RsPeerId &mSslId;
|
|
|
|
};
|
2012-10-08 19:06:34 -04:00
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
static bool addFeedItemIfUniqueCallback(FeedItem *feedItem, void *data)
|
|
|
|
{
|
|
|
|
AddFeedItemIfUniqueData *findData = (AddFeedItemIfUniqueData*) data;
|
|
|
|
if (!findData || findData->mSslId.isNull()) {
|
|
|
|
return false;
|
2010-09-01 16:54:24 -04:00
|
|
|
}
|
2012-10-08 19:06:34 -04:00
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
SecurityItem *secitem = dynamic_cast<SecurityItem*>(feedItem);
|
|
|
|
if (!secitem) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (secitem->isSame(findData->mSslId, findData->mType)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2010-09-01 16:54:24 -04:00
|
|
|
}
|
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
void NewsFeed::addFeedItemIfUnique(FeedItem *item, int itemType, const RsPeerId &sslId, bool replace)
|
2011-07-11 11:53:41 -04:00
|
|
|
{
|
2014-11-15 12:24:49 -05:00
|
|
|
AddFeedItemIfUniqueData data(itemType, sslId);
|
|
|
|
FeedItem *feedItem = ui->feedWidget->findFeedItem(addFeedItemIfUniqueCallback, &data);
|
|
|
|
|
|
|
|
if (feedItem) {
|
|
|
|
if (!replace) {
|
|
|
|
delete item;
|
|
|
|
return;
|
2011-07-11 11:53:41 -04:00
|
|
|
}
|
2014-11-15 12:24:49 -05:00
|
|
|
|
|
|
|
ui->feedWidget->removeFeedItem(item);
|
2011-07-11 11:53:41 -04:00
|
|
|
}
|
2013-01-08 17:07:52 -05:00
|
|
|
|
2011-07-11 11:53:41 -04:00
|
|
|
addFeedItem(item);
|
|
|
|
}
|
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
void NewsFeed::addFeedItemPeerConnect(const RsFeedItem &fi)
|
2008-06-20 08:43:23 -04:00
|
|
|
{
|
|
|
|
/* make new widget */
|
2014-11-13 17:03:12 -05:00
|
|
|
PeerItem *pi = new PeerItem(this, NEWSFEED_PEERLIST, RsPeerId(fi.mId1), PEER_TYPE_CONNECT, false);
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
/* 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
|
|
|
}
|
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
void NewsFeed::addFeedItemPeerDisconnect(const RsFeedItem &fi)
|
2008-06-20 08:43:23 -04:00
|
|
|
{
|
|
|
|
/* make new widget */
|
2014-11-13 17:03:12 -05:00
|
|
|
PeerItem *pi = new PeerItem(this, NEWSFEED_PEERLIST, RsPeerId(fi.mId1), PEER_TYPE_STD, false);
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
/* 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
|
|
|
}
|
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
void NewsFeed::addFeedItemPeerHello(const RsFeedItem &fi)
|
2008-06-20 08:43:23 -04:00
|
|
|
{
|
|
|
|
/* make new widget */
|
2014-11-13 17:03:12 -05:00
|
|
|
PeerItem *pi = new PeerItem(this, NEWSFEED_PEERLIST, RsPeerId(fi.mId1), PEER_TYPE_HELLO, false);
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
/* 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
|
|
|
}
|
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
void NewsFeed::addFeedItemPeerNew(const RsFeedItem &fi)
|
2008-06-20 08:43:23 -04:00
|
|
|
{
|
|
|
|
/* make new widget */
|
2014-11-13 17:03:12 -05:00
|
|
|
PeerItem *pi = new PeerItem(this, NEWSFEED_PEERLIST, RsPeerId(fi.mId1), PEER_TYPE_NEW_FOF, false);
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
/* 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
|
|
|
}
|
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
void NewsFeed::addFeedItemSecurityConnectAttempt(const RsFeedItem &fi)
|
2011-07-10 21:08:01 -04:00
|
|
|
{
|
|
|
|
/* make new widget */
|
2014-11-13 17:03:12 -05:00
|
|
|
SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, RsPgpId(fi.mId1), RsPeerId(fi.mId2), fi.mId3, fi.mId4, fi.mType, false);
|
2011-07-10 21:08:01 -04:00
|
|
|
|
|
|
|
/* add to layout */
|
2014-11-13 17:03:12 -05:00
|
|
|
addFeedItemIfUnique(pi, fi.mType, RsPeerId(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
|
|
|
|
}
|
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
void NewsFeed::addFeedItemSecurityAuthDenied(const RsFeedItem &fi)
|
2011-07-10 21:08:01 -04:00
|
|
|
{
|
|
|
|
/* make new widget */
|
2014-11-13 17:03:12 -05:00
|
|
|
SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, RsPgpId(fi.mId1), RsPeerId(fi.mId2), fi.mId3, fi.mId4, fi.mType, false);
|
2011-07-10 21:08:01 -04:00
|
|
|
|
|
|
|
/* add to layout */
|
2014-11-13 17:03:12 -05:00
|
|
|
addFeedItemIfUnique(pi, RS_FEED_ITEM_SEC_AUTH_DENIED, RsPeerId(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
|
|
|
|
}
|
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
void NewsFeed::addFeedItemSecurityUnknownIn(const RsFeedItem &fi)
|
2011-07-10 21:08:01 -04:00
|
|
|
{
|
|
|
|
/* make new widget */
|
2014-11-13 17:03:12 -05:00
|
|
|
SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, RsPgpId(fi.mId1), RsPeerId(fi.mId2), fi.mId3, fi.mId4, RS_FEED_ITEM_SEC_UNKNOWN_IN, false);
|
2011-07-10 21:08:01 -04:00
|
|
|
|
|
|
|
/* add to layout */
|
2014-11-13 17:03:12 -05:00
|
|
|
addFeedItemIfUnique(pi, RS_FEED_ITEM_SEC_UNKNOWN_IN, RsPeerId(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
|
|
|
|
}
|
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
void NewsFeed::addFeedItemSecurityUnknownOut(const RsFeedItem &fi)
|
2011-07-11 11:53:41 -04:00
|
|
|
{
|
|
|
|
/* make new widget */
|
2014-11-13 17:03:12 -05:00
|
|
|
SecurityItem *pi = new SecurityItem(this, NEWSFEED_SECLIST, RsPgpId(fi.mId1), RsPeerId(fi.mId2), fi.mId3, fi.mId4, RS_FEED_ITEM_SEC_UNKNOWN_OUT, false);
|
2013-01-08 17:07:52 -05:00
|
|
|
|
2011-07-11 11:53:41 -04:00
|
|
|
/* add to layout */
|
2014-11-13 17:03:12 -05:00
|
|
|
addFeedItemIfUnique(pi, RS_FEED_ITEM_SEC_UNKNOWN_OUT, RsPeerId(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
|
|
|
|
}
|
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
void NewsFeed::addFeedItemChannelNew(const RsFeedItem &fi)
|
2008-06-20 08:43:23 -04:00
|
|
|
{
|
2014-11-17 19:49:21 -05:00
|
|
|
RsGxsGroupId grpId(fi.mId1);
|
|
|
|
|
|
|
|
if (grpId.isNull()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-07-04 10:41:24 -04:00
|
|
|
/* make new widget */
|
2014-11-17 19:49:21 -05:00
|
|
|
GxsChannelGroupItem *item = new GxsChannelGroupItem(this, NEWSFEED_CHANNELNEWLIST, grpId, false, true);
|
2008-07-04 10:41:24 -04:00
|
|
|
|
|
|
|
/* add to layout */
|
2014-11-17 19:49:21 -05:00
|
|
|
addFeedItem(item);
|
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
|
|
|
}
|
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
//void NewsFeed::addFeedItemChannelUpdate(const RsFeedItem &fi)
|
2014-11-13 17:03:12 -05:00
|
|
|
//{
|
|
|
|
// /* make new widget */
|
|
|
|
// ChanNewItem *cni = new ChanNewItem(this, NEWSFEED_CHANNEWLIST, fi.mId1, false, false);
|
2008-07-04 10:41:24 -04:00
|
|
|
|
2014-11-13 17:03:12 -05:00
|
|
|
// /* add to layout */
|
|
|
|
// addFeedItem(cni);
|
2008-07-04 10:41:24 -04:00
|
|
|
|
2014-11-13 17:03:12 -05:00
|
|
|
//#ifdef NEWS_DEBUG
|
|
|
|
// std::cerr << "NewsFeed::addFeedItemChanUpdate()";
|
|
|
|
// std::cerr << std::endl;
|
|
|
|
//#endif
|
|
|
|
//}
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
void NewsFeed::addFeedItemChannelMsg(const RsFeedItem &fi)
|
2008-06-20 08:43:23 -04:00
|
|
|
{
|
2014-11-13 17:03:12 -05:00
|
|
|
RsGxsGroupId grpId(fi.mId1);
|
|
|
|
RsGxsMessageId msgId(fi.mId2);
|
|
|
|
|
|
|
|
if (grpId.isNull() || msgId.isNull()) {
|
|
|
|
return;
|
|
|
|
}
|
2008-06-24 00:36:45 -04:00
|
|
|
|
2014-11-13 17:03:12 -05:00
|
|
|
/* make new widget */
|
|
|
|
GxsChannelPostItem *item = new GxsChannelPostItem(this, NEWSFEED_CHANNELNEWLIST, grpId, msgId, false, true);
|
2008-06-24 00:36:45 -04:00
|
|
|
|
|
|
|
/* add to layout */
|
2014-11-13 17:03:12 -05:00
|
|
|
addFeedItem(item);
|
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
|
|
|
}
|
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
void NewsFeed::addFeedItemForumNew(const RsFeedItem &fi)
|
2008-06-20 08:43:23 -04:00
|
|
|
{
|
2014-11-19 07:40:42 -05:00
|
|
|
RsGxsGroupId grpId(fi.mId1);
|
|
|
|
|
|
|
|
if (grpId.isNull()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-06-20 08:43:23 -04:00
|
|
|
/* make new widget */
|
2014-11-19 07:40:42 -05:00
|
|
|
GxsForumGroupItem *item = new GxsForumGroupItem(this, NEWSFEED_FORUMNEWLIST, grpId, false, true);
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
/* add to layout */
|
2014-11-19 07:40:42 -05:00
|
|
|
addFeedItem(item);
|
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
|
|
|
}
|
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
//void NewsFeed::addFeedItemForumUpdate(const RsFeedItem &fi)
|
2014-11-13 17:03:12 -05:00
|
|
|
//{
|
|
|
|
// /* make new widget */
|
|
|
|
// ForumNewItem *fni = new ForumNewItem(this, NEWSFEED_FORUMNEWLIST, fi.mId1, false, false);
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2014-11-13 17:03:12 -05:00
|
|
|
// /* add to layout */
|
|
|
|
// addFeedItem(fni);
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2014-11-13 17:03:12 -05:00
|
|
|
//#ifdef NEWS_DEBUG
|
|
|
|
// std::cerr << "NewsFeed::addFeedItemForumUpdate()";
|
|
|
|
// std::cerr << std::endl;
|
|
|
|
//#endif
|
|
|
|
//}
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
void NewsFeed::addFeedItemForumMsg(const RsFeedItem &fi)
|
2008-06-20 08:43:23 -04:00
|
|
|
{
|
2014-11-19 07:40:42 -05:00
|
|
|
RsGxsGroupId grpId(fi.mId1);
|
|
|
|
RsGxsMessageId msgId(fi.mId2);
|
|
|
|
|
|
|
|
if (grpId.isNull() || msgId.isNull()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-06-20 08:43:23 -04:00
|
|
|
/* make new widget */
|
2014-11-19 07:40:42 -05:00
|
|
|
GxsForumMsgItem *item = new GxsForumMsgItem(this, NEWSFEED_FORUMMSGLIST, grpId, msgId, false, true);
|
2008-06-20 08:43:23 -04:00
|
|
|
|
|
|
|
/* add to layout */
|
2014-11-19 07:40:42 -05:00
|
|
|
addFeedItem(item);
|
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
|
|
|
}
|
|
|
|
|
2014-11-20 19:50:18 -05:00
|
|
|
void NewsFeed::addFeedItemPostedNew(const RsFeedItem &fi)
|
|
|
|
{
|
|
|
|
RsGxsGroupId grpId(fi.mId1);
|
|
|
|
|
|
|
|
if (grpId.isNull()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* make new widget */
|
|
|
|
PostedGroupItem *item = new PostedGroupItem(this, NEWSFEED_POSTEDNEWLIST, grpId, false, true);
|
|
|
|
|
|
|
|
/* add to layout */
|
|
|
|
addFeedItem(item);
|
|
|
|
|
|
|
|
#ifdef NEWS_DEBUG
|
|
|
|
std::cerr << "NewsFeed::addFeedItemPostedNew()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
//void NewsFeed::addFeedItemPostedUpdate(const RsFeedItem &fi)
|
|
|
|
//{
|
|
|
|
// /* make new widget */
|
|
|
|
// GxsPostedGroupItem *item = new GxsPostedGroupItem(this, NEWSFEED_POSTEDNEWLIST, grpId, false, true);
|
|
|
|
|
|
|
|
// /* add to layout */
|
|
|
|
// addFeedItem(item);
|
|
|
|
|
|
|
|
//#ifdef NEWS_DEBUG
|
|
|
|
// std::cerr << "NewsFeed::addFeedItemPostedUpdate()";
|
|
|
|
// std::cerr << std::endl;
|
|
|
|
//#endif
|
|
|
|
//}
|
|
|
|
|
|
|
|
void NewsFeed::addFeedItemPostedMsg(const RsFeedItem &fi)
|
|
|
|
{
|
|
|
|
RsGxsGroupId grpId(fi.mId1);
|
|
|
|
RsGxsMessageId msgId(fi.mId2);
|
|
|
|
|
|
|
|
if (grpId.isNull() || msgId.isNull()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* make new widget */
|
|
|
|
PostedItem *item = new PostedItem(this, NEWSFEED_POSTEDMSGLIST, grpId, msgId, false, true);
|
|
|
|
|
|
|
|
/* add to layout */
|
|
|
|
addFeedItem(item);
|
|
|
|
|
|
|
|
#ifdef NEWS_DEBUG
|
|
|
|
std::cerr << "NewsFeed::addFeedItemPostedMsg()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2014-11-13 17:03:12 -05:00
|
|
|
#if 0
|
2014-11-15 12:24:49 -05:00
|
|
|
void NewsFeed::addFeedItemBlogNew(const RsFeedItem &fi)
|
2010-05-20 17:00:59 -04:00
|
|
|
{
|
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);
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
void NewsFeed::addFeedItemBlogMsg(const RsFeedItem &fi)
|
2008-06-20 08:43:23 -04:00
|
|
|
{
|
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);
|
|
|
|
|
|
|
|
/* 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
|
|
|
}
|
|
|
|
|
2013-09-07 00:21:48 -04:00
|
|
|
#endif
|
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
void NewsFeed::addFeedItemChatNew(const 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
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
if (!addWithoutCheck && fi.mId1 == rsPeers->getOwnId().toStdString()) {
|
2010-08-31 18:42:40 -04:00
|
|
|
/* chat message from myself */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-08-31 13:13:52 -04:00
|
|
|
/* make new widget */
|
2014-11-13 17:03:12 -05:00
|
|
|
ChatMsgItem *cm = new ChatMsgItem(this, NEWSFEED_CHATMSGLIST, RsPeerId(fi.mId1), fi.mId2);
|
2010-08-31 13:13:52 -04:00
|
|
|
|
|
|
|
/* 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
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
void NewsFeed::addFeedItemMessage(const RsFeedItem &fi)
|
2008-06-20 08:43:23 -04:00
|
|
|
{
|
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
|
|
|
|
|
|
|
/* 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
|
|
|
}
|
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
void NewsFeed::addFeedItemFilesNew(const 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()
|
|
|
|
{
|
2014-11-15 12:24:49 -05:00
|
|
|
return NULL;
|
2012-10-08 19:06:34 -04:00
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
void NewsFeed::openChat(const RsPeerId &peerId)
|
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::openChat()";
|
|
|
|
std::cerr << std::endl;
|
2008-07-09 05:53:47 -04:00
|
|
|
#endif
|
2008-06-20 08:43:23 -04:00
|
|
|
|
2014-11-13 17:03:12 -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;
|
|
|
|
}
|
|
|
|
|
2014-11-15 12:24:49 -05:00
|
|
|
static void sendNewsFeedChangedCallback(FeedItem *feedItem, void *data)
|
2010-11-06 15:13:33 -04:00
|
|
|
{
|
2014-11-15 12:24:49 -05:00
|
|
|
if (dynamic_cast<PeerItem*>(feedItem) == NULL) {
|
|
|
|
/* don't count PeerItem's */
|
|
|
|
++(*((int*) data));
|
2010-11-06 15:13:33 -04:00
|
|
|
}
|
|
|
|
}
|
2010-11-10 07:24:36 -05:00
|
|
|
|
|
|
|
void NewsFeed::sendNewsFeedChanged()
|
|
|
|
{
|
|
|
|
int count = 0;
|
2014-11-15 12:24:49 -05:00
|
|
|
ui->feedWidget->withAll(sendNewsFeedChangedCallback, &count);
|
2010-11-10 07:24:36 -05:00
|
|
|
|
|
|
|
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
|
|
|
}
|