diff --git a/retroshare-gui/src/gui/Identity/IdEditDialog.cpp b/retroshare-gui/src/gui/Identity/IdEditDialog.cpp index e4bbc7662..9cd8c60e9 100644 --- a/retroshare-gui/src/gui/Identity/IdEditDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdEditDialog.cpp @@ -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()); diff --git a/retroshare-gui/src/gui/Identity/IdEditDialog.h b/retroshare-gui/src/gui/Identity/IdEditDialog.h index d46cd7de3..d97aee090 100644 --- a/retroshare-gui/src/gui/Identity/IdEditDialog.h +++ b/retroshare-gui/src/gui/Identity/IdEditDialog.h @@ -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() ; diff --git a/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp b/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp index 7fb83f131..526c7fe43 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp +++ b/retroshare-gui/src/gui/gxs/GxsIdChooser.cpp @@ -27,6 +27,7 @@ #include "gui/Identity/IdEditDialog.h" #include +#include #include #include @@ -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(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())); } diff --git a/retroshare-gui/src/gui/gxs/GxsIdChooser.h b/retroshare-gui/src/gui/gxs/GxsIdChooser.h index e785fb227..98c33a052 100644 --- a/retroshare-gui/src/gui/gxs/GxsIdChooser.h +++ b/retroshare-gui/src/gui/gxs/GxsIdChooser.h @@ -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 diff --git a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp index d9e83111a..bacf1349f 100644 --- a/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp +++ b/retroshare-gui/src/gui/gxsforums/CreateGxsForumMsg.cpp @@ -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())