mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-30 01:38:51 -04:00
removed askForDeferredSelfSignature() and made IdEditDialog comply with this
This commit is contained in:
parent
0cc871da60
commit
cd98f02246
14 changed files with 28 additions and 145 deletions
|
@ -28,6 +28,7 @@
|
|||
#include "gui/gxs/GxsIdDetails.h"
|
||||
#include "util/qtthreadsutils.h"
|
||||
#include "util/misc.h"
|
||||
#include "gui/notifyqt.h"
|
||||
|
||||
#include <retroshare/rsidentity.h>
|
||||
#include <retroshare/rspeers.h>
|
||||
|
@ -539,18 +540,40 @@ void IdEditDialog::createId()
|
|||
params.mImage.clear();
|
||||
|
||||
RsGxsId keyId;
|
||||
std::string gpg_password;
|
||||
|
||||
if(rsIdentity->createIdentity(keyId,params.nickname,params.mImage,!params.isPgpLinked))
|
||||
if(params.isPgpLinked)
|
||||
{
|
||||
std::string gpg_name = rsPeers->getGPGName(rsPeers->getGPGOwnId());
|
||||
bool cancelled;
|
||||
|
||||
if(!NotifyQt::getInstance()->askForPassword(tr("Profile password needed.").toStdString(),
|
||||
gpg_name + " (" + rsPeers->getOwnId().toStdString() + ")",
|
||||
false,
|
||||
gpg_password,cancelled))
|
||||
{
|
||||
QMessageBox::critical(NULL,tr("Identity creation failed"),tr("Cannot create an identity linked to your profile without your profile password."));
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(rsIdentity->createIdentity(keyId,params.nickname,params.mImage,!params.isPgpLinked,gpg_password))
|
||||
{
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
|
||||
RsIdentityDetails det;
|
||||
rsIdentity->getIdDetails(keyId,det);
|
||||
|
||||
setupExistingId((RsGxsGroupId)keyId);
|
||||
if(rsIdentity->getIdDetails(keyId,det))
|
||||
{
|
||||
QMessageBox::information(NULL,tr("Identity creation success"),tr("Your new identity was successfuly created."));
|
||||
close();
|
||||
}
|
||||
else
|
||||
QMessageBox::critical(NULL,tr("Identity creation failed"),tr("Cannot create identity. Something went wrong."));
|
||||
}
|
||||
else
|
||||
QMessageBox::critical(NULL,tr("Identity creation failed"),tr("Cannot create identity. Something went wrong."));
|
||||
QMessageBox::critical(NULL,tr("Identity creation failed"),tr("Cannot create identity. Something went wrong. Check your profile password."));
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
|
|
|
@ -199,51 +199,6 @@ class SignatureEventData
|
|||
std::string reason ;
|
||||
};
|
||||
|
||||
bool NotifyQt::askForDeferredSelfSignature(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen,int& signature_result, std::string reason /*=""*/)
|
||||
{
|
||||
{
|
||||
QMutexLocker m(&_mutex) ;
|
||||
|
||||
std::cerr << "NotifyQt:: deferred signature event requeted. " << std::endl;
|
||||
|
||||
// Look into the queue
|
||||
|
||||
Sha1CheckSum chksum = RsDirUtil::sha1sum((uint8_t*)data,len) ;
|
||||
|
||||
std::map<std::string,SignatureEventData*>::iterator it = _deferred_signature_queue.find(chksum.toStdString()) ;
|
||||
signature_result = SELF_SIGNATURE_RESULT_PENDING ;
|
||||
|
||||
if(it != _deferred_signature_queue.end())
|
||||
{
|
||||
signature_result = it->second->signature_result ;
|
||||
|
||||
if(it->second->signature_result != SELF_SIGNATURE_RESULT_PENDING) // found it. Copy the result, and remove from the queue.
|
||||
{
|
||||
// We should check for the exact data match, for the sake of being totally secure.
|
||||
//
|
||||
std::cerr << "Found into queue: returning it" << std::endl;
|
||||
|
||||
memcpy(sign,it->second->sign,*it->second->signlen) ;
|
||||
*signlen = *(it->second->signlen) ;
|
||||
|
||||
delete it->second ;
|
||||
_deferred_signature_queue.erase(it) ;
|
||||
}
|
||||
return true ; // already registered, but not done yet.
|
||||
}
|
||||
|
||||
// Not found. Store in the queue and emit a signal.
|
||||
//
|
||||
std::cerr << "NotifyQt:: deferred signature event requeted. Pushing into queue" << std::endl;
|
||||
|
||||
SignatureEventData *edta = new SignatureEventData(data,len,*signlen, reason) ;
|
||||
|
||||
_deferred_signature_queue[chksum.toStdString()] = edta ;
|
||||
}
|
||||
emit deferredSignatureHandlingRequested() ;
|
||||
return true;
|
||||
}
|
||||
|
||||
void NotifyQt::handleSignatureEvent()
|
||||
{
|
||||
std::cerr << "NotifyQt:: performing a deferred signature in the main GUI thread." << std::endl;
|
||||
|
@ -780,19 +735,6 @@ void NotifyQt::notifyListPreChange(int list, int /*type*/)
|
|||
return;
|
||||
}
|
||||
|
||||
/* New Timer Based Update scheme ...
|
||||
* means correct thread seperation
|
||||
*
|
||||
* uses Flags, to detect changes
|
||||
*/
|
||||
|
||||
void NotifyQt::resetCachedPassphrases()
|
||||
{
|
||||
std::cerr << "Clearing PGP passphrase." << std::endl;
|
||||
|
||||
rsNotify->clearPgpPassphrase() ;
|
||||
}
|
||||
|
||||
void NotifyQt::enable()
|
||||
{
|
||||
QMutexLocker m(&_mutex) ;
|
||||
|
|
|
@ -94,20 +94,6 @@ class NotifyQt: public QObject, public NotifyClient
|
|||
virtual bool askForPassword(const std::string& title, const std::string& key_details, bool prev_is_bad, std::string& password, bool &cancelled);
|
||||
virtual bool askForPluginConfirmation(const std::string& plugin_filename, const std::string& plugin_file_hash,bool first_time);
|
||||
|
||||
// Queues the signature event so that it canhappen in the main GUI thread (to ask for passwd).
|
||||
// To use this function: call is multiple times as soon as it returns true.
|
||||
//
|
||||
// Dont' use a while, if you're in a mutexed part, otherwize it will lock. You need to call the function
|
||||
// and periodically exit the locked code between calls to allow the signature to happen.
|
||||
//
|
||||
// Returns:
|
||||
// false = the signature is registered, but the result is not there yet. Call again soon.
|
||||
// true = signature done. Data is ready. signature_result takes the following values:
|
||||
// 1: signature success
|
||||
// 2: signature failed. Wrong passwd, user pressed cancel, etc.
|
||||
//
|
||||
virtual bool askForDeferredSelfSignature(const void *data, const uint32_t len, unsigned char *sign, unsigned int *signlen, int& signature_result, std::string reason = "") ;
|
||||
|
||||
/* Notify from GUI */
|
||||
void notifyChatFontChanged();
|
||||
void notifyChatStyleChanged(int /*ChatStyle::enumStyleType*/ styleType);
|
||||
|
@ -176,7 +162,6 @@ class NotifyQt: public QObject, public NotifyClient
|
|||
public slots:
|
||||
void UpdateGUI(); /* called by timer */
|
||||
void SetDisableAll(bool bValue);
|
||||
void resetCachedPassphrases() ;
|
||||
|
||||
private slots:
|
||||
void runningTick();
|
||||
|
|
|
@ -580,11 +580,6 @@ feenableexcept(FE_INVALID | FE_DIVBYZERO);
|
|||
#endif
|
||||
#endif // RS_JSONAPI
|
||||
|
||||
// This is done using a timer, because the passphrase request from notify is asynchrouneous and therefore clearing the
|
||||
// passphrase here makes it request for a passphrase when creating the default chat identity.
|
||||
|
||||
QTimer::singleShot(10000, notify, SLOT(resetCachedPassphrases())) ;
|
||||
|
||||
/* dive into the endless loop */
|
||||
int ti = rshare.exec();
|
||||
delete w ;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue