2013-03-15 17:02:43 -04:00
|
|
|
/*
|
|
|
|
* Retroshare Gxs Feed Item
|
2013-03-11 16:53:15 -04:00
|
|
|
*
|
2013-03-15 17:02:43 -04:00
|
|
|
* Copyright 2012-2013 by Robert Fernie.
|
2013-03-11 16:53:15 -04:00
|
|
|
*
|
2013-03-15 17:02:43 -04:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License Version 2.1 as published by the Free Software Foundation.
|
2013-03-11 16:53:15 -04:00
|
|
|
*
|
2013-03-15 17:02:43 -04:00
|
|
|
* This library 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
|
|
|
|
* Library General Public License for more details.
|
2013-03-11 16:53:15 -04:00
|
|
|
*
|
2013-03-15 17:02:43 -04:00
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA.
|
|
|
|
*
|
|
|
|
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
|
|
|
*
|
|
|
|
*/
|
2013-03-11 16:53:15 -04:00
|
|
|
|
|
|
|
#include <QDateTime>
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QFileInfo>
|
|
|
|
|
|
|
|
#include "rshare.h"
|
|
|
|
#include "GxsChannelPostItem.h"
|
|
|
|
|
|
|
|
#include "FeedHolder.h"
|
|
|
|
#include "SubFileItem.h"
|
|
|
|
#include "gui/notifyqt.h"
|
|
|
|
#include "util/misc.h"
|
|
|
|
#include "gui/RetroShareLink.h"
|
|
|
|
#include "util/HandleRichText.h"
|
|
|
|
#include "util/DateTime.h"
|
|
|
|
|
|
|
|
/****
|
|
|
|
* #define DEBUG_ITEM 1
|
|
|
|
****/
|
|
|
|
|
2013-03-15 17:02:43 -04:00
|
|
|
#define DEBUG_ITEM 1
|
|
|
|
|
2013-03-11 16:53:15 -04:00
|
|
|
#define COLOR_NORMAL QColor(248, 248, 248)
|
|
|
|
#define COLOR_NEW QColor(220, 236, 253)
|
|
|
|
|
|
|
|
#define SELF_LOAD 1
|
|
|
|
#define DATA_PROVIDED 2
|
|
|
|
|
2013-03-15 17:02:43 -04:00
|
|
|
|
|
|
|
GxsChannelPostItem::GxsChannelPostItem(FeedHolder *parent, uint32_t feedId, const RsGxsGroupId &groupId, const RsGxsMessageId &messageId, bool isHome)
|
|
|
|
:GxsFeedItem(parent, feedId, groupId, messageId, isHome, rsGxsChannels, true)
|
2013-03-11 16:53:15 -04:00
|
|
|
{
|
|
|
|
mMode = SELF_LOAD;
|
|
|
|
|
|
|
|
setup();
|
|
|
|
}
|
|
|
|
|
2013-03-15 17:02:43 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2013-03-11 16:53:15 -04:00
|
|
|
/** Constructor */
|
|
|
|
GxsChannelPostItem::GxsChannelPostItem(FeedHolder *parent, uint32_t feedId, const RsGxsChannelPost &post, uint32_t subFlags, bool isHome)
|
2013-03-15 17:02:43 -04:00
|
|
|
:GxsFeedItem(parent, feedId, post.mMeta.mGroupId, post.mMeta.mMsgId, isHome, rsGxsChannels, false)
|
2013-03-11 16:53:15 -04:00
|
|
|
{
|
2013-03-15 17:02:43 -04:00
|
|
|
std::cerr << "GxsChannelPostItem::GxsChannelPostItem() Direct Load";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
2013-03-11 16:53:15 -04:00
|
|
|
mMode = DATA_PROVIDED;
|
2013-03-15 17:02:43 -04:00
|
|
|
mGroupMeta.mSubscribeFlags = subFlags;
|
|
|
|
m_inUpdateItemStatic = false;
|
2013-03-11 16:53:15 -04:00
|
|
|
|
|
|
|
setup();
|
|
|
|
|
2013-03-15 17:02:43 -04:00
|
|
|
// is it because we are in the constructor?
|
2013-03-11 16:53:15 -04:00
|
|
|
loadPost(post);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GxsChannelPostItem::setup()
|
|
|
|
{
|
|
|
|
/* Invoke the Qt Designer generated object setup routine */
|
|
|
|
setupUi(this);
|
|
|
|
|
|
|
|
setAttribute ( Qt::WA_DeleteOnClose, true );
|
|
|
|
|
|
|
|
m_inUpdateItemStatic = false;
|
|
|
|
|
|
|
|
/* general ones */
|
|
|
|
connect( expandButton, SIGNAL( clicked( void ) ), this, SLOT( toggle ( void ) ) );
|
|
|
|
connect( clearButton, SIGNAL( clicked( void ) ), this, SLOT( removeItem ( void ) ) );
|
|
|
|
|
|
|
|
/* specific */
|
|
|
|
connect(readAndClearButton, SIGNAL(clicked()), this, SLOT(readAndClearItem()));
|
|
|
|
connect( unsubscribeButton, SIGNAL( clicked( void ) ), this, SLOT( unsubscribeChannel ( void ) ) );
|
|
|
|
|
2013-03-12 20:33:14 -04:00
|
|
|
connect( downloadButton, SIGNAL( clicked( void ) ), this, SLOT( download ( void ) ) );
|
2013-03-11 16:53:15 -04:00
|
|
|
// HACK FOR NOW.
|
2013-03-15 17:02:43 -04:00
|
|
|
connect( commentButton, SIGNAL( clicked( void ) ), this, SLOT( loadComments ( void ) ) );
|
2013-03-11 16:53:15 -04:00
|
|
|
|
|
|
|
connect( playButton, SIGNAL( clicked( void ) ), this, SLOT( play ( void ) ) );
|
|
|
|
connect( copyLinkButton, SIGNAL( clicked( void ) ), this, SLOT( copyLink ( void ) ) );
|
|
|
|
|
|
|
|
connect( readButton, SIGNAL( toggled(bool) ), this, SLOT( readToggled(bool) ) );
|
|
|
|
connect( NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int)), Qt::QueuedConnection);
|
|
|
|
|
|
|
|
downloadButton->hide();
|
|
|
|
playButton->hide();
|
|
|
|
warn_image_label->hide();
|
|
|
|
warning_label->hide();
|
|
|
|
|
|
|
|
titleLabel->setMinimumWidth(100);
|
|
|
|
subjectLabel->setMinimumWidth(100);
|
|
|
|
warning_label->setMinimumWidth(100);
|
|
|
|
|
|
|
|
frame->setProperty("state", "");
|
|
|
|
QPalette palette = frame->palette();
|
|
|
|
palette.setColor(frame->backgroundRole(), COLOR_NORMAL);
|
|
|
|
frame->setPalette(palette);
|
|
|
|
|
|
|
|
expandFrame->hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-03-15 17:02:43 -04:00
|
|
|
void GxsChannelPostItem::loadComments()
|
2013-03-11 16:53:15 -04:00
|
|
|
{
|
2013-03-15 17:02:43 -04:00
|
|
|
QString title = QString::fromUtf8(mPost.mMeta.mMsgName.c_str());
|
|
|
|
comments(title);
|
|
|
|
}
|
2013-03-11 16:53:15 -04:00
|
|
|
|
|
|
|
|
2013-03-15 17:02:43 -04:00
|
|
|
void GxsChannelPostItem::loadMessage(const uint32_t &token)
|
|
|
|
{
|
|
|
|
std::cerr << "GxsChannelPostItem::loadMessage()";
|
|
|
|
std::cerr << std::endl;
|
2013-03-11 16:53:15 -04:00
|
|
|
|
2013-03-15 17:02:43 -04:00
|
|
|
std::vector<RsGxsChannelPost> posts;
|
|
|
|
if (!rsGxsChannels->getPostData(token, posts))
|
2013-03-11 16:53:15 -04:00
|
|
|
{
|
2013-03-15 17:02:43 -04:00
|
|
|
std::cerr << "GxsChannelPostItem::loadMessage() ERROR getting data";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
return;
|
2013-03-11 16:53:15 -04:00
|
|
|
}
|
2013-03-15 17:02:43 -04:00
|
|
|
|
|
|
|
if (posts.size() != 1)
|
2013-03-11 16:53:15 -04:00
|
|
|
{
|
2013-03-15 17:02:43 -04:00
|
|
|
std::cerr << "GxsChannelPostItem::loadMessage() Wrong number of Items";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
return;
|
2013-03-11 16:53:15 -04:00
|
|
|
}
|
|
|
|
|
2013-03-15 17:02:43 -04:00
|
|
|
loadPost(posts[0]);
|
2013-03-12 20:33:14 -04:00
|
|
|
|
2013-03-15 17:02:43 -04:00
|
|
|
updateItem();
|
2013-03-11 16:53:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void GxsChannelPostItem::loadPost(const RsGxsChannelPost &post)
|
|
|
|
{
|
|
|
|
/* fill in */
|
|
|
|
#ifdef DEBUG_ITEM
|
|
|
|
std::cerr << "GxsChannelPostItem::loadPost()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
|
2013-03-15 17:02:43 -04:00
|
|
|
m_inUpdateItemStatic = true;
|
|
|
|
|
|
|
|
mPost = post;
|
|
|
|
|
2013-03-11 16:53:15 -04:00
|
|
|
QString title;
|
|
|
|
|
|
|
|
if (!mIsHome)
|
|
|
|
{
|
|
|
|
title = tr("Channel Feed") + ": ";
|
|
|
|
RetroShareLink link;
|
|
|
|
link.createChannel(post.mMeta.mGroupId, "");
|
|
|
|
title += link.toHtml();
|
|
|
|
titleLabel->setText(title);
|
|
|
|
RetroShareLink msgLink;
|
|
|
|
msgLink.createChannel(post.mMeta.mGroupId, post.mMeta.mMsgId);
|
|
|
|
subjectLabel->setText(msgLink.toHtml());
|
|
|
|
|
|
|
|
if (IS_GROUP_SUBSCRIBED(mSubscribeFlags) || IS_GROUP_ADMIN(mSubscribeFlags))
|
|
|
|
{
|
|
|
|
unsubscribeButton->setEnabled(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
unsubscribeButton->setEnabled(false);
|
|
|
|
}
|
|
|
|
readButton->hide();
|
2013-03-12 20:33:14 -04:00
|
|
|
//newLabel->hide();
|
2013-03-11 16:53:15 -04:00
|
|
|
copyLinkButton->hide();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* subject */
|
|
|
|
titleLabel->setText(QString::fromUtf8(post.mMeta.mMsgName.c_str()));
|
|
|
|
subjectLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(post.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
|
|
|
|
|
|
|
|
/* disable buttons: deletion facility not enabled with cache services yet */
|
|
|
|
clearButton->setEnabled(false);
|
|
|
|
unsubscribeButton->setEnabled(false);
|
|
|
|
clearButton->hide();
|
|
|
|
readAndClearButton->hide();
|
|
|
|
unsubscribeButton->hide();
|
|
|
|
copyLinkButton->show();
|
|
|
|
|
2013-03-15 17:02:43 -04:00
|
|
|
if (IS_GROUP_SUBSCRIBED(mGroupMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroupMeta.mSubscribeFlags))
|
2013-03-11 16:53:15 -04:00
|
|
|
{
|
|
|
|
|
|
|
|
readButton->setVisible(true);
|
2013-03-15 17:02:43 -04:00
|
|
|
#if 0
|
2013-03-11 16:53:15 -04:00
|
|
|
uint32_t status = 0;
|
|
|
|
rsChannels->getMessageStatus(mChanId, mMsgId, status);
|
2013-03-16 08:28:14 -04:00
|
|
|
#endif
|
2013-03-11 16:53:15 -04:00
|
|
|
|
|
|
|
if (IS_MSG_UNREAD(post.mMeta.mMsgStatus) || IS_MSG_NEW(post.mMeta.mMsgStatus))
|
|
|
|
{
|
|
|
|
readButton->setChecked(true);
|
|
|
|
readButton->setIcon(QIcon(":/images/message-state-unread.png"));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
readButton->setChecked(false);
|
|
|
|
readButton->setIcon(QIcon(":/images/message-state-read.png"));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool newState;
|
|
|
|
QColor color;
|
|
|
|
if (!IS_MSG_UNREAD(post.mMeta.mMsgStatus))
|
|
|
|
{
|
2013-03-12 20:33:14 -04:00
|
|
|
//newLabel->setVisible(false);
|
2013-03-11 16:53:15 -04:00
|
|
|
newState = false;
|
|
|
|
color = COLOR_NORMAL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-03-12 20:33:14 -04:00
|
|
|
//newLabel->setVisible(true);
|
2013-03-11 16:53:15 -04:00
|
|
|
newState = true;
|
|
|
|
color = COLOR_NEW;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* unpolish widget to clear the stylesheet's palette cache */
|
|
|
|
frame->style()->unpolish(frame);
|
|
|
|
|
|
|
|
QPalette palette = frame->palette();
|
|
|
|
palette.setColor(frame->backgroundRole(), color);
|
|
|
|
frame->setPalette(palette);
|
|
|
|
|
|
|
|
frame->setProperty("new", newState);
|
|
|
|
Rshare::refreshStyleSheet(frame, false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
readButton->setVisible(false);
|
2013-03-12 20:33:14 -04:00
|
|
|
//newLabel->setVisible(false);
|
2013-03-11 16:53:15 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
msgLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(post.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
|
|
|
|
msgFrame->setVisible(!post.mMsg.empty());
|
|
|
|
|
|
|
|
datetimelabel->setText(DateTime::formatLongDateTime(post.mMeta.mPublishTs));
|
|
|
|
|
|
|
|
filelabel->setText(QString("(%1 %2) %3").arg(post.mCount).arg(tr("Files")).arg(misc::friendlyUnit(post.mSize)));
|
|
|
|
|
|
|
|
if (mFileItems.empty() == false) {
|
|
|
|
std::list<SubFileItem *>::iterator it;
|
|
|
|
for(it = mFileItems.begin(); it != mFileItems.end(); it++)
|
|
|
|
{
|
|
|
|
delete(*it);
|
|
|
|
}
|
|
|
|
mFileItems.clear();
|
|
|
|
}
|
|
|
|
|
2013-03-12 20:33:14 -04:00
|
|
|
std::list<RsGxsFile>::const_iterator it;
|
|
|
|
for(it = post.mFiles.begin(); it != post.mFiles.end(); it++)
|
2013-03-11 16:53:15 -04:00
|
|
|
{
|
|
|
|
/* add file */
|
2013-03-12 20:33:14 -04:00
|
|
|
std::string path;
|
|
|
|
SubFileItem *fi = new SubFileItem(it->mHash, it->mName, path, it->mSize,
|
2013-03-11 16:53:15 -04:00
|
|
|
SFI_STATE_REMOTE | SFI_TYPE_CHANNEL, "");
|
|
|
|
mFileItems.push_back(fi);
|
|
|
|
|
|
|
|
/* check if the file is a media file */
|
2013-03-12 20:33:14 -04:00
|
|
|
if (!misc::isPreviewable(QFileInfo(QString::fromUtf8(it->mName.c_str())).suffix()))
|
2013-03-11 16:53:15 -04:00
|
|
|
fi->mediatype();
|
|
|
|
|
|
|
|
|
|
|
|
QLayout *layout = expandFrame->layout();
|
|
|
|
layout->addWidget(fi);
|
|
|
|
}
|
|
|
|
|
2013-03-12 20:33:14 -04:00
|
|
|
if(post.mThumbnail.mData != NULL)
|
2013-03-11 16:53:15 -04:00
|
|
|
{
|
|
|
|
QPixmap thumbnail;
|
2013-03-12 20:33:14 -04:00
|
|
|
thumbnail.loadFromData(post.mThumbnail.mData, post.mThumbnail.mSize, "PNG");
|
2013-03-15 17:02:43 -04:00
|
|
|
// Wiping data - as its been passed to thumbnail.
|
2013-03-11 16:53:15 -04:00
|
|
|
logoLabel->setPixmap(thumbnail);
|
|
|
|
}
|
2013-03-15 17:02:43 -04:00
|
|
|
|
|
|
|
m_inUpdateItemStatic = false;
|
2013-03-11 16:53:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void GxsChannelPostItem::setFileCleanUpWarning(uint32_t time_left)
|
|
|
|
{
|
|
|
|
int hours = (int)time_left/3600;
|
|
|
|
int minutes = (time_left - hours*3600)%60;
|
|
|
|
|
|
|
|
warning_label->setText(tr("Warning! You have less than %1 hours and %2 minute before this file is deleted Consider saving it.").arg(
|
|
|
|
QString::number(hours)).arg(QString::number(minutes)));
|
|
|
|
|
|
|
|
QFont warnFont = warning_label->font();
|
|
|
|
warnFont.setBold(true);
|
|
|
|
warning_label->setFont(warnFont);
|
|
|
|
|
|
|
|
warn_image_label->setVisible(true);
|
|
|
|
warning_label->setVisible(true);
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void GxsChannelPostItem::updateItem()
|
|
|
|
{
|
|
|
|
/* fill in */
|
|
|
|
#ifdef DEBUG_ITEM
|
|
|
|
std::cerr << "GxsChannelPostItem::updateItem()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
int msec_rate = 10000;
|
|
|
|
|
|
|
|
int downloadCount = 0;
|
|
|
|
int downloadStartable = 0;
|
|
|
|
int playCount = 0;
|
|
|
|
int playStartable = 0;
|
|
|
|
bool startable;
|
|
|
|
bool loopAgain = false;
|
|
|
|
|
|
|
|
/* Very slow Tick to check when all files are downloaded */
|
|
|
|
std::list<SubFileItem *>::iterator it;
|
|
|
|
for(it = mFileItems.begin(); it != mFileItems.end(); it++)
|
|
|
|
{
|
|
|
|
SubFileItem *item = *it;
|
|
|
|
|
|
|
|
if (item->isDownloadable(startable)) {
|
|
|
|
downloadCount++;
|
|
|
|
if (startable) {
|
|
|
|
downloadStartable++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (item->isPlayable(startable)) {
|
|
|
|
playCount++;
|
|
|
|
if (startable) {
|
|
|
|
playStartable++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!item->done())
|
|
|
|
{
|
|
|
|
/* loop again */
|
|
|
|
loopAgain = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (downloadCount) {
|
|
|
|
downloadButton->show();
|
|
|
|
|
|
|
|
if (downloadStartable) {
|
|
|
|
downloadButton->setEnabled(true);
|
|
|
|
} else {
|
|
|
|
downloadButton->setEnabled(false);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
downloadButton->hide();
|
|
|
|
}
|
|
|
|
if (playCount) {
|
|
|
|
/* one file is playable */
|
|
|
|
playButton->show();
|
|
|
|
|
|
|
|
if (playStartable == 1) {
|
|
|
|
playButton->setEnabled(true);
|
|
|
|
} else {
|
|
|
|
playButton->setEnabled(false);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
playButton->hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (loopAgain) {
|
|
|
|
QTimer::singleShot( msec_rate, this, SLOT(updateItem( void ) ));
|
|
|
|
}
|
|
|
|
|
|
|
|
// HACK TO DISPLAY COMMENT BUTTON FOR NOW.
|
2013-03-15 17:02:43 -04:00
|
|
|
//downloadButton->show();
|
|
|
|
//downloadButton->setEnabled(true);
|
2013-03-11 16:53:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void GxsChannelPostItem::toggle()
|
|
|
|
{
|
2013-03-15 17:02:43 -04:00
|
|
|
if (mParent)
|
|
|
|
{
|
|
|
|
mParent->lockLayout(this, true);
|
|
|
|
}
|
2013-03-11 16:53:15 -04:00
|
|
|
|
|
|
|
if (expandFrame->isHidden())
|
|
|
|
{
|
|
|
|
expandFrame->show();
|
|
|
|
expandButton->setIcon(QIcon(QString(":/images/edit_remove24.png")));
|
|
|
|
expandButton->setToolTip(tr("Hide"));
|
|
|
|
|
|
|
|
readToggled(false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
expandFrame->hide();
|
|
|
|
expandButton->setIcon(QIcon(QString(":/images/edit_add24.png")));
|
|
|
|
expandButton->setToolTip(tr("Expand"));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mParent)
|
|
|
|
{
|
2013-03-15 17:02:43 -04:00
|
|
|
mParent->lockLayout(this, false);
|
2013-03-11 16:53:15 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********** SPECIFIC FUNCTIONS ***********************/
|
|
|
|
|
|
|
|
void GxsChannelPostItem::readAndClearItem()
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_ITEM
|
|
|
|
std::cerr << "GxsChannelPostItem::readAndClearItem()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
readToggled(false);
|
|
|
|
removeItem();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GxsChannelPostItem::unsubscribeChannel()
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_ITEM
|
|
|
|
std::cerr << "GxsChannelPostItem::unsubscribeChannel()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
#endif
|
|
|
|
|
2013-03-15 17:02:43 -04:00
|
|
|
unsubscribe();
|
2013-03-11 16:53:15 -04:00
|
|
|
updateItemStatic();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GxsChannelPostItem::download()
|
|
|
|
{
|
|
|
|
std::list<SubFileItem *>::iterator it;
|
|
|
|
for(it = mFileItems.begin(); it != mFileItems.end(); it++)
|
|
|
|
{
|
|
|
|
(*it)->download();
|
|
|
|
}
|
|
|
|
|
|
|
|
updateItem();
|
|
|
|
}
|
|
|
|
|
|
|
|
void GxsChannelPostItem::play()
|
|
|
|
{
|
|
|
|
std::list<SubFileItem *>::iterator it;
|
|
|
|
for(it = mFileItems.begin(); it != mFileItems.end(); it++)
|
|
|
|
{
|
|
|
|
bool startable;
|
|
|
|
if ((*it)->isPlayable(startable) && startable) {
|
|
|
|
(*it)->play();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GxsChannelPostItem::readToggled(bool checked)
|
|
|
|
{
|
2013-03-15 17:02:43 -04:00
|
|
|
|
|
|
|
#if 0
|
2013-03-11 16:53:15 -04:00
|
|
|
if (m_inUpdateItemStatic) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set always as read ... */
|
|
|
|
uint32_t statusNew = CHANNEL_MSG_STATUS_READ;
|
|
|
|
if (checked) {
|
|
|
|
/* ... and as unread by user */
|
|
|
|
statusNew |= CHANNEL_MSG_STATUS_UNREAD_BY_USER;
|
|
|
|
} else {
|
|
|
|
/* ... and as read by user */
|
|
|
|
statusNew &= ~CHANNEL_MSG_STATUS_UNREAD_BY_USER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mIsHome) {
|
|
|
|
disconnect( NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int)));
|
|
|
|
}
|
|
|
|
rsChannels->setMessageStatus(mChanId, mMsgId, statusNew, CHANNEL_MSG_STATUS_READ | CHANNEL_MSG_STATUS_UNREAD_BY_USER);
|
|
|
|
if (!mIsHome) {
|
|
|
|
connect( NotifyQt::getInstance(), SIGNAL(channelMsgReadSatusChanged(QString,QString,int)), this, SLOT(channelMsgReadSatusChanged(QString,QString,int)), Qt::QueuedConnection);
|
|
|
|
}
|
2013-03-15 17:02:43 -04:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2013-03-11 16:53:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void GxsChannelPostItem::channelMsgReadSatusChanged(const QString& channelId, const QString& msgId, int status)
|
|
|
|
{
|
2013-03-15 17:02:43 -04:00
|
|
|
|
|
|
|
#if 0
|
2013-03-11 16:53:15 -04:00
|
|
|
if (channelId.toStdString() == mChanId && msgId.toStdString() == mMsgId) {
|
|
|
|
if (!mIsHome) {
|
|
|
|
if (status & CHANNEL_MSG_STATUS_READ) {
|
|
|
|
close();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
updateItemStatic();
|
|
|
|
}
|
2013-03-15 17:02:43 -04:00
|
|
|
#endif
|
|
|
|
|
2013-03-11 16:53:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void GxsChannelPostItem::copyLink()
|
|
|
|
{
|
2013-03-15 17:02:43 -04:00
|
|
|
|
|
|
|
#if 0
|
2013-03-11 16:53:15 -04:00
|
|
|
if (mChanId.empty() || mMsgId.empty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ChannelMsgInfo cmi;
|
|
|
|
if (rsChannels->getChannelMessage(mChanId, mMsgId, cmi)) {
|
|
|
|
RetroShareLink link;
|
|
|
|
if (link.createChannel(cmi.channelId, cmi.msgId)) {
|
|
|
|
QList<RetroShareLink> urls;
|
|
|
|
urls.push_back(link);
|
|
|
|
RSLinkClipboard::copyLinks(urls);
|
|
|
|
}
|
|
|
|
}
|
2013-03-15 17:02:43 -04:00
|
|
|
#endif
|
|
|
|
|
2013-03-11 16:53:15 -04:00
|
|
|
}
|