2009-07-30 17:27:47 -04:00
|
|
|
#ifndef RETROSHARE_INIT_INTERFACE_H
|
|
|
|
#define RETROSHARE_INIT_INTERFACE_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* "$Id: rsiface.h,v 1.9 2007-04-21 19:08:51 rmf24 Exp $"
|
|
|
|
*
|
|
|
|
* RetroShare C++ Interface.
|
|
|
|
*
|
|
|
|
* Copyright 2004-2006 by Robert Fernie.
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License Version 2 as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA.
|
|
|
|
*
|
|
|
|
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-11-03 18:54:34 -04:00
|
|
|
// 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
|
2011-12-06 18:00:42 -05:00
|
|
|
#define RS_INIT_BASE_DIR_ERROR -2 // AuthGPG::InitAuth failed
|
2012-06-09 17:01:22 -04:00
|
|
|
#define RS_INIT_NO_KEYRING -3 // Keyring is empty. Need to import it.
|
2010-07-26 18:09:33 -04:00
|
|
|
|
2009-02-08 09:30:28 -05:00
|
|
|
|
2009-05-23 11:07:35 -04:00
|
|
|
/****
|
|
|
|
* #define RS_USE_PGPSSL 1
|
|
|
|
***/
|
|
|
|
|
2009-07-30 17:27:47 -04:00
|
|
|
#define RS_USE_PGPSSL 1
|
|
|
|
|
2013-09-23 16:55:34 -04:00
|
|
|
#include <stdint.h>
|
2011-02-01 18:27:53 -05:00
|
|
|
#include <list>
|
2012-07-20 15:00:10 -04:00
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
2014-03-17 16:56:06 -04:00
|
|
|
#include <retroshare/rstypes.h>
|
2011-02-01 18:27:53 -05:00
|
|
|
|
2010-07-26 18:09:33 -04:00
|
|
|
/*!
|
|
|
|
* Initialisation Class (not publicly disclosed to RsIFace)
|
|
|
|
*/
|
2009-02-08 09:30:28 -05:00
|
|
|
class RsInit
|
|
|
|
{
|
|
|
|
public:
|
2009-07-30 17:27:47 -04:00
|
|
|
/* reorganised RsInit system */
|
2009-02-08 09:30:28 -05:00
|
|
|
|
2010-07-26 18:09:33 -04:00
|
|
|
/*!
|
|
|
|
* PreLogin
|
|
|
|
* Call before init retroshare, initialises rsinitconfig's public attributes
|
|
|
|
*/
|
2009-07-30 17:27:47 -04:00
|
|
|
static void InitRsConfig() ;
|
2010-07-26 18:09:33 -04:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* Should be called to load up ssl cert and private key, and intialises gpg
|
|
|
|
* this must be called before accessing rsserver (e.g. ::startupretroshare)
|
|
|
|
* @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
|
2010-11-03 18:54:34 -04:00
|
|
|
* @return RS_INIT_...
|
2010-07-26 18:09:33 -04:00
|
|
|
*/
|
2010-11-03 18:54:34 -04:00
|
|
|
static int InitRetroShare(int argc, char **argv, bool strictCheck=true);
|
2010-05-08 17:44:08 -04:00
|
|
|
|
2010-04-30 10:34:48 -04:00
|
|
|
static bool isPortable();
|
2010-10-07 07:17:42 -04:00
|
|
|
static bool isWindowsXP();
|
2013-09-23 16:55:34 -04:00
|
|
|
static bool collectEntropy(uint32_t bytes) ;
|
2012-06-09 17:01:22 -04:00
|
|
|
|
2010-07-26 18:09:33 -04:00
|
|
|
/*!
|
2013-09-08 22:10:49 -04:00
|
|
|
* Setup Hidden Location;
|
2010-07-26 18:09:33 -04:00
|
|
|
*/
|
2013-09-08 22:10:49 -04:00
|
|
|
static bool SetHiddenLocation(const std::string& hiddenaddress, uint16_t port);
|
2009-05-23 11:07:35 -04:00
|
|
|
|
2014-01-17 21:32:55 -05:00
|
|
|
static bool LoadPassword(const std::string& passwd) ;
|
2009-07-30 17:27:47 -04:00
|
|
|
|
2010-07-26 18:09:33 -04:00
|
|
|
/*!
|
2009-05-23 11:07:35 -04:00
|
|
|
|
2014-02-01 09:16:15 -05:00
|
|
|
|
2010-07-26 18:09:33 -04:00
|
|
|
* Final Certificate load. This can be called if:
|
2010-11-03 18:54:34 -04:00
|
|
|
* a) InitRetroshare() returns RS_INIT_HAVE_ACCOUNT -> autoLoad/password Set.
|
2014-01-17 21:32:55 -05:00
|
|
|
* b) or LoadPassword()
|
2010-07-01 16:30:36 -04:00
|
|
|
*
|
2014-01-17 21:32:55 -05:00
|
|
|
* This uses the preferredId from RsAccounts.
|
|
|
|
* This wrapper also locks the profile before finalising the login
|
2009-02-08 09:30:28 -05:00
|
|
|
*/
|
2011-08-12 16:02:00 -04:00
|
|
|
static int LockAndLoadCertificates(bool autoLoginNT, std::string& lockFilePath);
|
2009-07-30 17:27:47 -04:00
|
|
|
|
2010-07-26 18:09:33 -04:00
|
|
|
/*!
|
|
|
|
* Post Login Options
|
|
|
|
*/
|
|
|
|
|
2016-03-01 07:08:33 -05:00
|
|
|
static bool getStartMinimised();
|
2009-07-30 17:27:47 -04:00
|
|
|
|
2010-04-08 08:02:46 -04:00
|
|
|
static int getSslPwdLen();
|
|
|
|
static bool getAutoLogin();
|
|
|
|
static void setAutoLogin(bool autoLogin);
|
|
|
|
static bool RsClearAutoLogin() ;
|
|
|
|
|
2009-07-30 17:27:47 -04:00
|
|
|
private:
|
2010-07-26 18:09:33 -04:00
|
|
|
|
2014-01-17 21:32:55 -05:00
|
|
|
#if 0
|
2009-07-30 17:27:47 -04:00
|
|
|
/* Auto Login */
|
|
|
|
static bool RsStoreAutoLogin() ;
|
|
|
|
static bool RsTryAutoLogin() ;
|
2014-01-17 21:32:55 -05:00
|
|
|
#endif
|
2010-04-08 08:02:46 -04:00
|
|
|
|
2014-01-17 21:32:55 -05:00
|
|
|
// THESE CAN BE REMOVED FROM THE CLASS TOO.
|
2010-07-01 16:30:36 -04:00
|
|
|
/* Lock/unlock profile directory */
|
2011-03-16 19:25:57 -04:00
|
|
|
static int LockConfigDirectory(const std::string& accountDir, std::string& lockFilePath);
|
2010-07-01 16:30:36 -04:00
|
|
|
static void UnlockConfigDirectory();
|
|
|
|
|
|
|
|
/* The true LoadCertificates() method */
|
|
|
|
static int LoadCertificates(bool autoLoginNT) ;
|
2009-07-30 17:27:47 -04:00
|
|
|
|
2009-02-08 09:30:28 -05:00
|
|
|
};
|
|
|
|
|
2014-01-17 21:32:55 -05:00
|
|
|
|
|
|
|
|
|
|
|
/* Seperate Class for dealing with Accounts */
|
|
|
|
|
|
|
|
namespace RsAccounts
|
|
|
|
{
|
2015-07-30 08:00:48 -04:00
|
|
|
/**
|
2016-08-22 21:19:33 -04:00
|
|
|
* @brief ConfigDirectory (normally ~/.retroshare) you can call this method
|
|
|
|
* even before initialisation (you can't with some other methods)
|
|
|
|
* @see RsAccountsDetail::PathBaseDirectory()
|
|
|
|
*/
|
|
|
|
std::string ConfigDirectory();
|
|
|
|
|
|
|
|
/**
|
2015-07-30 08:00:48 -04:00
|
|
|
* @brief DataDirectory
|
2016-08-22 21:19:33 -04:00
|
|
|
* you can call this method even before initialisation (you can't with some other methods)
|
2015-07-30 08:00:48 -04:00
|
|
|
* @param check if set to true and directory does not exist, return empty string
|
|
|
|
* @return path where global platform independent files are stored, like bdboot.txt or webinterface files
|
|
|
|
*/
|
|
|
|
std::string DataDirectory(bool check = true);
|
2016-08-22 21:19:33 -04:00
|
|
|
|
2014-01-17 21:32:55 -05:00
|
|
|
std::string PGPDirectory();
|
|
|
|
std::string AccountDirectory();
|
|
|
|
|
|
|
|
// PGP Accounts.
|
2014-03-17 16:56:06 -04:00
|
|
|
int GetPGPLogins(std::list<RsPgpId> &pgpIds);
|
|
|
|
int GetPGPLoginDetails(const RsPgpId& id, std::string &name, std::string &email);
|
2015-01-12 17:02:43 -05:00
|
|
|
bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, RsPgpId &pgpId, const int keynumbits, std::string &errString);
|
2014-01-17 21:32:55 -05:00
|
|
|
|
|
|
|
// PGP Support Functions.
|
2014-03-17 16:56:06 -04:00
|
|
|
bool ExportIdentity(const std::string& fname,const RsPgpId& pgp_id) ;
|
|
|
|
bool ImportIdentity(const std::string& fname,RsPgpId& imported_pgp_id,std::string& import_error) ;
|
2015-06-16 08:35:07 -04:00
|
|
|
bool ImportIdentityFromString(const std::string& data,RsPgpId& imported_pgp_id,std::string& import_error) ;
|
2014-01-17 21:32:55 -05:00
|
|
|
void GetUnsupportedKeys(std::map<std::string,std::vector<std::string> > &unsupported_keys);
|
|
|
|
bool CopyGnuPGKeyrings() ;
|
|
|
|
|
|
|
|
// Rs Accounts
|
2014-03-17 16:56:06 -04:00
|
|
|
bool SelectAccount(const RsPeerId& id);
|
2014-01-17 21:32:55 -05:00
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
bool GetPreferredAccountId(RsPeerId &id);
|
|
|
|
bool GetAccountIds(std::list<RsPeerId> &ids);
|
|
|
|
bool GetAccountDetails(const RsPeerId &id,
|
|
|
|
RsPgpId &gpgId, std::string &gpgName,
|
2014-01-17 21:32:55 -05:00
|
|
|
std::string &gpgEmail, std::string &location);
|
|
|
|
|
2014-03-17 16:56:06 -04:00
|
|
|
bool GenerateSSLCertificate(const RsPgpId& pgp_id, const std::string& org, const std::string& loc, const std::string& country, const bool ishiddenloc, const std::string& passwd, RsPeerId &sslId, std::string &errString);
|
2014-01-17 21:32:55 -05:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-07-30 17:27:47 -04:00
|
|
|
#endif
|