mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-06 16:15:23 -04:00
GxsForums:
- Fixed expand new messages - Fixed creating of thread/post messages git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6065 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
84c910672e
commit
f12473f7f7
5 changed files with 402 additions and 362 deletions
|
@ -41,118 +41,133 @@
|
|||
#include <sys/stat.h>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
#define CREATEGXSFORUMMSG_FORUMINFO 1
|
||||
#define CREATEGXSFORUMMSG_PARENTMSG 2
|
||||
|
||||
|
||||
/** Constructor */
|
||||
CreateGxsForumMsg::CreateGxsForumMsg(const std::string &fId, const std::string &pId)
|
||||
: QDialog(NULL, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint), mForumId(fId), mParentId(pId)
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
|
||||
/* Setup Queue */
|
||||
mForumQueue = new TokenQueue(rsGxsForums->getTokenService(), this);
|
||||
|
||||
QString text = pId.empty() ? tr("Start New Thread") : tr("Post Forum Message");
|
||||
setWindowTitle(text);
|
||||
QString text = pId.empty() ? tr("Start New Thread") : tr("Post Forum Message");
|
||||
setWindowTitle(text);
|
||||
|
||||
ui.headerFrame->setHeaderImage(QPixmap(":/images/konversation64.png"));
|
||||
ui.headerFrame->setHeaderText(text);
|
||||
ui.headerFrame->setHeaderImage(QPixmap(":/images/konversation64.png"));
|
||||
ui.headerFrame->setHeaderText(text);
|
||||
|
||||
Settings->loadWidgetInformation(this);
|
||||
Settings->loadWidgetInformation(this);
|
||||
|
||||
connect( ui.forumMessage, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( forumMessageCostumPopupMenu( QPoint ) ) );
|
||||
connect(ui.forumMessage, SIGNAL( customContextMenuRequested(QPoint)), this, SLOT(forumMessageCostumPopupMenu(QPoint)));
|
||||
|
||||
connect(ui.hashBox, SIGNAL(fileHashingFinished(QList<HashedFile>)), this, SLOT(fileHashingFinished(QList<HashedFile>)));
|
||||
connect(ui.hashBox, SIGNAL(fileHashingFinished(QList<HashedFile>)), this, SLOT(fileHashingFinished(QList<HashedFile>)));
|
||||
|
||||
// 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()));
|
||||
// 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()));
|
||||
|
||||
setAcceptDrops(true);
|
||||
ui.hashBox->setDropWidget(this);
|
||||
ui.hashBox->setAutoHide(false);
|
||||
setAcceptDrops(true);
|
||||
ui.hashBox->setDropWidget(this);
|
||||
ui.hashBox->setAutoHide(false);
|
||||
|
||||
mParentMsgLoaded = false;
|
||||
mForumMetaLoaded = false;
|
||||
|
||||
newMsg();
|
||||
newMsg();
|
||||
}
|
||||
|
||||
CreateGxsForumMsg::~CreateGxsForumMsg()
|
||||
{
|
||||
delete(mForumQueue);
|
||||
}
|
||||
|
||||
/** context menu searchTablewidget2 **/
|
||||
void CreateGxsForumMsg::forumMessageCostumPopupMenu(QPoint point)
|
||||
{
|
||||
QMenu *contextMnu = ui.forumMessage->createStandardContextMenu(point);
|
||||
QMenu *contextMnu = ui.forumMessage->createStandardContextMenu(point);
|
||||
|
||||
contextMnu->addSeparator();
|
||||
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()));
|
||||
contextMnu->addSeparator();
|
||||
|
||||
if (RSLinkClipboard::empty()) {
|
||||
pasteLinkAct->setDisabled (true);
|
||||
pasteLinkFullAct->setDisabled (true);
|
||||
}
|
||||
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()));
|
||||
|
||||
contextMnu->exec(QCursor::pos());
|
||||
delete(contextMnu);
|
||||
if (RSLinkClipboard::empty()) {
|
||||
pasteLinkAct->setDisabled (true);
|
||||
pasteLinkFullAct->setDisabled (true);
|
||||
}
|
||||
|
||||
contextMnu->exec(QCursor::pos());
|
||||
delete(contextMnu);
|
||||
}
|
||||
|
||||
void CreateGxsForumMsg::newMsg()
|
||||
{
|
||||
/* clear all */
|
||||
/* clear all */
|
||||
mParentMsgLoaded = false;
|
||||
mForumMetaLoaded = false;
|
||||
|
||||
/* fill in the available OwnIds for signing */
|
||||
ui.idChooser->loadIds(IDCHOOSER_ID_REQUIRED, "");
|
||||
|
||||
/* 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"));
|
||||
|
||||
/* request Data */
|
||||
{
|
||||
RsTokReqOptions opts;
|
||||
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_META;
|
||||
|
||||
std::list<std::string> groupIds;
|
||||
groupIds.push_back(mForumId);
|
||||
|
||||
|
||||
std::cerr << "ForumsV2Dialog::newMsg() Requesting Group Summary(" << mForumId << ")";
|
||||
std::cerr << std::endl;
|
||||
|
||||
|
||||
uint32_t token;
|
||||
mForumQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_SUMMARY, opts, groupIds, CREATEGXSFORUMMSG_FORUMINFO);
|
||||
|
||||
}
|
||||
|
||||
if (mParentId != "")
|
||||
|
||||
if (mParentId.empty())
|
||||
{
|
||||
mParentMsgLoaded = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
RsTokReqOptions opts;
|
||||
|
||||
std::list<std::string> msgIds;
|
||||
msgIds.push_back(mParentId);
|
||||
|
||||
opts.mReqType = GXS_REQUEST_TYPE_MSG_DATA;
|
||||
|
||||
GxsMsgReq msgIds;
|
||||
std::vector<RsGxsMessageId> &vect = msgIds[mForumId];
|
||||
vect.push_back(mParentId);
|
||||
|
||||
std::cerr << "ForumsV2Dialog::newMsg() Requesting Parent Summary(" << mParentId << ")";
|
||||
std::cerr << std::endl;
|
||||
|
||||
uint32_t token;
|
||||
#ifdef TOGXS
|
||||
mForumQueue->requestMsgRelatedInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, CREATEGXSFORUMMSG_PARENTMSG);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t token;
|
||||
mForumQueue->requestMsgInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, msgIds, CREATEGXSFORUMMSG_PARENTMSG);
|
||||
}
|
||||
}
|
||||
|
||||
void CreateGxsForumMsg::saveForumInfo(const RsGroupMetaData &meta)
|
||||
{
|
||||
mForumMeta = meta;
|
||||
mForumMetaLoaded = true;
|
||||
|
||||
|
||||
loadFormInformation();
|
||||
}
|
||||
|
||||
|
@ -160,39 +175,42 @@ void CreateGxsForumMsg::saveParentMsg(const RsGxsForumMsg &msg)
|
|||
{
|
||||
mParentMsg = msg;
|
||||
mParentMsgLoaded = true;
|
||||
|
||||
|
||||
loadFormInformation();
|
||||
}
|
||||
|
||||
void CreateGxsForumMsg::loadFormInformation()
|
||||
{
|
||||
if ((!mParentMsgLoaded) && (mParentId != ""))
|
||||
if ((!mParentMsgLoaded) && (!mParentId.empty()))
|
||||
{
|
||||
std::cerr << "CreateGxsForumMsg::loadMsgInformation() ParentMsg not Loaded Yet";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!mForumMetaLoaded)
|
||||
{
|
||||
std::cerr << "CreateGxsForumMsg::loadMsgInformation() ForumMeta not Loaded Yet";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ui.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
ui.innerFrame->setEnabled(true);
|
||||
|
||||
std::cerr << "CreateGxsForumMsg::loadMsgInformation() Data Available!";
|
||||
std::cerr << std::endl;
|
||||
|
||||
|
||||
QString name = QString::fromUtf8(mForumMeta.mGroupName.c_str());
|
||||
QString subj;
|
||||
if (mParentId != "")
|
||||
if (!mParentId.empty())
|
||||
{
|
||||
QString title = QString::fromUtf8(mParentMsg.mMeta.mMsgName.c_str());
|
||||
name += " " + tr("In Reply to") + ": ";
|
||||
name += title;
|
||||
|
||||
|
||||
QString text = title;
|
||||
|
||||
|
||||
if (text.startsWith("Re:", Qt::CaseInsensitive))
|
||||
{
|
||||
subj = title;
|
||||
|
@ -201,21 +219,20 @@ void CreateGxsForumMsg::loadFormInformation()
|
|||
{
|
||||
subj = "Re: " + title;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
ui.forumName->setText(misc::removeNewLine(name));
|
||||
ui.forumSubject->setText(misc::removeNewLine(subj));
|
||||
|
||||
if (!ui.forumSubject->text().isEmpty())
|
||||
{
|
||||
ui.forumMessage->setFocus();
|
||||
}
|
||||
else
|
||||
|
||||
if (ui.forumSubject->text().isEmpty())
|
||||
{
|
||||
ui.forumSubject->setFocus();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
ui.forumMessage->setFocus();
|
||||
}
|
||||
|
||||
#ifdef TOGXS
|
||||
if (mForumMeta.mGroupFlags & RS_DISTRIB_AUTHEN_REQ)
|
||||
#else
|
||||
|
@ -232,25 +249,23 @@ void CreateGxsForumMsg::loadFormInformation()
|
|||
ui.signBox->setEnabled(true);
|
||||
}
|
||||
|
||||
ui.forumMessage->setText("");
|
||||
ui.forumMessage->setText("");
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CreateGxsForumMsg::createMsg()
|
||||
{
|
||||
QString name = misc::removeNewLine(ui.forumSubject->text());
|
||||
QString desc;
|
||||
QString name = misc::removeNewLine(ui.forumSubject->text());
|
||||
QString desc;
|
||||
|
||||
RsHtml::optimizeHtml(ui.forumMessage, desc);
|
||||
|
||||
if(name.isEmpty())
|
||||
{ /* error message */
|
||||
QMessageBox::warning(this, tr("RetroShare"),tr("Please set a Forum Subject and Forum Message"),
|
||||
QMessageBox::Ok, QMessageBox::Ok);
|
||||
if(name.isEmpty())
|
||||
{ /* error message */
|
||||
QMessageBox::warning(this, tr("RetroShare"),tr("Please set a Forum Subject and Forum Message"),
|
||||
QMessageBox::Ok, QMessageBox::Ok);
|
||||
|
||||
return; //Don't add a empty Subject!!
|
||||
}
|
||||
return; //Don't add a empty Subject!!
|
||||
}
|
||||
|
||||
RsGxsForumMsg msg;
|
||||
msg.mMeta.mGroupId = mForumId;
|
||||
|
@ -260,15 +275,15 @@ void CreateGxsForumMsg::createMsg()
|
|||
{
|
||||
msg.mMeta.mThreadId = mParentMsg.mMeta.mThreadId;
|
||||
}
|
||||
|
||||
|
||||
msg.mMeta.mMsgName = std::string(name.toUtf8());
|
||||
msg.mMsg = std::string(desc.toUtf8());
|
||||
#ifdef TOGXS
|
||||
msg.mMeta.mMsgFlags = RS_DISTRIB_AUTHEN_REQ;
|
||||
#endif
|
||||
|
||||
|
||||
if ((msg.mMsg == "") && (msg.mMeta.mMsgName == ""))
|
||||
return; /* do nothing */
|
||||
return; /* do nothing */
|
||||
|
||||
if (ui.signBox->isChecked())
|
||||
{
|
||||
|
@ -294,84 +309,55 @@ void CreateGxsForumMsg::createMsg()
|
|||
uint32_t token;
|
||||
rsGxsForums->createMsg(token, msg);
|
||||
close();
|
||||
|
||||
|
||||
// Previous Info - for reference.
|
||||
|
||||
//ForumMsgInfo msgInfo;
|
||||
|
||||
//msgInfo.forumId = mForumId;
|
||||
//msgInfo.threadId = "";
|
||||
//msgInfo.parentId = mParentId;
|
||||
//msgInfo.msgId = "";
|
||||
|
||||
//msgInfo.title = name.toStdWString();
|
||||
//msgInfo.msg = desc.toStdWString();
|
||||
//msgInfo.msgflags = 0;
|
||||
|
||||
//if (ui.signBox->isChecked())
|
||||
//{
|
||||
// msgInfo.msgflags = RS_DISTRIB_AUTHEN_REQ;
|
||||
//}
|
||||
|
||||
//if ((msgInfo.msg == L"") && (msgInfo.title == L""))
|
||||
// return; /* do nothing */
|
||||
|
||||
//if (rsForumsV2->ForumMessageSend(msgInfo) == true) {
|
||||
// close();
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void CreateGxsForumMsg::closeEvent (QCloseEvent * /*event*/)
|
||||
{
|
||||
Settings->saveWidgetInformation(this);
|
||||
Settings->saveWidgetInformation(this);
|
||||
}
|
||||
|
||||
void CreateGxsForumMsg::smileyWidgetForums()
|
||||
{
|
||||
Emoticons::showSmileyWidget(this, ui.emoticonButton, SLOT(addSmileys()), false);
|
||||
Emoticons::showSmileyWidget(this, ui.emoticonButton, SLOT(addSmileys()), false);
|
||||
}
|
||||
|
||||
void CreateGxsForumMsg::addSmileys()
|
||||
{
|
||||
ui.forumMessage->textCursor().insertText(qobject_cast<QPushButton*>(sender())->toolTip().split("|").first());
|
||||
ui.forumMessage->textCursor().insertText(qobject_cast<QPushButton*>(sender())->toolTip().split("|").first());
|
||||
}
|
||||
|
||||
void CreateGxsForumMsg::addFile()
|
||||
{
|
||||
QStringList files;
|
||||
if (misc::getOpenFileNames(this, RshareSettings::LASTDIR_EXTRAFILE, tr("Add Extra File"), "", files)) {
|
||||
ui.hashBox->addAttachments(files,RS_FILE_REQ_ANONYMOUS_ROUTING);
|
||||
}
|
||||
QStringList files;
|
||||
if (misc::getOpenFileNames(this, RshareSettings::LASTDIR_EXTRAFILE, tr("Add Extra File"), "", files)) {
|
||||
ui.hashBox->addAttachments(files,RS_FILE_REQ_ANONYMOUS_ROUTING);
|
||||
}
|
||||
}
|
||||
|
||||
void CreateGxsForumMsg::fileHashingFinished(QList<HashedFile> hashedFiles)
|
||||
{
|
||||
std::cerr << "CreateGxsForumMsg::fileHashingFinished() started." << std::endl;
|
||||
std::cerr << "CreateGxsForumMsg::fileHashingFinished() started." << std::endl;
|
||||
|
||||
QString mesgString;
|
||||
QString mesgString;
|
||||
|
||||
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>";
|
||||
}
|
||||
}
|
||||
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>";
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CHAT_DEBUG
|
||||
std::cerr << "CreateGxsForumMsg::anchorClicked mesgString : " << mesgString.toStdString() << std::endl;
|
||||
std::cerr << "CreateGxsForumMsg::anchorClicked mesgString : " << mesgString.toStdString() << std::endl;
|
||||
#endif
|
||||
|
||||
if (!mesgString.isEmpty()) {
|
||||
ui.forumMessage->textCursor().insertHtml(mesgString);
|
||||
}
|
||||
if (!mesgString.isEmpty()) {
|
||||
ui.forumMessage->textCursor().insertHtml(mesgString);
|
||||
}
|
||||
|
||||
ui.forumMessage->setFocus( Qt::OtherFocusReason );
|
||||
ui.forumMessage->setFocus( Qt::OtherFocusReason );
|
||||
}
|
||||
|
||||
void CreateGxsForumMsg::pasteLink()
|
||||
|
@ -393,17 +379,14 @@ void CreateGxsForumMsg::pasteOwnCertificateLink()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void CreateGxsForumMsg::loadForumInfo(const uint32_t &token)
|
||||
{
|
||||
std::cerr << "CreateGxsForumMsg::loadForumInfo()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
|
||||
std::list<RsGroupMetaData> groupInfo;
|
||||
rsGxsForums->getGroupSummary(token, groupInfo);
|
||||
|
||||
|
||||
if (groupInfo.size() == 1)
|
||||
{
|
||||
RsGroupMetaData fi = groupInfo.front();
|
||||
|
@ -416,12 +399,11 @@ void CreateGxsForumMsg::loadForumInfo(const uint32_t &token)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void CreateGxsForumMsg::loadParentMsg(const uint32_t &token)
|
||||
{
|
||||
std::cerr << "CreateGxsForumMsg::loadParentMsg()";
|
||||
std::cerr << std::endl;
|
||||
|
||||
|
||||
// Only grab one.... ignore more (shouldn't be any).
|
||||
std::vector<RsGxsForumMsg> msgs;
|
||||
if (rsGxsForums->getMsgData(token, msgs))
|
||||
|
@ -431,20 +413,16 @@ void CreateGxsForumMsg::loadParentMsg(const uint32_t &token)
|
|||
/* error */
|
||||
std::cerr << "CreateGxsForumMsg::loadParentMsg() ERROR wrong number of msgs";
|
||||
std::cerr << std::endl;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
saveParentMsg(msgs[0]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CreateGxsForumMsg::loadRequest(const TokenQueue *queue, const TokenRequest &req)
|
||||
{
|
||||
std::cerr << "CreateGxsForum::loadRequest() UserType: " << req.mUserType;
|
||||
std::cerr << std::endl;
|
||||
|
||||
|
||||
if (queue == mForumQueue)
|
||||
{
|
||||
/* now switch on req */
|
||||
|
@ -453,15 +431,13 @@ void CreateGxsForumMsg::loadRequest(const TokenQueue *queue, const TokenRequest
|
|||
case CREATEGXSFORUMMSG_FORUMINFO:
|
||||
loadForumInfo(req.mToken);
|
||||
break;
|
||||
|
||||
case CREATEGXSFORUMMSG_PARENTMSG:
|
||||
loadParentMsg(req.mToken);
|
||||
break;
|
||||
default:
|
||||
std::cerr << "CreateGxsForum::loadRequest() UNKNOWN UserType ";
|
||||
std::cerr << std::endl;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue