mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-03 02:50:07 -05:00
removed TokenQueue from IdEditDialog PGP Signed identities still not working
This commit is contained in:
parent
d9b74beb44
commit
0cc871da60
@ -45,13 +45,14 @@
|
||||
enum class TokenRequestType: uint8_t
|
||||
{
|
||||
UNDEFINED = 0x00,
|
||||
GROUP_INFO = 0x01,
|
||||
POSTS = 0x02,
|
||||
ALL_POSTS = 0x03,
|
||||
MSG_RELATED_INFO = 0x04,
|
||||
GROUP_STATISTICS = 0x05,
|
||||
SERVICE_STATISTICS = 0x06,
|
||||
NO_KILL_TYPE = 0x07,
|
||||
GROUP_DATA = 0x01,
|
||||
GROUP_META = 0x02,
|
||||
POSTS = 0x03,
|
||||
ALL_POSTS = 0x04,
|
||||
MSG_RELATED_INFO = 0x05,
|
||||
GROUP_STATISTICS = 0x06,
|
||||
SERVICE_STATISTICS = 0x07,
|
||||
NO_KILL_TYPE = 0x08,
|
||||
};
|
||||
|
||||
class RsGxsIfaceHelper
|
||||
@ -252,12 +253,23 @@ public:
|
||||
/// @see RsTokenService::requestGroupInfo
|
||||
bool requestGroupInfo( uint32_t& token, const RsTokReqOptions& opts, const std::list<RsGxsGroupId> &groupIds, bool high_priority_request = false )
|
||||
{
|
||||
cancelActiveRequestTokens(TokenRequestType::GROUP_INFO);
|
||||
TokenRequestType token_request_type;
|
||||
|
||||
switch(opts.mReqType)
|
||||
{
|
||||
case GXS_REQUEST_TYPE_GROUP_DATA: token_request_type = TokenRequestType::GROUP_DATA; break;
|
||||
case GXS_REQUEST_TYPE_GROUP_META: token_request_type = TokenRequestType::GROUP_META; break;
|
||||
default:
|
||||
RsErr() << __PRETTY_FUNCTION__ << "(EE) Unexpected request type " << opts.mReqType << "!!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
cancelActiveRequestTokens(token_request_type);
|
||||
|
||||
if( mTokenService.requestGroupInfo(token, 0, opts, groupIds))
|
||||
{
|
||||
RS_STACK_MUTEX(mMtx);
|
||||
mActiveTokens[token]=high_priority_request? (TokenRequestType::NO_KILL_TYPE) : (TokenRequestType::GROUP_INFO);
|
||||
mActiveTokens[token]=high_priority_request? (TokenRequestType::NO_KILL_TYPE) : token_request_type;
|
||||
locked_dumpTokens();
|
||||
return true;
|
||||
}
|
||||
@ -268,12 +280,24 @@ public:
|
||||
/// @see RsTokenService::requestGroupInfo
|
||||
bool requestGroupInfo(uint32_t& token, const RsTokReqOptions& opts, bool high_priority_request = false)
|
||||
{
|
||||
cancelActiveRequestTokens(TokenRequestType::GROUP_INFO);
|
||||
TokenRequestType token_request_type;
|
||||
|
||||
switch(opts.mReqType)
|
||||
{
|
||||
case GXS_REQUEST_TYPE_GROUP_DATA: token_request_type = TokenRequestType::GROUP_DATA; break;
|
||||
case GXS_REQUEST_TYPE_GROUP_META: token_request_type = TokenRequestType::GROUP_META; break;
|
||||
default:
|
||||
RsErr() << __PRETTY_FUNCTION__ << "(EE) Unexpected request type " << opts.mReqType << "!!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
cancelActiveRequestTokens(token_request_type);
|
||||
|
||||
|
||||
if( mTokenService.requestGroupInfo(token, 0, opts))
|
||||
{
|
||||
RS_STACK_MUTEX(mMtx);
|
||||
mActiveTokens[token]=high_priority_request? (TokenRequestType::NO_KILL_TYPE) : (TokenRequestType::GROUP_INFO);
|
||||
mActiveTokens[token]=high_priority_request? (TokenRequestType::NO_KILL_TYPE) : token_request_type;
|
||||
locked_dumpTokens();
|
||||
return true;
|
||||
}
|
||||
|
@ -1301,8 +1301,7 @@ bool IdDialog::fillIdListItem(const RsGxsIdGroup& data, QTreeWidgetItem *&item,
|
||||
RsIdentityDetails idd ;
|
||||
rsIdentity->getIdDetails(RsGxsId(data.mMeta.mGroupId),idd) ;
|
||||
|
||||
bool isBanned = idd.mReputation.mOverallReputationLevel ==
|
||||
RsReputationLevel::LOCALLY_NEGATIVE;
|
||||
bool isBanned = idd.mReputation.mOverallReputationLevel == RsReputationLevel::LOCALLY_NEGATIVE;
|
||||
uint32_t item_flags = 0;
|
||||
|
||||
/* do filtering */
|
||||
@ -1474,7 +1473,7 @@ void IdDialog::loadIdentities(const std::map<RsGxsGroupId,RsGxsIdGroup>& ids_set
|
||||
RsPgpId ownPgpId = rsPeers->getGPGOwnId();
|
||||
|
||||
// Update existing and remove not existing items
|
||||
// Also remove items that do not have the correct parent
|
||||
// Also remove items that do not have the correct parent
|
||||
|
||||
QTreeWidgetItemIterator itemIterator(ui->idTreeWidget);
|
||||
QTreeWidgetItem *item = NULL;
|
||||
@ -1494,6 +1493,9 @@ void IdDialog::loadIdentities(const std::map<RsGxsGroupId,RsGxsIdGroup>& ids_set
|
||||
|
||||
QTreeWidgetItem *parent_item = item->parent() ;
|
||||
|
||||
// if(it->second.mMeta.mPublishTs > time(NULL) - 20 || it->second.mMeta.mGroupId == RsGxsGroupId("3de2172503675206b3a23c997e5ee688"))
|
||||
// std::cerr << "Captured ID " <<it->second.mMeta.mGroupId << std::endl;
|
||||
|
||||
if( (parent_item == allItem && it->second.mIsAContact) || (parent_item == contactsItem && !it->second.mIsAContact))
|
||||
{
|
||||
delete item ; // do not remove from the list, so that it is added again in the correct place.
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "gui/common/UIStateHelper.h"
|
||||
#include "gui/common/AvatarDialog.h"
|
||||
#include "gui/gxs/GxsIdDetails.h"
|
||||
#include "util/TokenQueue.h"
|
||||
#include "util/qtthreadsutils.h"
|
||||
#include "util/misc.h"
|
||||
|
||||
#include <retroshare/rsidentity.h>
|
||||
@ -88,17 +88,13 @@ IdEditDialog::IdEditDialog(QWidget *parent) :
|
||||
/* Initialize ui */
|
||||
ui->lineEdit_Nickname->setMaxLength(RSID_MAXIMUM_NICKNAME_SIZE);
|
||||
|
||||
mIdQueue = new TokenQueue(rsIdentity->getTokenService(), this);
|
||||
ui->pushButton_Tag->setEnabled(false);
|
||||
ui->pushButton_Tag->hide(); // unfinished
|
||||
ui->plainTextEdit_Tag->hide();
|
||||
ui->label_TagCheck->hide();
|
||||
}
|
||||
|
||||
IdEditDialog::~IdEditDialog()
|
||||
{
|
||||
delete(mIdQueue);
|
||||
}
|
||||
IdEditDialog::~IdEditDialog() {}
|
||||
|
||||
void IdEditDialog::changeAvatar()
|
||||
{
|
||||
@ -199,25 +195,52 @@ void IdEditDialog::setAvatar(const QPixmap &avatar)
|
||||
}
|
||||
}
|
||||
|
||||
void IdEditDialog::setupExistingId(const RsGxsGroupId &keyId)
|
||||
void IdEditDialog::setupExistingId(const RsGxsGroupId& keyId)
|
||||
{
|
||||
setWindowTitle(tr("Edit identity"));
|
||||
ui->headerFrame->setHeaderImage(QPixmap(":/icons/png/person.png"));
|
||||
ui->headerFrame->setHeaderText(tr("Edit identity"));
|
||||
|
||||
mStateHelper->setLoading(IDEDITDIALOG_LOADID, true);
|
||||
|
||||
mIsNew = false;
|
||||
mGroupId.clear();
|
||||
|
||||
mStateHelper->setLoading(IDEDITDIALOG_LOADID, true);
|
||||
RsThread::async([this,keyId]()
|
||||
{
|
||||
std::vector<RsGxsIdGroup> datavector;
|
||||
|
||||
RsTokReqOptions opts;
|
||||
opts.mReqType = GXS_REQUEST_TYPE_GROUP_DATA;
|
||||
bool res = rsIdentity->getIdentitiesInfo(std::set<RsGxsId>({(RsGxsId)keyId}),datavector);
|
||||
|
||||
std::list<RsGxsGroupId> groupIds;
|
||||
groupIds.push_back(keyId);
|
||||
RsQThreadUtils::postToObject( [this,keyId,res,datavector]()
|
||||
{
|
||||
/* Here it goes any code you want to be executed on the Qt Gui
|
||||
* thread, for example to update the data model with new information
|
||||
* after a blocking call to RetroShare API complete, note that
|
||||
* Qt::QueuedConnection is important!
|
||||
*/
|
||||
|
||||
uint32_t token;
|
||||
mIdQueue->requestGroupInfo(token, RS_TOKREQ_ANSTYPE_DATA, opts, groupIds, IDEDITDIALOG_LOADID);
|
||||
mStateHelper->setLoading(IDEDITDIALOG_LOADID, false);
|
||||
|
||||
/* get details from libretroshare */
|
||||
|
||||
if (!res || datavector.size() != 1)
|
||||
{
|
||||
std::cerr << __PRETTY_FUNCTION__ << " failed to collect group info for identity " << keyId << std::endl;
|
||||
|
||||
ui->lineEdit_KeyId->setText(tr("Error KeyID invalid"));
|
||||
ui->lineEdit_Nickname->setText("");
|
||||
|
||||
ui->lineEdit_GpgHash->setText(tr("N/A"));
|
||||
ui->lineEdit_GpgId->setText(tr("N/A"));
|
||||
ui->lineEdit_GpgName->setText(tr("N/A"));
|
||||
return;
|
||||
}
|
||||
|
||||
loadExistingId(datavector[0]);
|
||||
|
||||
}, this );
|
||||
});
|
||||
}
|
||||
|
||||
void IdEditDialog::enforceNoAnonIds()
|
||||
@ -227,33 +250,9 @@ void IdEditDialog::enforceNoAnonIds()
|
||||
ui->radioButton_Pseudo->setEnabled(false);
|
||||
}
|
||||
|
||||
void IdEditDialog::loadExistingId(uint32_t token)
|
||||
void IdEditDialog::loadExistingId(const RsGxsIdGroup& id_group)
|
||||
{
|
||||
mStateHelper->setLoading(IDEDITDIALOG_LOADID, false);
|
||||
|
||||
/* get details from libretroshare */
|
||||
std::vector<RsGxsIdGroup> datavector;
|
||||
if (!rsIdentity->getGroupData(token, datavector))
|
||||
{
|
||||
ui->lineEdit_KeyId->setText(tr("Error getting key!"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (datavector.size() != 1)
|
||||
{
|
||||
std::cerr << "IdDialog::insertIdDetails() Invalid datavector size";
|
||||
std::cerr << std::endl;
|
||||
|
||||
ui->lineEdit_KeyId->setText(tr("Error KeyID invalid"));
|
||||
ui->lineEdit_Nickname->setText("");
|
||||
|
||||
ui->lineEdit_GpgHash->setText(tr("N/A"));
|
||||
ui->lineEdit_GpgId->setText(tr("N/A"));
|
||||
ui->lineEdit_GpgName->setText(tr("N/A"));
|
||||
return;
|
||||
}
|
||||
|
||||
mEditGroup = datavector[0];
|
||||
mEditGroup = id_group;
|
||||
mGroupId = mEditGroup.mMeta.mGroupId;
|
||||
|
||||
QPixmap avatar;
|
||||
@ -539,14 +538,22 @@ void IdEditDialog::createId()
|
||||
else
|
||||
params.mImage.clear();
|
||||
|
||||
uint32_t token = 0;
|
||||
rsIdentity->createIdentity(token, params);
|
||||
RsGxsId keyId;
|
||||
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
if(rsIdentity->createIdentity(keyId,params.nickname,params.mImage,!params.isPgpLinked))
|
||||
{
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
|
||||
mIdQueue->queueRequest(token, 0, 0, IDEDITDIALOG_CREATEID);
|
||||
RsIdentityDetails det;
|
||||
rsIdentity->getIdDetails(keyId,det);
|
||||
|
||||
setupExistingId((RsGxsGroupId)keyId);
|
||||
}
|
||||
else
|
||||
QMessageBox::critical(NULL,tr("Identity creation failed"),tr("Cannot create identity. Something went wrong."));
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
void IdEditDialog::idCreated(uint32_t token)
|
||||
{
|
||||
if (!rsIdentity->acknowledgeGrp(token, mGroupId)) {
|
||||
@ -559,6 +566,7 @@ void IdEditDialog::idCreated(uint32_t token)
|
||||
|
||||
accept();
|
||||
}
|
||||
#endif
|
||||
|
||||
void IdEditDialog::updateId()
|
||||
{
|
||||
@ -594,11 +602,12 @@ void IdEditDialog::updateId()
|
||||
mEditGroup.mImage.clear();
|
||||
|
||||
uint32_t dummyToken = 0;
|
||||
rsIdentity->updateIdentity(dummyToken, mEditGroup);
|
||||
rsIdentity->updateIdentity(mEditGroup);
|
||||
|
||||
accept();
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
void IdEditDialog::loadRequest(const TokenQueue */*queue*/, const TokenRequest &req)
|
||||
{
|
||||
std::cerr << "IdDialog::loadRequest() UserType: " << req.mUserType;
|
||||
@ -615,3 +624,4 @@ void IdEditDialog::loadRequest(const TokenQueue */*queue*/, const TokenRequest &
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
@ -34,7 +34,7 @@ namespace Ui {
|
||||
class IdEditDialog;
|
||||
}
|
||||
|
||||
class IdEditDialog : public QDialog, public TokenResponse
|
||||
class IdEditDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@ -43,13 +43,11 @@ public:
|
||||
~IdEditDialog();
|
||||
|
||||
void setupNewId(bool pseudo, bool enable_anon = true);
|
||||
void setupExistingId(const RsGxsGroupId &keyId);
|
||||
void setupExistingId(const RsGxsGroupId& keyId);
|
||||
void enforceNoAnonIds() ;
|
||||
|
||||
RsGxsGroupId groupId() { return mGroupId; }
|
||||
|
||||
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
|
||||
|
||||
private slots:
|
||||
void idTypeToggled(bool checked);
|
||||
void submit();
|
||||
@ -68,7 +66,7 @@ private:
|
||||
void createId();
|
||||
void updateId();
|
||||
void updateIdType(bool pseudo);
|
||||
void loadExistingId(uint32_t token);
|
||||
void loadExistingId(const RsGxsIdGroup& id_group);
|
||||
void setAvatar(const QPixmap &avatar);
|
||||
void idCreated(uint32_t token);
|
||||
|
||||
@ -83,8 +81,6 @@ protected:
|
||||
UIStateHelper *mStateHelper;
|
||||
|
||||
RsGxsIdGroup mEditGroup;
|
||||
|
||||
TokenQueue *mIdQueue;
|
||||
RsGxsGroupId mGroupId;
|
||||
|
||||
QPixmap mAvatar; // Avatar from identity (not calculated)
|
||||
|
@ -207,28 +207,6 @@ GxsMessageFrameWidget *GxsForumsDialog::createMessageFrameWidget(const RsGxsGrou
|
||||
return new GxsForumThreadWidget(groupId);
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
void GxsForumsDialog::loadGroupSummaryToken(const uint32_t &token, std::list<RsGroupMetaData> &groupInfo, RsUserdata *&userdata)
|
||||
{
|
||||
std::vector<RsGxsForumGroup> groups;
|
||||
rsGxsForums->getGroupData(token, groups);
|
||||
|
||||
/* Save groups to fill description */
|
||||
GxsForumGroupInfoData *forumData = new GxsForumGroupInfoData;
|
||||
userdata = forumData;
|
||||
|
||||
std::vector<RsGxsForumGroup>::iterator groupIt;
|
||||
for (groupIt = groups.begin(); groupIt != groups.end(); ++groupIt) {
|
||||
RsGxsForumGroup &group = *groupIt;
|
||||
groupInfo.push_back(group.mMeta);
|
||||
|
||||
if (!group.mDescription.empty()) {
|
||||
forumData->mDescription[group.mMeta.mGroupId] = QString::fromUtf8(group.mDescription.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void GxsForumsDialog::groupInfoToGroupItemInfo(const RsGxsGenericGroupData *groupData, GroupItemInfo &groupItemInfo)
|
||||
{
|
||||
GxsGroupFrameDialog::groupInfoToGroupItemInfo(groupData, groupItemInfo);
|
||||
@ -249,27 +227,3 @@ void GxsForumsDialog::groupInfoToGroupItemInfo(const RsGxsGenericGroupData *grou
|
||||
groupItemInfo.icon = QIcon(":icons/png/forums-signed.png");
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
void ::groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo, const RsUserdata *userdata)
|
||||
{
|
||||
GxsGroupFrameDialog::groupInfoToGroupItemInfo(groupInfo, groupItemInfo, userdata);
|
||||
|
||||
const GxsForumGroupInfoData *forumData = dynamic_cast<const GxsForumGroupInfoData*>(userdata);
|
||||
if (!forumData) {
|
||||
std::cerr << "GxsForumsDialog::groupInfoToGroupItemInfo() Failed to cast data to GxsForumGroupInfoData";
|
||||
std::cerr << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
QMap<RsGxsGroupId, QString>::const_iterator descriptionIt = forumData->mDescription.find(groupInfo.mGroupId);
|
||||
if (descriptionIt != forumData->mDescription.end()) {
|
||||
groupItemInfo.description = descriptionIt.value();
|
||||
}
|
||||
|
||||
//if (IS_GROUP_ADMIN(groupInfo.mSubscribeFlags))
|
||||
// groupItemInfo.icon = QIcon(":images/konv_message2.png");
|
||||
if ((IS_GROUP_PGP_AUTHED(groupInfo.mSignFlags)) || (IS_GROUP_MESSAGE_TRACKING(groupInfo.mSignFlags)) )
|
||||
groupItemInfo.icon = QIcon(":icons/png/forums-signed.png");
|
||||
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user