Added new return codes to RsInit::InitRetroShare to know, what failed.

Show error box when gpg initialization failed.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3744 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2010-11-03 22:54:34 +00:00
parent 89f448d282
commit 0e41211f3c
6 changed files with 208 additions and 112 deletions

View file

@ -135,6 +135,8 @@ AuthGPGimpl::AuthGPGimpl()
{
RsStackMutex stack(gpgMtxEngine); /******* LOCKED ******/
CTX = NULL;
setlocale(LC_ALL, "");
gpgme_check_version(NULL);
gpgme_set_locale(NULL, LC_CTYPE, setlocale (LC_CTYPE, NULL));
@ -197,6 +199,11 @@ bool AuthGPGimpl::InitAuth ()
{
std::string HomeDir;
if (!CTX) {
std::cerr << "Error with gpg initialization. Is gpg missing ?" << std::endl;
return false;
}
#ifdef WINDOWS_SYS
if (RsInit::isPortable ()) {
// set home dir of gpg to configdir\gnupg

View file

@ -26,7 +26,11 @@
*
*/
// Initialize ok, result >= 0
#define RS_INIT_OK 0 // Initialize ok
#define RS_INIT_HAVE_ACCOUNT 1 // Initialize ok, have account
// Initialize failed, result < 0
#define RS_INIT_AUTH_FAILED -1 // AuthGPG::InitAuth failed
/****
@ -55,10 +59,9 @@ class RsInit
* @param argc passed from executable
* @param argv commandline arguments passed to executable
* @param strictCheck set to true if you want rs to continue executing if invalid argument passed and vice versa
* @return one is initialisation has been successful
* @return RS_INIT_...
*/
static int InitRetroShare(int argc, char **argv,
bool strictCheck=true);
static int InitRetroShare(int argc, char **argv, bool strictCheck=true);
/*!
* This return directory seperator for different platforms, not an issue anymore as C library can distinguish
@ -107,7 +110,7 @@ class RsInit
/*!
* Final Certificate load. This can be called if:
* a) InitRetroshare() returns true -> autoLoad/password Set.
* a) InitRetroshare() returns RS_INIT_HAVE_ACCOUNT -> autoLoad/password Set.
* b) SelectGPGAccount() && LoadPassword()
*
* This wrapper is used to lock the profile first before

View file

@ -585,8 +585,11 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck
setupBaseDir();
get_configinit(RsInitConfig::basedir, RsInitConfig::preferedId);
/* Initialize AuthGPG */
AuthGPG::getAuthGPG()->InitAuth();
/* Initialize AuthGPG */
if (AuthGPG::getAuthGPG()->InitAuth() == false) {
std::cerr << "AuthGPG::InitAuth failed" << std::endl;
return RS_INIT_AUTH_FAILED;
}
//std::list<accountId> ids;
std::list<accountId>::iterator it;
@ -648,7 +651,7 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck
if (RsInitConfig::havePasswd)
{
return 1;
return RS_INIT_HAVE_ACCOUNT;
}
RsInit::LoadPassword(RsInitConfig::preferedId, "");
@ -656,10 +659,10 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck
if (RsTryAutoLogin())
{
RsInit::setAutoLogin(true);
return 1;
return RS_INIT_HAVE_ACCOUNT;
}
}
return 0;
return RS_INIT_OK;
}
/**************************** Access Functions for Init Data **************************/