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:
drbob 2008-01-25 08:49:40 +00:00
parent c7ce92aba2
commit c4e1d73837
22 changed files with 651 additions and 486 deletions

View File

@ -24,6 +24,8 @@
#include "ChatDialog.h" #include "ChatDialog.h"
#include "rsiface/rsiface.h" #include "rsiface/rsiface.h"
#include "rsiface/rspeers.h"
#include "chat/PopupChatDialog.h" #include "chat/PopupChatDialog.h"
#include <sstream> #include <sstream>
@ -247,53 +249,36 @@ void ChatDialog::sendMsg()
void ChatDialog::insertSendList() void ChatDialog::insertSendList()
{ {
rsiface->lockData(); /* Lock Interface */ std::list<std::string> peers;
std::list<std::string>::iterator it;
std::map<RsCertId,NeighbourInfo>::const_iterator it; if (!rsPeers)
const std::map<RsCertId,NeighbourInfo> &friends = {
rsiface->getFriendMap(); /* not ready yet! */
return;
}
rsPeers->getOnlineList(peers);
/* get a link to the table */ /* get a link to the table */
QTreeWidget *sendWidget = ui.msgSendList; QTreeWidget *sendWidget = ui.msgSendList;
QList<QTreeWidgetItem *> items;
/* remove old items ??? */ for(it = peers.begin(); it != peers.end(); it++)
sendWidget->clear();
sendWidget->setColumnCount(1);
QList<QTreeWidgetItem *> items;
for(it = friends.begin(); it != friends.end(); it++)
{ {
/* if offline, don't add */
if ((it -> second.connectString == "Online" ) || RsPeerDetails details;
(it -> second.connectString == "Yourself")) if (!rsPeers->getPeerDetails(*it, details))
{ {
/* ok */ continue; /* BAD */
}
else
{
continue;
} }
/* make a widget per friend */ /* make a widget per friend */
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0); QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
/* add all the labels */ /* add all the labels */
/* (0) Person */ /* (0) Person */
item -> setText(0, QString::fromStdString(it->second.name)); item -> setText(0, QString::fromStdString(details.name));
/* () Org */
//item -> setText(1, QString::fromStdString(it->second.org));
/* () Location */
//item -> setText(2, QString::fromStdString(it->second.loc));
/* () Country */
//item -> setText(3, QString::fromStdString(it->second.country));
/*{
std::ostringstream out;
out << it->second.id;
item -> setText(4, QString::fromStdString(out.str()));
}*/
//item -> setText(5, "Friend");
//item -> setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); //item -> setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
item -> setFlags(Qt::ItemIsUserCheckable); item -> setFlags(Qt::ItemIsUserCheckable);
@ -309,17 +294,17 @@ void ChatDialog::insertSendList()
item -> setCheckState(0, Qt::Unchecked); item -> setCheckState(0, Qt::Unchecked);
} }
************/ ************/
/* add to the list */ /* add to the list */
items.append(item); items.append(item);
} }
/* remove old items */
sendWidget->clear();
sendWidget->setColumnCount(1);
/* add the items in! */ /* add the items in! */
sendWidget->insertTopLevelItems(0, items); sendWidget->insertTopLevelItems(0, items);
rsiface->unlockData(); /* UnLock Interface */
sendWidget->update(); /* update display */ sendWidget->update(); /* update display */
} }

View File

@ -118,6 +118,8 @@ void ExampleDialog::peertreeWidgetCostumPopupMenu( QPoint point )
/* get the list of peers from the RsIface. */ /* get the list of peers from the RsIface. */
void ExampleDialog::insertExample() void ExampleDialog::insertExample()
{ {
#if 0
rsiface->lockData(); /* Lock Interface */ rsiface->lockData(); /* Lock Interface */
std::map<RsCertId,NeighbourInfo>::const_iterator it; std::map<RsCertId,NeighbourInfo>::const_iterator it;
@ -226,6 +228,7 @@ void ExampleDialog::insertExample()
rsiface->unlockData(); /* UnLock Interface */ rsiface->unlockData(); /* UnLock Interface */
peerWidget->update(); /* update display */ peerWidget->update(); /* update display */
#endif
} }
QTreeWidgetItem *ExampleDialog::getCurrentLine() QTreeWidgetItem *ExampleDialog::getCurrentLine()

View File

@ -22,12 +22,10 @@
#include <QFile> #include <QFile>
#include <QFileInfo> #include <QFileInfo>
//#include "common/vmessagebox.h"
//#include "rshare.h"
#include "GamesDialog.h" #include "GamesDialog.h"
#include "rsiface/rsiface.h" #include "rsiface/rsiface.h"
#include "rsiface/rsgame.h" #include "rsiface/rsgame.h"
#include "rsiface/rspeers.h"
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
@ -269,35 +267,30 @@ void GamesDialog::updateGameDetails()
} }
if (detail.status == "Invite") if (detail.status == "Invite")
{ {
/* add all the online peers not listed above */ std::list<std::string> friends;
rsiface->lockData(); /* Lock Interface */ std::list<std::string>::iterator fit;
rsPeers->getOnlineList(friends);
std::map<RsCertId,NeighbourInfo>::const_iterator fit;
const std::map<RsCertId,NeighbourInfo> &friends =
rsiface->getFriendMap();
for(fit = friends.begin(); fit != friends.end(); fit++) for(fit = friends.begin(); fit != friends.end(); fit++)
{ {
if (detail.gamers.end() != detail.gamers.find(fit->first)) if (detail.gamers.end() != detail.gamers.find(*fit))
{ {
/* already present */ /* already present */
continue; continue;
} }
if (1) std::string name = rsPeers->getPeerName(*fit);
{
/* not online */
}
/* make a widget per friend */ /* make a widget per friend */
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0); QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
item -> setText(GAME_PEER_PLAYER, QString::fromStdString(fit->second.name)); item -> setText(GAME_PEER_PLAYER, QString::fromStdString(name));
item -> setText(GAME_PEER_INVITE, "No"); item -> setText(GAME_PEER_INVITE, "No");
item -> setText(GAME_PEER_INTEREST, "?"); item -> setText(GAME_PEER_INTEREST, "?");
item -> setText(GAME_PEER_PLAY, "?"); item -> setText(GAME_PEER_PLAY, "?");
item -> setText(GAME_PEER_ID, QString::fromStdString(fit->first)); item -> setText(GAME_PEER_ID, QString::fromStdString(*fit));
if ((oldSelect) && (oldId == fit->first)) if ((oldSelect) && (oldId == *fit))
{ {
newSelect = item; newSelect = item;
} }
@ -305,9 +298,6 @@ void GamesDialog::updateGameDetails()
/* add to the list */ /* add to the list */
items.append(item); items.append(item);
} }
rsiface->unlockData(); /* UnLock Interface */
} }
detailWidget->clear(); detailWidget->clear();
@ -415,18 +405,14 @@ void GamesDialog::createGame()
if (addAll) if (addAll)
{ {
/* add all the online peers not listed above */ std::list<std::string> friends;
rsiface->lockData(); /* Lock Interface */ std::list<std::string>::iterator fit;
std::map<RsCertId,NeighbourInfo>::const_iterator fit; rsPeers->getOnlineList(friends);
const std::map<RsCertId,NeighbourInfo> &friends =
rsiface->getFriendMap();
for(fit = friends.begin(); fit != friends.end(); fit++) for(fit = friends.begin(); fit != friends.end(); fit++)
{ {
rsGameLauncher -> invitePeer(gameId, fit->first); rsGameLauncher -> invitePeer(gameId, *fit);
} }
rsiface->unlockData(); /* UnLock Interface */
} }
/* call to the GameControl */ /* call to the GameControl */

View File

@ -43,6 +43,7 @@
#include "util/rsversion.h" #include "util/rsversion.h"
#include "rsiface/rsiface.h" #include "rsiface/rsiface.h"
#include "rsiface/rspeers.h"
#include "gui/connect/InviteDialog.h" #include "gui/connect/InviteDialog.h"
#include "gui/connect/AddFriendDialog.h" #include "gui/connect/AddFriendDialog.h"
@ -347,7 +348,7 @@ void MainWindow::inviteFriend()
{ {
static InviteDialog *inviteDialog = new InviteDialog(this); static InviteDialog *inviteDialog = new InviteDialog(this);
std::string invite = rsicontrol->NeighGetInvite(); std::string invite = rsPeers->GetRetroshareInvite();
inviteDialog->setInfo(invite); inviteDialog->setInfo(invite);
inviteDialog->show(); inviteDialog->show();
@ -367,7 +368,7 @@ void MainWindow::addSharedDirectory()
if (dir != "") if (dir != "")
{ {
rsicontrol -> ConfigAddSharedDir(dir); rsicontrol -> ConfigAddSharedDir(dir);
rsicontrol -> ConfigSave(); //rsicontrol -> ConfigSave();
} }
} }

View File

@ -21,11 +21,14 @@
#include <QFile> #include <QFile>
#include <QFileInfo> #include <QFileInfo>
#include "common/vmessagebox.h" #include "common/vmessagebox.h"
#include "rshare.h"
#include "MessengerWindow.h"
#include "rsiface/rsiface.h" #include "rsiface/rsiface.h"
#include "rsiface/rspeers.h"
#include "rshare.h"
#include "MessengerWindow.h"
#include "chat/PopupChatDialog.h" #include "chat/PopupChatDialog.h"
#include "msgs/ChanMsgDialog.h" #include "msgs/ChanMsgDialog.h"
#include "ChatDialog.h" #include "ChatDialog.h"
@ -164,51 +167,51 @@ void MessengerWindow::messengertreeWidgetCostumPopupMenu( QPoint point )
/* get the list of peers from the RsIface. */ /* get the list of peers from the RsIface. */
void MessengerWindow::insertPeers() void MessengerWindow::insertPeers()
{ {
rsiface->lockData(); /* Lock Interface */ if (!rsPeers)
{
/* not ready yet! */
return;
}
std::map<RsCertId,NeighbourInfo>::const_iterator it; std::list<std::string> peers;
const std::map<RsCertId,NeighbourInfo> &friends = std::list<std::string>::iterator it;
rsiface->getFriendMap();
rsPeers->getFriendList(peers);
/* get a link to the table */ /* get a link to the table */
QTreeWidget *peerWidget = ui.messengertreeWidget; QTreeWidget *peerWidget = ui.messengertreeWidget;
/* remove old items ??? */
peerWidget->clear();
peerWidget->setColumnCount(1);
/* have two lists: online / offline */ /* have two lists: online / offline */
QList<QTreeWidgetItem *> online_items; QList<QTreeWidgetItem *> online_items;
QList<QTreeWidgetItem *> offline_items; QList<QTreeWidgetItem *> offline_items;
for(it = peers.begin(); it != peers.end(); it++)
for(it = friends.begin(); it != friends.end(); it++)
{ {
RsPeerDetails details;
if (!rsPeers->getPeerDetails(*it, details))
{
continue; /* BAD */
}
/* make a widget per friend */ /* make a widget per friend */
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0); QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
/* add all the labels */ /* add all the labels */
/* (0) Person */ /* (0) Person */
item -> setText(0, QString::fromStdString(it->second.name)); item -> setText(0, QString::fromStdString(details.name));
/* (1) Org */ /* (1) Org */
//item -> setText(1, QString::fromStdString(it->second.org)); //item -> setText(1, QString::fromStdString(details.org));
/* (2) Location */ /* (2) Location */
//item -> setText(2, QString::fromStdString(it->second.loc)); //item -> setText(2, QString::fromStdString(details.location));
/* (3) Country */ /* (3) Email */
//item -> setText(3, QString::fromStdString(it->second.country)); //item -> setText(3, QString::fromStdString(details.email));
/* Hidden ones: RsCertId */
/* Hidden ones: */ item -> setText(4, QString::fromStdString(details.id));
/* () RsCertId */
{
std::ostringstream out;
out << it -> second.id;
item -> setText(4, QString::fromStdString(out.str()));
}
/* add to the list */ /* add to the list */
if (it->second.statusString == "Online") if (details.state & RS_PEER_STATE_CONNECTED)
{ {
online_items.append(item); online_items.append(item);
item -> setIcon(0,(QIcon(IMAGE_ONLINE))); item -> setIcon(0,(QIcon(IMAGE_ONLINE)));
@ -220,8 +223,9 @@ void MessengerWindow::insertPeers()
} }
} }
/* make parent items (TODO) */ /* remove old items */
/* add the items in! */ peerWidget->clear();
peerWidget->setColumnCount(1);
if (online_items.size() > 0) if (online_items.size() > 0)
{ {
@ -250,8 +254,6 @@ void MessengerWindow::insertPeers()
item -> setIcon(0,(QIcon(IMAGE_OFF))); item -> setIcon(0,(QIcon(IMAGE_OFF)));
} }
rsiface->unlockData(); /* UnLock Interface */
peerWidget->update(); /* update display */ peerWidget->update(); /* update display */
} }
@ -291,7 +293,7 @@ void MessengerWindow::connectfriend2()
else else
{ {
std::cerr << "MessengerWindow::connectfriend2() Trying" << std::endl; std::cerr << "MessengerWindow::connectfriend2() Trying" << std::endl;
rsicontrol->FriendConnectAttempt(getMessengerPeerRsCertId(i)); rsPeers->connectAttempt(getMessengerPeerRsCertId(i));
} }
} }
@ -446,7 +448,7 @@ void MessengerWindow::removefriend2()
std::cerr << "MessengerWindow::removefriend2() Noone Selected -- sorry" << std::endl; std::cerr << "MessengerWindow::removefriend2() Noone Selected -- sorry" << std::endl;
return; return;
} }
rsicontrol->FriendRemove(getMessengerPeerRsCertId(c)); rsPeers->removeFriend(getMessengerPeerRsCertId(c));
} }
void MessengerWindow::changeAvatarClicked() void MessengerWindow::changeAvatarClicked()

View File

@ -28,7 +28,7 @@
#include "connect/ConnectDialog.h" #include "connect/ConnectDialog.h"
#include "authdlg/AuthorizationDialog.h" #include "authdlg/AuthorizationDialog.h"
#include "rsiface/rsiface.h" #include "rsiface/rsiface.h"
#include "rsiface/rstypes.h" #include "rsiface/rspeers.h"
#include <sstream> #include <sstream>
@ -214,11 +214,14 @@ void NetworkDialog::loadcert()
/* get the list of Neighbours from the RsIface. */ /* get the list of Neighbours from the RsIface. */
void NetworkDialog::insertConnect() void NetworkDialog::insertConnect()
{ {
rsiface->lockData(); /* Lock Interface */ if (!rsPeers)
{
return;
}
std::map<RsCertId,NeighbourInfo>::const_iterator it; std::list<std::string> neighs;
const std::map<RsCertId,NeighbourInfo> &neighs = std::list<std::string>::iterator it;
rsiface->getNeighbourMap(); rsPeers->getOthersList(neighs);
/* get a link to the table */ /* get a link to the table */
QTreeWidget *connectWidget = ui.connecttreeWidget; QTreeWidget *connectWidget = ui.connecttreeWidget;
@ -230,57 +233,76 @@ void NetworkDialog::insertConnect()
oldId = (oldSelect -> text(9)).toStdString(); oldId = (oldSelect -> text(9)).toStdString();
} }
/* remove old items ??? */
connectWidget->clear();
connectWidget->setColumnCount(11);
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 (!rsPeers->getPeerDetails(*it, detail))
{
continue; /* BAD */
}
/* make a widget per friend */ /* make a widget per friend */
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0); QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
/* add all the labels */ /* add all the labels */
/* (0) Status Icon */ /* (0) Status Icon */
item -> setText(0, ""); item -> setText(0, "");
/* (1) Accept/Deny */ /* (1) Accept/Deny */
item -> setText(1, QString::fromStdString(it->second.acceptString)); if (detail.state & RS_PEER_STATE_FRIEND)
/* (2) Trust Level */ {
item -> setText(2, QString::fromStdString(it->second.trustString)); item -> setText(1, tr("Accept"));
}
else
{
item -> setText(1, tr("Deny"));
}
item -> setText(2,QString::fromStdString(
RsPeerTrustString(detail.trustLvl)));
/* (3) Last Connect */ /* (3) Last Connect */
item -> setText(3, QString::fromStdString(it->second.lastConnect));
/* (4) Person */
item -> setText(4, QString::fromStdString(it->second.name));
/* (5) Peer Address */
item -> setText(5, QString::fromStdString(it->second.peerAddress));
/* Others */
item -> setText(6, QString::fromStdString(it->second.org));
item -> setText(7, QString::fromStdString(it->second.loc));
item -> setText(8, QString::fromStdString(it->second.country));
{ {
std::ostringstream out; std::ostringstream out;
out << it -> second.id; out << detail.lastConnect;
item -> setText(9, QString::fromStdString(out.str())); item -> setText(3, QString::fromStdString(out.str()));
if ((oldSelect) && (oldId == out.str())) }
/* (4) Person */
item -> setText(4, QString::fromStdString(detail.name));
/* (5) Peer Address */
{
std::ostringstream out;
out << detail.localAddr << ":";
out << detail.localPort << "/";
out << detail.extAddr << ":";
out << detail.extPort;
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(detail.email));
{
item -> setText(9, QString::fromStdString(detail.id));
if ((oldSelect) && (oldId == detail.id))
{ {
newSelect = item; newSelect = item;
} }
} }
item -> setText(10, QString::fromStdString(it->second.authCode)); item -> setText(10, QString::fromStdString(detail.authcode));
/* change background */ /* change background */
int i; int i;
if (it->second.acceptString == "Accept") if (detail.state & RS_PEER_STATE_FRIEND)
{ {
if (it->second.lastConnect != "Never") if (detail.lastConnect < 10000) /* 3 hours? */
{ {
/* bright green */ /* bright green */
for(i = 1; i < 11; i++) for(i = 1; i < 11; i++)
@ -300,7 +322,7 @@ void NetworkDialog::insertConnect()
} }
else else
{ {
if (it->second.trustLvl > 3) if (detail.trustLvl > RS_TRUST_LVL_MARGINAL)
{ {
for(i = 1; i < 11; i++) for(i = 1; i < 11; i++)
{ {
@ -308,7 +330,7 @@ void NetworkDialog::insertConnect()
item -> setIcon(0,(QIcon(IMAGE_DENIED))); item -> setIcon(0,(QIcon(IMAGE_DENIED)));
} }
} }
else if (it->second.lastConnect != "Never") else if (detail.lastConnect < 10000) /* 3 hours? */
{ {
for(i = 1; i < 11; i++) for(i = 1; i < 11; i++)
{ {
@ -331,6 +353,10 @@ void NetworkDialog::insertConnect()
items.append(item); items.append(item);
} }
/* remove old items ??? */
connectWidget->clear();
connectWidget->setColumnCount(11);
/* add the items in! */ /* add the items in! */
connectWidget->insertTopLevelItems(0, items); connectWidget->insertTopLevelItems(0, items);
if (newSelect) if (newSelect)
@ -338,8 +364,6 @@ void NetworkDialog::insertConnect()
connectWidget->setCurrentItem(newSelect); connectWidget->setCurrentItem(newSelect);
} }
rsiface->unlockData(); /* UnLock Interface */
connectWidget->update(); /* update display */ connectWidget->update(); /* update display */
} }
@ -358,18 +382,6 @@ QTreeWidgetItem *NetworkDialog::getCurrentNeighbour()
/* Display the columns of this item. */ /* Display the columns of this item. */
/**** NO NEED ANYMORE
std::ostringstream out;
out << "CurrentNeighbourItem: " << std::endl;
for(int i = 1; i < 6; i++)
{
QString txt = item -> text(i);
out << "\t" << i << ":" << txt.toStdString() << std::endl;
}
std::cerr << out.str();
*****************/
return item; return item;
} }
@ -398,7 +410,7 @@ std::string NetworkDialog::loadneighbour()
std::string id; std::string id;
if (file != "") if (file != "")
{ {
rsicontrol->NeighLoadCertificate(file, id); rsPeers->LoadCertificateFromFile(file, id);
} }
return id; return id;
} }

View File

@ -26,6 +26,8 @@
#include "rshare.h" #include "rshare.h"
#include "PeersDialog.h" #include "PeersDialog.h"
#include "rsiface/rsiface.h" #include "rsiface/rsiface.h"
#include "rsiface/rspeers.h"
#include "chat/PopupChatDialog.h" #include "chat/PopupChatDialog.h"
#include "msgs/ChanMsgDialog.h" #include "msgs/ChanMsgDialog.h"
#include "ChatDialog.h" #include "ChatDialog.h"
@ -147,11 +149,16 @@ void PeersDialog::peertreeWidgetCostumPopupMenu( QPoint point )
/* get the list of peers from the RsIface. */ /* get the list of peers from the RsIface. */
void PeersDialog::insertPeers() void PeersDialog::insertPeers()
{ {
rsiface->lockData(); /* Lock Interface */ std::list<std::string> peers;
std::list<std::string>::iterator it;
std::map<RsCertId,NeighbourInfo>::const_iterator it; if (!rsPeers)
const std::map<RsCertId,NeighbourInfo> &friends = {
rsiface->getFriendMap(); /* not ready yet! */
return;
}
rsPeers->getFriendList(peers);
/* get a link to the table */ /* get a link to the table */
QTreeWidget *peerWidget = ui.peertreeWidget; QTreeWidget *peerWidget = ui.peertreeWidget;
@ -168,10 +175,15 @@ void PeersDialog::insertPeers()
peerWidget->setColumnCount(12); peerWidget->setColumnCount(12);
QList<QTreeWidgetItem *> items; QList<QTreeWidgetItem *> items;
for(it = friends.begin(); it != friends.end(); it++) for(it = peers.begin(); it != peers.end(); it++)
{ {
RsPeerDetails detail;
if (!rsPeers->getPeerDetails(*it, detail))
{
continue; /* BAD */
}
/* make a widget per friend */ /* make a widget per friend */
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0); QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
@ -181,51 +193,56 @@ void PeersDialog::insertPeers()
item -> setText(0, ""); item -> setText(0, "");
/* (0) Status */ /* (0) Status */
item -> setText(1, QString::fromStdString( item -> setText(1,
it->second.statusString)); QString::fromStdString(RsPeerStateString(detail.state)));
/* (1) Person */ /* (1) Person */
item -> setText(2, QString::fromStdString(it->second.name)); item -> setText(2, QString::fromStdString(detail.name));
/* (2) Auto Connect */ /* (2) Auto Connect */
item -> setText(3, QString::fromStdString( item -> setText(3, QString::fromStdString("Yes"));
it->second.connectString));
/* (3) Trust Level */ /* (3) Trust Level */
item -> setText(4, QString::fromStdString(it->second.trustString)); item -> setText(4,QString::fromStdString(
RsPeerTrustString(detail.trustLvl)));
/* (4) Peer Address */ /* (4) Peer Address */
item -> setText(5, QString::fromStdString(it->second.peerAddress));
/* less important ones */
/* () Last Contact */
item -> setText(6, QString::fromStdString(it->second.lastConnect));
/* () Org */
item -> setText(7, QString::fromStdString(it->second.org));
/* () Location */
item -> setText(8, QString::fromStdString(it->second.loc));
/* () Country */
item -> setText(9, QString::fromStdString(it->second.country));
/* Hidden ones: */
/* () RsCertId */
{ {
std::ostringstream out; std::ostringstream out;
out << it -> second.id; out << detail.localAddr << ":";
item -> setText(10, QString::fromStdString(out.str())); out << detail.localPort << "/";
if ((oldSelect) && (oldId == out.str())) out << detail.extAddr << ":";
out << detail.extPort;
item -> setText(5, QString::fromStdString(out.str()));
}
/* less important ones */
/* () Last Contact */
item -> setText(6,QString::fromStdString(
RsPeerLastConnectString(detail.lastConnect)));
/* () Org */
item -> setText(7, QString::fromStdString(detail.org));
/* () Location */
item -> setText(8, QString::fromStdString(detail.location));
/* () Email */
item -> setText(9, QString::fromStdString(detail.email));
/* Hidden ones: RsCertId */
{
item -> setText(10, QString::fromStdString(detail.id));
if ((oldSelect) && (oldId == detail.id))
{ {
newSelect = item; newSelect = item;
} }
} }
/* () AuthCode */ /* () AuthCode */
item -> setText(11, QString::fromStdString(it->second.authCode)); item -> setText(11, QString::fromStdString(detail.authcode));
/* change background */ /* change background */
int i; int i;
if (it->second.statusString == "Online") if (detail.state & RS_PEER_STATE_CONNECTED)
{ {
/* bright green */ /* bright green */
for(i = 1; i < 12; i++) for(i = 1; i < 12; i++)
@ -234,9 +251,18 @@ void PeersDialog::insertPeers()
item -> setIcon(0,(QIcon(IMAGE_ONLINE))); item -> setIcon(0,(QIcon(IMAGE_ONLINE)));
} }
} }
else else if (detail.state & RS_PEER_STATE_ONLINE)
{ {
if (it->second.lastConnect != "Never") /* bright green */
for(i = 1; i < 12; i++)
{
item -> setBackground(i,QBrush(Qt::cyan));
item -> setIcon(0,(QIcon(IMAGE_OFFLINE)));
}
}
else
{
if (detail.lastConnect < 10000)
{ {
for(i = 1; i < 12; i++) for(i = 1; i < 12; i++)
{ {
@ -254,8 +280,6 @@ void PeersDialog::insertPeers()
} }
} }
/* add to the list */ /* add to the list */
items.append(item); items.append(item);
} }
@ -267,9 +291,6 @@ void PeersDialog::insertPeers()
peerWidget->setCurrentItem(newSelect); peerWidget->setCurrentItem(newSelect);
} }
rsiface->unlockData(); /* UnLock Interface */
peerWidget->update(); /* update display */ peerWidget->update(); /* update display */
} }
@ -300,7 +321,10 @@ void PeersDialog::exportfriend()
{ {
std::cerr << "PeersDialog::exportfriend() Saving to: " << file << std::endl; std::cerr << "PeersDialog::exportfriend() Saving to: " << file << std::endl;
std::cerr << std::endl; std::cerr << std::endl;
rsicontrol->FriendSaveCertificate(id, file); if (rsPeers)
{
rsPeers->SaveCertificateToFile(id, file);
}
} }
} }
@ -408,7 +432,11 @@ void PeersDialog::removefriend()
std::cerr << "PeersDialog::removefriend() Noone Selected -- sorry" << std::endl; std::cerr << "PeersDialog::removefriend() Noone Selected -- sorry" << std::endl;
return; return;
} }
rsicontrol->FriendRemove(getPeerRsCertId(c));
if (rsPeers)
{
rsPeers->removeFriend(getPeerRsCertId(c));
}
} }
@ -427,7 +455,10 @@ void PeersDialog::connectfriend()
{ {
QTreeWidgetItem *c = getCurrentPeer(); QTreeWidgetItem *c = getCurrentPeer();
std::cerr << "PeersDialog::connectfriend()" << std::endl; std::cerr << "PeersDialog::connectfriend()" << std::endl;
rsicontrol->FriendConnectAttempt(getPeerRsCertId(c)); if (rsPeers)
{
rsPeers->connectAttempt(getPeerRsCertId(c));
}
} }
void PeersDialog::setaddressfriend() void PeersDialog::setaddressfriend()

View File

@ -118,6 +118,8 @@ void PhotoDialog::peertreeWidgetCostumPopupMenu( QPoint point )
/* get the list of peers from the RsIface. */ /* get the list of peers from the RsIface. */
void PhotoDialog::insertExample() void PhotoDialog::insertExample()
{ {
#if 0
rsiface->lockData(); /* Lock Interface */ rsiface->lockData(); /* Lock Interface */
std::map<RsCertId,NeighbourInfo>::const_iterator it; std::map<RsCertId,NeighbourInfo>::const_iterator it;
@ -224,6 +226,7 @@ void PhotoDialog::insertExample()
rsiface->unlockData(); /* UnLock Interface */ rsiface->unlockData(); /* UnLock Interface */
peerWidget->update(); /* update display */ peerWidget->update(); /* update display */
#endif
} }
QTreeWidgetItem *PhotoDialog::getCurrentLine() QTreeWidgetItem *PhotoDialog::getCurrentLine()

View File

@ -165,7 +165,7 @@ PreferencesWindow::saveChanges()
} }
/* call to RsIface save function.... */ /* call to RsIface save function.... */
rsicontrol -> ConfigSave(); //rsicontrol -> ConfigSave();
QMainWindow::close(); QMainWindow::close();
} }

View File

@ -25,6 +25,7 @@
#include <iostream> #include <iostream>
#include "rsiface/rsiface.h" #include "rsiface/rsiface.h"
#include "rsiface/rspeers.h"
@ -187,8 +188,8 @@ void ServerDialog::saveAddresses()
QString str; QString str;
bool saveAddr = false; bool saveAddr = false;
rsicontrol -> NetworkDHTActive(ui.DHTButton->isChecked()); //rsicontrol -> NetworkDHTActive(ui.DHTButton->isChecked());
rsicontrol -> NetworkUPnPActive(ui.UPnPButton->isChecked()); //rsicontrol -> NetworkUPnPActive(ui.UPnPButton->isChecked());
if (ui.ManualButton->isChecked()) if (ui.ManualButton->isChecked())
{ {
@ -197,9 +198,9 @@ void ServerDialog::saveAddresses()
if (saveAddr) if (saveAddr)
{ {
rsicontrol->ConfigSetLocalAddr(ui.localAddress->text().toStdString(), ui.localPort->value()); rsPeers->setLocalAddress(rsPeers->getOwnId(), ui.localAddress->text().toStdString(), ui.localPort->value());
rsicontrol->ConfigSetLanConfig(ui.chkFirewall->isChecked(), ui.chkForwarded->isChecked()); //rsicontrol->ConfigSetLanConfig(ui.chkFirewall->isChecked(), ui.chkForwarded->isChecked());
rsicontrol->ConfigSetExtAddr(ui.extAddress->text().toStdString(), ui.extPort->value()); rsPeers->setExtAddress(rsPeers->getOwnId(), ui.extAddress->text().toStdString(), ui.extPort->value());
} }
rsicontrol->ConfigSetDataRates( ui.totalRate->value(), ui.indivRate->value() ); rsicontrol->ConfigSetDataRates( ui.totalRate->value(), ui.indivRate->value() );

View File

@ -22,7 +22,9 @@
#include "rshare.h" #include "rshare.h"
#include "SharedFilesDialog.h" #include "SharedFilesDialog.h"
#include "rsiface/rsiface.h" #include "rsiface/rsiface.h"
#include "rsiface/rspeers.h"
#include "rsiface/RemoteDirModel.h" #include "rsiface/RemoteDirModel.h"
#include "util/RsAction.h" #include "util/RsAction.h"
#include "msgs/ChanMsgDialog.h" #include "msgs/ChanMsgDialog.h"
@ -308,31 +310,30 @@ void SharedFilesDialog::shareddirtreeWidgetCostumPopupMenu( QPoint point )
QMenu *recMenu = new QMenu( tr("Recommend To "), this ); QMenu *recMenu = new QMenu( tr("Recommend To "), this );
QMenu *msgMenu = new QMenu( tr("Message Friend "), &contextMnu2 ); QMenu *msgMenu = new QMenu( tr("Message Friend "), &contextMnu2 );
std::list<std::string> peers;
std::list<std::string>::iterator it;
rsiface->lockData(); /* Lock Interface */ if (!rsPeers)
std::map<RsCertId,NeighbourInfo>::const_iterator it;
const std::map<RsCertId,NeighbourInfo> &friends =
rsiface->getFriendMap();
for(it = friends.begin(); it != friends.end(); it++)
{ {
/* not ready yet! */
return;
}
rsPeers->getFriendList(peers);
for(it = peers.begin(); it != peers.end(); it++)
{
std::string name = rsPeers->getPeerName(*it);
/* parents are /* parents are
* recMenu * recMenu
* msgMenu * msgMenu
*/ */
std::string rsid;
{
std::ostringstream out;
out << it -> second.id;
rsid = out.str();
}
RsAction *qaf1 = new RsAction( QString::fromStdString( it->second.name ), recMenu, rsid ); RsAction *qaf1 = new RsAction( QString::fromStdString( name ), recMenu, *it );
connect( qaf1 , SIGNAL( triggeredId( std::string ) ), this, SLOT( recommendFilesTo( std::string ) ) ); connect( qaf1 , SIGNAL( triggeredId( std::string ) ), this, SLOT( recommendFilesTo( std::string ) ) );
recMenu->addAction(qaf1); recMenu->addAction(qaf1);
RsAction *qaf2 = new RsAction( QString::fromStdString( it->second.name ), msgMenu, rsid ); RsAction *qaf2 = new RsAction( QString::fromStdString( name ), msgMenu, *it );
connect( qaf2 , SIGNAL( triggeredId( std::string ) ), this, SLOT( recommendFilesToMsg( std::string ) ) ); connect( qaf2 , SIGNAL( triggeredId( std::string ) ), this, SLOT( recommendFilesToMsg( std::string ) ) );
msgMenu->addAction(qaf2); msgMenu->addAction(qaf2);
@ -340,9 +341,6 @@ void SharedFilesDialog::shareddirtreeWidgetCostumPopupMenu( QPoint point )
} }
rsiface->unlockData(); /* UnLock Interface */
contextMnu2.addAction( openfileAct); contextMnu2.addAction( openfileAct);
contextMnu2.addMenu( recMenu); contextMnu2.addMenu( recMenu);
contextMnu2.addMenu( msgMenu); contextMnu2.addMenu( msgMenu);

View File

@ -25,6 +25,7 @@
#include "AuthorizationDialog.h" #include "AuthorizationDialog.h"
#include "rsiface/rsiface.h" #include "rsiface/rsiface.h"
#include "rsiface/rspeers.h"
#include <iostream> #include <iostream>
@ -112,8 +113,8 @@ void AuthorizationDialog::authAttempt()
/* well lets do it ! */ /* well lets do it ! */
std::cerr << "Attempting AuthCode:" << authCode << std::endl; std::cerr << "Attempting AuthCode:" << authCode << std::endl;
rsicontrol -> NeighAuthFriend(authId, authCode); rsPeers->AuthCertificate(authId, authCode);
rsicontrol -> NeighAddFriend(authId); rsPeers->addFriend(authId);
/* close it up! */ /* close it up! */
closedlg(); closedlg();

View File

@ -29,8 +29,10 @@
#include <QToolBar> #include <QToolBar>
#include <QTextCursor> #include <QTextCursor>
#include <QTextList> #include <QTextList>
#include "rsiface/rspeers.h"
/* Define the format used for displaying the date and time */ /* Define the format used for displaying the date and time */
#define DATETIME_FMT "MMM dd hh:mm:ss" #define DATETIME_FMT "MMM dd hh:mm:ss"
@ -201,24 +203,21 @@ void PopupChatDialog::addChatMsg(ChatInfo *ci)
std::ostringstream out; std::ostringstream out;
int ts = time(NULL); int ts = time(NULL);
bool offline = true; bool offline = true;
{ {
rsiface->lockData(); /* Lock Interface */ RsPeerDetails detail;
const NeighbourInfo *peer = rsiface->getFriend(dialogId); if (!rsPeers->getPeerDetails(dialogId, detail))
if (!peer)
{ {
std::cerr << "WARNING CANNOT GET PEER INFO!!!!" << std::endl; std::cerr << "WARNING CANNOT GET PEER INFO!!!!" << std::endl;
} }
else if (peer->statusString == "Online") else if (detail.state & RS_PEER_STATE_CONNECTED)
{ {
offline = false; offline = false;
} }
}
rsiface->unlockData(); /* Unlock Interface */
}
if (offline) if (offline)
{ {
QString line = "<br>\n<span style=\"color:#1D84C9\"><strong> ----- PEER OFFLINE (Chat will be lost) -----</strong></span> \n<br>"; QString line = "<br>\n<span style=\"color:#1D84C9\"><strong> ----- PEER OFFLINE (Chat will be lost) -----</strong></span> \n<br>";

View File

@ -21,6 +21,8 @@
#include "AddFriendDialog.h" #include "AddFriendDialog.h"
#include "rsiface/rsiface.h" #include "rsiface/rsiface.h"
#include "rsiface/rspeers.h"
#include "gui/NetworkDialog.h" #include "gui/NetworkDialog.h"
#include <util/WidgetBackgroundImage.h> #include <util/WidgetBackgroundImage.h>
@ -53,7 +55,7 @@ void AddFriendDialog::donebutton()
std::string certstr = ui.emailText->toPlainText().toStdString(); std::string certstr = ui.emailText->toPlainText().toStdString();
/* ask retroshare to load */ /* ask retroshare to load */
if ((cDialog) && (rsicontrol -> NeighLoadPEMString(certstr, id))) if ((cDialog) && (rsPeers->LoadCertificateFromString(certstr, id)))
{ {
close(); close();
cDialog->showpeerdetails(id); cDialog->showpeerdetails(id);

View File

@ -21,6 +21,7 @@
#include "ConfCertDialog.h" #include "ConfCertDialog.h"
#include "rsiface/rsiface.h" #include "rsiface/rsiface.h"
#include "rsiface/rspeers.h"
/* Define the format used for displaying the date and time */ /* Define the format used for displaying the date and time */
#define DATETIME_FMT "MMM dd hh:mm:ss" #define DATETIME_FMT "MMM dd hh:mm:ss"
@ -74,43 +75,43 @@ void ConfCertDialog::loadId(std::string id)
void ConfCertDialog::loadDialog() void ConfCertDialog::loadDialog()
{ {
/* open up the rsiface and get the data */
/* get the shared directories */
rsiface->lockData(); /* Lock Interface */
/* get the correct friend */ RsPeerDetails detail;
const NeighbourInfo *ni = rsiface->getFriend(mId); if (!rsPeers->getPeerDetails(mId, detail))
if (!ni)
{ {
/* fail */ /* fail */
rsiface->unlockData(); /* UnLock Interface */
return; return;
} }
ui.name->setText(QString::fromStdString(ni -> name)); ui.name->setText(QString::fromStdString(detail.name));
ui.orgloc->setText(QString::fromStdString(ni -> org + "/" + ni -> loc)); ui.orgloc->setText(QString::fromStdString(detail.org));
ui.country->setText(QString::fromStdString(ni -> country + "/" + ni -> state)); ui.country->setText(QString::fromStdString(detail.location));
/* set local address */ /* set local address */
ui.localAddress->setText(QString::fromStdString(ni->localAddr)); ui.localAddress->setText(QString::fromStdString(detail.localAddr));
ui.localPort -> setValue(ni->localPort); ui.localPort -> setValue(detail.localPort);
/* set the server address */ /* set the server address */
ui.extAddress->setText(QString::fromStdString(ni->extAddr)); ui.extAddress->setText(QString::fromStdString(detail.extAddr));
ui.extPort -> setValue(ni->extPort); ui.extPort -> setValue(detail.extPort);
/* set the url for DNS access */
ui.extName->setText(QString::fromStdString(ni->extName)); /* set the url for DNS access (OLD) */
ui.chkFirewall ->setChecked(ni->firewalled); ui.extName->setText(QString::fromStdString(""));
ui.chkForwarded ->setChecked(ni->forwardPort);
/**** 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 -> setCheckState(Qt::Checked);
ui.signBox -> setEnabled(false); ui.signBox -> setEnabled(false);
if (ni->trustLvl == 5) /* 5 = Trusted, 6 = OwnSign */ if (detail.trusted)
{ {
ui.trustBox -> setCheckState(Qt::Checked); ui.trustBox -> setCheckState(Qt::Checked);
} }
@ -128,60 +129,44 @@ void ConfCertDialog::loadDialog()
ui.trustBox -> setCheckState(Qt::Unchecked); ui.trustBox -> setCheckState(Qt::Unchecked);
ui.trustBox -> setEnabled(false); ui.trustBox -> setEnabled(false);
} }
rsiface->unlockData(); /* UnLock Interface */
} }
void ConfCertDialog::applyDialog() void ConfCertDialog::applyDialog()
{ {
/* open up the rsiface and get the data */ RsPeerDetails detail;
/* get the shared directories */ if (!rsPeers->getPeerDetails(mId, detail))
rsiface->lockData(); /* Lock Interface */
/* get the correct friend */
const NeighbourInfo *ni = rsiface->getFriend(mId);
if (!ni)
{ {
/* fail */ /* fail */
rsiface->unlockData(); /* UnLock Interface */
return; return;
} }
/* check if the data is the same */ /* check if the data is the same */
bool localChanged = false; bool localChanged = false;
bool extChanged = false; bool extChanged = false;
bool fwChanged = false; bool fwChanged = false;
bool dnsChanged = false;
bool signChanged = false; bool signChanged = false;
bool trustChanged = false; bool trustChanged = false;
/* set local address */ /* set local address */
if ((ni->localAddr != ui.localAddress->text().toStdString()) if ((detail.localAddr != ui.localAddress->text().toStdString())
|| (ni->localPort != ui.localPort -> value())) || (detail.localPort != ui.localPort -> value()))
{ {
/* changed ... set it */ /* changed ... set it */
localChanged = true; localChanged = true;
} }
if ((ni->extAddr != ui.extAddress->text().toStdString()) if ((detail.extAddr != ui.extAddress->text().toStdString())
|| (ni->extPort != ui.extPort -> value())) || (detail.extPort != ui.extPort -> value()))
{ {
/* changed ... set it */ /* changed ... set it */
extChanged = true; extChanged = true;
} }
if (ni->extName != ui.extName->text().toStdString()) #if 0
{ if ((detail.firewalled != ui.chkFirewall ->isChecked()) ||
/* changed ... set it */ (detail.forwardPort != ui.chkForwarded ->isChecked()))
dnsChanged = true;
}
if ((ni->firewalled != ui.chkFirewall ->isChecked()) ||
(ni->forwardPort != ui.chkForwarded ->isChecked()))
{ {
/* changed ... set it */ /* changed ... set it */
fwChanged = true; fwChanged = true;
@ -191,13 +176,11 @@ void ConfCertDialog::applyDialog()
{ {
/* nada */ /* nada */
} }
#endif
if (ni->ownsign) if (detail.ownsign)
{ {
/* check the trust tick */ if (detail.trusted != ui.trustBox->isChecked())
bool trsted = (ni->trustLvl == 5); /* 5 = Trusted, 6 = OwnSign */
if (trsted != ui.trustBox->isChecked())
{ {
trustChanged = true; trustChanged = true;
} }
@ -210,30 +193,26 @@ void ConfCertDialog::applyDialog()
} }
} }
rsiface->unlockData(); /* UnLock Interface */
/* now we can action the changes */ /* now we can action the changes */
if (localChanged) if (localChanged)
rsicontrol -> FriendSetLocalAddress(mId, rsPeers->setLocalAddress(mId,
ui.localAddress->text().toStdString(), ui.localPort->value()); ui.localAddress->text().toStdString(), ui.localPort->value());
if (extChanged) if (extChanged)
rsicontrol -> FriendSetExtAddress(mId, rsPeers->setExtAddress(mId,
ui.extAddress->text().toStdString(), ui.extPort->value()); ui.extAddress->text().toStdString(), ui.extPort->value());
if (dnsChanged) #if 0
rsicontrol -> FriendSetDNSAddress(mId, ui.extName->text().toStdString());
if (fwChanged) if (fwChanged)
rsicontrol -> FriendSetFirewall(mId, ui.chkFirewall->isChecked(), rsicontrol -> FriendSetFirewall(mId, ui.chkFirewall->isChecked(),
ui.chkForwarded->isChecked()); ui.chkForwarded->isChecked());
#endif
if (trustChanged) if (trustChanged)
rsicontrol -> FriendTrustSignature(mId, ui.trustBox->isChecked()); rsPeers->TrustCertificate(mId, ui.trustBox->isChecked());
if (signChanged) if (signChanged)
rsicontrol -> FriendSignCert(mId); rsPeers->SignCertificate(mId);
/* reload now */ /* reload now */
loadDialog(); loadDialog();

View File

@ -25,7 +25,9 @@
#include "ConnectDialog.h" #include "ConnectDialog.h"
#include "rsiface/rsiface.h" #include "rsiface/rsiface.h"
#include "rsiface/rspeers.h"
#include <iostream> #include <iostream>
#include <sstream>
/** Default constructor */ /** Default constructor */
ConnectDialog::ConnectDialog(QWidget *parent, Qt::WFlags flags) ConnectDialog::ConnectDialog(QWidget *parent, Qt::WFlags flags)
@ -124,8 +126,8 @@ void ConnectDialog::authAttempt()
/* well lets do it ! */ /* well lets do it ! */
std::cerr << "Attempting AuthCode:" << authCode << std::endl; std::cerr << "Attempting AuthCode:" << authCode << std::endl;
rsicontrol -> NeighAuthFriend(authId, authCode); rsPeers->AuthCertificate(authId, authCode);
rsicontrol -> NeighAddFriend(authId); rsPeers->addFriend(authId);
/* close it up! */ /* close it up! */
closeinfodlg(); closeinfodlg();
@ -133,42 +135,44 @@ void ConnectDialog::authAttempt()
bool ConnectDialog::loadPeer(std::string id) bool ConnectDialog::loadPeer(std::string id)
{ {
std::map<RsCertId,NeighbourInfo>::const_iterator it; RsPeerDetails detail;
/* first grab the list of signers (outside lock) */ if (!rsPeers->getPeerDetails(id, detail))
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())
{ {
rsiface->unlockData(); /* UnLock Interface */ rsiface->unlockData(); /* UnLock Interface */
return false; 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 */ /* setup the gui */
setInfo(it->second.name, it->second.trustString, it->second.org, setInfo(detail.name, trustString, detail.org,
it->second.loc, it->second.country, signersString); detail.location, detail.email, out.str());
setAuthCode(id, it->second.authCode); setAuthCode(id, detail.authcode);
rsiface->unlockData(); /* UnLock Interface */
return true; return true;
} }

View File

@ -22,7 +22,9 @@
#include "rshare.h" #include "rshare.h"
#include "ChanMsgDialog.h" #include "ChanMsgDialog.h"
#include "rsiface/rsiface.h" #include "rsiface/rsiface.h"
#include "rsiface/rspeers.h"
#include <sstream> #include <sstream>
#include <QContextMenuEvent> #include <QContextMenuEvent>
@ -128,53 +130,52 @@ void ChanMsgDialog::createchannelmsg()
void ChanMsgDialog::insertSendList() void ChanMsgDialog::insertSendList()
{ {
rsiface->lockData(); /* Lock Interface */ if (!rsPeers)
{
std::map<RsCertId,NeighbourInfo>::const_iterator it; /* not ready yet! */
const std::map<RsCertId,NeighbourInfo> &friends = return;
rsiface->getFriendMap(); }
std::list<std::string> peers;
std::list<std::string>::iterator it;
rsPeers->getFriendList(peers);
/* get a link to the table */ /* get a link to the table */
QTreeWidget *sendWidget = ui.msgSendList; QTreeWidget *sendWidget = ui.msgSendList;
/* remove old items ??? */
sendWidget->clear();
sendWidget->setColumnCount(1);
QList<QTreeWidgetItem *> items; QList<QTreeWidgetItem *> items;
for(it = friends.begin(); it != friends.end(); it++) for(it = peers.begin(); it != peers.end(); it++)
{ {
if (it -> second.connectString == "Yourself")
RsPeerDetails detail;
if (!rsPeers->getPeerDetails(*it, detail))
{ {
/* ok */ continue; /* BAD */
continue;
} }
/* make a widget per friend */ /* make a widget per friend */
QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0); QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);
/* add all the labels */ /* add all the labels */
/* (0) Person */ /* (0) Person */
item -> setText(0, QString::fromStdString(it->second.name)); item -> setText(0, QString::fromStdString(detail.name));
/* () Org */ /* () Org */
//item -> setText(1, QString::fromStdString(it->second.org)); item -> setText(1, QString::fromStdString(detail.org));
/* () Location */ /* () Location */
//item -> setText(2, QString::fromStdString(it->second.loc)); item -> setText(2, QString::fromStdString(detail.location));
/* () Country */ /* () Country */
//item -> setText(3, QString::fromStdString(it->second.country)); item -> setText(3, QString::fromStdString(detail.email));
/*{ /* () Id */
std::ostringstream out; item -> setText(4, QString::fromStdString(detail.id));
out << it->second.id;
item -> setText(4, QString::fromStdString(out.str()));
}*/
item -> setText(1, "Friend");
item -> setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled); item -> setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
//item -> setCheckState(0, Qt::Checked); //item -> setCheckState(0, Qt::Checked);
// //
item -> setCheckState(0, Qt::Unchecked);
#if 0
if (it -> second.inMsg) if (it -> second.inMsg)
{ {
item -> setCheckState(0, Qt::Checked); item -> setCheckState(0, Qt::Checked);
@ -183,16 +184,19 @@ void ChanMsgDialog::insertSendList()
{ {
item -> setCheckState(0, Qt::Unchecked); item -> setCheckState(0, Qt::Unchecked);
} }
#endif
/* add to the list */ /* add to the list */
items.append(item); items.append(item);
} }
/* remove old items ??? */
sendWidget->clear();
sendWidget->setColumnCount(6);
/* add the items in! */ /* add the items in! */
sendWidget->insertTopLevelItems(0, items); sendWidget->insertTopLevelItems(0, items);
rsiface->unlockData(); /* UnLock Interface */
sendWidget->update(); /* update display */ sendWidget->update(); /* update display */
} }
@ -389,13 +393,15 @@ void ChanMsgDialog::sendMessage()
} }
} }
std::list<std::string> persons;
std::list<std::string>::iterator it3;
#if 0
/* get a list of people to send it to */ /* get a list of people to send it to */
std::map<RsCertId,NeighbourInfo>::const_iterator it2; std::map<RsCertId,NeighbourInfo>::const_iterator it2;
const std::map<RsCertId,NeighbourInfo> &friends = const std::map<RsCertId,NeighbourInfo> &friends =
rsiface->getFriendMap(); rsiface->getFriendMap();
std::list<std::string> persons;
std::list<std::string>::iterator it3;
for(it2 = friends.begin(); it2 != friends.end(); it2++) for(it2 = friends.begin(); it2 != friends.end(); it2++)
{ {
@ -408,6 +414,7 @@ void ChanMsgDialog::sendMessage()
persons.push_back(out.str()); persons.push_back(out.str());
} }
} }
#endif
rsiface->unlockData(); /* UnLock Interface */ rsiface->unlockData(); /* UnLock Interface */

View File

@ -115,6 +115,23 @@ void NotifyQt::UpdateGUI()
iface->unlockData(); /* UnLock Interface */ iface->unlockData(); /* UnLock Interface */
/* hack to force updates until we've fixed that part */
static time_t lastTs = 0;
if (time(NULL) > lastTs + 5)
{
lastTs = time(NULL);
uNeigh = true;
uFri = true;
uTrans = true;
uChat = true;
uMsg = true;
uChan = true;
uRecom = true;
uConf = true;
}
if (uNeigh) if (uNeigh)
displayNeighbours(); displayNeighbours();
@ -148,24 +165,6 @@ void NotifyQt::UpdateGUI()
void NotifyQt::displayNeighbours() void NotifyQt::displayNeighbours()
{ {
iface->lockData(); /* Lock Interface */
std::map<RsCertId,NeighbourInfo>::const_iterator it;
const std::map<RsCertId,NeighbourInfo> &neighs = iface->getNeighbourMap();
std::ostringstream out;
for(it = neighs.begin(); it != neighs.end(); it++)
{
out << "Neighbour: ";
out << it ->second.name << " ";
out << it ->second.status << " ";
out << it ->second.trustLvl << " ";
out << std::endl;
}
std::cerr << out.str();
iface->unlockData(); /* UnLock Interface */
/* Do the GUI */ /* Do the GUI */
if (cDialog) if (cDialog)
cDialog->insertConnect(); cDialog->insertConnect();
@ -173,24 +172,6 @@ void NotifyQt::displayNeighbours()
void NotifyQt::displayFriends() void NotifyQt::displayFriends()
{ {
iface->lockData(); /* Lock Interface */
std::map<RsCertId,NeighbourInfo>::const_iterator it;
const std::map<RsCertId,NeighbourInfo> &friends = iface->getFriendMap();
std::ostringstream out;
for(it = friends.begin(); it != friends.end(); it++)
{
out << "Friend: ";
out << it->second.name << " ";
out << it->second.status << " ";
out << it->second.trustLvl << " ";
out << std::endl;
}
std::cerr << out.str();
iface->unlockData(); /* UnLock Interface */
if (pDialog) if (pDialog)
pDialog->insertPeers(); pDialog->insertPeers();
if (mWindow) if (mWindow)

View File

@ -0,0 +1,113 @@
#ifndef RS_GAME_GUI_INTERFACE_H
#define RS_GAME_GUI_INTERFACE_H
/*
* libretroshare/src/rsiface: rsgame.h
*
* RetroShare C++ Interface.
*
* Copyright 2007-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "rstypes.h"
class RsGameLauncher;
/* declare single RsIface for everyone to use! */
extern RsGameLauncher *rsGameLauncher;
#include <map>
#include <string>
#include <inttypes.h>
class RsGameInfo
{
public:
std::string gameId;
std::string serverId;
std::string gameType;
std::string gameName;
std::string serverName;
std::string status;
uint16_t numPlayers;
};
class RsGamePeer
{
public:
std::string name;
bool invite;
bool interested;
bool play;
};
class RsGameDetail
{
public:
std::string gameId;
std::string gameType;
std::string gameName;
bool areServer; /* are we the server? */
std::string serverId; /* if not, who is? */
std::string serverName;
std::string status;
uint16_t numPlayers;
std::map<std::string, RsGamePeer> gamers;
};
class RsGameLauncher
{
public:
/* server commands */
virtual std::string createGame(uint32_t gameType, std::string name) = 0;
virtual bool deleteGame(std::string gameId) = 0;
virtual bool inviteGame(std::string gameId) = 0;
virtual bool playGame(std::string gameId) = 0;
//virtual bool quitGame(std::string gameId) = 0;
virtual bool invitePeer(std::string gameId, std::string peerId) = 0;
virtual bool uninvitePeer(std::string gameId, std::string peerId) = 0;
virtual bool confirmPeer(std::string gameId, std::string peerId,
int16_t pos = -1) = 0;
virtual bool unconfirmPeer(std::string gameId, std::string peerId) = 0;
/* client commands */
virtual bool interestedPeer(std::string gameId) = 0;
virtual bool uninterestedPeer(std::string gameId) = 0;
/* get details */
virtual bool getGameList(std::list<RsGameInfo> &gameList) = 0;
virtual bool getGameDetail(std::string gameId, RsGameDetail &detail) = 0;
};
#endif

View File

@ -86,14 +86,6 @@ public:
virtual void lockData() = 0; virtual void lockData() = 0;
virtual void unlockData() = 0; virtual void unlockData() = 0;
const std::map<RsCertId,NeighbourInfo> &getNeighbourMap()
{ return mNeighbourMap; }
const std::map<RsCertId,NeighbourInfo> &getFriendMap()
{ return mFriendMap; }
const NeighbourInfo * getFriend(std::string id);
const std::list<FileTransferInfo> &getTransferList() const std::list<FileTransferInfo> &getTransferList()
{ return mTransferList; } { return mTransferList; }
@ -167,8 +159,6 @@ bool hasChanged(DataFlags set); /* resets it */
void fillLists(); /* create some dummy data to display */ void fillLists(); /* create some dummy data to display */
/* Internals */ /* Internals */
std::map<RsCertId,NeighbourInfo> mNeighbourMap;
std::map<RsCertId,NeighbourInfo> mFriendMap;
std::list<PersonInfo> mRemoteDirList; std::list<PersonInfo> mRemoteDirList;
std::list<PersonInfo> mLocalDirList; std::list<PersonInfo> mLocalDirList;
std::list<FileTransferInfo> mTransferList; std::list<FileTransferInfo> mTransferList;
@ -202,38 +192,6 @@ virtual ~RsControl() { return; }
/* Real Startup Fn */ /* Real Startup Fn */
virtual int StartupRetroShare(RsInit *config) = 0; virtual int StartupRetroShare(RsInit *config) = 0;
/****************************************/
/* Neighbour Operations */
virtual std::string NeighGetInvite() = 0;
virtual int NeighLoadPEMString(std::string pem, std::string &id) = 0;
virtual int NeighLoadCertificate(std::string fname, std::string &id) = 0;
virtual int NeighAuthFriend(std::string id, RsAuthId code) = 0;
virtual int NeighAddFriend(std::string id) = 0;
virtual int NeighGetSigners(std::string uid, char *out, int len) = 0;
/****************************************/
/* Friend Operations */
virtual int FriendStatus(std::string id, bool accept) = 0;
virtual int FriendRemove(std::string id) = 0;
virtual int FriendConnectAttempt(std::string id) = 0;
virtual int FriendSignCert(std::string id) = 0;
virtual int FriendTrustSignature(std::string id, bool trust) = 0;
virtual int FriendSetLocalAddress(std::string id, std::string addr,
unsigned short port) = 0;
virtual int FriendSetExtAddress(std::string id, std::string addr,
unsigned short port) = 0;
virtual int FriendSetDNSAddress(std::string id, std::string addr) = 0;
virtual int FriendSetFirewall(std::string id, bool firewalled, bool forwarded) = 0;
virtual int FriendSaveCertificate(std::string id, std::string fname) = 0;
/*
virtual int FriendSetConnectMode(std::string id, int mode) = 0;
*/
virtual int FriendSetBandwidth(std::string id, float outkB, float inkB) = 0;
/****************************************/ /****************************************/
/* Directory Actions */ /* Directory Actions */
virtual int RequestDirDetails(std::string uid, std::string path, DirDetails &details) = 0; virtual int RequestDirDetails(std::string uid, std::string path, DirDetails &details) = 0;
@ -288,8 +246,8 @@ virtual int ClearInRecommend() = 0;
/****************************************/ /****************************************/
/* RsIface Networking */ /* RsIface Networking */
virtual int NetworkDHTActive(bool active) = 0; //virtual int NetworkDHTActive(bool active) = 0;
virtual int NetworkUPnPActive(bool active) = 0; //virtual int NetworkUPnPActive(bool active) = 0;
/****************************************/ /****************************************/
/* Config */ /* Config */
@ -297,14 +255,9 @@ virtual int ConfigAddSharedDir( std::string dir ) = 0;
virtual int ConfigRemoveSharedDir( std::string dir ) = 0; virtual int ConfigRemoveSharedDir( std::string dir ) = 0;
virtual int ConfigSetIncomingDir( std::string dir ) = 0; virtual int ConfigSetIncomingDir( std::string dir ) = 0;
virtual int ConfigSetLocalAddr( std::string ipAddr, int port ) = 0;
virtual int ConfigSetExtAddr( std::string ipAddr, int port ) = 0;
virtual int ConfigSetExtName( std::string addr ) = 0;
virtual int ConfigSetLanConfig( bool fire, bool forw ) = 0;
virtual int ConfigSetDataRates( int total, int indiv ) = 0; virtual int ConfigSetDataRates( int total, int indiv ) = 0;
virtual int ConfigSetBootPrompt( bool on ) = 0; virtual int ConfigSetBootPrompt( bool on ) = 0;
virtual int ConfigSave( ) = 0; //virtual int ConfigSave( ) = 0;
/****************************************/ /****************************************/

View File

@ -0,0 +1,147 @@
#ifndef RETROSHARE_PEER_GUI_INTERFACE_H
#define RETROSHARE_PEER_GUI_INTERFACE_H
/*
* libretroshare/src/rsiface: rspeer.h
*
* RetroShare C++ Interface.
*
* Copyright 2004-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include <inttypes.h>
#include <string>
#include <list>
/* The Main Interface Class - for information about your Peers */
class RsPeers;
extern RsPeers *rsPeers;
/* Trust Levels */
const uint32_t RS_TRUST_LVL_UNKNOWN = 0x0001;
const uint32_t RS_TRUST_LVL_MARGINAL = 0x0002;
const uint32_t RS_TRUST_LVL_GOOD = 0x0003;
/* Net Mode */
const uint32_t RS_NETMODE_UDP = 0x0001;
const uint32_t RS_NETMODE_UPNP = 0x0002;
const uint32_t RS_NETMODE_EXT = 0x0003;
/* State */
const uint32_t RS_PEER_STATE_FRIEND = 0x0001;
const uint32_t RS_PEER_STATE_ONLINE = 0x0002;
const uint32_t RS_PEER_STATE_CONNECTED = 0x0004;
/* A couple of helper functions for translating the numbers games */
std::string RsPeerTrustString(uint32_t trustLvl);
std::string RsPeerStateString(uint32_t state);
std::string RsPeerNetModeString(uint32_t netModel);
std::string RsPeerLastConnectString(uint32_t lastConnect);
/* Details class */
class RsPeerDetails
{
public:
RsPeerDetails();
/* Auth details */
std::string id;
std::string name;
std::string email;
std::string location;
std::string org;
std::string fpr; /* fingerprint */
std::string authcode;
std::list<std::string> signers;
uint32_t trustLvl;
bool ownsign; /* we have signed certificate */
bool trusted; /* we trust their signature on others */
/* Network details (only valid if friend) */
uint32_t state;
std::string localAddr;
uint16_t localPort;
std::string extAddr;
uint16_t extPort;
uint32_t netMode;
/* basic stats */
uint32_t lastConnect; /* how long ago */
uint32_t connectPeriod;
};
std::ostream &operator<<(std::ostream &out, const RsPeerDetails &detail);
class RsPeers
{
public:
RsPeers() { return; }
virtual ~RsPeers() { return; }
/* Updates ... */
virtual bool FriendsChanged() = 0;
virtual bool OthersChanged() = 0;
/* Peer Details (Net & Auth) */
virtual std::string getOwnId() = 0;
virtual bool getOnlineList(std::list<std::string> &ids) = 0;
virtual bool getFriendList(std::list<std::string> &ids) = 0;
virtual bool getOthersList(std::list<std::string> &ids) = 0;
virtual bool isFriend(std::string id) = 0;
virtual std::string getPeerName(std::string id) = 0;
virtual bool getPeerDetails(std::string id, RsPeerDetails &d) = 0;
/* Add/Remove Friends */
virtual bool addFriend(std::string id) = 0;
virtual bool removeFriend(std::string id) = 0;
/* Network Stuff */
virtual bool connectAttempt(std::string id) = 0;
virtual bool setLocalAddress(std::string id, std::string addr, uint16_t port) = 0;
virtual bool setExtAddress( std::string id, std::string addr, uint16_t port) = 0;
virtual bool setNetworkMode(std::string id, uint32_t netMode) = 0;
/* Auth Stuff */
virtual std::string GetRetroshareInvite() = 0;
virtual bool LoadCertificateFromFile(std::string fname, std::string &id) = 0;
virtual bool LoadCertificateFromString(std::string cert, std::string &id) = 0;
virtual bool SaveCertificateToFile(std::string id, std::string fname) = 0;
virtual std::string SaveCertificateToString(std::string id) = 0;
virtual bool AuthCertificate(std::string id, std::string code) = 0;
virtual bool SignCertificate(std::string id) = 0;
virtual bool TrustCertificate(std::string id, bool trust) = 0;
};
#endif

View File

@ -75,48 +75,6 @@ class BaseInfo
mutable unsigned int mId; /* (GUI) Model Id -> unique number */ mutable unsigned int mId; /* (GUI) Model Id -> unique number */
}; };
class NeighbourInfo: public BaseInfo
{
public:
std::string name;
std::string org;
std::string loc;
std::string state;
std::string country;
int trustLvl;
std::string trustString;
std::list<RsCertId> signers;
std::string authCode;
int status;
std::string acceptString;
std::string statusString;
std::string connectString;
std::string lastConnect;
std::string peerAddress;
/* server settings */
std::string localAddr;
int localPort;
std::string extAddr;
int extPort;
std::string extName;
bool firewalled;
bool forwardPort;
int maxRate; /* kb */
bool ownsign;
/* Flags to indicate if they are in
* chat or msg list
*/
bool inChat;
bool inMsg;
};
/********************** For the Directory Listing *****************/ /********************** For the Directory Listing *****************/
class FileInfo: public BaseInfo class FileInfo: public BaseInfo
@ -345,7 +303,6 @@ class SearchRequest
}; };
std::ostream &operator<<(std::ostream &out, const NeighbourInfo &info);
std::ostream &operator<<(std::ostream &out, const MessageInfo &info); std::ostream &operator<<(std::ostream &out, const MessageInfo &info);
std::ostream &operator<<(std::ostream &out, const ChannelInfo &info); std::ostream &operator<<(std::ostream &out, const ChannelInfo &info);
std::ostream &operator<<(std::ostream &out, const ChatInfo &info); std::ostream &operator<<(std::ostream &out, const ChatInfo &info);