mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-06 21:58:57 -04:00
merge of branch v0.6-idclean 7180
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7187 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
7815efb16f
commit
0f29d28b1b
397 changed files with 6503 additions and 5702 deletions
|
@ -44,29 +44,53 @@
|
|||
#include "util/DateTime.h"
|
||||
#include "util/misc.h"
|
||||
|
||||
static QMap<std::string, ConfCertDialog*> instances;
|
||||
static QMap<RsPeerId, ConfCertDialog*> instances_ssl;
|
||||
static QMap<RsPgpId, ConfCertDialog*> instances_pgp;
|
||||
|
||||
ConfCertDialog *ConfCertDialog::instance(const std::string& peer_id)
|
||||
ConfCertDialog *ConfCertDialog::instance(const RsPeerId& peer_id)
|
||||
{
|
||||
ConfCertDialog *d = instances[peer_id];
|
||||
|
||||
ConfCertDialog *d = instances_ssl[peer_id];
|
||||
if (d) {
|
||||
return d;
|
||||
}
|
||||
|
||||
d = new ConfCertDialog(peer_id);
|
||||
instances[peer_id] = d;
|
||||
RsPeerDetails details ;
|
||||
if(!rsPeers->getPeerDetails(peer_id,details))
|
||||
return NULL ;
|
||||
|
||||
d = new ConfCertDialog(peer_id,details.gpg_id);
|
||||
instances_ssl[peer_id] = d;
|
||||
|
||||
return d;
|
||||
}
|
||||
ConfCertDialog *ConfCertDialog::instance(const RsPgpId& pgp_id)
|
||||
{
|
||||
|
||||
ConfCertDialog *d = instances_pgp[pgp_id];
|
||||
if (d) {
|
||||
return d;
|
||||
}
|
||||
|
||||
d = new ConfCertDialog(RsPeerId(),pgp_id);
|
||||
instances_pgp[pgp_id] = d;
|
||||
|
||||
return d;
|
||||
}
|
||||
/** Default constructor */
|
||||
ConfCertDialog::ConfCertDialog(const std::string& id, QWidget *parent, Qt::WindowFlags flags)
|
||||
: QDialog(parent, flags), mId(id)
|
||||
ConfCertDialog::ConfCertDialog(const RsPeerId& id, const RsPgpId &pgp_id, QWidget *parent, Qt::WindowFlags flags)
|
||||
: QDialog(parent, flags), peerId(id), pgpId(pgp_id)
|
||||
{
|
||||
/* Invoke Qt Designer generated QObject setup routine */
|
||||
ui.setupUi(this);
|
||||
|
||||
ui._useOldFormat_CB->setChecked(true) ;
|
||||
if(id.isNull())
|
||||
ui._useOldFormat_CB->setChecked(true) ;
|
||||
else
|
||||
{
|
||||
ui._useOldFormat_CB->setChecked(false) ;
|
||||
ui._useOldFormat_CB->setEnabled(false) ;
|
||||
}
|
||||
|
||||
ui.headerFrame->setHeaderImage(QPixmap(":/images/user/identityinfo64.png"));
|
||||
ui.headerFrame->setHeaderText(tr("Friend Details"));
|
||||
|
@ -97,64 +121,46 @@ ConfCertDialog::ConfCertDialog(const std::string& id, QWidget *parent, Qt::Windo
|
|||
|
||||
ConfCertDialog::~ConfCertDialog()
|
||||
{
|
||||
QMap<std::string, ConfCertDialog*>::iterator it = instances.find(mId);
|
||||
if (it != instances.end()) {
|
||||
instances.erase(it);
|
||||
if(peerId.isNull())
|
||||
{
|
||||
QMap<RsPeerId, ConfCertDialog*>::iterator it = instances_ssl.find(peerId);
|
||||
if (it != instances_ssl.end())
|
||||
instances_ssl.erase(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
QMap<RsPgpId, ConfCertDialog*>::iterator it = instances_pgp.find(pgpId);
|
||||
if (it != instances_pgp.end())
|
||||
instances_pgp.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
void ConfCertDialog::showIt(const std::string& peer_id, enumPage page)
|
||||
{
|
||||
ConfCertDialog *confdialog = instance(peer_id);
|
||||
|
||||
switch (page) {
|
||||
case PageDetails:
|
||||
confdialog->ui.stabWidget->setCurrentIndex(0);
|
||||
break;
|
||||
case PageTrust:
|
||||
confdialog->ui.stabWidget->setCurrentIndex(1);
|
||||
break;
|
||||
case PageCertificate:
|
||||
confdialog->ui.stabWidget->setCurrentIndex(2);
|
||||
break;
|
||||
}
|
||||
|
||||
confdialog->load();
|
||||
confdialog->show();
|
||||
confdialog->raise();
|
||||
confdialog->activateWindow();
|
||||
|
||||
/* window will destroy itself! */
|
||||
}
|
||||
|
||||
void ConfCertDialog::setServiceFlags()
|
||||
{
|
||||
RsPeerDetails detail;
|
||||
if (!rsPeers->getPeerDetails(mId, detail))
|
||||
return ;
|
||||
ServicePermissionFlags flags(0) ;
|
||||
|
||||
ServicePermissionFlags flags(0) ;
|
||||
if(ui._anonymous_routing_CB->isChecked()) flags = flags | RS_SERVICE_PERM_TURTLE ;
|
||||
if( ui._discovery_CB->isChecked()) flags = flags | RS_SERVICE_PERM_DISCOVERY ;
|
||||
if( ui._forums_channels_CB->isChecked()) flags = flags | RS_SERVICE_PERM_DISTRIB ;
|
||||
if( ui._direct_transfer_CB->isChecked()) flags = flags | RS_SERVICE_PERM_DIRECT_DL ;
|
||||
|
||||
if(ui._anonymous_routing_CB->isChecked()) flags = flags | RS_SERVICE_PERM_TURTLE ;
|
||||
if( ui._discovery_CB->isChecked()) flags = flags | RS_SERVICE_PERM_DISCOVERY ;
|
||||
if( ui._forums_channels_CB->isChecked()) flags = flags | RS_SERVICE_PERM_DISTRIB ;
|
||||
if( ui._direct_transfer_CB->isChecked()) flags = flags | RS_SERVICE_PERM_DIRECT_DL ;
|
||||
|
||||
rsPeers->setServicePermissionFlags(detail.gpg_id,flags) ;
|
||||
rsPeers->setServicePermissionFlags(pgpId,flags) ;
|
||||
}
|
||||
|
||||
void ConfCertDialog::loadAll()
|
||||
{
|
||||
QMap<std::string, ConfCertDialog*>::iterator it;
|
||||
for (it = instances.begin(); it != instances.end(); it++) {
|
||||
it.value()->load();
|
||||
}
|
||||
for(QMap<RsPeerId, ConfCertDialog*>::iterator it = instances_ssl.begin(); it != instances_ssl.end(); it++) it.value()->load();
|
||||
for(QMap<RsPgpId , ConfCertDialog*>::iterator it = instances_pgp.begin(); it != instances_pgp.end(); it++) it.value()->load();
|
||||
}
|
||||
|
||||
void ConfCertDialog::load()
|
||||
{
|
||||
RsPeerDetails detail;
|
||||
if (!rsPeers->getPeerDetails(mId, detail))
|
||||
|
||||
bool ok = false ;
|
||||
|
||||
if(!(rsPeers->getPeerDetails(peerId, detail) || rsPeers->getGPGDetails(pgpId, detail)))
|
||||
{
|
||||
QMessageBox::information(this,
|
||||
tr("RetroShare"),
|
||||
|
@ -163,7 +169,7 @@ void ConfCertDialog::load()
|
|||
return;
|
||||
}
|
||||
|
||||
if(detail.isOnlyGPGdetail && !rsPeers->isKeySupported(mId))
|
||||
if(detail.isOnlyGPGdetail && !rsPeers->isKeySupported(pgpId))
|
||||
{
|
||||
ui.make_friend_button->setEnabled(false) ;
|
||||
ui.make_friend_button->setToolTip(tr("The supplied key algorithm is not supported by RetroShare\n(Only RSA keys are supported at the moment)")) ;
|
||||
|
@ -180,86 +186,92 @@ void ConfCertDialog::load()
|
|||
ui._direct_transfer_CB->setChecked( detail.service_perm_flags & RS_SERVICE_PERM_DIRECT_DL ) ;
|
||||
|
||||
ui.name->setText(QString::fromUtf8(detail.name.c_str()));
|
||||
ui.peerid->setText(QString::fromStdString(detail.id));
|
||||
ui.peerid->setText(QString::fromStdString(detail.id.toStdString()));
|
||||
|
||||
RetroShareLink link;
|
||||
link.createPerson(detail.id);
|
||||
link.createPerson(detail.gpg_id);
|
||||
|
||||
ui.rsid->setText(link.toHtml());
|
||||
ui.pgpfingerprint->setText(misc::fingerPrintStyleSplit(QString::fromStdString(detail.fpr)));
|
||||
ui.pgpfingerprint->setText(misc::fingerPrintStyleSplit(QString::fromStdString(detail.fpr.toStdString())));
|
||||
ui.rsid->setToolTip(link.title());
|
||||
|
||||
if (!detail.isOnlyGPGdetail) {
|
||||
ui.avatar->setId(mId, false);
|
||||
if (!detail.isOnlyGPGdetail)
|
||||
{
|
||||
ui.avatar->setId(peerId);
|
||||
|
||||
ui.loc->setText(QString::fromUtf8(detail.location.c_str()));
|
||||
// Dont Show a timestamp in RS calculate the day
|
||||
ui.lastcontact->setText(DateTime::formatLongDateTime(detail.lastConnect));
|
||||
ui.loc->setText(QString::fromUtf8(detail.location.c_str()));
|
||||
// Dont Show a timestamp in RS calculate the day
|
||||
ui.lastcontact->setText(DateTime::formatLongDateTime(detail.lastConnect));
|
||||
|
||||
/* set retroshare version */
|
||||
std::string version;
|
||||
rsDisc->getPeerVersion(detail.id, version);
|
||||
ui.version->setText(QString::fromStdString(version));
|
||||
/* set retroshare version */
|
||||
std::string version;
|
||||
rsDisc->getPeerVersion(detail.id, version);
|
||||
ui.version->setText(QString::fromStdString(version));
|
||||
|
||||
RsPeerCryptoParams cdet ;
|
||||
if(RsControl::instance()->getPeerCryptoDetails(detail.id,cdet) && cdet.connexion_state!=0)
|
||||
{
|
||||
QString ct ;
|
||||
ct += QString::fromStdString(cdet.cipher_name) ;
|
||||
ct += QString::number(cdet.cipher_bits_1) ;
|
||||
ct += "-"+QString::fromStdString(cdet.cipher_version) ;
|
||||
ui.crypto_info->setText(ct) ;
|
||||
}
|
||||
else
|
||||
ui.crypto_info->setText(tr("Not connected")) ;
|
||||
RsPeerCryptoParams cdet ;
|
||||
if(RsControl::instance()->getPeerCryptoDetails(detail.id,cdet) && cdet.connexion_state!=0)
|
||||
{
|
||||
QString ct ;
|
||||
ct += QString::fromStdString(cdet.cipher_name) ;
|
||||
ct += QString::number(cdet.cipher_bits_1) ;
|
||||
ct += "-"+QString::fromStdString(cdet.cipher_version) ;
|
||||
ui.crypto_info->setText(ct) ;
|
||||
}
|
||||
else
|
||||
ui.crypto_info->setText(tr("Not connected")) ;
|
||||
|
||||
if (detail.isHiddenNode)
|
||||
{
|
||||
/* set local address */
|
||||
ui.localAddress->setText("hidden");
|
||||
ui.localPort -> setValue(0);
|
||||
/* set the server address */
|
||||
ui.extAddress->setText("hidden");
|
||||
ui.extPort -> setValue(0);
|
||||
if (detail.isHiddenNode)
|
||||
{
|
||||
/* set local address */
|
||||
ui.localAddress->setText("hidden");
|
||||
ui.localPort -> setValue(0);
|
||||
/* set the server address */
|
||||
ui.extAddress->setText("hidden");
|
||||
ui.extPort -> setValue(0);
|
||||
|
||||
ui.dynDNS->setText(QString::fromStdString(detail.hiddenNodeAddress));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* set local address */
|
||||
ui.localAddress->setText(QString::fromStdString(detail.localAddr));
|
||||
ui.localPort -> setValue(detail.localPort);
|
||||
/* set the server address */
|
||||
ui.extAddress->setText(QString::fromStdString(detail.extAddr));
|
||||
ui.extPort -> setValue(detail.extPort);
|
||||
|
||||
ui.dynDNS->setText(QString::fromStdString(detail.dyndns));
|
||||
}
|
||||
|
||||
ui.statusline->setText(StatusDefs::connectStateString(detail));
|
||||
ui.dynDNS->setText(QString::fromStdString(detail.hiddenNodeAddress));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* set local address */
|
||||
ui.localAddress->setText(QString::fromStdString(detail.localAddr));
|
||||
ui.localPort -> setValue(detail.localPort);
|
||||
/* set the server address */
|
||||
ui.extAddress->setText(QString::fromStdString(detail.extAddr));
|
||||
ui.extPort -> setValue(detail.extPort);
|
||||
|
||||
ui.ipAddressList->clear();
|
||||
for(std::list<std::string>::const_iterator it(detail.ipAddressList.begin());it!=detail.ipAddressList.end();++it)
|
||||
ui.ipAddressList->addItem(QString::fromStdString(*it));
|
||||
ui.dynDNS->setText(QString::fromStdString(detail.dyndns));
|
||||
}
|
||||
|
||||
ui.loc->show();
|
||||
ui.label_loc->show();
|
||||
ui.statusline->show();
|
||||
ui.label_status->show();
|
||||
ui.lastcontact->show();
|
||||
ui.label_last_contact->show();
|
||||
ui.version->show();
|
||||
ui.label_version->show();
|
||||
ui.statusline->setText(StatusDefs::connectStateString(detail));
|
||||
|
||||
ui.groupBox->show();
|
||||
ui.groupBox_4->show();
|
||||
ui.tabWidget->show();
|
||||
ui.rsid->hide();
|
||||
ui.label_rsid->hide();
|
||||
ui.pgpfingerprint->show();
|
||||
ui.pgpfingerprint_label->show();
|
||||
} else {
|
||||
ui.avatar->setId(mId, true);
|
||||
ui.ipAddressList->clear();
|
||||
for(std::list<std::string>::const_iterator it(detail.ipAddressList.begin());it!=detail.ipAddressList.end();++it)
|
||||
ui.ipAddressList->addItem(QString::fromStdString(*it));
|
||||
|
||||
ui.loc->show();
|
||||
ui.label_loc->show();
|
||||
ui.statusline->show();
|
||||
ui.label_status->show();
|
||||
ui.lastcontact->show();
|
||||
ui.label_last_contact->show();
|
||||
ui.version->show();
|
||||
ui.label_version->show();
|
||||
|
||||
ui.groupBox->show();
|
||||
ui.groupBox_4->show();
|
||||
ui.tabWidget->show();
|
||||
ui.rsid->hide();
|
||||
ui.label_rsid->hide();
|
||||
ui.pgpfingerprint->show();
|
||||
ui.pgpfingerprint_label->show();
|
||||
|
||||
ui.stabWidget->setTabEnabled(2,true) ;
|
||||
ui.stabWidget->setTabEnabled(3,true) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
//ui.avatar->setId(pgpId.toStdString(), true);
|
||||
|
||||
ui.rsid->show();
|
||||
ui.peerid->hide();
|
||||
|
@ -281,6 +293,10 @@ void ConfCertDialog::load()
|
|||
|
||||
ui.groupBox->hide();
|
||||
ui.tabWidget->hide();
|
||||
|
||||
ui.stabWidget->setTabEnabled(2,true) ;
|
||||
ui.stabWidget->setTabEnabled(3,false) ;
|
||||
ui._useOldFormat_CB->setEnabled(false) ;
|
||||
}
|
||||
|
||||
if (detail.gpg_id == rsPeers->getGPGOwnId()) {
|
||||
|
@ -387,7 +403,7 @@ void ConfCertDialog::load()
|
|||
}
|
||||
|
||||
QString text;
|
||||
for(std::list<std::string>::const_iterator it(detail.gpgSigners.begin());it!=detail.gpgSigners.end();++it) {
|
||||
for(std::list<RsPgpId>::const_iterator it(detail.gpgSigners.begin());it!=detail.gpgSigners.end();++it) {
|
||||
link.createPerson(*it);
|
||||
if (link.valid()) {
|
||||
text += link.toHtml() + "<BR>";
|
||||
|
@ -401,7 +417,7 @@ void ConfCertDialog::load()
|
|||
void ConfCertDialog::loadInvitePage()
|
||||
{
|
||||
RsPeerDetails detail;
|
||||
if (!rsPeers->getPeerDetails(mId, detail))
|
||||
if (!rsPeers->getPeerDetails(peerId, detail) && !rsPeers->getGPGDetails(pgpId,detail))
|
||||
{
|
||||
QMessageBox::information(this,
|
||||
tr("RetroShare"),
|
||||
|
@ -409,8 +425,12 @@ void ConfCertDialog::loadInvitePage()
|
|||
close();
|
||||
return;
|
||||
}
|
||||
std::string invite ;
|
||||
|
||||
std::string invite = rsPeers->GetRetroshareInvite(detail.id,ui._shouldAddSignatures_CB->isChecked()) ; // this needs to be a SSL id
|
||||
if(detail.isOnlyGPGdetail)
|
||||
invite = rsPeers->getPGPKey(detail.gpg_id,ui._shouldAddSignatures_CB->isChecked()) ; // this needs to be a SSL id
|
||||
else
|
||||
invite = rsPeers->GetRetroshareInvite(detail.id,ui._shouldAddSignatures_CB->isChecked()) ; // this needs to be a SSL id
|
||||
|
||||
ui.userCertificateText->setReadOnly(true);
|
||||
ui.userCertificateText->setMinimumHeight(200);
|
||||
|
@ -427,9 +447,9 @@ void ConfCertDialog::applyDialog()
|
|||
{
|
||||
std::cerr << "ConfCertDialog::applyDialog() called" << std::endl ;
|
||||
RsPeerDetails detail;
|
||||
if (!rsPeers->getPeerDetails(mId, detail))
|
||||
if (!rsPeers->getPeerDetails(peerId, detail))
|
||||
{
|
||||
if (!rsPeers->getGPGDetails(mId, detail)) {
|
||||
if (!rsPeers->getGPGDetails(pgpId, detail)) {
|
||||
QMessageBox::information(this,
|
||||
tr("RetroShare"),
|
||||
tr("Error : cannot get peer details."));
|
||||
|
@ -441,11 +461,11 @@ void ConfCertDialog::applyDialog()
|
|||
//check the GPG trustlvl
|
||||
if (ui.radioButton_trust_fully->isChecked() && detail.trustLvl != RS_TRUST_LVL_FULL) {
|
||||
//trust has changed to fully
|
||||
rsPeers->trustGPGCertificate(detail.id, RS_TRUST_LVL_FULL);
|
||||
rsPeers->trustGPGCertificate(pgpId, RS_TRUST_LVL_FULL);
|
||||
} else if (ui.radioButton_trust_marginnaly->isChecked() && detail.trustLvl != RS_TRUST_LVL_MARGINAL) {
|
||||
rsPeers->trustGPGCertificate(detail.id, RS_TRUST_LVL_MARGINAL);
|
||||
rsPeers->trustGPGCertificate(pgpId, RS_TRUST_LVL_MARGINAL);
|
||||
} else if (ui.radioButton_trust_never->isChecked() && detail.trustLvl != RS_TRUST_LVL_NEVER) {
|
||||
rsPeers->trustGPGCertificate(detail.id, RS_TRUST_LVL_NEVER);
|
||||
rsPeers->trustGPGCertificate(pgpId, RS_TRUST_LVL_NEVER);
|
||||
}
|
||||
|
||||
if (!detail.isOnlyGPGdetail) {
|
||||
|
@ -466,13 +486,13 @@ void ConfCertDialog::applyDialog()
|
|||
|
||||
/* now we can action the changes */
|
||||
if (localChanged)
|
||||
rsPeers->setLocalAddress(mId, ui.localAddress->text().toStdString(), ui.localPort->value());
|
||||
rsPeers->setLocalAddress(peerId, ui.localAddress->text().toStdString(), ui.localPort->value());
|
||||
|
||||
if (extChanged)
|
||||
rsPeers->setExtAddress(mId,ui.extAddress->text().toStdString(), ui.extPort->value());
|
||||
rsPeers->setExtAddress(peerId,ui.extAddress->text().toStdString(), ui.extPort->value());
|
||||
|
||||
if (dnsChanged)
|
||||
rsPeers->setDynDNS(mId, ui.dynDNS->text().toStdString());
|
||||
rsPeers->setDynDNS(peerId, ui.dynDNS->text().toStdString());
|
||||
|
||||
if(localChanged || extChanged || dnsChanged)
|
||||
emit configChanged();
|
||||
|
@ -486,12 +506,11 @@ void ConfCertDialog::applyDialog()
|
|||
|
||||
void ConfCertDialog::makeFriend()
|
||||
{
|
||||
std::string gpg_id = rsPeers->getGPGId(mId);
|
||||
if (ui.signGPGKeyCheckBox->isChecked()) {
|
||||
rsPeers->signGPGCertificate(gpg_id);
|
||||
rsPeers->signGPGCertificate(pgpId);
|
||||
}
|
||||
|
||||
rsPeers->addFriend(mId, gpg_id);
|
||||
rsPeers->addFriend(peerId, pgpId);
|
||||
setServiceFlags() ;
|
||||
loadAll();
|
||||
|
||||
|
@ -500,8 +519,7 @@ void ConfCertDialog::makeFriend()
|
|||
|
||||
void ConfCertDialog::denyFriend()
|
||||
{
|
||||
std::string gpg_id = rsPeers->getGPGId(mId);
|
||||
rsPeers->removeFriend(gpg_id);
|
||||
rsPeers->removeFriend(pgpId);
|
||||
loadAll();
|
||||
|
||||
emit configChanged();
|
||||
|
@ -509,8 +527,7 @@ void ConfCertDialog::denyFriend()
|
|||
|
||||
void ConfCertDialog::signGPGKey()
|
||||
{
|
||||
std::string gpg_id = rsPeers->getGPGId(mId);
|
||||
if (!rsPeers->signGPGCertificate(gpg_id)) {
|
||||
if (!rsPeers->signGPGCertificate(pgpId)) {
|
||||
QMessageBox::warning ( NULL,
|
||||
tr("Signature Failure"),
|
||||
tr("Maybe password is wrong"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue