From 589711d482b26d87f31eb59c92a1d174f5038c41 Mon Sep 17 00:00:00 2001 From: csoler Date: Wed, 17 Mar 2010 21:10:10 +0000 Subject: [PATCH] cleaned the config->Transfers tab, made the default chunk strategy combobox effective. git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5.0@2576 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/ft/ftcontroller.cc | 28 ++++ libretroshare/src/ft/ftcontroller.h | 3 + libretroshare/src/ft/ftserver.cc | 8 ++ libretroshare/src/ft/ftserver.h | 3 + libretroshare/src/rsiface/rsfiles.h | 2 + .../src/gui/settings/TransferPage.cpp | 75 +++------- .../src/gui/settings/TransferPage.h | 6 +- .../src/gui/settings/TransferPage.ui | 135 ++++++------------ 8 files changed, 110 insertions(+), 150 deletions(-) diff --git a/libretroshare/src/ft/ftcontroller.cc b/libretroshare/src/ft/ftcontroller.cc index eaca0383b..2008ea9e8 100644 --- a/libretroshare/src/ft/ftcontroller.cc +++ b/libretroshare/src/ft/ftcontroller.cc @@ -1147,6 +1147,8 @@ bool ftController::FileRequest(std::string fname, std::string hash, ftFileCreator *fc = new ftFileCreator(savepath, size, hash); ftTransferModule *tm = new ftTransferModule(fc, mDataplex,this); + fc->setChunkStrategy(mDefaultChunkStrategy) ; + /* add into maps */ ftFileControl *ftfc = new ftFileControl(fname, savepath, destination, size, hash, flags, fc, tm, callbackCode); ftfc->mCreateTime = time(NULL); @@ -1726,6 +1728,7 @@ bool ftController::CancelCacheFile(RsPeerId id, std::string path, std::string ha const std::string download_dir_ss("DOWN_DIR"); const std::string partial_dir_ss("PART_DIR"); const std::string share_dwl_dir("SHARE_DWL_DIR"); +const std::string default_chunk_strategy_ss("DEFAULT_CHUNK_STRATEGY"); /* p3Config Interface */ @@ -1757,6 +1760,7 @@ std::list ftController::saveList(bool &cleanup) configMap[download_dir_ss] = getDownloadDirectory(); configMap[partial_dir_ss] = getPartialsDirectory(); configMap[share_dwl_dir] = mShareDownloadDir ? "YES" : "NO"; + configMap[default_chunk_strategy_ss] = (mDefaultChunkStrategy==FileChunksInfo::CHUNK_STRATEGY_STREAMING) ? "STREAMING" : "RANDOM"; RsConfigKeyValueSet *rskv = new RsConfigKeyValueSet(); @@ -1940,15 +1944,39 @@ bool ftController::loadConfigMap(std::map &configMap) } } + if (configMap.end() != (mit = configMap.find(default_chunk_strategy_ss))) + { + if(mit->second == "STREAMING") + setDefaultChunkStrategy(FileChunksInfo::CHUNK_STRATEGY_STREAMING) ; + else if(mit->second == "RANDOM") + setDefaultChunkStrategy(FileChunksInfo::CHUNK_STRATEGY_RANDOM) ; + } + return true; } +FileChunksInfo::ChunkStrategy ftController::defaultChunkStrategy() +{ + RsStackMutex stack(ctrlMutex); /******* LOCKED ********/ + return mDefaultChunkStrategy ; +} +void ftController::setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy S) +{ + RsStackMutex stack(ctrlMutex); /******* LOCKED ********/ + mDefaultChunkStrategy = S ; + IndicateConfigChanged() ; +} + void ftController::setShareDownloadDirectory(bool value) { + RsStackMutex stack(ctrlMutex); /******* LOCKED ********/ mShareDownloadDir = value; + IndicateConfigChanged() ; } bool ftController::getShareDownloadDirectory() { + RsStackMutex stack(ctrlMutex); /******* LOCKED ********/ return mShareDownloadDir; } + diff --git a/libretroshare/src/ft/ftcontroller.h b/libretroshare/src/ft/ftcontroller.h index 2dd955f2e..ba1cf93cf 100644 --- a/libretroshare/src/ft/ftcontroller.h +++ b/libretroshare/src/ft/ftcontroller.h @@ -144,6 +144,8 @@ class ftController: public CacheTransfer, public RsThread, public pqiMonitor, pu bool alreadyHaveFile(const std::string& hash) ; bool setChunkStrategy(const std::string& hash,FileChunksInfo::ChunkStrategy s); + void setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy s); + FileChunksInfo::ChunkStrategy defaultChunkStrategy(); bool FileCancel(std::string hash); bool FileControl(std::string hash, uint32_t flags); @@ -265,6 +267,7 @@ class ftController: public CacheTransfer, public RsThread, public pqiMonitor, pu /* share incoming directory */ bool mShareDownloadDir; + FileChunksInfo::ChunkStrategy mDefaultChunkStrategy ; uint32_t _max_active_downloads ; // maximum number of simultaneous downloads }; diff --git a/libretroshare/src/ft/ftserver.cc b/libretroshare/src/ft/ftserver.cc index 5bbbb552f..7e63f126f 100644 --- a/libretroshare/src/ft/ftserver.cc +++ b/libretroshare/src/ft/ftserver.cc @@ -272,6 +272,14 @@ bool ftServer::setChunkStrategy(const std::string& hash,FileChunksInfo::ChunkStr { return mFtController->setChunkStrategy(hash,s); } +void ftServer::setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy) +{ + mFtController->defaultChunkStrategy() ; +} +FileChunksInfo::ChunkStrategy ftServer::defaultChunkStrategy() +{ + return mFtController->defaultChunkStrategy() ; +} bool ftServer::FileCancel(std::string hash) { diff --git a/libretroshare/src/ft/ftserver.h b/libretroshare/src/ft/ftserver.h index b70c3808b..fd764d760 100644 --- a/libretroshare/src/ft/ftserver.h +++ b/libretroshare/src/ft/ftserver.h @@ -125,6 +125,9 @@ virtual bool FileCancel(std::string hash); virtual bool FileControl(std::string hash, uint32_t flags); virtual bool FileClearCompleted(); virtual bool setChunkStrategy(const std::string& hash,FileChunksInfo::ChunkStrategy s) ; +virtual void setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy) ; +virtual FileChunksInfo::ChunkStrategy defaultChunkStrategy() ; + /*** * Control of Downloads Priority. diff --git a/libretroshare/src/rsiface/rsfiles.h b/libretroshare/src/rsiface/rsfiles.h index 4accaa49a..141997cc3 100644 --- a/libretroshare/src/rsiface/rsfiles.h +++ b/libretroshare/src/rsiface/rsfiles.h @@ -113,6 +113,8 @@ class RsFiles virtual bool FileRequest(std::string fname, std::string hash, uint64_t size, std::string dest, uint32_t flags, std::list srcIds) = 0; virtual bool FileCancel(std::string hash) = 0; virtual bool setChunkStrategy(const std::string& hash,FileChunksInfo::ChunkStrategy) = 0; + virtual void setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy) = 0; + virtual FileChunksInfo::ChunkStrategy defaultChunkStrategy() = 0; virtual bool FileControl(std::string hash, uint32_t flags) = 0; virtual bool FileClearCompleted() = 0; diff --git a/retroshare-gui/src/gui/settings/TransferPage.cpp b/retroshare-gui/src/gui/settings/TransferPage.cpp index 32df7c720..e07a60cfd 100644 --- a/retroshare-gui/src/gui/settings/TransferPage.cpp +++ b/retroshare-gui/src/gui/settings/TransferPage.cpp @@ -26,9 +26,9 @@ #include #include -#include "rsiface/rsiface.h" -#include "rsiface/rsfiles.h" -#include "rsiface/rspeers.h" +#include +#include +#include #include @@ -38,15 +38,15 @@ TransferPage::TransferPage(QWidget * parent, Qt::WFlags flags) /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); -// QTimer *timer = new QTimer(this); -// timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus())); -// timer->start(1000); - - updateStatus(); - ui._queueSize_SB->setValue(rsFiles->getQueueSize()) ; + if(rsFiles->defaultChunkStrategy() == FileChunksInfo::CHUNK_STRATEGY_STREAMING) + ui._defaultStrategy_CB->setCurrentIndex(0) ; + else + ui._defaultStrategy_CB->setCurrentIndex(1) ; + QObject::connect(ui._queueSize_SB,SIGNAL(valueChanged(int)),this,SLOT(updateQueueSize(int))) ; + QObject::connect(ui._defaultStrategy_CB,SIGNAL(activated(int)),this,SLOT(updateDefaultStrategy(int))) ; /* Hide platform specific features */ #ifdef Q_WS_WIN @@ -54,6 +54,20 @@ TransferPage::TransferPage(QWidget * parent, Qt::WFlags flags) #endif } +void TransferPage::updateDefaultStrategy(int i) +{ + switch(i) + { + case 0: rsFiles->setDefaultChunkStrategy(FileChunksInfo::CHUNK_STRATEGY_STREAMING) ; + break ; + + case 1: rsFiles->setDefaultChunkStrategy(FileChunksInfo::CHUNK_STRATEGY_RANDOM) ; + break ; + + default: ; + } +} + void TransferPage::updateQueueSize(int s) { rsFiles->setQueueSize(s) ; @@ -65,46 +79,3 @@ void TransferPage::closeEvent (QCloseEvent * event) } -/** Saves the changes on this page */ -bool -TransferPage::save(QString &errmsg) -{ - - /* save the server address */ - /* save local address */ - /* save the url for DNS access */ - - /* restart server */ - - /* save all? */ - //saveAddresses(); - return true; -} - -/** Loads the settings for this page */ -void TransferPage::load() -{ - - /* load up configuration from rsPeers */ -// RsPeerDetails detail; -// if (!rsPeers->getPeerDetails(rsPeers->getOwnId(), detail)) -// { -// return; -// } - - -} - -/** Loads the settings for this page */ -void TransferPage::updateStatus() -{ - /* load up configuration from rsPeers */ -// RsPeerDetails detail; -// if (!rsPeers->getPeerDetails(rsPeers->getOwnId(), detail)) -// { -// return; -// } -} - - - diff --git a/retroshare-gui/src/gui/settings/TransferPage.h b/retroshare-gui/src/gui/settings/TransferPage.h index f2a47ae51..5169f14a7 100644 --- a/retroshare-gui/src/gui/settings/TransferPage.h +++ b/retroshare-gui/src/gui/settings/TransferPage.h @@ -36,13 +36,13 @@ class TransferPage: public ConfigPage ~TransferPage() {} /** Saves the changes on this page */ - bool save(QString &errmsg); + virtual bool save(QString &errmsg) {} /** Loads the settings for this page */ - void load(); + virtual void load() {} public slots: - void updateStatus(); void updateQueueSize(int) ; + void updateDefaultStrategy(int) ; private: diff --git a/retroshare-gui/src/gui/settings/TransferPage.ui b/retroshare-gui/src/gui/settings/TransferPage.ui index 6325eab7a..6cc79ba0b 100644 --- a/retroshare-gui/src/gui/settings/TransferPage.ui +++ b/retroshare-gui/src/gui/settings/TransferPage.ui @@ -13,31 +13,36 @@ Form - - - - - 0 + + + + + Transfer options - - - Transfer - - - - - - Transfer options - - - + + + + + + Queue Size: - + + + + Default chunk strategy: + + + + + + + + true @@ -53,40 +58,10 @@ - - - - Maximum Download speed per file: - - - - - + + - false - - - kB/s - - - 100000 - - - 1024 - - - - - - - Default chunk strategy: - - - - - - - false + true @@ -100,46 +75,17 @@ - - - - false - - - Show Cache Transfers - - - - - - - - - Qt::Vertical - - - - 248 - 138 - - - - - - - - - F2F Routing - - - - - - true - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> + + + + + + + true + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;"> @@ -148,11 +94,10 @@ p, li { white-space: pre-wrap; } <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">You can separately setup share flags for each shared directory in the shared files dialog to be:</span></p> <ul style="-qt-list-indent: 1;"><li style=" font-size:8pt;" style=" margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Browsable by friends</span>: files are seen by your friends.</li> <li style=" font-size:8pt;" style=" margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-weight:600;">Anonymously shared</span>: files are anonymously reachable through distant F2F tunnels.</li></ul></body></html> - - - - - + + + +