From 2bd3fbf977bec600b78cc69cb48736d2561c4d67 Mon Sep 17 00:00:00 2001 From: csoler Date: Sun, 19 Sep 2021 20:05:19 +0200 Subject: [PATCH 1/2] made Options tab in Profiles Details window be disabled when the profile is not a friend --- retroshare-gui/src/gui/connect/PGPKeyDialog.cpp | 4 ++++ retroshare-gui/src/gui/connect/PGPKeyDialog.ui | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp b/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp index b167ca1ed..cc86593c4 100644 --- a/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp +++ b/retroshare-gui/src/gui/connect/PGPKeyDialog.cpp @@ -45,6 +45,8 @@ #include "util/DateTime.h" #include "util/misc.h" +#define FRIEND_OPTIONS_TAB_INDEX 2 + QMap PGPKeyDialog::instances_pgp; PGPKeyDialog *PGPKeyDialog::instance(const RsPgpId& pgp_id) @@ -199,11 +201,13 @@ void PGPKeyDialog::load() { ui.make_friend_button->hide(); ui.denyFriendButton->show(); + ui.stabWidget->setTabEnabled(FRIEND_OPTIONS_TAB_INDEX,true); } else { ui.make_friend_button->show(); ui.denyFriendButton->hide(); + ui.stabWidget->setTabEnabled(FRIEND_OPTIONS_TAB_INDEX,false); } //web of trust diff --git a/retroshare-gui/src/gui/connect/PGPKeyDialog.ui b/retroshare-gui/src/gui/connect/PGPKeyDialog.ui index 04b891fdf..d65df4758 100644 --- a/retroshare-gui/src/gui/connect/PGPKeyDialog.ui +++ b/retroshare-gui/src/gui/connect/PGPKeyDialog.ui @@ -393,7 +393,7 @@ p, li { white-space: pre-wrap; } - Options + Friend options From 9a440e077e8bd442fb92fa56cc68483ef5a4809d Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 21 Sep 2021 20:47:25 +0200 Subject: [PATCH 2/2] automatically close ongoing uploads when we stop sharing an extra file --- libretroshare/src/ft/ftcontroller.cc | 5 +++++ libretroshare/src/ft/ftcontroller.h | 1 + libretroshare/src/ft/ftdatamultiplex.cc | 17 +++++++++++++++++ libretroshare/src/ft/ftdatamultiplex.h | 6 +++--- libretroshare/src/ft/ftserver.cc | 5 ++++- 5 files changed, 30 insertions(+), 4 deletions(-) diff --git a/libretroshare/src/ft/ftcontroller.cc b/libretroshare/src/ft/ftcontroller.cc index 1dc0b1dad..b43139911 100644 --- a/libretroshare/src/ft/ftcontroller.cc +++ b/libretroshare/src/ft/ftcontroller.cc @@ -1541,6 +1541,11 @@ std::string ftController::getPartialsDirectory() return mPartialsPath; } +bool ftController::FileServerCancel(const RsFileHash& hash) +{ + RsStackMutex stack(ctrlMutex); /******* LOCKED ********/ + return mDataplex->deleteServer(hash); +} bool ftController::setDestinationDirectory(const RsFileHash& hash,const std::string& dest_dir) { RsStackMutex stack(ctrlMutex); /******* LOCKED ********/ diff --git a/libretroshare/src/ft/ftcontroller.h b/libretroshare/src/ft/ftcontroller.h index e890a83d6..854a3e3a1 100644 --- a/libretroshare/src/ft/ftcontroller.h +++ b/libretroshare/src/ft/ftcontroller.h @@ -157,6 +157,7 @@ public: bool getFileDownloadChunksDetails(const RsFileHash& hash,FileChunksInfo& info); bool setDestinationName(const RsFileHash& hash,const std::string& dest_name) ; bool setDestinationDirectory(const RsFileHash& hash,const std::string& dest_name) ; + bool FileServerCancel(const RsFileHash& hash); // Download speed bool getPriority(const RsFileHash& hash,DwlSpeed& p); diff --git a/libretroshare/src/ft/ftdatamultiplex.cc b/libretroshare/src/ft/ftdatamultiplex.cc index de8f1261c..f4b63be8b 100644 --- a/libretroshare/src/ft/ftdatamultiplex.cc +++ b/libretroshare/src/ft/ftdatamultiplex.cc @@ -1039,6 +1039,23 @@ void ftDataMultiplex::handlePendingCrcRequests() } } +bool ftDataMultiplex::deleteServer(const RsFileHash& hash) +{ + RsStackMutex stack(dataMtx); /******* LOCK MUTEX ******/ + + auto sit = mServers.find(hash); + + if(sit == mServers.end()) + return false; + + // We don't delete servers that are clients at the same time ! + if(dynamic_cast(sit->second) == NULL) + delete sit->second; + + mServers.erase(sit); + return true; +} + void ftDataMultiplex::deleteUnusedServers() { RsStackMutex stack(dataMtx); /******* LOCK MUTEX ******/ diff --git a/libretroshare/src/ft/ftdatamultiplex.h b/libretroshare/src/ft/ftdatamultiplex.h index 019940b63..6b15e7617 100644 --- a/libretroshare/src/ft/ftdatamultiplex.h +++ b/libretroshare/src/ft/ftdatamultiplex.h @@ -112,9 +112,9 @@ class ftDataMultiplex: public ftDataRecv, public RsQueueThread bool FileDownloads(std::list &hashs); bool FileDetails(const RsFileHash &hash, FileSearchFlags hintsflag, FileInfo &info); - void deleteUnusedServers() ; - void handlePendingCrcRequests() ; - + void deleteUnusedServers() ; + bool deleteServer(const RsFileHash& hash); // deletes FtServers for the given hash. Used when removing an extra file from shares. + void handlePendingCrcRequests() ; /*************** SEND INTERFACE (calls ftDataSend) *******************/ diff --git a/libretroshare/src/ft/ftserver.cc b/libretroshare/src/ft/ftserver.cc index 07a400acf..e8c7b504d 100644 --- a/libretroshare/src/ft/ftserver.cc +++ b/libretroshare/src/ft/ftserver.cc @@ -817,7 +817,10 @@ bool ftServer::ExtraFileAdd(std::string fname, const RsFileHash& hash, uint64_t } bool ftServer::ExtraFileRemove(const RsFileHash& hash) -{ return mFileDatabase->removeExtraFile(hash); } +{ + mFtController->FileServerCancel(hash); + return mFileDatabase->removeExtraFile(hash); +} bool ftServer::ExtraFileHash( std::string localpath, rstime_t period, TransferRequestFlags flags ) {