mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-15 01:49:35 -04:00
added a signature add/remove button in connect wizard, only when gpgme-1.3.1 or greater is used, based on the availability of the GPGME_EXPORT_MODE_MINIMAL option.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4372 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
28e5f1b8f3
commit
e9853b655c
7 changed files with 80 additions and 23 deletions
|
@ -428,7 +428,7 @@ void AuthGPGimpl::processServices()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* save the certificate to string */
|
/* save the certificate to string */
|
||||||
loadOrSave->m_certGpg = SaveCertificateToString(loadOrSave->m_certGpgId);
|
loadOrSave->m_certGpg = SaveCertificateToString(loadOrSave->m_certGpgId,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
service->setGPGOperation(loadOrSave);
|
service->setGPGOperation(loadOrSave);
|
||||||
|
@ -1353,7 +1353,7 @@ bool AuthGPGimpl::isGPGAccepted(const std::string &id)
|
||||||
|
|
||||||
|
|
||||||
/* SKTAN : do not know how to use std::string id */
|
/* SKTAN : do not know how to use std::string id */
|
||||||
std::string AuthGPGimpl::SaveCertificateToString(const std::string &id)
|
std::string AuthGPGimpl::SaveCertificateToString(const std::string &id,bool include_signatures)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!isGPGId(id)) {
|
if (!isGPGId(id)) {
|
||||||
|
@ -1368,13 +1368,19 @@ std::string AuthGPGimpl::SaveCertificateToString(const std::string &id)
|
||||||
pattern[0] = id.c_str();
|
pattern[0] = id.c_str();
|
||||||
gpgme_data_t gpgmeData;
|
gpgme_data_t gpgmeData;
|
||||||
|
|
||||||
|
#ifdef GPGME_EXPORT_MODE_MINIMAL
|
||||||
|
gpgme_export_mode_t export_mode = include_signatures?0:GPGME_EXPORT_MODE_MINIMAL ;
|
||||||
|
#else
|
||||||
|
gpgme_export_mode_t export_mode = 0 ;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (GPG_ERR_NO_ERROR != gpgme_data_new (&gpgmeData))
|
if (GPG_ERR_NO_ERROR != gpgme_data_new (&gpgmeData))
|
||||||
{
|
{
|
||||||
std::cerr << "Error create Data" << std::endl;
|
std::cerr << "Error create Data" << std::endl;
|
||||||
}
|
}
|
||||||
gpgme_set_armor (CTX, 1);
|
gpgme_set_armor (CTX, 1);
|
||||||
|
|
||||||
if (GPG_ERR_NO_ERROR != gpgme_op_export_ext (CTX, pattern, 0, gpgmeData))
|
if (GPG_ERR_NO_ERROR != gpgme_op_export_ext (CTX, pattern, export_mode, gpgmeData))
|
||||||
{
|
{
|
||||||
std::cerr << "Error export Data" << std::endl;
|
std::cerr << "Error export Data" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,7 +213,7 @@ virtual bool isGPGId(const std::string &id) = 0;
|
||||||
*
|
*
|
||||||
****/
|
****/
|
||||||
virtual bool LoadCertificateFromString(const std::string &pem, std::string &gpg_id,std::string& error_string) = 0;
|
virtual bool LoadCertificateFromString(const std::string &pem, std::string &gpg_id,std::string& error_string) = 0;
|
||||||
virtual std::string SaveCertificateToString(const std::string &id) = 0;
|
virtual std::string SaveCertificateToString(const std::string &id,bool include_signatures) = 0;
|
||||||
|
|
||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
/************************* STAGE 6 ***********************************************/
|
/************************* STAGE 6 ***********************************************/
|
||||||
|
@ -333,7 +333,7 @@ virtual bool isGPGId(const std::string &id);
|
||||||
*
|
*
|
||||||
****/
|
****/
|
||||||
virtual bool LoadCertificateFromString(const std::string &pem, std::string &gpg_id,std::string& error_string);
|
virtual bool LoadCertificateFromString(const std::string &pem, std::string &gpg_id,std::string& error_string);
|
||||||
virtual std::string SaveCertificateToString(const std::string &id);
|
virtual std::string SaveCertificateToString(const std::string &id,bool include_signatures) ;
|
||||||
|
|
||||||
/*********************************************************************************/
|
/*********************************************************************************/
|
||||||
/************************* STAGE 6 ***********************************************/
|
/************************* STAGE 6 ***********************************************/
|
||||||
|
|
|
@ -211,8 +211,9 @@ virtual bool getAllowServerIPDetermination() = 0 ;
|
||||||
virtual bool getAllowTunnelConnection() = 0 ;
|
virtual bool getAllowTunnelConnection() = 0 ;
|
||||||
|
|
||||||
/* Auth Stuff */
|
/* Auth Stuff */
|
||||||
virtual std::string GetRetroshareInvite(const std::string& ssl_id) = 0;
|
virtual std::string GetRetroshareInvite(const std::string& ssl_id,bool include_signatures) = 0;
|
||||||
virtual std::string GetRetroshareInvite() = 0;
|
virtual std::string GetRetroshareInvite(bool include_signatures) = 0;
|
||||||
|
virtual bool hasExportMinimal() = 0 ;
|
||||||
|
|
||||||
virtual bool loadCertificateFromFile(const std::string &fname, std::string &ssl_id, std::string &gpg_id) = 0;
|
virtual bool loadCertificateFromFile(const std::string &fname, std::string &ssl_id, std::string &gpg_id) = 0;
|
||||||
virtual bool loadDetailsFromStringCert(const std::string &certGPG, RsPeerDetails &pd,std::string& error_string) = 0;
|
virtual bool loadDetailsFromStringCert(const std::string &certGPG, RsPeerDetails &pd,std::string& error_string) = 0;
|
||||||
|
|
|
@ -129,6 +129,15 @@ p3Peers::p3Peers(p3ConnectMgr *cm)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool p3Peers::hasExportMinimal()
|
||||||
|
{
|
||||||
|
#ifdef GPGME_EXPORT_MODE_MINIMAL
|
||||||
|
return true ;
|
||||||
|
#else
|
||||||
|
return false ;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/* Updates ... */
|
/* Updates ... */
|
||||||
bool p3Peers::FriendsChanged()
|
bool p3Peers::FriendsChanged()
|
||||||
{
|
{
|
||||||
|
@ -858,13 +867,13 @@ p3Peers::setVisState(const std::string &id, uint32_t extVisState)
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
/* Auth Stuff */
|
/* Auth Stuff */
|
||||||
std::string
|
std::string
|
||||||
p3Peers::GetRetroshareInvite()
|
p3Peers::GetRetroshareInvite(bool include_signatures)
|
||||||
{
|
{
|
||||||
return GetRetroshareInvite(getOwnId());
|
return GetRetroshareInvite(getOwnId(),include_signatures);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
p3Peers::GetRetroshareInvite(const std::string& ssl_id)
|
p3Peers::GetRetroshareInvite(const std::string& ssl_id,bool include_signatures)
|
||||||
{
|
{
|
||||||
#ifdef P3PEERS_DEBUG
|
#ifdef P3PEERS_DEBUG
|
||||||
std::cerr << "p3Peers::GetRetroshareInvite()" << std::endl;
|
std::cerr << "p3Peers::GetRetroshareInvite()" << std::endl;
|
||||||
|
@ -876,7 +885,7 @@ p3Peers::GetRetroshareInvite(const std::string& ssl_id)
|
||||||
|
|
||||||
if (getPeerDetails(ssl_id, Detail))
|
if (getPeerDetails(ssl_id, Detail))
|
||||||
{
|
{
|
||||||
invite = AuthGPG::getAuthGPG()->SaveCertificateToString(Detail.gpg_id);
|
invite = AuthGPG::getAuthGPG()->SaveCertificateToString(Detail.gpg_id,include_signatures);
|
||||||
|
|
||||||
if(!Detail.isOnlyGPGdetail)
|
if(!Detail.isOnlyGPGdetail)
|
||||||
{
|
{
|
||||||
|
|
|
@ -89,9 +89,10 @@ virtual bool getAllowTunnelConnection() ;
|
||||||
|
|
||||||
/* Auth Stuff */
|
/* Auth Stuff */
|
||||||
// Get the invitation (GPG cert + local/ext address + SSL id for the given peer)
|
// Get the invitation (GPG cert + local/ext address + SSL id for the given peer)
|
||||||
virtual std::string GetRetroshareInvite(const std::string& ssl_id);
|
virtual std::string GetRetroshareInvite(const std::string& ssl_id,bool include_signatures);
|
||||||
// same but for own id
|
// same but for own id
|
||||||
virtual std::string GetRetroshareInvite();
|
virtual std::string GetRetroshareInvite(bool include_signatures);
|
||||||
|
virtual bool hasExportMinimal() ;
|
||||||
|
|
||||||
virtual bool loadCertificateFromFile(const std::string &fname, std::string &id, std::string &gpg_id);
|
virtual bool loadCertificateFromFile(const std::string &fname, std::string &id, std::string &gpg_id);
|
||||||
virtual bool loadDetailsFromStringCert(const std::string &cert, RsPeerDetails &pd, std::string& error_string);
|
virtual bool loadDetailsFromStringCert(const std::string &cert, RsPeerDetails &pd, std::string& error_string);
|
||||||
|
|
|
@ -206,6 +206,18 @@ int IntroPage::nextId() const
|
||||||
|
|
||||||
return ConnectFriendWizard::Page_Foff;
|
return ConnectFriendWizard::Page_Foff;
|
||||||
}
|
}
|
||||||
|
void TextPage::toggleSignatureState()
|
||||||
|
{
|
||||||
|
_shouldAddSignatures = !_shouldAddSignatures ;
|
||||||
|
|
||||||
|
if(_shouldAddSignatures)
|
||||||
|
userCertIncludeSignaturesButton->setToolTip("Remove signatures") ;
|
||||||
|
else
|
||||||
|
userCertIncludeSignaturesButton->setToolTip("Include signatures") ;
|
||||||
|
|
||||||
|
updateOwnCert() ;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
//============================================================================
|
//============================================================================
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
@ -225,16 +237,10 @@ TextPage::TextPage(QWidget *parent)
|
||||||
|
|
||||||
std::cerr << "TextPage() getting Invite" << std::endl;
|
std::cerr << "TextPage() getting Invite" << std::endl;
|
||||||
userCertEdit = new QTextEdit;
|
userCertEdit = new QTextEdit;
|
||||||
std::string invite = rsPeers->GetRetroshareInvite();
|
|
||||||
|
|
||||||
userCertEdit->setReadOnly(true);
|
userCertEdit->setReadOnly(true);
|
||||||
QFont font("Courier New",10,50,false);
|
|
||||||
font.setStyleHint(QFont::TypeWriter,QFont::PreferMatch);
|
|
||||||
font.setStyle(QFont::StyleNormal);
|
|
||||||
userCertEdit->setFont(font);
|
|
||||||
userCertEdit->setText(QString::fromStdString(invite));
|
|
||||||
|
|
||||||
std::cerr << "TextPage() getting Invite: " << invite << std::endl;
|
_shouldAddSignatures = false ;
|
||||||
|
updateOwnCert() ;
|
||||||
|
|
||||||
userCertHelpButton = new QPushButton;
|
userCertHelpButton = new QPushButton;
|
||||||
userCertHelpButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
userCertHelpButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
|
@ -244,6 +250,15 @@ TextPage::TextPage(QWidget *parent)
|
||||||
connect (userCertHelpButton, SIGNAL( clicked()),
|
connect (userCertHelpButton, SIGNAL( clicked()),
|
||||||
this, SLOT( showHelpUserCert()) );
|
this, SLOT( showHelpUserCert()) );
|
||||||
|
|
||||||
|
userCertIncludeSignaturesButton = new QPushButton;
|
||||||
|
userCertIncludeSignaturesButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
|
userCertIncludeSignaturesButton->setFixedSize(20,20);
|
||||||
|
userCertIncludeSignaturesButton->setFlat(true);
|
||||||
|
userCertIncludeSignaturesButton->setIcon( QIcon(":images/gpgp_key_generate.png") );
|
||||||
|
userCertIncludeSignaturesButton->setToolTip(tr("Include signatures"));
|
||||||
|
|
||||||
|
connect (userCertIncludeSignaturesButton, SIGNAL(clicked()), this, SLOT(toggleSignatureState()));
|
||||||
|
|
||||||
userCertCopyButton = new QPushButton;
|
userCertCopyButton = new QPushButton;
|
||||||
userCertCopyButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
userCertCopyButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
userCertCopyButton->setFixedSize(20,20);
|
userCertCopyButton->setFixedSize(20,20);
|
||||||
|
@ -274,6 +289,10 @@ TextPage::TextPage(QWidget *parent)
|
||||||
|
|
||||||
userCertButtonsLayout = new QVBoxLayout();
|
userCertButtonsLayout = new QVBoxLayout();
|
||||||
userCertButtonsLayout->addWidget(userCertHelpButton);
|
userCertButtonsLayout->addWidget(userCertHelpButton);
|
||||||
|
|
||||||
|
if(rsPeers->hasExportMinimal())
|
||||||
|
userCertButtonsLayout->addWidget(userCertIncludeSignaturesButton);
|
||||||
|
|
||||||
userCertButtonsLayout->addWidget(userCertCopyButton);
|
userCertButtonsLayout->addWidget(userCertCopyButton);
|
||||||
userCertButtonsLayout->addWidget(userCertSaveButton);
|
userCertButtonsLayout->addWidget(userCertSaveButton);
|
||||||
userCertButtonsLayout->addWidget(userCertMailButton);
|
userCertButtonsLayout->addWidget(userCertMailButton);
|
||||||
|
@ -288,6 +307,9 @@ TextPage::TextPage(QWidget *parent)
|
||||||
friendCertEdit = new QTextEdit;
|
friendCertEdit = new QTextEdit;
|
||||||
|
|
||||||
//font.setWeight(75);
|
//font.setWeight(75);
|
||||||
|
QFont font("Courier New",10,50,false);
|
||||||
|
font.setStyleHint(QFont::TypeWriter,QFont::PreferMatch);
|
||||||
|
font.setStyle(QFont::StyleNormal);
|
||||||
friendCertEdit->setFont(font);
|
friendCertEdit->setFont(font);
|
||||||
|
|
||||||
friendCertCleanButton = new QPushButton;
|
friendCertCleanButton = new QPushButton;
|
||||||
|
@ -314,6 +336,20 @@ TextPage::TextPage(QWidget *parent)
|
||||||
//
|
//
|
||||||
setLayout(textPageLayout);
|
setLayout(textPageLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextPage::updateOwnCert()
|
||||||
|
{
|
||||||
|
std::string invite = rsPeers->GetRetroshareInvite(_shouldAddSignatures);
|
||||||
|
|
||||||
|
std::cerr << "TextPage() getting Invite: " << invite << std::endl;
|
||||||
|
|
||||||
|
QFont font("Courier New",10,50,false);
|
||||||
|
font.setStyleHint(QFont::TypeWriter,QFont::PreferMatch);
|
||||||
|
font.setStyle(QFont::StyleNormal);
|
||||||
|
userCertEdit->setFont(font);
|
||||||
|
userCertEdit->setText(QString::fromStdString(invite));
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
//============================================================================
|
//============================================================================
|
||||||
//
|
//
|
||||||
|
@ -706,7 +742,7 @@ void CertificatePage::loadFriendCert() {
|
||||||
void CertificatePage::generateCertificateCalled() {
|
void CertificatePage::generateCertificateCalled() {
|
||||||
qDebug() << " generateCertificateCalled";
|
qDebug() << " generateCertificateCalled";
|
||||||
|
|
||||||
std::string cert = rsPeers->GetRetroshareInvite();
|
std::string cert = rsPeers->GetRetroshareInvite(false);
|
||||||
if (cert.empty()) {
|
if (cert.empty()) {
|
||||||
QMessageBox::information(this, tr("RetroShare"),
|
QMessageBox::information(this, tr("RetroShare"),
|
||||||
tr("Sorry, create certificate failed"),
|
tr("Sorry, create certificate failed"),
|
||||||
|
@ -1239,7 +1275,7 @@ bool EmailPage::validatePage()
|
||||||
if (mailaddresses.isEmpty() == false)
|
if (mailaddresses.isEmpty() == false)
|
||||||
{
|
{
|
||||||
std::string body = inviteTextEdit->toPlainText().toStdString();
|
std::string body = inviteTextEdit->toPlainText().toStdString();
|
||||||
body += "\n\n" + rsPeers->GetRetroshareInvite();
|
body += "\n\n" + rsPeers->GetRetroshareInvite(false);
|
||||||
|
|
||||||
sendMail (mailaddresses.toStdString(), subjectEdit->text().toStdString(), body);
|
sendMail (mailaddresses.toStdString(), subjectEdit->text().toStdString(), body);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -84,6 +84,7 @@ private:
|
||||||
QVBoxLayout* userCertButtonsLayout;
|
QVBoxLayout* userCertButtonsLayout;
|
||||||
QPushButton* userCertHelpButton;
|
QPushButton* userCertHelpButton;
|
||||||
QPushButton* userCertCopyButton;
|
QPushButton* userCertCopyButton;
|
||||||
|
QPushButton* userCertIncludeSignaturesButton;
|
||||||
QPushButton* userCertSaveButton;
|
QPushButton* userCertSaveButton;
|
||||||
QPushButton* userCertMailButton;//! on Windows, click on this button
|
QPushButton* userCertMailButton;//! on Windows, click on this button
|
||||||
//! launches default email client
|
//! launches default email client
|
||||||
|
@ -96,13 +97,16 @@ private:
|
||||||
QVBoxLayout* textPageLayout;
|
QVBoxLayout* textPageLayout;
|
||||||
|
|
||||||
void setCurrentFileName(const QString &fileName);
|
void setCurrentFileName(const QString &fileName);
|
||||||
|
void updateOwnCert() ;
|
||||||
|
|
||||||
|
bool _shouldAddSignatures ;
|
||||||
QString fileName;
|
QString fileName;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void showHelpUserCert();
|
void showHelpUserCert();
|
||||||
void copyCert();
|
void copyCert();
|
||||||
void cleanFriendCert();
|
void cleanFriendCert();
|
||||||
|
void toggleSignatureState();
|
||||||
|
|
||||||
bool fileSave();
|
bool fileSave();
|
||||||
bool fileSaveAs();
|
bool fileSaveAs();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue