mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
24ad4b8880
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7437 b45a01b8-16f6-495d-af2f-9b41ad6348cc
103 lines
3.3 KiB
C++
103 lines
3.3 KiB
C++
/*
|
|
* 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".
|
|
*
|
|
*/
|
|
|
|
|
|
#include "GxsCreateCommentDialog.h"
|
|
#include "ui_GxsCreateCommentDialog.h"
|
|
#include "gui/Identity/IdDialog.h"
|
|
|
|
#include <QMessageBox>
|
|
#include <iostream>
|
|
|
|
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()));
|
|
connect(ui->toolButton_NewId, SIGNAL(clicked()), this, SLOT(createNewGxsId()));
|
|
|
|
/* fill in the available OwnIds for signing */
|
|
ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, RsGxsId());
|
|
}
|
|
|
|
void GxsCreateCommentDialog::createComment()
|
|
{
|
|
RsGxsComment comment;
|
|
|
|
comment.mComment = std::string(ui->commentTextEdit->document()->toPlainText().toUtf8());
|
|
comment.mMeta.mParentId = mParentId.second;
|
|
comment.mMeta.mGroupId = mParentId.first;
|
|
comment.mMeta.mThreadId = mThreadId;
|
|
|
|
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;
|
|
switch (ui->idChooser->getChosenId(authorId)) {
|
|
case GxsIdChooser::KnowId:
|
|
case GxsIdChooser::UnKnowId:
|
|
comment.mMeta.mAuthorId = authorId;
|
|
std::cerr << "AuthorId : " << comment.mMeta.mAuthorId << std::endl;
|
|
std::cerr << std::endl;
|
|
|
|
break;
|
|
case GxsIdChooser::NoId:
|
|
case GxsIdChooser::None:
|
|
default:
|
|
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);
|
|
Q_UNUSED(ret)
|
|
return;
|
|
}//switch (ui->idChooser->getChosenId(authorId))
|
|
|
|
uint32_t token;
|
|
mCommentService->createComment(token, comment);
|
|
mTokenQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, 0);
|
|
close();
|
|
}
|
|
|
|
void GxsCreateCommentDialog::createNewGxsId()
|
|
{
|
|
IdEditDialog dlg(this);
|
|
dlg.setupNewId(false);
|
|
dlg.exec();
|
|
ui->idChooser->setDefaultId(dlg.getLastIdName());
|
|
}
|
|
|
|
GxsCreateCommentDialog::~GxsCreateCommentDialog()
|
|
{
|
|
delete ui;
|
|
}
|