mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 00:49:28 -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"));
|
||||
|
||||
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;
|
||||
mGroupId.clear();
|
||||
|
||||
@ -139,7 +145,11 @@ void IdEditDialog::setupNewId(bool pseudo)
|
||||
|
||||
ui->frame_Tags->setHidden(true);
|
||||
ui->radioButton_GpgId->setEnabled(true);
|
||||
ui->radioButton_Pseudo->setEnabled(true);
|
||||
|
||||
if(enable_anon)
|
||||
ui->radioButton_Pseudo->setEnabled(true);
|
||||
else
|
||||
ui->radioButton_Pseudo->setEnabled(false);
|
||||
|
||||
setAvatar(QPixmap());
|
||||
|
||||
|
@ -45,7 +45,7 @@ public:
|
||||
IdEditDialog(QWidget *parent = 0);
|
||||
~IdEditDialog();
|
||||
|
||||
void setupNewId(bool pseudo);
|
||||
void setupNewId(bool pseudo, bool enable_anon = true);
|
||||
void setupExistingId(const RsGxsGroupId &keyId);
|
||||
void enforceNoAnonIds() ;
|
||||
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "gui/Identity/IdEditDialog.h"
|
||||
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QStandardItemModel>
|
||||
#include <algorithm>
|
||||
|
||||
#include <retroshare/rspeers.h>
|
||||
@ -138,7 +139,6 @@ static void loadPrivateIdsCallback(GxsIdDetailsType type, const RsIdentityDetail
|
||||
switch (type) {
|
||||
case GXS_ID_DETAILS_TYPE_EMPTY:
|
||||
case GXS_ID_DETAILS_TYPE_FAILED:
|
||||
// icons = ;
|
||||
break;
|
||||
|
||||
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->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->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()
|
||||
{
|
||||
if (mFirstLoad) {
|
||||
@ -217,6 +245,8 @@ void GxsIdChooser::loadPrivateIds()
|
||||
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, TYPE_CREATE_ID, ROLE_TYPE);
|
||||
|
||||
|
||||
}
|
||||
setDefaultItem();
|
||||
emit idsLoaded();
|
||||
@ -299,7 +329,7 @@ void GxsIdChooser::indexActivated(int index)
|
||||
int type = itemData(index, ROLE_TYPE).toInt();
|
||||
if (type == TYPE_CREATE_ID) {
|
||||
IdEditDialog dlg(this);
|
||||
dlg.setupNewId(false);
|
||||
dlg.setupNewId(false, !(mFlags & IDCHOOSER_NON_ANONYMOUS));
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
setDefaultId(RsGxsId(dlg.groupId()));
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ class RsGxsUpdateBroadcastBase;
|
||||
#define IDCHOOSER_ID_REQUIRED 0x0001
|
||||
#define IDCHOOSER_ANON_DEFAULT 0x0002
|
||||
#define IDCHOOSER_NO_CREATE 0x0004
|
||||
#define IDCHOOSER_NON_ANONYMOUS 0x0008
|
||||
|
||||
class GxsIdChooser : public QComboBox
|
||||
{
|
||||
@ -48,6 +49,7 @@ public:
|
||||
virtual ~GxsIdChooser();
|
||||
|
||||
void setFlags(uint32_t flags) ;
|
||||
uint32_t flags() const { return mFlags ; }
|
||||
|
||||
enum ChosenId_Ret {None, KnowId, UnKnowId, NoId} ;
|
||||
void loadIds(uint32_t chooserFlags, const RsGxsId &defId);
|
||||
@ -56,6 +58,7 @@ public:
|
||||
bool setChosenId(const RsGxsId &gxsId);
|
||||
ChosenId_Ret getChosenId(RsGxsId &gxsId);
|
||||
|
||||
void setEntryEnabled(int index, bool enabled);
|
||||
signals:
|
||||
// emitted after first load of own ids
|
||||
void idsLoaded();
|
||||
@ -71,13 +74,13 @@ private slots:
|
||||
|
||||
private:
|
||||
void loadPrivateIds();
|
||||
void setDefaultItem();
|
||||
void setDefaultItem();
|
||||
|
||||
uint32_t mFlags;
|
||||
RsGxsId mDefaultId;
|
||||
bool mFirstLoad;
|
||||
|
||||
RsGxsUpdateBroadcastBase *mBase;
|
||||
RsGxsUpdateBroadcastBase *mBase;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -121,7 +121,12 @@ void CreateGxsForumMsg::newMsg()
|
||||
mForumMetaLoaded = false;
|
||||
|
||||
/* fill in the available OwnIds for signing */
|
||||
ui.idChooser->loadIds(IDCHOOSER_ID_REQUIRED, RsGxsId());
|
||||
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());
|
||||
|
||||
if (mForumId.isNull()) {
|
||||
mStateHelper->setActive(CREATEGXSFORUMMSG_FORUMINFO, false);
|
||||
@ -203,6 +208,13 @@ void CreateGxsForumMsg::loadFormInformation()
|
||||
std::cerr << "CreateGxsForumMsg::loadMsgInformation() Data Available!";
|
||||
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 subj;
|
||||
if (!mParentId.isNull())
|
||||
|
Loading…
Reference in New Issue
Block a user