2013-03-11 16:53:15 -04:00
|
|
|
/****************************************************************
|
|
|
|
* RetroShare is distributed under the following license:
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013 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.
|
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
#include "GxsChannelGroupDialog.h"
|
|
|
|
|
|
|
|
#include <retroshare/rsgxschannels.h>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
// To start with we only have open forums - with distribution controls.
|
2013-07-19 05:48:51 -04:00
|
|
|
|
2014-01-28 02:57:58 -05:00
|
|
|
const uint32_t ChannelCreateEnabledFlags = (
|
|
|
|
GXS_GROUP_FLAGS_NAME |
|
|
|
|
GXS_GROUP_FLAGS_ICON |
|
2013-03-11 16:53:15 -04:00
|
|
|
GXS_GROUP_FLAGS_DESCRIPTION |
|
|
|
|
GXS_GROUP_FLAGS_DISTRIBUTION |
|
|
|
|
// GXS_GROUP_FLAGS_PUBLISHSIGN |
|
|
|
|
GXS_GROUP_FLAGS_SHAREKEYS |
|
|
|
|
// GXS_GROUP_FLAGS_PERSONALSIGN |
|
|
|
|
GXS_GROUP_FLAGS_COMMENTS |
|
|
|
|
0);
|
|
|
|
|
|
|
|
const uint32_t ChannelCreateDefaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC |
|
|
|
|
//GXS_GROUP_DEFAULTS_DISTRIB_GROUP |
|
|
|
|
//GXS_GROUP_DEFAULTS_DISTRIB_LOCAL |
|
2013-07-19 05:48:51 -04:00
|
|
|
|
2013-03-11 16:53:15 -04:00
|
|
|
GXS_GROUP_DEFAULTS_PUBLISH_OPEN |
|
|
|
|
//GXS_GROUP_DEFAULTS_PUBLISH_THREADS |
|
|
|
|
//GXS_GROUP_DEFAULTS_PUBLISH_REQUIRED |
|
|
|
|
//GXS_GROUP_DEFAULTS_PUBLISH_ENCRYPTED |
|
2013-07-19 05:48:51 -04:00
|
|
|
|
2013-03-11 16:53:15 -04:00
|
|
|
//GXS_GROUP_DEFAULTS_PERSONAL_GPG |
|
|
|
|
GXS_GROUP_DEFAULTS_PERSONAL_REQUIRED |
|
|
|
|
//GXS_GROUP_DEFAULTS_PERSONAL_IFNOPUB |
|
2013-07-19 05:48:51 -04:00
|
|
|
|
2013-03-11 16:53:15 -04:00
|
|
|
GXS_GROUP_DEFAULTS_COMMENTS_YES |
|
|
|
|
//GXS_GROUP_DEFAULTS_COMMENTS_NO |
|
|
|
|
0);
|
|
|
|
|
2014-01-28 02:57:58 -05:00
|
|
|
const uint32_t ChannelEditEnabledFlags = ChannelCreateEnabledFlags;
|
|
|
|
const uint32_t ChannelEditDefaultsFlags = ChannelCreateDefaultsFlags;
|
|
|
|
|
2013-03-11 16:53:15 -04:00
|
|
|
GxsChannelGroupDialog::GxsChannelGroupDialog(TokenQueue *tokenQueue, QWidget *parent)
|
2014-07-24 19:26:04 -04:00
|
|
|
: GxsGroupDialog(tokenQueue, ChannelCreateEnabledFlags, ChannelCreateDefaultsFlags, parent)
|
2013-03-11 16:53:15 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-02-09 05:43:59 -05:00
|
|
|
GxsChannelGroupDialog::GxsChannelGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, QWidget *parent)
|
2014-07-24 19:26:04 -04:00
|
|
|
: GxsGroupDialog(tokenExternalQueue, tokenService, mode, groupId, ChannelEditEnabledFlags, ChannelEditDefaultsFlags, parent)
|
2013-03-11 16:53:15 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void GxsChannelGroupDialog::initUi()
|
|
|
|
{
|
|
|
|
switch (mode())
|
|
|
|
{
|
|
|
|
case MODE_CREATE:
|
|
|
|
setUiText(UITYPE_SERVICE_HEADER, tr("Create New Channel"));
|
2014-02-09 05:43:59 -05:00
|
|
|
setUiText(UITYPE_BUTTONBOX_OK, tr("Create Channel"));
|
2013-03-11 16:53:15 -04:00
|
|
|
break;
|
|
|
|
case MODE_SHOW:
|
|
|
|
setUiText(UITYPE_SERVICE_HEADER, tr("Channel"));
|
|
|
|
break;
|
|
|
|
case MODE_EDIT:
|
|
|
|
setUiText(UITYPE_SERVICE_HEADER, tr("Edit Channel"));
|
2014-02-09 05:43:59 -05:00
|
|
|
setUiText(UITYPE_BUTTONBOX_OK, tr("Update Channel"));
|
2013-03-11 16:53:15 -04:00
|
|
|
break;
|
|
|
|
}
|
2013-08-30 12:30:23 -04:00
|
|
|
|
|
|
|
setUiText(UITYPE_KEY_SHARE_CHECKBOX, tr("Add Channel Admins"));
|
|
|
|
setUiText(UITYPE_CONTACTS_DOCK, tr("Select Channel Admins"));
|
2013-03-11 16:53:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
QPixmap GxsChannelGroupDialog::serviceImage()
|
|
|
|
{
|
2014-05-06 13:41:38 -04:00
|
|
|
switch (mode())
|
|
|
|
{
|
|
|
|
case MODE_CREATE:
|
|
|
|
return QPixmap(":/images/add_channel64.png");
|
|
|
|
break;
|
|
|
|
case MODE_SHOW:
|
|
|
|
return QPixmap(":/images/channels.png");
|
|
|
|
case MODE_EDIT:
|
|
|
|
return QPixmap(":/images/channels.png");
|
|
|
|
}
|
2014-07-24 19:26:04 -04:00
|
|
|
|
|
|
|
return QPixmap();
|
2013-03-11 16:53:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool GxsChannelGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta)
|
|
|
|
{
|
|
|
|
// Specific Function.
|
|
|
|
RsGxsChannelGroup grp;
|
|
|
|
grp.mMeta = meta;
|
2014-04-14 18:36:10 -04:00
|
|
|
grp.mDescription = getDescription().toUtf8().constData();
|
2013-03-11 16:53:15 -04:00
|
|
|
|
|
|
|
rsGxsChannels->createGroup(token, grp);
|
|
|
|
return true;
|
|
|
|
}
|
2014-01-28 02:57:58 -05:00
|
|
|
|
2014-04-14 18:36:10 -04:00
|
|
|
bool GxsChannelGroupDialog::service_EditGroup(uint32_t &token, RsGroupMetaData &editedMeta)
|
2014-01-28 02:57:58 -05:00
|
|
|
{
|
2014-02-09 05:43:59 -05:00
|
|
|
RsGxsChannelGroup grp;
|
|
|
|
grp.mMeta = editedMeta;
|
2014-04-14 18:36:10 -04:00
|
|
|
grp.mDescription = getDescription().toUtf8().constData();
|
2014-02-09 05:43:59 -05:00
|
|
|
|
|
|
|
std::cerr << "GxsChannelGroupDialog::service_EditGroup() submitting changes";
|
2014-01-28 02:57:58 -05:00
|
|
|
std::cerr << std::endl;
|
|
|
|
|
2014-02-19 06:11:06 -05:00
|
|
|
rsGxsChannels->updateGroup(token, grp);
|
2014-02-09 05:43:59 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-04-14 18:36:10 -04:00
|
|
|
bool GxsChannelGroupDialog::service_loadGroup(uint32_t token, Mode /*mode*/, RsGroupMetaData& groupMetaData, QString &description)
|
2014-02-09 05:43:59 -05:00
|
|
|
{
|
2014-04-14 18:36:10 -04:00
|
|
|
std::cerr << "GxsChannelGroupDialog::service_loadGroup(" << token << ")";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
std::vector<RsGxsChannelGroup> groups;
|
|
|
|
if (!rsGxsChannels->getGroupData(token, groups))
|
|
|
|
{
|
|
|
|
std::cerr << "GxsChannelGroupDialog::service_loadGroup() Error getting GroupData";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (groups.size() != 1)
|
|
|
|
{
|
|
|
|
std::cerr << "GxsChannelGroupDialog::service_loadGroup() Error Group.size() != 1";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::cerr << "GxsChannelsGroupDialog::service_loadGroup() Unfinished Loading";
|
|
|
|
std::cerr << std::endl;
|
2014-02-09 05:43:59 -05:00
|
|
|
|
|
|
|
groupMetaData = groups[0].mMeta;
|
2014-04-14 18:36:10 -04:00
|
|
|
description = QString::fromUtf8(groups[0].mDescription.c_str());
|
|
|
|
|
2014-02-09 05:43:59 -05:00
|
|
|
return true;
|
2014-01-28 02:57:58 -05:00
|
|
|
}
|