removed token queue from CreateCircleDialog

This commit is contained in:
csoler 2022-07-04 17:25:11 +02:00
parent 54fd77822d
commit cdc650540b

View file

@ -422,7 +422,7 @@ void CreateCircleDialog::createCircle()
close() ; close() ;
return ; return ;
} }
#ifdef DEBUG_CREATE_CIRCLE_DIALOG #ifdef DEBUG_CREATE_CIRCLE_DIALOG
std::cerr << "CreateCircleDialog::createCircle()"; std::cerr << "CreateCircleDialog::createCircle()";
std::cerr << std::endl; std::cerr << std::endl;
@ -431,10 +431,10 @@ void CreateCircleDialog::createCircle()
QString name = ui.circleName->text(); QString name = ui.circleName->text();
if(name.isEmpty()) { if(name.isEmpty()) {
/* error message */ /* error message */
QMessageBox::warning(this, tr("RetroShare"),tr("Please set a name for your Circle"), QMessageBox::Ok, QMessageBox::Ok); QMessageBox::warning(this, tr("RetroShare"),tr("Please set a name for your Circle"), QMessageBox::Ok, QMessageBox::Ok);
return; //Don't add a empty Subject!! return; //Don't add a empty Subject!!
} }
RsGxsCircleGroup circle = mCircleGroup; // init with loaded group RsGxsCircleGroup circle = mCircleGroup; // init with loaded group
@ -448,23 +448,23 @@ void CreateCircleDialog::createCircle()
{ {
case GxsIdChooser::KnowId: case GxsIdChooser::KnowId:
case GxsIdChooser::UnKnowId: case GxsIdChooser::UnKnowId:
circle.mMeta.mAuthorId = authorId; circle.mMeta.mAuthorId = authorId;
circle.mMeta.mAuthenFlags = GXS_SERV::GRP_OPTION_AUTHEN_AUTHOR_SIGN; circle.mMeta.mAuthenFlags = GXS_SERV::GRP_OPTION_AUTHEN_AUTHOR_SIGN;
#ifdef DEBUG_CREATE_CIRCLE_DIALOG #ifdef DEBUG_CREATE_CIRCLE_DIALOG
std::cerr << "CreateCircleDialog::createCircle() AuthorId: " << authorId; std::cerr << "CreateCircleDialog::createCircle() AuthorId: " << authorId;
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
break; break;
case GxsIdChooser::NoId: case GxsIdChooser::NoId:
case GxsIdChooser::None: case GxsIdChooser::None:
circle.mMeta.mAuthorId.clear(); circle.mMeta.mAuthorId.clear();
circle.mMeta.mAuthenFlags = 0; circle.mMeta.mAuthenFlags = 0;
default: ; default: ;
#ifdef DEBUG_CREATE_CIRCLE_DIALOG #ifdef DEBUG_CREATE_CIRCLE_DIALOG
std::cerr << "CreateCircleDialog::createCircle() No AuthorId Chosen!"; std::cerr << "CreateCircleDialog::createCircle() No AuthorId Chosen!";
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
} }
@ -472,144 +472,163 @@ void CreateCircleDialog::createCircle()
/* copy Ids from GUI */ /* copy Ids from GUI */
QTreeWidget *tree = ui.treeWidget_membership; QTreeWidget *tree = ui.treeWidget_membership;
int count = tree->topLevelItemCount(); int count = tree->topLevelItemCount();
for(int i = 0; i < count; ++i) for(int i = 0; i < count; ++i)
{ {
QTreeWidgetItem *item = tree->topLevelItem(i); QTreeWidgetItem *item = tree->topLevelItem(i);
QString keyId = item->text(RSCIRCLEID_COL_KEYID); QString keyId = item->text(RSCIRCLEID_COL_KEYID);
/* insert into circle */ /* insert into circle */
if (mIsExternalCircle) if (mIsExternalCircle)
{ {
RsGxsId key_id_gxs(keyId.toStdString()) ; RsGxsId key_id_gxs(keyId.toStdString()) ;
if(key_id_gxs.isNull()) if(key_id_gxs.isNull())
{ {
std::cerr << "Error: Not a proper keyID: " << keyId.toStdString() << std::endl; std::cerr << "Error: Not a proper keyID: " << keyId.toStdString() << std::endl;
continue ; continue ;
} }
circle.mInvitedMembers.insert(key_id_gxs) ; circle.mInvitedMembers.insert(key_id_gxs) ;
#ifdef DEBUG_CREATE_CIRCLE_DIALOG #ifdef DEBUG_CREATE_CIRCLE_DIALOG
std::cerr << "CreateCircleDialog::createCircle() Inserting Member: " << keyId.toStdString(); std::cerr << "CreateCircleDialog::createCircle() Inserting Member: " << keyId.toStdString();
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
} }
else else
{ {
RsPgpId key_id_pgp(keyId.toStdString()) ; RsPgpId key_id_pgp(keyId.toStdString()) ;
if(key_id_pgp.isNull()) if(key_id_pgp.isNull())
{ {
std::cerr << "Error: Not a proper PGP keyID: " << keyId.toStdString() << std::endl; std::cerr << "Error: Not a proper PGP keyID: " << keyId.toStdString() << std::endl;
continue ; continue ;
} }
circle.mLocalFriends.insert(key_id_pgp) ; circle.mLocalFriends.insert(key_id_pgp) ;
#ifdef DEBUG_CREATE_CIRCLE_DIALOG #ifdef DEBUG_CREATE_CIRCLE_DIALOG
std::cerr << "CreateCircleDialog::createCircle() Inserting Friend: " << keyId.toStdString(); std::cerr << "CreateCircleDialog::createCircle() Inserting Friend: " << keyId.toStdString();
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
} }
} }
if (mIsExternalCircle) if (mIsExternalCircle)
{ {
#ifdef DEBUG_CREATE_CIRCLE_DIALOG #ifdef DEBUG_CREATE_CIRCLE_DIALOG
std::cerr << "CreateCircleDialog::createCircle() External Circle"; std::cerr << "CreateCircleDialog::createCircle() External Circle";
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
// set distribution from GUI. // set distribution from GUI.
circle.mMeta.mCircleId.clear() ; circle.mMeta.mCircleId.clear() ;
circle.mMeta.mGroupFlags = GXS_SERV::FLAG_PRIVACY_PUBLIC; circle.mMeta.mGroupFlags = GXS_SERV::FLAG_PRIVACY_PUBLIC;
if (ui.radioButton_Public->isChecked()) { if (ui.radioButton_Public->isChecked()) {
#ifdef DEBUG_CREATE_CIRCLE_DIALOG #ifdef DEBUG_CREATE_CIRCLE_DIALOG
std::cerr << "CreateCircleDialog::createCircle() Public Circle"; std::cerr << "CreateCircleDialog::createCircle() Public Circle";
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
circle.mMeta.mCircleType = GXS_CIRCLE_TYPE_PUBLIC; circle.mMeta.mCircleType = GXS_CIRCLE_TYPE_PUBLIC;
} else if (ui.radioButton_Self->isChecked()) { } else if (ui.radioButton_Self->isChecked()) {
#ifdef DEBUG_CREATE_CIRCLE_DIALOG #ifdef DEBUG_CREATE_CIRCLE_DIALOG
std::cerr << "CreateCircleDialog::createCircle() ExtSelfRef Circle"; std::cerr << "CreateCircleDialog::createCircle() ExtSelfRef Circle";
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
circle.mMeta.mCircleType = GXS_CIRCLE_TYPE_EXT_SELF; circle.mMeta.mCircleType = GXS_CIRCLE_TYPE_EXT_SELF;
} else if (ui.radioButton_Restricted->isChecked()) { } else if (ui.radioButton_Restricted->isChecked()) {
#ifdef DEBUG_CREATE_CIRCLE_DIALOG #ifdef DEBUG_CREATE_CIRCLE_DIALOG
std::cerr << "CreateCircleDialog::createCircle() External (Other) Circle"; std::cerr << "CreateCircleDialog::createCircle() External (Other) Circle";
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
circle.mMeta.mCircleType = GXS_CIRCLE_TYPE_EXTERNAL; circle.mMeta.mCircleType = GXS_CIRCLE_TYPE_EXTERNAL;
/* grab circle ID from chooser */ /* grab circle ID from chooser */
RsGxsCircleId chosenId; RsGxsCircleId chosenId;
if (ui.circleComboBox->getChosenCircle(chosenId)) { if (ui.circleComboBox->getChosenCircle(chosenId)) {
#ifdef DEBUG_CREATE_CIRCLE_DIALOG #ifdef DEBUG_CREATE_CIRCLE_DIALOG
std::cerr << "CreateCircleDialog::createCircle() ChosenId: " << chosenId; std::cerr << "CreateCircleDialog::createCircle() ChosenId: " << chosenId;
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
circle.mMeta.mCircleId = chosenId; circle.mMeta.mCircleId = chosenId;
} else {//if (ui.circleComboBox->getChosenCircle(chosenId)) } else {//if (ui.circleComboBox->getChosenCircle(chosenId))
#ifdef DEBUG_CREATE_CIRCLE_DIALOG #ifdef DEBUG_CREATE_CIRCLE_DIALOG
std::cerr << "CreateCircleDialog::createCircle() Error no Id Chosen"; std::cerr << "CreateCircleDialog::createCircle() Error no Id Chosen";
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
QMessageBox::warning(this, tr("RetroShare"),tr("No Restriction Circle Selected"), QMessageBox::Ok, QMessageBox::Ok); QMessageBox::warning(this, tr("RetroShare"),tr("No Restriction Circle Selected"), QMessageBox::Ok, QMessageBox::Ok);
return; return;
}//else (ui.circleComboBox->getChosenCircle(chosenId)) }//else (ui.circleComboBox->getChosenCircle(chosenId))
} }
else else
{ {
QMessageBox::warning(this, tr("RetroShare"),tr("No Circle Limitations Selected"), QMessageBox::Ok, QMessageBox::Ok); QMessageBox::warning(this, tr("RetroShare"),tr("No Circle Limitations Selected"), QMessageBox::Ok, QMessageBox::Ok);
return; return;
} }
}
else
{
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
std::cerr << "CreateCircleDialog::createCircle() Personal Circle";
std::cerr << std::endl;
#endif
// set personal distribution
circle.mMeta.mCircleId.clear() ;
circle.mMeta.mCircleType = GXS_CIRCLE_TYPE_LOCAL;
}
uint32_t token;
if(mIsExistingCircle)
{
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
std::cerr << "CreateCircleDialog::updateCircle() : mCircleType: " << circle.mMeta.mCircleType << std::endl;
std::cerr << "CreateCircleDialog::updateCircle() : mCircleId: " << circle.mMeta.mCircleId << std::endl;
std::cerr << "CreateCircleDialog::updateCircle() : mGroupId: " << circle.mMeta.mGroupId << std::endl;
std::cerr << "CreateCircleDialog::updateCircle() Checks and Balances Okay - calling service proper.."<< std::endl;
#endif
rsGxsCircles->updateGroup(token, circle);
} }
else else
{ {
#ifdef DEBUG_CREATE_CIRCLE_DIALOG #ifdef DEBUG_CREATE_CIRCLE_DIALOG
std::cerr << "CreateCircleDialog::createCircle() : mCircleType: " << circle.mMeta.mCircleType << std::endl; std::cerr << "CreateCircleDialog::createCircle() Personal Circle";
std::cerr << "CreateCircleDialog::createCircle() : mCircleId: " << circle.mMeta.mCircleId << std::endl; std::cerr << std::endl;
std::cerr << "CreateCircleDialog::createCircle() Checks and Balances Okay - calling service proper.."<< std::endl;
#endif #endif
rsGxsCircles->createGroup(token, circle); // set personal distribution
circle.mMeta.mCircleId.clear() ;
circle.mMeta.mCircleType = GXS_CIRCLE_TYPE_LOCAL;
} }
RsThread::async([&circle,this]()
{
RsGxsCircleId circleId;
if(mIsExistingCircle)
{
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
std::cerr << "CreateCircleDialog::updateCircle() : mCircleType: " << circle.mMeta.mCircleType << std::endl;
std::cerr << "CreateCircleDialog::updateCircle() : mCircleId: " << circle.mMeta.mCircleId << std::endl;
std::cerr << "CreateCircleDialog::updateCircle() : mGroupId: " << circle.mMeta.mGroupId << std::endl;
std::cerr << "CreateCircleDialog::updateCircle() Checks and Balances Okay - calling service proper.."<< std::endl;
#endif
rsGxsCircles->editCircle(circle);
circleId = RsGxsCircleId(circle.mMeta.mGroupId);
}
else
{
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
std::cerr << "CreateCircleDialog::createCircle() : mCircleType: " << circle.mMeta.mCircleType << std::endl;
std::cerr << "CreateCircleDialog::createCircle() : mCircleId: " << circle.mMeta.mCircleId << std::endl;
std::cerr << "CreateCircleDialog::createCircle() Checks and Balances Okay - calling service proper.."<< std::endl;
#endif
rsGxsCircles->createCircle(circle.mMeta.mGroupName,
static_cast<RsGxsCircleType>(circle.mMeta.mCircleType),
circleId,
circle.mMeta.mCircleId,
circle.mMeta.mAuthorId,
circle.mInvitedMembers,
circle.mLocalFriends);
}
RsQThreadUtils::postToObject( [this,circle,circleId]()
{
if(!mIsExistingCircle)
QMessageBox::information(nullptr,tr("Circle created"),
tr("Your new circle has been created:\n Name: %1\n Id: %2.")
.arg(QString::fromUtf8(circle.mMeta.mGroupName.c_str()))
.arg(QString::fromStdString(circleId.toStdString())));
});
});
close(); close();
} }
@ -810,11 +829,6 @@ void CreateCircleDialog::loadIdentities()
void CreateCircleDialog::fillIdentitiesList(const std::vector<RsGxsIdGroup>& id_groups) void CreateCircleDialog::fillIdentitiesList(const std::vector<RsGxsIdGroup>& id_groups)
{ {
#ifdef DEBUG_CREATE_CIRCLE_DIALOG
std::cerr << "CreateCircleDialog::loadIdentities(" << token << ")";
std::cerr << std::endl;
#endif
QTreeWidget *tree = ui.treeWidget_IdList; QTreeWidget *tree = ui.treeWidget_IdList;
tree->clear(); tree->clear();