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()); }
void Heartbeat::handle_receive(boost::shared_ptr<boost::asio::ip::udp::endpoint> remote_ep, const boost::system::error_code& error, std::size_t bytes_transferred) { if (!error) { std::string peer_id(recv_buffer_.data()); if (myid_ != peer_id) { boost::asio::ip::address address = remote_ep->address(); std::string peer_ip = address.to_string(); // std::cout << "heartbeat from: " << peer_ip << " " << peer_id << std::endl; reflesh_peer(peer_id, peer_ip); } else { // std::cout << "xxxxxx\n"; } } else { std::cerr << error.message() << std::endl; } strand_->post(boost::bind(&Heartbeat::start_receive, this)); }
void NetworkDialog::denyFriend() { QTreeWidgetItem *wi = getCurrentNeighbour(); RsPgpId peer_id( wi->text(COLUMN_PEERID).toStdString() ); rsPeers->removeFriend(peer_id) ; securedUpdateDisplay(); }
void ServiceControlHandler::handleUser(Request& req, Response& resp){ // no get, only put (post) to allow user or delete to remove user std::string serviceidtext; std::string peeridtext; bool enabled; bool ok; req.mStream << makeKeyValueReference("service_id", serviceidtext) << makeKeyValueReference("peer_id", peeridtext) << makeKeyValueReference("enabled", enabled); RsPeerId peer_id(peeridtext); if (peer_id.isNull()) { resp.setFail("peer_id missing or not found"); return; } RsServicePermissions serv_perms ; uint32_t serviceid = atoi(serviceidtext.c_str()); if (serviceid == 0) { resp.setFail("service_id missed"); return; } if(!rsServiceControl->getServicePermissions(serviceid, serv_perms)){ resp.setFail("service_id " + serviceidtext + " is invalid"); return; } if(req.isPut()) { if (enabled && !serv_perms.peerHasPermission(peer_id)) { serv_perms.setPermission(peer_id); } else if (!enabled && serv_perms.peerHasPermission(peer_id)){ serv_perms.resetPermission(peer_id); } else { //nothing todo resp.setOk(); return; } } else { resp.setFail("only POST supported."); return; } ok = rsServiceControl->updateServicePermissions(serviceid,serv_perms); if (!ok) { resp.setFail("updateServicePermissions failed"); return; } resp.setOk(); }
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); }
lsd_peer_alert::lsd_peer_alert(aux::stack_allocator& alloc, torrent_handle const& h , tcp::endpoint const& i) : peer_alert(alloc, h, i, peer_id(0)) {}
lsd_peer_alert::lsd_peer_alert(torrent_handle const& h , tcp::endpoint const& i) : peer_alert(h, i, peer_id(0)) {}