merged branch 0.5.0 commits 2576, 2579, 2581-2583 into trunk

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2592 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2010-03-21 21:07:12 +00:00
parent 294f4207ed
commit b000245ef5
14 changed files with 201 additions and 247 deletions

View file

@ -57,6 +57,7 @@
* #define CONTROL_DEBUG 1 * #define CONTROL_DEBUG 1
* #define DEBUG_DWLQUEUE 1 * #define DEBUG_DWLQUEUE 1
*****/ *****/
#define DEBUG_DWLQUEUE 1
static const uint32_t SAVE_TRANSFERS_DELAY = 61 ; // save transfer progress every 61 seconds. static const uint32_t SAVE_TRANSFERS_DELAY = 61 ; // save transfer progress every 61 seconds.
static const uint32_t INACTIVE_CHUNKS_CHECK_DELAY = 60 ; // time after which an inactive chunk is released static const uint32_t INACTIVE_CHUNKS_CHECK_DELAY = 60 ; // time after which an inactive chunk is released
@ -410,16 +411,23 @@ void ftController::checkDownloadQueue()
// Check for inactive transfers. // Check for inactive transfers.
// //
time_t now = time(NULL) ; time_t now = time(NULL) ;
uint32_t nb_moved = 0 ; // don't move more files than the size of the queue.
for(std::map<std::string,ftFileControl*>::const_iterator it(mDownloads.begin());it!=mDownloads.end();++it) for(std::map<std::string,ftFileControl*>::const_iterator it(mDownloads.begin());it!=mDownloads.end() && nb_moved <= _max_active_downloads;++it)
if( it->second->mState != ftFileControl::QUEUED if( it->second->mState != ftFileControl::QUEUED
&& it->second->mState != ftFileControl::PAUSED && it->second->mState != ftFileControl::PAUSED
&& now - it->second->mCreator->lastRecvTimeStamp() > (time_t)MAX_TIME_INACTIVE_REQUEUED) && now > it->second->mCreator->lastRecvTimeStamp() + (time_t)MAX_TIME_INACTIVE_REQUEUED)
{ {
#ifdef DEBUG_DWLQUEUE
std::cerr << " - Inactive file " << it->second->mName << " at position " << it->second->mQueuePosition << " moved to end of the queue. mState=" << it->second->mState << ", time lapse=" << now - it->second->mCreator->lastRecvTimeStamp() << std::endl ;
#endif
locked_bottomQueue(it->second->mQueuePosition) ; locked_bottomQueue(it->second->mQueuePosition) ;
#ifdef DEBUG_DWLQUEUE #ifdef DEBUG_DWLQUEUE
std::cerr << " - Inactive file " << it->second->mName << " moved to end of the queue" << std::endl ; std::cerr << " new position: " << it->second->mQueuePosition << std::endl ;
std::cerr << " new state: " << it->second->mState << std::endl ;
#endif #endif
it->second->mCreator->resetRecvTimeStamp() ; // very important!
++nb_moved ;
} }
} }
@ -454,7 +462,8 @@ void ftController::setQueueSize(uint32_t s)
std::cerr << "Settign new queue size to " << s << std::endl ; std::cerr << "Settign new queue size to " << s << std::endl ;
#endif #endif
for(uint32_t p=std::min(s,old_s);p<=std::max(s,old_s);++p) for(uint32_t p=std::min(s,old_s);p<=std::max(s,old_s);++p)
locked_checkQueueElement(p); if(p < _queue.size())
locked_checkQueueElement(p);
} }
else else
std::cerr << "ftController::setQueueSize(): cannot set queue to size " << s << std::endl ; std::cerr << "ftController::setQueueSize(): cannot set queue to size " << s << std::endl ;
@ -540,11 +549,6 @@ void ftController::locked_swapQueue(uint32_t pos1,uint32_t pos2)
locked_checkQueueElement(pos2) ; locked_checkQueueElement(pos2) ;
} }
//void ftController::checkQueueElements()
//{
// for(uint32_t pos=0;pos<_queue.size();++pos)
// checkQueueElement(pos) ;
//}
void ftController::locked_checkQueueElement(uint32_t pos) void ftController::locked_checkQueueElement(uint32_t pos)
{ {
_queue[pos]->mQueuePosition = pos ; _queue[pos]->mQueuePosition = pos ;
@ -1147,6 +1151,8 @@ bool ftController::FileRequest(std::string fname, std::string hash,
ftFileCreator *fc = new ftFileCreator(savepath, size, hash); ftFileCreator *fc = new ftFileCreator(savepath, size, hash);
ftTransferModule *tm = new ftTransferModule(fc, mDataplex,this); ftTransferModule *tm = new ftTransferModule(fc, mDataplex,this);
fc->setChunkStrategy(mDefaultChunkStrategy) ;
/* add into maps */ /* add into maps */
ftFileControl *ftfc = new ftFileControl(fname, savepath, destination, size, hash, flags, fc, tm, callbackCode); ftFileControl *ftfc = new ftFileControl(fname, savepath, destination, size, hash, flags, fc, tm, callbackCode);
ftfc->mCreateTime = time(NULL); ftfc->mCreateTime = time(NULL);
@ -1726,6 +1732,7 @@ bool ftController::CancelCacheFile(RsPeerId id, std::string path, std::string ha
const std::string download_dir_ss("DOWN_DIR"); const std::string download_dir_ss("DOWN_DIR");
const std::string partial_dir_ss("PART_DIR"); const std::string partial_dir_ss("PART_DIR");
const std::string share_dwl_dir("SHARE_DWL_DIR"); const std::string share_dwl_dir("SHARE_DWL_DIR");
const std::string default_chunk_strategy_ss("DEFAULT_CHUNK_STRATEGY");
/* p3Config Interface */ /* p3Config Interface */
@ -1757,6 +1764,7 @@ std::list<RsItem *> ftController::saveList(bool &cleanup)
configMap[download_dir_ss] = getDownloadDirectory(); configMap[download_dir_ss] = getDownloadDirectory();
configMap[partial_dir_ss] = getPartialsDirectory(); configMap[partial_dir_ss] = getPartialsDirectory();
configMap[share_dwl_dir] = mShareDownloadDir ? "YES" : "NO"; configMap[share_dwl_dir] = mShareDownloadDir ? "YES" : "NO";
configMap[default_chunk_strategy_ss] = (mDefaultChunkStrategy==FileChunksInfo::CHUNK_STRATEGY_STREAMING) ? "STREAMING" : "RANDOM";
RsConfigKeyValueSet *rskv = new RsConfigKeyValueSet(); RsConfigKeyValueSet *rskv = new RsConfigKeyValueSet();
@ -1940,15 +1948,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; 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) void ftController::setShareDownloadDirectory(bool value)
{ {
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
mShareDownloadDir = value; mShareDownloadDir = value;
IndicateConfigChanged() ;
} }
bool ftController::getShareDownloadDirectory() bool ftController::getShareDownloadDirectory()
{ {
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
return mShareDownloadDir; return mShareDownloadDir;
} }

View file

@ -144,6 +144,8 @@ class ftController: public CacheTransfer, public RsThread, public pqiMonitor, pu
bool alreadyHaveFile(const std::string& hash) ; bool alreadyHaveFile(const std::string& hash) ;
bool setChunkStrategy(const std::string& hash,FileChunksInfo::ChunkStrategy s); bool setChunkStrategy(const std::string& hash,FileChunksInfo::ChunkStrategy s);
void setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy s);
FileChunksInfo::ChunkStrategy defaultChunkStrategy();
bool FileCancel(std::string hash); bool FileCancel(std::string hash);
bool FileControl(std::string hash, uint32_t flags); bool FileControl(std::string hash, uint32_t flags);
@ -265,6 +267,7 @@ class ftController: public CacheTransfer, public RsThread, public pqiMonitor, pu
/* share incoming directory */ /* share incoming directory */
bool mShareDownloadDir; bool mShareDownloadDir;
FileChunksInfo::ChunkStrategy mDefaultChunkStrategy ;
uint32_t _max_active_downloads ; // maximum number of simultaneous downloads uint32_t _max_active_downloads ; // maximum number of simultaneous downloads
}; };

View file

@ -58,6 +58,11 @@ time_t ftFileCreator::lastRecvTimeStamp()
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/ RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
return _last_recv_time_t ; return _last_recv_time_t ;
} }
void ftFileCreator::resetRecvTimeStamp()
{
RsStackMutex stack(ftcMutex); /********** STACK LOCKED MTX ******/
_last_recv_time_t = time(NULL) ;
}
void ftFileCreator::closeFile() void ftFileCreator::closeFile()
{ {

View file

@ -76,8 +76,9 @@ class ftFileCreator: public ftFileProvider
// removes the designated file source from the chunkmap. // removes the designated file source from the chunkmap.
void removeFileSource(const std::string& peer_id) ; void removeFileSource(const std::string& peer_id) ;
// Returns the time stamp of the last data receive. // Returns resets the time stamp of the last data receive.
time_t lastRecvTimeStamp() ; time_t lastRecvTimeStamp() ;
void resetRecvTimeStamp() ;
// actually store data in the file, and update chunks info // actually store data in the file, and update chunks info
// //

View file

@ -272,6 +272,14 @@ bool ftServer::setChunkStrategy(const std::string& hash,FileChunksInfo::ChunkStr
{ {
return mFtController->setChunkStrategy(hash,s); 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) 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 FileControl(std::string hash, uint32_t flags);
virtual bool FileClearCompleted(); virtual bool FileClearCompleted();
virtual bool setChunkStrategy(const std::string& hash,FileChunksInfo::ChunkStrategy s) ; virtual bool setChunkStrategy(const std::string& hash,FileChunksInfo::ChunkStrategy s) ;
virtual void setDefaultChunkStrategy(FileChunksInfo::ChunkStrategy) ;
virtual FileChunksInfo::ChunkStrategy defaultChunkStrategy() ;
/*** /***
* Control of Downloads Priority. * 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 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 FileCancel(std::string hash) = 0;
virtual bool setChunkStrategy(const std::string& hash,FileChunksInfo::ChunkStrategy) = 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 FileControl(std::string hash, uint32_t flags) = 0;
virtual bool FileClearCompleted() = 0; virtual bool FileClearCompleted() = 0;

View file

@ -49,11 +49,16 @@ class RetroShareLink
/// returns the string retroshare://file|name|size|hash /// returns the string retroshare://file|name|size|hash
QString toString() const ; QString toString() const ;
/// returns the string <a href="retroshare://file|name|size|hash">retroshare://file|name|size|hash</a> /// returns the string <a href="retroshare://file|name|size|hash">name</a>
QString toHtml() const ; QString toHtml() const ;
/// returns the string <a href="retroshare://file|name|size|hash">retroshare://file|name|size|hash</a>
QString toHtmlFull() const ;
QUrl toUrl() const ; QUrl toUrl() const ;
bool valid() const { return _size > 0 ; } bool valid() const { return _size > 0 ; }
bool operator==(const RetroShareLink& l) const { return _hash == l._hash ; }
private: private:
void check() ; void check() ;
static bool checkHash(const QString& hash) ; static bool checkHash(const QString& hash) ;
@ -68,32 +73,42 @@ class RetroShareLink
/// This class handles the copy/paste of links. Every member is static to ensure unicity. /// This class handles the copy/paste of links. Every member is static to ensure unicity.
/// I put no mutex, because all calls supposely com from the GUI thread. /// I put no mutex, because all calls supposely com from the GUI thread.
///
/// All links are stored in html format into the clipboard. Why? Because this allows to import
/// links from both the clipboard and the RS application, e.g. paste links from an internet forum.
/// This requires many clipboard parsing operations, but this is not a problem because this code is
/// not performances-critical.
// //
class RSLinkClipboard class RSLinkClipboard
{ {
public: public:
static void copyLinks(const std::vector<RetroShareLink>& links) // Copy these links to the RS clipboard. Also copy them to the system clipboard
{ //
_links = links ; static void copyLinks(const std::vector<RetroShareLink>& links) ;
}
static const std::vector<RetroShareLink>& pasteLinks() // Get the liste of pasted links, either from the internal RS links, or by default
{ // from the clipboard.
return _links ; //
} static std::vector<RetroShareLink> pasteLinks() ;
static QString toHtml()
{ // Produces a list of links with no html structure.
QString res ; static QString toString() ;
for(uint32_t i=0;i<_links.size();++i)
res += _links[i].toHtml() + "<br/>" ; // produces a list of html links that displays with the file names only
//
static QString toHtml();
// produces a list of html links that displays the full links
//
static QString toHtmlFull();
// Returns true is no links are found to paste.
// Useful for menus.
//
static bool empty();
return res ;
}
static bool empty()
{
return _links.empty();
}
private: private:
static std::vector<RetroShareLink> _links ; static std::vector<RetroShareLink> parseClipboard() ;
}; };

View file

@ -104,7 +104,7 @@ void ShareManager::load()
for(it = dirs.begin(); it != dirs.end(); it++,++row) for(it = dirs.begin(); it != dirs.end(); it++,++row)
{ {
listWidget->insertRow(row) ; listWidget->insertRow(row) ;
listWidget->setItem(row,0,new QTableWidgetItem(QString::fromStdString((*it).filename))); listWidget->setItem(row,0,new QTableWidgetItem(QString::fromUtf8((*it).filename.c_str())));
#ifdef USE_COMBOBOX #ifdef USE_COMBOBOX
QComboBox *cb = new QComboBox ; QComboBox *cb = new QComboBox ;
cb->addItem(QString("Network Wide")) ; cb->addItem(QString("Network Wide")) ;
@ -173,8 +173,7 @@ void ShareManager::addShareDirectory()
*/ */
QString qdir = QFileDialog::getExistingDirectory(this, tr("Select A Folder To Share"), "", QString qdir = QFileDialog::getExistingDirectory(this, tr("Select A Folder To Share"), "", QFileDialog::DontUseNativeDialog | QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
/* add it to the server */ /* add it to the server */
std::string dir = qdir.toStdString(); std::string dir = qdir.toStdString();

View file

@ -201,6 +201,7 @@ TransfersDialog::TransfersDialog(QWidget *parent)
#endif #endif
QObject::connect(ui._showCacheTransfers_CB,SIGNAL(toggled(bool)),this,SLOT(insertTransfers())) ;
} }
@ -663,50 +664,23 @@ void TransfersDialog::insertTransfers()
// std::list<DwlDetails> dwlDetails; // std::list<DwlDetails> dwlDetails;
// rsFiles->getDwlDetails(dwlDetails); // rsFiles->getDwlDetails(dwlDetails);
//first clean the model in case some files are not download anymore
//remove items that are not fiends anymore
int removeIndex = 0; std::set<std::string> used_hashes ;
while (removeIndex < DLListModel->rowCount()) {
std::string hash = DLListModel->item(removeIndex, ID)->data(Qt::EditRole).toString().toStdString();
std::list<std::string>::iterator downHashesIt;
bool found = false;
for (downHashesIt = downHashes.begin(); downHashesIt != downHashes.end(); downHashesIt++) {
if (hash == *downHashesIt) {
found = true;
break;
}
}
// if (!found) {
// //look in the queued files
// std::list<DwlDetails>::iterator dwlDetailsIt;
// for (dwlDetailsIt = dwlDetails.begin(); dwlDetailsIt != dwlDetails.end(); dwlDetailsIt++) {
// if (hash == dwlDetailsIt->hash) {
// found = true;
// break;
// }
// }
// }
if (!found) {
DLListModel->takeRow(removeIndex);
} else {
removeIndex++;
}
}
// clear all source peers. // clear all source peers.
std::list<std::string>::iterator it; std::list<std::string>::iterator it;
for (it = downHashes.begin(); it != downHashes.end(); it++) { for (it = downHashes.begin(); it != downHashes.end(); it++)
{
FileInfo info; FileInfo info;
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info)) { if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, info)) {
//if file transfer is a cache file index file, don't show it //if file transfer is a cache file index file, don't show it
continue; continue;
} }
if ((info.flags & CB_CODE_CACHE)) { if((info.flags & CB_CODE_CACHE) && !ui._showCacheTransfers_CB->isChecked())
/*(!_show_cache_transfers) &&*/
continue; continue;
}
QString fileName = QString::fromUtf8(info.fname.c_str()); QString fileName = QString::fromUtf8(info.fname.c_str());
QString fileHash = QString::fromStdString(info.hash); QString fileHash = QString::fromStdString(info.hash);
@ -763,6 +737,7 @@ void TransfersDialog::insertTransfers()
pinfo.nb_chunks = pinfo.cmap._map.empty()?0:fcinfo.chunks.size() ; pinfo.nb_chunks = pinfo.cmap._map.empty()?0:fcinfo.chunks.size() ;
int addedRow = addItem("", fileName, fileHash, fileSize, pinfo, fileDlspeed, sources, status, priority, completed, remaining, downloadtime); int addedRow = addItem("", fileName, fileHash, fileSize, pinfo, fileDlspeed, sources, status, priority, completed, remaining, downloadtime);
used_hashes.insert(info.hash) ;
/* continue to next download item if no peers to add */ /* continue to next download item if no peers to add */
if (!info.peers.size()) continue; if (!info.peers.size()) continue;
@ -810,7 +785,7 @@ void TransfersDialog::insertTransfers()
// std::cerr << std::endl ; // std::cerr << std::endl ;
// std::cerr << std::endl ; // std::cerr << std::endl ;
std::cout << "adding peer " << peerName.toStdString() << " to row " << addedRow << ", hashfile and peerid=" << hashFileAndPeerId.toStdString() << std::endl ; // std::cout << "adding peer " << peerName.toStdString() << " to row " << addedRow << ", hashfile and peerid=" << hashFileAndPeerId.toStdString() << std::endl ;
int row_id = addPeerToItem(addedRow, peerName, hashFileAndPeerId, peerDlspeed, status, peerpinfo); int row_id = addPeerToItem(addedRow, peerName, hashFileAndPeerId, peerDlspeed, status, peerpinfo);
used_rows.insert(row_id) ; used_rows.insert(row_id) ;
@ -825,31 +800,22 @@ void TransfersDialog::insertTransfers()
if(used_rows.find(r) == used_rows.end()) if(used_rows.find(r) == used_rows.end())
dlItem->takeRow(r) ; dlItem->takeRow(r) ;
} }
// remove hashes that where not shown
//first clean the model in case some files are not download anymore
//remove items that are not fiends anymore
int removeIndex = 0;
while (removeIndex < DLListModel->rowCount())
{
std::string hash = DLListModel->item(removeIndex, ID)->data(Qt::EditRole).toString().toStdString();
/* here i will insert files from the download queue - which are if(used_hashes.find(hash) == used_hashes.end())
* not started yet and can't be find in FileDownloads DLListModel->takeRow(removeIndex);
* */ else
// std::list<DwlDetails>::iterator dit; removeIndex++;
// for (dit = dwlDetails.begin(); dit != dwlDetails.end(); dit ++) }
// {
//// switch (dit->priority) {
//// case 0: priority = tr("Low"); break;
//// case 1: priority = tr("Normal"); break;
//// case 2: priority = tr("High"); break;
//// case 3: priority = tr("Auto"); break;
//// default: priority = tr("Auto"); break;
//// }
//
// FileProgressInfo pinfo ;
// pinfo.progress = 0.0 ;
// pinfo.nb_chunks = 0 ;
//
// addItem("", QString::fromUtf8(dit->fname.c_str()),
// QString::fromStdString(dit->hash), dit->count, pinfo, 0, 0,
// tr("Queued"), "", 0, 0, 0);
// }
//
// Now show upload hashes
//
std::list<std::string> upHashes; std::list<std::string> upHashes;
rsFiles->FileUploads(upHashes); rsFiles->FileUploads(upHashes);
//first clean the model in case some files are not uploaded anymore //first clean the model in case some files are not uploaded anymore
@ -881,7 +847,7 @@ void TransfersDialog::insertTransfers()
if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_UPLOAD, info)) { if (!rsFiles->FileDetails(*it, RS_FILE_HINTS_UPLOAD, info)) {
continue; continue;
} }
if (/*(!_show_cache_transfers) &&*/ (info.flags & CB_CODE_CACHE)) if((info.flags & CB_CODE_CACHE) && !ui._showCacheTransfers_CB->isChecked())
continue ; continue ;
std::list<TransferInfo>::iterator pit; std::list<TransferInfo>::iterator pit;

View file

@ -602,6 +602,13 @@ p, li { white-space: pre-wrap; }
</property> </property>
</spacer> </spacer>
</item> </item>
<item>
<widget class="QCheckBox" name="_showCacheTransfers_CB">
<property name="text">
<string>Show cache transfers</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -658,9 +665,6 @@ p, li { white-space: pre-wrap; }
<attribute name="headerStretchLastSection"> <attribute name="headerStretchLastSection">
<bool>false</bool> <bool>false</bool>
</attribute> </attribute>
<attribute name="headerStretchLastSection">
<bool>false</bool>
</attribute>
</widget> </widget>
</item> </item>
</layout> </layout>
@ -843,8 +847,8 @@ p, li { white-space: pre-wrap; }
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>98</width> <width>578</width>
<height>28</height> <height>113</height>
</rect> </rect>
</property> </property>
</widget> </widget>

View file

@ -26,9 +26,9 @@
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include "rsiface/rsiface.h" #include <rsiface/rsiface.h>
#include "rsiface/rsfiles.h" #include <rsiface/rsfiles.h>
#include "rsiface/rspeers.h" #include <rsiface/rspeers.h>
#include <QTimer> #include <QTimer>
@ -38,15 +38,15 @@ TransferPage::TransferPage(QWidget * parent, Qt::WFlags flags)
/* Invoke the Qt Designer generated object setup routine */ /* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this); 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()) ; 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._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 */ /* Hide platform specific features */
#ifdef Q_WS_WIN #ifdef Q_WS_WIN
@ -54,6 +54,20 @@ TransferPage::TransferPage(QWidget * parent, Qt::WFlags flags)
#endif #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) void TransferPage::updateQueueSize(int s)
{ {
rsFiles->setQueueSize(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() {} ~TransferPage() {}
/** Saves the changes on this page */ /** Saves the changes on this page */
bool save(QString &errmsg); virtual bool save(QString &errmsg) {}
/** Loads the settings for this page */ /** Loads the settings for this page */
void load(); virtual void load() {}
public slots: public slots:
void updateStatus();
void updateQueueSize(int) ; void updateQueueSize(int) ;
void updateDefaultStrategy(int) ;
private: private:

View file

@ -13,31 +13,36 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item row="0" column="0"> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QGroupBox" name="groupBox">
<property name="currentIndex"> <property name="title">
<number>0</number> <string>Transfer options</string>
</property> </property>
<widget class="QWidget" name="Seite"> <layout class="QVBoxLayout" name="verticalLayout_3">
<attribute name="title"> <item>
<string>Transfer</string> <layout class="QHBoxLayout" name="horizontalLayout">
</attribute> <item>
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_4">
<item row="0" column="0"> <item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Transfer options</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">
<string>Queue Size:</string> <string>Queue Size:</string>
</property> </property>
</widget> </widget>
</item> </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"> <widget class="QSpinBox" name="_queueSize_SB">
<property name="enabled"> <property name="enabled">
<bool>true</bool> <bool>true</bool>
@ -53,40 +58,10 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="0"> <item>
<widget class="QLabel" name="label_2"> <widget class="QComboBox" name="_defaultStrategy_CB">
<property name="text">
<string>Maximum Download speed per file:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="downspeedspinBox">
<property name="enabled"> <property name="enabled">
<bool>false</bool> <bool>true</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>
</property> </property>
<item> <item>
<property name="text"> <property name="text">
@ -100,46 +75,17 @@
</item> </item>
</widget> </widget>
</item> </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> </layout>
</widget> </item>
</item> </layout>
<item row="2" column="0"> </item>
<spacer name="verticalSpacer"> <item>
<property name="orientation"> <widget class="QTextEdit" name="textEdit">
<enum>Qt::Vertical</enum> <property name="readOnly">
</property> <bool>true</bool>
<property name="sizeHint" stdset="0"> </property>
<size> <property name="html">
<width>248</width> <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;
<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;
&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; &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; } 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; &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;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;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> &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> </property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget>
</widget> </widget>
</item> </item>
</layout> </layout>