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".
|
|
|
|
*
|
|
|
|
*/
|
2012-07-30 19:55:21 -04:00
|
|
|
|
|
|
|
#ifndef _GXS_GROUP_DIALOG_H
|
|
|
|
#define _GXS_GROUP_DIALOG_H
|
|
|
|
|
|
|
|
#include "ui_GxsGroupDialog.h"
|
|
|
|
|
2012-10-21 15:45:35 -04:00
|
|
|
#include "util/TokenQueue.h"
|
2012-07-30 19:55:21 -04:00
|
|
|
|
|
|
|
/********
|
|
|
|
* Notes:
|
|
|
|
*
|
|
|
|
* This is a generic Group Dialog, which is expected to be overloaded to include
|
|
|
|
* specific data for a specific service.
|
|
|
|
*
|
|
|
|
* To acheive this, we have a GxsGroupExtension widget
|
|
|
|
* - programmatically added to the GUI.
|
|
|
|
* - called to fill in fields in the Data Structures.
|
|
|
|
*
|
|
|
|
* To enable extension, we have a bunch of flags so various options can
|
|
|
|
* be shown / disabled for each specific service.
|
|
|
|
* - Enabled.
|
|
|
|
* - Defaults.
|
|
|
|
* - ReadOnly
|
|
|
|
*
|
|
|
|
* This form will be used for Create/Edit & View of Group Info.
|
|
|
|
*/
|
|
|
|
|
|
|
|
class GxsGroupExtension: public QWidget
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GxsGroupExtension() : QWidget() { return; }
|
|
|
|
};
|
|
|
|
|
2012-11-07 18:24:23 -05:00
|
|
|
/*** Group flags affect what is visually enabled that gets input into the grpMeta ***/
|
|
|
|
|
2014-01-28 02:57:58 -05:00
|
|
|
#define GXS_GROUP_FLAGS_NAME 0x00000001
|
|
|
|
#define GXS_GROUP_FLAGS_ICON 0x00000002
|
|
|
|
#define GXS_GROUP_FLAGS_DESCRIPTION 0x00000004
|
|
|
|
#define GXS_GROUP_FLAGS_DISTRIBUTION 0x00000008
|
|
|
|
#define GXS_GROUP_FLAGS_PUBLISHSIGN 0x00000010
|
|
|
|
#define GXS_GROUP_FLAGS_SHAREKEYS 0x00000020
|
|
|
|
#define GXS_GROUP_FLAGS_PERSONALSIGN 0x00000040
|
|
|
|
#define GXS_GROUP_FLAGS_COMMENTS 0x00000080
|
2012-07-30 19:55:21 -04:00
|
|
|
|
|
|
|
#define GXS_GROUP_FLAGS_EXTRA 0x00000100
|
|
|
|
|
2012-11-07 18:24:23 -05:00
|
|
|
/*** Default flags are used to determine privacy of group, signatures required ***
|
|
|
|
*** whether publish or id and whether comments are allowed or not ***/
|
|
|
|
|
2012-07-30 19:55:21 -04:00
|
|
|
#define GXS_GROUP_DEFAULTS_DISTRIB_MASK 0x0000000f
|
|
|
|
#define GXS_GROUP_DEFAULTS_PUBLISH_MASK 0x000000f0
|
|
|
|
#define GXS_GROUP_DEFAULTS_PERSONAL_MASK 0x00000f00
|
|
|
|
#define GXS_GROUP_DEFAULTS_COMMENTS_MASK 0x0000f000
|
|
|
|
|
|
|
|
#define GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC 0x00000001
|
|
|
|
#define GXS_GROUP_DEFAULTS_DISTRIB_GROUP 0x00000002
|
|
|
|
#define GXS_GROUP_DEFAULTS_DISTRIB_LOCAL 0x00000004
|
|
|
|
|
|
|
|
#define GXS_GROUP_DEFAULTS_PUBLISH_OPEN 0x00000010
|
|
|
|
#define GXS_GROUP_DEFAULTS_PUBLISH_THREADS 0x00000020
|
|
|
|
#define GXS_GROUP_DEFAULTS_PUBLISH_REQUIRED 0x00000040
|
|
|
|
#define GXS_GROUP_DEFAULTS_PUBLISH_ENCRYPTED 0x00000080
|
|
|
|
|
|
|
|
#define GXS_GROUP_DEFAULTS_PERSONAL_PGP 0x00000100
|
|
|
|
#define GXS_GROUP_DEFAULTS_PERSONAL_REQUIRED 0x00000200
|
|
|
|
#define GXS_GROUP_DEFAULTS_PERSONAL_IFNOPUB 0x00000400
|
|
|
|
|
|
|
|
#define GXS_GROUP_DEFAULTS_COMMENTS_YES 0x00001000
|
|
|
|
#define GXS_GROUP_DEFAULTS_COMMENTS_NO 0x00002000
|
|
|
|
|
2012-10-29 18:41:41 -04:00
|
|
|
/*!
|
|
|
|
* The aim of this dialog is to be convenient to encapsulate group
|
|
|
|
* creation code for several GXS services such forums, channels
|
|
|
|
* and posted
|
|
|
|
* The functionality provided are for group creation are:
|
|
|
|
* - Specifying the authentication type of the group
|
|
|
|
* - Specifying group image
|
|
|
|
* -
|
|
|
|
* The main limitation is that it will not deal with the actual service GXS Group
|
|
|
|
* data structure, but the meta structure which is the same across GXS services
|
|
|
|
* The long term plan is perhap logic structure (i.e. code) will be moved into each GXS \n
|
|
|
|
* service for better customisation of group creation, or perhaps not!
|
|
|
|
*/
|
2014-01-28 02:57:58 -05:00
|
|
|
class GxsGroupDialog : public QDialog, public TokenResponse
|
2012-07-30 19:55:21 -04:00
|
|
|
{
|
2012-11-28 17:27:19 -05:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum Mode {
|
|
|
|
MODE_CREATE,
|
|
|
|
MODE_SHOW,
|
|
|
|
MODE_EDIT
|
|
|
|
};
|
2012-07-30 19:55:21 -04:00
|
|
|
|
2013-01-06 19:00:46 -05:00
|
|
|
enum UiType {
|
|
|
|
UITYPE_SERVICE_HEADER,
|
|
|
|
UITYPE_KEY_SHARE_CHECKBOX,
|
2014-01-11 17:02:05 -05:00
|
|
|
UITYPE_CONTACTS_DOCK,
|
|
|
|
UITYPE_BUTTONBOX_OK
|
2013-01-06 19:00:46 -05:00
|
|
|
};
|
|
|
|
|
2012-07-30 19:55:21 -04:00
|
|
|
public:
|
|
|
|
|
2012-11-28 17:27:19 -05:00
|
|
|
/*!
|
|
|
|
* Constructs a GxsGroupDialog for creating group
|
|
|
|
* @param tokenQueue This should be the TokenQueue of the (parent) service
|
|
|
|
* in order to receive acknowledgement of group creation, if set to NULL with create mode \n
|
|
|
|
* creation will not happen
|
|
|
|
* @param enableFlags This determines what options are enabled such as Icon, Description, publish type and key sharing
|
|
|
|
* @param defaultFlags This deter
|
|
|
|
* @param parent The parent dialog
|
|
|
|
* @param mode
|
|
|
|
*/
|
2014-01-28 02:57:58 -05:00
|
|
|
GxsGroupDialog(TokenQueue* tokenQueue, uint32_t enableFlags, uint32_t defaultFlags, QWidget *parent = NULL);
|
2012-11-28 17:27:19 -05:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* Contructs a GxsGroupDialog for display a group or editing
|
|
|
|
* @param grpMeta This is used to fill out the dialog
|
|
|
|
* @param mode This determines whether the dialog starts in show or edit mode (Edit not supported yet)
|
|
|
|
* @param parent
|
|
|
|
*/
|
2014-01-28 02:57:58 -05:00
|
|
|
GxsGroupDialog(TokenQueue *tokenExternalQueue, RsTokenService *tokenService, Mode mode, RsGxsGroupId groupId, uint32_t enableFlags, uint32_t defaultFlags, QWidget *parent = NULL);
|
2012-11-28 17:27:19 -05:00
|
|
|
|
|
|
|
uint32_t mode() { return mMode; }
|
2012-07-30 19:55:21 -04:00
|
|
|
|
2014-01-28 02:57:58 -05:00
|
|
|
// overloaded from TokenResponse
|
|
|
|
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
|
|
|
|
2012-10-29 18:41:41 -04:00
|
|
|
private:
|
2012-11-28 17:27:19 -05:00
|
|
|
void newGroup();
|
|
|
|
void init();
|
|
|
|
void initMode();
|
2014-07-06 07:19:58 -04:00
|
|
|
void createNewGxsId();
|
2012-07-30 19:55:21 -04:00
|
|
|
|
2012-11-28 17:27:19 -05:00
|
|
|
// Functions that can be overloaded for specific stuff.
|
2012-07-30 19:55:21 -04:00
|
|
|
|
|
|
|
protected slots:
|
2012-11-28 17:27:19 -05:00
|
|
|
void submitGroup();
|
|
|
|
void addGroupLogo();
|
2012-07-30 19:55:21 -04:00
|
|
|
|
|
|
|
protected:
|
2012-11-28 17:27:19 -05:00
|
|
|
virtual void showEvent(QShowEvent*);
|
|
|
|
|
2013-01-07 06:40:05 -05:00
|
|
|
virtual void initUi() = 0;
|
2012-11-28 17:27:19 -05:00
|
|
|
virtual QPixmap serviceImage() = 0;
|
2014-07-24 19:26:04 -04:00
|
|
|
virtual QIcon serviceWindowIcon();
|
2012-11-28 17:27:19 -05:00
|
|
|
|
2013-01-07 06:40:05 -05:00
|
|
|
void setUiText(UiType uiType, const QString &text);
|
|
|
|
|
2012-11-28 17:27:19 -05:00
|
|
|
/*!
|
2014-04-14 18:36:10 -04:00
|
|
|
* It is up to the service to do the actual group creation
|
|
|
|
* Service can also modify initial meta going into group
|
2012-11-28 17:27:19 -05:00
|
|
|
* @param token This should be set to the token retrieved
|
|
|
|
* @param meta The deriving GXS service should set their grp meta to this value
|
|
|
|
*/
|
|
|
|
virtual bool service_CreateGroup(uint32_t &token, const RsGroupMetaData &meta) = 0;
|
|
|
|
|
2014-04-14 18:36:10 -04:00
|
|
|
/*!
|
|
|
|
* It is up to the service to do the actual group editing
|
|
|
|
* @param token This should be set to the token retrieved
|
|
|
|
* @param meta The deriving GXS service should set their grp meta to this value
|
|
|
|
*/
|
|
|
|
virtual bool service_EditGroup(uint32_t &token, RsGroupMetaData &editedMeta) = 0;
|
2014-01-28 02:57:58 -05:00
|
|
|
|
|
|
|
// To be overloaded by users.
|
|
|
|
// use Token to retrieve from service, fill in metaData.
|
2014-04-14 18:36:10 -04:00
|
|
|
virtual bool service_loadGroup(uint32_t token, Mode mode, RsGroupMetaData& groupMetaData, QString &description) = 0;
|
2014-01-20 02:29:54 -05:00
|
|
|
|
2012-11-28 17:27:19 -05:00
|
|
|
/*!
|
|
|
|
* This returns a group logo from the ui \n
|
|
|
|
* Should be calleld by deriving service
|
|
|
|
* @return The logo for the service
|
|
|
|
*/
|
|
|
|
QPixmap getLogo();
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* This returns a group description string from the ui
|
|
|
|
* @return group description string
|
|
|
|
*/
|
2014-04-14 18:36:10 -04:00
|
|
|
QString getDescription();
|
|
|
|
|
2012-07-30 19:55:21 -04:00
|
|
|
private slots:
|
|
|
|
/* actions to take.... */
|
|
|
|
void cancelDialog();
|
|
|
|
|
|
|
|
// set private forum key share list
|
|
|
|
void setShareList();
|
|
|
|
|
2012-12-15 18:11:11 -05:00
|
|
|
void updateCircleOptions();
|
|
|
|
|
2012-07-30 19:55:21 -04:00
|
|
|
private:
|
2013-06-04 17:00:43 -04:00
|
|
|
bool setCircleParameters(RsGroupMetaData &meta);
|
2012-12-15 18:11:11 -05:00
|
|
|
|
2012-07-30 19:55:21 -04:00
|
|
|
void setGroupSignFlags(uint32_t signFlags);
|
|
|
|
uint32_t getGroupSignFlags();
|
2014-01-28 02:57:58 -05:00
|
|
|
|
|
|
|
void setAllReadonly();
|
|
|
|
void setupReadonly();
|
2012-07-30 19:55:21 -04:00
|
|
|
void setupDefaults();
|
|
|
|
void setupVisibility();
|
|
|
|
void clearForm();
|
|
|
|
void createGroup();
|
2014-04-14 18:36:10 -04:00
|
|
|
void editGroup();
|
2012-07-30 19:55:21 -04:00
|
|
|
void sendShareList(std::string forumId);
|
|
|
|
void loadNewGroupId(const uint32_t &token);
|
|
|
|
|
2014-01-28 02:57:58 -05:00
|
|
|
// loading existing Groups.
|
|
|
|
void requestGroup(const RsGxsGroupId &groupId);
|
|
|
|
void loadGroup(uint32_t token);
|
2014-04-14 18:36:10 -04:00
|
|
|
void updateFromExistingMeta(const QString &description);
|
2014-01-28 02:57:58 -05:00
|
|
|
|
2014-02-09 05:43:59 -05:00
|
|
|
bool prepareGroupMetaData(RsGroupMetaData &meta);
|
|
|
|
|
2012-10-29 18:41:41 -04:00
|
|
|
std::list<std::string> mShareList;
|
2012-07-30 19:55:21 -04:00
|
|
|
QPixmap picture;
|
2014-01-28 02:57:58 -05:00
|
|
|
RsTokenService *mTokenService;
|
|
|
|
TokenQueue *mExternalTokenQueue;
|
|
|
|
TokenQueue *mInternalTokenQueue;
|
2012-11-28 17:27:19 -05:00
|
|
|
RsGroupMetaData mGrpMeta;
|
2012-07-30 19:55:21 -04:00
|
|
|
|
2014-01-28 02:57:58 -05:00
|
|
|
Mode mMode;
|
2012-07-30 19:55:21 -04:00
|
|
|
uint32_t mEnabledFlags;
|
|
|
|
uint32_t mReadonlyFlags;
|
|
|
|
uint32_t mDefaultsFlags;
|
|
|
|
|
2014-04-14 18:36:10 -04:00
|
|
|
protected:
|
2012-07-30 19:55:21 -04:00
|
|
|
/** Qt Designer generated object */
|
|
|
|
Ui::GxsGroupDialog ui;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|