mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-20 21:34:31 -05:00
first code for the gui : network dialog, start dialog and certificate first generation
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2009 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
45b2287d41
commit
77b3c0afd0
@ -198,7 +198,7 @@ AuthGPG::AuthGPG()
|
||||
*/
|
||||
bool AuthGPG::availablePGPCertificates(std::list<std::string> &ids)
|
||||
{
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
|
||||
int i = 0;
|
||||
gpgme_key_t KEY = NULL;
|
||||
@ -609,7 +609,7 @@ bool AuthGPG::printOwnKeys_locked()
|
||||
|
||||
bool AuthGPG::printKeys()
|
||||
{
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
printAllKeys_locked();
|
||||
return printOwnKeys_locked();
|
||||
}
|
||||
@ -827,7 +827,7 @@ bool AuthGPG::VerifySignature_locked(const void *data, int datalen, const void *
|
||||
|
||||
bool AuthGPG::active()
|
||||
{
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
|
||||
return ((gpgmeInit) && (gpgmeKeySelected) && (gpgmeX509Selected));
|
||||
}
|
||||
@ -855,7 +855,7 @@ int AuthGPG::setConfigDirectories(std::string confFile, std::string neighDir
|
||||
/**** These Two are common */
|
||||
std::string AuthGPG::getPGPName(GPG_id id)
|
||||
{
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
|
||||
certmap::iterator it;
|
||||
if (mKeyList.end() != (it = mKeyList.find(id)))
|
||||
@ -867,7 +867,7 @@ std::string AuthGPG::getPGPName(GPG_id id)
|
||||
/**** These Two are common */
|
||||
std::string AuthGPG::getPGPEmail(GPG_id id)
|
||||
{
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
|
||||
certmap::iterator it;
|
||||
if (mKeyList.end() != (it = mKeyList.find(id)))
|
||||
@ -880,14 +880,14 @@ std::string AuthGPG::getPGPEmail(GPG_id id)
|
||||
|
||||
std::string AuthGPG::PGPOwnId()
|
||||
{
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
|
||||
return mOwnGpgId;
|
||||
}
|
||||
|
||||
bool AuthGPG::getPGPAllList(std::list<std::string> &ids)
|
||||
{
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
|
||||
/* add an id for each pgp certificate */
|
||||
certmap::iterator it;
|
||||
@ -898,8 +898,29 @@ bool AuthGPG::getPGPAllList(std::list<std::string> &ids)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AuthGPG::getPGPDetails(std::string id, RsPeerDetails &d)
|
||||
{
|
||||
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
|
||||
/* add an id for each pgp certificate */
|
||||
certmap::iterator it;
|
||||
if (mKeyList.end() != (it = mKeyList.find(id)))
|
||||
{
|
||||
d.id = it->second.id;
|
||||
d.name = it->second.name;
|
||||
d.email = it->second.email;
|
||||
d.trustLvl = it->second.trustLvl;
|
||||
d.validLvl = it->second.validLvl;
|
||||
d.ownsign = it->second.ownsign;
|
||||
d.signers = it->second.signers;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool AuthGPG::decryptText(gpgme_data_t CIPHER, gpgme_data_t PLAIN) {
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
gpgme_set_armor (CTX, 1);
|
||||
gpg_error_t ERR;
|
||||
if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_decrypt (CTX, CIPHER, PLAIN)))
|
||||
@ -914,7 +935,7 @@ bool AuthGPG::decryptText(gpgme_data_t CIPHER, gpgme_data_t PLAIN) {
|
||||
}
|
||||
|
||||
bool AuthGPG::encryptText(gpgme_data_t PLAIN, gpgme_data_t CIPHER) {
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
|
||||
gpgme_encrypt_flags_t* flags = new gpgme_encrypt_flags_t();
|
||||
gpgme_key_t keys[2] = {mOwnGpgCert.key, NULL};
|
||||
@ -933,7 +954,7 @@ bool AuthGPG::encryptText(gpgme_data_t PLAIN, gpgme_data_t CIPHER) {
|
||||
|
||||
bool AuthGPG::getPGPSignedList(std::list<std::string> &ids)
|
||||
{
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
|
||||
certmap::iterator it;
|
||||
for(it = mKeyList.begin(); it != mKeyList.end(); it++)
|
||||
@ -948,7 +969,7 @@ bool AuthGPG::getPGPSignedList(std::list<std::string> &ids)
|
||||
|
||||
bool AuthGPG::isPGPValid(GPG_id id)
|
||||
{
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
|
||||
certmap::iterator it;
|
||||
if (mKeyList.end() != (it = mKeyList.find(id))) {
|
||||
@ -962,7 +983,7 @@ bool AuthGPG::isPGPValid(GPG_id id)
|
||||
|
||||
bool AuthGPG::isPGPSigned(GPG_id id)
|
||||
{
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
//RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
|
||||
certmap::iterator it;
|
||||
if (mKeyList.end() != (it = mKeyList.find(id)))
|
||||
@ -1135,8 +1156,7 @@ bool AuthGPG::SignCertificateLevel0(GPG_id id)
|
||||
}
|
||||
|
||||
/* reload stuff now ... */
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
|
||||
RsStackMutex stack(pgpMtx); /******* LOCKED ******/
|
||||
storeAllKeys_locked();
|
||||
|
||||
return true;
|
||||
@ -1433,7 +1453,7 @@ static gpg_error_t keySignCallback(void *opaque, gpgme_status_code_t status, \
|
||||
class SignParams *sparams = (class SignParams *)params->oParams;
|
||||
const char *result = NULL;
|
||||
|
||||
fprintf(stderr,"keySignCallback status: %d args: %s, params->state: %d\n", status, args, params->state);
|
||||
fprintf(stderr,"keySignCallback status: %d args: %s, params->state: %d\n", status, args, params->state);
|
||||
|
||||
/* printf stuff out */
|
||||
if (status == GPGME_STATUS_EOF)
|
||||
@ -1448,7 +1468,6 @@ static gpg_error_t keySignCallback(void *opaque, gpgme_status_code_t status, \
|
||||
fprintf(stderr,"keySignCallback GPGME_STATUS_GOOD_PASSPHRASE\n");
|
||||
if (status == GPGME_STATUS_BAD_PASSPHRASE)
|
||||
fprintf(stderr,"keySignCallback GPGME_STATUS_BAD_PASSPHRASE\n");
|
||||
|
||||
if (status == GPGME_STATUS_GET_LINE)
|
||||
fprintf(stderr,"keySignCallback GPGME_STATUS_GET_LINE\n");
|
||||
if (status == GPGME_STATUS_GET_BOOL)
|
||||
@ -1456,6 +1475,26 @@ static gpg_error_t keySignCallback(void *opaque, gpgme_status_code_t status, \
|
||||
if (status == GPGME_STATUS_ALREADY_SIGNED)
|
||||
fprintf(stderr,"keySignCallback GPGME_STATUS_ALREADY_SIGNED\n");
|
||||
|
||||
/* printf stuff out */
|
||||
if (params->state == SIGN_START)
|
||||
fprintf(stderr,"keySignCallback params->state SIGN_START\n");
|
||||
if (params->state == SIGN_COMMAND)
|
||||
fprintf(stderr,"keySignCallback params->state SIGN_COMMAND\n");
|
||||
if (params->state == SIGN_UIDS)
|
||||
fprintf(stderr,"keySignCallback params->state SIGN_UIDS\n");
|
||||
if (params->state == SIGN_SET_EXPIRE)
|
||||
fprintf(stderr,"keySignCallback params->state SIGN_SET_EXPIRE\n");
|
||||
if (params->state == SIGN_SET_CHECK_LEVEL)
|
||||
fprintf(stderr,"keySignCallback params->state SIGN_SET_CHECK_LEVEL\n");
|
||||
if (params->state == SIGN_CONFIRM)
|
||||
fprintf(stderr,"keySignCallback params->state SIGN_CONFIRM\n");
|
||||
if (params->state == SIGN_QUIT)
|
||||
fprintf(stderr,"keySignCallback params->state SIGN_QUIT\n");
|
||||
if (params->state == SIGN_ENTER_PASSPHRASE)
|
||||
fprintf(stderr,"keySignCallback params->state SIGN_ENTER_PASSPHRASE\n");
|
||||
if (params->state == SIGN_ERROR)
|
||||
fprintf(stderr,"keySignCallback params->state SIGN_ERROR");
|
||||
|
||||
|
||||
if(status == GPGME_STATUS_EOF ||
|
||||
status == GPGME_STATUS_GOT_IT ||
|
||||
@ -1598,27 +1637,19 @@ static gpg_error_t keySignCallback(void *opaque, gpgme_status_code_t status, \
|
||||
params->err = gpg_error (GPG_ERR_GENERAL);
|
||||
}
|
||||
break;
|
||||
// case SIGN_ENTER_PASSPHRASE:
|
||||
// fprintf(stderr,"keySignCallback SIGN_ENTER_PASSPHRASE\n");
|
||||
//
|
||||
// if(status == GPGME_STATUS_GET_HIDDEN &&
|
||||
// (!std::string("passphrase.enter").compare(args)))
|
||||
// {
|
||||
// params->state = SIGN_CONFIRM;
|
||||
// result = sparams->passphrase.c_str();
|
||||
// }
|
||||
// // If using pgp_pwd_callback, then never have to enter passphrase this way.
|
||||
// // must catch GOOD_PASSPHRASE to move on.
|
||||
// else if (status == GPGME_STATUS_GOOD_PASSPHRASE)
|
||||
// {
|
||||
// params->state = SIGN_CONFIRM;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// params->state = SIGN_ERROR;
|
||||
// params->err = gpg_error (GPG_ERR_GENERAL);
|
||||
// }
|
||||
// break;
|
||||
case SIGN_ENTER_PASSPHRASE:
|
||||
fprintf(stderr,"keySignCallback SIGN_ENTER_PASSPHRASE\n");
|
||||
|
||||
if (status == GPGME_STATUS_GOOD_PASSPHRASE)
|
||||
{
|
||||
params->state = SIGN_CONFIRM;
|
||||
}
|
||||
else
|
||||
{
|
||||
params->state = SIGN_ERROR;
|
||||
params->err = gpg_error (GPG_ERR_GENERAL);
|
||||
}
|
||||
break;
|
||||
case SIGN_CONFIRM:
|
||||
fprintf(stderr,"keySignCallback SIGN_CONFIRM\n");
|
||||
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/evp.h>
|
||||
#include "util/rsthreads.h"
|
||||
#include "rsiface/rspeers.h"
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <map>
|
||||
@ -150,6 +151,7 @@ class AuthGPG
|
||||
/* PGP web of trust management */
|
||||
GPG_id PGPOwnId();
|
||||
bool getPGPAllList(std::list<std::string> &ids);
|
||||
bool getPGPDetails(std::string id, RsPeerDetails &d);
|
||||
bool getPGPSignedList(std::list<std::string> &ids);
|
||||
bool getPGPValidList(std::list<std::string> &ids);
|
||||
bool isPGPValid(std::string id);
|
||||
|
@ -1769,7 +1769,7 @@ X509 *AuthSSL::SignX509Req(X509_REQ *req, long days)
|
||||
X509 *x509 = X509_new();
|
||||
if (x509 == NULL)
|
||||
{
|
||||
std::cerr << "GPGAuthMgr::SignX509Req() FAIL" << std::endl;
|
||||
std::cerr << "AuthSSL::SignX509Req() FAIL" << std::endl;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -1777,7 +1777,7 @@ X509 *AuthSSL::SignX509Req(X509_REQ *req, long days)
|
||||
unsigned long chtype = MBSTRING_ASC;
|
||||
X509_NAME *issuer_name = X509_NAME_new();
|
||||
X509_NAME_add_entry_by_txt(issuer_name, "CN", chtype,
|
||||
(unsigned char *) mOwnId.c_str(), -1, -1, 0);
|
||||
(unsigned char *) AuthGPG::getAuthGPG()->PGPOwnId().c_str(), -1, -1, 0);
|
||||
/****
|
||||
X509_NAME_add_entry_by_NID(issuer_name, 48, 0,
|
||||
(unsigned char *) "email@email.com", -1, -1, 0);
|
||||
@ -1787,24 +1787,24 @@ X509 *AuthSSL::SignX509Req(X509_REQ *req, long days)
|
||||
(unsigned char *) "loc", -1, -1, 0);
|
||||
****/
|
||||
|
||||
std::cerr << "GPGAuthMgr::SignX509Req() Issuer name: " << mOwnId << std::endl;
|
||||
std::cerr << "AuthSSL::SignX509Req() Issuer name: " << AuthGPG::getAuthGPG()->PGPOwnId() << std::endl;
|
||||
|
||||
BIGNUM *btmp = BN_new();
|
||||
if (!BN_pseudo_rand(btmp, SERIAL_RAND_BITS, 0, 0))
|
||||
{
|
||||
std::cerr << "GPGAuthMgr::SignX509Req() rand FAIL" << std::endl;
|
||||
std::cerr << "AuthSSL::SignX509Req() rand FAIL" << std::endl;
|
||||
return NULL;
|
||||
}
|
||||
if (!BN_to_ASN1_INTEGER(btmp, serial))
|
||||
{
|
||||
std::cerr << "GPGAuthMgr::SignX509Req() asn1 FAIL" << std::endl;
|
||||
std::cerr << "AuthSSL::SignX509Req() asn1 FAIL" << std::endl;
|
||||
return NULL;
|
||||
}
|
||||
BN_free(btmp);
|
||||
|
||||
if (!X509_set_serialNumber(x509, serial))
|
||||
{
|
||||
std::cerr << "GPGAuthMgr::SignX509Req() serial FAIL" << std::endl;
|
||||
std::cerr << "AuthSSL::SignX509Req() serial FAIL" << std::endl;
|
||||
return NULL;
|
||||
}
|
||||
ASN1_INTEGER_free(serial);
|
||||
@ -1815,7 +1815,7 @@ X509 *AuthSSL::SignX509Req(X509_REQ *req, long days)
|
||||
|
||||
if (!X509_set_issuer_name(x509, issuer_name))
|
||||
{
|
||||
std::cerr << "GPGAuthMgr::SignX509Req() issue FAIL" << std::endl;
|
||||
std::cerr << "AuthSSL::SignX509Req() issue FAIL" << std::endl;
|
||||
return NULL;
|
||||
}
|
||||
X509_NAME_free(issuer_name);
|
||||
@ -1823,26 +1823,26 @@ X509 *AuthSSL::SignX509Req(X509_REQ *req, long days)
|
||||
|
||||
if (!X509_gmtime_adj(X509_get_notBefore(x509),0))
|
||||
{
|
||||
std::cerr << "GPGAuthMgr::SignX509Req() notbefore FAIL" << std::endl;
|
||||
std::cerr << "AuthSSL::SignX509Req() notbefore FAIL" << std::endl;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!X509_gmtime_adj(X509_get_notAfter(x509), (long)60*60*24*days))
|
||||
{
|
||||
std::cerr << "GPGAuthMgr::SignX509Req() notafter FAIL" << std::endl;
|
||||
std::cerr << "AuthSSL::SignX509Req() notafter FAIL" << std::endl;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!X509_set_subject_name(x509, X509_REQ_get_subject_name(req)))
|
||||
{
|
||||
std::cerr << "GPGAuthMgr::SignX509Req() sub FAIL" << std::endl;
|
||||
std::cerr << "AuthSSL::SignX509Req() sub FAIL" << std::endl;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tmppkey = X509_REQ_get_pubkey(req);
|
||||
if (!tmppkey || !X509_set_pubkey(x509,tmppkey))
|
||||
{
|
||||
std::cerr << "GPGAuthMgr::SignX509Req() pub FAIL" << std::endl;
|
||||
std::cerr << "AuthSSL::SignX509Req() pub FAIL" << std::endl;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -1901,7 +1901,7 @@ X509 *AuthSSL::SignX509Req(X509_REQ *req, long days)
|
||||
{
|
||||
hashoutl=0;
|
||||
sigoutl=0;
|
||||
fprintf(stderr, "GPGAuthMgr::SignX509Req: ASN1err(ASN1_F_ASN1_SIGN,ERR_R_MALLOC_FAILURE)\n");
|
||||
fprintf(stderr, "AuthSSL::SignX509Req: ASN1err(ASN1_F_ASN1_SIGN,ERR_R_MALLOC_FAILURE)\n");
|
||||
goto err;
|
||||
}
|
||||
p=buf_in;
|
||||
@ -1916,7 +1916,7 @@ X509 *AuthSSL::SignX509Req(X509_REQ *req, long days)
|
||||
(unsigned int *)&hashoutl))
|
||||
{
|
||||
hashoutl=0;
|
||||
fprintf(stderr, "GPGAuthMgr::SignX509Req: ASN1err(ASN1_F_ASN1_SIGN,ERR_R_EVP_LIB)\n");
|
||||
fprintf(stderr, "AuthSSL::SignX509Req: ASN1err(ASN1_F_ASN1_SIGN,ERR_R_EVP_LIB)\n");
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,11 @@
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
/* The Main Interface Class - for information about your Peers */
|
||||
/* The Main Interface Class - for information about your Peers
|
||||
* A peer is another RS instance, means associated with an SSL certificate
|
||||
* A same GPG person can have multiple peer running with different SSL certs signed by the same GPG key
|
||||
* Thus a peer have SSL cert details, and also the parent GPG details
|
||||
*/
|
||||
class RsPeers;
|
||||
extern RsPeers *rsPeers;
|
||||
|
||||
@ -105,7 +109,7 @@ class RsPeerDetails
|
||||
/* basic stats */
|
||||
uint32_t lastConnect; /* how long ago */
|
||||
std::string autoconnect;
|
||||
uint32_t connectPeriod;
|
||||
uint32_t connectPeriod;
|
||||
};
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const RsPeerDetails &detail);
|
||||
@ -138,6 +142,7 @@ virtual bool getPeerDetails(std::string id, RsPeerDetails &d) = 0;
|
||||
virtual std::string getPGPOwnId() = 0;
|
||||
virtual bool getPGPFriendList(std::list<std::string> &ids) = 0;
|
||||
virtual bool getPGPAllList(std::list<std::string> &ids) = 0;
|
||||
virtual bool getPGPDetails(std::string id, RsPeerDetails &d) = 0;
|
||||
|
||||
/* Add/Remove Friends */
|
||||
virtual bool addFriend(std::string id) = 0;
|
||||
@ -167,8 +172,7 @@ virtual bool LoadCertificateFromString(std::string cert, std::string &id) = 0;
|
||||
virtual bool SaveCertificateToFile(std::string id, std::string fname) = 0;
|
||||
virtual std::string SaveCertificateToString(std::string id) = 0;
|
||||
|
||||
virtual bool AuthCertificate(std::string id, std::string code) = 0;
|
||||
virtual bool SignCertificate(std::string id) = 0;
|
||||
virtual bool SignGPGCertificate(std::string id) = 0;
|
||||
virtual bool TrustCertificate(std::string id, bool trust) = 0;
|
||||
|
||||
};
|
||||
|
@ -549,6 +549,18 @@ bool p3Peers::getPGPAllList(std::list<std::string> &ids)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3Peers::getPGPDetails(std::string id, RsPeerDetails &d)
|
||||
{
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::getPgpDetails()";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
/* get from mAuthMgr */
|
||||
AuthGPG::getAuthGPG()->getPGPDetails(id, d);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string p3Peers::getPGPOwnId()
|
||||
{
|
||||
#ifdef P3PEERS_DEBUG
|
||||
@ -874,34 +886,14 @@ std::string p3Peers::SaveCertificateToString(std::string id)
|
||||
return AuthSSL::getAuthSSL()->SaveCertificateToString(id);
|
||||
}
|
||||
|
||||
bool p3Peers::AuthCertificate(std::string id, std::string code)
|
||||
{
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::AuthCertificate() " << id;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
if (AuthSSL::getAuthSSL()->AuthCertificate(id))
|
||||
{
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::AuthCertificate() OK ... Adding as Friend";
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
/* add in as a friend */
|
||||
return mConnMgr->addFriend(id);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool p3Peers::SignCertificate(std::string id)
|
||||
bool p3Peers::SignGPGCertificate(std::string id)
|
||||
{
|
||||
#ifdef P3PEERS_DEBUG
|
||||
std::cerr << "p3Peers::SignCertificate() " << id;
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
return AuthSSL::getAuthSSL()->SignCertificate(id);
|
||||
return AuthGPG::getAuthGPG()->SignCertificateLevel0(id);
|
||||
}
|
||||
|
||||
bool p3Peers::TrustCertificate(std::string id, bool trust)
|
||||
|
@ -57,6 +57,7 @@ virtual bool getPeerDetails(std::string id, RsPeerDetails &d);
|
||||
virtual std::string getPGPOwnId();
|
||||
virtual bool getPGPFriendList(std::list<std::string> &ids);
|
||||
virtual bool getPGPAllList(std::list<std::string> &ids);
|
||||
virtual bool getPGPDetails(std::string id, RsPeerDetails &d);
|
||||
|
||||
|
||||
/* Add/Remove Friends */
|
||||
@ -87,8 +88,7 @@ virtual bool LoadCertificateFromString(std::string cert, std::string &id);
|
||||
virtual bool SaveCertificateToFile(std::string id, std::string fname);
|
||||
virtual std::string SaveCertificateToString(std::string id);
|
||||
|
||||
virtual bool AuthCertificate(std::string id, std::string code);
|
||||
virtual bool SignCertificate(std::string id);
|
||||
virtual bool SignGPGCertificate(std::string id);
|
||||
virtual bool TrustCertificate(std::string id, bool trust);
|
||||
|
||||
private:
|
||||
|
@ -50,30 +50,29 @@ GenCertDialog::GenCertDialog(QWidget *parent, Qt::WFlags flags)
|
||||
|
||||
//ui.genName->setFocus(Qt::OtherFocusReason);
|
||||
|
||||
//the pgp password is now a GT box.
|
||||
ui.genPGPpassword->hide();
|
||||
ui.label_3->hide();
|
||||
ui.genCountry->hide();
|
||||
ui.label_6->hide();
|
||||
ui.genOrg->hide();
|
||||
ui.label_8->hide();
|
||||
|
||||
#ifdef RS_USE_PGPSSL
|
||||
/* get all available pgp private certificates....
|
||||
* mark last one as default.
|
||||
*/
|
||||
std::cerr << "Finding PGPUsers" << std::endl;
|
||||
/* get all available pgp private certificates....
|
||||
* mark last one as default.
|
||||
*/
|
||||
std::cerr << "Finding PGPUsers" << std::endl;
|
||||
|
||||
std::list<std::string> pgpIds;
|
||||
std::list<std::string>::iterator it;
|
||||
if (RsInit::GetPGPLogins(pgpIds))
|
||||
{
|
||||
for(it = pgpIds.begin(); it != pgpIds.end(); it++)
|
||||
{
|
||||
const QVariant & userData = QVariant(QString::fromStdString(*it));
|
||||
std::string name, email;
|
||||
RsInit::GetPGPLoginDetails(*it, name, email);
|
||||
std::cerr << "Adding PGPUser: " << name << " id: " << *it << std::endl;
|
||||
ui.genPGPuser->addItem(QString::fromStdString(name), userData);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
std::list<std::string> pgpIds;
|
||||
std::list<std::string>::iterator it;
|
||||
if (RsInit::GetPGPLogins(pgpIds))
|
||||
{
|
||||
for(it = pgpIds.begin(); it != pgpIds.end(); it++)
|
||||
{
|
||||
const QVariant & userData = QVariant(QString::fromStdString(*it));
|
||||
std::string name, email;
|
||||
RsInit::GetPGPLoginDetails(*it, name, email);
|
||||
std::cerr << "Adding PGPUser: " << name << " id: " << *it << std::endl;
|
||||
ui.genPGPuser->addItem(QString::fromStdString(name), userData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -112,16 +111,11 @@ void GenCertDialog::genPerson()
|
||||
{
|
||||
|
||||
/* Check the data from the GUI. */
|
||||
std::string genName = ui.genName->text().toStdString();
|
||||
std::string genOrg = ui.genOrg->text().toStdString();
|
||||
std::string genLoc = ui.genLoc->text().toStdString();
|
||||
std::string genCountry = ui.genCountry->text().toStdString();
|
||||
std::string err;
|
||||
|
||||
|
||||
#ifdef RS_USE_PGPSSL
|
||||
|
||||
std::string PGPpasswd = ui.genPGPpassword->text().toStdString();
|
||||
int pgpidx = ui.genPGPuser->currentIndex();
|
||||
if (pgpidx < 0)
|
||||
{
|
||||
@ -136,23 +130,6 @@ void GenCertDialog::genPerson()
|
||||
QVariant data = ui.genPGPuser->itemData(pgpidx);
|
||||
std::string PGPId = (data.toString()).toStdString();
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
if (genName.length() >= 3)
|
||||
{
|
||||
/* name passes basic test */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Message Dialog */
|
||||
QMessageBox::StandardButton sb = QMessageBox::warning ( NULL,
|
||||
"Generate ID Failure",
|
||||
"Your Name is too short (3+ characters)",
|
||||
QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
|
||||
//generate a random ssl password
|
||||
std::cerr << " generating sslPasswd." << std::endl;
|
||||
qsrand(time(NULL));
|
||||
@ -169,7 +146,8 @@ void GenCertDialog::genPerson()
|
||||
//RsInit::LoadGPGPassword(PGPpasswd);
|
||||
|
||||
std::string sslId;
|
||||
bool okGen = RsInit::GenerateSSLCertificate(genName, genOrg, genLoc, genCountry, sslPasswd, sslId, err);
|
||||
std::cerr << "Generating SSL cert with name : " << ui.genPGPuser->itemText(pgpidx).toStdString() << std::endl;
|
||||
bool okGen = RsInit::GenerateSSLCertificate(ui.genPGPuser->itemText(pgpidx).toStdString(), genOrg, genLoc, genCountry, sslPasswd, sslId, err);
|
||||
|
||||
if (okGen)
|
||||
{
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>428</width>
|
||||
<height>404</height>
|
||||
<height>413</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
@ -1035,51 +1035,34 @@ p, li { white-space: pre-wrap; }
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Name:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="genName"/>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="3">
|
||||
<widget class="Line" name="line_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Organisation:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1" colspan="2">
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="genOrg"/>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Location:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1" colspan="2">
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="genLoc"/>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Country:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1" colspan="2">
|
||||
<item row="4" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="genCountry"/>
|
||||
</item>
|
||||
<item row="0" column="1" colspan="2">
|
||||
@ -1092,35 +1075,7 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>PGP Password</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="genPGPpassword">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="Line" name="line_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1" colspan="2">
|
||||
<widget class="Line" name="line_6">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<item row="5" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -1169,8 +1124,6 @@ p, li { white-space: pre-wrap; }
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>genPGPuser</tabstop>
|
||||
<tabstop>genPGPpassword</tabstop>
|
||||
<tabstop>genName</tabstop>
|
||||
<tabstop>genOrg</tabstop>
|
||||
<tabstop>genLoc</tabstop>
|
||||
<tabstop>genCountry</tabstop>
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "rsiface/rsiface.h"
|
||||
#include "rsiface/rspeers.h"
|
||||
#include "rsiface/rsdisc.h"
|
||||
#include <algorithm>
|
||||
|
||||
/* for GPGME */
|
||||
#include "rsiface/rsinit.h"
|
||||
@ -96,44 +97,25 @@ NetworkDialog::NetworkDialog(QWidget *parent)
|
||||
ui.connecttreeWidget -> setRootIsDecorated( false );
|
||||
|
||||
/* Set header resize modes and initial section sizes */
|
||||
QHeaderView * _header = ui.connecttreeWidget->header () ;
|
||||
_header->setResizeMode (0, QHeaderView::Custom);
|
||||
_header->setResizeMode (1, QHeaderView::Interactive);
|
||||
_header->setResizeMode (2, QHeaderView::Interactive);
|
||||
_header->setResizeMode (3, QHeaderView::Interactive);
|
||||
_header->setResizeMode (4, QHeaderView::Interactive);
|
||||
_header->setResizeMode (5, QHeaderView::Interactive);
|
||||
_header->setResizeMode (6, QHeaderView::Interactive);
|
||||
_header->setResizeMode (7, QHeaderView::Interactive);
|
||||
_header->setResizeMode (8, QHeaderView::Interactive);
|
||||
_header->setResizeMode (9, QHeaderView::Interactive);
|
||||
|
||||
_header->resizeSection ( 0, 25 );
|
||||
_header->resizeSection ( 1, 100 );
|
||||
_header->resizeSection ( 2, 100 );
|
||||
_header->resizeSection ( 3, 100 );
|
||||
_header->resizeSection ( 4, 100 );
|
||||
_header->resizeSection ( 5, 200);
|
||||
_header->resizeSection ( 6, 100 );
|
||||
_header->resizeSection ( 7, 100 );
|
||||
_header->resizeSection ( 8, 100 );
|
||||
_header->resizeSection ( 9, 100 );
|
||||
|
||||
// set header text aligment
|
||||
QTreeWidgetItem * headerItem = ui.connecttreeWidget->headerItem();
|
||||
headerItem->setTextAlignment(0, Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
headerItem->setTextAlignment(1, Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
headerItem->setTextAlignment(2, Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
headerItem->setTextAlignment(3, Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
headerItem->setTextAlignment(4, Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
headerItem->setTextAlignment(5, Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
headerItem->setTextAlignment(6, Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
headerItem->setTextAlignment(7, Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
headerItem->setTextAlignment(8, Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
headerItem->setTextAlignment(9, Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
QHeaderView * _header = ui.connecttreeWidget->header () ;
|
||||
_header->setResizeMode (0, QHeaderView::Custom);
|
||||
_header->setResizeMode (1, QHeaderView::Interactive);
|
||||
_header->setResizeMode (2, QHeaderView::Interactive);
|
||||
_header->setResizeMode (3, QHeaderView::Interactive);
|
||||
|
||||
ui.networkTab->addTab(new NetworkView(),QString(tr("Network View")));
|
||||
ui.networkTab->addTab(new TrustView(),QString(tr("Trust matrix")));
|
||||
_header->resizeSection ( 0, 25 );
|
||||
_header->resizeSection ( 1, 200 );
|
||||
_header->resizeSection ( 2, 200 );
|
||||
|
||||
// set header text aligment
|
||||
QTreeWidgetItem * headerItem = ui.connecttreeWidget->headerItem();
|
||||
headerItem->setTextAlignment(0, Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
headerItem->setTextAlignment(1, Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
headerItem->setTextAlignment(2, Qt::AlignHCenter | Qt::AlignVCenter);
|
||||
headerItem->setTextAlignment(3, Qt::AlignVCenter);
|
||||
|
||||
ui.networkTab->addTab(new NetworkView(),QString(tr("Network View")));
|
||||
ui.networkTab->addTab(new TrustView(),QString(tr("Trust matrix")));
|
||||
|
||||
QString version = "-";
|
||||
std::map<std::string, std::string>::iterator vit;
|
||||
@ -198,14 +180,14 @@ void NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint point )
|
||||
|
||||
std::string peer_id = wi->text(9).toStdString() ;
|
||||
|
||||
// That's what context menus are made for
|
||||
// That's what context menus are made for
|
||||
RsPeerDetails detail;
|
||||
if(!rsPeers->getPeerDetails(peer_id, detail)) // that is not suppose to fail.
|
||||
if(!rsPeers->getPGPDetails(peer_id, detail)) // that is not suppose to fail.
|
||||
return ;
|
||||
|
||||
if(peer_id != rsPeers->getOwnId())
|
||||
if(peer_id != rsPeers->getPGPOwnId())
|
||||
{
|
||||
if(detail.state & RS_PEER_STATE_FRIEND)
|
||||
if(detail.ownsign)
|
||||
{
|
||||
denyFriendAct = new QAction(QIcon(IMAGE_DENIED), tr( "Deny friend" ), this );
|
||||
|
||||
@ -214,10 +196,7 @@ void NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint point )
|
||||
}
|
||||
else // not a friend
|
||||
{
|
||||
if(detail.validLvl > RS_TRUST_LVL_MARGINAL) // it's a denied old friend.
|
||||
makefriendAct = new QAction(QIcon(IMAGE_MAKEFRIEND), tr( "Accept friend" ), this );
|
||||
else
|
||||
makefriendAct = new QAction(QIcon(IMAGE_MAKEFRIEND), tr( "Make friend" ), this );
|
||||
makefriendAct = new QAction(QIcon(IMAGE_MAKEFRIEND), tr( "Make friend" ), this );
|
||||
|
||||
connect( makefriendAct , SIGNAL( triggered() ), this, SLOT( makeFriend() ) );
|
||||
contextMnu.addAction( makefriendAct);
|
||||
@ -232,7 +211,7 @@ void NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint point )
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if ( peer_id == rsPeers->getOwnId())
|
||||
if ( peer_id == rsPeers->getPGPOwnId())
|
||||
{
|
||||
exportcertAct = new QAction(QIcon(IMAGE_EXPIORT), tr( "Export my Cert" ), this );
|
||||
connect( exportcertAct , SIGNAL( triggered() ), this, SLOT( on_actionExportKey_activated() ) );
|
||||
@ -250,7 +229,7 @@ void NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint point )
|
||||
void NetworkDialog::denyFriend()
|
||||
{
|
||||
QTreeWidgetItem *wi = getCurrentNeighbour();
|
||||
std::string peer_id = wi->text(9).toStdString() ;
|
||||
std::string peer_id = wi->text(3).toStdString() ;
|
||||
rsPeers->removeFriend(peer_id) ;
|
||||
|
||||
insertConnect() ;
|
||||
@ -273,9 +252,9 @@ void NetworkDialog::deleteCert()
|
||||
void NetworkDialog::makeFriend()
|
||||
{
|
||||
QTreeWidgetItem *wi = getCurrentNeighbour();
|
||||
std::string authId = wi->text(9).toStdString() ;
|
||||
std::string authId = wi->text(3).toStdString() ;
|
||||
|
||||
rsPeers->AuthCertificate(authId, "");
|
||||
rsPeers->SignGPGCertificate(authId);
|
||||
rsPeers->addFriend(authId);
|
||||
|
||||
insertConnect() ;
|
||||
@ -284,7 +263,7 @@ void NetworkDialog::makeFriend()
|
||||
/** Shows Peer Information/Auth Dialog */
|
||||
void NetworkDialog::peerdetails()
|
||||
{
|
||||
ConfCertDialog::show(getCurrentNeighbour()->text(9).toStdString());
|
||||
ConfCertDialog::show(getCurrentNeighbour()->text(3).toStdString());
|
||||
}
|
||||
|
||||
/** Shows Peer Information/Auth Dialog */
|
||||
@ -360,9 +339,9 @@ void NetworkDialog::insertConnect()
|
||||
return;
|
||||
}
|
||||
|
||||
std::list<std::string> neighs;
|
||||
std::list<std::string> neighs; //these are GPG ids
|
||||
std::list<std::string>::iterator it;
|
||||
rsPeers->getOthersList(neighs);
|
||||
rsPeers->getPGPAllList(neighs);
|
||||
|
||||
/* get a link to the table */
|
||||
QTreeWidget *connectWidget = ui.connecttreeWidget;
|
||||
@ -371,122 +350,75 @@ void NetworkDialog::insertConnect()
|
||||
std::string oldId;
|
||||
if (oldSelect)
|
||||
{
|
||||
oldId = (oldSelect -> text(9)).toStdString();
|
||||
oldId = (oldSelect -> text(3)).toStdString();
|
||||
}
|
||||
|
||||
RsPeerDetails ownGPGDetails ;
|
||||
rsPeers->getPGPDetails(rsPeers->getPGPOwnId(), ownGPGDetails);
|
||||
|
||||
QList<QTreeWidgetItem *> items;
|
||||
for(it = neighs.begin(); it != neighs.end(); it++)
|
||||
{
|
||||
RsPeerDetails detail;
|
||||
if (!rsPeers->getPeerDetails(*it, detail))
|
||||
{
|
||||
continue; /* BAD */
|
||||
}
|
||||
if (*it == rsPeers->getPGPOwnId()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* make a widget per friend */
|
||||
RsPeerDetails detail;
|
||||
if (!rsPeers->getPGPDetails(*it, detail))
|
||||
{
|
||||
continue; /* BAD */
|
||||
}
|
||||
/* make a widget per friend */
|
||||
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
|
||||
|
||||
/* add all the labels */
|
||||
|
||||
/* (0) Status Icon */
|
||||
item -> setText(0, "");
|
||||
item -> setText(0, "");
|
||||
|
||||
/* (1) Accept/Deny */
|
||||
if (detail.state & RS_PEER_STATE_FRIEND)
|
||||
item -> setText(1, tr("Trusted"));
|
||||
/* (1) Person */
|
||||
item -> setText(1, QString::fromStdString(detail.name));
|
||||
|
||||
/* (2) has me auth */
|
||||
bool hasSignedMe = false;
|
||||
std::list<std::string>::iterator signersIt;
|
||||
for(signersIt = ownGPGDetails.signers.begin(); signersIt != ownGPGDetails.signers.end() ; ++signersIt) {
|
||||
if (*signersIt == detail.id) {
|
||||
hasSignedMe = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (hasSignedMe)
|
||||
item -> setText(2, tr("Has authenticated me"));
|
||||
else
|
||||
item -> setText(1, tr("Denied"));
|
||||
|
||||
if (rsPeers->isTrustingMe(detail.id) || detail.lastConnect>0)
|
||||
item -> setText(2, tr("Is trusting me"));
|
||||
else
|
||||
item -> setText(2, tr("Unknown"));
|
||||
|
||||
/* (3) Last Connect */
|
||||
{
|
||||
std::ostringstream out;
|
||||
// Show anouncement if a friend never was connected.
|
||||
if (detail.lastConnect==0 )
|
||||
item -> setText(3, tr("Never seen"));
|
||||
else
|
||||
{
|
||||
// Dont Show a timestamp in RS calculate the day
|
||||
QDateTime datum = QDateTime::fromTime_t(detail.lastConnect);
|
||||
// out << datum.toString(Qt::LocalDate);
|
||||
QString stime = datum.toString(Qt::LocalDate);
|
||||
item -> setText(3, stime);
|
||||
}
|
||||
}
|
||||
item -> setText(2, tr("Unknown"));
|
||||
|
||||
/* (4) Person */
|
||||
item -> setText(4, QString::fromStdString(detail.name));
|
||||
|
||||
/* (5) Peer Address */
|
||||
/* (3) key id */
|
||||
{
|
||||
std::ostringstream out;
|
||||
if(detail.state & RS_PEER_STATE_FRIEND) {
|
||||
out << detail.localAddr << ":";
|
||||
out << detail.localPort << "/";
|
||||
out << detail.extAddr << ":";
|
||||
out << detail.extPort;
|
||||
} else {
|
||||
// No Trust => no IP Information
|
||||
out << "Unknown";
|
||||
}
|
||||
item -> setText(5, QString::fromStdString(out.str()));
|
||||
}
|
||||
|
||||
/* Others */
|
||||
item -> setText(6, QString::fromStdString(detail.org));
|
||||
item -> setText(7, QString::fromStdString(detail.location));
|
||||
item -> setText(8, QString::fromStdString(rsPeers->getPeerName(detail.id)));
|
||||
|
||||
{
|
||||
item -> setText(9, QString::fromStdString(detail.id));
|
||||
item -> setText(3, QString::fromStdString(detail.id));
|
||||
if ((oldSelect) && (oldId == detail.id))
|
||||
{
|
||||
newSelect = item;
|
||||
}
|
||||
}
|
||||
|
||||
//item -> setText(10, QString::fromStdString(detail.authcode));
|
||||
|
||||
/**
|
||||
* Determinated the Background Color
|
||||
*/
|
||||
QColor backgrndcolor;
|
||||
|
||||
if (detail.state & RS_PEER_STATE_FRIEND)
|
||||
if (detail.ownsign)
|
||||
{
|
||||
item -> setIcon(0,(QIcon(IMAGE_AUTHED)));
|
||||
backgrndcolor=Qt::green;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rsPeers->isTrustingMe(detail.id))
|
||||
if (hasSignedMe)
|
||||
{
|
||||
backgrndcolor=Qt::magenta;
|
||||
item -> setIcon(0,(QIcon(IMAGE_TRUSTED)));
|
||||
for(int k=0;k<8;++k)
|
||||
item -> setToolTip(k,QString::fromStdString(detail.name) + QString(tr(" is trusting you. \nRight-click and select 'make friend' to be able to connect."))) ;
|
||||
}
|
||||
#ifdef RS_USE_PGPSSL
|
||||
else if (detail.validLvl > GPGME_VALIDITY_MARGINAL)
|
||||
{
|
||||
backgrndcolor=Qt::cyan;
|
||||
item -> setIcon(0,(QIcon(IMAGE_DENIED)));
|
||||
}
|
||||
#else
|
||||
else if (detail.trustLvl > RS_TRUST_LVL_MARGINAL)
|
||||
{
|
||||
backgrndcolor=Qt::cyan;
|
||||
item -> setIcon(0,(QIcon(IMAGE_DENIED)));
|
||||
}
|
||||
#endif
|
||||
else if (detail.lastConnect < 10000) /* 3 hours? */
|
||||
{
|
||||
backgrndcolor=Qt::yellow;
|
||||
item -> setIcon(0,(QIcon(IMAGE_DENIED)));
|
||||
item -> setToolTip(k,QString::fromStdString(detail.name) + QString(tr(" has authenticaed you. \nRight-click and select 'make friend' to be able to connect."))) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -502,39 +434,28 @@ void NetworkDialog::insertConnect()
|
||||
|
||||
/* add to the list */
|
||||
items.append(item);
|
||||
|
||||
}
|
||||
|
||||
// add self to network.
|
||||
RsPeerDetails pd ;
|
||||
if(rsPeers->getPeerDetails(rsPeers->getOwnId(),pd))
|
||||
{
|
||||
QTreeWidgetItem *self_item = new QTreeWidgetItem((QTreeWidget*)0);
|
||||
QTreeWidgetItem *self_item = new QTreeWidgetItem((QTreeWidget*)0);
|
||||
|
||||
self_item->setText(1,"N/A");
|
||||
self_item->setText(2,"N/A");
|
||||
self_item->setText(3,"N/A");
|
||||
self_item->setText(4,QString::fromStdString(pd.name) + " (yourself)") ;
|
||||
self_item->setText(1,QString::fromStdString(ownGPGDetails.name) + " (yourself)") ;
|
||||
self_item->setText(2,"N/A");
|
||||
self_item->setText(3, QString::fromStdString(ownGPGDetails.id));
|
||||
|
||||
std::ostringstream out;
|
||||
out << pd.localAddr << ":" << pd.localPort << "/" << pd.extAddr << ":" << pd.extPort;
|
||||
self_item->setText(5, QString::fromStdString(out.str()));
|
||||
self_item->setText(6, QString::fromStdString(pd.org));
|
||||
self_item->setText(7, QString::fromStdString(pd.location));
|
||||
self_item->setText(8, QString::fromStdString(pd.email));
|
||||
self_item->setText(9, QString::fromStdString(pd.id));
|
||||
// Color each Background column in the Network Tab except the first one => 1-9
|
||||
for(int i=1;i<10;++i)
|
||||
{
|
||||
self_item->setBackground(i,QBrush(Qt::green));
|
||||
}
|
||||
self_item->setIcon(0,(QIcon(IMAGE_AUTHED)));
|
||||
items.append(self_item);
|
||||
|
||||
// Color each Background column in the Network Tab except the first one => 1-9
|
||||
for(int i=1;i<10;++i)
|
||||
{
|
||||
self_item->setBackground(i,QBrush(Qt::green));
|
||||
}
|
||||
self_item->setIcon(0,(QIcon(IMAGE_AUTHED)));
|
||||
items.append(self_item);
|
||||
}
|
||||
|
||||
/* remove old items ??? */
|
||||
connectWidget->clear();
|
||||
connectWidget->setColumnCount(10);
|
||||
connectWidget->setColumnCount(4);
|
||||
|
||||
/* add the items in! */
|
||||
connectWidget->insertTopLevelItems(0, items);
|
||||
@ -542,7 +463,7 @@ void NetworkDialog::insertConnect()
|
||||
{
|
||||
connectWidget->setCurrentItem(newSelect);
|
||||
}
|
||||
|
||||
connectWidget->sortItems( 1, Qt::AscendingOrder );
|
||||
connectWidget->update(); /* update display */
|
||||
}
|
||||
|
||||
@ -569,7 +490,7 @@ QTreeWidgetItem *NetworkDialog::getCurrentNeighbour()
|
||||
/* Utility Fns */
|
||||
RsCertId getNeighRsCertId(QTreeWidgetItem *i)
|
||||
{
|
||||
RsCertId id = (i -> text(9)).toStdString();
|
||||
RsCertId id = (i -> text(3)).toStdString();
|
||||
return id;
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
<number>20</number>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
@ -74,27 +74,39 @@
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="uniformRowHeights">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="sortingEnabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="animated">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<attribute name="headerCascadingSectionResizes">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="headerDefaultSectionSize">
|
||||
<number>200</number>
|
||||
</attribute>
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="headerCascadingSectionResizes">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<attribute name="headerDefaultSectionSize">
|
||||
<number>200</number>
|
||||
</attribute>
|
||||
<attribute name="headerStretchLastSection">
|
||||
<bool>true</bool>
|
||||
</attribute>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Your trust</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Peer's trust</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Last Contact</string>
|
||||
<string> </string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
@ -104,22 +116,7 @@
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Peer Address</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Organisation</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Location</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Country</string>
|
||||
<string>Peer's trust</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
|
@ -53,35 +53,13 @@ StartDialog::StartDialog(QWidget *parent, Qt::WFlags flags)
|
||||
/* Create Bandwidth Graph related QObjects */
|
||||
_settings = new RshareSettings();
|
||||
|
||||
ui.loadPasswd->setFocus();
|
||||
|
||||
//connect(ui.genButton, SIGNAL(clicked()), this, SLOT(genPerson()));
|
||||
ui.loadButton->setFocus();
|
||||
|
||||
connect(ui.loadButton, SIGNAL(clicked()), this, SLOT(loadPerson()));
|
||||
connect(ui.loadPasswd, SIGNAL(returnPressed()), this, SLOT(loadPerson()));
|
||||
connect(ui.loadGPGPasswd, SIGNAL(returnPressed()), this, SLOT(loadPerson()));
|
||||
//connect(ui.selectButton, SIGNAL(clicked()), this, SLOT(selectFriend()));
|
||||
//connect(ui.friendBox, SIGNAL(stateChanged(int)), this, SLOT(checkChanged(int)));
|
||||
|
||||
/* load the Certificate File name */
|
||||
std::string userName;
|
||||
|
||||
#ifndef WINDOWS_SYS /* UNIX */
|
||||
//hide autologin because it's not functionnal on other than windows system
|
||||
ui.autoBox->hide();
|
||||
#endif
|
||||
|
||||
//comment those to show the pgp and ssl password dialog
|
||||
ui.loadPasswd->hide();
|
||||
ui.label_4->hide();
|
||||
|
||||
ui.loadGPGPasswd->hide();
|
||||
ui.label_5->hide();
|
||||
|
||||
ui.loadPasswd->setMinimumHeight(0);
|
||||
ui.loadGPGPasswd->setMinimumHeight(0);
|
||||
ui.label_4->setMinimumHeight(0);
|
||||
ui.label_5->setMinimumHeight(0);
|
||||
|
||||
/* get all available pgp private certificates....
|
||||
* mark last one as default.
|
||||
*/
|
||||
@ -100,8 +78,6 @@ StartDialog::StartDialog(QWidget *parent, Qt::WFlags flags)
|
||||
std::string gpgid, name, email, sslname;
|
||||
RsInit::getAccountDetails(*it, gpgid, name, email, sslname);
|
||||
QString accountName = QString::fromStdString(name);
|
||||
accountName += "/";
|
||||
accountName += QString::fromStdString(sslname);
|
||||
ui.loadName->addItem(accountName, userData);
|
||||
|
||||
if (preferedId == *it)
|
||||
@ -149,10 +125,7 @@ void StartDialog::closeinfodlg()
|
||||
void StartDialog::loadPerson()
|
||||
{
|
||||
std::string accountId = "";
|
||||
std::string passwd = ui.loadPasswd->text().toStdString();
|
||||
#ifdef RS_USE_PGPSSL
|
||||
|
||||
std::string gpgPasswd = ui.loadGPGPasswd->text().toStdString();
|
||||
int pgpidx = ui.loadName->currentIndex();
|
||||
if (pgpidx < 0)
|
||||
{
|
||||
@ -172,19 +145,16 @@ void StartDialog::loadPerson()
|
||||
gpgId, gpgName, gpgEmail, sslName))
|
||||
{
|
||||
RsInit::SelectGPGAccount(gpgId);
|
||||
//RsInit::LoadGPGPassword(gpgPasswd);
|
||||
}
|
||||
#else
|
||||
#endif
|
||||
RsInit::LoadPassword(accountId, passwd);
|
||||
|
||||
RsInit::LoadPassword(accountId, "");
|
||||
loadCertificates();
|
||||
}
|
||||
|
||||
void StartDialog::loadCertificates()
|
||||
{
|
||||
bool autoSave = (Qt::Checked == ui.autoBox -> checkState());
|
||||
/* Final stage of loading */
|
||||
if (RsInit::LoadCertificates(autoSave))
|
||||
if (RsInit::LoadCertificates(false))
|
||||
{
|
||||
close();
|
||||
}
|
||||
@ -195,9 +165,7 @@ void StartDialog::loadCertificates()
|
||||
"Login Failure",
|
||||
"*** Wrong Password ***",
|
||||
QMessageBox::Ok);
|
||||
ui.loadPasswd->setText("");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void StartDialog::on_labelProfile_linkActivated(QString link)
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>291</width>
|
||||
<height>514</height>
|
||||
<height>525</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="palette">
|
||||
@ -594,69 +594,9 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Password:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QLineEdit" name="loadPasswd">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QCheckBox" name="autoBox">
|
||||
<property name="text">
|
||||
<string>Auto-login</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>98</width>
|
||||
<height>17</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QComboBox" name="loadName"/>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<widget class="QLineEdit" name="loadGPGPasswd">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>PGP Password</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
@ -681,19 +621,6 @@ p, li { white-space: pre-wrap; }
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>61</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QPushButton" name="loadButton">
|
||||
<property name="text">
|
||||
@ -707,6 +634,19 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>61</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<spacer>
|
||||
<property name="orientation">
|
||||
@ -738,32 +678,6 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="3">
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>24</width>
|
||||
<height>198</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<spacer name="horizontalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>25</width>
|
||||
<height>208</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QLabel" name="labelProfile">
|
||||
<property name="text">
|
||||
@ -791,9 +705,6 @@ p, li { white-space: pre-wrap; }
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>loadName</tabstop>
|
||||
<tabstop>loadPasswd</tabstop>
|
||||
<tabstop>loadGPGPasswd</tabstop>
|
||||
<tabstop>autoBox</tabstop>
|
||||
<tabstop>loadButton</tabstop>
|
||||
<tabstop>toolButton</tabstop>
|
||||
</tabstops>
|
||||
|
Loading…
Reference in New Issue
Block a user