2018-11-14 15:14:40 -05:00
/*******************************************************************************
* retroshare - gui / src / gui / gxs / GxsGroupDialog . cpp *
* *
* Copyright 2012 - 2013 by Robert Fernie < retroshare . project @ gmail . com > *
* *
* This program is free software : you can redistribute it and / or modify *
* it under the terms of the GNU Affero General Public License as *
* published by the Free Software Foundation , either version 3 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 Affero General Public License for more details . *
* *
* You should have received a copy of the GNU Affero General Public License *
* along with this program . If not , see < https : //www.gnu.org/licenses/>. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2012-07-30 19:55:21 -04:00
# include <QMessageBox>
2020-02-19 17:14:19 -05:00
# include <QPushButton>
2012-07-30 19:55:21 -04:00
# include "util/misc.h"
2014-12-27 18:51:45 -05:00
# include "util/DateTime.h"
2020-03-22 16:47:14 -04:00
# include "util/qtthreadsutils.h"
2012-07-30 19:55:21 -04:00
# include "GxsGroupDialog.h"
# include "gui/common/PeerDefs.h"
2019-01-06 09:56:39 -05:00
# include "gui/RetroShareLink.h"
2013-02-28 16:58:38 -05:00
# include "retroshare/rsgxsflags.h"
2012-07-30 19:55:21 -04:00
# include <algorithm>
# include <retroshare/rspeers.h>
2012-12-15 18:11:11 -05:00
# include <retroshare/rsgxscircles.h>
2012-07-30 19:55:21 -04:00
2017-10-22 06:49:38 -04:00
# include <gui/settings/rsharesettings.h>
2012-07-30 19:55:21 -04:00
# include <iostream>
2019-01-06 09:56:39 -05:00
2012-10-21 15:45:35 -04:00
// Control of Publish Signatures.
2015-10-23 22:53:00 -04:00
//
// These are now defined in rsgxsflags.h
//
// #define FLAG_GROUP_SIGN_PUBLISH_MASK 0x000000ff
// #define FLAG_GROUP_SIGN_PUBLISH_ENCRYPTED 0x00000001
// #define FLAG_GROUP_SIGN_PUBLISH_ALLSIGNED 0x00000002
// #define FLAG_GROUP_SIGN_PUBLISH_THREADHEAD 0x00000004
// #define FLAG_GROUP_SIGN_PUBLISH_NONEREQ 0x00000008
// // Author Signature.
//
// These are now defined in rsgxsflags.h
//
// #define FLAG_AUTHOR_AUTHENTICATION_MASK 0x0000ff00
// #define FLAG_AUTHOR_AUTHENTICATION_NONE 0x00000000
// #define FLAG_AUTHOR_AUTHENTICATION_GPG 0x00000100
// #define FLAG_AUTHOR_AUTHENTICATION_REQUIRED 0x00000200
// #define FLAG_AUTHOR_AUTHENTICATION_IFNOPUBSIGN 0x00000400
2012-10-21 15:45:35 -04:00
2014-07-24 19:26:04 -04:00
# define GXSGROUP_NEWGROUPID 1
# define GXSGROUP_LOADGROUP 2
# define GXSGROUP_INTERNAL_LOADGROUP 3
2012-07-30 19:55:21 -04:00
/** Constructor */
2020-03-22 16:47:14 -04:00
GxsGroupDialog : : GxsGroupDialog ( uint32_t enableFlags , uint32_t defaultFlags , QWidget * parent )
: QDialog ( parent , Qt : : WindowSystemMenuHint | Qt : : WindowTitleHint | Qt : : WindowCloseButtonHint ) , mGrpMeta ( ) , mMode ( MODE_CREATE ) , mEnabledFlags ( enableFlags ) , mReadonlyFlags ( 0 ) , mDefaultsFlags ( defaultFlags )
2012-07-30 19:55:21 -04:00
{
2012-12-15 18:11:11 -05:00
/* Invoke the Qt Designer generated object setup routine */
ui . setupUi ( this ) ;
2017-10-22 06:49:38 -04:00
2012-12-15 18:11:11 -05:00
init ( ) ;
2012-11-28 17:27:19 -05:00
}
2020-03-22 16:47:14 -04:00
GxsGroupDialog : : GxsGroupDialog ( Mode mode , RsGxsGroupId groupId , uint32_t enableFlags , uint32_t defaultFlags , QWidget * parent )
: QDialog ( parent , Qt : : WindowSystemMenuHint | Qt : : WindowTitleHint | Qt : : WindowCloseButtonHint ) , mGrpMeta ( ) , mMode ( mode ) , mEnabledFlags ( enableFlags ) , mReadonlyFlags ( 0 ) , mDefaultsFlags ( defaultFlags )
2012-11-28 17:27:19 -05:00
{
/* Invoke the Qt Designer generated object setup routine */
ui . setupUi ( this ) ;
2014-01-28 02:57:58 -05:00
mGrpMeta . mGroupId = groupId ;
2012-11-28 17:27:19 -05:00
init ( ) ;
}
2014-10-12 06:46:09 -04:00
GxsGroupDialog : : ~ GxsGroupDialog ( )
{
2017-10-22 06:49:38 -04:00
Settings - > saveWidgetInformation ( this ) ;
2014-10-12 06:46:09 -04:00
}
2012-11-28 17:27:19 -05:00
void GxsGroupDialog : : init ( )
{
2012-12-15 18:11:11 -05:00
// connect up the buttons.
2014-07-24 19:26:04 -04:00
connect ( ui . buttonBox , SIGNAL ( accepted ( ) ) , this , SLOT ( submitGroup ( ) ) ) ;
connect ( ui . buttonBox , SIGNAL ( rejected ( ) ) , this , SLOT ( cancelDialog ( ) ) ) ;
connect ( ui . pubKeyShare_cb , SIGNAL ( clicked ( ) ) , this , SLOT ( setShareList ( ) ) ) ;
2018-08-09 15:18:37 -04:00
connect ( ui . addAdmins_cb , SIGNAL ( clicked ( ) ) , this , SLOT ( setAdminsList ( ) ) ) ;
2019-01-06 09:56:39 -05:00
connect ( ui . filtercomboBox , SIGNAL ( currentIndexChanged ( int ) ) , this , SLOT ( filterComboBoxChanged ( int ) ) ) ;
2012-12-15 18:11:11 -05:00
2014-07-24 19:26:04 -04:00
connect ( ui . groupLogo , SIGNAL ( clicked ( ) ) , this , SLOT ( addGroupLogo ( ) ) ) ;
2012-07-30 19:55:21 -04:00
2012-12-15 18:11:11 -05:00
ui . typePublic - > setChecked ( true ) ;
2016-03-20 22:21:09 -04:00
ui . distributionValueLabel - > setText ( tr ( " Public " ) ) ;
2012-12-15 18:11:11 -05:00
updateCircleOptions ( ) ;
2012-11-17 16:43:21 -05:00
2014-07-24 19:26:04 -04:00
connect ( ui . typePublic , SIGNAL ( clicked ( ) ) , this , SLOT ( updateCircleOptions ( ) ) ) ;
connect ( ui . typeGroup , SIGNAL ( clicked ( ) ) , this , SLOT ( updateCircleOptions ( ) ) ) ;
connect ( ui . typeLocal , SIGNAL ( clicked ( ) ) , this , SLOT ( updateCircleOptions ( ) ) ) ;
2012-07-30 19:55:21 -04:00
2012-12-15 18:11:11 -05:00
if ( ! ui . pubKeyShare_cb - > isChecked ( ) )
{
2018-08-09 15:18:37 -04:00
ui . shareKeyList - > hide ( ) ;
//this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height());
2012-12-15 18:11:11 -05:00
}
2018-08-09 15:18:37 -04:00
if ( ! ui . addAdmins_cb - > isChecked ( ) )
{
ui . adminsList - > hide ( ) ;
2019-01-06 09:56:39 -05:00
ui . filtercomboBox - > hide ( ) ;
2018-08-09 15:18:37 -04:00
//this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height());
}
2019-01-06 09:56:39 -05:00
/* Add filter types */
ui . filtercomboBox - > addItem ( tr ( " All People " ) ) ;
ui . filtercomboBox - > addItem ( tr ( " My Contacts " ) ) ;
ui . filtercomboBox - > setCurrentIndex ( 0 ) ;
2018-08-09 15:18:37 -04:00
/* initialize key share list */
ui . shareKeyList - > setHeaderText ( tr ( " Contacts: " ) ) ;
ui . shareKeyList - > setModus ( FriendSelectionWidget : : MODUS_CHECK ) ;
ui . shareKeyList - > start ( ) ;
2012-07-30 19:55:21 -04:00
2012-12-15 18:11:11 -05:00
/* initialize key share list */
2018-08-09 15:18:37 -04:00
ui . adminsList - > setHeaderText ( tr ( " Moderators: " ) ) ;
ui . adminsList - > setModus ( FriendSelectionWidget : : MODUS_CHECK ) ;
ui . adminsList - > setShowType ( FriendSelectionWidget : : SHOW_GXS ) ;
ui . adminsList - > start ( ) ;
2019-01-06 09:56:39 -05:00
2012-07-30 19:55:21 -04:00
2012-12-15 18:11:11 -05:00
/* Setup Reasonable Defaults */
2012-07-30 19:55:21 -04:00
2014-07-24 19:26:04 -04:00
ui . idChooser - > loadIds ( 0 , RsGxsId ( ) ) ;
2016-07-11 18:30:12 -04:00
ui . circleComboBox - > loadCircles ( RsGxsCircleId ( ) ) ;
2016-07-09 18:06:59 -04:00
ui . localComboBox - > loadGroups ( 0 , RsNodeGroupId ( ) ) ;
2014-12-30 16:35:34 -05:00
ui . groupDesc - > setPlaceholderText ( tr ( " Set a descriptive description here " ) ) ;
2012-12-15 18:11:11 -05:00
2015-10-24 00:22:55 -04:00
ui . personal_ifnopub - > hide ( ) ;
ui . personal_required - > hide ( ) ;
ui . personal_required - > setChecked ( true ) ; // this is always true
2012-12-15 18:11:11 -05:00
initMode ( ) ;
2017-10-22 06:49:38 -04:00
Settings - > loadWidgetInformation ( this ) ;
2012-07-30 19:55:21 -04:00
}
2020-02-14 09:01:19 -05:00
void GxsGroupDialog : : injectExtraWidget ( QWidget * widget )
{
// add extra widget into layout.
QVBoxLayout * vbox = new QVBoxLayout ( ) ;
vbox - > addWidget ( widget ) ;
ui . extraFrame - > setLayout ( vbox ) ;
}
2014-07-24 19:26:04 -04:00
QIcon GxsGroupDialog : : serviceWindowIcon ( )
{
return qApp - > windowIcon ( ) ;
}
2012-11-21 13:55:52 -05:00
void GxsGroupDialog : : showEvent ( QShowEvent * )
{
2019-01-19 16:36:19 -05:00
ui . headerFrame - > setHeaderImage ( serviceImage ( ) ) ;
2014-07-24 19:26:04 -04:00
setWindowIcon ( serviceWindowIcon ( ) ) ;
2013-01-06 19:00:46 -05:00
2013-01-07 06:40:05 -05:00
initUi ( ) ;
2020-03-22 16:47:14 -04:00
if ( ! mGrpMeta . mGroupId . isNull ( ) & & mGrpMeta . mPublishTs = = 0 ) // group not actually loaded yet
loadGroup ( mGrpMeta . mGroupId ) ;
2013-01-07 06:40:05 -05:00
}
2013-01-06 19:00:46 -05:00
2013-01-07 06:40:05 -05:00
void GxsGroupDialog : : setUiText ( UiType uiType , const QString & text )
{
switch ( uiType )
{
case UITYPE_SERVICE_HEADER :
setWindowTitle ( text ) ;
2019-01-19 16:36:19 -05:00
ui . headerFrame - > setHeaderText ( text ) ;
2013-01-07 06:40:05 -05:00
break ;
case UITYPE_KEY_SHARE_CHECKBOX :
ui . pubKeyShare_cb - > setText ( text ) ;
break ;
case UITYPE_CONTACTS_DOCK :
2018-08-09 15:18:37 -04:00
case UITYPE_ADD_ADMINS_CHECKBOX :
//ui.contactsdockWidget->setWindowTitle(text);
2013-01-07 06:40:05 -05:00
break ;
2014-04-14 18:36:10 -04:00
case UITYPE_BUTTONBOX_OK :
2014-01-11 17:02:05 -05:00
ui . buttonBox - > button ( QDialogButtonBox : : Ok ) - > setText ( text ) ;
break ;
2013-01-06 19:00:46 -05:00
}
2012-11-21 13:55:52 -05:00
}
2018-08-09 15:18:37 -04:00
void GxsGroupDialog : : setUiToolTip ( UiType uiType , const QString & text )
{
switch ( uiType )
{
case UITYPE_KEY_SHARE_CHECKBOX :
ui . pubKeyShare_cb - > setToolTip ( text ) ;
break ;
case UITYPE_ADD_ADMINS_CHECKBOX :
ui . addAdmins_cb - > setToolTip ( text ) ;
break ;
case UITYPE_BUTTONBOX_OK :
ui . buttonBox - > button ( QDialogButtonBox : : Ok ) - > setToolTip ( text ) ;
default :
break ;
}
}
2012-11-28 17:27:19 -05:00
void GxsGroupDialog : : initMode ( )
2012-07-30 19:55:21 -04:00
{
2014-01-28 02:57:58 -05:00
setAllReadonly ( ) ;
2012-12-15 18:11:11 -05:00
switch ( mode ( ) )
{
case MODE_CREATE :
{
2015-05-03 12:42:58 -04:00
ui . stackedWidget - > setCurrentIndex ( 0 ) ;
2012-12-15 18:11:11 -05:00
ui . buttonBox - > setStandardButtons ( QDialogButtonBox : : Ok | QDialogButtonBox : : Cancel ) ;
newGroup ( ) ;
}
break ;
case MODE_SHOW :
{
2014-12-27 18:51:45 -05:00
ui . stackedWidget - > setCurrentIndex ( 1 ) ;
2014-01-28 02:57:58 -05:00
mReadonlyFlags = 0xffffffff ; // Force all to readonly.
2012-12-15 18:11:11 -05:00
ui . buttonBox - > setStandardButtons ( QDialogButtonBox : : Close ) ;
2014-01-28 02:57:58 -05:00
}
break ;
2014-04-14 18:36:10 -04:00
2014-01-28 02:57:58 -05:00
case MODE_EDIT :
{
2015-05-03 12:42:58 -04:00
ui . stackedWidget - > setCurrentIndex ( 0 ) ;
2014-01-28 02:57:58 -05:00
ui . buttonBox - > setStandardButtons ( QDialogButtonBox : : Ok | QDialogButtonBox : : Cancel ) ;
ui . buttonBox - > button ( QDialogButtonBox : : Ok ) - > setText ( tr ( " Submit Group Changes " ) ) ;
2012-12-15 18:11:11 -05:00
}
break ;
}
2012-07-30 19:55:21 -04:00
}
void GxsGroupDialog : : clearForm ( )
{
ui . groupName - > clear ( ) ;
ui . groupDesc - > clear ( ) ;
ui . groupName - > setFocus ( ) ;
}
void GxsGroupDialog : : setupDefaults ( )
{
/* Enable / Show Parts based on Flags */
2012-12-15 18:11:11 -05:00
if ( mDefaultsFlags & GXS_GROUP_DEFAULTS_DISTRIB_MASK )
{
if ( mDefaultsFlags & GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC )
{
ui . typePublic - > setChecked ( true ) ;
2016-03-20 22:21:09 -04:00
ui . distributionValueLabel - > setText ( tr ( " Public " ) ) ;
ui . distributionCircleComboBox - > setVisible ( false ) ;
2012-12-15 18:11:11 -05:00
}
else if ( mDefaultsFlags & GXS_GROUP_DEFAULTS_DISTRIB_GROUP )
{
ui . typeGroup - > setChecked ( true ) ;
2016-03-20 22:21:09 -04:00
ui . distributionValueLabel - > setText ( tr ( " Restricted to circle: " ) ) ;
ui . distributionCircleComboBox - > setVisible ( true ) ;
2012-12-15 18:11:11 -05:00
}
else if ( mDefaultsFlags & GXS_GROUP_DEFAULTS_DISTRIB_LOCAL )
{
ui . typeLocal - > setChecked ( true ) ;
2016-03-20 22:21:09 -04:00
ui . distributionValueLabel - > setText ( tr ( " Limited to your friends " ) ) ;
ui . distributionCircleComboBox - > setVisible ( false ) ;
2012-12-15 18:11:11 -05:00
}
else
{
// default
ui . typePublic - > setChecked ( true ) ;
}
}
if ( mDefaultsFlags & GXS_GROUP_DEFAULTS_PUBLISH_MASK )
{
if ( mDefaultsFlags & GXS_GROUP_DEFAULTS_PUBLISH_ENCRYPTED )
{
ui . publish_encrypt - > setChecked ( true ) ;
}
else if ( mDefaultsFlags & GXS_GROUP_DEFAULTS_PUBLISH_REQUIRED )
{
ui . publish_required - > setChecked ( true ) ;
}
else if ( mDefaultsFlags & GXS_GROUP_DEFAULTS_PUBLISH_THREADS )
{
ui . publish_threads - > setChecked ( true ) ;
}
else
{
// default
ui . publish_open - > setChecked ( true ) ;
}
}
if ( mDefaultsFlags & GXS_GROUP_DEFAULTS_PERSONAL_MASK )
{
if ( mDefaultsFlags & GXS_GROUP_DEFAULTS_PERSONAL_PGP )
{
ui . personal_pgp - > setChecked ( true ) ;
}
else if ( mDefaultsFlags & GXS_GROUP_DEFAULTS_PERSONAL_REQUIRED )
{
ui . personal_required - > setChecked ( true ) ;
}
else if ( mDefaultsFlags & GXS_GROUP_DEFAULTS_PERSONAL_IFNOPUB )
{
ui . personal_ifnopub - > setChecked ( true ) ;
}
else
{
// default
ui . personal_ifnopub - > setChecked ( true ) ;
}
}
if ( mDefaultsFlags & GXS_GROUP_DEFAULTS_COMMENTS_MASK )
{
if ( mDefaultsFlags & GXS_GROUP_DEFAULTS_COMMENTS_YES )
{
ui . comments_allowed - > setChecked ( true ) ;
2016-03-20 22:21:09 -04:00
ui . commentsValueLabel - > setText ( tr ( " Allowed " ) ) ;
2012-12-15 18:11:11 -05:00
}
else if ( mDefaultsFlags & GXS_GROUP_DEFAULTS_COMMENTS_NO )
{
ui . comments_no - > setChecked ( true ) ;
2016-03-20 22:21:09 -04:00
ui . commentsValueLabel - > setText ( tr ( " Disallowed " ) ) ;
2012-12-15 18:11:11 -05:00
}
else
{
// default
ui . comments_no - > setChecked ( true ) ;
2016-03-20 22:21:09 -04:00
ui . commentsValueLabel - > setText ( tr ( " Allowed " ) ) ;
2012-12-15 18:11:11 -05:00
}
2015-10-25 19:28:13 -04:00
}
2016-06-30 14:16:45 -04:00
if ( ( mDefaultsFlags & GXS_GROUP_DEFAULTS_ANTISPAM_FAVOR_PGP ) & & ( mDefaultsFlags & GXS_GROUP_DEFAULTS_ANTISPAM_FAVOR_PGP_KNOWN ) )
ui . antiSpam_perms_CB - > setCurrentIndex ( 2 ) ;
else if ( mDefaultsFlags & GXS_GROUP_DEFAULTS_ANTISPAM_FAVOR_PGP )
ui . antiSpam_perms_CB - > setCurrentIndex ( 1 ) ;
else
ui . antiSpam_perms_CB - > setCurrentIndex ( 0 ) ;
2016-03-20 22:21:09 -04:00
QString antispam_string ;
if ( mDefaultsFlags & GXS_GROUP_DEFAULTS_ANTISPAM_TRACK ) antispam_string + = tr ( " Message tracking " ) ;
if ( mDefaultsFlags & GXS_GROUP_DEFAULTS_ANTISPAM_FAVOR_PGP ) antispam_string + = ( antispam_string . isNull ( ) ? " " : " and " ) + tr ( " PGP signature required " ) ;
ui . antiSpamValueLabel - > setText ( antispam_string ) ;
2015-10-25 19:28:13 -04:00
2014-09-15 15:14:38 -04:00
# ifndef RS_USE_CIRCLES
ui . typeGroup - > setEnabled ( false ) ;
2014-12-27 18:51:45 -05:00
ui . typeGroup_3 - > setEnabled ( false ) ;
ui . typeLocal_3 - > setEnabled ( false ) ;
2014-09-15 15:14:38 -04:00
# endif
2012-07-30 19:55:21 -04:00
}
void GxsGroupDialog : : setupVisibility ( )
{
2014-04-14 18:36:10 -04:00
ui . groupName - > setVisible ( mEnabledFlags & GXS_GROUP_FLAGS_NAME ) ;
2012-12-15 18:11:11 -05:00
2014-04-14 18:36:10 -04:00
ui . groupLogo - > setVisible ( mEnabledFlags & GXS_GROUP_FLAGS_ICON ) ;
2012-12-15 18:11:11 -05:00
2014-04-14 18:36:10 -04:00
ui . groupDesc - > setVisible ( mEnabledFlags & GXS_GROUP_FLAGS_DESCRIPTION ) ;
2012-12-15 18:11:11 -05:00
2014-04-14 18:36:10 -04:00
ui . distribGroupBox - > setVisible ( mEnabledFlags & GXS_GROUP_FLAGS_DISTRIBUTION ) ;
2016-03-20 22:21:09 -04:00
ui . distributionLabel - > setVisible ( mEnabledFlags & GXS_GROUP_FLAGS_DISTRIBUTION ) ;
ui . distributionValueLabel - > setVisible ( mEnabledFlags & GXS_GROUP_FLAGS_DISTRIBUTION ) ;
2015-10-29 22:58:21 -04:00
ui . spamProtection_GB - > setVisible ( mEnabledFlags & GXS_GROUP_FLAGS_ANTI_SPAM ) ;
2016-03-20 22:21:09 -04:00
ui . antiSpamLabel - > setVisible ( mEnabledFlags & GXS_GROUP_FLAGS_ANTI_SPAM ) ;
ui . antiSpamValueLabel - > setVisible ( mEnabledFlags & GXS_GROUP_FLAGS_ANTI_SPAM ) ;
2012-12-15 18:11:11 -05:00
2014-04-14 18:36:10 -04:00
ui . publishGroupBox - > setVisible ( mEnabledFlags & GXS_GROUP_FLAGS_PUBLISHSIGN ) ;
2012-12-15 18:11:11 -05:00
2014-04-14 18:36:10 -04:00
ui . pubKeyShare_cb - > setVisible ( mEnabledFlags & GXS_GROUP_FLAGS_SHAREKEYS ) ;
2018-08-09 15:18:37 -04:00
ui . addAdmins_cb - > setVisible ( mEnabledFlags & GXS_GROUP_FLAGS_ADDADMINS ) ;
2018-08-30 05:08:49 -04:00
ui . label_8 - > setVisible ( mEnabledFlags & GXS_GROUP_FLAGS_ADDADMINS ) ;
ui . moderatorsLabel - > setVisible ( mEnabledFlags & GXS_GROUP_FLAGS_ADDADMINS ) ;
2012-12-15 18:11:11 -05:00
2014-04-14 18:36:10 -04:00
ui . personalGroupBox - > setVisible ( mEnabledFlags & GXS_GROUP_FLAGS_PERSONALSIGN ) ;
2012-12-15 18:11:11 -05:00
2014-04-14 18:36:10 -04:00
ui . commentGroupBox - > setVisible ( mEnabledFlags & GXS_GROUP_FLAGS_COMMENTS ) ;
2016-03-20 22:21:09 -04:00
ui . commentsLabel - > setVisible ( mEnabledFlags & GXS_GROUP_FLAGS_COMMENTS ) ;
ui . commentsValueLabel - > setVisible ( mEnabledFlags & GXS_GROUP_FLAGS_COMMENTS ) ;
2012-07-30 19:55:21 -04:00
2014-04-14 18:36:10 -04:00
ui . extraFrame - > setVisible ( mEnabledFlags & GXS_GROUP_FLAGS_EXTRA ) ;
}
2012-07-30 19:55:21 -04:00
2014-01-28 02:57:58 -05:00
void GxsGroupDialog : : setAllReadonly ( )
{
uint32_t origReadonlyFlags = mReadonlyFlags ;
mReadonlyFlags = 0xffffffff ;
setupReadonly ( ) ;
mReadonlyFlags = origReadonlyFlags ;
}
void GxsGroupDialog : : setupReadonly ( )
{
2014-04-14 18:36:10 -04:00
ui . publishGroupBox - > setEnabled ( ! ( mReadonlyFlags & GXS_GROUP_FLAGS_PUBLISHSIGN ) ) ;
2014-01-28 02:57:58 -05:00
2014-04-14 18:36:10 -04:00
ui . pubKeyShare_cb - > setEnabled ( ! ( mReadonlyFlags & GXS_GROUP_FLAGS_SHAREKEYS ) ) ;
2014-01-28 02:57:58 -05:00
2014-04-14 18:36:10 -04:00
ui . personalGroupBox - > setEnabled ( ! ( mReadonlyFlags & GXS_GROUP_FLAGS_PERSONALSIGN ) ) ;
2014-12-27 18:51:45 -05:00
2014-04-14 18:36:10 -04:00
ui . idChooser - > setEnabled ( ! ( mReadonlyFlags & GXS_GROUP_FLAGS_PERSONALSIGN ) ) ;
2014-01-28 02:57:58 -05:00
2016-03-20 22:21:09 -04:00
//ui.distribGroupBox_2->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_DISTRIBUTION));
//ui.commentGroupBox_2->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_COMMENTS));
2015-10-29 22:58:21 -04:00
ui . spamProtection_GB - > setEnabled ( ! ( mReadonlyFlags & GXS_GROUP_FLAGS_ANTI_SPAM ) ) ;
2016-03-20 22:21:09 -04:00
//ui.spamProtection_GB_2->setEnabled(!(mReadonlyFlags & GXS_GROUP_FLAGS_ANTI_SPAM));
2014-01-28 02:57:58 -05:00
2014-04-14 18:36:10 -04:00
ui . extraFrame - > setEnabled ( ! ( mReadonlyFlags & GXS_GROUP_FLAGS_EXTRA ) ) ;
2014-09-15 15:14:38 -04:00
# ifndef UNFINISHED
ui . pubKeyShare_cb - > setEnabled ( false ) ;
# endif
2014-04-14 18:36:10 -04:00
}
2014-01-28 02:57:58 -05:00
2012-07-30 19:55:21 -04:00
void GxsGroupDialog : : newGroup ( )
{
2012-12-15 18:11:11 -05:00
setupDefaults ( ) ;
setupVisibility ( ) ;
2014-01-28 02:57:58 -05:00
setupReadonly ( ) ;
2012-12-15 18:11:11 -05:00
clearForm ( ) ;
2012-07-30 19:55:21 -04:00
}
2014-04-14 18:36:10 -04:00
void GxsGroupDialog : : updateFromExistingMeta ( const QString & description )
2014-01-28 02:57:58 -05:00
{
2016-07-11 21:33:09 -04:00
std : : cerr < < " void GxsGroupDialog::updateFromExistingMeta() " ;
std : : cerr < < std : : endl ;
std : : cerr < < " void GxsGroupDialog::updateFromExistingMeta() mGrpMeta.mCircleType: " ;
std : : cerr < < mGrpMeta . mCircleType < < " Internal: " < < mGrpMeta . mInternalCircle ;
std : : cerr < < " External: " < < mGrpMeta . mCircleId ;
std : : cerr < < std : : endl ;
setupDefaults ( ) ;
setupVisibility ( ) ;
setupReadonly ( ) ;
clearForm ( ) ;
setGroupSignFlags ( mGrpMeta . mSignFlags ) ;
2019-01-06 09:56:39 -05:00
RetroShareLink link ;
2016-07-11 21:33:09 -04:00
/* setup name */
ui . groupName - > setText ( QString : : fromUtf8 ( mGrpMeta . mGroupName . c_str ( ) ) ) ;
/* Show Mode */
ui . nameline - > setText ( QString : : fromUtf8 ( mGrpMeta . mGroupName . c_str ( ) ) ) ;
ui . popline - > setText ( QString : : number ( mGrpMeta . mPop ) ) ;
ui . postsline - > setText ( QString : : number ( mGrpMeta . mVisibleMsgCount ) ) ;
2017-01-11 14:44:27 -05:00
if ( mGrpMeta . mLastPost = = 0 )
ui . lastpostline - > setText ( tr ( " Never " ) ) ;
else
ui . lastpostline - > setText ( DateTime : : formatLongDateTime ( mGrpMeta . mLastPost ) ) ;
2015-05-03 03:58:04 -04:00
ui . authorLabel - > setId ( mGrpMeta . mAuthorId ) ;
2019-12-03 17:59:40 -05:00
ui . createdline - > setText ( DateTime : : formatLongDateTime ( mGrpMeta . mPublishTs ) ) ;
2019-01-06 09:56:39 -05:00
link = RetroShareLink : : createMessage ( mGrpMeta . mAuthorId , " " ) ;
ui . authorLabel - > setText ( link . toHtml ( ) ) ;
2016-07-11 21:33:09 -04:00
ui . IDline - > setText ( QString : : fromStdString ( mGrpMeta . mGroupId . toStdString ( ) ) ) ;
ui . descriptiontextEdit - > setPlainText ( description ) ;
switch ( mode ( ) )
{
case MODE_CREATE : {
}
break ;
case MODE_SHOW : {
2019-01-19 16:36:19 -05:00
ui . headerFrame - > setHeaderText ( QString : : fromUtf8 ( mGrpMeta . mGroupName . c_str ( ) ) ) ;
if ( ! mPicture . isNull ( ) )
ui . headerFrame - > setHeaderImage ( mPicture ) ;
2016-07-11 21:33:09 -04:00
}
break ;
case MODE_EDIT : {
}
break ;
}
/* set description */
ui . groupDesc - > setPlainText ( description ) ;
QString distribution_string = " [Unknown] " ;
switch ( mGrpMeta . mCircleType )
{
case GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY :
{
ui . typeLocal - > setChecked ( true ) ;
distribution_string = tr ( " Only friends nodes in group " ) ;
RsGroupInfo ginfo ;
rsPeers - > getGroupInfo ( RsNodeGroupId ( mGrpMeta . mInternalCircle ) , ginfo ) ;
QString desc ;
GroupChooser : : makeNodeGroupDesc ( ginfo , desc ) ;
distribution_string + = desc ;
ui . localComboBox - > loadGroups ( 0 , RsNodeGroupId ( mGrpMeta . mInternalCircle ) ) ;
ui . distributionCircleComboBox - > setVisible ( false ) ;
ui . localComboBox - > setVisible ( true ) ;
}
break ;
case GXS_CIRCLE_TYPE_PUBLIC :
ui . typePublic - > setChecked ( true ) ;
distribution_string = tr ( " Public " ) ;
ui . distributionCircleComboBox - > setVisible ( false ) ;
ui . localComboBox - > setVisible ( false ) ;
break ;
case GXS_CIRCLE_TYPE_EXTERNAL :
ui . typeGroup - > setChecked ( true ) ;
distribution_string = tr ( " Restricted to circle: " ) ;
ui . localComboBox - > setVisible ( false ) ;
ui . distributionCircleComboBox - > setVisible ( true ) ;
ui . distributionCircleComboBox - > loadCircles ( mGrpMeta . mCircleId ) ;
ui . circleComboBox - > loadCircles ( mGrpMeta . mCircleId ) ;
break ;
default :
std : : cerr < < " CreateCircleDialog::updateCircleGUI() INVALID mCircleType " ;
std : : cerr < < std : : endl ;
break ;
}
2016-03-20 22:21:09 -04:00
ui . distributionValueLabel - > setText ( distribution_string ) ;
2014-04-14 18:36:10 -04:00
2016-07-11 21:33:09 -04:00
ui . idChooser - > loadIds ( 0 , mGrpMeta . mAuthorId ) ;
2014-01-28 02:57:58 -05:00
2016-07-11 21:33:09 -04:00
if ( ! mGrpMeta . mAuthorId . isNull ( ) )
ui . idChooser - > setChosenId ( mGrpMeta . mAuthorId ) ;
updateCircleOptions ( ) ;
2012-07-30 19:55:21 -04:00
}
void GxsGroupDialog : : submitGroup ( )
{
2012-12-15 18:11:11 -05:00
std : : cerr < < " GxsGroupDialog::submitGroup() " ;
std : : cerr < < std : : endl ;
/* switch depending on mode */
switch ( mode ( ) )
{
case MODE_CREATE :
{
/* just close if down */
createGroup ( ) ;
}
break ;
case MODE_SHOW :
{
/* just close if down */
cancelDialog ( ) ;
}
break ;
case MODE_EDIT :
{
2014-01-28 02:57:58 -05:00
editGroup ( ) ;
2012-12-15 18:11:11 -05:00
}
break ;
}
2012-07-30 19:55:21 -04:00
}
2014-01-20 02:29:54 -05:00
void GxsGroupDialog : : editGroup ( )
{
2014-02-09 05:43:59 -05:00
std : : cerr < < " GxsGroupDialog::editGroup() " < < std : : endl ;
2014-01-20 02:29:54 -05:00
2014-02-09 05:43:59 -05:00
RsGroupMetaData newMeta ;
newMeta . mGroupId = mGrpMeta . mGroupId ;
2020-03-03 05:56:35 -05:00
QString reason ;
if ( ! prepareGroupMetaData ( newMeta , reason ) )
2014-02-09 05:43:59 -05:00
{
/* error message */
2020-03-03 05:56:35 -05:00
QMessageBox : : warning ( this , " RetroShare " , tr ( " Failed to Prepare Group MetaData: " ) + reason , QMessageBox : : Ok , QMessageBox : : Ok ) ;
2014-02-09 05:43:59 -05:00
return ; //Don't add a empty name!!
}
std : : cerr < < " GxsGroupDialog::editGroup() calling service_EditGroup " ;
std : : cerr < < std : : endl ;
2014-01-20 02:29:54 -05:00
2020-03-22 16:47:14 -04:00
if ( ! service_updateGroup ( newMeta ) )
2014-02-09 05:43:59 -05:00
{
std : : cerr < < " GxsGroupDialog::editGroup() ERROR " ;
std : : cerr < < std : : endl ;
}
2014-01-20 02:29:54 -05:00
2014-02-09 05:43:59 -05:00
close ( ) ;
2013-10-05 07:36:31 -04:00
}
2020-03-03 05:56:35 -05:00
bool GxsGroupDialog : : prepareGroupMetaData ( RsGroupMetaData & meta , QString & reason )
2014-02-09 05:43:59 -05:00
{
std : : cerr < < " GxsGroupDialog::prepareGroupMetaData() " ;
2012-12-15 18:11:11 -05:00
std : : cerr < < std : : endl ;
2015-03-18 09:36:38 -04:00
// here would be the place to check for empty author id
// but GXS_SERV::GRP_OPTION_AUTHEN_AUTHOR_SIGN is currently not used by any service
2020-03-03 05:56:35 -05:00
2015-03-18 09:36:38 -04:00
ui . idChooser - > getChosenId ( meta . mAuthorId ) ;
2020-03-03 05:56:35 -05:00
if ( ( mDefaultsFlags & GXS_GROUP_DEFAULTS_PERSONAL_GROUP ) & & ( meta . mAuthorId . isNull ( ) ) ) {
std : : cerr < < " GxsGroupDialog::prepareGroupMetaData() " ;
std : : cerr < < " Group needs a Personal Signature " ;
std : : cerr < < std : : endl ;
reason = " Missing AuthorId " ;
return false ;
}
2014-07-06 07:19:58 -04:00
2014-07-26 18:29:53 -04:00
QString name = getName ( ) ;
2013-02-28 16:58:38 -05:00
uint32_t flags = GXS_SERV : : FLAG_PRIVACY_PUBLIC ;
2012-12-15 18:11:11 -05:00
2014-07-06 07:19:58 -04:00
if ( name . isEmpty ( ) ) {
2014-02-09 05:43:59 -05:00
std : : cerr < < " GxsGroupDialog::prepareGroupMetaData() " ;
std : : cerr < < " Invalid GroupName " ;
std : : cerr < < std : : endl ;
2020-03-03 05:56:35 -05:00
reason = " Missing GroupName " ;
2014-02-09 05:43:59 -05:00
return false ;
2016-04-03 17:11:13 -04:00
}
2014-07-06 07:19:58 -04:00
2012-12-15 18:11:11 -05:00
// Fill in the MetaData as best we can.
meta . mGroupName = std : : string ( name . toUtf8 ( ) ) ;
meta . mGroupFlags = flags ;
meta . mSignFlags = getGroupSignFlags ( ) ;
2014-07-06 07:19:58 -04:00
if ( ! setCircleParameters ( meta ) ) {
2014-02-09 05:43:59 -05:00
std : : cerr < < " GxsGroupDialog::prepareGroupMetaData() " ;
std : : cerr < < " Invalid Circles " ;
std : : cerr < < std : : endl ;
2020-03-03 05:56:35 -05:00
reason = " Invalid Circle Parameters " ;
2014-02-09 05:43:59 -05:00
return false ;
2016-04-03 17:11:13 -04:00
}
2013-06-04 17:00:43 -04:00
2014-02-09 05:43:59 -05:00
std : : cerr < < " void GxsGroupDialog::prepareGroupMetaData() meta.mCircleType: " ;
2014-01-28 02:57:58 -05:00
std : : cerr < < meta . mCircleType < < " Internal: " < < meta . mInternalCircle ;
std : : cerr < < " External: " < < meta . mCircleId ;
std : : cerr < < std : : endl ;
2013-06-04 17:00:43 -04:00
2014-02-09 05:43:59 -05:00
return true ;
}
2014-07-24 19:26:04 -04:00
2014-02-09 05:43:59 -05:00
void GxsGroupDialog : : createGroup ( )
{
std : : cerr < < " GxsGroupDialog::createGroup() " ;
std : : cerr < < std : : endl ;
2014-07-26 18:29:53 -04:00
/* Check name */
QString name = getName ( ) ;
2014-02-09 05:43:59 -05:00
if ( name . isEmpty ( ) )
{
2014-04-14 18:36:10 -04:00
/* error message */
QMessageBox : : warning ( this , " RetroShare " , tr ( " Please add a Name " ) , QMessageBox : : Ok , QMessageBox : : Ok ) ;
return ; //Don't add a empty name!!
2014-02-09 05:43:59 -05:00
}
RsGroupMetaData meta ;
2020-03-03 05:56:35 -05:00
QString reason ;
if ( ! prepareGroupMetaData ( meta , reason ) )
2014-02-09 05:43:59 -05:00
{
/* error message */
2020-03-03 05:56:35 -05:00
QMessageBox : : warning ( this , " RetroShare " , tr ( " Failed to Prepare Group MetaData: " ) + reason , QMessageBox : : Ok , QMessageBox : : Ok ) ;
2014-02-09 05:43:59 -05:00
return ; //Don't add with invalid circle.
}
2020-03-22 16:47:14 -04:00
if ( service_createGroup ( meta ) )
2012-12-15 18:11:11 -05:00
{
2020-03-22 16:47:14 -04:00
// now update the UI
# warning Missing code here!
# ifdef TODO
//
// get the Queue to handle response. What is this for?
2014-01-28 02:57:58 -05:00
if ( mExternalTokenQueue ! = NULL )
mExternalTokenQueue - > queueRequest ( token , TOKENREQ_GROUPINFO , RS_TOKREQ_ANSTYPE_ACK , GXSGROUP_NEWGROUPID ) ;
2020-03-22 16:47:14 -04:00
# endif
2012-12-15 18:11:11 -05:00
}
2013-03-08 14:55:59 -05:00
2012-12-15 18:11:11 -05:00
close ( ) ;
2012-07-30 19:55:21 -04:00
}
uint32_t GxsGroupDialog : : getGroupSignFlags ( )
{
2016-06-30 14:16:45 -04:00
/* grab from the ui options -> */
uint32_t signFlags = 0 ;
if ( ui . publish_encrypt - > isChecked ( ) ) {
signFlags | = GXS_SERV : : FLAG_GROUP_SIGN_PUBLISH_ENCRYPTED ;
} else if ( ui . publish_required - > isChecked ( ) ) {
signFlags | = GXS_SERV : : FLAG_GROUP_SIGN_PUBLISH_ALLSIGNED ;
} else if ( ui . publish_threads - > isChecked ( ) ) {
signFlags | = GXS_SERV : : FLAG_GROUP_SIGN_PUBLISH_THREADHEAD ;
} else { // publish_open (default).
signFlags | = GXS_SERV : : FLAG_GROUP_SIGN_PUBLISH_NONEREQ ;
}
2012-07-30 19:55:21 -04:00
2016-06-30 14:16:45 -04:00
if ( ui . personal_required - > isChecked ( ) )
signFlags | = GXS_SERV : : FLAG_AUTHOR_AUTHENTICATION_REQUIRED ;
if ( ui . personal_ifnopub - > isChecked ( ) )
signFlags | = GXS_SERV : : FLAG_AUTHOR_AUTHENTICATION_IFNOPUBSIGN ;
// Author Signature.
switch ( ui . antiSpam_perms_CB - > currentIndex ( ) )
{
case 0 : break ;
case 2 : signFlags | = GXS_SERV : : FLAG_AUTHOR_AUTHENTICATION_GPG_KNOWN ; // no break below, since we want *both* flags in this case.
2017-07-15 07:29:33 -04:00
/* fallthrough */
2016-06-30 14:16:45 -04:00
case 1 : signFlags | = GXS_SERV : : FLAG_AUTHOR_AUTHENTICATION_GPG ;
break ;
}
return signFlags ;
2012-07-30 19:55:21 -04:00
}
void GxsGroupDialog : : setGroupSignFlags ( uint32_t signFlags )
{
2015-10-23 22:53:00 -04:00
if ( signFlags & GXS_SERV : : FLAG_GROUP_SIGN_PUBLISH_ENCRYPTED ) {
2012-12-15 18:11:11 -05:00
ui . publish_encrypt - > setChecked ( true ) ;
2015-10-23 22:53:00 -04:00
} else if ( signFlags & GXS_SERV : : FLAG_GROUP_SIGN_PUBLISH_ALLSIGNED ) {
2012-12-15 18:11:11 -05:00
ui . publish_required - > setChecked ( true ) ;
2015-10-23 22:53:00 -04:00
} else if ( signFlags & GXS_SERV : : FLAG_GROUP_SIGN_PUBLISH_THREADHEAD ) {
2012-12-15 18:11:11 -05:00
ui . publish_threads - > setChecked ( true ) ;
2015-10-23 22:53:00 -04:00
} else if ( signFlags & GXS_SERV : : FLAG_GROUP_SIGN_PUBLISH_NONEREQ ) {
2012-12-15 18:11:11 -05:00
ui . publish_open - > setChecked ( true ) ;
}
2015-10-24 00:22:55 -04:00
if ( signFlags & GXS_SERV : : FLAG_AUTHOR_AUTHENTICATION_REQUIRED )
2012-12-15 18:11:11 -05:00
ui . personal_required - > setChecked ( true ) ;
2015-10-24 00:22:55 -04:00
if ( signFlags & GXS_SERV : : FLAG_AUTHOR_AUTHENTICATION_IFNOPUBSIGN )
2012-12-15 18:11:11 -05:00
ui . personal_ifnopub - > setChecked ( true ) ;
2015-10-24 00:22:55 -04:00
2016-06-30 14:16:45 -04:00
if ( ( signFlags & GXS_SERV : : FLAG_AUTHOR_AUTHENTICATION_GPG_KNOWN ) & & ( signFlags & GXS_SERV : : FLAG_AUTHOR_AUTHENTICATION_GPG ) )
ui . antiSpam_perms_CB - > setCurrentIndex ( 2 ) ;
else if ( signFlags & GXS_SERV : : FLAG_AUTHOR_AUTHENTICATION_GPG )
ui . antiSpam_perms_CB - > setCurrentIndex ( 1 ) ;
else
ui . antiSpam_perms_CB - > setCurrentIndex ( 0 ) ;
2016-03-20 22:21:09 -04:00
QString antispam_string ;
if ( signFlags & GXS_SERV : : FLAG_AUTHOR_AUTHENTICATION_TRACK_MESSAGES ) antispam_string + = tr ( " Message tracking " ) ;
2016-06-30 14:16:45 -04:00
if ( signFlags & GXS_SERV : : FLAG_AUTHOR_AUTHENTICATION_GPG_KNOWN ) antispam_string + = ( antispam_string . isNull ( ) ? " " : " and " ) + tr ( " PGP signature from known ID required " ) ;
2016-06-30 15:06:41 -04:00
else
2016-06-30 14:16:45 -04:00
if ( signFlags & GXS_SERV : : FLAG_AUTHOR_AUTHENTICATION_GPG ) antispam_string + = ( antispam_string . isNull ( ) ? " " : " and " ) + tr ( " PGP signature required " ) ;
2016-03-20 22:21:09 -04:00
ui . antiSpamValueLabel - > setText ( antispam_string ) ;
//ui.antiSpam_trackMessages_2->setChecked((bool)(signFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_TRACK_MESSAGES) );
//ui.antiSpam_signedIds_2 ->setChecked((bool)(signFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG) );
2015-10-29 22:58:21 -04:00
//ui.SignEdIds->setChecked((bool)(signFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG) );
//ui.trackmessagesradioButton->setChecked((bool)(signFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_TRACK_MESSAGES) );
2015-10-25 19:28:13 -04:00
2012-12-15 18:11:11 -05:00
/* guess at comments */
2015-10-23 22:53:00 -04:00
if ( ( signFlags & GXS_SERV : : FLAG_GROUP_SIGN_PUBLISH_THREADHEAD ) & &
( signFlags & GXS_SERV : : FLAG_AUTHOR_AUTHENTICATION_IFNOPUBSIGN ) )
2012-12-15 18:11:11 -05:00
{
2016-03-20 22:21:09 -04:00
// (cyril) very weird piece of code. Need to clear this up.
2012-12-15 18:11:11 -05:00
ui . comments_allowed - > setChecked ( true ) ;
2019-03-30 17:53:14 -04:00
ui . commentsValueLabel - > setText ( " Allowed " ) ;
2012-12-15 18:11:11 -05:00
}
else
{
ui . comments_no - > setChecked ( true ) ;
2019-03-30 17:53:14 -04:00
ui . commentsValueLabel - > setText ( " Forbidden " ) ;
2012-12-15 18:11:11 -05:00
}
2012-07-30 19:55:21 -04:00
}
2012-12-15 18:11:11 -05:00
/**** Above logic is flawed, and will be removed shortly
*
*
* * * */
void GxsGroupDialog : : updateCircleOptions ( )
{
if ( ui . typeGroup - > isChecked ( ) )
{
2014-01-28 02:57:58 -05:00
ui . circleComboBox - > setEnabled ( ! ( mReadonlyFlags & GXS_GROUP_FLAGS_DISTRIBUTION ) ) ;
2012-12-15 18:11:11 -05:00
ui . circleComboBox - > setVisible ( true ) ;
}
else
{
ui . circleComboBox - > setEnabled ( false ) ;
ui . circleComboBox - > setVisible ( false ) ;
}
if ( ui . typeLocal - > isChecked ( ) )
{
2014-02-05 02:08:29 -05:00
ui . localComboBox - > setEnabled ( ! ( mReadonlyFlags & GXS_GROUP_FLAGS_DISTRIBUTION ) ) ;
2012-12-15 18:11:11 -05:00
ui . localComboBox - > setVisible ( true ) ;
}
else
{
ui . localComboBox - > setEnabled ( false ) ;
ui . localComboBox - > setVisible ( false ) ;
}
}
2013-06-04 17:00:43 -04:00
bool GxsGroupDialog : : setCircleParameters ( RsGroupMetaData & meta )
2012-12-15 18:11:11 -05:00
{
2016-07-09 18:06:59 -04:00
meta . mCircleType = GXS_CIRCLE_TYPE_PUBLIC ;
meta . mCircleId . clear ( ) ;
meta . mOriginator . clear ( ) ;
meta . mInternalCircle . clear ( ) ;
if ( ui . typePublic - > isChecked ( ) )
{
meta . mCircleType = GXS_CIRCLE_TYPE_PUBLIC ;
meta . mCircleId . clear ( ) ;
}
else if ( ui . typeGroup - > isChecked ( ) )
{
meta . mCircleType = GXS_CIRCLE_TYPE_EXTERNAL ;
if ( ! ui . circleComboBox - > getChosenCircle ( meta . mCircleId ) )
{
return false ;
}
}
else if ( ui . typeLocal - > isChecked ( ) )
{
meta . mCircleType = GXS_CIRCLE_TYPE_YOUR_FRIENDS_ONLY ;
meta . mCircleId . clear ( ) ;
meta . mOriginator . clear ( ) ;
meta . mInternalCircle . clear ( ) ;
RsNodeGroupId ngi ;
if ( ! ui . localComboBox - > getChosenGroup ( ngi ) )
return false ;
meta . mInternalCircle = RsGxsCircleId ( ngi ) ;
}
else
return false ;
return true ;
2012-12-15 18:11:11 -05:00
}
2012-07-30 19:55:21 -04:00
void GxsGroupDialog : : cancelDialog ( )
{
std : : cerr < < " GxsGroupDialog::cancelDialog() Should Close! " ;
std : : cerr < < std : : endl ;
close ( ) ;
}
void GxsGroupDialog : : addGroupLogo ( )
{
QPixmap img = misc : : getOpenThumbnailedPicture ( this , tr ( " Load Group Logo " ) , 64 , 64 ) ;
if ( img . isNull ( ) )
return ;
2014-07-26 18:29:53 -04:00
setLogo ( img ) ;
2012-07-30 19:55:21 -04:00
}
2012-11-11 18:45:22 -05:00
QPixmap GxsGroupDialog : : getLogo ( )
{
2014-07-26 18:29:53 -04:00
return mPicture ;
}
void GxsGroupDialog : : setLogo ( const QPixmap & pixmap )
{
mPicture = pixmap ;
// to show the selected
ui . groupLogo - > setPixmap ( mPicture ) ;
}
QString GxsGroupDialog : : getName ( )
{
return misc : : removeNewLine ( ui . groupName - > text ( ) ) ;
2012-11-11 18:45:22 -05:00
}
2012-07-30 19:55:21 -04:00
2012-11-11 18:45:22 -05:00
QString GxsGroupDialog : : getDescription ( )
{
2014-07-26 18:29:53 -04:00
return ui . groupDesc - > toPlainText ( ) ;
2012-11-11 18:45:22 -05:00
}
2012-07-30 19:55:21 -04:00
2018-08-09 15:18:37 -04:00
void GxsGroupDialog : : getSelectedModerators ( std : : set < RsGxsId > & ids )
{
ui . adminsList - > selectedIds < RsGxsId , FriendSelectionWidget : : IDTYPE_GXS > ( ids , true ) ;
}
2018-08-30 04:54:52 -04:00
void GxsGroupDialog : : setSelectedModerators ( const std : : set < RsGxsId > & ids )
{
2020-04-27 11:00:13 -04:00
ui . addAdmins_cb - > setChecked ( true ) ;
ui . adminsList - > show ( ) ;
ui . filtercomboBox - > show ( ) ;
2018-08-30 04:54:52 -04:00
ui . adminsList - > setSelectedIds < RsGxsId , FriendSelectionWidget : : IDTYPE_GXS > ( ids , false ) ;
2018-08-30 05:08:49 -04:00
QString moderatorsListString ;
RsIdentityDetails det ;
2019-01-06 09:56:39 -05:00
RetroShareLink link ;
2018-08-30 05:08:49 -04:00
for ( auto it ( ids . begin ( ) ) ; it ! = ids . end ( ) ; + + it )
{
rsIdentity - > getIdDetails ( * it , det ) ;
if ( ! moderatorsListString . isNull ( ) )
moderatorsListString + = " , " ;
2019-01-06 09:56:39 -05:00
if ( det . mNickname . empty ( ) )
moderatorsListString + = " [Unknown] " ;
link = RetroShareLink : : createMessage ( det . mId , " " ) ;
if ( link . valid ( ) )
moderatorsListString + = link . toHtml ( ) + " " ;
2018-08-30 05:08:49 -04:00
2019-01-06 09:56:39 -05:00
}
//ui.moderatorsLabel->setId(det.mId);
2018-08-30 05:08:49 -04:00
ui . moderatorsLabel - > setText ( moderatorsListString ) ;
2018-08-30 04:54:52 -04:00
}
2012-07-30 19:55:21 -04:00
/***********************************************************************************
Share Lists .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2014-04-14 18:36:10 -04:00
void GxsGroupDialog : : sendShareList ( std : : string /*groupId*/ )
2012-07-30 19:55:21 -04:00
{
close ( ) ;
}
2018-08-09 15:18:37 -04:00
void GxsGroupDialog : : setAdminsList ( )
{
if ( ui . addAdmins_cb - > isChecked ( ) )
{
//this->resize(this->size().width() + ui.contactsdockWidget->size().width(), this->size().height());
ui . adminsList - > show ( ) ;
2019-01-06 09:56:39 -05:00
ui . filtercomboBox - > show ( ) ;
2018-08-09 15:18:37 -04:00
}
else
{ // hide share widget
ui . adminsList - > hide ( ) ;
2019-01-06 09:56:39 -05:00
ui . filtercomboBox - > hide ( ) ;
2018-08-09 15:18:37 -04:00
//this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height());
}
}
2012-07-30 19:55:21 -04:00
void GxsGroupDialog : : setShareList ( )
{
2014-07-26 18:29:53 -04:00
if ( ui . pubKeyShare_cb - > isChecked ( ) ) {
QMessageBox : : warning ( this , " " , " ToDo " ) ;
ui . pubKeyShare_cb - > setChecked ( false ) ;
2012-12-15 18:11:11 -05:00
}
2014-07-26 18:29:53 -04:00
// if (ui.pubKeyShare_cb->isChecked()){
// this->resize(this->size().width() + ui.contactsdockWidget->size().width(), this->size().height());
// ui.contactsdockWidget->show();
// } else { // hide share widget
// ui.contactsdockWidget->hide();
// this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height());
// }
2012-07-30 19:55:21 -04:00
}
2014-01-28 02:57:58 -05:00
2019-01-06 09:56:39 -05:00
void GxsGroupDialog : : filterComboBoxChanged ( int i )
{
switch ( i )
{
default :
case 0 :
ui . adminsList - > setShowType ( FriendSelectionWidget : : SHOW_GXS ) ;
break ;
case 1 :
ui . adminsList - > setShowType ( FriendSelectionWidget : : SHOW_CONTACTS ) ;
break ;
}
}
2014-01-28 02:57:58 -05:00
/***********************************************************************************
Loading Group .
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2020-03-22 16:47:14 -04:00
void GxsGroupDialog : : loadGroup ( const RsGxsGroupId & grpId )
{
RsThread : : async ( [ this , grpId ] ( )
{
RsGxsGenericGroupData * groupData ;
if ( ! service_getGroupData ( grpId , groupData ) )
{
std : : cerr < < __PRETTY_FUNCTION__ < < " failed to collect group info " < < std : : endl ;
return ;
}
RsQThreadUtils : : postToObject ( [ this , groupData ] ( )
{
/* Here it goes any code you want to be executed on the Qt Gui
* thread , for example to update the data model with new information
* after a blocking call to RetroShare API complete , note that
* Qt : : QueuedConnection is important !
*/
mGrpMeta = groupData - > mMeta ;
QString description ;
if ( service_loadGroup ( groupData , mMode , description ) )
updateFromExistingMeta ( description ) ;
delete groupData ;
} , this ) ;
} ) ;
}