Changed some parameters from "std::string" to "const std::string&" in rsinit.h.

Log the error messages from gpgme (ProcessPGPmeError) to stderr.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@4560 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2011-08-12 20:02:00 +00:00
parent 70d02c718d
commit 43c0594d18
5 changed files with 94 additions and 137 deletions

View File

@ -904,8 +904,9 @@ bool AuthGPGimpl::DoOwnSignature(const void *data, unsigned int datalen, void *b
gpg_error_t ERR;
if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_sign(CTX,gpgmeData, gpgmeSig, mode)))
{
ProcessPGPmeError(ERR);
std::cerr << "AuthGPGimpl::Sign FAILED ERR: " << ERR << std::endl;
std::cerr << ProcessPGPmeError(ERR) << std::endl;
gpgme_data_release(gpgmeSig);
gpgme_data_release(gpgmeData);
gpgme_signers_clear(CTX);
@ -999,8 +1000,8 @@ bool AuthGPGimpl::VerifySignature(const void *data, int datalen, const void *sig
gpgme_error_t ERR;
if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_verify(CTX,gpgmeSig, gpgmeData, NULL)))
{
ProcessPGPmeError(ERR);
std::cerr << "AuthGPGimpl::Verify FAILED" << std::endl;
std::cerr << ProcessPGPmeError(ERR) << std::endl;
}
gpgme_verify_result_t res = gpgme_op_verify_result(CTX);
@ -1084,8 +1085,8 @@ bool AuthGPGimpl::GeneratePGPCertificate(std::string name, std::string email,
if(GPG_ERR_NO_ERROR != (ERR = gpgme_op_genkey(CTX, setKeyPairParams(true, 2048, name, "generated by Retroshare", email, \
passwd).c_str(), NULL, NULL))) {
ProcessPGPmeError(ERR);
std::cerr << "Error generating the key" << std::endl;
std::cerr << ProcessPGPmeError(ERR) << std::endl;
return 0;
}
@ -1202,7 +1203,8 @@ bool AuthGPGimpl::getGPGDetails(const std::string &id, RsPeerDetails &d)
return false;
}
bool AuthGPGimpl::decryptText(gpgme_data_t CIPHER, gpgme_data_t PLAIN) {
bool AuthGPGimpl::decryptText(gpgme_data_t CIPHER, gpgme_data_t PLAIN)
{
RsStackMutex stack(gpgMtxEngine); /******* LOCKED ******/
gpgme_set_armor (CTX, 1);
gpg_error_t ERR;
@ -1211,15 +1213,16 @@ bool AuthGPGimpl::decryptText(gpgme_data_t CIPHER, gpgme_data_t PLAIN) {
if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_decrypt (CTX, CIPHER, PLAIN)))
{
ProcessPGPmeError(ERR);
std::cerr << "AuthGPGimpl::decryptText() Error decrypting text." << std::endl;
std::cerr << "AuthGPGimpl::decryptText() Error decrypting text" << std::endl;
std::cerr << ProcessPGPmeError(ERR) << std::endl;
return false;
}
return true;
}
bool AuthGPGimpl::encryptText(gpgme_data_t PLAIN, gpgme_data_t CIPHER) {
bool AuthGPGimpl::encryptText(gpgme_data_t PLAIN, gpgme_data_t CIPHER)
{
RsStackMutex stack(gpgMtxEngine); /******* LOCKED ******/
gpgme_encrypt_flags_t* flags = new gpgme_encrypt_flags_t();
gpgme_key_t keys[2] = {mOwnGpgCert.key, NULL};
@ -1228,11 +1231,10 @@ bool AuthGPGimpl::encryptText(gpgme_data_t PLAIN, gpgme_data_t CIPHER) {
cleanupZombies(2); // cleanup zombies under OSX. (Called before gpgme operation)
if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_encrypt(CTX, keys, *flags, PLAIN, CIPHER)))
{
ProcessPGPmeError(ERR);
std::cerr << "AuthGPGimpl::encryptText() Error encrypting text." << std::endl;
std::cerr << "AuthGPGimpl::encryptText() Error encrypting text" << std::endl;
std::cerr << ProcessPGPmeError(ERR) << std::endl;
return false;
}
@ -1420,7 +1422,7 @@ bool AuthGPGimpl::LoadCertificateFromString(const std::string &str, std::string
if (GPG_ERR_NO_ERROR != (ERR = gpgme_data_new_from_mem(&gpgmeData, cleancert.c_str(), cleancert.length(), 1)))
{
error_string = ProcessPGPmeError(ERR) ;
std::cerr << "Error create Data" << std::endl;
std::cerr << "Error create Data: " << error_string << std::endl;
return false;
}
@ -1869,7 +1871,7 @@ static gpg_error_t keySignCallback(void *opaque, gpgme_status_code_t status, \
fprintf(stderr,"keySignCallback Error status\n");
ProcessPGPmeError(params->err);
std::cerr << ProcessPGPmeError(params->err) << std::endl;
return params->err;
}
@ -2107,7 +2109,7 @@ static gpg_error_t keySignCallback(void *opaque, gpgme_status_code_t status, \
}
fprintf(stderr,"keySignCallback Error status\n");
ProcessPGPmeError(params->err);
std::cerr << ProcessPGPmeError(params->err) << std::endl;
return params->err;
}

View File

@ -74,9 +74,7 @@ class RsInit
static bool getPreferedAccountId(std::string &id);
static bool getPGPEngineFileName(std::string &fileName);
static bool getAccountIds(std::list<std::string> &ids);
static bool getAccountDetails(std::string id,
std::string &gpgId, std::string &gpgName,
std::string &gpgEmail, std::string &sslName);
static bool getAccountDetails(std::string id, std::string &gpgId, std::string &gpgName, std::string &gpgEmail, std::string &sslName);
static bool ValidateCertificate(std::string &userName) ;
@ -85,24 +83,24 @@ class RsInit
* Generating GPGme Account
*/
static int GetPGPLogins(std::list<std::string> &pgpIds);
static int GetPGPLoginDetails(std::string id, std::string &name, std::string &email);
static bool GeneratePGPCertificate(std::string name, std::string email, std::string passwd, std::string &pgpId, std::string &errString);
static int GetPGPLoginDetails(const std::string& id, std::string &name, std::string &email);
static bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, std::string &pgpId, std::string &errString);
/*!
* Login GGP
*/
static bool SelectGPGAccount(const std::string& gpgId);
static bool LoadGPGPassword(std::string passwd);
static bool LoadGPGPassword(const std::string& passwd);
/*!
* Create SSL Certificates
*/
static bool GenerateSSLCertificate(std::string name, std::string org, std::string loc, std::string country, std::string passwd, std::string &sslId, std::string &errString);
static bool GenerateSSLCertificate(const std::string& name, const std::string& org, const std::string& loc, const std::string& country, const std::string& passwd, std::string &sslId, std::string &errString);
/*!
* intialises directories for passwords and ssl keys
*/
static bool LoadPassword(std::string id, std::string passwd) ;
static bool LoadPassword(const std::string& id, const std::string& passwd) ;
/*!
* Final Certificate load. This can be called if:
@ -114,7 +112,6 @@ class RsInit
*/
static int LockAndLoadCertificates(bool autoLoginNT, std::string& lockFilePath);
/*!
* Post Login Options
*/
@ -140,10 +137,10 @@ class RsInit
static void setupBaseDir();
/* Account Details */
static bool get_configinit(std::string dir, std::string &id);
static bool create_configinit(std::string dir, std::string id);
static bool get_configinit(const std::string& dir, std::string &id);
static bool create_configinit(const std::string& dir, const std::string& id);
static bool setupAccount(std::string accountdir);
static bool setupAccount(const std::string& accountdir);
/* Auto Login */
static bool RsStoreAutoLogin() ;
@ -158,6 +155,4 @@ class RsInit
};
#endif

View File

@ -1047,7 +1047,7 @@ int RsInit::GetPGPLogins(std::list<std::string> &pgpIds) {
return 1;
}
int RsInit::GetPGPLoginDetails(std::string id, std::string &name, std::string &email)
int RsInit::GetPGPLoginDetails(const std::string& id, std::string &name, std::string &email)
{
#ifdef GPG_DEBUG
std::cerr << "RsInit::GetPGPLoginDetails for \"" << id << "\"" << std::endl;
@ -1191,13 +1191,14 @@ bool RsInit::SelectGPGAccount(const std::string& gpgId)
}
bool RsInit::GeneratePGPCertificate(std::string name, std::string email, std::string passwd, std::string &pgpId, std::string &errString) {
bool RsInit::GeneratePGPCertificate(const std::string& name, const std::string& email, const std::string& passwd, std::string &pgpId, std::string &errString)
{
return AuthGPG::getAuthGPG()->GeneratePGPCertificate(name, email, passwd, pgpId, errString);
}
/* Create SSL Certificates */
bool RsInit::GenerateSSLCertificate(std::string gpg_id, std::string org, std::string loc, std::string country, std::string passwd, std::string &sslId, std::string &errString)
bool RsInit::GenerateSSLCertificate(const std::string& gpg_id, const std::string& org, const std::string& loc, const std::string& country, const std::string& passwd, std::string &sslId, std::string &errString)
{
// generate the private_key / certificate.
// save to file.
@ -1347,7 +1348,7 @@ bool RsInit::GenerateSSLCertificate(std::string gpg_id, std::string org, std
/******************* PRIVATE FNS TO HELP with GEN **************/
bool RsInit::setupAccount(std::string accountdir)
bool RsInit::setupAccount(const std::string& accountdir)
{
/* actual config directory isd */
@ -1407,7 +1408,7 @@ bool RsInit::setupAccount(std::string accountdir)
/***************************** FINAL LOADING OF SETUP *************************/
/* Login SSL */
bool RsInit::LoadPassword(std::string id, std::string inPwd)
bool RsInit::LoadPassword(const std::string& id, const std::string& inPwd)
{
/* select configDir */
@ -1466,7 +1467,6 @@ int RsInit::LockAndLoadCertificates(bool autoLoginNT, std::string& lockFilePath
*/
int RsInit::LoadCertificates(bool autoLoginNT)
{
if (RsInitConfig::load_cert == "")
{
std::cerr << "RetroShare needs a certificate" << std::endl;
@ -1516,11 +1516,13 @@ int RsInit::LoadCertificates(bool autoLoginNT)
return 1;
}
bool RsInit::RsClearAutoLogin()
{
return RsLoginHandler::clearAutoLogin(RsInitConfig::preferedId);
}
bool RsInit::get_configinit(std::string dir, std::string &id)
bool RsInit::get_configinit(const std::string& dir, std::string &id)
{
// have a config directories.
@ -1551,8 +1553,7 @@ bool RsInit::get_configinit(std::string dir, std::string &id)
return false;
}
bool RsInit::create_configinit(std::string dir, std::string id)
bool RsInit::create_configinit(const std::string& dir, const std::string& id)
{
// Check for config file.
std::string initfile = dir + "/";

View File

@ -96,29 +96,6 @@ GenCertDialog::GenCertDialog(QWidget *parent, Qt::WFlags flags)
newGPGKeyGenUiSetup();
}
/** Destructor. */
//GenCertDialog::~GenCertDialog()
//{
//}
/**
Overloads the default show() slot so we can set opacity*/
void GenCertDialog::show()
{
//loadSettings();
if(!this->isVisible()) {
QWidget::show();
}
}
void GenCertDialog::closeinfodlg()
{
close();
}
void GenCertDialog::newGPGKeyGenUiSetup() {
QString titleStr("<span style=\"font-size:17pt; font-weight:500;"
@ -152,9 +129,9 @@ void GenCertDialog::newGPGKeyGenUiSetup() {
ui.label_3->setText( titleStr.arg( tr("Create a new Location") ) ) ;
}
}
void GenCertDialog::genPerson()
{
/* Check the data from the GUI. */
std::string genLoc = ui.location_input->text().toUtf8().constData();
std::string PGPId;
@ -257,20 +234,15 @@ void GenCertDialog::genPerson()
else
{
/* Message Dialog */
QMessageBox::warning ( NULL,
QMessageBox::warning( NULL,
"Generate ID Failure",
"Failed to Generate your new Certificate, maybe PGP password is wrong !",
QMessageBox::Ok);
}
}
void GenCertDialog::selectFriend()
{
#if 0
/* still need to find home (first) */
@ -288,13 +260,10 @@ void GenCertDialog::selectFriend()
ui.genFriend -> setText("<Invalid Selected>");
}
#endif
}
void GenCertDialog::checkChanged(int /*i*/)
{
#if 0
if (i)
{
@ -309,10 +278,8 @@ void GenCertDialog::checkChanged(int /*i*/)
ui.genFriend -> setText("<None Selected>");
}
#endif
}
void GenCertDialog::loadCertificates()
{
std::string lockFile;

View File

@ -38,15 +38,7 @@ public:
GenCertDialog(QWidget *parent = 0, Qt::WFlags flags = 0);
/** Default destructor */
//~GenCertDialog();
public slots:
/** Overloaded QWidget.show */
void show();
private slots:
void closeinfodlg();
void genPerson();
//void loadPerson();
void selectFriend();