diff --git a/libretroshare/src/ft/ftcontroller.cc b/libretroshare/src/ft/ftcontroller.cc index 3a7628970..308dc5061 100644 --- a/libretroshare/src/ft/ftcontroller.cc +++ b/libretroshare/src/ft/ftcontroller.cc @@ -63,7 +63,7 @@ static const uint32_t INACTIVE_CHUNKS_CHECK_DELAY = 60 ; // save transfer progre ftFileControl::ftFileControl() :mTransfer(NULL), mCreator(NULL), mState(0), mSize(0), mFlags(0), - mPriority(PRIORITY_NORMAL) + mPriority(SPEED_NORMAL) { return; } @@ -75,7 +75,7 @@ ftFileControl::ftFileControl(std::string fname, :mName(fname), mCurrentPath(tmppath), mDestination(dest), mTransfer(tm), mCreator(fc), mState(0), mHash(hash), mSize(size), mFlags(flags), mDoCallback(false), mCallbackCode(cb), - mPriority(PRIORITY_NORMAL) // default priority to normal + mPriority(SPEED_NORMAL) // default priority to normal { if (cb) mDoCallback = true; @@ -253,39 +253,17 @@ void ftController::tickTransfers() // 2.1 - decide based on probability, which category of files we handle. - static const float HIGH_PRIORITY_PROB = 0.60 ; - static const float NORMAL_PRIORITY_PROB = 0.25 ; - static const float LOW_PRIORITY_PROB = 0.15 ; - static const float SUSP_PRIORITY_PROB = 0.00 ; +// static const float HIGH_PRIORITY_PROB = 0.60 ; +// static const float NORMAL_PRIORITY_PROB = 0.25 ; +// static const float LOW_PRIORITY_PROB = 0.15 ; +// static const float SUSP_PRIORITY_PROB = 0.00 ; std::cerr << "Priority tabs: " ; - std::cerr << "Low (" << mPriorityTab[PRIORITY_LOW ].size() << ") " ; - std::cerr << "Normal (" << mPriorityTab[PRIORITY_NORMAL].size() << ") " ; - std::cerr << "High (" << mPriorityTab[PRIORITY_HIGH ].size() << ") " ; + std::cerr << "Low (" << mPriorityTab[SPEED_LOW ].size() << ") " ; + std::cerr << "Normal (" << mPriorityTab[SPEED_NORMAL].size() << ") " ; + std::cerr << "High (" << mPriorityTab[SPEED_HIGH ].size() << ") " ; std::cerr << std::endl ; -// float probs[3] = { (!mPriorityTab[PRIORITY_LOW ].empty())* LOW_PRIORITY_PROB, -// (!mPriorityTab[PRIORITY_NORMAL].empty())*NORMAL_PRIORITY_PROB, -// (!mPriorityTab[PRIORITY_HIGH ].empty())* HIGH_PRIORITY_PROB } ; -// -// float total = probs[0]+probs[1]+probs[2] ; -// float cumul_probs[3] = { probs[0], probs[0]+probs[1], probs[0]+probs[1]+probs[2] } ; -// -// float r = rand()/(float)RAND_MAX * total; -// int chosen ; -// -// if(total == 0.0) -// return ; -// -// if(r < cumul_probs[0]) -// chosen = 0 ; -// else if(r < cumul_probs[1]) -// chosen = 1 ; -// else -// chosen = 2 ; -// -// std::cerr << "chosen: " << chosen << std::endl ; - /* tick the transferModules */ // start anywhere in the chosen list of transfers, so that not to favor any special transfer @@ -299,31 +277,9 @@ void ftController::tickTransfers() for(int i=0;i<(int)mPriorityTab[chosen].size();++i) mPriorityTab[chosen][(i+start)%(int)mPriorityTab[chosen].size()]->tick() ; } - -// { -// -//#ifdef CONTROL_DEBUG -// std::cerr << "\tTicking: " << it->first; -// std::cerr << std::endl; -//#endif -// -// if (it->second.mTransfer) -// { -//#ifdef CONTROL_DEBUG -// std::cerr << "\tTicking mTransfer: " << (void*)it->second.mTransfer; -// std::cerr << std::endl; -//#endif -// (it->second.mTransfer)->tick(); -// } -//#ifdef CONTROL_DEBUG -// else -// std::cerr << "No mTransfer for this hash." << std::endl ; -//#endif -// } -// } } -bool ftController::getPriority(const std::string& hash,DwlPriority& p) +bool ftController::getPriority(const std::string& hash,DwlSpeed& p) { RsStackMutex stack(ctrlMutex); /******* LOCKED ********/ @@ -337,7 +293,7 @@ bool ftController::getPriority(const std::string& hash,DwlPriority& p) else return false ; } -void ftController::setPriority(const std::string& hash,DwlPriority p) +void ftController::setPriority(const std::string& hash,DwlSpeed p) { RsStackMutex stack(ctrlMutex); /******* LOCKED ********/ diff --git a/libretroshare/src/ft/ftcontroller.h b/libretroshare/src/ft/ftcontroller.h index f8a726e08..e33492e1c 100644 --- a/libretroshare/src/ft/ftcontroller.h +++ b/libretroshare/src/ft/ftcontroller.h @@ -85,7 +85,7 @@ class ftFileControl bool mDoCallback; uint32_t mCallbackCode; time_t mCreateTime; - DwlPriority mPriority ; + DwlSpeed mPriority ; }; class ftPendingRequest @@ -144,8 +144,8 @@ bool FileClearCompleted(); bool FlagFileComplete(std::string hash); bool getFileDownloadChunksDetails(const std::string& hash,FileChunksInfo& info); -bool getPriority(const std::string& hash,DwlPriority& p); -void setPriority(const std::string& hash,DwlPriority p); +bool getPriority(const std::string& hash,DwlSpeed& p); +void setPriority(const std::string& hash,DwlSpeed p); /* get Details of File Transfers */ bool FileDownloads(std::list &hashs); diff --git a/libretroshare/src/ft/ftserver.cc b/libretroshare/src/ft/ftserver.cc index 17a779043..e8875b80f 100644 --- a/libretroshare/src/ft/ftserver.cc +++ b/libretroshare/src/ft/ftserver.cc @@ -263,7 +263,12 @@ bool ftServer::setChunkStrategy(const std::string& hash,FileChunksInfo::ChunkStr bool ftServer::FileCancel(std::string hash) { - return mFtController->FileCancel(hash); + // Remove from both queue and ftController, by default. + // + mFtDwlQueue->clearDownload(hash); + mFtController->FileCancel(hash); + + return true ; } bool ftServer::FileControl(std::string hash, uint32_t flags) @@ -277,26 +282,35 @@ bool ftServer::FileClearCompleted() } /* Control of Downloads Priority. */ -bool ftServer::changePriority(const std::string hash, int priority) +bool ftServer::changeQueuePriority(const std::string hash, int priority) { - mFtController->setPriority(hash, (DwlPriority) priority); + return mFtDwlQueue->changePriority(hash,(DwlPriority)priority) ; +} +bool ftServer::changeDownloadSpeed(const std::string hash, int speed) +{ + mFtController->setPriority(hash, (DwlSpeed)speed); return true ; } - -bool ftServer::getPriority(const std::string hash, int & priority) +bool ftServer::getDownloadSpeed(const std::string hash, int & speed) { - DwlPriority _priority; - int ret = mFtController->getPriority(hash, _priority); - if (ret) { - priority = _priority; - } + DwlSpeed _speed; + int ret = mFtController->getPriority(hash, _speed); + if (ret) + speed = _speed; return ret; } +bool ftServer::getQueuePriority(const std::string hash, int & priority) +{ + DwlPriority _priority; + int ret = mFtDwlQueue->getPriority(hash, _priority); + if (ret) + priority = _priority; + return ret; +} bool ftServer::clearDownload(const std::string hash) { - return mFtDwlQueue->clearDownload(hash); } void ftServer::clearQueue() diff --git a/libretroshare/src/ft/ftserver.h b/libretroshare/src/ft/ftserver.h index fb25b128c..66c1dd7a0 100644 --- a/libretroshare/src/ft/ftserver.h +++ b/libretroshare/src/ft/ftserver.h @@ -125,8 +125,10 @@ virtual bool setChunkStrategy(const std::string& hash,FileChunksInfo::ChunkStrat /*** * Control of Downloads Priority. ***/ -virtual bool changePriority(const std::string hash, int priority); -virtual bool getPriority(const std::string hash, int & priority); +virtual bool changeQueuePriority(const std::string hash, int priority); +virtual bool changeDownloadSpeed(const std::string hash, int speed); +virtual bool getQueuePriority(const std::string hash, int & priority); +virtual bool getDownloadSpeed(const std::string hash, int & speed); virtual bool clearDownload(const std::string hash); virtual void clearQueue(); virtual void getDwlDetails(std::list & details); diff --git a/libretroshare/src/rsiface/rsfiles.h b/libretroshare/src/rsiface/rsfiles.h index 1e01fd918..e150c5e19 100644 --- a/libretroshare/src/rsiface/rsfiles.h +++ b/libretroshare/src/rsiface/rsfiles.h @@ -119,8 +119,10 @@ class RsFiles /*** * Control of Downloads Priority. ***/ - virtual bool changePriority(const std::string hash, int priority) = 0; - virtual bool getPriority(const std::string hash, int & priority) = 0; + virtual bool changeQueuePriority(const std::string hash, int priority) = 0; + virtual bool changeDownloadSpeed(const std::string hash, int speed) = 0; + virtual bool getQueuePriority(const std::string hash, int & priority) = 0; + virtual bool getDownloadSpeed(const std::string hash, int & speed) = 0; virtual bool clearDownload(const std::string hash) = 0; virtual void clearQueue() = 0; virtual void getDwlDetails(std::list & details) = 0; diff --git a/libretroshare/src/rsiface/rstypes.h b/libretroshare/src/rsiface/rstypes.h index 75c2a1764..ef0264d22 100644 --- a/libretroshare/src/rsiface/rstypes.h +++ b/libretroshare/src/rsiface/rstypes.h @@ -63,6 +63,12 @@ enum DwlPriority { PRIORITY_LOW = 0x00, PRIORITY_AUTO = 0x03 }; +enum DwlSpeed { SPEED_LOW = 0x00, + SPEED_NORMAL = 0x01, + SPEED_HIGH = 0x02 +}; + + class FileInfo { @@ -107,7 +113,7 @@ class FileInfo uint32_t downloadStatus; /* 0 = Err, 1 = Ok, 2 = Done */ std::list peers; - DwlPriority priority ; + DwlSpeed priority ; time_t lastTS; }; diff --git a/libretroshare/src/rsserver/rsinit.cc b/libretroshare/src/rsserver/rsinit.cc index 0dce27d04..710386a6f 100644 --- a/libretroshare/src/rsserver/rsinit.cc +++ b/libretroshare/src/rsserver/rsinit.cc @@ -950,11 +950,8 @@ bool RsInit::GenerateSSLCertificate(std::string gpg_id, std::string org, std /* try to load it, and get Id */ std::string location; - if (LoadCheckX509andGetLocation(cert_name.c_str(), location, sslId) == 0) { - std::cerr << "RsInit::GenerateSSLCertificate() Cannot check own signature, maybe the files are corrupted." << std::endl; - return false; - } - + bool ret = LoadCheckX509andGetLocation(cert_name.c_str(), location, sslId) ; + std::cout << "LoadCheckX509andGetLocation: returned " << ret << ", sslId=" << sslId << std::endl ; if(!ret) diff --git a/retroshare-gui/src/gui/DLListDelegate.cpp b/retroshare-gui/src/gui/DLListDelegate.cpp index 06ae41c0e..d8ca34354 100644 --- a/retroshare-gui/src/gui/DLListDelegate.cpp +++ b/retroshare-gui/src/gui/DLListDelegate.cpp @@ -151,8 +151,19 @@ void DLListDelegate::paint(QPainter * painter, const QStyleOptionViewItem & opti // create a xProgressBar FileProgressInfo pinfo = index.data().value() ; xProgressBar progressBar(pinfo.cmap,option.rect, painter); // the 3rd param is the color schema (0 is the default value) - progressBar.setDisplayText(false); // should display % text? - progressBar.setValue(pinfo.progress); // set the progress value + + if(pinfo.type == FileProgressInfo::DOWNLOAD_LINE) + { + progressBar.setDisplayText(true); // should display % text? + progressBar.setValue(pinfo.progress); // set the progress value + progressBar.setColorSchema(0) ; + } + else + { + progressBar.setDisplayText(false); // should display % text? + progressBar.setValue(pinfo.progress); // set the progress value + progressBar.setColorSchema(1) ; + } progressBar.setVerticalSpan(1); progressBar.paint(); // paint the progress bar } diff --git a/retroshare-gui/src/gui/TransfersDialog.cpp b/retroshare-gui/src/gui/TransfersDialog.cpp index e53547b98..4e27a530c 100644 --- a/retroshare-gui/src/gui/TransfersDialog.cpp +++ b/retroshare-gui/src/gui/TransfersDialog.cpp @@ -115,10 +115,10 @@ TransfersDialog::TransfersDialog(QWidget *parent) DLListModel->setHeaderData(SIZE, Qt::Horizontal, tr("Size", "i.e: file size")); DLListModel->setHeaderData(COMPLETED, Qt::Horizontal, tr("Completed", "")); DLListModel->setHeaderData(DLSPEED, Qt::Horizontal, tr("Speed", "i.e: Download speed")); - DLListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress", "i.e: % downloaded")); + DLListModel->setHeaderData(PROGRESS, Qt::Horizontal, tr("Progress / Availability", "i.e: % downloaded")); DLListModel->setHeaderData(SOURCES, Qt::Horizontal, tr("Sources", "i.e: Sources")); DLListModel->setHeaderData(STATUS, Qt::Horizontal, tr("Status")); - DLListModel->setHeaderData(PRIORITY, Qt::Horizontal, tr("Priority")); + DLListModel->setHeaderData(PRIORITY, Qt::Horizontal, tr("Speed / Queue priority")); DLListModel->setHeaderData(REMAINING, Qt::Horizontal, tr("Remaining", "i.e: Estimated Time of Arrival / Time left")); DLListModel->setHeaderData(ID, Qt::Horizontal, tr("Core-ID")); ui.downloadList->setModel(DLListModel); @@ -321,48 +321,61 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point ) viewMenu->addAction(rootisnotdecoratedAct); viewMenu->addAction(rootisdecoratedAct); - clearQueuedDwlAct = new QAction(QIcon(), tr("Clear from Queue"), this); - connect(clearQueuedDwlAct, SIGNAL(triggered()), this, SLOT(clearQueuedDwl())); - clearQueueAct = new QAction(QIcon(), tr("Clear Queue"), this); + clearQueueAct = new QAction(QIcon(), tr("Remove all queued"), this); connect(clearQueueAct, SIGNAL(triggered()), this, SLOT(clearQueue())); priorityLowAct = new QAction(QIcon(IMAGE_PRIORITYLOW), tr("Low"), this); - connect(priorityLowAct, SIGNAL(triggered()), this, SLOT(priorityLow())); + connect(priorityLowAct, SIGNAL(triggered()), this, SLOT(priorityQueueLow())); priorityNormalAct = new QAction(QIcon(IMAGE_PRIORITYNORMAL), tr("Normal"), this); - connect(priorityNormalAct, SIGNAL(triggered()), this, SLOT(priorityNormal())); + connect(priorityNormalAct, SIGNAL(triggered()), this, SLOT(priorityQueueNormal())); priorityHighAct = new QAction(QIcon(IMAGE_PRIORITYHIGH), tr("High"), this); - connect(priorityHighAct, SIGNAL(triggered()), this, SLOT(priorityHigh())); + connect(priorityHighAct, SIGNAL(triggered()), this, SLOT(priorityQueueHigh())); priorityAutoAct = new QAction(QIcon(IMAGE_PRIORITYAUTO), tr("Auto"), this); - connect(priorityAutoAct, SIGNAL(triggered()), this, SLOT(priorityAuto())); + connect(priorityAutoAct, SIGNAL(triggered()), this, SLOT(priorityQueueAuto())); - QMenu *priorityMenu = new QMenu(tr("Priority (Download)"), this); - priorityMenu->setIcon(QIcon(IMAGE_PRIORITY)); - priorityMenu->addAction(priorityLowAct); - priorityMenu->addAction(priorityNormalAct); - priorityMenu->addAction(priorityHighAct); - priorityMenu->addAction(priorityAutoAct); + prioritySlowAct = new QAction(QIcon(IMAGE_PRIORITYLOW), tr("Slower"), this); + connect(prioritySlowAct, SIGNAL(triggered()), this, SLOT(speedSlow())); + priorityMediumAct = new QAction(QIcon(IMAGE_PRIORITYNORMAL), tr("Average"), this); + connect(priorityMediumAct, SIGNAL(triggered()), this, SLOT(speedAverage())); + priorityFastAct = new QAction(QIcon(IMAGE_PRIORITYHIGH), tr("Faster"), this); + connect(priorityFastAct, SIGNAL(triggered()), this, SLOT(speedFast())); - chunkStreamingAct = new QAction(QIcon(IMAGE_PRIORITYAUTO), tr("Streaming"), this); - connect(chunkStreamingAct, SIGNAL(triggered()), this, SLOT(chunkStreaming())); - chunkRandomAct = new QAction(QIcon(IMAGE_PRIORITYAUTO), tr("Random"), this); - connect(chunkRandomAct, SIGNAL(triggered()), this, SLOT(chunkRandom())); + QMenu *priorityQueueMenu = new QMenu(tr("Priority (Queue)"), this); + priorityQueueMenu->setIcon(QIcon(IMAGE_PRIORITY)); + priorityQueueMenu->addAction(priorityLowAct); + priorityQueueMenu->addAction(priorityNormalAct); + priorityQueueMenu->addAction(priorityHighAct); + priorityQueueMenu->addAction(priorityAutoAct); - QMenu *chunkMenu = new QMenu(tr("Chunk strategy"), this); - chunkMenu->setIcon(QIcon(IMAGE_PRIORITY)); - chunkMenu->addAction(chunkStreamingAct); - chunkMenu->addAction(chunkRandomAct); + QMenu *prioritySpeedMenu = new QMenu(tr("Priority (Speed)"), this); + prioritySpeedMenu->setIcon(QIcon(IMAGE_PRIORITY)); + prioritySpeedMenu->addAction(prioritySlowAct); + prioritySpeedMenu->addAction(priorityMediumAct); + prioritySpeedMenu->addAction(priorityFastAct); + + chunkStreamingAct = new QAction(QIcon(IMAGE_PRIORITYAUTO), tr("Streaming"), this); + connect(chunkStreamingAct, SIGNAL(triggered()), this, SLOT(chunkStreaming())); + chunkRandomAct = new QAction(QIcon(IMAGE_PRIORITYAUTO), tr("Random"), this); + connect(chunkRandomAct, SIGNAL(triggered()), this, SLOT(chunkRandom())); + + QMenu *chunkMenu = new QMenu(tr("Chunk strategy"), this); + chunkMenu->setIcon(QIcon(IMAGE_PRIORITY)); + chunkMenu->addAction(chunkStreamingAct); + chunkMenu->addAction(chunkRandomAct); contextMnu.clear(); + if (addPlayOption) - { contextMnu.addAction(playAct); - } + contextMnu.addSeparator(); if(!items.empty()) { bool all_paused = true ; bool all_downld = true ; + bool all_downloading = true ; + bool all_queued = true ; QModelIndexList lst = ui.downloadList->selectionModel ()->selectedIndexes (); @@ -372,10 +385,21 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point ) all_downld = false ; if ( lst[i].column() == 0 && lst[i].model ()->data (lst[i].model ()->index (lst[i].row (), STATUS )).toString() == "Downloading") all_paused = false ; + + if ( lst[i].column() == 0) + if(lst[i].model ()->data (lst[i].model ()->index (lst[i].row (), STATUS )).toString() == "Queued") + all_downloading = false ; + else + all_queued = false ; } - contextMnu.addMenu( priorityMenu); - contextMnu.addMenu( chunkMenu); + if(all_downloading) + contextMnu.addMenu(prioritySpeedMenu); + else if(all_queued) + contextMnu.addMenu(priorityQueueMenu) ; + + if(all_downloading) + contextMnu.addMenu( chunkMenu); if(!all_paused) contextMnu.addAction( pauseAct); @@ -403,7 +427,6 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point ) #endif contextMnu.addAction( pastelinkAct); contextMnu.addSeparator(); - contextMnu.addAction( clearQueuedDwlAct); contextMnu.addAction( clearQueueAct); contextMnu.addSeparator(); contextMnu.addMenu( viewMenu); @@ -776,17 +799,17 @@ void TransfersDialog::insertTransfers() } switch (info.priority) { - case 0: - priority = tr("Low"); + case SPEED_LOW: + priority = tr("Slower"); break; - case 1: - priority = tr("Normal"); + case SPEED_NORMAL: + priority = tr("Average"); break; - case 2: - priority = tr("High"); + case SPEED_HIGH: + priority = tr("Faster"); break; default: - priority = tr("Auto"); + priority = tr("Average"); break; } @@ -799,6 +822,7 @@ void TransfersDialog::insertTransfers() FileProgressInfo pinfo ; pinfo.cmap = fcinfo.chunks ; + pinfo.type = FileProgressInfo::DOWNLOAD_LINE ; pinfo.progress = completed*100.0/info.size ; // std::cerr << "Converting fcinfo to compressed chunk map. Chunks=" << fcinfo.chunks.size() << std::endl ; @@ -872,6 +896,7 @@ void TransfersDialog::insertTransfers() remaining = (info.size - info.transfered) / (pit->tfRate * 1024.0); FileProgressInfo pinfo ; + pinfo.type = FileProgressInfo::DOWNLOAD_SOURCE ; pinfo.cmap = fcinfo.compressed_peer_availability_maps[pit->peerId] ; pinfo.progress = 0.0 ; // we don't display completion for sources. @@ -1061,6 +1086,7 @@ void TransfersDialog::insertTransfers() FileProgressInfo pinfo ; pinfo.progress = progress ; pinfo.cmap = CompressedChunkMap() ; + pinfo.type = FileProgressInfo::DOWNLOAD_LINE ; addUploadItem(symbol, name, coreId, fileSize, pinfo, dlspeed, sources, status, completed, remaining); ulCount++; @@ -1086,41 +1112,17 @@ QString TransfersDialog::getPeerName(const std::string& id) const void TransfersDialog::cancel() { QString queryWrn2; - queryWrn2.clear(); - queryWrn2.append(tr("Are you sure that you want to cancel and delete these files?")); + queryWrn2.clear(); + queryWrn2.append(tr("Are you sure that you want to cancel and delete these files?")); - if ((QMessageBox::question(this, tr("RetroShare"),queryWrn2,QMessageBox::Ok|QMessageBox::No, QMessageBox::Ok))== QMessageBox::Ok) - { - for(int i = 0; i <= DLListModel->rowCount(); i++) - { - if(selection->isRowSelected(i, QModelIndex())) - { - QVector pri; - pri << "Low" << "Normal" << "High" << "Auto"; - QString priority = getPriority(i, DLListModel).trimmed(); - std::string id = getID(i, DLListModel).toStdString(); + if ((QMessageBox::question(this, tr("RetroShare"),queryWrn2,QMessageBox::Ok|QMessageBox::No, QMessageBox::Ok))== QMessageBox::Ok) + for(int i = 0; i <= DLListModel->rowCount(); i++) + if(selection->isRowSelected(i, QModelIndex())) + { + std::string id = getID(i, DLListModel).toStdString(); - if (pri.indexOf(priority) >= 0) - { - /* for file that is just in dwl queue */ - rsFiles->clearDownload(id); - } - else - { -#ifdef UNUSED - QString qname = getFileName(i, DLListModel); - /* XXX -> Should not have to 'trim' filename ... something wrong here.. - * but otherwise, not exact filename .... BUG - */ - std::string name = (qname.trimmed()).toStdString(); -#endif rsFiles->FileCancel(id); /* hash */ - } - } - } - } - else - return; + } } void TransfersDialog::handleDownloadRequest(const QString& url){ @@ -1452,17 +1454,17 @@ void TransfersDialog::openTransfer() } /* clear download or all queue - for pending dwls */ -void TransfersDialog::clearQueuedDwl() -{ - std::set items; - std::set::iterator it; - getIdOfSelectedItems(items); - - for (it = items.begin(); it != items.end(); it ++) { - std::string hash = (*it)->data(Qt::DisplayRole).toString().toStdString(); - rsFiles->clearDownload(hash); - } -} +//void TransfersDialog::clearQueuedDwl() +//{ +// std::set items; +// std::set::iterator it; +// getIdOfSelectedItems(items); +// +// for (it = items.begin(); it != items.end(); it ++) { +// std::string hash = (*it)->data(Qt::DisplayRole).toString().toStdString(); +// rsFiles->clearDownload(hash); +// } +//} void TransfersDialog::clearQueue() { rsFiles->clearQueue(); @@ -1488,24 +1490,37 @@ void TransfersDialog::setChunkStrategy(FileChunksInfo::ChunkStrategy s) } } /* modify download priority actions */ -void TransfersDialog::priorityLow() +void TransfersDialog::speedSlow() { - changePriority(0); + changeSpeed(0); } -void TransfersDialog::priorityNormal() +void TransfersDialog::speedAverage() { - changePriority(1); + changeSpeed(1); } -void TransfersDialog::priorityHigh() +void TransfersDialog::speedFast() { - changePriority(2); -} -void TransfersDialog::priorityAuto() -{ - changePriority(3); + changeSpeed(2); } -void TransfersDialog::changePriority(int priority) +void TransfersDialog::priorityQueueLow() +{ + changeQueuePriority(0); +} +void TransfersDialog::priorityQueueNormal() +{ + changeQueuePriority(1); +} +void TransfersDialog::priorityQueueHigh() +{ + changeQueuePriority(2); +} +void TransfersDialog::priorityQueueAuto() +{ + changeQueuePriority(3); +} + +void TransfersDialog::changeSpeed(int speed) { std::set items; std::set::iterator it; @@ -1513,7 +1528,21 @@ void TransfersDialog::changePriority(int priority) for (it = items.begin(); it != items.end(); it ++) { std::string hash = (*it)->data(Qt::DisplayRole).toString().toStdString(); - rsFiles->changePriority(hash, priority); + rsFiles->changeDownloadSpeed(hash, speed); + } +} + + +void TransfersDialog::changeQueuePriority(int priority) +{ + std::set items; + std::set::iterator it; + getIdOfSelectedItems(items); + + for (it = items.begin(); it != items.end(); it ++) + { + std::string hash = (*it)->data(Qt::DisplayRole).toString().toStdString(); + rsFiles->changeQueuePriority(hash, priority); } } diff --git a/retroshare-gui/src/gui/TransfersDialog.h b/retroshare-gui/src/gui/TransfersDialog.h index 039779695..1c7fbc61d 100644 --- a/retroshare-gui/src/gui/TransfersDialog.h +++ b/retroshare-gui/src/gui/TransfersDialog.h @@ -85,14 +85,20 @@ class TransfersDialog : public RsAutoUpdatePage void previewTransfer(); /** clear download or all queue - for pending dwls */ - void clearQueuedDwl(); void clearQueue(); /** modify download priority actions */ - void priorityLow(); - void priorityNormal(); - void priorityHigh(); - void priorityAuto(); + void priorityQueueLow(); + void priorityQueueNormal(); + void priorityQueueHigh(); + void priorityQueueAuto(); + + void speedSlow(); + void speedAverage(); + void speedFast(); + + void changeSpeed(int) ; + void changeQueuePriority(int) ; void chunkRandom(); void chunkStreaming(); @@ -146,6 +152,9 @@ class TransfersDialog : public RsAutoUpdatePage QAction *clearQueuedDwlAct; QAction *clearQueueAct; QAction *changePriorityAct; + QAction *prioritySlowAct; + QAction *priorityMediumAct; + QAction *priorityFastAct; QAction *priorityLowAct; QAction *priorityNormalAct; QAction *priorityHighAct; diff --git a/retroshare-gui/src/gui/xprogressbar.cpp b/retroshare-gui/src/gui/xprogressbar.cpp index ecba3e2b3..e5c2af495 100644 --- a/retroshare-gui/src/gui/xprogressbar.cpp +++ b/retroshare-gui/src/gui/xprogressbar.cpp @@ -66,8 +66,8 @@ void xProgressBar::setColor() /* green schema */ case 1: // background - backgroundBorderColor.setRgb(3, 194, 26); - backgroundColor.setRgb(76, 214, 93); + backgroundBorderColor.setRgb(53, 194, 26); + backgroundColor.setRgb(176, 214, 93); // progress gradBorderColor.setRgb(8, 77, 16); gradColor1.setRgb(0, 137, 16); diff --git a/retroshare-gui/src/gui/xprogressbar.h b/retroshare-gui/src/gui/xprogressbar.h index ade488135..9f8d5cda4 100644 --- a/retroshare-gui/src/gui/xprogressbar.h +++ b/retroshare-gui/src/gui/xprogressbar.h @@ -39,6 +39,9 @@ class FileProgressInfo { public: + typedef enum { DOWNLOAD_LINE,UPLOAD_LINE,DOWNLOAD_SOURCE } LineType ; + + LineType type ; CompressedChunkMap cmap ; float progress ; };