2013-03-15 17:02:43 -04:00
|
|
|
/*
|
|
|
|
* Retroshare Gxs Support
|
|
|
|
*
|
|
|
|
* 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".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2013-03-11 16:53:15 -04:00
|
|
|
|
|
|
|
#include "GxsCreateCommentDialog.h"
|
|
|
|
#include "ui_GxsCreateCommentDialog.h"
|
|
|
|
|
2013-03-12 20:33:14 -04:00
|
|
|
#include <QMessageBox>
|
|
|
|
#include <iostream>
|
|
|
|
|
2013-03-11 16:53:15 -04:00
|
|
|
GxsCreateCommentDialog::GxsCreateCommentDialog(TokenQueue *tokQ, RsGxsCommentService *service,
|
|
|
|
const RsGxsGrpMsgIdPair &parentId, const RsGxsMessageId& threadId, QWidget *parent) :
|
|
|
|
QDialog(parent),
|
|
|
|
ui(new Ui::GxsCreateCommentDialog), mTokenQueue(tokQ), mCommentService(service), mParentId(parentId), mThreadId(threadId)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(createComment()));
|
2013-03-12 20:33:14 -04:00
|
|
|
|
|
|
|
/* fill in the available OwnIds for signing */
|
|
|
|
ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, "");
|
2013-03-11 16:53:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void GxsCreateCommentDialog::createComment()
|
|
|
|
{
|
|
|
|
RsGxsComment comment;
|
|
|
|
|
2013-03-12 20:33:14 -04:00
|
|
|
comment.mComment = std::string(ui->commentTextEdit->document()->toPlainText().toUtf8());
|
2013-03-11 16:53:15 -04:00
|
|
|
comment.mMeta.mParentId = mParentId.second;
|
|
|
|
comment.mMeta.mGroupId = mParentId.first;
|
|
|
|
comment.mMeta.mThreadId = mThreadId;
|
|
|
|
|
2013-03-12 20:33:14 -04:00
|
|
|
std::cerr << "GxsCreateCommentDialog::createComment()";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
std::cerr << "GroupId : " << comment.mMeta.mGroupId << std::endl;
|
|
|
|
std::cerr << "ThreadId : " << comment.mMeta.mThreadId << std::endl;
|
|
|
|
std::cerr << "ParentId : " << comment.mMeta.mParentId << std::endl;
|
|
|
|
|
|
|
|
|
|
|
|
RsGxsId authorId;
|
|
|
|
if (ui->idChooser->getChosenId(authorId))
|
|
|
|
{
|
|
|
|
comment.mMeta.mAuthorId = authorId;
|
|
|
|
std::cerr << "AuthorId : " << comment.mMeta.mAuthorId << std::endl;
|
|
|
|
std::cerr << std::endl;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::cerr << "GxsCreateCommentDialog::createComment() ERROR GETTING AuthorId!";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
int ret = QMessageBox::information(this, tr("Comment Signing Error"),
|
|
|
|
tr("You need to create an Identity\n"
|
|
|
|
"before you can comment"),
|
|
|
|
QMessageBox::Ok);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-03-11 16:53:15 -04:00
|
|
|
uint32_t token;
|
|
|
|
mCommentService->createComment(token, comment);
|
|
|
|
mTokenQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, 0);
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
|
|
|
GxsCreateCommentDialog::~GxsCreateCommentDialog()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|