mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-15 09:27:09 -05:00
added new flag to GxsIdChooser to force non anonymous ids. Disabled by default
This commit is contained in:
parent
e0db78f71a
commit
8ea97711e8
@ -113,10 +113,16 @@ void IdEditDialog::changeAvatar()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IdEditDialog::setupNewId(bool pseudo)
|
void IdEditDialog::setupNewId(bool pseudo,bool enable_anon)
|
||||||
{
|
{
|
||||||
setWindowTitle(tr("New identity"));
|
setWindowTitle(tr("New identity"));
|
||||||
|
|
||||||
|
if(pseudo && !enable_anon)
|
||||||
|
{
|
||||||
|
std::cerr << "IdEditDialog::setupNewId: Error. Cannot init with pseudo-anonymous id when anon ids are disabled." << std::endl;
|
||||||
|
pseudo = false ;
|
||||||
|
}
|
||||||
|
|
||||||
mIsNew = true;
|
mIsNew = true;
|
||||||
mGroupId.clear();
|
mGroupId.clear();
|
||||||
|
|
||||||
@ -139,7 +145,11 @@ void IdEditDialog::setupNewId(bool pseudo)
|
|||||||
|
|
||||||
ui->frame_Tags->setHidden(true);
|
ui->frame_Tags->setHidden(true);
|
||||||
ui->radioButton_GpgId->setEnabled(true);
|
ui->radioButton_GpgId->setEnabled(true);
|
||||||
|
|
||||||
|
if(enable_anon)
|
||||||
ui->radioButton_Pseudo->setEnabled(true);
|
ui->radioButton_Pseudo->setEnabled(true);
|
||||||
|
else
|
||||||
|
ui->radioButton_Pseudo->setEnabled(false);
|
||||||
|
|
||||||
setAvatar(QPixmap());
|
setAvatar(QPixmap());
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public:
|
|||||||
IdEditDialog(QWidget *parent = 0);
|
IdEditDialog(QWidget *parent = 0);
|
||||||
~IdEditDialog();
|
~IdEditDialog();
|
||||||
|
|
||||||
void setupNewId(bool pseudo);
|
void setupNewId(bool pseudo, bool enable_anon = true);
|
||||||
void setupExistingId(const RsGxsGroupId &keyId);
|
void setupExistingId(const RsGxsGroupId &keyId);
|
||||||
void enforceNoAnonIds() ;
|
void enforceNoAnonIds() ;
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "gui/Identity/IdEditDialog.h"
|
#include "gui/Identity/IdEditDialog.h"
|
||||||
|
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSortFilterProxyModel>
|
||||||
|
#include <QStandardItemModel>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include <retroshare/rspeers.h>
|
#include <retroshare/rspeers.h>
|
||||||
@ -138,7 +139,6 @@ static void loadPrivateIdsCallback(GxsIdDetailsType type, const RsIdentityDetail
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case GXS_ID_DETAILS_TYPE_EMPTY:
|
case GXS_ID_DETAILS_TYPE_EMPTY:
|
||||||
case GXS_ID_DETAILS_TYPE_FAILED:
|
case GXS_ID_DETAILS_TYPE_FAILED:
|
||||||
// icons = ;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GXS_ID_DETAILS_TYPE_LOADING:
|
case GXS_ID_DETAILS_TYPE_LOADING:
|
||||||
@ -154,11 +154,39 @@ static void loadPrivateIdsCallback(GxsIdDetailsType type, const RsIdentityDetail
|
|||||||
chooser->setItemData(index, (type == GXS_ID_DETAILS_TYPE_DONE) ? TYPE_FOUND_ID : TYPE_UNKNOWN_ID, ROLE_TYPE);
|
chooser->setItemData(index, (type == GXS_ID_DETAILS_TYPE_DONE) ? TYPE_FOUND_ID : TYPE_UNKNOWN_ID, ROLE_TYPE);
|
||||||
chooser->setItemIcon(index, icons.empty() ? QIcon() : icons[0]);
|
chooser->setItemIcon(index, icons.empty() ? QIcon() : icons[0]);
|
||||||
|
|
||||||
|
std::cerr << "ID=" << details.mId << ", chooser->flags()=" << chooser->flags() << ", pgpLinked=" << details.mPgpLinked ;
|
||||||
|
|
||||||
|
if((chooser->flags() & IDCHOOSER_NON_ANONYMOUS) && !(details.mPgpLinked))
|
||||||
|
{
|
||||||
|
std::cerr << " - disabling ID - entry = " << index << std::endl;
|
||||||
|
chooser->setEntryEnabled(index,false) ;
|
||||||
|
}
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
chooser->model()->sort(0);
|
chooser->model()->sort(0);
|
||||||
|
|
||||||
chooser->blockSignals(false) ;
|
chooser->blockSignals(false) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GxsIdChooser::setEntryEnabled(int indx,bool enabled)
|
||||||
|
{
|
||||||
|
bool disable = !enabled ;
|
||||||
|
|
||||||
|
QSortFilterProxyModel* model = qobject_cast<QSortFilterProxyModel*>(QComboBox::model());
|
||||||
|
//QStandardItem* item = model->item(index);
|
||||||
|
|
||||||
|
QModelIndex ii = model->index(indx,0);
|
||||||
|
|
||||||
|
// visually disable by greying out - works only if combobox has been painted already and palette returns the wanted color
|
||||||
|
//model->setFlags(ii,disable ? (model->flags(ii) & ~(Qt::ItemIsSelectable|Qt::ItemIsEnabled)) : (Qt::ItemIsSelectable|Qt::ItemIsEnabled));
|
||||||
|
|
||||||
|
uint32_t v = enabled?(1|32):(0);
|
||||||
|
|
||||||
|
// clear item data in order to use default color
|
||||||
|
//model->setData(ii,disable ? (QComboBox::palette().color(QPalette::Disabled, QPalette::Text)) : QVariant(), Qt::TextColorRole);
|
||||||
|
model->setData(ii,QVariant(v),Qt::UserRole-1) ;
|
||||||
|
}
|
||||||
|
|
||||||
void GxsIdChooser::loadPrivateIds()
|
void GxsIdChooser::loadPrivateIds()
|
||||||
{
|
{
|
||||||
if (mFirstLoad) {
|
if (mFirstLoad) {
|
||||||
@ -217,6 +245,8 @@ void GxsIdChooser::loadPrivateIds()
|
|||||||
addItem(QIcon(":/images/identity/identity_create_32.png"), str, id);
|
addItem(QIcon(":/images/identity/identity_create_32.png"), str, id);
|
||||||
setItemData(count() - 1, QString("%1_%2").arg(TYPE_CREATE_ID).arg(str), ROLE_SORT);
|
setItemData(count() - 1, QString("%1_%2").arg(TYPE_CREATE_ID).arg(str), ROLE_SORT);
|
||||||
setItemData(count() - 1, TYPE_CREATE_ID, ROLE_TYPE);
|
setItemData(count() - 1, TYPE_CREATE_ID, ROLE_TYPE);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
setDefaultItem();
|
setDefaultItem();
|
||||||
emit idsLoaded();
|
emit idsLoaded();
|
||||||
@ -299,7 +329,7 @@ void GxsIdChooser::indexActivated(int index)
|
|||||||
int type = itemData(index, ROLE_TYPE).toInt();
|
int type = itemData(index, ROLE_TYPE).toInt();
|
||||||
if (type == TYPE_CREATE_ID) {
|
if (type == TYPE_CREATE_ID) {
|
||||||
IdEditDialog dlg(this);
|
IdEditDialog dlg(this);
|
||||||
dlg.setupNewId(false);
|
dlg.setupNewId(false, !(mFlags & IDCHOOSER_NON_ANONYMOUS));
|
||||||
if (dlg.exec() == QDialog::Accepted) {
|
if (dlg.exec() == QDialog::Accepted) {
|
||||||
setDefaultId(RsGxsId(dlg.groupId()));
|
setDefaultId(RsGxsId(dlg.groupId()));
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ class RsGxsUpdateBroadcastBase;
|
|||||||
#define IDCHOOSER_ID_REQUIRED 0x0001
|
#define IDCHOOSER_ID_REQUIRED 0x0001
|
||||||
#define IDCHOOSER_ANON_DEFAULT 0x0002
|
#define IDCHOOSER_ANON_DEFAULT 0x0002
|
||||||
#define IDCHOOSER_NO_CREATE 0x0004
|
#define IDCHOOSER_NO_CREATE 0x0004
|
||||||
|
#define IDCHOOSER_NON_ANONYMOUS 0x0008
|
||||||
|
|
||||||
class GxsIdChooser : public QComboBox
|
class GxsIdChooser : public QComboBox
|
||||||
{
|
{
|
||||||
@ -48,6 +49,7 @@ public:
|
|||||||
virtual ~GxsIdChooser();
|
virtual ~GxsIdChooser();
|
||||||
|
|
||||||
void setFlags(uint32_t flags) ;
|
void setFlags(uint32_t flags) ;
|
||||||
|
uint32_t flags() const { return mFlags ; }
|
||||||
|
|
||||||
enum ChosenId_Ret {None, KnowId, UnKnowId, NoId} ;
|
enum ChosenId_Ret {None, KnowId, UnKnowId, NoId} ;
|
||||||
void loadIds(uint32_t chooserFlags, const RsGxsId &defId);
|
void loadIds(uint32_t chooserFlags, const RsGxsId &defId);
|
||||||
@ -56,6 +58,7 @@ public:
|
|||||||
bool setChosenId(const RsGxsId &gxsId);
|
bool setChosenId(const RsGxsId &gxsId);
|
||||||
ChosenId_Ret getChosenId(RsGxsId &gxsId);
|
ChosenId_Ret getChosenId(RsGxsId &gxsId);
|
||||||
|
|
||||||
|
void setEntryEnabled(int index, bool enabled);
|
||||||
signals:
|
signals:
|
||||||
// emitted after first load of own ids
|
// emitted after first load of own ids
|
||||||
void idsLoaded();
|
void idsLoaded();
|
||||||
|
@ -121,6 +121,11 @@ void CreateGxsForumMsg::newMsg()
|
|||||||
mForumMetaLoaded = false;
|
mForumMetaLoaded = false;
|
||||||
|
|
||||||
/* fill in the available OwnIds for signing */
|
/* fill in the available OwnIds for signing */
|
||||||
|
std::cerr << "Initing ID chooser. Sign flags = " << std::hex << mForumMeta.mSignFlags << std::dec << std::endl;
|
||||||
|
|
||||||
|
if(mForumMeta.mSignFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG)
|
||||||
|
ui.idChooser->loadIds(IDCHOOSER_ID_REQUIRED | IDCHOOSER_NON_ANONYMOUS, RsGxsId());
|
||||||
|
else
|
||||||
ui.idChooser->loadIds(IDCHOOSER_ID_REQUIRED, RsGxsId());
|
ui.idChooser->loadIds(IDCHOOSER_ID_REQUIRED, RsGxsId());
|
||||||
|
|
||||||
if (mForumId.isNull()) {
|
if (mForumId.isNull()) {
|
||||||
@ -203,6 +208,13 @@ void CreateGxsForumMsg::loadFormInformation()
|
|||||||
std::cerr << "CreateGxsForumMsg::loadMsgInformation() Data Available!";
|
std::cerr << "CreateGxsForumMsg::loadMsgInformation() Data Available!";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
std::cerr << "CreateGxsForumMsg::loadMsgInformation() using signFlags=" << std::hex << mForumMeta.mSignFlags << std::dec << std::endl;
|
||||||
|
|
||||||
|
if(mForumMeta.mSignFlags & GXS_SERV::FLAG_AUTHOR_AUTHENTICATION_GPG)
|
||||||
|
ui.idChooser->setFlags(IDCHOOSER_ID_REQUIRED | IDCHOOSER_NON_ANONYMOUS) ;
|
||||||
|
else
|
||||||
|
ui.idChooser->setFlags(IDCHOOSER_ID_REQUIRED) ;
|
||||||
|
|
||||||
QString name = QString::fromUtf8(mForumMeta.mGroupName.c_str());
|
QString name = QString::fromUtf8(mForumMeta.mGroupName.c_str());
|
||||||
QString subj;
|
QString subj;
|
||||||
if (!mParentId.isNull())
|
if (!mParentId.isNull())
|
||||||
|
Loading…
Reference in New Issue
Block a user