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:
joss17 2010-01-13 21:08:46 +00:00
parent 45b2287d41
commit 77b3c0afd0
12 changed files with 267 additions and 510 deletions

View File

@ -198,7 +198,7 @@ AuthGPG::AuthGPG()
*/ */
bool AuthGPG::availablePGPCertificates(std::list<std::string> &ids) bool AuthGPG::availablePGPCertificates(std::list<std::string> &ids)
{ {
RsStackMutex stack(pgpMtx); /******* LOCKED ******/ //RsStackMutex stack(pgpMtx); /******* LOCKED ******/
int i = 0; int i = 0;
gpgme_key_t KEY = NULL; gpgme_key_t KEY = NULL;
@ -609,7 +609,7 @@ bool AuthGPG::printOwnKeys_locked()
bool AuthGPG::printKeys() bool AuthGPG::printKeys()
{ {
RsStackMutex stack(pgpMtx); /******* LOCKED ******/ //RsStackMutex stack(pgpMtx); /******* LOCKED ******/
printAllKeys_locked(); printAllKeys_locked();
return printOwnKeys_locked(); return printOwnKeys_locked();
} }
@ -827,7 +827,7 @@ bool AuthGPG::VerifySignature_locked(const void *data, int datalen, const void *
bool AuthGPG::active() bool AuthGPG::active()
{ {
RsStackMutex stack(pgpMtx); /******* LOCKED ******/ //RsStackMutex stack(pgpMtx); /******* LOCKED ******/
return ((gpgmeInit) && (gpgmeKeySelected) && (gpgmeX509Selected)); return ((gpgmeInit) && (gpgmeKeySelected) && (gpgmeX509Selected));
} }
@ -855,7 +855,7 @@ int AuthGPG::setConfigDirectories(std::string confFile, std::string neighDir
/**** These Two are common */ /**** These Two are common */
std::string AuthGPG::getPGPName(GPG_id id) std::string AuthGPG::getPGPName(GPG_id id)
{ {
RsStackMutex stack(pgpMtx); /******* LOCKED ******/ //RsStackMutex stack(pgpMtx); /******* LOCKED ******/
certmap::iterator it; certmap::iterator it;
if (mKeyList.end() != (it = mKeyList.find(id))) if (mKeyList.end() != (it = mKeyList.find(id)))
@ -867,7 +867,7 @@ std::string AuthGPG::getPGPName(GPG_id id)
/**** These Two are common */ /**** These Two are common */
std::string AuthGPG::getPGPEmail(GPG_id id) std::string AuthGPG::getPGPEmail(GPG_id id)
{ {
RsStackMutex stack(pgpMtx); /******* LOCKED ******/ //RsStackMutex stack(pgpMtx); /******* LOCKED ******/
certmap::iterator it; certmap::iterator it;
if (mKeyList.end() != (it = mKeyList.find(id))) if (mKeyList.end() != (it = mKeyList.find(id)))
@ -880,14 +880,14 @@ std::string AuthGPG::getPGPEmail(GPG_id id)
std::string AuthGPG::PGPOwnId() std::string AuthGPG::PGPOwnId()
{ {
RsStackMutex stack(pgpMtx); /******* LOCKED ******/ //RsStackMutex stack(pgpMtx); /******* LOCKED ******/
return mOwnGpgId; return mOwnGpgId;
} }
bool AuthGPG::getPGPAllList(std::list<std::string> &ids) bool AuthGPG::getPGPAllList(std::list<std::string> &ids)
{ {
RsStackMutex stack(pgpMtx); /******* LOCKED ******/ //RsStackMutex stack(pgpMtx); /******* LOCKED ******/
/* add an id for each pgp certificate */ /* add an id for each pgp certificate */
certmap::iterator it; certmap::iterator it;
@ -898,8 +898,29 @@ bool AuthGPG::getPGPAllList(std::list<std::string> &ids)
return true; 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) { bool AuthGPG::decryptText(gpgme_data_t CIPHER, gpgme_data_t PLAIN) {
RsStackMutex stack(pgpMtx); /******* LOCKED ******/ //RsStackMutex stack(pgpMtx); /******* LOCKED ******/
gpgme_set_armor (CTX, 1); gpgme_set_armor (CTX, 1);
gpg_error_t ERR; gpg_error_t ERR;
if (GPG_ERR_NO_ERROR != (ERR = gpgme_op_decrypt (CTX, CIPHER, PLAIN))) 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) { 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_encrypt_flags_t* flags = new gpgme_encrypt_flags_t();
gpgme_key_t keys[2] = {mOwnGpgCert.key, NULL}; 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) bool AuthGPG::getPGPSignedList(std::list<std::string> &ids)
{ {
RsStackMutex stack(pgpMtx); /******* LOCKED ******/ //RsStackMutex stack(pgpMtx); /******* LOCKED ******/
certmap::iterator it; certmap::iterator it;
for(it = mKeyList.begin(); it != mKeyList.end(); 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) bool AuthGPG::isPGPValid(GPG_id id)
{ {
RsStackMutex stack(pgpMtx); /******* LOCKED ******/ //RsStackMutex stack(pgpMtx); /******* LOCKED ******/
certmap::iterator it; certmap::iterator it;
if (mKeyList.end() != (it = mKeyList.find(id))) { if (mKeyList.end() != (it = mKeyList.find(id))) {
@ -962,7 +983,7 @@ bool AuthGPG::isPGPValid(GPG_id id)
bool AuthGPG::isPGPSigned(GPG_id id) bool AuthGPG::isPGPSigned(GPG_id id)
{ {
RsStackMutex stack(pgpMtx); /******* LOCKED ******/ //RsStackMutex stack(pgpMtx); /******* LOCKED ******/
certmap::iterator it; certmap::iterator it;
if (mKeyList.end() != (it = mKeyList.find(id))) if (mKeyList.end() != (it = mKeyList.find(id)))
@ -1135,8 +1156,7 @@ bool AuthGPG::SignCertificateLevel0(GPG_id id)
} }
/* reload stuff now ... */ /* reload stuff now ... */
RsStackMutex stack(pgpMtx); /******* LOCKED ******/ RsStackMutex stack(pgpMtx); /******* LOCKED ******/
storeAllKeys_locked(); storeAllKeys_locked();
return true; 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; class SignParams *sparams = (class SignParams *)params->oParams;
const char *result = NULL; 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 */ /* printf stuff out */
if (status == GPGME_STATUS_EOF) 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"); fprintf(stderr,"keySignCallback GPGME_STATUS_GOOD_PASSPHRASE\n");
if (status == GPGME_STATUS_BAD_PASSPHRASE) if (status == GPGME_STATUS_BAD_PASSPHRASE)
fprintf(stderr,"keySignCallback GPGME_STATUS_BAD_PASSPHRASE\n"); fprintf(stderr,"keySignCallback GPGME_STATUS_BAD_PASSPHRASE\n");
if (status == GPGME_STATUS_GET_LINE) if (status == GPGME_STATUS_GET_LINE)
fprintf(stderr,"keySignCallback GPGME_STATUS_GET_LINE\n"); fprintf(stderr,"keySignCallback GPGME_STATUS_GET_LINE\n");
if (status == GPGME_STATUS_GET_BOOL) 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) if (status == GPGME_STATUS_ALREADY_SIGNED)
fprintf(stderr,"keySignCallback GPGME_STATUS_ALREADY_SIGNED\n"); 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 || if(status == GPGME_STATUS_EOF ||
status == GPGME_STATUS_GOT_IT || 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); params->err = gpg_error (GPG_ERR_GENERAL);
} }
break; break;
// case SIGN_ENTER_PASSPHRASE: case SIGN_ENTER_PASSPHRASE:
// fprintf(stderr,"keySignCallback SIGN_ENTER_PASSPHRASE\n"); fprintf(stderr,"keySignCallback SIGN_ENTER_PASSPHRASE\n");
//
// if(status == GPGME_STATUS_GET_HIDDEN && if (status == GPGME_STATUS_GOOD_PASSPHRASE)
// (!std::string("passphrase.enter").compare(args))) {
// { params->state = SIGN_CONFIRM;
// params->state = SIGN_CONFIRM; }
// result = sparams->passphrase.c_str(); else
// } {
// // If using pgp_pwd_callback, then never have to enter passphrase this way. params->state = SIGN_ERROR;
// // must catch GOOD_PASSPHRASE to move on. params->err = gpg_error (GPG_ERR_GENERAL);
// else if (status == GPGME_STATUS_GOOD_PASSPHRASE) }
// { break;
// params->state = SIGN_CONFIRM;
// }
// else
// {
// params->state = SIGN_ERROR;
// params->err = gpg_error (GPG_ERR_GENERAL);
// }
// break;
case SIGN_CONFIRM: case SIGN_CONFIRM:
fprintf(stderr,"keySignCallback SIGN_CONFIRM\n"); fprintf(stderr,"keySignCallback SIGN_CONFIRM\n");

View File

@ -43,6 +43,7 @@
#include <openssl/ssl.h> #include <openssl/ssl.h>
#include <openssl/evp.h> #include <openssl/evp.h>
#include "util/rsthreads.h" #include "util/rsthreads.h"
#include "rsiface/rspeers.h"
#include <string> #include <string>
#include <list> #include <list>
#include <map> #include <map>
@ -150,6 +151,7 @@ class AuthGPG
/* PGP web of trust management */ /* PGP web of trust management */
GPG_id PGPOwnId(); GPG_id PGPOwnId();
bool getPGPAllList(std::list<std::string> &ids); bool getPGPAllList(std::list<std::string> &ids);
bool getPGPDetails(std::string id, RsPeerDetails &d);
bool getPGPSignedList(std::list<std::string> &ids); bool getPGPSignedList(std::list<std::string> &ids);
bool getPGPValidList(std::list<std::string> &ids); bool getPGPValidList(std::list<std::string> &ids);
bool isPGPValid(std::string id); bool isPGPValid(std::string id);

View File

@ -1769,7 +1769,7 @@ X509 *AuthSSL::SignX509Req(X509_REQ *req, long days)
X509 *x509 = X509_new(); X509 *x509 = X509_new();
if (x509 == NULL) if (x509 == NULL)
{ {
std::cerr << "GPGAuthMgr::SignX509Req() FAIL" << std::endl; std::cerr << "AuthSSL::SignX509Req() FAIL" << std::endl;
return NULL; return NULL;
} }
@ -1777,7 +1777,7 @@ X509 *AuthSSL::SignX509Req(X509_REQ *req, long days)
unsigned long chtype = MBSTRING_ASC; unsigned long chtype = MBSTRING_ASC;
X509_NAME *issuer_name = X509_NAME_new(); X509_NAME *issuer_name = X509_NAME_new();
X509_NAME_add_entry_by_txt(issuer_name, "CN", chtype, 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, X509_NAME_add_entry_by_NID(issuer_name, 48, 0,
(unsigned char *) "email@email.com", -1, -1, 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); (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(); BIGNUM *btmp = BN_new();
if (!BN_pseudo_rand(btmp, SERIAL_RAND_BITS, 0, 0)) 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; return NULL;
} }
if (!BN_to_ASN1_INTEGER(btmp, serial)) 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; return NULL;
} }
BN_free(btmp); BN_free(btmp);
if (!X509_set_serialNumber(x509, serial)) if (!X509_set_serialNumber(x509, serial))
{ {
std::cerr << "GPGAuthMgr::SignX509Req() serial FAIL" << std::endl; std::cerr << "AuthSSL::SignX509Req() serial FAIL" << std::endl;
return NULL; return NULL;
} }
ASN1_INTEGER_free(serial); ASN1_INTEGER_free(serial);
@ -1815,7 +1815,7 @@ X509 *AuthSSL::SignX509Req(X509_REQ *req, long days)
if (!X509_set_issuer_name(x509, issuer_name)) 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; return NULL;
} }
X509_NAME_free(issuer_name); 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)) 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; return NULL;
} }
if (!X509_gmtime_adj(X509_get_notAfter(x509), (long)60*60*24*days)) 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; return NULL;
} }
if (!X509_set_subject_name(x509, X509_REQ_get_subject_name(req))) 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; return NULL;
} }
tmppkey = X509_REQ_get_pubkey(req); tmppkey = X509_REQ_get_pubkey(req);
if (!tmppkey || !X509_set_pubkey(x509,tmppkey)) 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; return NULL;
} }
@ -1901,7 +1901,7 @@ X509 *AuthSSL::SignX509Req(X509_REQ *req, long days)
{ {
hashoutl=0; hashoutl=0;
sigoutl=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; goto err;
} }
p=buf_in; p=buf_in;
@ -1916,7 +1916,7 @@ X509 *AuthSSL::SignX509Req(X509_REQ *req, long days)
(unsigned int *)&hashoutl)) (unsigned int *)&hashoutl))
{ {
hashoutl=0; 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; goto err;
} }

View File

@ -30,7 +30,11 @@
#include <string> #include <string>
#include <list> #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; class RsPeers;
extern RsPeers *rsPeers; extern RsPeers *rsPeers;
@ -105,7 +109,7 @@ class RsPeerDetails
/* basic stats */ /* basic stats */
uint32_t lastConnect; /* how long ago */ uint32_t lastConnect; /* how long ago */
std::string autoconnect; std::string autoconnect;
uint32_t connectPeriod; uint32_t connectPeriod;
}; };
std::ostream &operator<<(std::ostream &out, const RsPeerDetails &detail); 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 std::string getPGPOwnId() = 0;
virtual bool getPGPFriendList(std::list<std::string> &ids) = 0; virtual bool getPGPFriendList(std::list<std::string> &ids) = 0;
virtual bool getPGPAllList(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 */ /* Add/Remove Friends */
virtual bool addFriend(std::string id) = 0; 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 bool SaveCertificateToFile(std::string id, std::string fname) = 0;
virtual std::string SaveCertificateToString(std::string id) = 0; virtual std::string SaveCertificateToString(std::string id) = 0;
virtual bool AuthCertificate(std::string id, std::string code) = 0; virtual bool SignGPGCertificate(std::string id) = 0;
virtual bool SignCertificate(std::string id) = 0;
virtual bool TrustCertificate(std::string id, bool trust) = 0; virtual bool TrustCertificate(std::string id, bool trust) = 0;
}; };

View File

@ -549,6 +549,18 @@ bool p3Peers::getPGPAllList(std::list<std::string> &ids)
return true; 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() std::string p3Peers::getPGPOwnId()
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
@ -874,34 +886,14 @@ std::string p3Peers::SaveCertificateToString(std::string id)
return AuthSSL::getAuthSSL()->SaveCertificateToString(id); return AuthSSL::getAuthSSL()->SaveCertificateToString(id);
} }
bool p3Peers::AuthCertificate(std::string id, std::string code) bool p3Peers::SignGPGCertificate(std::string id)
{
#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)
{ {
#ifdef P3PEERS_DEBUG #ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::SignCertificate() " << id; std::cerr << "p3Peers::SignCertificate() " << id;
std::cerr << std::endl; std::cerr << std::endl;
#endif #endif
return AuthSSL::getAuthSSL()->SignCertificate(id); return AuthGPG::getAuthGPG()->SignCertificateLevel0(id);
} }
bool p3Peers::TrustCertificate(std::string id, bool trust) bool p3Peers::TrustCertificate(std::string id, bool trust)

View File

@ -57,6 +57,7 @@ virtual bool getPeerDetails(std::string id, RsPeerDetails &d);
virtual std::string getPGPOwnId(); virtual std::string getPGPOwnId();
virtual bool getPGPFriendList(std::list<std::string> &ids); virtual bool getPGPFriendList(std::list<std::string> &ids);
virtual bool getPGPAllList(std::list<std::string> &ids); virtual bool getPGPAllList(std::list<std::string> &ids);
virtual bool getPGPDetails(std::string id, RsPeerDetails &d);
/* Add/Remove Friends */ /* 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 bool SaveCertificateToFile(std::string id, std::string fname);
virtual std::string SaveCertificateToString(std::string id); virtual std::string SaveCertificateToString(std::string id);
virtual bool AuthCertificate(std::string id, std::string code); virtual bool SignGPGCertificate(std::string id);
virtual bool SignCertificate(std::string id);
virtual bool TrustCertificate(std::string id, bool trust); virtual bool TrustCertificate(std::string id, bool trust);
private: private:

View File

@ -50,30 +50,29 @@ GenCertDialog::GenCertDialog(QWidget *parent, Qt::WFlags flags)
//ui.genName->setFocus(Qt::OtherFocusReason); //ui.genName->setFocus(Qt::OtherFocusReason);
//the pgp password is now a GT box. ui.genCountry->hide();
ui.genPGPpassword->hide(); ui.label_6->hide();
ui.label_3->hide(); ui.genOrg->hide();
ui.label_8->hide();
#ifdef RS_USE_PGPSSL /* get all available pgp private certificates....
/* get all available pgp private certificates.... * mark last one as default.
* mark last one as default. */
*/ std::cerr << "Finding PGPUsers" << std::endl;
std::cerr << "Finding PGPUsers" << std::endl;
std::list<std::string> pgpIds; std::list<std::string> pgpIds;
std::list<std::string>::iterator it; std::list<std::string>::iterator it;
if (RsInit::GetPGPLogins(pgpIds)) if (RsInit::GetPGPLogins(pgpIds))
{ {
for(it = pgpIds.begin(); it != pgpIds.end(); it++) for(it = pgpIds.begin(); it != pgpIds.end(); it++)
{ {
const QVariant & userData = QVariant(QString::fromStdString(*it)); const QVariant & userData = QVariant(QString::fromStdString(*it));
std::string name, email; std::string name, email;
RsInit::GetPGPLoginDetails(*it, name, email); RsInit::GetPGPLoginDetails(*it, name, email);
std::cerr << "Adding PGPUser: " << name << " id: " << *it << std::endl; std::cerr << "Adding PGPUser: " << name << " id: " << *it << std::endl;
ui.genPGPuser->addItem(QString::fromStdString(name), userData); ui.genPGPuser->addItem(QString::fromStdString(name), userData);
} }
} }
#endif
} }
@ -112,16 +111,11 @@ void GenCertDialog::genPerson()
{ {
/* Check the data from the GUI. */ /* Check the data from the GUI. */
std::string genName = ui.genName->text().toStdString();
std::string genOrg = ui.genOrg->text().toStdString(); std::string genOrg = ui.genOrg->text().toStdString();
std::string genLoc = ui.genLoc->text().toStdString(); std::string genLoc = ui.genLoc->text().toStdString();
std::string genCountry = ui.genCountry->text().toStdString(); std::string genCountry = ui.genCountry->text().toStdString();
std::string err; std::string err;
#ifdef RS_USE_PGPSSL
std::string PGPpasswd = ui.genPGPpassword->text().toStdString();
int pgpidx = ui.genPGPuser->currentIndex(); int pgpidx = ui.genPGPuser->currentIndex();
if (pgpidx < 0) if (pgpidx < 0)
{ {
@ -136,23 +130,6 @@ void GenCertDialog::genPerson()
QVariant data = ui.genPGPuser->itemData(pgpidx); QVariant data = ui.genPGPuser->itemData(pgpidx);
std::string PGPId = (data.toString()).toStdString(); 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 //generate a random ssl password
std::cerr << " generating sslPasswd." << std::endl; std::cerr << " generating sslPasswd." << std::endl;
qsrand(time(NULL)); qsrand(time(NULL));
@ -169,7 +146,8 @@ void GenCertDialog::genPerson()
//RsInit::LoadGPGPassword(PGPpasswd); //RsInit::LoadGPGPassword(PGPpasswd);
std::string sslId; 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) if (okGen)
{ {

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>428</width> <width>428</width>
<height>404</height> <height>413</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -1035,51 +1035,34 @@ p, li { white-space: pre-wrap; }
<property name="spacing"> <property name="spacing">
<number>6</number> <number>6</number>
</property> </property>
<item row="4" column="0"> <item row="2" 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">
<widget class="QLabel" name="label_6"> <widget class="QLabel" name="label_6">
<property name="text"> <property name="text">
<string>Organisation:</string> <string>Organisation:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="1" colspan="2"> <item row="2" column="1" colspan="2">
<widget class="QLineEdit" name="genOrg"/> <widget class="QLineEdit" name="genOrg"/>
</item> </item>
<item row="7" column="0"> <item row="3" column="0">
<widget class="QLabel" name="label_7"> <widget class="QLabel" name="label_7">
<property name="text"> <property name="text">
<string>Location:</string> <string>Location:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="1" colspan="2"> <item row="3" column="1" colspan="2">
<widget class="QLineEdit" name="genLoc"/> <widget class="QLineEdit" name="genLoc"/>
</item> </item>
<item row="8" column="0"> <item row="4" column="0">
<widget class="QLabel" name="label_8"> <widget class="QLabel" name="label_8">
<property name="text"> <property name="text">
<string>Country:</string> <string>Country:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="8" column="1" colspan="2"> <item row="4" column="1" colspan="2">
<widget class="QLineEdit" name="genCountry"/> <widget class="QLineEdit" name="genCountry"/>
</item> </item>
<item row="0" column="1" colspan="2"> <item row="0" column="1" colspan="2">
@ -1092,35 +1075,7 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item row="5" column="1">
<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">
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@ -1169,8 +1124,6 @@ p, li { white-space: pre-wrap; }
</widget> </widget>
<tabstops> <tabstops>
<tabstop>genPGPuser</tabstop> <tabstop>genPGPuser</tabstop>
<tabstop>genPGPpassword</tabstop>
<tabstop>genName</tabstop>
<tabstop>genOrg</tabstop> <tabstop>genOrg</tabstop>
<tabstop>genLoc</tabstop> <tabstop>genLoc</tabstop>
<tabstop>genCountry</tabstop> <tabstop>genCountry</tabstop>

View File

@ -33,6 +33,7 @@
#include "rsiface/rsiface.h" #include "rsiface/rsiface.h"
#include "rsiface/rspeers.h" #include "rsiface/rspeers.h"
#include "rsiface/rsdisc.h" #include "rsiface/rsdisc.h"
#include <algorithm>
/* for GPGME */ /* for GPGME */
#include "rsiface/rsinit.h" #include "rsiface/rsinit.h"
@ -96,44 +97,25 @@ NetworkDialog::NetworkDialog(QWidget *parent)
ui.connecttreeWidget -> setRootIsDecorated( false ); ui.connecttreeWidget -> setRootIsDecorated( false );
/* Set header resize modes and initial section sizes */ /* Set header resize modes and initial section sizes */
QHeaderView * _header = ui.connecttreeWidget->header () ; QHeaderView * _header = ui.connecttreeWidget->header () ;
_header->setResizeMode (0, QHeaderView::Custom); _header->setResizeMode (0, QHeaderView::Custom);
_header->setResizeMode (1, QHeaderView::Interactive); _header->setResizeMode (1, QHeaderView::Interactive);
_header->setResizeMode (2, QHeaderView::Interactive); _header->setResizeMode (2, QHeaderView::Interactive);
_header->setResizeMode (3, 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);
ui.networkTab->addTab(new NetworkView(),QString(tr("Network View"))); _header->resizeSection ( 0, 25 );
ui.networkTab->addTab(new TrustView(),QString(tr("Trust matrix"))); _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 = "-"; QString version = "-";
std::map<std::string, std::string>::iterator vit; 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() ; 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; 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 ; 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 ); denyFriendAct = new QAction(QIcon(IMAGE_DENIED), tr( "Deny friend" ), this );
@ -214,10 +196,7 @@ void NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint point )
} }
else // not a friend else // not a friend
{ {
if(detail.validLvl > RS_TRUST_LVL_MARGINAL) // it's a denied old friend. makefriendAct = new QAction(QIcon(IMAGE_MAKEFRIEND), tr( "Make friend" ), this );
makefriendAct = new QAction(QIcon(IMAGE_MAKEFRIEND), tr( "Accept friend" ), this );
else
makefriendAct = new QAction(QIcon(IMAGE_MAKEFRIEND), tr( "Make friend" ), this );
connect( makefriendAct , SIGNAL( triggered() ), this, SLOT( makeFriend() ) ); connect( makefriendAct , SIGNAL( triggered() ), this, SLOT( makeFriend() ) );
contextMnu.addAction( makefriendAct); contextMnu.addAction( makefriendAct);
@ -232,7 +211,7 @@ void NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint point )
#endif #endif
} }
} }
if ( peer_id == rsPeers->getOwnId()) if ( peer_id == rsPeers->getPGPOwnId())
{ {
exportcertAct = new QAction(QIcon(IMAGE_EXPIORT), tr( "Export my Cert" ), this ); exportcertAct = new QAction(QIcon(IMAGE_EXPIORT), tr( "Export my Cert" ), this );
connect( exportcertAct , SIGNAL( triggered() ), this, SLOT( on_actionExportKey_activated() ) ); connect( exportcertAct , SIGNAL( triggered() ), this, SLOT( on_actionExportKey_activated() ) );
@ -250,7 +229,7 @@ void NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint point )
void NetworkDialog::denyFriend() void NetworkDialog::denyFriend()
{ {
QTreeWidgetItem *wi = getCurrentNeighbour(); QTreeWidgetItem *wi = getCurrentNeighbour();
std::string peer_id = wi->text(9).toStdString() ; std::string peer_id = wi->text(3).toStdString() ;
rsPeers->removeFriend(peer_id) ; rsPeers->removeFriend(peer_id) ;
insertConnect() ; insertConnect() ;
@ -273,9 +252,9 @@ void NetworkDialog::deleteCert()
void NetworkDialog::makeFriend() void NetworkDialog::makeFriend()
{ {
QTreeWidgetItem *wi = getCurrentNeighbour(); 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); rsPeers->addFriend(authId);
insertConnect() ; insertConnect() ;
@ -284,7 +263,7 @@ void NetworkDialog::makeFriend()
/** Shows Peer Information/Auth Dialog */ /** Shows Peer Information/Auth Dialog */
void NetworkDialog::peerdetails() void NetworkDialog::peerdetails()
{ {
ConfCertDialog::show(getCurrentNeighbour()->text(9).toStdString()); ConfCertDialog::show(getCurrentNeighbour()->text(3).toStdString());
} }
/** Shows Peer Information/Auth Dialog */ /** Shows Peer Information/Auth Dialog */
@ -360,9 +339,9 @@ void NetworkDialog::insertConnect()
return; return;
} }
std::list<std::string> neighs; std::list<std::string> neighs; //these are GPG ids
std::list<std::string>::iterator it; std::list<std::string>::iterator it;
rsPeers->getOthersList(neighs); rsPeers->getPGPAllList(neighs);
/* get a link to the table */ /* get a link to the table */
QTreeWidget *connectWidget = ui.connecttreeWidget; QTreeWidget *connectWidget = ui.connecttreeWidget;
@ -371,122 +350,75 @@ void NetworkDialog::insertConnect()
std::string oldId; std::string oldId;
if (oldSelect) if (oldSelect)
{ {
oldId = (oldSelect -> text(9)).toStdString(); oldId = (oldSelect -> text(3)).toStdString();
} }
RsPeerDetails ownGPGDetails ;
rsPeers->getPGPDetails(rsPeers->getPGPOwnId(), ownGPGDetails);
QList<QTreeWidgetItem *> items; QList<QTreeWidgetItem *> items;
for(it = neighs.begin(); it != neighs.end(); it++) for(it = neighs.begin(); it != neighs.end(); it++)
{ {
RsPeerDetails detail; if (*it == rsPeers->getPGPOwnId()) {
if (!rsPeers->getPeerDetails(*it, detail)) continue;
{ }
continue; /* BAD */
}
/* 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); QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
/* add all the labels */
/* (0) Status Icon */ /* (0) Status Icon */
item -> setText(0, ""); item -> setText(0, "");
/* (1) Accept/Deny */ /* (1) Person */
if (detail.state & RS_PEER_STATE_FRIEND) item -> setText(1, QString::fromStdString(detail.name));
item -> setText(1, tr("Trusted"));
/* (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 else
item -> setText(1, tr("Denied")); item -> setText(2, tr("Unknown"));
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);
}
}
/* (4) Person */ /* (3) key id */
item -> setText(4, QString::fromStdString(detail.name));
/* (5) Peer Address */
{ {
std::ostringstream out; item -> setText(3, QString::fromStdString(detail.id));
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));
if ((oldSelect) && (oldId == detail.id)) if ((oldSelect) && (oldId == detail.id))
{ {
newSelect = item; newSelect = item;
} }
} }
//item -> setText(10, QString::fromStdString(detail.authcode));
/** /**
* Determinated the Background Color * Determinated the Background Color
*/ */
QColor backgrndcolor; QColor backgrndcolor;
if (detail.state & RS_PEER_STATE_FRIEND) if (detail.ownsign)
{ {
item -> setIcon(0,(QIcon(IMAGE_AUTHED))); item -> setIcon(0,(QIcon(IMAGE_AUTHED)));
backgrndcolor=Qt::green; backgrndcolor=Qt::green;
} }
else else
{ {
if (rsPeers->isTrustingMe(detail.id)) if (hasSignedMe)
{ {
backgrndcolor=Qt::magenta; backgrndcolor=Qt::magenta;
item -> setIcon(0,(QIcon(IMAGE_TRUSTED))); item -> setIcon(0,(QIcon(IMAGE_TRUSTED)));
for(int k=0;k<8;++k) 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."))) ; item -> setToolTip(k,QString::fromStdString(detail.name) + QString(tr(" has authenticaed 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)));
} }
else else
{ {
@ -502,39 +434,28 @@ void NetworkDialog::insertConnect()
/* add to the list */ /* add to the list */
items.append(item); items.append(item);
} }
// add self to network. // add self to network.
RsPeerDetails pd ; QTreeWidgetItem *self_item = new QTreeWidgetItem((QTreeWidget*)0);
if(rsPeers->getPeerDetails(rsPeers->getOwnId(),pd))
{
QTreeWidgetItem *self_item = new QTreeWidgetItem((QTreeWidget*)0);
self_item->setText(1,"N/A"); self_item->setText(1,QString::fromStdString(ownGPGDetails.name) + " (yourself)") ;
self_item->setText(2,"N/A"); self_item->setText(2,"N/A");
self_item->setText(3,"N/A"); self_item->setText(3, QString::fromStdString(ownGPGDetails.id));
self_item->setText(4,QString::fromStdString(pd.name) + " (yourself)") ;
std::ostringstream out; // Color each Background column in the Network Tab except the first one => 1-9
out << pd.localAddr << ":" << pd.localPort << "/" << pd.extAddr << ":" << pd.extPort; for(int i=1;i<10;++i)
self_item->setText(5, QString::fromStdString(out.str())); {
self_item->setText(6, QString::fromStdString(pd.org)); self_item->setBackground(i,QBrush(Qt::green));
self_item->setText(7, QString::fromStdString(pd.location)); }
self_item->setText(8, QString::fromStdString(pd.email)); self_item->setIcon(0,(QIcon(IMAGE_AUTHED)));
self_item->setText(9, QString::fromStdString(pd.id)); 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 ??? */ /* remove old items ??? */
connectWidget->clear(); connectWidget->clear();
connectWidget->setColumnCount(10); connectWidget->setColumnCount(4);
/* add the items in! */ /* add the items in! */
connectWidget->insertTopLevelItems(0, items); connectWidget->insertTopLevelItems(0, items);
@ -542,7 +463,7 @@ void NetworkDialog::insertConnect()
{ {
connectWidget->setCurrentItem(newSelect); connectWidget->setCurrentItem(newSelect);
} }
connectWidget->sortItems( 1, Qt::AscendingOrder );
connectWidget->update(); /* update display */ connectWidget->update(); /* update display */
} }
@ -569,7 +490,7 @@ QTreeWidgetItem *NetworkDialog::getCurrentNeighbour()
/* Utility Fns */ /* Utility Fns */
RsCertId getNeighRsCertId(QTreeWidgetItem *i) RsCertId getNeighRsCertId(QTreeWidgetItem *i)
{ {
RsCertId id = (i -> text(9)).toStdString(); RsCertId id = (i -> text(3)).toStdString();
return id; return id;
} }

View File

@ -66,7 +66,7 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="lineWidth"> <property name="lineWidth">
<number>0</number> <number>20</number>
</property> </property>
<property name="iconSize"> <property name="iconSize">
<size> <size>
@ -74,27 +74,39 @@
<height>16</height> <height>16</height>
</size> </size>
</property> </property>
<property name="uniformRowHeights">
<bool>true</bool>
</property>
<property name="sortingEnabled"> <property name="sortingEnabled">
<bool>true</bool> <bool>true</bool>
</property> </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> <column>
<property name="text"> <property name="text">
<string/> <string> </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>
</property> </property>
</column> </column>
<column> <column>
@ -104,22 +116,7 @@
</column> </column>
<column> <column>
<property name="text"> <property name="text">
<string>Peer Address</string> <string>Peer's trust</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>
</property> </property>
</column> </column>
<column> <column>

View File

@ -53,35 +53,13 @@ StartDialog::StartDialog(QWidget *parent, Qt::WFlags flags)
/* Create Bandwidth Graph related QObjects */ /* Create Bandwidth Graph related QObjects */
_settings = new RshareSettings(); _settings = new RshareSettings();
ui.loadPasswd->setFocus(); ui.loadButton->setFocus();
//connect(ui.genButton, SIGNAL(clicked()), this, SLOT(genPerson()));
connect(ui.loadButton, SIGNAL(clicked()), this, SLOT(loadPerson())); 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 */ /* load the Certificate File name */
std::string userName; 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.... /* get all available pgp private certificates....
* mark last one as default. * mark last one as default.
*/ */
@ -100,8 +78,6 @@ StartDialog::StartDialog(QWidget *parent, Qt::WFlags flags)
std::string gpgid, name, email, sslname; std::string gpgid, name, email, sslname;
RsInit::getAccountDetails(*it, gpgid, name, email, sslname); RsInit::getAccountDetails(*it, gpgid, name, email, sslname);
QString accountName = QString::fromStdString(name); QString accountName = QString::fromStdString(name);
accountName += "/";
accountName += QString::fromStdString(sslname);
ui.loadName->addItem(accountName, userData); ui.loadName->addItem(accountName, userData);
if (preferedId == *it) if (preferedId == *it)
@ -149,10 +125,7 @@ void StartDialog::closeinfodlg()
void StartDialog::loadPerson() void StartDialog::loadPerson()
{ {
std::string accountId = ""; 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(); int pgpidx = ui.loadName->currentIndex();
if (pgpidx < 0) if (pgpidx < 0)
{ {
@ -172,19 +145,16 @@ void StartDialog::loadPerson()
gpgId, gpgName, gpgEmail, sslName)) gpgId, gpgName, gpgEmail, sslName))
{ {
RsInit::SelectGPGAccount(gpgId); RsInit::SelectGPGAccount(gpgId);
//RsInit::LoadGPGPassword(gpgPasswd);
} }
#else
#endif RsInit::LoadPassword(accountId, "");
RsInit::LoadPassword(accountId, passwd);
loadCertificates(); loadCertificates();
} }
void StartDialog::loadCertificates() void StartDialog::loadCertificates()
{ {
bool autoSave = (Qt::Checked == ui.autoBox -> checkState());
/* Final stage of loading */ /* Final stage of loading */
if (RsInit::LoadCertificates(autoSave)) if (RsInit::LoadCertificates(false))
{ {
close(); close();
} }
@ -195,9 +165,7 @@ void StartDialog::loadCertificates()
"Login Failure", "Login Failure",
"*** Wrong Password ***", "*** Wrong Password ***",
QMessageBox::Ok); QMessageBox::Ok);
ui.loadPasswd->setText("");
} }
} }
void StartDialog::on_labelProfile_linkActivated(QString link) void StartDialog::on_labelProfile_linkActivated(QString link)

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>291</width> <width>291</width>
<height>514</height> <height>525</height>
</rect> </rect>
</property> </property>
<property name="palette"> <property name="palette">
@ -594,69 +594,9 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</item> </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"> <item row="1" column="0" colspan="2">
<widget class="QComboBox" name="loadName"/> <widget class="QComboBox" name="loadName"/>
</item> </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"> <item row="2" column="0" colspan="2">
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
@ -681,19 +621,6 @@ p, li { white-space: pre-wrap; }
<property name="bottomMargin"> <property name="bottomMargin">
<number>9</number> <number>9</number>
</property> </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"> <item row="0" column="1">
<widget class="QPushButton" name="loadButton"> <widget class="QPushButton" name="loadButton">
<property name="text"> <property name="text">
@ -707,6 +634,19 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</item> </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"> <item row="0" column="2">
<spacer> <spacer>
<property name="orientation"> <property name="orientation">
@ -738,32 +678,6 @@ p, li { white-space: pre-wrap; }
</property> </property>
</widget> </widget>
</item> </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"> <item row="5" column="1">
<widget class="QLabel" name="labelProfile"> <widget class="QLabel" name="labelProfile">
<property name="text"> <property name="text">
@ -791,9 +705,6 @@ p, li { white-space: pre-wrap; }
</widget> </widget>
<tabstops> <tabstops>
<tabstop>loadName</tabstop> <tabstop>loadName</tabstop>
<tabstop>loadPasswd</tabstop>
<tabstop>loadGPGPasswd</tabstop>
<tabstop>autoBox</tabstop>
<tabstop>loadButton</tabstop> <tabstop>loadButton</tabstop>
<tabstop>toolButton</tabstop> <tabstop>toolButton</tabstop>
</tabstops> </tabstops>