mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-23 00:01:21 -04:00
Commit of the new UDP Connection methods and
the rewrite of the retroshare core networking stack. This check-in commits the changes to the GUI code. Changes to use the new rspeers.h interface to the retroshare core. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@316 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
c7ce92aba2
commit
c4e1d73837
22 changed files with 651 additions and 486 deletions
|
@ -21,6 +21,8 @@
|
|||
#include "AddFriendDialog.h"
|
||||
|
||||
#include "rsiface/rsiface.h"
|
||||
#include "rsiface/rspeers.h"
|
||||
|
||||
#include "gui/NetworkDialog.h"
|
||||
#include <util/WidgetBackgroundImage.h>
|
||||
|
||||
|
@ -53,7 +55,7 @@ void AddFriendDialog::donebutton()
|
|||
std::string certstr = ui.emailText->toPlainText().toStdString();
|
||||
|
||||
/* ask retroshare to load */
|
||||
if ((cDialog) && (rsicontrol -> NeighLoadPEMString(certstr, id)))
|
||||
if ((cDialog) && (rsPeers->LoadCertificateFromString(certstr, id)))
|
||||
{
|
||||
close();
|
||||
cDialog->showpeerdetails(id);
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "ConfCertDialog.h"
|
||||
|
||||
#include "rsiface/rsiface.h"
|
||||
#include "rsiface/rspeers.h"
|
||||
|
||||
/* Define the format used for displaying the date and time */
|
||||
#define DATETIME_FMT "MMM dd hh:mm:ss"
|
||||
|
@ -74,43 +75,43 @@ void ConfCertDialog::loadId(std::string id)
|
|||
|
||||
void ConfCertDialog::loadDialog()
|
||||
{
|
||||
/* open up the rsiface and get the data */
|
||||
/* get the shared directories */
|
||||
rsiface->lockData(); /* Lock Interface */
|
||||
|
||||
/* get the correct friend */
|
||||
const NeighbourInfo *ni = rsiface->getFriend(mId);
|
||||
if (!ni)
|
||||
RsPeerDetails detail;
|
||||
if (!rsPeers->getPeerDetails(mId, detail))
|
||||
{
|
||||
/* fail */
|
||||
rsiface->unlockData(); /* UnLock Interface */
|
||||
return;
|
||||
}
|
||||
|
||||
ui.name->setText(QString::fromStdString(ni -> name));
|
||||
ui.orgloc->setText(QString::fromStdString(ni -> org + "/" + ni -> loc));
|
||||
ui.country->setText(QString::fromStdString(ni -> country + "/" + ni -> state));
|
||||
ui.name->setText(QString::fromStdString(detail.name));
|
||||
ui.orgloc->setText(QString::fromStdString(detail.org));
|
||||
ui.country->setText(QString::fromStdString(detail.location));
|
||||
|
||||
/* set local address */
|
||||
ui.localAddress->setText(QString::fromStdString(ni->localAddr));
|
||||
ui.localPort -> setValue(ni->localPort);
|
||||
ui.localAddress->setText(QString::fromStdString(detail.localAddr));
|
||||
ui.localPort -> setValue(detail.localPort);
|
||||
/* set the server address */
|
||||
ui.extAddress->setText(QString::fromStdString(ni->extAddr));
|
||||
ui.extPort -> setValue(ni->extPort);
|
||||
/* set the url for DNS access */
|
||||
ui.extName->setText(QString::fromStdString(ni->extName));
|
||||
ui.chkFirewall ->setChecked(ni->firewalled);
|
||||
ui.chkForwarded ->setChecked(ni->forwardPort);
|
||||
ui.extAddress->setText(QString::fromStdString(detail.extAddr));
|
||||
ui.extPort -> setValue(detail.extPort);
|
||||
|
||||
/* set the url for DNS access (OLD) */
|
||||
ui.extName->setText(QString::fromStdString(""));
|
||||
|
||||
/**** TODO ****/
|
||||
//ui.chkFirewall ->setChecked(ni->firewalled);
|
||||
//ui.chkForwarded ->setChecked(ni->forwardPort);
|
||||
ui.chkFirewall ->setChecked(0);
|
||||
ui.chkForwarded ->setChecked(0);
|
||||
|
||||
ui.indivRate->setValue(ni->maxRate);
|
||||
ui.indivRate->setValue(0);
|
||||
|
||||
ui.trustLvl->setText(QString::fromStdString(ni->trustString));
|
||||
ui.trustLvl->setText(QString::fromStdString(RsPeerTrustString(detail.trustLvl)));
|
||||
|
||||
if (ni->ownsign)
|
||||
if (detail.ownsign)
|
||||
{
|
||||
ui.signBox -> setCheckState(Qt::Checked);
|
||||
ui.signBox -> setEnabled(false);
|
||||
if (ni->trustLvl == 5) /* 5 = Trusted, 6 = OwnSign */
|
||||
if (detail.trusted)
|
||||
{
|
||||
ui.trustBox -> setCheckState(Qt::Checked);
|
||||
}
|
||||
|
@ -128,60 +129,44 @@ void ConfCertDialog::loadDialog()
|
|||
ui.trustBox -> setCheckState(Qt::Unchecked);
|
||||
ui.trustBox -> setEnabled(false);
|
||||
}
|
||||
|
||||
rsiface->unlockData(); /* UnLock Interface */
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ConfCertDialog::applyDialog()
|
||||
{
|
||||
/* open up the rsiface and get the data */
|
||||
/* get the shared directories */
|
||||
rsiface->lockData(); /* Lock Interface */
|
||||
|
||||
/* get the correct friend */
|
||||
const NeighbourInfo *ni = rsiface->getFriend(mId);
|
||||
if (!ni)
|
||||
RsPeerDetails detail;
|
||||
if (!rsPeers->getPeerDetails(mId, detail))
|
||||
{
|
||||
/* fail */
|
||||
rsiface->unlockData(); /* UnLock Interface */
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* check if the data is the same */
|
||||
bool localChanged = false;
|
||||
bool extChanged = false;
|
||||
bool fwChanged = false;
|
||||
bool dnsChanged = false;
|
||||
bool signChanged = false;
|
||||
bool trustChanged = false;
|
||||
|
||||
/* set local address */
|
||||
if ((ni->localAddr != ui.localAddress->text().toStdString())
|
||||
|| (ni->localPort != ui.localPort -> value()))
|
||||
if ((detail.localAddr != ui.localAddress->text().toStdString())
|
||||
|| (detail.localPort != ui.localPort -> value()))
|
||||
{
|
||||
/* changed ... set it */
|
||||
localChanged = true;
|
||||
}
|
||||
|
||||
if ((ni->extAddr != ui.extAddress->text().toStdString())
|
||||
|| (ni->extPort != ui.extPort -> value()))
|
||||
if ((detail.extAddr != ui.extAddress->text().toStdString())
|
||||
|| (detail.extPort != ui.extPort -> value()))
|
||||
{
|
||||
/* changed ... set it */
|
||||
extChanged = true;
|
||||
}
|
||||
|
||||
if (ni->extName != ui.extName->text().toStdString())
|
||||
{
|
||||
/* changed ... set it */
|
||||
dnsChanged = true;
|
||||
}
|
||||
|
||||
if ((ni->firewalled != ui.chkFirewall ->isChecked()) ||
|
||||
(ni->forwardPort != ui.chkForwarded ->isChecked()))
|
||||
#if 0
|
||||
if ((detail.firewalled != ui.chkFirewall ->isChecked()) ||
|
||||
(detail.forwardPort != ui.chkForwarded ->isChecked()))
|
||||
{
|
||||
/* changed ... set it */
|
||||
fwChanged = true;
|
||||
|
@ -191,13 +176,11 @@ void ConfCertDialog::applyDialog()
|
|||
{
|
||||
/* nada */
|
||||
}
|
||||
#endif
|
||||
|
||||
if (ni->ownsign)
|
||||
if (detail.ownsign)
|
||||
{
|
||||
/* check the trust tick */
|
||||
bool trsted = (ni->trustLvl == 5); /* 5 = Trusted, 6 = OwnSign */
|
||||
|
||||
if (trsted != ui.trustBox->isChecked())
|
||||
if (detail.trusted != ui.trustBox->isChecked())
|
||||
{
|
||||
trustChanged = true;
|
||||
}
|
||||
|
@ -210,30 +193,26 @@ void ConfCertDialog::applyDialog()
|
|||
}
|
||||
}
|
||||
|
||||
rsiface->unlockData(); /* UnLock Interface */
|
||||
|
||||
|
||||
/* now we can action the changes */
|
||||
if (localChanged)
|
||||
rsicontrol -> FriendSetLocalAddress(mId,
|
||||
rsPeers->setLocalAddress(mId,
|
||||
ui.localAddress->text().toStdString(), ui.localPort->value());
|
||||
|
||||
if (extChanged)
|
||||
rsicontrol -> FriendSetExtAddress(mId,
|
||||
rsPeers->setExtAddress(mId,
|
||||
ui.extAddress->text().toStdString(), ui.extPort->value());
|
||||
|
||||
if (dnsChanged)
|
||||
rsicontrol -> FriendSetDNSAddress(mId, ui.extName->text().toStdString());
|
||||
|
||||
#if 0
|
||||
if (fwChanged)
|
||||
rsicontrol -> FriendSetFirewall(mId, ui.chkFirewall->isChecked(),
|
||||
ui.chkForwarded->isChecked());
|
||||
#endif
|
||||
|
||||
if (trustChanged)
|
||||
rsicontrol -> FriendTrustSignature(mId, ui.trustBox->isChecked());
|
||||
rsPeers->TrustCertificate(mId, ui.trustBox->isChecked());
|
||||
|
||||
if (signChanged)
|
||||
rsicontrol -> FriendSignCert(mId);
|
||||
rsPeers->SignCertificate(mId);
|
||||
|
||||
/* reload now */
|
||||
loadDialog();
|
||||
|
|
|
@ -25,7 +25,9 @@
|
|||
#include "ConnectDialog.h"
|
||||
|
||||
#include "rsiface/rsiface.h"
|
||||
#include "rsiface/rspeers.h"
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
/** Default constructor */
|
||||
ConnectDialog::ConnectDialog(QWidget *parent, Qt::WFlags flags)
|
||||
|
@ -124,8 +126,8 @@ void ConnectDialog::authAttempt()
|
|||
|
||||
/* well lets do it ! */
|
||||
std::cerr << "Attempting AuthCode:" << authCode << std::endl;
|
||||
rsicontrol -> NeighAuthFriend(authId, authCode);
|
||||
rsicontrol -> NeighAddFriend(authId);
|
||||
rsPeers->AuthCertificate(authId, authCode);
|
||||
rsPeers->addFriend(authId);
|
||||
|
||||
/* close it up! */
|
||||
closeinfodlg();
|
||||
|
@ -133,42 +135,44 @@ void ConnectDialog::authAttempt()
|
|||
|
||||
bool ConnectDialog::loadPeer(std::string id)
|
||||
{
|
||||
std::map<RsCertId,NeighbourInfo>::const_iterator it;
|
||||
/* first grab the list of signers (outside lock) */
|
||||
|
||||
char signerstr[1024];
|
||||
rsicontrol->NeighGetSigners(id, signerstr, 1024);
|
||||
|
||||
/* XXX NOTE We must copy the char * to a string,
|
||||
* otherwise it get trampled on by the it = find(id).
|
||||
* ( DONT KNOW WHY???? ) under mingw.
|
||||
*/
|
||||
|
||||
std::string signersString;
|
||||
signersString = signerstr;
|
||||
|
||||
/* grab the interface and check person */
|
||||
rsiface->lockData(); /* Lock Interface */
|
||||
|
||||
const std::map<RsCertId,NeighbourInfo> &neighs =
|
||||
rsiface->getNeighbourMap();
|
||||
|
||||
it = neighs.find(id);
|
||||
|
||||
if (it == neighs.end())
|
||||
RsPeerDetails detail;
|
||||
if (!rsPeers->getPeerDetails(id, detail))
|
||||
{
|
||||
rsiface->unlockData(); /* UnLock Interface */
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string trustString;
|
||||
|
||||
switch(detail.trustLvl)
|
||||
{
|
||||
case RS_TRUST_LVL_GOOD:
|
||||
trustString = "Good";
|
||||
break;
|
||||
case RS_TRUST_LVL_MARGINAL:
|
||||
trustString = "Marginal";
|
||||
break;
|
||||
case RS_TRUST_LVL_UNKNOWN:
|
||||
default:
|
||||
trustString = "No Trust";
|
||||
break;
|
||||
}
|
||||
|
||||
std::ostringstream out;
|
||||
|
||||
std::list<std::string>::iterator it;
|
||||
for(it = detail.signers.begin(); it != detail.signers.end(); it++)
|
||||
{
|
||||
out << rsPeers->getPeerName(*it) << " <" << *it << ">";
|
||||
out << std::endl;
|
||||
}
|
||||
|
||||
/* setup the gui */
|
||||
setInfo(it->second.name, it->second.trustString, it->second.org,
|
||||
it->second.loc, it->second.country, signersString);
|
||||
setInfo(detail.name, trustString, detail.org,
|
||||
detail.location, detail.email, out.str());
|
||||
|
||||
setAuthCode(id, it->second.authCode);
|
||||
setAuthCode(id, detail.authcode);
|
||||
|
||||
rsiface->unlockData(); /* UnLock Interface */
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue