Used RsGxsGroupId instead of std:string for id/name in IdEditDialog/GxsidChooser.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7936 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2015-02-10 12:55:16 +00:00
parent 05d25a83d5
commit 0a1698f8c8
6 changed files with 63 additions and 40 deletions

View File

@ -843,7 +843,10 @@ void IdDialog::editIdentity()
return;
}
std::string keyId = item->text(RSID_COL_KEYID).toStdString();
RsGxsGroupId keyId = RsGxsGroupId(item->text(RSID_COL_KEYID).toStdString());
if (keyId.isNull()) {
return;
}
IdEditDialog dlg(this);
dlg.setupExistingId(keyId);

View File

@ -36,7 +36,8 @@
#include <iostream>
#define IDEDITDIALOG_LOADID 1
#define IDEDITDIALOG_LOADID 1
#define IDEDITDIALOG_CREATEID 2
/** Constructor */
IdEditDialog::IdEditDialog(QWidget *parent) :
@ -44,7 +45,6 @@ IdEditDialog::IdEditDialog(QWidget *parent) :
ui(new(Ui::IdEditDialog))
{
mIsNew = true;
mLastIdName="";
ui->setupUi(this);
@ -76,7 +76,7 @@ IdEditDialog::IdEditDialog(QWidget *parent) :
connect(ui->radioButton_GpgId, SIGNAL(toggled(bool)), this, SLOT(idTypeToggled(bool)));
connect(ui->radioButton_Pseudo, SIGNAL(toggled(bool)), this, SLOT(idTypeToggled(bool)));
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(submit()));
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(close()));
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
connect(ui->plainTextEdit_Tag, SIGNAL(textChanged()), this, SLOT(checkNewTag()));
connect(ui->pushButton_Tag, SIGNAL(clicked(bool)), this, SLOT(addRecognTag()));
@ -114,6 +114,7 @@ void IdEditDialog::setupNewId(bool pseudo)
setWindowTitle(tr("New identity"));
mIsNew = true;
mGroupId.clear();
ui->lineEdit_KeyId->setText(tr("To be generated"));
ui->lineEdit_Nickname->setText("");
@ -181,13 +182,14 @@ void IdEditDialog::setAvatar(const QPixmap &avatar)
}
}
void IdEditDialog::setupExistingId(std::string keyId)
void IdEditDialog::setupExistingId(const RsGxsGroupId &keyId)
{
setWindowTitle(tr("Edit identity"));
ui->headerFrame->setHeaderImage(QPixmap(":/images/identity/identity_edit_64.png"));
ui->headerFrame->setHeaderText(tr("Edit identity"));
mIsNew = false;
mGroupId.clear();
mStateHelper->setLoading(IDEDITDIALOG_LOADID, true);
@ -195,7 +197,7 @@ void IdEditDialog::setupExistingId(std::string keyId)
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
std::list<RsGxsGroupId> groupIds;
groupIds.push_back(RsGxsGroupId(keyId));
groupIds.push_back(keyId);
uint32_t token;
mIdQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, IDEDITDIALOG_LOADID);
@ -228,8 +230,9 @@ void IdEditDialog::loadExistingId(uint32_t token)
}
mEditGroup = datavector[0];
QPixmap avatar;
mGroupId = mEditGroup.mMeta.mGroupId;
QPixmap avatar;
if (mEditGroup.mImage.mSize > 0) {
avatar.loadFromData(mEditGroup.mImage.mData, mEditGroup.mImage.mSize, "PNG");
}
@ -503,11 +506,25 @@ void IdEditDialog::createId()
else
params.mImage.clear();
uint32_t dummyToken = 0;
rsIdentity->createIdentity(dummyToken, params);
uint32_t token = 0;
rsIdentity->createIdentity(token, params);
mLastIdName = groupname;
close();
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
mIdQueue->queueRequest(token, 0, 0, IDEDITDIALOG_CREATEID);
}
void IdEditDialog::idCreated(uint32_t token)
{
if (!rsIdentity->acknowledgeGrp(token, mGroupId)) {
std::cerr << "IdDialog::idCreated() acknowledgeGrp failed";
std::cerr << std::endl;
reject();
return;
}
accept();
}
void IdEditDialog::updateId()
@ -540,8 +557,7 @@ void IdEditDialog::updateId()
uint32_t dummyToken = 0;
rsIdentity->updateIdentity(dummyToken, mEditGroup);
mLastIdName = groupname;
close();
accept();
}
void IdEditDialog::loadRequest(const TokenQueue */*queue*/, const TokenRequest &req)
@ -549,6 +565,14 @@ void IdEditDialog::loadRequest(const TokenQueue */*queue*/, const TokenRequest &
std::cerr << "IdDialog::loadRequest() UserType: " << req.mUserType;
std::cerr << std::endl;
// only one here!
loadExistingId(req.mToken);
switch (req.mUserType) {
case IDEDITDIALOG_LOADID:
loadExistingId(req.mToken);
break;
case IDEDITDIALOG_CREATEID:
idCreated(req.mToken);
break;
}
}

View File

@ -46,12 +46,12 @@ public:
~IdEditDialog();
void setupNewId(bool pseudo);
void setupExistingId(std::string keyId);
void setupExistingId(const RsGxsGroupId &keyId);
RsGxsGroupId groupId() { return mGroupId; }
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
std::string getLastIdName() {return mLastIdName;}
private slots:
void idTypeToggled(bool checked);
void submit();
@ -72,6 +72,7 @@ private:
void updateIdType(bool pseudo);
void loadExistingId(uint32_t token);
void setAvatar(const QPixmap &avatar);
void idCreated(uint32_t token);
void loadRecognTags();
// extract details.
@ -86,7 +87,7 @@ protected:
RsGxsIdGroup mEditGroup;
TokenQueue *mIdQueue;
std::string mLastIdName;
RsGxsGroupId mGroupId;
QPixmap mAvatar; // Avatar from identity (not calculated)
};

View File

@ -33,6 +33,7 @@
#include <retroshare/rsmsgs.h>
#include <retroshare/rspeers.h>
#include <retroshare/rsidentity.h>
/****
* #define DEBUG_ITEM 1

View File

@ -60,7 +60,6 @@ GxsIdChooser::GxsIdChooser(QWidget *parent)
mFirstLoad = true;
mDefaultId.clear() ;
mDefaultIdName.clear();
/* Enable sort with own role */
QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this);
@ -103,7 +102,7 @@ void GxsIdChooser::showEvent(QShowEvent *event)
QComboBox::showEvent(event);
}
void GxsIdChooser::loadIds(uint32_t chooserFlags, RsGxsId defId)
void GxsIdChooser::loadIds(uint32_t chooserFlags, const RsGxsId &defId)
{
mFlags = chooserFlags;
mDefaultId = defId;
@ -111,6 +110,11 @@ void GxsIdChooser::loadIds(uint32_t chooserFlags, RsGxsId defId)
mFirstLoad = true;
}
void GxsIdChooser::setDefaultId(const RsGxsId &defId)
{
mDefaultId = defId;
}
static void loadPrivateIdsCallback(GxsIdDetailsType type, const RsIdentityDetails &details, QObject *object, const QVariant &/*data*/)
{
GxsIdChooser *chooser = dynamic_cast<GxsIdChooser*>(object);
@ -175,10 +179,6 @@ void GxsIdChooser::loadPrivateIds(uint32_t token)
if (data.mMeta.mSubscribeFlags & GXS_SERV::GROUP_SUBSCRIBE_ADMIN) {
ids.push_back((RsGxsId) data.mMeta.mGroupId);
}
if (mDefaultIdName == data.mMeta.mGroupName) {
mDefaultId = (RsGxsId) data.mMeta.mGroupId;
}
}
//rsIdentity->getDefaultId(defId);
@ -256,7 +256,7 @@ void GxsIdChooser::setDefaultItem()
}
}
bool GxsIdChooser::setChosenId(RsGxsId &gxsId)
bool GxsIdChooser::setChosenId(const RsGxsId &gxsId)
{
QString id = QString::fromStdString(gxsId.toStdString());
@ -313,8 +313,9 @@ void GxsIdChooser::indexActivated(int index)
if (type == TYPE_CREATE_ID) {
IdEditDialog dlg(this);
dlg.setupNewId(false);
dlg.exec();
setDefaultId(dlg.getLastIdName());
if (dlg.exec() == QDialog::Accepted) {
setDefaultId(RsGxsId(dlg.groupId()));
}
}
}

View File

@ -25,10 +25,7 @@
#define _GXS_ID_CHOOSER_H
#include <QComboBox>
#include <QPushButton>
#include "util/TokenQueue.h"
#include <retroshare/rsidentity.h>
#include <retroshare/rsgxsifacetypes.h>
// This class implement a basic RS functionality which is that ComboBox displaying Id
// should update regularly. They also should update only when visible, to save CPU time.
@ -52,16 +49,14 @@ public:
void setFlags(uint32_t flags) ;
void loadRequest(const TokenQueue *queue, const TokenRequest &req);//TokenResponse
/* TokenResponse */
virtual void loadRequest(const TokenQueue *queue, const TokenRequest &req);
enum ChosenId_Ret {None, KnowId, UnKnowId, NoId} ;
void loadIds(uint32_t chooserFlags, RsGxsId defId);
void setDefaultId(RsGxsId defId) {mDefaultId=defId;}
void setDefaultId(std::string defIdName) {mDefaultIdName=defIdName;}
void loadIds(uint32_t chooserFlags, const RsGxsId &defId);
void setDefaultId(const RsGxsId &defId);
bool hasAvailableIds() const { return !mDefaultId.isNull() ; }
bool setChosenId(RsGxsId &gxsId);
bool setChosenId(const RsGxsId &gxsId);
ChosenId_Ret getChosenId(RsGxsId &gxsId);
protected:
@ -80,9 +75,7 @@ private:
uint32_t mFlags;
RsGxsId mDefaultId;
std::string mDefaultIdName;
bool mFirstLoad;
QPushButton* addNewCxsId;
TokenQueue *mIdQueue;
RsGxsUpdateBroadcastBase *mBase;