2008-04-15 12:40:38 -04:00
|
|
|
/****************************************************************
|
|
|
|
* RetroShare is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Robert Fernie
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program 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 General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
****************************************************************/
|
|
|
|
|
2008-11-27 20:49:17 -05:00
|
|
|
#include <QMessageBox>
|
2008-04-15 12:40:38 -04:00
|
|
|
|
|
|
|
#include "CreateForum.h"
|
|
|
|
|
|
|
|
#include "rsiface/rsforums.h"
|
2008-06-24 00:36:45 -04:00
|
|
|
#include "rsiface/rschannels.h"
|
2008-04-15 12:40:38 -04:00
|
|
|
|
|
|
|
/** Constructor */
|
2008-06-24 00:36:45 -04:00
|
|
|
CreateForum::CreateForum(QWidget *parent, bool isForum)
|
|
|
|
: QWidget(parent), mIsForum(isForum)
|
2008-04-15 12:40:38 -04:00
|
|
|
{
|
|
|
|
/* Invoke the Qt Designer generated object setup routine */
|
|
|
|
ui.setupUi(this);
|
|
|
|
|
|
|
|
// connect up the buttons.
|
|
|
|
connect( ui.cancelButton, SIGNAL( clicked ( bool ) ), this, SLOT( cancelForum( ) ) );
|
|
|
|
connect( ui.createButton, SIGNAL( clicked ( bool ) ), this, SLOT( createForum( ) ) );
|
|
|
|
|
|
|
|
newForum();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-11-27 20:49:17 -05:00
|
|
|
void CreateForum::show()
|
|
|
|
{
|
|
|
|
//loadSettings();
|
|
|
|
if(!this->isVisible()) {
|
|
|
|
QWidget::show();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-15 12:40:38 -04:00
|
|
|
|
|
|
|
void CreateForum::newForum()
|
|
|
|
{
|
2008-06-24 00:36:45 -04:00
|
|
|
|
|
|
|
if (mIsForum)
|
|
|
|
{
|
|
|
|
/* enforce Public for the moment */
|
|
|
|
ui.typePublic->setChecked(true);
|
|
|
|
|
|
|
|
ui.typePrivate->setEnabled(false);
|
|
|
|
ui.typeEncrypted->setEnabled(false);
|
|
|
|
|
|
|
|
ui.msgAnon->setChecked(true);
|
|
|
|
ui.msgAuth->setEnabled(false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* enforce Private for the moment */
|
|
|
|
ui.typePrivate->setChecked(true);
|
|
|
|
|
|
|
|
ui.typePublic->setEnabled(false);
|
|
|
|
ui.typeEncrypted->setEnabled(false);
|
|
|
|
|
|
|
|
ui.msgAnon->setChecked(true);
|
|
|
|
ui.msgAuth->setEnabled(false);
|
|
|
|
ui.msgGroupBox->hide();
|
|
|
|
}
|
2008-04-15 12:40:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void CreateForum::createForum()
|
|
|
|
{
|
|
|
|
QString name = ui.forumName->text();
|
2008-06-24 00:36:45 -04:00
|
|
|
QString desc = ui.forumDesc->toPlainText(); //toHtml();
|
2008-04-15 12:40:38 -04:00
|
|
|
uint32_t flags = 0;
|
|
|
|
|
2008-11-27 20:49:17 -05:00
|
|
|
if(name.isEmpty())
|
|
|
|
{ /* error message */
|
|
|
|
int ret = QMessageBox::warning(this, tr("RetroShare"),
|
|
|
|
tr("Please add a Name"),
|
|
|
|
QMessageBox::Ok, QMessageBox::Ok);
|
|
|
|
|
|
|
|
return; //Don't add a empty name!!
|
|
|
|
}
|
|
|
|
else
|
|
|
|
|
2008-06-24 00:36:45 -04:00
|
|
|
if (ui.typePublic->isChecked())
|
2008-04-15 12:40:38 -04:00
|
|
|
{
|
2008-06-13 11:46:34 -04:00
|
|
|
flags |= RS_DISTRIB_PUBLIC;
|
2008-04-15 12:40:38 -04:00
|
|
|
}
|
2008-06-24 00:36:45 -04:00
|
|
|
else if (ui.typePrivate->isChecked())
|
2008-04-15 12:40:38 -04:00
|
|
|
{
|
2008-06-13 11:46:34 -04:00
|
|
|
flags |= RS_DISTRIB_PRIVATE;
|
2008-04-15 12:40:38 -04:00
|
|
|
}
|
2008-06-24 00:36:45 -04:00
|
|
|
else if (ui.typeEncrypted->isChecked())
|
2008-04-15 12:40:38 -04:00
|
|
|
{
|
2008-06-13 11:46:34 -04:00
|
|
|
flags |= RS_DISTRIB_ENCRYPTED;
|
2008-04-15 12:40:38 -04:00
|
|
|
}
|
|
|
|
|
2008-06-24 00:36:45 -04:00
|
|
|
if (ui.msgAuth->isChecked())
|
2008-04-15 12:40:38 -04:00
|
|
|
{
|
2008-06-13 11:46:34 -04:00
|
|
|
flags |= RS_DISTRIB_AUTHEN_REQ;
|
2008-04-15 12:40:38 -04:00
|
|
|
}
|
2008-06-24 00:36:45 -04:00
|
|
|
else if (ui.msgAnon->isChecked())
|
2008-04-15 12:40:38 -04:00
|
|
|
{
|
2008-06-13 11:46:34 -04:00
|
|
|
flags |= RS_DISTRIB_AUTHEN_ANON;
|
2008-04-15 12:40:38 -04:00
|
|
|
}
|
|
|
|
|
2008-06-24 00:36:45 -04:00
|
|
|
if (mIsForum)
|
|
|
|
{
|
|
|
|
if (rsForums)
|
|
|
|
{
|
|
|
|
rsForums->createForum(name.toStdWString(), desc.toStdWString(), flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (rsChannels)
|
|
|
|
{
|
|
|
|
rsChannels->createChannel(name.toStdWString(), desc.toStdWString(), flags);
|
|
|
|
}
|
|
|
|
}
|
2008-04-15 12:40:38 -04:00
|
|
|
|
|
|
|
close();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CreateForum::cancelForum()
|
|
|
|
{
|
|
|
|
close();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|