* minor changes required to get the gui working with PGP,

* improved NetworkView to show signatures, and friends.

I expect these will be cleaned up later - these were purely functional so i could test pgp.

Enable using RS_USE_PGPSSL in rsiface/rsinit.h
   


git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1266 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2009-05-23 15:13:01 +00:00
parent 5f28f76b07
commit 100cf75439
19 changed files with 695 additions and 208 deletions

View File

@ -9,25 +9,14 @@ UI_DIR = temp/ui
MOC_DIR = temp/moc
################################# Linux ##########################################
# Put lib dir in QMAKE_LFLAGS so it appears before -L/usr/lib
linux-g++ {
OBJECTS_DIR = temp/linux-g++/obj
LIBS += ../../../../lib/linux-g++/libretroshare.a
LIBS += ../../../../lib/linux-g++/libminiupnpc.a
LIBS += ../../../../lib/linux-g++/libssl.a
LIBS += ../../../../lib/linux-g++/libcrypto.a
LIBS += -lQtUiTools
LIBS += -lz
QMAKE_LFLAGS += -L"../../../../lib/linux-g++"
}
linux-g++-64 {
OBJECTS_DIR = temp/linux-g++-64/obj
LIBS += ../../../../lib/linux-g++-64/libretroshare.a
LIBS += ../../../../lib/linux-g++-64/libminiupnpc.a
LIBS += ../../../../lib/linux-g++-64/libssl.a
LIBS += ../../../../lib/linux-g++-64/libcrypto.a
LIBS += -lz
QMAKE_LFLAGS += -L"../../../../lib/linux-g++-64"
}
#################### Cross compilation for windows under Linux ###################
@ -35,15 +24,10 @@ linux-g++-64 {
win32-x-g++ {
OBJECTS_DIR = temp/win32-x-g++/obj
LIBS += ../../../../lib/win32-x-g++/libretroshare.a
LIBS += ../../../../lib/win32-x-g++/libssl.a
LIBS += ../../../../lib/win32-x-g++/libcrypto.a
LIBS += ../../../../lib/win32-x-g++/libminiupnpc.a
LIBS += ../../../../lib/win32-x-g++/libz.a
LIBS += -L${HOME}/.wine/drive_c/pthreads/lib -lpthreadGCE2
LIBS += -lQtUiTools
LIBS += -lws2_32 -luuid -lole32 -liphlpapi -lcrypt32 -gdi32
LIBS += -lole32 -lwinmm
LIBS += -L"../../../../lib/win32-x-g++"
LIBS += -lpthreadGCE2
LIBS += -lws2_32 -luuid -lole32 -liphlpapi -lcrypt32-cygwin -lgdi32
LIBS += -lole32 -lwinmm
DEFINES *= WIN32
@ -80,6 +64,10 @@ macx {
############################## Common stuff ######################################
LIBS += -lretroshare -lminiupnpc -lssl -lcrypto
LIBS += -lz -lgpgme
LIBS += -lQtUiTools
DEPENDPATH += . \
rsiface \
control \
@ -225,6 +213,7 @@ HEADERS += rshare.h \
gui/channels/mySubscriptionsDialog.h \
gui/elastic/graphwidget.h \
gui/elastic/edge.h \
gui/elastic/arrow.h \
gui/elastic/node.h \
gui/NewsFeed.h \
gui/PeersFeed.h \
@ -429,6 +418,7 @@ SOURCES += main.cpp \
gui/channels/mySubscriptionsDialog.cpp \
gui/elastic/graphwidget.cpp \
gui/elastic/edge.cpp \
gui/elastic/arrow.cpp \
gui/elastic/node.cpp \
gui/NewsFeed.cpp \
gui/PeersFeed.cpp \

View File

@ -49,6 +49,28 @@ GenCertDialog::GenCertDialog(QWidget *parent, Qt::WFlags flags)
ui.genName->setFocus(Qt::OtherFocusReason);
#ifdef RS_USE_PGPSSL
/* 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::GetLogins(pgpIds))
{
for(it = pgpIds.begin(); it != pgpIds.end(); it++)
{
const QVariant & userData = QVariant(QString::fromStdString(*it));
std::string name, email;
RsInit::GetLoginDetails(*it, name, email);
std::cerr << "Adding PGPUser: " << name << " id: " << *it << std::endl;
ui.genPGPuser->addItem(QString::fromStdString(name), userData);
}
}
#endif
}
/** Destructor. */
@ -92,7 +114,28 @@ void GenCertDialog::genPerson()
std::string passwd = ui.genPasswd->text().toStdString();
std::string passwd2 = ui.genPasswd2->text().toStdString();
std::string err;
#ifdef RS_USE_PGPSSL
std::string PGPpasswd = ui.genPGPpassword->text().toStdString();
int pgpidx = ui.genPGPuser->currentIndex();
if (pgpidx < 0)
{
/* Message Dialog */
QMessageBox::StandardButton sb = QMessageBox::warning ( NULL,
"Generate ID Failure",
"Missing PGP Certificate",
QMessageBox::Ok);
return;
}
QVariant data = ui.genPGPuser->itemData(pgpidx);
std::string PGPId = (data.toString()).toStdString();
#endif
if (genName.length() >= 3)
{
/* name passes basic test */
@ -125,6 +168,13 @@ void GenCertDialog::genPerson()
return;
}
#ifdef RS_USE_PGPSSL
/* Initialise the PGP user first */
RsInit::LoadGPGPassword(PGPId, PGPpasswd);
#endif
bool okGen = RsInit::RsGenerateCertificate(genName, genOrg, genLoc, genCountry, passwd, err);
if (okGen)

View File

@ -5,8 +5,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>395</width>
<height>392</height>
<width>394</width>
<height>457</height>
</rect>
</property>
<property name="palette" >
@ -499,27 +499,8 @@
<iconset resource="images.qrc" >
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="2" column="0" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" >
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<widget class="QLabel" name="loginLabel" >
<property name="palette" >
<palette>
@ -1006,7 +987,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="1" column="0" >
<item>
<layout class="QGridLayout" >
<property name="margin" >
<number>0</number>
@ -1014,99 +995,96 @@ p, li { white-space: pre-wrap; }
<property name="spacing" >
<number>6</number>
</property>
<item row="5" column="1" colspan="2" >
<widget class="QLineEdit" name="genLoc" />
</item>
<item row="4" column="0" >
<widget class="QLabel" name="label_6" >
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>Organisation:</string>
<string>Name:</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3" >
<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="3" column="0" >
<widget class="QLabel" name="label_9" >
<property name="text" >
<string>Password (Again)</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2" >
<widget class="QLineEdit" name="genPasswd" >
<property name="echoMode" >
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="5" column="0" >
<widget class="QLabel" name="label_7" >
<property name="text" >
<string>Location:</string>
</property>
</widget>
</item>
<item row="7" column="0" colspan="3" >
<widget class="Line" name="line_2" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="4" column="1" colspan="2" >
<widget class="QLineEdit" name="genOrg" />
</item>
<item row="10" column="0" colspan="3" >
<widget class="Line" name="line_3" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="8" column="0" colspan="3" >
<widget class="QCheckBox" name="friendBox" >
<property name="text" >
<string>Load Trusted Certificate (Optional)</string>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2" >
<widget class="QLineEdit" name="genName" />
</item>
<item row="11" column="0" colspan="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>211</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="1" colspan="2" >
<widget class="QLineEdit" name="genPasswd2" >
<property name="echoMode" >
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="2" column="0" >
<item row="6" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Password</string>
</property>
</widget>
</item>
<item row="9" column="0" colspan="2" >
<item row="6" column="1" colspan="2" >
<widget class="QLineEdit" name="genPasswd" >
<property name="echoMode" >
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="7" column="0" >
<widget class="QLabel" name="label_9" >
<property name="text" >
<string>Password (Again)</string>
</property>
</widget>
</item>
<item row="7" column="1" colspan="2" >
<widget class="QLineEdit" name="genPasswd2" >
<property name="echoMode" >
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="8" column="0" >
<widget class="QLabel" name="label_6" >
<property name="text" >
<string>Organisation:</string>
</property>
</widget>
</item>
<item row="8" column="1" colspan="2" >
<widget class="QLineEdit" name="genOrg" />
</item>
<item row="9" column="0" >
<widget class="QLabel" name="label_7" >
<property name="text" >
<string>Location:</string>
</property>
</widget>
</item>
<item row="9" column="1" colspan="2" >
<widget class="QLineEdit" name="genLoc" />
</item>
<item row="10" column="0" >
<widget class="QLabel" name="label_8" >
<property name="text" >
<string>Country:</string>
</property>
</widget>
</item>
<item row="10" column="1" colspan="2" >
<widget class="QLineEdit" name="genCountry" />
</item>
<item row="11" column="0" colspan="3" >
<widget class="Line" name="line_2" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="12" column="0" colspan="3" >
<widget class="QCheckBox" name="friendBox" >
<property name="text" >
<string>Load Trusted Certificate (Optional)</string>
</property>
</widget>
</item>
<item row="13" column="0" colspan="2" >
<layout class="QGridLayout" >
<property name="margin" >
<number>0</number>
@ -1137,33 +1115,91 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</item>
<item row="6" column="0" >
<widget class="QLabel" name="label_8" >
<property name="text" >
<string>Country:</string>
<item row="14" column="0" colspan="3" >
<widget class="Line" name="line_3" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>Name:</string>
</property>
</widget>
</item>
<item row="11" column="2" >
<item row="15" column="2" >
<widget class="QPushButton" name="genButton" >
<property name="text" >
<string>Generate New Certificate</string>
</property>
</widget>
</item>
<item row="6" column="1" colspan="2" >
<widget class="QLineEdit" name="genCountry" />
<item row="15" column="0" colspan="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>211</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1" colspan="2" >
<widget class="QComboBox" name="genPGPuser" />
</item>
<item row="0" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>OpenPGP User</string>
</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="2" >
<widget class="Line" name="line_6" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
<zorder>loginLabel</zorder>
<zorder></zorder>
<zorder></zorder>
<zorder></zorder>
</widget>
<tabstops>
<tabstop>genName</tabstop>

View File

@ -31,6 +31,11 @@
#include "connect/ConnectDialog.h"
#include "rsiface/rsiface.h"
#include "rsiface/rspeers.h"
/* for GPGME */
#include "rsiface/rsinit.h"
#include <gpgme.h>
#include <sstream>
#include <QTimer>
@ -180,6 +185,7 @@ void NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint point )
return ;
if(peer_id != rsPeers->getOwnId())
{
if(detail.state & RS_PEER_STATE_FRIEND)
{
denyFriendAct = new QAction(QIcon(IMAGE_DENIED), tr( "Deny friend" ), this );
@ -205,6 +211,7 @@ void NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint point )
}
#endif
}
}
peerdetailsAct = new QAction(QIcon(IMAGE_PEERDETAILS), tr( "Peer details..." ), this );
connect( peerdetailsAct , SIGNAL( triggered() ), this, SLOT( peerdetails() ) );
@ -446,11 +453,19 @@ void NetworkDialog::insertConnect()
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.trustLvl > 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;

View File

@ -23,6 +23,8 @@
#include "rsiface/rspeers.h"
#include "rsiface/rsdisc.h"
#include <gpgme.h>
#include <QMenu>
#include <QMouseEvent>
#include <QGraphicsItem>
@ -143,60 +145,88 @@ void NetworkView::insertPeers()
/* add all friends */
std::list<std::string> ids;
std::list<std::string>::iterator it;
rsPeers->getOthersList(ids);
rsPeers->getPGPAllList(ids);
std::string ownId = rsPeers->getPGPOwnId();
std::cerr << "NetworkView::insertPeers()" << std::endl;
/* get the list of friends' issuers, as we flag them specially */
std::list<std::string> fids;
rsPeers->getPGPFriendList(fids);
int i = 0;
uint32_t type = 0;
for(it = ids.begin(); it != ids.end(); it++, i++)
{
if (*it == ownId)
{
continue;
}
/* *** */
std::string name = rsPeers->getPeerName(*it);
if (rsPeers->isFriend(*it))
RsPeerDetails detail;
if (!rsPeers->getPeerDetails(*it, detail))
{
type = ELASTIC_NODE_TYPE_FRIEND;
continue;
}
else
switch(detail.trustLvl)
{
RsPeerDetails detail;
rsPeers->getPeerDetails(*it, detail);
if(detail.trustLvl > RS_TRUST_LVL_MARGINAL)
{
type = ELASTIC_NODE_TYPE_AUTHED;
}
else if (detail.trustLvl >= RS_TRUST_LVL_MARGINAL)
{
type = ELASTIC_NODE_TYPE_MARGINALAUTH;
}
else
{
default:
case GPGME_VALIDITY_UNKNOWN:
case GPGME_VALIDITY_UNDEFINED:
case GPGME_VALIDITY_NEVER:
/* lots of fall through */
type = ELASTIC_NODE_TYPE_FOF;
}
}
break;
ui.graphicsView->addNode(type, *it, name);
case GPGME_VALIDITY_MARGINAL:
/* lots of fall through */
type = ELASTIC_NODE_TYPE_MARGINALAUTH;
break;
case GPGME_VALIDITY_FULL:
case GPGME_VALIDITY_ULTIMATE:
/* lots of fall through */
type = ELASTIC_NODE_TYPE_AUTHED;
if (fids.end() != std::find(fids.begin(), fids.end(), *it))
{
type = ELASTIC_NODE_TYPE_FRIEND;
}
break;
}
ui.graphicsView->addNode(type, *it, detail.name);
std::cerr << "NetworkView::insertPeers() Added Friend: " << *it << std::endl;
}
insertConnections();
insertSignatures();
}
void NetworkView::insertConnections()
{
/* iterate through all friends */
std::list<std::string> ids;
std::list<std::string> fids, ids;
std::list<std::string>::iterator it;
std::map<std::string, std::list<std::string> > connLists;
std::string ownId = rsPeers->getOwnId();
rsPeers->getOthersList(ids);
//std::string ownId = rsPeers->getGPGOwnId();
//rsPeers->getPGPAllList(ids);
rsPeers->getPGPFriendList(fids);
std::cerr << "NetworkView::insertConnections()" << std::endl;
// For the moment, only add friends.
for(it = fids.begin(); it != fids.end(); it++)
{
ui.graphicsView->addEdge("", *it);
std::cerr << "NetworkView: Adding Edge: Self -> " << *it;
std::cerr << std::endl;
}
#if 0
int i = 0;
for(it = ids.begin(); it != ids.end(); it++, i++)
{
@ -249,8 +279,44 @@ void NetworkView::insertConnections()
}
}
}
#endif
}
void NetworkView::insertSignatures()
{
/* iterate through all friends */
std::list<std::string> ids;
std::list<std::string>::iterator it, sit;
std::string ownId = rsPeers->getPGPOwnId();
rsPeers->getPGPAllList(ids);
std::cerr << "NetworkView::insertSignatures()" << std::endl;
int i = 0;
for(it = ids.begin(); it != ids.end(); it++, i++)
{
RsPeerDetails detail;
if (!rsPeers->getPeerDetails(*it, detail))
{
continue;
}
for(sit = detail.signers.begin(); sit != detail.signers.end(); sit++)
{
if (*it != *sit)
{
std::cerr << "NetworkView: Adding Arrow: ";
std::cerr << *sit << " <-> " << *it;
std::cerr << std::endl;
ui.graphicsView->addArrow(*sit, *it);
}
}
}
}
void NetworkView::changedScene()
{

View File

@ -42,6 +42,7 @@ private slots:
void peerCustomPopupMenu( QPoint point );
void insertPeers();
void insertSignatures();
void insertConnections();
void changedScene();

View File

@ -70,17 +70,38 @@ StartDialog::StartDialog(QWidget *parent, Qt::WFlags flags)
/* load the Certificate File name */
std::string userName;
#ifdef RS_USE_PGPSSL
/* get all available pgp private certificates....
* mark last one as default.
*/
std::list<std::string> pgpIds;
std::list<std::string>::iterator it;
if (RsInit::GetLogins(pgpIds))
{
for(it = pgpIds.begin(); it != pgpIds.end(); it++)
{
const QVariant & userData = QVariant(QString::fromStdString(*it));
std::string name, email;
RsInit::GetLoginDetails(*it, name, email);
ui.loadName->addItem(QString::fromStdString(name), userData);
}
}
#else
if (RsInit::ValidateCertificate(userName))
{
/* just need to enter password */
ui.loadName->setText(QString::fromStdString(userName));
ui.loadName->addItem(QString::fromStdString(userName));
//ui.loadName->setText(QString::fromStdString(userName));
ui.loadPasswd->setFocus(Qt::OtherFocusReason);
ui.loadButton -> setEnabled(true);
}
else
{
/* need to generate new user */
ui.loadName->setText("<No Existing User>");
ui.loadName->addItem("<No Existing User>");
//ui.loadName->setText("<No Existing User>");
ui.loadButton -> setEnabled(false);
//ui.genName->setFocus(Qt::OtherFocusReason);
}
@ -88,6 +109,8 @@ StartDialog::StartDialog(QWidget *parent, Qt::WFlags flags)
ui.autoBox->setChecked(false) ;
ui.autoBox->setEnabled(false) ;
#endif
#endif
//ui.genFriend -> setText("<None Selected>");
}
@ -124,6 +147,26 @@ void StartDialog::closeinfodlg()
void StartDialog::loadPerson()
{
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)
{
/* Message Dialog */
QMessageBox::StandardButton sb = QMessageBox::warning ( NULL,
"Load Person Failure",
"Missing PGP Certificate",
QMessageBox::Ok);
return;
}
QVariant data = ui.loadName->itemData(pgpidx);
std::string PGPId = (data.toString()).toStdString();
RsInit::LoadGPGPassword(PGPId, gpgPasswd);
#else
#endif
RsInit::LoadPassword(passwd);
loadCertificates();
}

View File

@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>268</width>
<height>535</height>
<height>627</height>
</rect>
</property>
<property name="palette" >
@ -638,7 +638,7 @@ p, li { white-space: pre-wrap; }
<string>Generate now a Profile</string>
</property>
<property name="text" >
<string>generate now a profile</string>
<string>generate new a profile</string>
</property>
<property name="flat" >
<bool>false</bool>
@ -658,19 +658,6 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="1" column="0" colspan="2" >
<widget class="QLineEdit" name="loadName" >
<property name="minimumSize" >
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="readOnly" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2" >
<widget class="QLabel" name="label_4" >
<property name="text" >
@ -694,7 +681,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="4" column="0" >
<item row="6" column="0" >
<widget class="QCheckBox" name="autoBox" >
<property name="text" >
<string>Auto-login</string>
@ -704,7 +691,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="4" column="1" >
<item row="6" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
@ -717,6 +704,19 @@ p, li { white-space: pre-wrap; }
</property>
</spacer>
</item>
<item row="1" column="0" colspan="2" >
<widget class="QComboBox" name="loadName" />
</item>
<item row="5" column="0" colspan="2" >
<widget class="QLineEdit" name="loadGPGPasswd" />
</item>
<item row="4" column="0" >
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>PGP Password</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -802,7 +802,6 @@ p, li { white-space: pre-wrap; }
</widget>
</widget>
<tabstops>
<tabstop>loadName</tabstop>
<tabstop>loadPasswd</tabstop>
<tabstop>autoBox</tabstop>
<tabstop>loadButton</tabstop>

View File

@ -156,6 +156,7 @@ TextPage::TextPage(QWidget *parent)
userCertLabel = new QLabel(tr("The text below is your XPGP certificate. "
"You have to provide it to your friend "));
std::cerr << "TextPage() getting Invite" << std::endl;
userCertEdit = new QTextEdit;
std::string invite = rsPeers->GetRetroshareInvite();
@ -178,6 +179,8 @@ TextPage::TextPage(QWidget *parent)
userCertEdit->setReadOnly(true);
userCertEdit->setMinimumHeight(200);
std::cerr << "TextPage() getting Invite: " << invite << std::endl;
userCertHelpButton = new QPushButton;
userCertHelpButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
userCertHelpButton->setFixedSize(20,20);

View File

@ -0,0 +1,139 @@
/****************************************************************************
**
** Copyright (C) 2006-2007 Trolltech ASA. All rights reserved.
**
** This file is part of the example classes of the Qt Toolkit.
**
** This file may be used under the terms of the GNU General Public
** License version 2.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of
** this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
** http://trolltech.com/products/qt/licenses/licensing/opensource/
**
** If you are unsure which license is appropriate for your use, please
** review the following information:
** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
** or contact the sales department at sales@trolltech.com.
**
** In addition, as a special exception, Trolltech gives you certain
** additional rights. These rights are described in the Trolltech GPL
** Exception version 1.0, which can be found at
** http://www.trolltech.com/products/qt/gplexception/ and in the file
** GPL_EXCEPTION.txt in this package.
**
** In addition, as a special exception, Trolltech, as the sole copyright
** holder for Qt Designer, grants users of the Qt/Eclipse Integration
** plug-in the right for the Qt/Eclipse Integration to link to
** functionality provided by Qt Designer and its related libraries.
**
** Trolltech reserves all rights not expressly granted herein.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/
#include <QPainter>
#include "arrow.h"
#include "node.h"
#include <math.h>
static const double Pi = 3.14159265358979323846264338327950288419717;
static double TwoPi = 2.0 * Pi;
Arrow::Arrow(Node *sourceNode, Node *destNode)
: arrowSize(10)
{
setAcceptedMouseButtons(0);
source = sourceNode;
dest = destNode;
source->addArrow(this);
dest->addArrow(this);
adjust();
}
Arrow::~Arrow()
{
}
Node *Arrow::sourceNode() const
{
return source;
}
void Arrow::setSourceNode(Node *node)
{
source = node;
adjust();
}
Node *Arrow::destNode() const
{
return dest;
}
void Arrow::setDestNode(Node *node)
{
dest = node;
adjust();
}
void Arrow::adjust()
{
if (!source || !dest)
return;
QLineF line(mapFromItem(source, 0, 0), mapFromItem(dest, 0, 0));
qreal length = line.length();
QPointF edgeOffset((line.dx() * 10) / length, (line.dy() * 10) / length);
prepareGeometryChange();
sourcePoint = line.p1() + edgeOffset;
destPoint = line.p2() - edgeOffset;
}
QRectF Arrow::boundingRect() const
{
if (!source || !dest)
return QRectF();
qreal penWidth = 1;
qreal extra = (penWidth + arrowSize) / 2.0;
return QRectF(sourcePoint, QSizeF(destPoint.x() - sourcePoint.x(),
destPoint.y() - sourcePoint.y()))
.normalized()
.adjusted(-extra, -extra, extra, extra);
}
void Arrow::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
if (!source || !dest)
return;
// Draw the line itself
QLineF line(sourcePoint, destPoint);
painter->setPen(QPen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
painter->drawLine(line);
// Draw the arrows if there's enough room
double angle = ::acos(line.dx() / line.length());
if (line.dy() >= 0)
angle = TwoPi - angle;
QPointF sourceArrowP1 = sourcePoint + QPointF(sin(angle + Pi / 3) * arrowSize,
cos(angle + Pi / 3) * arrowSize);
QPointF sourceArrowP2 = sourcePoint + QPointF(sin(angle + Pi - Pi / 3) * arrowSize,
cos(angle + Pi - Pi / 3) * arrowSize);
QPointF destArrowP1 = destPoint + QPointF(sin(angle - Pi / 3) * arrowSize,
cos(angle - Pi / 3) * arrowSize);
QPointF destArrowP2 = destPoint + QPointF(sin(angle - Pi + Pi / 3) * arrowSize,
cos(angle - Pi + Pi / 3) * arrowSize);
painter->setBrush(Qt::black);
painter->drawPolygon(QPolygonF() << line.p1() << sourceArrowP1 << sourceArrowP2);
painter->drawPolygon(QPolygonF() << line.p2() << destArrowP1 << destArrowP2);
}

View File

@ -0,0 +1,73 @@
/****************************************************************************
**
** Copyright (C) 2006-2007 Trolltech ASA. All rights reserved.
**
** This file is part of the example classes of the Qt Toolkit.
**
** This file may be used under the terms of the GNU General Public
** License version 2.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of
** this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
** http://trolltech.com/products/qt/licenses/licensing/opensource/
**
** If you are unsure which license is appropriate for your use, please
** review the following information:
** http://trolltech.com/products/qt/licenses/licensing/licensingoverview
** or contact the sales department at sales@trolltech.com.
**
** In addition, as a special exception, Trolltech gives you certain
** additional rights. These rights are described in the Trolltech GPL
** Exception version 1.0, which can be found at
** http://www.trolltech.com/products/qt/gplexception/ and in the file
** GPL_EXCEPTION.txt in this package.
**
** In addition, as a special exception, Trolltech, as the sole copyright
** holder for Qt Designer, grants users of the Qt/Eclipse Integration
** plug-in the right for the Qt/Eclipse Integration to link to
** functionality provided by Qt Designer and its related libraries.
**
** Trolltech reserves all rights not expressly granted herein.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/
#ifndef ARROW_H
#define ARROW_H
#include <QGraphicsItem>
class Node;
class Arrow : public QGraphicsItem
{
public:
Arrow(Node *sourceNode, Node *destNode);
~Arrow();
Node *sourceNode() const;
void setSourceNode(Node *node);
Node *destNode() const;
void setDestNode(Node *node);
void adjust();
enum { Type = UserType + 2 };
int type() const { return Type; }
protected:
QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
private:
Node *source, *dest;
QPointF sourcePoint;
QPointF destPoint;
qreal arrowSize;
};
#endif

View File

@ -36,6 +36,7 @@
#include "graphwidget.h"
#include "edge.h"
#include "arrow.h"
#include "node.h"
#include <QDebug>
@ -96,26 +97,10 @@ bool GraphWidget::clearGraph()
delete oldscene;
}
if (oldcenterNode)
{
//delete oldcenterNode;
}
nodeMap.clear();
edgeList.clear();
std::list<Edge *>::iterator eit;
std::map<std::string, Node *>::iterator it;
for(eit = edgeList.begin(); eit != edgeList.end(); eit++)
{
//delete(*eit);
}
for(it = nodeMap.begin(); it != nodeMap.end(); it++)
{
//delete(it->second);
}
nodeMap.clear();
edgeList.clear();
return true;
return true;
}
void GraphWidget::addNode(uint32_t type, std::string id, std::string name)
@ -161,10 +146,43 @@ void GraphWidget::addEdge(std::string id1, std::string id2)
}
}
void GraphWidget::addArrow(std::string id1, std::string id2)
{
std::map<std::string, Node *>::iterator it;
Node *n1 = NULL;
Node *n2 = NULL;
if (id1 == "")
{
n1 = centerNode;
}
else
{
it = nodeMap.find(id1);
if (it != nodeMap.end())
{
n1 = it->second;
}
}
it = nodeMap.find(id2);
if (it != nodeMap.end())
{
n2 = it->second;
}
if ((n1) && (n2))
{
Arrow *arrow = new Arrow(n1, n2);
scene()->addItem(arrow);
arrowList.push_back(arrow);
}
}
void GraphWidget::itemMoved()
{
if (!timerId)
timerId = startTimer(1000 / 25);
timerId = startTimer(1000 / 10);
}
void GraphWidget::keyPressEvent(QKeyEvent *event)

View File

@ -44,6 +44,7 @@
class Node;
class Edge;
class Arrow;
class GraphWidget : public QGraphicsView
{
@ -57,6 +58,7 @@ public:
bool clearGraph();
void addNode(uint32_t type, std::string id, std::string name);
void addEdge(std::string id1, std::string id2);
void addArrow(std::string id1, std::string id2);
protected:
void keyPressEvent(QKeyEvent *event);
@ -72,6 +74,7 @@ private:
std::map<std::string, Node *> nodeMap;
std::list<Edge *> edgeList;
std::list<Arrow *> arrowList;
};
#endif

View File

@ -41,6 +41,7 @@
#include <QMenu>
#include "edge.h"
#include "arrow.h"
#include "node.h"
#include "graphwidget.h"
#include <math.h>
@ -65,6 +66,17 @@ QList<Edge *> Node::edges() const
return edgeList;
}
void Node::addArrow(Arrow *arrow)
{
arrowList << arrow;
arrow->adjust();
}
QList<Arrow *> Node::arrows() const
{
return arrowList;
}
void Node::calculateForces()
{
if (!scene() || scene()->mouseGrabberItem() == this) {
@ -103,6 +115,20 @@ void Node::calculateForces()
yvel += pos.y() / weight;
}
// Now subtract all forces pulling items together
// alternative weight??
weight = sqrt(arrowList.size() + 1) * 10;
foreach (Arrow *arrow, arrowList) {
QPointF pos;
if (arrow->sourceNode() == this)
pos = mapFromItem(arrow->destNode(), 0, 0);
else
pos = mapFromItem(arrow->sourceNode(), 0, 0);
xvel += pos.x() / weight;
yvel += pos.y() / weight;
}
// push away from edges too.
QRectF sceneRect = scene()->sceneRect();
int mid_x = (sceneRect.left() + sceneRect.right()) / 2;

View File

@ -50,6 +50,7 @@
#define ELASTIC_NODE_TYPE_FOF 5
class Edge;
class Arrow;
class GraphWidget;
class QGraphicsSceneMouseEvent;
@ -61,6 +62,9 @@ public:
void addEdge(Edge *edge);
QList<Edge *> edges() const;
void addArrow(Arrow *arrow);
QList<Arrow *> arrows() const;
enum { Type = UserType + 1 };
int type() const { return Type; }
@ -80,6 +84,7 @@ protected:
private:
QList<Edge *> edgeList;
QList<Arrow *> arrowList;
QPointF newPos;
GraphWidget *graph;

View File

@ -556,7 +556,7 @@ RemoteDirModel::RemoteDirModel(bool mode, QObject *parent)
std::list<DirStub>::iterator it;
int i = 0;
for(it = details.children.begin();
(i < row) && (it != details.children.end()); it++, i++);
((i < row) && (it != details.children.end())); it++, i++) ;
if (it == details.children.end())
{

View File

@ -1,5 +1,9 @@
/* Initialisation Class (not publicly disclosed to RsIFace) */
/****
* #define RS_USE_PGPSSL 1
***/
class RsInit
{
public:
@ -7,6 +11,7 @@ class RsInit
static const char *RsConfigDirectory() ;
static bool setStartMinimised() ;
static int InitRetroShare(int argcIgnored, char **argvIgnored) ;
static int LoadCertificates(bool autoLoginNT) ;
@ -23,6 +28,16 @@ class RsInit
static std::string getHomePath() ;
/* PGPSSL init functions */
#ifdef RS_USE_PGPSSL
static bool LoadGPGPassword(std::string id, std::string passwd);
static int GetLogins(std::list<std::string> &pgpIds);
static int GetLoginDetails(std::string id, std::string &name, std::string &email);
static std::string gpgPasswd;
#endif
/* Key Parameters that must be set before
* RetroShare will start up:
*/

View File

@ -31,7 +31,7 @@
#include <list>
#include <iostream>
#include <string>
#include <stdint.h>
class RsNotify;
extern RsNotify *rsNotify;
@ -107,7 +107,7 @@ virtual bool NotifySysMessage(uint32_t &sysid, uint32_t &type,
std::string &title, std::string &msg) = 0;
virtual bool NotifyPopupMessage(uint32_t &ptype, std::string &name, std::string &msg) = 0;
virtual bool NotifyLogMessage(uint32_t &sysid, uint32_t &type,
std::string &title, std::string &msg) = 0;
std::string &title, std::string &msg) = 0;
/* Control over Messages */
virtual bool GetSysMessageList(std::map<uint32_t, std::string> &list) = 0;

View File

@ -78,7 +78,7 @@ class RsPeerDetails
std::string location;
std::string org;
std::string fpr; /* fingerprint */
std::string fpr; /* pgp fingerprint */
std::string authcode;
std::list<std::string> signers;
@ -130,6 +130,11 @@ virtual bool isFriend(std::string id) = 0;
virtual std::string getPeerName(std::string id) = 0;
virtual bool getPeerDetails(std::string id, RsPeerDetails &d) = 0;
/* Using PGP Ids */
virtual std::string getPGPOwnId() = 0;
virtual bool getPGPFriendList(std::list<std::string> &ids) = 0;
virtual bool getPGPAllList(std::list<std::string> &ids) = 0;
/* Add/Remove Friends */
virtual bool addFriend(std::string id) = 0;
virtual bool removeFriend(std::string id) = 0;