2012-06-13 20:36:25 -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
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
|
|
|
|
2012-11-12 15:47:55 -05:00
|
|
|
#include "CreateGxsForumMsg.h"
|
2012-06-13 20:36:25 -04:00
|
|
|
|
|
|
|
#include <QMenu>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QDesktopWidget>
|
|
|
|
#include <QDropEvent>
|
|
|
|
#include <QPushButton>
|
|
|
|
|
2012-11-12 15:47:55 -05:00
|
|
|
#include <retroshare/rsgxsforums.h>
|
2012-07-28 17:09:53 -04:00
|
|
|
#include <retroshare/rspeers.h>
|
2012-06-13 20:36:25 -04:00
|
|
|
|
|
|
|
#include "gui/settings/rsharesettings.h"
|
|
|
|
#include "gui/RetroShareLink.h"
|
|
|
|
#include "gui/common/Emoticons.h"
|
|
|
|
|
2012-11-19 16:35:48 -05:00
|
|
|
#include "util/HandleRichText.h"
|
2012-06-13 20:36:25 -04:00
|
|
|
#include "util/misc.h"
|
|
|
|
|
|
|
|
#include <sys/stat.h>
|
2012-07-28 17:09:53 -04:00
|
|
|
#include <iostream>
|
|
|
|
|
2012-11-12 15:47:55 -05:00
|
|
|
#define CREATEGXSFORUMMSG_FORUMINFO 1
|
|
|
|
#define CREATEGXSFORUMMSG_PARENTMSG 2
|
2012-06-13 20:36:25 -04:00
|
|
|
|
|
|
|
/** Constructor */
|
2012-11-21 13:55:52 -05:00
|
|
|
CreateGxsForumMsg::CreateGxsForumMsg(const std::string &fId, const std::string &pId)
|
|
|
|
: QDialog(NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), mForumId(fId), mParentId(pId)
|
2012-06-13 20:36:25 -04:00
|
|
|
{
|
2013-01-07 17:11:16 -05:00
|
|
|
/* Invoke the Qt Designer generated object setup routine */
|
|
|
|
ui.setupUi(this);
|
|
|
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
2012-06-13 20:36:25 -04:00
|
|
|
|
2012-07-28 17:09:53 -04:00
|
|
|
/* Setup Queue */
|
2012-11-12 15:47:55 -05:00
|
|
|
mForumQueue = new TokenQueue(rsGxsForums->getTokenService(), this);
|
|
|
|
|
2013-01-07 17:11:16 -05:00
|
|
|
QString text = pId.empty() ? tr("Start New Thread") : tr("Post Forum Message");
|
|
|
|
setWindowTitle(text);
|
2012-11-21 13:55:52 -05:00
|
|
|
|
2013-01-07 17:11:16 -05:00
|
|
|
ui.headerFrame->setHeaderImage(QPixmap(":/images/konversation64.png"));
|
|
|
|
ui.headerFrame->setHeaderText(text);
|
2012-07-28 17:09:53 -04:00
|
|
|
|
2013-01-07 17:11:16 -05:00
|
|
|
Settings->loadWidgetInformation(this);
|
2012-06-13 20:36:25 -04:00
|
|
|
|
2013-01-07 17:11:16 -05:00
|
|
|
connect(ui.forumMessage, SIGNAL( customContextMenuRequested(QPoint)), this, SLOT(forumMessageCostumPopupMenu(QPoint)));
|
2012-06-13 20:36:25 -04:00
|
|
|
|
2013-01-07 17:11:16 -05:00
|
|
|
connect(ui.hashBox, SIGNAL(fileHashingFinished(QList<HashedFile>)), this, SLOT(fileHashingFinished(QList<HashedFile>)));
|
2012-06-13 20:36:25 -04:00
|
|
|
|
2013-01-07 17:11:16 -05:00
|
|
|
// connect up the buttons.
|
|
|
|
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(createMsg()));
|
|
|
|
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(close()));
|
|
|
|
connect(ui.emoticonButton, SIGNAL(clicked()), this, SLOT(smileyWidgetForums()));
|
|
|
|
connect(ui.attachFileButton, SIGNAL(clicked()), this, SLOT(addFile()));
|
|
|
|
connect(ui.pastersButton, SIGNAL(clicked()), this, SLOT(pasteLink()));
|
2012-06-13 20:36:25 -04:00
|
|
|
|
2013-01-07 17:11:16 -05:00
|
|
|
setAcceptDrops(true);
|
|
|
|
ui.hashBox->setDropWidget(this);
|
|
|
|
ui.hashBox->setAutoHide(false);
|
2012-06-13 20:36:25 -04:00
|
|
|
|
2012-07-28 17:09:53 -04:00
|
|
|
mParentMsgLoaded = false;
|
|
|
|
mForumMetaLoaded = false;
|
|
|
|
|
2013-01-07 17:11:16 -05:00
|
|
|
newMsg();
|
|
|
|
}
|
|
|
|
|
|
|
|
CreateGxsForumMsg::~CreateGxsForumMsg()
|
|
|
|
{
|
|
|
|
delete(mForumQueue);
|
2012-06-13 20:36:25 -04:00
|
|
|
}
|
|
|
|
|
2012-11-21 13:55:52 -05:00
|
|
|
void CreateGxsForumMsg::forumMessageCostumPopupMenu(QPoint point)
|
2012-06-13 20:36:25 -04:00
|
|
|
{
|
2013-01-07 17:11:16 -05:00
|
|
|
QMenu *contextMnu = ui.forumMessage->createStandardContextMenu(point);
|
2012-06-13 20:36:25 -04:00
|
|
|
|
2013-01-07 17:11:16 -05:00
|
|
|
contextMnu->addSeparator();
|
2012-06-13 20:36:25 -04:00
|
|
|
|
2013-01-07 17:11:16 -05:00
|
|
|
QAction *pasteLinkAct = contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste RetroShare Link"), this, SLOT(pasteLink()));
|
|
|
|
QAction *pasteLinkFullAct = contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste full RetroShare Link"), this, SLOT(pasteLinkFull()));
|
|
|
|
contextMnu->addAction(QIcon(":/images/pasterslink.png"), tr("Paste my certificate link"), this, SLOT(pasteOwnCertificateLink()));
|
2012-06-13 20:36:25 -04:00
|
|
|
|
2013-01-07 17:11:16 -05:00
|
|
|
if (RSLinkClipboard::empty()) {
|
|
|
|
pasteLinkAct->setDisabled (true);
|
|
|
|
pasteLinkFullAct->setDisabled (true);
|
|
|
|
}
|
|
|
|
|
|
|
|
contextMnu->exec(QCursor::pos());
|
|
|
|
delete(contextMnu);
|
2012-06-13 20:36:25 -04:00
|
|
|
}
|
|
|
|
|
2012-11-12 15:47:55 -05:00
|
|
|
void CreateGxsForumMsg::newMsg()
|
2012-06-13 20:36:25 -04:00
|
|
|
{
|
2013-01-07 17:11:16 -05:00
|
|
|
/* clear all */
|
2012-07-28 17:09:53 -04:00
|
|
|
mParentMsgLoaded = false;
|
|
|
|
mForumMetaLoaded = false;
|
|
|
|
|
2012-11-19 17:14:45 -05:00
|
|
|
/* fill in the available OwnIds for signing */
|
|
|
|
ui.idChooser->loadIds(IDCHOOSER_ID_REQUIRED, "");
|
|
|
|
|
2013-01-07 17:11:16 -05:00
|
|
|
/* lock gui */
|
|
|
|
ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
|
|
|
ui.innerFrame->setEnabled(false);
|
|
|
|
|
|
|
|
if (mForumId.empty()) {
|
|
|
|
ui.forumName->setText(tr("No Forum"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ui.forumName->setText(tr("Loading"));
|
|
|
|
|
2012-07-28 17:09:53 -04:00
|
|
|
/* request Data */
|
|
|
|
{
|
|
|
|
RsTokReqOptions opts;
|
2013-01-07 17:11:16 -05:00
|
|
|
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
|
|
|
|
2012-07-28 17:09:53 -04:00
|
|
|
std::list<std::string> groupIds;
|
|
|
|
groupIds.push_back(mForumId);
|
2013-01-07 17:11:16 -05:00
|
|
|
|
2012-07-28 17:09:53 -04:00
|
|
|
std::cerr << "ForumsV2Dialog::newMsg() Requesting Group Summary(" << mForumId << ")";
|
|
|
|
std::cerr << std::endl;
|
2013-01-07 17:11:16 -05:00
|
|
|
|
2012-07-28 17:09:53 -04:00
|
|
|
uint32_t token;
|
2012-11-12 15:47:55 -05:00
|
|
|
mForumQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, groupIds, CREATEGXSFORUMMSG_FORUMINFO);
|
2013-01-07 17:11:16 -05:00
|
|
|
}
|
2012-07-28 17:09:53 -04:00
|
|
|
|
2013-01-07 17:11:16 -05:00
|
|
|
if (mParentId.empty())
|
|
|
|
{
|
|
|
|
mParentMsgLoaded = true;
|
2012-07-28 17:09:53 -04:00
|
|
|
}
|
2013-01-07 17:11:16 -05:00
|
|
|
else
|
2012-07-28 17:09:53 -04:00
|
|
|
{
|
|
|
|
RsTokReqOptions opts;
|
2013-01-07 17:11:16 -05:00
|
|
|
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
|
|
|
|
|
|
|
GxsMsgReq msgIds;
|
|
|
|
std::vector<RsGxsMessageId> &vect = msgIds[mForumId];
|
|
|
|
vect.push_back(mParentId);
|
|
|
|
|
2012-07-28 17:09:53 -04:00
|
|
|
std::cerr << "ForumsV2Dialog::newMsg() Requesting Parent Summary(" << mParentId << ")";
|
|
|
|
std::cerr << std::endl;
|
2013-01-07 17:11:16 -05:00
|
|
|
|
2012-07-28 17:09:53 -04:00
|
|
|
uint32_t token;
|
2013-01-07 17:11:16 -05:00
|
|
|
mForumQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, CREATEGXSFORUMMSG_PARENTMSG);
|
|
|
|
}
|
2012-07-28 17:09:53 -04:00
|
|
|
}
|
2012-06-13 20:36:25 -04:00
|
|
|
|
2012-11-12 15:47:55 -05:00
|
|
|
void CreateGxsForumMsg::saveForumInfo(const RsGroupMetaData &meta)
|
2012-07-28 17:09:53 -04:00
|
|
|
{
|
|
|
|
mForumMeta = meta;
|
|
|
|
mForumMetaLoaded = true;
|
2013-01-07 17:11:16 -05:00
|
|
|
|
2012-07-28 17:09:53 -04:00
|
|
|
loadFormInformation();
|
|
|
|
}
|
2012-06-13 20:36:25 -04:00
|
|
|
|
2012-11-12 15:47:55 -05:00
|
|
|
void CreateGxsForumMsg::saveParentMsg(const RsGxsForumMsg &msg)
|
2012-07-28 17:09:53 -04:00
|
|
|
{
|
|
|
|
mParentMsg = msg;
|
|
|
|
mParentMsgLoaded = true;
|
2013-01-07 17:11:16 -05:00
|
|
|
|
2012-07-28 17:09:53 -04:00
|
|
|
loadFormInformation();
|
|
|
|
}
|
2012-06-13 20:36:25 -04:00
|
|
|
|
2012-11-12 15:47:55 -05:00
|
|
|
void CreateGxsForumMsg::loadFormInformation()
|
2012-07-28 17:09:53 -04:00
|
|
|
{
|
2013-01-07 17:11:16 -05:00
|
|
|
if ((!mParentMsgLoaded) && (!mParentId.empty()))
|
2012-07-28 17:09:53 -04:00
|
|
|
{
|
2012-11-12 15:47:55 -05:00
|
|
|
std::cerr << "CreateGxsForumMsg::loadMsgInformation() ParentMsg not Loaded Yet";
|
2012-07-28 17:09:53 -04:00
|
|
|
std::cerr << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
2013-01-07 17:11:16 -05:00
|
|
|
|
2012-07-28 17:09:53 -04:00
|
|
|
if (!mForumMetaLoaded)
|
|
|
|
{
|
2012-11-12 15:47:55 -05:00
|
|
|
std::cerr << "CreateGxsForumMsg::loadMsgInformation() ForumMeta not Loaded Yet";
|
2012-07-28 17:09:53 -04:00
|
|
|
std::cerr << std::endl;
|
|
|
|
return;
|
|
|
|
}
|
2013-01-07 17:11:16 -05:00
|
|
|
|
|
|
|
ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
|
|
|
ui.innerFrame->setEnabled(true);
|
|
|
|
|
2012-11-12 15:47:55 -05:00
|
|
|
std::cerr << "CreateGxsForumMsg::loadMsgInformation() Data Available!";
|
2012-07-28 17:09:53 -04:00
|
|
|
std::cerr << std::endl;
|
2013-01-07 17:11:16 -05:00
|
|
|
|
2012-07-28 17:09:53 -04:00
|
|
|
QString name = QString::fromUtf8(mForumMeta.mGroupName.c_str());
|
|
|
|
QString subj;
|
2013-01-07 17:11:16 -05:00
|
|
|
if (!mParentId.empty())
|
2012-07-28 17:09:53 -04:00
|
|
|
{
|
|
|
|
QString title = QString::fromUtf8(mParentMsg.mMeta.mMsgName.c_str());
|
|
|
|
name += " " + tr("In Reply to") + ": ";
|
|
|
|
name += title;
|
2013-01-07 17:11:16 -05:00
|
|
|
|
2012-07-28 17:09:53 -04:00
|
|
|
QString text = title;
|
2013-01-07 17:11:16 -05:00
|
|
|
|
2012-07-28 17:09:53 -04:00
|
|
|
if (text.startsWith("Re:", Qt::CaseInsensitive))
|
|
|
|
{
|
|
|
|
subj = title;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
subj = "Re: " + title;
|
|
|
|
}
|
|
|
|
}
|
2013-01-07 17:11:16 -05:00
|
|
|
|
2012-07-28 17:09:53 -04:00
|
|
|
ui.forumName->setText(misc::removeNewLine(name));
|
|
|
|
ui.forumSubject->setText(misc::removeNewLine(subj));
|
2013-01-07 17:11:16 -05:00
|
|
|
|
|
|
|
if (ui.forumSubject->text().isEmpty())
|
2012-07-28 17:09:53 -04:00
|
|
|
{
|
2013-01-07 17:11:16 -05:00
|
|
|
ui.forumSubject->setFocus();
|
2012-07-28 17:09:53 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-01-07 17:11:16 -05:00
|
|
|
ui.forumMessage->setFocus();
|
2012-07-28 17:09:53 -04:00
|
|
|
}
|
2013-01-07 17:11:16 -05:00
|
|
|
|
2012-11-12 15:47:55 -05:00
|
|
|
#ifdef TOGXS
|
2012-07-28 17:09:53 -04:00
|
|
|
if (mForumMeta.mGroupFlags & RS_DISTRIB_AUTHEN_REQ)
|
2012-11-12 15:47:55 -05:00
|
|
|
#else
|
|
|
|
if (1)
|
|
|
|
#endif
|
2012-07-28 17:09:53 -04:00
|
|
|
{
|
|
|
|
ui.signBox->setChecked(true);
|
|
|
|
ui.signBox->setEnabled(false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Uncheck sign box by default for anonymous forums */
|
|
|
|
ui.signBox->setChecked(false);
|
|
|
|
ui.signBox->setEnabled(true);
|
|
|
|
}
|
2012-06-13 20:36:25 -04:00
|
|
|
|
2013-01-07 17:11:16 -05:00
|
|
|
ui.forumMessage->setText("");
|
2012-06-13 20:36:25 -04:00
|
|
|
}
|
|
|
|
|
2012-11-12 15:47:55 -05:00
|
|
|
void CreateGxsForumMsg::createMsg()
|
2012-06-13 20:36:25 -04:00
|
|
|
{
|
2013-01-07 17:11:16 -05:00
|
|
|
QString name = misc::removeNewLine(ui.forumSubject->text());
|
|
|
|
QString desc;
|
2012-06-13 20:36:25 -04:00
|
|
|
|
2012-11-19 16:35:48 -05:00
|
|
|
RsHtml::optimizeHtml(ui.forumMessage, desc);
|
2012-06-13 20:36:25 -04:00
|
|
|
|
2013-01-07 17:11:16 -05:00
|
|
|
if(name.isEmpty())
|
|
|
|
{ /* error message */
|
|
|
|
QMessageBox::warning(this, tr("RetroShare"),tr("Please set a Forum Subject and Forum Message"),
|
|
|
|
QMessageBox::Ok, QMessageBox::Ok);
|
2012-06-13 20:36:25 -04:00
|
|
|
|
2013-01-07 17:11:16 -05:00
|
|
|
return; //Don't add a empty Subject!!
|
|
|
|
}
|
2012-06-13 20:36:25 -04:00
|
|
|
|
2012-11-12 15:47:55 -05:00
|
|
|
RsGxsForumMsg msg;
|
2012-07-28 17:09:53 -04:00
|
|
|
msg.mMeta.mGroupId = mForumId;
|
|
|
|
msg.mMeta.mParentId = mParentId;
|
|
|
|
msg.mMeta.mMsgId = "";
|
|
|
|
if (mParentMsgLoaded)
|
|
|
|
{
|
|
|
|
msg.mMeta.mThreadId = mParentMsg.mMeta.mThreadId;
|
|
|
|
}
|
2013-01-07 17:11:16 -05:00
|
|
|
|
2012-07-28 17:09:53 -04:00
|
|
|
msg.mMeta.mMsgName = std::string(name.toUtf8());
|
|
|
|
msg.mMsg = std::string(desc.toUtf8());
|
2012-11-12 15:47:55 -05:00
|
|
|
#ifdef TOGXS
|
2012-07-28 17:09:53 -04:00
|
|
|
msg.mMeta.mMsgFlags = RS_DISTRIB_AUTHEN_REQ;
|
2012-11-12 15:47:55 -05:00
|
|
|
#endif
|
2013-01-07 17:11:16 -05:00
|
|
|
|
2012-07-28 17:09:53 -04:00
|
|
|
if ((msg.mMsg == "") && (msg.mMeta.mMsgName == ""))
|
2013-01-07 17:11:16 -05:00
|
|
|
return; /* do nothing */
|
2012-11-19 17:14:45 -05:00
|
|
|
|
|
|
|
if (ui.signBox->isChecked())
|
|
|
|
{
|
|
|
|
RsGxsId authorId;
|
|
|
|
if (ui.idChooser->getChosenId(authorId))
|
|
|
|
{
|
|
|
|
msg.mMeta.mAuthorId = authorId;
|
|
|
|
std::cerr << "CreateGxsForumMsg::createMsg() AuthorId: " << authorId;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::cerr << "CreateGxsForumMsg::createMsg() ERROR GETTING AuthorId!";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::cerr << "CreateGxsForumMsg::createMsg() No Signature (for now :)";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
}
|
|
|
|
|
2012-07-28 17:09:53 -04:00
|
|
|
uint32_t token;
|
2012-11-12 15:47:55 -05:00
|
|
|
rsGxsForums->createMsg(token, msg);
|
2012-07-28 17:09:53 -04:00
|
|
|
close();
|
|
|
|
}
|
2012-06-13 20:36:25 -04:00
|
|
|
|
2012-11-12 15:47:55 -05:00
|
|
|
void CreateGxsForumMsg::closeEvent (QCloseEvent * /*event*/)
|
2012-06-13 20:36:25 -04:00
|
|
|
{
|
2013-01-07 17:11:16 -05:00
|
|
|
Settings->saveWidgetInformation(this);
|
2012-06-13 20:36:25 -04:00
|
|
|
}
|
|
|
|
|
2012-11-12 15:47:55 -05:00
|
|
|
void CreateGxsForumMsg::smileyWidgetForums()
|
2012-06-13 20:36:25 -04:00
|
|
|
{
|
2013-01-07 17:11:16 -05:00
|
|
|
Emoticons::showSmileyWidget(this, ui.emoticonButton, SLOT(addSmileys()), false);
|
2012-06-13 20:36:25 -04:00
|
|
|
}
|
|
|
|
|
2012-11-12 15:47:55 -05:00
|
|
|
void CreateGxsForumMsg::addSmileys()
|
2012-06-13 20:36:25 -04:00
|
|
|
{
|
2013-01-07 17:11:16 -05:00
|
|
|
ui.forumMessage->textCursor().insertText(qobject_cast<QPushButton*>(sender())->toolTip().split("|").first());
|
2012-06-13 20:36:25 -04:00
|
|
|
}
|
|
|
|
|
2012-11-12 15:47:55 -05:00
|
|
|
void CreateGxsForumMsg::addFile()
|
2012-06-13 20:36:25 -04:00
|
|
|
{
|
2013-01-07 17:11:16 -05:00
|
|
|
QStringList files;
|
|
|
|
if (misc::getOpenFileNames(this, RshareSettings::LASTDIR_EXTRAFILE, tr("Add Extra File"), "", files)) {
|
|
|
|
ui.hashBox->addAttachments(files,RS_FILE_REQ_ANONYMOUS_ROUTING);
|
|
|
|
}
|
2012-06-13 20:36:25 -04:00
|
|
|
}
|
|
|
|
|
2012-11-12 15:47:55 -05:00
|
|
|
void CreateGxsForumMsg::fileHashingFinished(QList<HashedFile> hashedFiles)
|
2012-06-13 20:36:25 -04:00
|
|
|
{
|
2013-01-07 17:11:16 -05:00
|
|
|
std::cerr << "CreateGxsForumMsg::fileHashingFinished() started." << std::endl;
|
2012-06-13 20:36:25 -04:00
|
|
|
|
2013-01-07 17:11:16 -05:00
|
|
|
QString mesgString;
|
2012-06-13 20:36:25 -04:00
|
|
|
|
2013-01-07 17:11:16 -05:00
|
|
|
QList<HashedFile>::iterator it;
|
|
|
|
for (it = hashedFiles.begin(); it != hashedFiles.end(); ++it) {
|
|
|
|
HashedFile& hashedFile = *it;
|
|
|
|
RetroShareLink link;
|
|
|
|
if (link.createFile(hashedFile.filename, hashedFile.size, QString::fromStdString(hashedFile.hash))) {
|
|
|
|
mesgString += link.toHtmlSize() + "<br>";
|
|
|
|
}
|
|
|
|
}
|
2012-06-13 20:36:25 -04:00
|
|
|
|
|
|
|
#ifdef CHAT_DEBUG
|
2013-01-07 17:11:16 -05:00
|
|
|
std::cerr << "CreateGxsForumMsg::anchorClicked mesgString : " << mesgString.toStdString() << std::endl;
|
2012-06-13 20:36:25 -04:00
|
|
|
#endif
|
|
|
|
|
2013-01-07 17:11:16 -05:00
|
|
|
if (!mesgString.isEmpty()) {
|
|
|
|
ui.forumMessage->textCursor().insertHtml(mesgString);
|
|
|
|
}
|
2012-06-13 20:36:25 -04:00
|
|
|
|
2013-01-07 17:11:16 -05:00
|
|
|
ui.forumMessage->setFocus( Qt::OtherFocusReason );
|
2012-06-13 20:36:25 -04:00
|
|
|
}
|
|
|
|
|
2012-11-12 15:47:55 -05:00
|
|
|
void CreateGxsForumMsg::pasteLink()
|
2012-06-13 20:36:25 -04:00
|
|
|
{
|
|
|
|
ui.forumMessage->insertHtml(RSLinkClipboard::toHtml()) ;
|
|
|
|
}
|
|
|
|
|
2012-11-12 15:47:55 -05:00
|
|
|
void CreateGxsForumMsg::pasteLinkFull()
|
2012-06-13 20:36:25 -04:00
|
|
|
{
|
|
|
|
ui.forumMessage->insertHtml(RSLinkClipboard::toHtmlFull()) ;
|
|
|
|
}
|
2012-07-28 17:09:53 -04:00
|
|
|
|
2012-11-12 15:47:55 -05:00
|
|
|
void CreateGxsForumMsg::pasteOwnCertificateLink()
|
2012-07-28 17:09:53 -04:00
|
|
|
{
|
|
|
|
RetroShareLink link ;
|
|
|
|
std::string ownId = rsPeers->getOwnId() ;
|
|
|
|
if( link.createCertificate(ownId) ) {
|
|
|
|
ui.forumMessage->insertHtml(link.toHtml() + " ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-12 15:47:55 -05:00
|
|
|
void CreateGxsForumMsg::loadForumInfo(const uint32_t &token)
|
2012-07-28 17:09:53 -04:00
|
|
|
{
|
2012-11-12 15:47:55 -05:00
|
|
|
std::cerr << "CreateGxsForumMsg::loadForumInfo()";
|
2012-07-28 17:09:53 -04:00
|
|
|
std::cerr << std::endl;
|
2013-01-07 17:11:16 -05:00
|
|
|
|
2012-07-28 17:09:53 -04:00
|
|
|
std::list<RsGroupMetaData> groupInfo;
|
2012-11-12 15:47:55 -05:00
|
|
|
rsGxsForums->getGroupSummary(token, groupInfo);
|
2013-01-07 17:11:16 -05:00
|
|
|
|
2012-07-28 17:09:53 -04:00
|
|
|
if (groupInfo.size() == 1)
|
|
|
|
{
|
|
|
|
RsGroupMetaData fi = groupInfo.front();
|
|
|
|
saveForumInfo(fi);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-12 15:47:55 -05:00
|
|
|
std::cerr << "CreateGxsForumMsg::loadForumInfo() ERROR INVALID Number of Forums";
|
2012-07-28 17:09:53 -04:00
|
|
|
std::cerr << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-12 15:47:55 -05:00
|
|
|
void CreateGxsForumMsg::loadParentMsg(const uint32_t &token)
|
2012-07-28 17:09:53 -04:00
|
|
|
{
|
2012-11-12 15:47:55 -05:00
|
|
|
std::cerr << "CreateGxsForumMsg::loadParentMsg()";
|
2012-07-28 17:09:53 -04:00
|
|
|
std::cerr << std::endl;
|
2013-01-07 17:11:16 -05:00
|
|
|
|
2012-07-28 17:09:53 -04:00
|
|
|
// Only grab one.... ignore more (shouldn't be any).
|
2012-11-12 15:47:55 -05:00
|
|
|
std::vector<RsGxsForumMsg> msgs;
|
|
|
|
if (rsGxsForums->getMsgData(token, msgs))
|
|
|
|
{
|
|
|
|
if (msgs.size() != 1)
|
|
|
|
{
|
|
|
|
/* error */
|
|
|
|
std::cerr << "CreateGxsForumMsg::loadParentMsg() ERROR wrong number of msgs";
|
|
|
|
std::cerr << std::endl;
|
2013-01-07 17:11:16 -05:00
|
|
|
}
|
2012-11-12 15:47:55 -05:00
|
|
|
saveParentMsg(msgs[0]);
|
|
|
|
}
|
2012-07-28 17:09:53 -04:00
|
|
|
}
|
|
|
|
|
2012-11-12 15:47:55 -05:00
|
|
|
void CreateGxsForumMsg::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
2012-07-28 17:09:53 -04:00
|
|
|
{
|
2012-11-12 15:47:55 -05:00
|
|
|
std::cerr << "CreateGxsForum::loadRequest() UserType: " << req.mUserType;
|
2012-07-28 17:09:53 -04:00
|
|
|
std::cerr << std::endl;
|
2013-01-07 17:11:16 -05:00
|
|
|
|
2012-07-28 17:09:53 -04:00
|
|
|
if (queue == mForumQueue)
|
|
|
|
{
|
|
|
|
/* now switch on req */
|
|
|
|
switch(req.mUserType)
|
|
|
|
{
|
2012-11-12 15:47:55 -05:00
|
|
|
case CREATEGXSFORUMMSG_FORUMINFO:
|
2012-07-28 17:09:53 -04:00
|
|
|
loadForumInfo(req.mToken);
|
|
|
|
break;
|
2012-11-12 15:47:55 -05:00
|
|
|
case CREATEGXSFORUMMSG_PARENTMSG:
|
2012-07-28 17:09:53 -04:00
|
|
|
loadParentMsg(req.mToken);
|
|
|
|
break;
|
|
|
|
default:
|
2012-11-12 15:47:55 -05:00
|
|
|
std::cerr << "CreateGxsForum::loadRequest() UNKNOWN UserType ";
|
2012-07-28 17:09:53 -04:00
|
|
|
std::cerr << std::endl;
|
2013-01-07 17:11:16 -05:00
|
|
|
|
2012-07-28 17:09:53 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|