Removed automatic cleaning of the certificate in p3Peers::loadDetailsFromStringCert.

Added new button in ConnectFriendWizard for cleaning the certificate.
Fixed cleaning:
- added blank line after the armor header
- moved the checksum to a new line
Recompile of the GUI needed.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4134 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2011-04-08 18:53:12 +00:00
parent 1bef23042f
commit 8f0793f071
7 changed files with 192 additions and 84 deletions

View file

@ -26,6 +26,7 @@
#include "cleanupxpgp.h" #include "cleanupxpgp.h"
#include <iostream> #include <iostream>
#include <string.h> //strlen #include <string.h> //strlen
#include <list>
/* /*
Method for cleaning up the certificate. This method removes any unnecessay white spaces and unnecessary Method for cleaning up the certificate. This method removes any unnecessay white spaces and unnecessary
@ -40,7 +41,7 @@ end tag we take care of cases like ----- END XPGP . Here extra empty spaces h
introduced and the actual tag should have been -----END XPGP introduced and the actual tag should have been -----END XPGP
*/ */
std::string cleanUpCertificate(std::string badCertificate) std::string cleanUpCertificate(const std::string& badCertificate)
{ {
/* /*
Buffer for storing the cleaned certificate. In certain cases the Buffer for storing the cleaned certificate. In certain cases the
@ -48,33 +49,33 @@ std::string cleanUpCertificate(std::string badCertificate)
*/ */
std::string cleanCertificate; std::string cleanCertificate;
//The entire certificate begin tag //The entire certificate begin tag
const char * beginCertTag="-----BEGIN"; const char * beginCertTag="-----BEGIN";
//The entire certificate end tag //The entire certificate end tag
const char * endCertTag="-----END"; const char * endCertTag="-----END";
//Tag containing dots. The common part of both start and end tags //Tag containing dots. The common part of both start and end tags
const char * commonTag="-----"; const char * commonTag="-----";
//Only BEGIN part of the begin tag //Only BEGIN part of the begin tag
const char * beginTag="BEGIN"; const char * beginTag="BEGIN";
//Only END part of the end tag //Only END part of the end tag
const char * endTag="END"; const char * endTag="END";
//The start index of the ----- part of the certificate begin tag //The start index of the ----- part of the certificate begin tag
size_t beginCertStartIdx1=0; size_t beginCertStartIdx1=0;
//The start index of the BEGIN part of the certificate begin tag //The start index of the BEGIN part of the certificate begin tag
size_t beginCertStartIdx2=0; size_t beginCertStartIdx2=0;
//The start index of the end part(-----) of the certificate begin tag. The begin tag ends with -----. Example -----BEGIN XPGP CERTIFICATE----- //The start index of the end part(-----) of the certificate begin tag. The begin tag ends with -----. Example -----BEGIN XPGP CERTIFICATE-----
size_t beginCertEndIdx=0; size_t beginCertEndIdx=0;
//The start index of the ----- part of the certificate end tag //The start index of the ----- part of the certificate end tag
size_t endCertStartIdx1=0; size_t endCertStartIdx1=0;
//The start index of the END part of the certificate end tag //The start index of the END part of the certificate end tag
size_t endCertStartIdx2=0; size_t endCertStartIdx2=0;
//The start index of the end part(-----) of the certificate end tag. The begin tag ends with -----. Example -----BEGIN XPGP CERTIFICATE----- //The start index of the end part(-----) of the certificate end tag. The begin tag ends with -----. Example -----BEGIN XPGP CERTIFICATE-----
size_t endCertEndIdx=0; size_t endCertEndIdx=0;
//The length of the bad certificate. //The length of the bad certificate.
size_t lengthOfCert=badCertificate.length(); size_t lengthOfCert=badCertificate.length();
//The current index value in the bad certificate //The current index value in the bad certificate
size_t currBadCertIdx=0; size_t currBadCertIdx=0;
//Temporary index value //Temporary index value
size_t tmpIdx=0; size_t tmpIdx=0;
//Boolean flag showing if the begin tag or the end tag has been found //Boolean flag showing if the begin tag or the end tag has been found
bool found=false; bool found=false;
/* /*
@ -92,7 +93,7 @@ std::string cleanUpCertificate(std::string badCertificate)
if(beginCertStartIdx2!=std::string::npos) if(beginCertStartIdx2!=std::string::npos)
{ {
found=true; found=true;
for(size_t i=beginCertStartIdx1+strlen(commonTag);i<beginCertStartIdx2;i++) for(size_t i=beginCertStartIdx1+strlen(commonTag);i<beginCertStartIdx2;i++)
{ {
if(badCertificate[i]!=' ' && badCertificate[i]!='\n' ) if(badCertificate[i]!=' ' && badCertificate[i]!='\n' )
{ {
@ -137,7 +138,7 @@ std::string cleanUpCertificate(std::string badCertificate)
if(endCertStartIdx2!=std::string::npos) if(endCertStartIdx2!=std::string::npos)
{ {
found=true; found=true;
for(size_t i=endCertStartIdx1+strlen(commonTag);i<endCertStartIdx2;i++) for(size_t i=endCertStartIdx1+strlen(commonTag);i<endCertStartIdx2;i++)
{ {
if(badCertificate[i]!=' '&& badCertificate[i]!='\n') if(badCertificate[i]!=' '&& badCertificate[i]!='\n')
{ {
@ -211,18 +212,33 @@ std::string cleanUpCertificate(std::string badCertificate)
while(badCertificate[currBadCertIdx]=='\n'|| badCertificate[currBadCertIdx]==' ') while(badCertificate[currBadCertIdx]=='\n'|| badCertificate[currBadCertIdx]==' ')
{ {
currBadCertIdx++; currBadCertIdx++;
} }
//keep the first line : gnupg version //keep the armor header
cleanCertificate += badCertificate[currBadCertIdx]; std::list<std::string> header;
currBadCertIdx++; header.push_back("Version");
while(badCertificate[currBadCertIdx]!='\n') header.push_back("Comment");
{ header.push_back("MessageID");
cleanCertificate += badCertificate[currBadCertIdx]; header.push_back("Hash");
currBadCertIdx++; header.push_back("Charset");
}
cleanCertificate += badCertificate[currBadCertIdx]; for (std::list<std::string>::iterator headerIt = header.begin (); headerIt != header.end(); headerIt++)
currBadCertIdx++; {
if (badCertificate.substr(currBadCertIdx, (*headerIt).length()) == *headerIt)
{
cleanCertificate += badCertificate.substr(currBadCertIdx, (*headerIt).length());
currBadCertIdx += (*headerIt).length();
while(badCertificate[currBadCertIdx]!='\n')
{
cleanCertificate += badCertificate[currBadCertIdx];
currBadCertIdx++;
}
cleanCertificate += "\n";
}
}
//add empty line after armor header
cleanCertificate += "\n";
//Start of the actual certificate. Remove spaces in the certificate //Start of the actual certificate. Remove spaces in the certificate
//and make sure there are 64 characters per line in the //and make sure there are 64 characters per line in the
@ -236,6 +252,11 @@ std::string cleanUpCertificate(std::string badCertificate)
cntPerLine=0; cntPerLine=0;
continue; continue;
} }
else if(badCertificate[currBadCertIdx]=='=')
{
/* checksum */
break;
}
else if(badCertificate[currBadCertIdx]==' ') else if(badCertificate[currBadCertIdx]==' ')
{ {
currBadCertIdx++; currBadCertIdx++;
@ -249,24 +270,50 @@ std::string cleanUpCertificate(std::string badCertificate)
cleanCertificate += badCertificate[currBadCertIdx]; cleanCertificate += badCertificate[currBadCertIdx];
cntPerLine++; cntPerLine++;
currBadCertIdx++; currBadCertIdx++;
} }
if(cleanCertificate.substr(cleanCertificate.length()-1,1)!="\n")
{ if (badCertificate[currBadCertIdx] == '=')
cleanCertificate += "\n"; {
// std::cerr<<"zeeeee"<<std::endl; /* checksum */
} if (*cleanCertificate.rbegin() != '\n')
else {
{ cleanCertificate += "\n";
// std::cerr<<"zooooo"<<std::endl; }
}
while(currBadCertIdx<endCertStartIdx1)
{
if (badCertificate[currBadCertIdx]==' ')
{
currBadCertIdx++;
continue;
}
else if(badCertificate[currBadCertIdx]=='\n')
{
currBadCertIdx++;
continue;
}
cleanCertificate += badCertificate[currBadCertIdx];
cntPerLine++;
currBadCertIdx++;
}
}
if(cleanCertificate.substr(cleanCertificate.length()-1,1)!="\n")
{
cleanCertificate += "\n";
// std::cerr<<"zeeeee"<<std::endl;
}
else
{
// std::cerr<<"zooooo"<<std::endl;
}
/* /*
Copying the begining part of the certificate end tag. Copying Copying the begining part of the certificate end tag. Copying
-----END part of the tag. -----END part of the tag.
*/ */
cleanCertificate += endCertTag; cleanCertificate += endCertTag;
currBadCertIdx=endCertStartIdx2+strlen(endTag); currBadCertIdx=endCertStartIdx2+strlen(endTag);
/* /*
Copying the name of the certificate e.g XPGP CERTIFICATE. The end tag also has the Copying the name of the certificate e.g XPGP CERTIFICATE. The end tag also has the
the name of the tag. the name of the tag.
*/ */
@ -284,9 +331,9 @@ std::string cleanUpCertificate(std::string badCertificate)
{ {
cleanCertificate += badCertificate[currBadCertIdx]; cleanCertificate += badCertificate[currBadCertIdx];
currBadCertIdx++; currBadCertIdx++;
} }
} }
/* /*
If the last character is a space we need to remove it. If the last character is a space we need to remove it.
*/ */
@ -300,16 +347,17 @@ std::string cleanUpCertificate(std::string badCertificate)
cleanCertificate += commonTag; cleanCertificate += commonTag;
cleanCertificate += "\n"; cleanCertificate += "\n";
return cleanCertificate; return cleanCertificate;
} }
#ifdef UNUSED_CODE
int findEndIdxOfCertStartTag(std::string badCertificate) int findEndIdxOfCertStartTag(std::string badCertificate)
{ {
size_t idxTag1=0; size_t idxTag1=0;
size_t tmpIdx=0; size_t tmpIdx=0;
size_t idxTag2=0; size_t idxTag2=0;
const char * tag1="---"; const char * tag1="---";
const char * tag2="---"; const char * tag2="---";
bool found=false; bool found=false;
while(found==false && (idxTag1=badCertificate.find(tag1,tmpIdx))!=std::string::npos) while(found==false && (idxTag1=badCertificate.find(tag1,tmpIdx))!=std::string::npos)
{ {
@ -318,7 +366,7 @@ int findEndIdxOfCertStartTag(std::string badCertificate)
if(idxTag2!=std::string::npos) if(idxTag2!=std::string::npos)
{ {
found=true; found=true;
for(size_t i=idxTag1+strlen(tag1);i<idxTag2;i++) for(size_t i=idxTag1+strlen(tag1);i<idxTag2;i++)
{ {
if(badCertificate[i]!=' ') if(badCertificate[i]!=' ')
{ {
@ -331,10 +379,7 @@ int findEndIdxOfCertStartTag(std::string badCertificate)
{ {
break; break;
} }
} }
return 1; return 1;
} }
#endif

View file

@ -38,13 +38,16 @@
//! ... text stuff ..... //! ... text stuff .....
//! //!
//!-----BEGIN XPGP CERTIFICATE----- //!-----BEGIN XPGP CERTIFICATE-----
//!Version: ...
//!
//!MIICxQIBADCCAUkCAQAwHhcNMDkwMjI4MTgzODIyWhcNMTQwMjI3MTgzODIyWjCC //!MIICxQIBADCCAUkCAQAwHhcNMDkwMjI4MTgzODIyWhcNMTQwMjI3MTgzODIyWjCC
//! ...more ines here... //! ...more ines here...
//!mEuhG8UmDIzC1jeTu8rTMnO+DO3FH/cek1vlfFl4t9g/xktG9U4SPLg= //!mEuhG8UmDIzC1jeTu8rTMnO+DO3FH/cek1vlfFl4t9g/xktG9U4SPLg=
//!=checksum
//!-----END XPGP CERTIFICATE----- //!-----END XPGP CERTIFICATE-----
//! //!
//! In the newer gui version, users send each other almost clean certificates, //! In the newer gui version, users send each other almost clean certificates,
//! so this functon is used only to avoid possible bugs with line endings //! so this functon is used only to avoid possible bugs with line endings
std::string cleanUpCertificate(std::string badCertificate); std::string cleanUpCertificate(const std::string& badCertificate);
#endif #endif

View file

@ -216,6 +216,7 @@ virtual std::string GetRetroshareInvite() = 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;
virtual bool cleanCertificate(const std::string &certstr, std::string &cleanCert) = 0;
virtual bool saveCertificateToFile(const std::string &id, const std::string &fname) = 0; virtual bool saveCertificateToFile(const std::string &id, const std::string &fname) = 0;
virtual std::string saveCertificateToString(const std::string &id) = 0; virtual std::string saveCertificateToString(const std::string &id) = 0;

View file

@ -957,7 +957,24 @@ bool p3Peers::loadCertificateFromFile(const std::string &fname, std::string &id
// return false; // return false;
//} //}
static bool splitCert(const std::string &certstr, std::string &cert, std::string &peerInfo)
{
cert.erase();
peerInfo.erase();
/* search for -----END CERTIFICATE----- */
std::string pgpend("-----END PGP PUBLIC KEY BLOCK-----");
size_t pos = certstr.find(pgpend);
if (pos != std::string::npos) {
pos += pgpend.length();
cert = certstr.substr(0, pos);
peerInfo = certstr.substr(pos + 1);
}
return !cert.empty();
}
bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetails &pd,std::string& error_string) bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetails &pd,std::string& error_string)
{ {
@ -966,23 +983,21 @@ bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetai
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
/* search for -----END CERTIFICATE----- */
std::string pgpend("-----END PGP PUBLIC KEY BLOCK-----");
//parse the text to get ip address //parse the text to get ip address
try { try {
size_t parsePosition = certstr.find(pgpend); std::string cert;
std::string peerInfo;
if (parsePosition != std::string::npos) { if (splitCert(certstr, cert, peerInfo)) {
parsePosition += pgpend.length();
std::string pgpCert = certstr.substr(0, parsePosition);
std::string gpg_id; std::string gpg_id;
std::string cleancert = cleanUpCertificate(pgpCert); AuthGPG::getAuthGPG()->LoadCertificateFromString(cert, gpg_id,error_string);
AuthGPG::getAuthGPG()->LoadCertificateFromString(cleancert, gpg_id,error_string);
AuthGPG::getAuthGPG()->getGPGDetails(gpg_id, pd); AuthGPG::getAuthGPG()->getGPGDetails(gpg_id, pd);
if (gpg_id == "") { if (gpg_id.empty()) {
return false; return false;
} }
} else {
return false;
} }
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
@ -990,11 +1005,11 @@ bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetai
#endif #endif
//let's parse the ssl id //let's parse the ssl id
parsePosition = certstr.find(CERT_SSL_ID); size_t parsePosition = peerInfo.find(CERT_SSL_ID);
std::cerr << "sslid position : " << parsePosition << std::endl; std::cerr << "sslid position : " << parsePosition << std::endl;
if (parsePosition != std::string::npos) { if (parsePosition != std::string::npos) {
parsePosition += CERT_SSL_ID.length(); parsePosition += CERT_SSL_ID.length();
std::string subCert = certstr.substr(parsePosition); std::string subCert = peerInfo.substr(parsePosition);
parsePosition = subCert.find(";"); parsePosition = subCert.find(";");
if (parsePosition != std::string::npos) { if (parsePosition != std::string::npos) {
std::string ssl_id = subCert.substr(0, parsePosition); std::string ssl_id = subCert.substr(0, parsePosition);
@ -1005,11 +1020,11 @@ bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetai
} }
//let's parse the location //let's parse the location
parsePosition = certstr.find(CERT_LOCATION); parsePosition = peerInfo.find(CERT_LOCATION);
std::cerr << "location position : " << parsePosition << std::endl; std::cerr << "location position : " << parsePosition << std::endl;
if (parsePosition != std::string::npos) { if (parsePosition != std::string::npos) {
parsePosition += CERT_LOCATION.length(); parsePosition += CERT_LOCATION.length();
std::string subCert = certstr.substr(parsePosition); std::string subCert = peerInfo.substr(parsePosition);
parsePosition = subCert.find(";"); parsePosition = subCert.find(";");
if (parsePosition != std::string::npos) { if (parsePosition != std::string::npos) {
std::string location = subCert.substr(0, parsePosition); std::string location = subCert.substr(0, parsePosition);
@ -1019,11 +1034,11 @@ bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetai
} }
//let's parse ip local address //let's parse ip local address
parsePosition = certstr.find(CERT_LOCAL_IP); parsePosition = peerInfo.find(CERT_LOCAL_IP);
std::cerr << "local ip position : " << parsePosition << std::endl; std::cerr << "local ip position : " << parsePosition << std::endl;
if (parsePosition != std::string::npos) { if (parsePosition != std::string::npos) {
parsePosition += CERT_LOCAL_IP.length(); parsePosition += CERT_LOCAL_IP.length();
std::string subCert = certstr.substr(parsePosition); std::string subCert = peerInfo.substr(parsePosition);
parsePosition = subCert.find(":"); parsePosition = subCert.find(":");
if (parsePosition != std::string::npos) { if (parsePosition != std::string::npos) {
std::string local_ip = subCert.substr(0, parsePosition); std::string local_ip = subCert.substr(0, parsePosition);
@ -1045,11 +1060,11 @@ bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetai
} }
//let's parse ip ext address //let's parse ip ext address
parsePosition = certstr.find(CERT_EXT_IP); parsePosition = peerInfo.find(CERT_EXT_IP);
std::cerr << "Ext ip position : " << parsePosition << std::endl; std::cerr << "Ext ip position : " << parsePosition << std::endl;
if (parsePosition != std::string::npos) { if (parsePosition != std::string::npos) {
parsePosition = parsePosition + CERT_EXT_IP.length(); parsePosition = parsePosition + CERT_EXT_IP.length();
std::string subCert = certstr.substr(parsePosition); std::string subCert = peerInfo.substr(parsePosition);
parsePosition = subCert.find(":"); parsePosition = subCert.find(":");
if (parsePosition != std::string::npos) { if (parsePosition != std::string::npos) {
std::string ext_ip = subCert.substr(0, parsePosition); std::string ext_ip = subCert.substr(0, parsePosition);
@ -1071,11 +1086,11 @@ bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetai
} }
//let's parse DynDNS //let's parse DynDNS
parsePosition = certstr.find(CERT_DYNDNS); parsePosition = peerInfo.find(CERT_DYNDNS);
std::cerr << "location DynDNS : " << parsePosition << std::endl; std::cerr << "location DynDNS : " << parsePosition << std::endl;
if (parsePosition != std::string::npos) { if (parsePosition != std::string::npos) {
parsePosition += CERT_DYNDNS.length(); parsePosition += CERT_DYNDNS.length();
std::string subCert = certstr.substr(parsePosition); std::string subCert = peerInfo.substr(parsePosition);
parsePosition = subCert.find(";"); parsePosition = subCert.find(";");
if (parsePosition != std::string::npos) { if (parsePosition != std::string::npos) {
std::string DynDNS = subCert.substr(0, parsePosition); std::string DynDNS = subCert.substr(0, parsePosition);
@ -1095,9 +1110,26 @@ bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetai
} }
} }
bool p3Peers::cleanCertificate(const std::string &certstr, std::string &cleanCert)
{
std::string cert;
std::string peerInfo;
if (splitCert(certstr, cert, peerInfo)) {
cleanCert = cleanUpCertificate(cert);
if (!cleanCert.empty()) {
if (!peerInfo.empty()) {
if (*cleanCert.rbegin() != '\n') {
cleanCert += "\n";
}
cleanCert += peerInfo;
}
return true;
}
}
return false;
}
bool p3Peers::saveCertificateToFile(const std::string &id, const std::string &fname) bool p3Peers::saveCertificateToFile(const std::string &id, const std::string &fname)
{ {

View file

@ -94,7 +94,8 @@ virtual std::string GetRetroshareInvite(const std::string& ssl_id);
virtual std::string GetRetroshareInvite(); virtual std::string GetRetroshareInvite();
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);
virtual bool cleanCertificate(const std::string &certstr, std::string &cleanCert);
virtual bool saveCertificateToFile(const std::string &id, const std::string &fname); virtual bool saveCertificateToFile(const std::string &id, const std::string &fname);
virtual std::string saveCertificateToString(const std::string &id); virtual std::string saveCertificateToString(const std::string &id);

View file

@ -228,11 +228,9 @@ TextPage::TextPage(QWidget *parent)
std::string invite = rsPeers->GetRetroshareInvite(); std::string invite = rsPeers->GetRetroshareInvite();
userCertEdit->setReadOnly(true); userCertEdit->setReadOnly(true);
userCertEdit->setMinimumHeight(200);
userCertEdit->setMinimumWidth(530);
QFont font("Courier New",10,50,false); QFont font("Courier New",10,50,false);
font.setStyleHint(QFont::TypeWriter,QFont::PreferMatch); font.setStyleHint(QFont::TypeWriter,QFont::PreferMatch);
font.setStyle(QFont::StyleNormal); font.setStyle(QFont::StyleNormal);
userCertEdit->setFont(font); userCertEdit->setFont(font);
userCertEdit->setText(QString::fromStdString(invite)); userCertEdit->setText(QString::fromStdString(invite));
@ -292,12 +290,27 @@ TextPage::TextPage(QWidget *parent)
//font.setWeight(75); //font.setWeight(75);
friendCertEdit->setFont(font); friendCertEdit->setFont(font);
friendCertCleanButton = new QPushButton;
friendCertCleanButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
friendCertCleanButton->setFixedSize(20,20);
friendCertCleanButton->setFlat(true);
friendCertCleanButton->setIcon( QIcon(":images/accepted16.png") );
friendCertCleanButton->setToolTip(tr("Clean certificate"));
connect (friendCertCleanButton, SIGNAL(clicked()), this, SLOT(cleanFriendCert()));
friendCertButtonsLayout = new QVBoxLayout();
friendCertButtonsLayout->addWidget(friendCertCleanButton);
friendCertLayout = new QHBoxLayout();
friendCertLayout->addWidget(friendCertEdit);
friendCertLayout->addLayout(friendCertButtonsLayout);
//=== add all widgets to one layout //=== add all widgets to one layout
textPageLayout = new QVBoxLayout(); textPageLayout = new QVBoxLayout();
textPageLayout->addWidget(userCertLabel); textPageLayout->addWidget(userCertLabel);
textPageLayout->addLayout(userCertLayout); textPageLayout->addLayout(userCertLayout);
textPageLayout->addWidget(friendCertLabel); textPageLayout->addWidget(friendCertLabel);
textPageLayout->addWidget(friendCertEdit); textPageLayout->addLayout(friendCertLayout);
// //
setLayout(textPageLayout); setLayout(textPageLayout);
} }
@ -329,6 +342,16 @@ TextPage::runEmailClient()
sendMail ("", tr("RetroShare Invite").toStdString(), userCertEdit->toPlainText().toStdString()); sendMail ("", tr("RetroShare Invite").toStdString(), userCertEdit->toPlainText().toStdString());
} }
void TextPage::cleanFriendCert()
{
std::string cert = friendCertEdit->toPlainText().toStdString();
std::string cleanCert;
if (rsPeers->cleanCertificate(cert, cleanCert)) {
friendCertEdit->setText(QString::fromStdString(cleanCert));
}
}
// //
//============================================================================ //============================================================================
// //

View file

@ -89,6 +89,9 @@ private:
//! launches default email client //! launches default email client
QLabel* friendCertLabel; QLabel* friendCertLabel;
QTextEdit* friendCertEdit; QTextEdit* friendCertEdit;
QPushButton* friendCertCleanButton;
QVBoxLayout* friendCertButtonsLayout;
QHBoxLayout* friendCertLayout;
QVBoxLayout* textPageLayout; QVBoxLayout* textPageLayout;
@ -99,13 +102,13 @@ private:
private slots: private slots:
void showHelpUserCert(); void showHelpUserCert();
void copyCert(); void copyCert();
void cleanFriendCert();
bool fileSave(); bool fileSave();
bool fileSaveAs(); bool fileSaveAs();
//! launches default email client (on windows) //! launches default email client (on windows)
//! Tested on Vista, it work normally... But a bit slowly. //! Tested on Vista, it work normally... But a bit slowly.
void runEmailClient(); void runEmailClient();
}; };