* Added gxs Circle Helper Classes: GxsCircleLabel / Chooser.

* Added Circles into generic GxsGroupDialog.
 	 - Fixed up display of circles in GxsGroupDialog, 
	 - and correctly set GroupMetaData for circles.
 * Added new Circles Window to ApplicationWindow (doesn't do much yet).



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5988 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2012-12-15 23:11:11 +00:00
parent 95cbb57abf
commit 7935c5547f
13 changed files with 1667 additions and 282 deletions

View file

@ -0,0 +1,108 @@
/****************************************************************
* 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 Library General Public License
* as published by the Free Software Foundation; either version 2.1
* 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 "GxsCircleChooser.h"
#include <algorithm>
#include <retroshare/rspeers.h>
#include <iostream>
/** Constructor */
GxsCircleChooser::GxsCircleChooser(QWidget *parent)
: QComboBox(parent), mFlags(0)
{
return;
}
void GxsCircleChooser::loadCircles(uint32_t chooserFlags)
{
mFlags = chooserFlags;
loadGxsCircles();
}
bool MakeGxsCircleDesc(const RsGxsCircleId &id, QString &desc)
{
RsGxsCircleDetails details;
if (rsGxsCircles->getCircleDetails(id, details))
{
desc = QString::fromUtf8(details.mCircleName.c_str());
}
else
{
desc += "Unknown";
}
desc += " (Ext) [";
desc += QString::fromStdString(id.substr(0,5));
desc += "...]";
return true;
}
void GxsCircleChooser::loadGxsCircles()
{
std::list<RsGxsCircleId> ids;
rsGxsCircles->getCircleIdList(ids);
if (ids.empty())
{
std::cerr << "GxsCircleChooser::loadGxsCircles() ERROR no ids";
std::cerr << std::endl;
return;
}
std::list<RsGxsCircleId>::iterator it;
for(it = ids.begin(); it != ids.end(); it++)
{
/* add to Chooser */
QString str;
if (!MakeGxsCircleDesc(*it, str))
{
std::cerr << "GxsCircleChooser::loadGxsCircles() ERROR Desc for Id: " << *it;
std::cerr << std::endl;
continue;
}
QString id = QString::fromStdString(*it);
addItem(str, id);
}
}
bool GxsCircleChooser::getChosenCircle(RsGxsCircleId &id)
{
if (count() < 1)
{
return false;
}
int idx = currentIndex();
QVariant var = itemData(idx);
id = var.toString().toStdString();
return true;
}

View file

@ -0,0 +1,45 @@
/****************************************************************
* 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 Library General Public License
* as published by the Free Software Foundation; either version 2.1
* 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.
****************************************************************/
#ifndef _GXS_CIRCLES_CHOOSER_H
#define _GXS_CIRCLES_CHOOSER_H
#include <QComboBox>
#include <retroshare/rsgxscircles.h>
class GxsCircleChooser : public QComboBox
{
Q_OBJECT
public:
GxsCircleChooser(QWidget *parent = NULL);
void loadCircles(uint32_t chooserFlags);
bool getChosenCircle(RsGxsCircleId &id);
private:
void loadGxsCircles();
uint32_t mFlags;
};
#endif

View file

@ -0,0 +1,103 @@
/****************************************************************
* 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 Library General Public License
* as published by the Free Software Foundation; either version 2.1
* 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 "GxsCircleLabel.h"
#include <algorithm>
#include <retroshare/rspeers.h>
#include <iostream>
/** Constructor */
GxsCircleLabel::GxsCircleLabel(QWidget *parent)
:QLabel(parent), mTimer(NULL), mCount(0)
{
mTimer = new QTimer(this);
mTimer->setSingleShot(true);
connect(mTimer, SIGNAL(timeout()), this, SLOT(loadId()));
return;
}
void GxsCircleLabel::setCircleId(const RsGxsCircleId &id)
{
mId = id;
if (mId == "")
{
setText("No Circle");
}
else
{
loadGxsCircle();
}
}
bool GxsCircleLabel::getCircleId(RsGxsCircleId &id)
{
id = mId;
return true;
}
static bool MakeCircleDesc(const RsGxsCircleId &id, QString &str)
{
RsGxsCircleDetails details;
if (!rsGxsCircles->getCircleDetails(id, details))
{
str = "Loading... " + QString::fromStdString(id.substr(0,5));
return false;
}
str = QString::fromUtf8(details.mCircleName.c_str());
str += " (Ext) [";
str += QString::fromStdString(id.substr(0,5));
str += "...]";
return true;
}
#define MAX_ATTEMPTS 3
void GxsCircleLabel::loadGxsCircle()
{
mCount++;
/* try and get details - if not there ... set callback */
QString desc;
bool loaded = MakeCircleDesc(mId, desc);
setText(desc);
if (loaded)
{
return;
}
if (mCount < MAX_ATTEMPTS)
{
/* timer event to try again (circles take longer) */
mTimer->setInterval(mCount * 3000);
mTimer->start();
}
}

View file

@ -0,0 +1,51 @@
/****************************************************************
* 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 Library General Public License
* as published by the Free Software Foundation; either version 2.1
* 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.
****************************************************************/
#ifndef _GXS_CIRCLE_LABEL_H
#define _GXS_CIRCLE_LABEL_H
#include <QTimer>
#include <QLabel>
#include <retroshare/rsgxscircles.h>
class GxsCircleLabel : public QLabel
{
Q_OBJECT
public:
GxsCircleLabel(QWidget *parent = NULL);
void setCircleId(const RsGxsCircleId &id);
bool getCircleId(RsGxsCircleId &id);
private slots:
void loadGxsCircle();
private:
QTimer *mTimer;
RsGxsCircleId mId;
int mCount;
};
#endif

View file

@ -29,6 +29,7 @@
#include <algorithm>
#include <retroshare/rspeers.h>
#include <retroshare/rsgxscircles.h>
#include <iostream>
@ -51,12 +52,12 @@
/** Constructor */
GxsGroupDialog::GxsGroupDialog(TokenQueue *tokenQueue, uint32_t enableFlags, uint16_t defaultFlags, QWidget *parent)
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint), mTokenQueue(tokenQueue), mMode(MODE_CREATE), mEnabledFlags(enableFlags), mReadonlyFlags(0), mDefaultsFlags(defaultFlags)
: QDialog(parent, Qt::WindowSystemMenuHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint), mTokenQueue(tokenQueue), mMode(MODE_CREATE), mEnabledFlags(enableFlags), mReadonlyFlags(0), mDefaultsFlags(defaultFlags)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
init();
init();
}
GxsGroupDialog::GxsGroupDialog(const RsGroupMetaData &grpMeta, Mode mode, QWidget *parent)
@ -70,64 +71,72 @@ GxsGroupDialog::GxsGroupDialog(const RsGroupMetaData &grpMeta, Mode mode, QWidge
void GxsGroupDialog::init()
{
// connect up the buttons.
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( ) ));
// connect up the buttons.
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( ) ));
connect( ui.groupLogo, SIGNAL(clicked() ), this , SLOT(addGroupLogo()));
connect( ui.addLogoButton, SIGNAL(clicked() ), this , SLOT(addGroupLogo()));
connect( ui.groupLogo, SIGNAL(clicked() ), this , SLOT(addGroupLogo()));
connect( ui.addLogoButton, SIGNAL(clicked() ), this , SLOT(addGroupLogo()));
if (!ui.pubKeyShare_cb->isChecked())
{
ui.contactsdockWidget->hide();
this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height());
}
ui.typePublic->setChecked(true);
updateCircleOptions();
/* initialize key share list */
ui.keyShareList->setHeaderText(tr("Contacts:"));
ui.keyShareList->setModus(FriendSelectionWidget::MODUS_CHECK);
ui.keyShareList->start();
connect( ui.typePublic, SIGNAL(clicked()), this , SLOT(updateCircleOptions()));
connect( ui.typeGroup, SIGNAL(clicked()), this , SLOT(updateCircleOptions()));
connect( ui.typeLocal, SIGNAL(clicked()), this , SLOT(updateCircleOptions()));
/* Setup Reasonable Defaults */
if (!ui.pubKeyShare_cb->isChecked())
{
ui.contactsdockWidget->hide();
this->resize(this->size().width() - ui.contactsdockWidget->size().width(), this->size().height());
}
ui.idChooser->loadIds(0,"");
/* initialize key share list */
ui.keyShareList->setHeaderText(tr("Contacts:"));
ui.keyShareList->setModus(FriendSelectionWidget::MODUS_CHECK);
ui.keyShareList->start();
initMode();
/* Setup Reasonable Defaults */
ui.idChooser->loadIds(0,"");
ui.circleComboBox->loadCircles(0);
initMode();
}
void GxsGroupDialog::showEvent(QShowEvent*)
{
QString header = serviceHeader();
ui.headerFrame->setHeaderText(header);
setWindowTitle(header);
ui.headerFrame->setHeaderImage(serviceImage());
QString header = serviceHeader();
ui.headerFrame->setHeaderText(header);
setWindowTitle(header);
ui.headerFrame->setHeaderImage(serviceImage());
}
void GxsGroupDialog::initMode()
{
switch (mode())
{
case MODE_CREATE:
{
ui.buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
ui.buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Create Group"));
newGroup();
}
break;
switch (mode())
{
case MODE_CREATE:
{
ui.buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
ui.buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Create Group"));
newGroup();
}
break;
case MODE_SHOW:
{
ui.buttonBox->setStandardButtons(QDialogButtonBox::Close);
}
break;
case MODE_SHOW:
{
ui.buttonBox->setStandardButtons(QDialogButtonBox::Close);
}
break;
//TODO
// case MODE_EDIT:
// {
// ui.createButton->setText(tr("Submit Changes"));
// }
// break;
}
// case MODE_EDIT:
// {
// ui.createButton->setText(tr("Submit Changes"));
// }
// break;
}
}
@ -142,259 +151,335 @@ void GxsGroupDialog::setupDefaults()
{
/* Enable / Show Parts based on Flags */
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_DISTRIB_MASK)
{
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC)
{
ui.typePublic->setChecked(true);
}
else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_DISTRIB_GROUP)
{
ui.typeGroup->setChecked(true);
}
else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_DISTRIB_LOCAL)
{
ui.typeLocal->setChecked(true);
}
else
{
// default
ui.typePublic->setChecked(true);
}
}
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_DISTRIB_MASK)
{
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_DISTRIB_PUBLIC)
{
ui.typePublic->setChecked(true);
}
else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_DISTRIB_GROUP)
{
ui.typeGroup->setChecked(true);
}
else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_DISTRIB_LOCAL)
{
ui.typeLocal->setChecked(true);
}
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_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_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);
}
else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_COMMENTS_NO)
{
ui.comments_no->setChecked(true);
}
else
{
// default
ui.comments_no->setChecked(true);
}
}
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_COMMENTS_MASK)
{
if (mDefaultsFlags & GXS_GROUP_DEFAULTS_COMMENTS_YES)
{
ui.comments_allowed->setChecked(true);
}
else if (mDefaultsFlags & GXS_GROUP_DEFAULTS_COMMENTS_NO)
{
ui.comments_no->setChecked(true);
}
else
{
// default
ui.comments_no->setChecked(true);
}
}
}
void GxsGroupDialog::setupVisibility()
{
{
ui.groupLogo->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_ICON);
ui.addLogoButton->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_ICON);
}
{
ui.groupLogo->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_ICON);
ui.addLogoButton->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_ICON);
}
{
ui.groupDesc->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_DESCRIPTION);
ui.groupDescLabel->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_DESCRIPTION);
}
{
ui.groupDesc->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_DESCRIPTION);
ui.groupDescLabel->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_DESCRIPTION);
}
{
ui.distribGroupBox->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_DISTRIBUTION);
}
{
ui.distribGroupBox->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_DISTRIBUTION);
}
{
ui.publishGroupBox->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_PUBLISHSIGN);
}
{
ui.publishGroupBox->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_PUBLISHSIGN);
}
{
ui.pubKeyShare_cb->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_SHAREKEYS);
}
{
ui.pubKeyShare_cb->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_SHAREKEYS);
}
{
ui.personalGroupBox->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_PERSONALSIGN);
}
{
ui.personalGroupBox->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_PERSONALSIGN);
}
{
ui.commentGroupBox->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_COMMENTS);
}
{
ui.commentGroupBox->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_COMMENTS);
}
{
ui.extraFrame->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_EXTRA);
}
{
ui.extraFrame->setVisible(mEnabledFlags & GXS_GROUP_FLAGS_EXTRA);
}
}
void GxsGroupDialog::newGroup()
{
setupDefaults();
setupVisibility();
clearForm();
setupDefaults();
setupVisibility();
clearForm();
}
void GxsGroupDialog::submitGroup()
{
std::cerr << "GxsGroupDialog::submitGroup()";
std::cerr << std::endl;
std::cerr << "GxsGroupDialog::submitGroup()";
std::cerr << std::endl;
/* switch depending on mode */
switch (mode())
{
case MODE_CREATE:
{
/* just close if down */
createGroup();
}
break;
/* 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_SHOW:
{
/* just close if down */
cancelDialog();
}
break;
case MODE_EDIT:
{
/* TEMP: just close if down */
cancelDialog();
}
break;
}
case MODE_EDIT:
{
/* TEMP: just close if down */
cancelDialog();
}
break;
}
}
void GxsGroupDialog::createGroup()
{
std::cerr << "GxsGroupDialog::createGroup()";
std::cerr << std::endl;
std::cerr << "GxsGroupDialog::createGroup()";
std::cerr << std::endl;
QString name = misc::removeNewLine(ui.groupName->text());
uint32_t flags = 0;
QString name = misc::removeNewLine(ui.groupName->text());
uint32_t flags = 0;
if(name.isEmpty())
{
/* error message */
QMessageBox::warning(this, "RetroShare", tr("Please add a Name"), QMessageBox::Ok, QMessageBox::Ok);
return; //Don't add a empty name!!
}
if(name.isEmpty())
{
/* error message */
QMessageBox::warning(this, "RetroShare", tr("Please add a Name"), QMessageBox::Ok, QMessageBox::Ok);
return; //Don't add a empty name!!
}
uint32_t token;
RsGroupMetaData meta;
uint32_t token;
RsGroupMetaData meta;
// Fill in the MetaData as best we can.
meta.mGroupName = std::string(name.toUtf8());
// Fill in the MetaData as best we can.
meta.mGroupName = std::string(name.toUtf8());
meta.mGroupFlags = flags;
meta.mSignFlags = getGroupSignFlags();
meta.mGroupFlags = flags;
meta.mSignFlags = getGroupSignFlags();
if (service_CreateGroup(token, meta))
{
// get the Queue to handle response.
if(mTokenQueue != NULL)
mTokenQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_ACK, GXSGROUP_NEWGROUPID);
}
close();
setCircleParameters(meta);
if (service_CreateGroup(token, meta))
{
// get the Queue to handle response.
if(mTokenQueue != NULL)
mTokenQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_ACK, GXSGROUP_NEWGROUPID);
}
close();
}
uint32_t GxsGroupDialog::getGroupSignFlags()
{
/* grab from the ui options -> */
uint32_t signFlags = 0;
if (ui.publish_encrypt->isChecked()) {
signFlags |= RSGXS_GROUP_SIGN_PUBLISH_ENCRYPTED;
} else if (ui.publish_required->isChecked()) {
signFlags |= RSGXS_GROUP_SIGN_PUBLISH_ALLSIGNED;
} else if (ui.publish_threads->isChecked()) {
signFlags |= RSGXS_GROUP_SIGN_PUBLISH_THREADHEAD;
} else { // publish_open (default).
signFlags |= RSGXS_GROUP_SIGN_PUBLISH_NONEREQ;
}
/* grab from the ui options -> */
uint32_t signFlags = 0;
if (ui.publish_encrypt->isChecked()) {
signFlags |= RSGXS_GROUP_SIGN_PUBLISH_ENCRYPTED;
} else if (ui.publish_required->isChecked()) {
signFlags |= RSGXS_GROUP_SIGN_PUBLISH_ALLSIGNED;
} else if (ui.publish_threads->isChecked()) {
signFlags |= RSGXS_GROUP_SIGN_PUBLISH_THREADHEAD;
} else { // publish_open (default).
signFlags |= RSGXS_GROUP_SIGN_PUBLISH_NONEREQ;
}
// Author Signature.
if (ui.personal_pgp->isChecked()) {
signFlags |= RSGXS_GROUP_SIGN_AUTHOR_GPG;
} else if (ui.personal_required->isChecked()) {
signFlags |= RSGXS_GROUP_SIGN_AUTHOR_REQUIRED;
} else if (ui.personal_ifnopub->isChecked()) {
signFlags |= RSGXS_GROUP_SIGN_AUTHOR_IFNOPUBSIGN;
} else { // shouldn't allow this one.
signFlags |= RSGXS_GROUP_SIGN_AUTHOR_NONE;
}
return signFlags;
if (ui.personal_pgp->isChecked()) {
signFlags |= RSGXS_GROUP_SIGN_AUTHOR_GPG;
} else if (ui.personal_required->isChecked()) {
signFlags |= RSGXS_GROUP_SIGN_AUTHOR_REQUIRED;
} else if (ui.personal_ifnopub->isChecked()) {
signFlags |= RSGXS_GROUP_SIGN_AUTHOR_IFNOPUBSIGN;
} else { // shouldn't allow this one.
signFlags |= RSGXS_GROUP_SIGN_AUTHOR_NONE;
}
return signFlags;
}
void GxsGroupDialog::setGroupSignFlags(uint32_t signFlags)
{
if (signFlags & RSGXS_GROUP_SIGN_PUBLISH_ENCRYPTED) {
ui.publish_encrypt->setChecked(true);
} else if (signFlags & RSGXS_GROUP_SIGN_PUBLISH_ALLSIGNED) {
ui.publish_required->setChecked(true);
} else if (signFlags & RSGXS_GROUP_SIGN_PUBLISH_THREADHEAD) {
ui.publish_threads->setChecked(true);
} else if (signFlags & RSGXS_GROUP_SIGN_PUBLISH_NONEREQ) {
ui.publish_open->setChecked(true);
}
if (signFlags & RSGXS_GROUP_SIGN_PUBLISH_ENCRYPTED) {
ui.publish_encrypt->setChecked(true);
} else if (signFlags & RSGXS_GROUP_SIGN_PUBLISH_ALLSIGNED) {
ui.publish_required->setChecked(true);
} else if (signFlags & RSGXS_GROUP_SIGN_PUBLISH_THREADHEAD) {
ui.publish_threads->setChecked(true);
} else if (signFlags & RSGXS_GROUP_SIGN_PUBLISH_NONEREQ) {
ui.publish_open->setChecked(true);
}
if (signFlags & RSGXS_GROUP_SIGN_AUTHOR_GPG) {
ui.personal_pgp->setChecked(true);
} else if (signFlags & RSGXS_GROUP_SIGN_AUTHOR_REQUIRED) {
ui.personal_required->setChecked(true);
} else if (signFlags & RSGXS_GROUP_SIGN_AUTHOR_IFNOPUBSIGN) {
ui.personal_ifnopub->setChecked(true);
} else if (signFlags & RSGXS_GROUP_SIGN_AUTHOR_NONE) {
// Its the same... but not quite.
//ui.personal_noifpub->setChecked();
}
if (signFlags & RSGXS_GROUP_SIGN_AUTHOR_GPG) {
ui.personal_pgp->setChecked(true);
} else if (signFlags & RSGXS_GROUP_SIGN_AUTHOR_REQUIRED) {
ui.personal_required->setChecked(true);
} else if (signFlags & RSGXS_GROUP_SIGN_AUTHOR_IFNOPUBSIGN) {
ui.personal_ifnopub->setChecked(true);
} else if (signFlags & RSGXS_GROUP_SIGN_AUTHOR_NONE) {
// Its the same... but not quite.
//ui.personal_noifpub->setChecked();
}
/* guess at comments */
if ((signFlags & RSGXS_GROUP_SIGN_PUBLISH_THREADHEAD)
&& (signFlags & RSGXS_GROUP_SIGN_AUTHOR_IFNOPUBSIGN))
{
ui.comments_allowed->setChecked(true);
}
else
{
ui.comments_no->setChecked(true);
}
/* guess at comments */
if ((signFlags & RSGXS_GROUP_SIGN_PUBLISH_THREADHEAD)
&& (signFlags & RSGXS_GROUP_SIGN_AUTHOR_IFNOPUBSIGN))
{
ui.comments_allowed->setChecked(true);
}
else
{
ui.comments_no->setChecked(true);
}
}
/**** Above logic is flawed, and will be removed shortly
*
*
****/
void GxsGroupDialog::updateCircleOptions()
{
if (ui.typeGroup->isChecked())
{
ui.circleComboBox->setEnabled(true);
ui.circleComboBox->setVisible(true);
}
else
{
ui.circleComboBox->setEnabled(false);
ui.circleComboBox->setVisible(false);
}
if (ui.typeLocal->isChecked())
{
ui.localComboBox->setEnabled(true);
ui.localComboBox->setVisible(true);
}
else
{
ui.localComboBox->setEnabled(false);
ui.localComboBox->setVisible(false);
}
}
void GxsGroupDialog::setCircleParameters(RsGroupMetaData &meta)
{
bool problem = false;
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))
{
problem = true;
}
}
else if (ui.typeGroup->isChecked())
{
meta.mCircleType = GXS_CIRCLE_TYPE_YOUREYESONLY;
meta.mCircleId.clear();
meta.mOriginator.clear();
meta.mInternalCircle = "Internal Circle Id";
problem = true;
}
else
{
problem = true;
}
if (problem)
{
// error.
meta.mCircleType = GXS_CIRCLE_TYPE_PUBLIC;
meta.mCircleId.clear();
meta.mOriginator.clear();
meta.mInternalCircle.clear();
}
}
void GxsGroupDialog::cancelDialog()
{
std::cerr << "GxsGroupDialog::cancelDialog() Should Close!";
@ -418,12 +503,12 @@ void GxsGroupDialog::addGroupLogo()
QPixmap GxsGroupDialog::getLogo()
{
return picture;
return picture;
}
QString GxsGroupDialog::getDescription()
{
return ui.groupDesc->document()->toPlainText();
return ui.groupDesc->document()->toPlainText();
}
/***********************************************************************************
@ -437,13 +522,13 @@ void GxsGroupDialog::sendShareList(std::string groupId)
void GxsGroupDialog::setShareList()
{
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());
}
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());
}
}
void GxsGroupDialog::wikitype()

View file

@ -188,8 +188,14 @@ private slots:
// set private forum key share list
void setShareList();
void updateCircleOptions();
private:
void setCircleParameters(RsGroupMetaData &meta);
void setGroupSignFlags(uint32_t signFlags);
uint32_t getGroupSignFlags();
void setupDefaults();

View file

@ -297,19 +297,16 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
<widget class="QComboBox" name="groupComboBox">
<item>
<property name="text">
<string>Select Group of Friends</string>
</property>
</item>
</widget>
<widget class="GxsCircleChooser" name="circleComboBox"/>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::MinimumExpanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
@ -319,25 +316,29 @@
</spacer>
</item>
<item>
<widget class="QPushButton" name="editGroupsButton">
<property name="text">
<string>Edit Groups</string>
</property>
<widget class="QComboBox" name="localComboBox">
<item>
<property name="text">
<string>Some Friends</string>
</property>
</item>
<item>
<property name="text">
<string>Another Group</string>
</property>
</item>
<item>
<property name="text">
<string>Family?</string>
</property>
</item>
<item>
<property name="text">
<string>Enemies</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
@ -491,6 +492,11 @@
<header>gui/common/FriendSelectionWidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>GxsCircleChooser</class>
<extends>QComboBox</extends>
<header>gui/gxs/GxsCircleChooser.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../images.qrc"/>