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 "PostedUserTypes.h"
|
|
|
|
|
|
|
|
#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
|
|
|
|
2013-07-15 14:39:39 -04:00
|
|
|
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(createPost()));
|
|
|
|
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(close()));
|
2013-08-31 15:23:49 -04:00
|
|
|
|
|
|
|
ui->headerFrame->setHeaderImage(QPixmap(":/images/posted_64.png"));
|
|
|
|
ui->headerFrame->setHeaderText(tr("Create Post"));
|
2013-03-15 17:02:43 -04:00
|
|
|
|
2013-07-15 14:39:39 -04:00
|
|
|
/* fill in the available OwnIds for signing */
|
|
|
|
ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, "");
|
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;
|
|
|
|
if (!ui->idChooser->getChosenId(authorId))
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
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;
|
2012-11-07 18:24:23 -05:00
|
|
|
|
2013-07-15 14:39:39 -04:00
|
|
|
uint32_t token;
|
|
|
|
mPosted->createPost(token, post);
|
|
|
|
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
|
|
|
}
|