mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -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
@ -428,7 +428,7 @@ void AuthGPGimpl::processServices()
|
||||
#endif
|
||||
|
||||
/* save the certificate to string */
|
||||
loadOrSave->m_certGpg = SaveCertificateToString(loadOrSave->m_certGpgId);
|
||||
loadOrSave->m_certGpg = SaveCertificateToString(loadOrSave->m_certGpgId,true);
|
||||
}
|
||||
|
||||
service->setGPGOperation(loadOrSave);
|
||||
@ -1353,7 +1353,7 @@ bool AuthGPGimpl::isGPGAccepted(const 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)) {
|
||||
@ -1368,13 +1368,19 @@ std::string AuthGPGimpl::SaveCertificateToString(const std::string &id)
|
||||
pattern[0] = id.c_str();
|
||||
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))
|
||||
{
|
||||
std::cerr << "Error create Data" << std::endl;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
@ -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 std::string SaveCertificateToString(const std::string &id) = 0;
|
||||
virtual std::string SaveCertificateToString(const std::string &id,bool include_signatures) = 0;
|
||||
|
||||
/*********************************************************************************/
|
||||
/************************* 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 std::string SaveCertificateToString(const std::string &id);
|
||||
virtual std::string SaveCertificateToString(const std::string &id,bool include_signatures) ;
|
||||
|
||||
/*********************************************************************************/
|
||||
/************************* STAGE 6 ***********************************************/
|
||||
|
@ -211,8 +211,9 @@ virtual bool getAllowServerIPDetermination() = 0 ;
|
||||
virtual bool getAllowTunnelConnection() = 0 ;
|
||||
|
||||
/* Auth Stuff */
|
||||
virtual std::string GetRetroshareInvite(const std::string& ssl_id) = 0;
|
||||
virtual std::string GetRetroshareInvite() = 0;
|
||||
virtual std::string GetRetroshareInvite(const std::string& ssl_id,bool include_signatures) = 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 loadDetailsFromStringCert(const std::string &certGPG, RsPeerDetails &pd,std::string& error_string) = 0;
|
||||
|
@ -129,6 +129,15 @@ p3Peers::p3Peers(p3ConnectMgr *cm)
|
||||
return;
|
||||
}
|
||||
|
||||
bool p3Peers::hasExportMinimal()
|
||||
{
|
||||
#ifdef GPGME_EXPORT_MODE_MINIMAL
|
||||
return true ;
|
||||
#else
|
||||
return false ;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Updates ... */
|
||||
bool p3Peers::FriendsChanged()
|
||||
{
|
||||
@ -858,13 +867,13 @@ p3Peers::setVisState(const std::string &id, uint32_t extVisState)
|
||||
//===========================================================================
|
||||
/* Auth Stuff */
|
||||
std::string
|
||||
p3Peers::GetRetroshareInvite()
|
||||
p3Peers::GetRetroshareInvite(bool include_signatures)
|
||||
{
|
||||
return GetRetroshareInvite(getOwnId());
|
||||
return GetRetroshareInvite(getOwnId(),include_signatures);
|
||||
}
|
||||
|
||||
std::string
|
||||
p3Peers::GetRetroshareInvite(const std::string& ssl_id)
|
||||
p3Peers::GetRetroshareInvite(const std::string& ssl_id,bool include_signatures)
|
||||
{
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::GetRetroshareInvite()" << std::endl;
|
||||
@ -876,7 +885,7 @@ p3Peers::GetRetroshareInvite(const std::string& ssl_id)
|
||||
|
||||
if (getPeerDetails(ssl_id, Detail))
|
||||
{
|
||||
invite = AuthGPG::getAuthGPG()->SaveCertificateToString(Detail.gpg_id);
|
||||
invite = AuthGPG::getAuthGPG()->SaveCertificateToString(Detail.gpg_id,include_signatures);
|
||||
|
||||
if(!Detail.isOnlyGPGdetail)
|
||||
{
|
||||
|
@ -89,9 +89,10 @@ virtual bool getAllowTunnelConnection() ;
|
||||
|
||||
/* Auth Stuff */
|
||||
// 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
|
||||
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 loadDetailsFromStringCert(const std::string &cert, RsPeerDetails &pd, std::string& error_string);
|
||||
|
@ -206,6 +206,18 @@ int IntroPage::nextId() const
|
||||
|
||||
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;
|
||||
userCertEdit = new QTextEdit;
|
||||
std::string invite = rsPeers->GetRetroshareInvite();
|
||||
|
||||
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->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
@ -244,6 +250,15 @@ TextPage::TextPage(QWidget *parent)
|
||||
connect (userCertHelpButton, SIGNAL( clicked()),
|
||||
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->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
userCertCopyButton->setFixedSize(20,20);
|
||||
@ -274,6 +289,10 @@ TextPage::TextPage(QWidget *parent)
|
||||
|
||||
userCertButtonsLayout = new QVBoxLayout();
|
||||
userCertButtonsLayout->addWidget(userCertHelpButton);
|
||||
|
||||
if(rsPeers->hasExportMinimal())
|
||||
userCertButtonsLayout->addWidget(userCertIncludeSignaturesButton);
|
||||
|
||||
userCertButtonsLayout->addWidget(userCertCopyButton);
|
||||
userCertButtonsLayout->addWidget(userCertSaveButton);
|
||||
userCertButtonsLayout->addWidget(userCertMailButton);
|
||||
@ -288,6 +307,9 @@ TextPage::TextPage(QWidget *parent)
|
||||
friendCertEdit = new QTextEdit;
|
||||
|
||||
//font.setWeight(75);
|
||||
QFont font("Courier New",10,50,false);
|
||||
font.setStyleHint(QFont::TypeWriter,QFont::PreferMatch);
|
||||
font.setStyle(QFont::StyleNormal);
|
||||
friendCertEdit->setFont(font);
|
||||
|
||||
friendCertCleanButton = new QPushButton;
|
||||
@ -314,6 +336,20 @@ TextPage::TextPage(QWidget *parent)
|
||||
//
|
||||
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() {
|
||||
qDebug() << " generateCertificateCalled";
|
||||
|
||||
std::string cert = rsPeers->GetRetroshareInvite();
|
||||
std::string cert = rsPeers->GetRetroshareInvite(false);
|
||||
if (cert.empty()) {
|
||||
QMessageBox::information(this, tr("RetroShare"),
|
||||
tr("Sorry, create certificate failed"),
|
||||
@ -1239,7 +1275,7 @@ bool EmailPage::validatePage()
|
||||
if (mailaddresses.isEmpty() == false)
|
||||
{
|
||||
std::string body = inviteTextEdit->toPlainText().toStdString();
|
||||
body += "\n\n" + rsPeers->GetRetroshareInvite();
|
||||
body += "\n\n" + rsPeers->GetRetroshareInvite(false);
|
||||
|
||||
sendMail (mailaddresses.toStdString(), subjectEdit->text().toStdString(), body);
|
||||
return true;
|
||||
|
@ -84,6 +84,7 @@ private:
|
||||
QVBoxLayout* userCertButtonsLayout;
|
||||
QPushButton* userCertHelpButton;
|
||||
QPushButton* userCertCopyButton;
|
||||
QPushButton* userCertIncludeSignaturesButton;
|
||||
QPushButton* userCertSaveButton;
|
||||
QPushButton* userCertMailButton;//! on Windows, click on this button
|
||||
//! launches default email client
|
||||
@ -96,13 +97,16 @@ private:
|
||||
QVBoxLayout* textPageLayout;
|
||||
|
||||
void setCurrentFileName(const QString &fileName);
|
||||
void updateOwnCert() ;
|
||||
|
||||
bool _shouldAddSignatures ;
|
||||
QString fileName;
|
||||
|
||||
private slots:
|
||||
void showHelpUserCert();
|
||||
void copyCert();
|
||||
void cleanFriendCert();
|
||||
void toggleSignatureState();
|
||||
|
||||
bool fileSave();
|
||||
bool fileSaveAs();
|
||||
|
Loading…
Reference in New Issue
Block a user