Пример #1
0
void NetworkDialog::connectTreeWidgetCostumPopupMenu( QPoint /*point*/ )
{
	//std::cerr << "NetworkDialog::connectTreeWidgetCostumPopupMenu( QPoint point ) called" << std::endl;
	QTreeWidgetItem *wi = getCurrentNeighbour();
	if (!wi)
		return;

	QMenu *contextMnu = new QMenu;

    RsPgpId peer_id(wi->text(COLUMN_PEERID).toStdString()) ;

	// That's what context menus are made for
	RsPeerDetails detail;
	if(!rsPeers->getGPGDetails(peer_id, detail))		// that is not suppose to fail.
		return ;

    if(peer_id != rsPeers->getGPGOwnId())
    {
        if(detail.accept_connection)
            contextMnu->addAction(QIcon(IMAGE_DENIED), tr("Deny friend"), this, SLOT(denyFriend()));
        else	// not a friend
            contextMnu->addAction(QIcon(IMAGE_MAKEFRIEND), tr("Make friend..."), this, SLOT(makeFriend()));
    }
	if(peer_id == rsPeers->getGPGOwnId())
		contextMnu->addAction(QIcon(IMAGE_EXPORT), tr("Export/create a new node"), this, SLOT(on_actionExportKey_activated()));

	contextMnu->addAction(QIcon(IMAGE_PEERDETAILS), tr("Peer details..."), this, SLOT(peerdetails()));
   //contextMnu->addAction(QIcon(IMAGE_MESSAGE), tr("Send Message"), this, SLOT(sendDistantMessage()));
	//contextMnu->addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyLink()));
	contextMnu->addSeparator() ;
	contextMnu->addAction(QIcon(IMAGE_CLEAN_UNUSED), tr("Remove unused keys..."), this, SLOT(removeUnusedKeys()));

	contextMnu->exec(QCursor::pos());
}
Пример #2
0
/** Shows Peer Information/Auth Dialog */
void NetworkDialog::peerdetails()
{
	QTreeWidgetItem* item = getCurrentNeighbour();
	if (item == NULL) {
		return;
	}
    PGPKeyDialog::showIt(RsPgpId(item->text(COLUMN_PEERID).toStdString()), PGPKeyDialog::PageDetails);
}
Пример #3
0
void NetworkDialog::denyFriend()
{
	QTreeWidgetItem *wi = getCurrentNeighbour();
    RsPgpId peer_id( wi->text(COLUMN_PEERID).toStdString() );
	rsPeers->removeFriend(peer_id) ;

	securedUpdateDisplay();
}
Пример #4
0
void NetworkDialog::denyFriend()
{
	QTreeWidgetItem *wi = getCurrentNeighbour();
	std::string peer_id = wi->text(COLUMN_PEERID).toStdString() ;
	rsPeers->removeFriend(peer_id) ;

	insertConnect() ;
}
Пример #5
0
void NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint /*point*/ )
{
	//std::cerr << "NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint point ) called" << std::endl;
	QTreeWidgetItem *wi = getCurrentNeighbour();
	if (!wi)
		return;

	QMenu *contextMnu = new QMenu;

	std::string peer_id = wi->text(COLUMN_PEERID).toStdString() ;

	// That's what context menus are made for
	RsPeerDetails detail;
	if(!rsPeers->getGPGDetails(peer_id, detail))		// that is not suppose to fail.
		return ;

	if(peer_id != rsPeers->getGPGOwnId())
	{
		if(detail.accept_connection)
		{
			QAction* denyFriendAct = new QAction(QIcon(IMAGE_DENIED), tr( "Deny friend" ), contextMnu );

			connect( denyFriendAct , SIGNAL( triggered() ), this, SLOT( denyFriend() ) );
			contextMnu->addAction( denyFriendAct);
		}
		else	// not a friend
		{
			QAction* makefriendAct = new QAction(QIcon(IMAGE_MAKEFRIEND), tr( "Make friend" ), contextMnu );

			connect( makefriendAct , SIGNAL( triggered() ), this, SLOT( makeFriend() ) );
			contextMnu->addAction( makefriendAct);
#ifdef TODO
			if(detail.validLvl > RS_TRUST_LVL_MARGINAL)		// it's a denied old friend.
			{
				QAction* deleteCertAct = new QAction(QIcon(IMAGE_PEERDETAILS), tr( "Delete certificate" ), contextMnu );
				connect( deleteCertAct, SIGNAL( triggered() ), this, SLOT( deleteCert() ) );
				contextMnu->addAction( deleteCertAct );
			}

#endif
		}
	}
	if(peer_id == rsPeers->getGPGOwnId())
	{
		QAction* exportcertAct = new QAction(QIcon(IMAGE_EXPORT), tr( "Export my Cert" ), contextMnu );
		connect( exportcertAct , SIGNAL( triggered() ), this, SLOT( on_actionExportKey_activated() ) );
		contextMnu->addAction( exportcertAct);
	}

	QAction* peerdetailsAct = new QAction(QIcon(IMAGE_PEERDETAILS), tr( "Peer details..." ), contextMnu );
	connect( peerdetailsAct , SIGNAL( triggered() ), this, SLOT( peerdetails() ) );
	contextMnu->addAction( peerdetailsAct);

	contextMnu->addAction(QIcon(IMAGE_COPYLINK), tr("Copy RetroShare Link"), this, SLOT(copyLink()));

	contextMnu->exec(QCursor::pos());
}
Пример #6
0
void NetworkDialog::addneighbour()
{
        QTreeWidgetItem *c = getCurrentNeighbour();
#ifdef NET_DEBUG 
        std::cerr << "ConnectionsDialog::addneighbour()" << std::endl;
#endif
        /*
        rsServer->NeighAddFriend(getNeighRsCertId(c));
        */
}
Пример #7
0
void NetworkDialog::makeFriend()
{
	QTreeWidgetItem *wi = getCurrentNeighbour();
	std::string authId = wi->text(9).toStdString() ;

	rsPeers->AuthCertificate(authId, "");
	rsPeers->addFriend(authId);

	insertConnect() ;
}
Пример #8
0
void NetworkDialog::authneighbour()
{
        QTreeWidgetItem *c = getCurrentNeighbour();
#ifdef NET_DEBUG 
        std::cerr << "ConnectionsDialog::authneighbour()" << std::endl;
#endif
        /*
	RsAuthId code;
        rsServer->NeighAuthFriend(getNeighRsCertId(c), code);
        */
}
Пример #9
0
void NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint point )
{

    QTreeWidgetItem *wi = getCurrentNeighbour();
    if (!wi)
    	return;

//		 return ;

      QMenu contextMnu( this );
      QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
      contextMnu.clear();

		std::string peer_id = wi->text(9).toStdString() ;

			// That's what context menus are made for
		RsPeerDetails detail;
		if(!rsPeers->getPeerDetails(peer_id, detail))		// that is not suppose to fail.
			return ;

		if(peer_id != rsPeers->getOwnId())
			if(detail.state & RS_PEER_STATE_FRIEND)
			{
				denyFriendAct = new QAction(QIcon(IMAGE_DENIED), tr( "Deny friend" ), this );

				connect( denyFriendAct , SIGNAL( triggered() ), this, SLOT( denyFriend() ) );
				contextMnu.addAction( denyFriendAct);
			}
			else	// not a friend
			{
				if(detail.trustLvl > RS_TRUST_LVL_MARGINAL)		// it's a denied old friend.
					makefriendAct = new QAction(QIcon(IMAGE_MAKEFRIEND), tr( "Accept friend" ), this );
				else
					makefriendAct = new QAction(QIcon(IMAGE_MAKEFRIEND), tr( "Make friend" ), this );

				connect( makefriendAct , SIGNAL( triggered() ), this, SLOT( makeFriend() ) );
				contextMnu.addAction( makefriendAct);
#ifdef TODO
				if(detail.trustLvl > RS_TRUST_LVL_MARGINAL)		// it's a denied old friend.
				{
					deleteCertAct = new QAction(QIcon(IMAGE_PEERDETAILS), tr( "Delete certificate" ), this );
					connect( deleteCertAct, SIGNAL( triggered() ), this, SLOT( deleteCert() ) );
					contextMnu.addAction( deleteCertAct );
				}
#endif
			}

		peerdetailsAct = new QAction(QIcon(IMAGE_PEERDETAILS), tr( "Peer details..." ), this );
		connect( peerdetailsAct , SIGNAL( triggered() ), this, SLOT( peerdetails() ) );
		contextMnu.addAction( peerdetailsAct);

		contextMnu.exec( mevent->globalPos() );
}
Пример #10
0
void NetworkDialog::deleteCert()
{
#ifdef TODO
	// do whatever is needed to remove the certificate completely, hopping this
	// will eventually remove the signature we've stamped on it.
	std::cout << "Deleting friend !" << std::endl ;

	QTreeWidgetItem *wi = getCurrentNeighbour();
	std::string peer_id = wi->text(9).toStdString() ;
	rsPeers->deleteCertificate(peer_id) ;

	insertConnect() ;
#endif
}
Пример #11
0
void NetworkDialog::copyLink()
{
	QTreeWidgetItem *wi = getCurrentNeighbour();
	if (wi == NULL) {
		return;
	}

    RsPgpId peer_id ( wi->text(COLUMN_PEERID).toStdString() ) ;

	QList<RetroShareLink> urls;
	RetroShareLink link;
	if (link.createPerson(peer_id)) {
		urls.push_back(link);
	}

	RSLinkClipboard::copyLinks(urls);
}
Пример #12
0
/** Shows Peer Information/Auth Dialog */
void NetworkDialog::peerdetails()
{
#if 0
#ifdef NET_DEBUG 
    std::cerr << "ConnectionsDialog::peerdetails()" << std::endl;
#endif

    QTreeWidgetItem *wi = 
    if (!wi)
    	return;

    RsCertId id = getNeighRsCertId(wi);
    std::ostringstream out;
    out << id;

    showpeerdetails(out.str());
#endif
	 ConfCertDialog::show(getCurrentNeighbour()->text(9).toStdString());
}
Пример #13
0
void NetworkDialog::makeFriend()
{
    PGPKeyDialog::showIt(RsPgpId(getCurrentNeighbour()->text(COLUMN_PEERID).toStdString()), PGPKeyDialog::PageDetails);
}
Пример #14
0
void NetworkDialog::makeFriend()
{
	ConfCertDialog::showIt(getCurrentNeighbour()->text(COLUMN_PEERID).toStdString(), ConfCertDialog::PageTrust);
}
Пример #15
0
/* get the list of Neighbours from the RsIface.  */
void NetworkDialog::insertConnect()
{
	if (!rsPeers)
	{
		return;
	}

	std::list<std::string> neighs;
	std::list<std::string>::iterator it;
	rsPeers->getOthersList(neighs);

	/* get a link to the table */
        QTreeWidget *connectWidget = ui.connecttreeWidget;
	QTreeWidgetItem *oldSelect = getCurrentNeighbour();
	QTreeWidgetItem *newSelect = NULL;
	std::string oldId;
	if (oldSelect)
	{
		oldId = (oldSelect -> text(9)).toStdString();
	}

        QList<QTreeWidgetItem *> items;
	for(it = neighs.begin(); it != neighs.end(); it++)
	{
		RsPeerDetails detail;
		if (!rsPeers->getPeerDetails(*it, detail))
		{
			continue; /* BAD */
		}

		/* make a widget per friend */
           	QTreeWidgetItem *item = new QTreeWidgetItem((QTreeWidget*)0);

		/* add all the labels */
		
	        /* (0) Status Icon */
		item -> setText(0, "");

		/* (1) Accept/Deny */
		if (detail.state & RS_PEER_STATE_FRIEND)
			item -> setText(1, tr("Trusted"));
		else
			item -> setText(1, tr("Denied"));

		if (rsPeers->isTrustingMe(detail.id) || detail.lastConnect>0)
			item -> setText(2, tr("Is trusting me"));
		else
			item -> setText(2, tr("Unknown"));

		/* (3) Last Connect */
		{
			std::ostringstream out;
			// Show anouncement if a friend never was connected.
			if (detail.lastConnect==0 ) 
				item -> setText(3, tr("Never seen"));
			else 
			{
				// Dont Show a timestamp in RS calculate the day
				QDateTime datum = QDateTime::fromTime_t(detail.lastConnect);
				// out << datum.toString(Qt::LocalDate);
				QString stime = datum.toString(Qt::LocalDate);
				item -> setText(3, stime);
			}
		}
		
        	/* (4) Person */
		item -> setText(4, QString::fromStdString(detail.name));
		
		/* (5) Peer Address */
		{
			std::ostringstream out;
			if(detail.state & RS_PEER_STATE_FRIEND) {
				out << detail.localAddr << ":";
				out << detail.localPort << "/";
				out << detail.extAddr << ":";
				out << detail.extPort;
			} else {
				// No Trust => no IP Information
				out << "0.0.0.0:0/0.0.0.0:0";
			}
                	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;
			}
		}

		//item -> setText(10, QString::fromStdString(detail.authcode));

		/**
		* Determinated the Background Color
		*/
		QColor backgrndcolor;
		
		if (detail.state & RS_PEER_STATE_FRIEND)
		{
			item -> setIcon(0,(QIcon(IMAGE_AUTHED)));
			backgrndcolor=Qt::green;
		}
		else
		{
			if (rsPeers->isTrustingMe(detail.id))
			{
				backgrndcolor=Qt::magenta;
				item -> setIcon(0,(QIcon(IMAGE_TRUSTED)));
				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."))) ;
			}
			else if (detail.trustLvl > RS_TRUST_LVL_MARGINAL)
			{
				backgrndcolor=Qt::cyan;
				item -> setIcon(0,(QIcon(IMAGE_DENIED)));
			}
			else if (detail.lastConnect < 10000) /* 3 hours? */
			{
				backgrndcolor=Qt::yellow;
				item -> setIcon(0,(QIcon(IMAGE_DENIED)));
			}
			else
			{
				backgrndcolor=Qt::gray;
				item -> setIcon(0,(QIcon(IMAGE_DENIED)));
			}
		}

		// Color each Background column in the Network Tab except the first one => 1-9
		// whith the determinated color
		for(int i = 1; i <10; i++)
			item -> setBackground(i,QBrush(backgrndcolor));

		/* add to the list */
		items.append(item);
	}

	// add self to network.
	RsPeerDetails pd ;
	if(rsPeers->getPeerDetails(rsPeers->getOwnId(),pd)) 
	{
		QTreeWidgetItem *self_item = new QTreeWidgetItem((QTreeWidget*)0);

		self_item->setText(1,"N/A");
		self_item->setText(2,"N/A");
		self_item->setText(3,"N/A");
		self_item->setText(4,QString::fromStdString(pd.name) + " (yourself)") ;

		std::ostringstream out;
		out << pd.localAddr << ":" << pd.localPort << "/" << pd.extAddr << ":" << pd.extPort;
		self_item->setText(5, QString::fromStdString(out.str()));
		self_item->setText(6, QString::fromStdString(pd.org));
		self_item->setText(7, QString::fromStdString(pd.location));
		self_item->setText(8, QString::fromStdString(pd.email));
		self_item->setText(9, QString::fromStdString(pd.id));

		// Color each Background column in the Network Tab except the first one => 1-9
		for(int i=1;i<10;++i)
		{
			self_item->setBackground(i,QBrush(Qt::green));
		}
		self_item->setIcon(0,(QIcon(IMAGE_AUTHED)));
		items.append(self_item);
	}

	/* remove old items ??? */
	connectWidget->clear();
	connectWidget->setColumnCount(10);	

	/* add the items in! */
	connectWidget->insertTopLevelItems(0, items);
	if (newSelect)
	{
		connectWidget->setCurrentItem(newSelect);
	}

	connectWidget->update(); /* update display */
}