2013-03-15 17:02:43 -04:00
|
|
|
/*
|
|
|
|
* Retroshare Posted
|
|
|
|
*
|
|
|
|
* Copyright 2012-2013 by Robert Fernie.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <QMessageBox>
|
2012-11-07 18:24:23 -05:00
|
|
|
#include "PostedCreatePostDialog.h"
|
|
|
|
#include "ui_PostedCreatePostDialog.h"
|
2013-07-15 14:39:39 -04:00
|
|
|
|
|
|
|
#include "util/TokenQueue.h"
|
2012-11-07 18:24:23 -05:00
|
|
|
|
2013-03-15 17:02:43 -04:00
|
|
|
#include <iostream>
|
|
|
|
|
2012-11-17 16:43:21 -05:00
|
|
|
PostedCreatePostDialog::PostedCreatePostDialog(TokenQueue* tokenQ, RsPosted *posted, const RsGxsGroupId& grpId, QWidget *parent):
|
2013-07-15 14:39:39 -04:00
|
|
|
QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint),
|
|
|
|
mTokenQueue(tokenQ), mPosted(posted), mGrpId(grpId),
|
|
|
|
ui(new Ui::PostedCreatePostDialog)
|
2012-11-07 18:24:23 -05:00
|
|
|
{
|
2013-07-15 14:39:39 -04:00
|
|
|
ui->setupUi(this);
|
2013-03-15 17:02:43 -04:00
|
|
|
|
2014-01-10 13:41:08 -05:00
|
|
|
connect(ui->submitButton, SIGNAL(clicked()), this, SLOT(createPost()));
|
2013-07-15 14:39:39 -04:00
|
|
|
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(close()));
|
2013-08-31 15:23:49 -04:00
|
|
|
|
|
|
|
ui->headerFrame->setHeaderImage(QPixmap(":/images/posted_64.png"));
|
2014-01-10 13:41:08 -05:00
|
|
|
ui->headerFrame->setHeaderText(tr("Submit a new Post"));
|
2013-03-15 17:02:43 -04:00
|
|
|
|
2014-07-22 11:04:36 -04:00
|
|
|
setAttribute ( Qt::WA_DeleteOnClose, true );
|
|
|
|
|
2013-07-15 14:39:39 -04:00
|
|
|
/* fill in the available OwnIds for signing */
|
2014-03-17 16:56:06 -04:00
|
|
|
ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, RsGxsId());
|
2012-11-07 18:24:23 -05:00
|
|
|
}
|
|
|
|
|
2013-07-15 14:39:39 -04:00
|
|
|
PostedCreatePostDialog::~PostedCreatePostDialog()
|
2012-11-07 18:24:23 -05:00
|
|
|
{
|
2013-07-15 14:39:39 -04:00
|
|
|
delete ui;
|
|
|
|
}
|
2013-03-15 17:02:43 -04:00
|
|
|
|
2013-07-15 14:39:39 -04:00
|
|
|
void PostedCreatePostDialog::createPost()
|
|
|
|
{
|
|
|
|
RsGxsId authorId;
|
2014-12-23 19:10:15 -05:00
|
|
|
switch (ui->idChooser->getChosenId(authorId)) {
|
|
|
|
case GxsIdChooser::KnowId:
|
|
|
|
case GxsIdChooser::UnKnowId:
|
|
|
|
break;
|
|
|
|
case GxsIdChooser::NoId:
|
|
|
|
case GxsIdChooser::None:
|
|
|
|
default:
|
2013-07-15 14:39:39 -04:00
|
|
|
std::cerr << "PostedCreatePostDialog::createPost() ERROR GETTING AuthorId!, Post Failed";
|
|
|
|
std::cerr << std::endl;
|
2013-03-15 17:02:43 -04:00
|
|
|
|
2013-07-15 14:39:39 -04:00
|
|
|
QMessageBox::warning(this, tr("RetroShare"),tr("Please create or choose a Signing Id first"), QMessageBox::Ok, QMessageBox::Ok);
|
2013-03-15 17:02:43 -04:00
|
|
|
|
2013-07-15 14:39:39 -04:00
|
|
|
return;
|
2014-12-23 19:10:15 -05:00
|
|
|
}//switch (ui->idChooser->getChosenId(authorId))
|
2013-03-15 17:02:43 -04:00
|
|
|
|
2013-07-15 14:39:39 -04:00
|
|
|
RsPostedPost post;
|
|
|
|
post.mMeta.mGroupId = mGrpId;
|
|
|
|
post.mLink = std::string(ui->linkEdit->text().toUtf8());
|
|
|
|
post.mNotes = std::string(ui->notesTextEdit->toPlainText().toUtf8());
|
|
|
|
post.mMeta.mMsgName = std::string(ui->titleEdit->text().toUtf8());
|
|
|
|
post.mMeta.mAuthorId = authorId;
|
2014-01-10 13:41:08 -05:00
|
|
|
|
|
|
|
if(ui->titleEdit->text().isEmpty()) {
|
|
|
|
/* error message */
|
|
|
|
QMessageBox::warning(this, "RetroShare", tr("Please add a Title"), QMessageBox::Ok, QMessageBox::Ok);
|
|
|
|
return; //Don't add a empty title!!
|
2014-12-23 19:10:15 -05:00
|
|
|
}//if(ui->titleEdit->text().isEmpty())
|
2012-11-07 18:24:23 -05:00
|
|
|
|
2013-07-15 14:39:39 -04:00
|
|
|
uint32_t token;
|
|
|
|
mPosted->createPost(token, post);
|
2014-07-23 14:51:56 -04:00
|
|
|
// mTokenQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, TOKEN_USER_TYPE_POST);
|
2012-11-07 18:24:23 -05:00
|
|
|
|
2013-07-15 14:39:39 -04:00
|
|
|
accept();
|
2012-11-07 18:24:23 -05:00
|
|
|
}
|