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
This commit is contained in:
csoler 2010-03-17 21:10:10 +00:00
parent 8305fe0bf7
commit 589711d482
8 changed files with 110 additions and 150 deletions

View File

@ -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<RsItem *> 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<std::string, std::string> &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;
}

View File

@ -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
};

View File

@ -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)
{

View File

@ -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.

View File

@ -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<std::string> 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;

View File

@ -26,9 +26,9 @@
#include <iostream>
#include <sstream>
#include "rsiface/rsiface.h"
#include "rsiface/rsfiles.h"
#include "rsiface/rspeers.h"
#include <rsiface/rsiface.h>
#include <rsiface/rsfiles.h>
#include <rsiface/rspeers.h>
#include <QTimer>
@ -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;
// }
}

View File

@ -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:

View File

@ -13,31 +13,36 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Transfer options</string>
</property>
<widget class="QWidget" name="Seite">
<attribute name="title">
<string>Transfer</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Transfer options</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Queue Size:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Default chunk strategy:</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QSpinBox" name="_queueSize_SB">
<property name="enabled">
<bool>true</bool>
@ -53,40 +58,10 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Maximum Download speed per file:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="downspeedspinBox">
<item>
<widget class="QComboBox" name="_defaultStrategy_CB">
<property name="enabled">
<bool>false</bool>
</property>
<property name="suffix">
<string> kB/s</string>
</property>
<property name="maximum">
<number>100000</number>
</property>
<property name="value">
<number>1024</number>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Default chunk strategy:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="strategycomboBox">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<item>
<property name="text">
@ -100,46 +75,17 @@
</item>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="checkBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Show Cache Transfers</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>248</width>
<height>138</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_3">
<attribute name="title">
<string>F2F Routing</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QTextEdit" name="textEdit">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
</item>
</layout>
</item>
<item>
<widget class="QTextEdit" name="textEdit">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Sans'; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
@ -148,11 +94,10 @@ p, li { white-space: pre-wrap; }
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt;You can separately setup share flags for each shared directory in the shared files dialog to be:&lt;/span&gt;&lt;/p&gt;
&lt;ul style=&quot;-qt-list-indent: 1;&quot;&gt;&lt;li style=&quot; font-size:8pt;&quot; style=&quot; margin-top:12px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Browsable by friends&lt;/span&gt;: files are seen by your friends.&lt;/li&gt;
&lt;li style=&quot; font-size:8pt;&quot; style=&quot; margin-top:0px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Anonymously shared&lt;/span&gt;: files are anonymously reachable through distant F2F tunnels.&lt;/li&gt;&lt;/ul&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>