2013-03-15 17:02:43 -04:00
|
|
|
/*
|
|
|
|
* Retroshare Gxs Support
|
2012-07-30 19:55:21 -04:00
|
|
|
*
|
2013-03-15 17:02:43 -04:00
|
|
|
* Copyright 2012-2013 by Robert Fernie.
|
2012-07-30 19:55:21 -04:00
|
|
|
*
|
2013-03-15 17:02:43 -04:00
|
|
|
* 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.
|
2012-07-30 19:55:21 -04:00
|
|
|
*
|
2013-03-15 17:02:43 -04:00
|
|
|
* 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.
|
2012-07-30 19:55:21 -04:00
|
|
|
*
|
2013-03-15 17:02:43 -04:00
|
|
|
* 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".
|
|
|
|
*
|
|
|
|
*/
|
2012-07-30 19:55:21 -04:00
|
|
|
|
|
|
|
#include "WikiGroupDialog.h"
|
|
|
|
|
|
|
|
#include <retroshare/rswiki.h>
|
|
|
|
#include <iostream>
|
|
|
|
|
2014-01-28 02:57:58 -05:00
|
|
|
const uint32_t WikiCreateEnabledFlags = (
|
|
|
|
GXS_GROUP_FLAGS_NAME |
|
|
|
|
// GXS_GROUP_FLAGS_ICON |
|
2012-11-12 15:47:55 -05: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);
|
|
|
|
|
|
|
|
uint32_t WikiCreateDefaultsFlags = ( GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC |
|
|
|
|
//GXS_GROUP_DEFAULTS_DISTRIB_GROUP |
|
|
|
|
//GXS_GROUP_DEFAULTS_DISTRIB_LOCAL |
|
|
|
|
|
|
|
|
GXS_GROUP_DEFAULTS_PUBLISH_OPEN |
|
|
|
|
//GXS_GROUP_DEFAULTS_PUBLISH_THREADS |
|
|
|
|
//GXS_GROUP_DEFAULTS_PUBLISH_REQUIRED |
|
|
|
|
//GXS_GROUP_DEFAULTS_PUBLISH_ENCRYPTED |
|
|
|
|
|
|
|
|
//GXS_GROUP_DEFAULTS_PERSONAL_GPG |
|
|
|
|
GXS_GROUP_DEFAULTS_PERSONAL_REQUIRED |
|
|
|
|
//GXS_GROUP_DEFAULTS_PERSONAL_IFNOPUB |
|
|
|
|
|
|
|
|
//GXS_GROUP_DEFAULTS_COMMENTS_YES |
|
|
|
|
GXS_GROUP_DEFAULTS_COMMENTS_NO |
|
|
|
|
0);
|
|
|
|
|
2014-01-28 02:57:58 -05:00
|
|
|
uint32_t WikiEditDefaultsFlags = WikiCreateDefaultsFlags;
|
|
|
|
uint32_t WikiEditEnabledFlags = WikiCreateEnabledFlags;
|
2012-11-12 15:47:55 -05:00
|
|
|
|
2012-10-31 19:32:56 -04:00
|
|
|
WikiGroupDialog::WikiGroupDialog(TokenQueue *tokenQueue, QWidget *parent)
|
2012-11-21 13:55:52 -05:00
|
|
|
:GxsGroupDialog(tokenQueue, WikiCreateEnabledFlags, WikiCreateDefaultsFlags, parent)
|
2012-07-30 19:55:21 -04:00
|
|
|
{
|
2012-10-31 19:32:56 -04:00
|
|
|
}
|
|
|
|
|
2014-01-28 02:57:58 -05:00
|
|
|
WikiGroupDialog::WikiGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, QWidget *parent)
|
|
|
|
:GxsGroupDialog(tokenExternalQueue, tokenService, mode, groupId, WikiEditEnabledFlags, WikiEditDefaultsFlags, parent)
|
2012-10-31 19:32:56 -04:00
|
|
|
{
|
2012-07-30 19:55:21 -04:00
|
|
|
}
|
|
|
|
|
2013-01-07 06:40:05 -05:00
|
|
|
void WikiGroupDialog::initUi()
|
2012-11-21 13:55:52 -05:00
|
|
|
{
|
2013-01-07 06:40:05 -05:00
|
|
|
switch (mode())
|
2012-11-28 17:27:19 -05:00
|
|
|
{
|
2013-01-07 06:40:05 -05:00
|
|
|
case MODE_CREATE:
|
|
|
|
setUiText(UITYPE_SERVICE_HEADER, tr("Create New Wiki Group"));
|
2014-02-09 05:43:59 -05:00
|
|
|
setUiText(UITYPE_BUTTONBOX_OK, tr("Create Group"));
|
2013-01-06 19:00:46 -05:00
|
|
|
break;
|
2013-01-07 06:40:05 -05:00
|
|
|
case MODE_SHOW:
|
|
|
|
setUiText(UITYPE_SERVICE_HEADER, tr("Wiki Group"));
|
|
|
|
break;
|
|
|
|
case MODE_EDIT:
|
|
|
|
setUiText(UITYPE_SERVICE_HEADER, tr("Edit Wiki Group"));
|
2014-02-09 05:43:59 -05:00
|
|
|
setUiText(UITYPE_BUTTONBOX_OK, tr("Update Group"));
|
2013-01-06 19:00:46 -05:00
|
|
|
break;
|
2012-11-28 17:27:19 -05:00
|
|
|
}
|
|
|
|
|
2013-01-07 06:40:05 -05:00
|
|
|
setUiText(UITYPE_KEY_SHARE_CHECKBOX, tr("Add Wiki Moderators"));
|
|
|
|
setUiText(UITYPE_CONTACTS_DOCK, tr("Select Wiki Moderators"));
|
2012-11-21 13:55:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
QPixmap WikiGroupDialog::serviceImage()
|
|
|
|
{
|
2013-08-29 21:28:30 -04:00
|
|
|
return QPixmap(":/images/resource-group-new_64.png");
|
2012-11-21 13:55:52 -05:00
|
|
|
}
|
2012-07-30 19:55:21 -04:00
|
|
|
|
|
|
|
bool WikiGroupDialog::service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta)
|
|
|
|
{
|
|
|
|
// Specific Function.
|
2012-10-31 19:32:56 -04:00
|
|
|
RsWikiCollection grp;
|
2012-07-30 19:55:21 -04:00
|
|
|
grp.mMeta = meta;
|
2014-04-14 18:36:10 -04:00
|
|
|
grp.mDescription = getDescription().toStdString();
|
2012-11-12 15:47:55 -05:00
|
|
|
std::cerr << "WikiGroupDialog::service_CreateGroup() storing to Queue";
|
|
|
|
std::cerr << std::endl;
|
2012-07-30 19:55:21 -04:00
|
|
|
|
2012-10-31 19:32:56 -04:00
|
|
|
rsWiki->submitCollection(token, grp);
|
2012-07-30 19:55:21 -04:00
|
|
|
|
2012-11-12 15:47:55 -05:00
|
|
|
return true;
|
2012-07-30 19:55:21 -04:00
|
|
|
}
|
2014-01-28 02:57:58 -05:00
|
|
|
|
2014-04-14 18:36:10 -04:00
|
|
|
bool WikiGroupDialog::service_EditGroup(uint32_t &token, RsGroupMetaData &editedMeta)
|
2014-01-28 02:57:58 -05:00
|
|
|
{
|
2014-02-09 05:43:59 -05:00
|
|
|
RsWikiCollection grp;
|
|
|
|
grp.mMeta = editedMeta;
|
2014-04-14 18:36:10 -04:00
|
|
|
grp.mDescription = getDescription().toStdString();
|
2014-02-09 05:43:59 -05:00
|
|
|
|
|
|
|
std::cerr << "WikiGroupDialog::service_EditGroup() submitting changes.";
|
2014-01-28 02:57:58 -05:00
|
|
|
std::cerr << std::endl;
|
|
|
|
|
2014-02-19 06:11:06 -05:00
|
|
|
rsWiki->updateCollection(token, grp);
|
2014-02-09 05:43:59 -05:00
|
|
|
return true;
|
2014-01-28 02:57:58 -05:00
|
|
|
}
|
|
|
|
|
2014-04-14 18:36:10 -04:00
|
|
|
bool WikiGroupDialog::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 << "WikiGroupDialog::service_loadGroup(" << token << ")";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
|
|
|
|
std::vector<RsWikiCollection> groups;
|
|
|
|
if (!rsWiki->getCollections(token, groups))
|
|
|
|
{
|
|
|
|
std::cerr << "WikiGroupDialog::service_loadGroup() Error getting GroupData";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (groups.size() != 1)
|
|
|
|
{
|
|
|
|
std::cerr << "WikiGroupDialog::service_loadGroup() Error Group.size() != 1";
|
|
|
|
std::cerr << std::endl;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::cerr << "WikisGroupDialog::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;
|
|
|
|
}
|