ported branch v0.5.0 commits 2529 and 2544 to trunk

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2545 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2010-03-15 12:57:08 +00:00
parent a4d1e61aa2
commit cc17744ee3
13 changed files with 123 additions and 105 deletions

View File

@ -277,7 +277,7 @@ void ftController::tickTransfers()
// Collect all non queued files. // Collect all non queued files.
// //
for(std::map<std::string,ftFileControl*>::iterator it(mDownloads.begin()); it != mDownloads.end(); it++) for(std::map<std::string,ftFileControl*>::iterator it(mDownloads.begin()); it != mDownloads.end(); it++)
if(it->second->mState != ftFileControl::QUEUED) if(it->second->mState != ftFileControl::QUEUED && it->second->mState != ftFileControl::PAUSED)
priority_tab[it->second->mPriority].push_back(it->second->mTransfer) ; priority_tab[it->second->mPriority].push_back(it->second->mTransfer) ;
// 2 - tick arrays with a probability proportional to priority // 2 - tick arrays with a probability proportional to priority
@ -412,7 +412,9 @@ void ftController::checkDownloadQueue()
time_t now = time(NULL) ; time_t now = time(NULL) ;
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();++it)
if(it->second->mState != ftFileControl::QUEUED && now - it->second->mCreator->lastRecvTimeStamp() > (time_t)MAX_TIME_INACTIVE_REQUEUED) if( it->second->mState != ftFileControl::QUEUED
&& it->second->mState != ftFileControl::PAUSED
&& now - it->second->mCreator->lastRecvTimeStamp() > (time_t)MAX_TIME_INACTIVE_REQUEUED)
{ {
locked_bottomQueue(it->second->mQueuePosition) ; locked_bottomQueue(it->second->mQueuePosition) ;
#ifdef DEBUG_DWLQUEUE #ifdef DEBUG_DWLQUEUE
@ -555,7 +557,7 @@ void ftController::locked_checkQueueElement(uint32_t pos)
mTurtle->monitorFileTunnels(_queue[pos]->mName,_queue[pos]->mHash,_queue[pos]->mSize) ; mTurtle->monitorFileTunnels(_queue[pos]->mName,_queue[pos]->mHash,_queue[pos]->mSize) ;
} }
if(pos >= _max_active_downloads && _queue[pos]->mState != ftFileControl::QUEUED) if(pos >= _max_active_downloads && _queue[pos]->mState != ftFileControl::QUEUED && _queue[pos]->mState != ftFileControl::PAUSED)
{ {
_queue[pos]->mState = ftFileControl::QUEUED ; _queue[pos]->mState = ftFileControl::QUEUED ;
_queue[pos]->mCreator->closeFile() ; _queue[pos]->mCreator->closeFile() ;
@ -1315,10 +1317,12 @@ bool ftController::FileCancel(std::string hash)
bool ftController::FileControl(std::string hash, uint32_t flags) bool ftController::FileControl(std::string hash, uint32_t flags)
{ {
#ifdef CONTROL_DEBUG //#ifdef CONTROL_DEBUG
std::cerr << "ftController::FileControl(" << hash << ","; std::cerr << "ftController::FileControl(" << hash << ",";
std::cerr << flags << ")"<<std::endl; std::cerr << flags << ")"<<std::endl;
#endif //#endif
RsStackMutex stack(ctrlMutex); /******* LOCKED ********/
/*check if the file in the download map*/ /*check if the file in the download map*/
std::map<std::string,ftFileControl*>::iterator mit=mDownloads.find(hash); std::map<std::string,ftFileControl*>::iterator mit=mDownloads.find(hash);
if (mit==mDownloads.end()) if (mit==mDownloads.end())
@ -1330,14 +1334,15 @@ bool ftController::FileControl(std::string hash, uint32_t flags)
} }
/*find the point to transfer module*/ /*find the point to transfer module*/
ftTransferModule* ft=(mit->second)->mTransfer;
switch (flags) switch (flags)
{ {
case RS_FILE_CTRL_PAUSE: case RS_FILE_CTRL_PAUSE:
ft->pauseTransfer(); mit->second->mState = ftFileControl::PAUSED ;
std::cerr << "setting state to " << ftFileControl::PAUSED << std::endl ;
break; break;
case RS_FILE_CTRL_START: case RS_FILE_CTRL_START:
ft->resumeTransfer(); mit->second->mState = ftFileControl::DOWNLOADING ;
std::cerr << "setting state to " << ftFileControl::DOWNLOADING << std::endl ;
break; break;
default: default:
return false; return false;
@ -1564,6 +1569,9 @@ bool ftController::FileDetails(std::string hash, FileInfo &info)
if(it->second->mState == ftFileControl::QUEUED) if(it->second->mState == ftFileControl::QUEUED)
info.downloadStatus = FT_STATE_QUEUED ; info.downloadStatus = FT_STATE_QUEUED ;
if(it->second->mState == ftFileControl::PAUSED)
info.downloadStatus = FT_STATE_PAUSED ;
info.tfRate = totalRate; info.tfRate = totalRate;
info.size = (it->second)->mSize; info.size = (it->second)->mSize;

View File

@ -69,7 +69,8 @@ class ftFileControl
enum { DOWNLOADING = 0, enum { DOWNLOADING = 0,
COMPLETED = 1, COMPLETED = 1,
ERROR_COMPLETION = 2, ERROR_COMPLETION = 2,
QUEUED = 3 QUEUED = 3,
PAUSED = 4
}; };
ftFileControl(); ftFileControl();

View File

@ -403,37 +403,6 @@ bool ftTransferModule::queryInactive()
return true; return true;
} }
bool ftTransferModule::pauseTransfer()
{
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
/*
std::map<std::string,peerInfo>::iterator mit;
for(mit = mOnlinePeers.begin(); mit != mOnlinePeers.end(); mit++)
{
(mit->second).state = PQIPEER_SUSPEND;
}
*/
mFileStatus.stat=ftFileStatus::PQIFILE_PAUSE;
return 1;
}
bool ftTransferModule::resumeTransfer()
{
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/
/*
std::map<std::string,peerInfo>::iterator mit;
for(mit = mOnlinePeers.begin(); mit != mOnlinePeers.end(); mit++)
{
(mit->second).state = PQIPEER_IDLE;
}
*/
mFileStatus.stat=ftFileStatus::PQIFILE_DOWNLOADING;
return 1;
}
bool ftTransferModule::cancelTransfer() bool ftTransferModule::cancelTransfer()
{ {
RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/ RsStackMutex stack(tfMtx); /******* STACK LOCKED ******/

View File

@ -105,7 +105,6 @@ public:
PQIFILE_INIT, PQIFILE_INIT,
PQIFILE_NOT_ONLINE, PQIFILE_NOT_ONLINE,
PQIFILE_DOWNLOADING, PQIFILE_DOWNLOADING,
PQIFILE_PAUSE,
PQIFILE_COMPLETE, PQIFILE_COMPLETE,
PQIFILE_FAIL, PQIFILE_FAIL,
PQIFILE_FAIL_CANCEL, PQIFILE_FAIL_CANCEL,
@ -138,8 +137,6 @@ public:
bool getFileSources(std::list<std::string> &peerIds); bool getFileSources(std::list<std::string> &peerIds);
bool getPeerState(std::string peerId,uint32_t &state,uint32_t &tfRate); bool getPeerState(std::string peerId,uint32_t &state,uint32_t &tfRate);
uint32_t getDataRate(std::string peerId); uint32_t getDataRate(std::string peerId);
bool pauseTransfer();
bool resumeTransfer();
bool cancelTransfer(); bool cancelTransfer();
bool completeFileTransfer(); bool completeFileTransfer();

View File

@ -45,6 +45,7 @@ const uint32_t FT_STATE_WAITING = 0x0002 ;
const uint32_t FT_STATE_DOWNLOADING = 0x0003 ; const uint32_t FT_STATE_DOWNLOADING = 0x0003 ;
const uint32_t FT_STATE_COMPLETE = 0x0004 ; const uint32_t FT_STATE_COMPLETE = 0x0004 ;
const uint32_t FT_STATE_QUEUED = 0x0005 ; const uint32_t FT_STATE_QUEUED = 0x0005 ;
const uint32_t FT_STATE_PAUSED = 0x0006 ;
class TransferInfo class TransferInfo
{ {

View File

@ -11,7 +11,6 @@ MOC_DIR = temp/moc
#CONFIG += debug #CONFIG += debug
debug { debug {
DEFINES += PEERS_DEBUG
QMAKE_CXXFLAGS *= -g QMAKE_CXXFLAGS *= -g
} }

View File

@ -25,6 +25,8 @@
const QString RetroShareLink::HEADER_NAME("retroshare://file"); const QString RetroShareLink::HEADER_NAME("retroshare://file");
std::vector<RetroShareLink> RSLinkClipboard::_links ;
RetroShareLink::RetroShareLink(const QUrl& url) RetroShareLink::RetroShareLink(const QUrl& url)
{ {
// parse // parse
@ -94,6 +96,10 @@ QString RetroShareLink::toString() const
{ {
return HEADER_NAME + "|" + _name + "|" + QString::number(_size) + "|" + _hash ; return HEADER_NAME + "|" + _name + "|" + QString::number(_size) + "|" + _hash ;
} }
QString RetroShareLink::toHtml() const
{
return QString("<a href='") + toString() + "'>" + toString() + "</a>" ;
}
bool RetroShareLink::checkName(const QString& name) bool RetroShareLink::checkName(const QString& name)
{ {

View File

@ -1,5 +1,5 @@
/*************************************************************************** /***************************************************************************
* Copyright (C) 2009 * * Copyright (C) 2009 Cyril Soler *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by * * it under the terms of the GNU General Public License as published by *
@ -24,6 +24,14 @@
// //
// The link is done in a way that if valid()==true, then the link can be used. // The link is done in a way that if valid()==true, then the link can be used.
// //
// The following combinations have been tested:
// copy paste-> Transfers (DL) | Message compose (forums) | Private msg | Public chat | private Chat
// -------------+----------------+--------------------------+------------------+-------------+-------------
// search | Y | Y | Y (send RS link) | Paste menu? | Paste menu?
// -------------+----------------+--------------------------+------------------+-------------+-------------
// shared | Y | Y | Y (send RS link) | Paste menu? | Paste menu?
// -------------+----------------+--------------------------+------------------+-------------+-------------
//
#include <stdint.h> #include <stdint.h>
#include <QString> #include <QString>
#include <QVector> #include <QVector>
@ -39,7 +47,10 @@ class RetroShareLink
const QString& name() const { return _name ; } const QString& name() const { return _name ; }
const QString& hash() const { return _hash ; } const QString& hash() const { return _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>
QString toHtml() const ;
QUrl toUrl() const ; QUrl toUrl() const ;
bool valid() const { return _size > 0 ; } bool valid() const { return _size > 0 ; }
@ -55,5 +66,37 @@ class RetroShareLink
QString _hash; QString _hash;
}; };
/// 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.
//
class RSLinkClipboard
{
public:
static void copyLinks(const std::vector<RetroShareLink>& links)
{
_links = links ;
}
static const std::vector<RetroShareLink>& pasteLinks()
{
return _links ;
}
static QString toHtml()
{
QString res ;
for(uint32_t i=0;i<_links.size();++i)
res += _links[i].toHtml() + "<br/>" ;
return res ;
}
static bool empty()
{
return _links.empty();
}
private:
static std::vector<RetroShareLink> _links ;
};
#endif #endif

View File

@ -1192,7 +1192,7 @@ void SearchDialog::copysearchLink()
int numdls = itemsForCopy.size(); int numdls = itemsForCopy.size();
QTreeWidgetItem * item; QTreeWidgetItem * item;
QList<QUrl> urls ; std::vector<RetroShareLink> urls ;
for (int i = 0; i < numdls; ++i) for (int i = 0; i < numdls; ++i)
{ {
@ -1211,12 +1211,10 @@ void SearchDialog::copysearchLink()
RetroShareLink link(fname, fsize, fhash); RetroShareLink link(fname, fsize, fhash);
if(link.valid()) if(link.valid())
urls.push_back(link.toUrl()) ; urls.push_back(link) ;
} }
} }
QMimeData *dt = new QMimeData; RSLinkClipboard::copyLinks(urls) ;
dt->setUrls(urls) ;
QApplication::clipboard()->setMimeData(dt) ;
} }
void SearchDialog::sendLinkTo( ) void SearchDialog::sendLinkTo( )
@ -1228,8 +1226,8 @@ void SearchDialog::sendLinkTo( )
nMsgDialog->newMsg(); nMsgDialog->newMsg();
nMsgDialog->insertTitleText("New RetroShare Link(s)"); nMsgDialog->insertTitleText("New RetroShare Link(s)");
nMsgDialog->insertHtmlText(QApplication::clipboard()->text().toStdString());
nMsgDialog->insertMsgText(RSLinkClipboard::toHtml().toStdString()) ;
nMsgDialog->show(); nMsgDialog->show();
} }

View File

@ -251,7 +251,7 @@ void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
else else
localModel->getDirDetailsFromSelect(lst, dirVec); localModel->getDirDetailsFromSelect(lst, dirVec);
QList<QUrl> urls ; std::vector<RetroShareLink> urls ;
for (int i = 0, n = dirVec.size(); i < n; ++i) for (int i = 0, n = dirVec.size(); i < n; ++i)
{ {
@ -275,19 +275,20 @@ void SharedFilesDialog::copyLink (const QModelIndexList& lst, bool remote)
continue; continue;
RetroShareLink link(details.name.c_str(), details.count, details.hash.c_str()); RetroShareLink link(details.name.c_str(), details.count, details.hash.c_str());
urls.push_back(link.toUrl()) ;
if(link.valid())
urls.push_back(link) ;
} }
} }
else else
{ {
RetroShareLink link(details.name.c_str(), details.count, details.hash.c_str()); RetroShareLink link(details.name.c_str(), details.count, details.hash.c_str());
urls.push_back(link.toUrl()) ; if(link.valid())
urls.push_back(link) ;
} }
} }
QMimeData *dt = new QMimeData ; RSLinkClipboard::copyLinks(urls) ;
dt->setUrls(urls) ;
QApplication::clipboard()->setMimeData(dt) ;
} }
void SharedFilesDialog::copyLinkRemote() void SharedFilesDialog::copyLinkRemote()
@ -327,7 +328,7 @@ void SharedFilesDialog::sendremoteLinkTo()
std::cerr << "SharedFilesDialog::sendremoteLinkTo()" << std::endl; std::cerr << "SharedFilesDialog::sendremoteLinkTo()" << std::endl;
nMsgDialog->newMsg(); nMsgDialog->newMsg();
nMsgDialog->insertTitleText("RetroShare Link"); nMsgDialog->insertTitleText("RetroShare Link");
nMsgDialog->insertMsgText(QApplication::clipboard()->text().toStdString()); nMsgDialog->insertMsgText(RSLinkClipboard::toHtml().toStdString());
nMsgDialog->show(); nMsgDialog->show();
} }
@ -347,7 +348,8 @@ void SharedFilesDialog::sendLinkTo()
std::cerr << "SharedFilesDialog::sendLinkTo()" << std::endl; std::cerr << "SharedFilesDialog::sendLinkTo()" << std::endl;
nMsgDialog->newMsg(); nMsgDialog->newMsg();
nMsgDialog->insertTitleText("RetroShare Link"); nMsgDialog->insertTitleText("RetroShare Link");
nMsgDialog->insertMsgText(QApplication::clipboard()->text().toStdString());
nMsgDialog->insertMsgText(RSLinkClipboard::toHtml().toStdString());
nMsgDialog->show(); nMsgDialog->show();
} }
@ -359,7 +361,6 @@ void SharedFilesDialog::sendHtmlLinkTo( )
/* create a message */ /* create a message */
ChanMsgDialog *nMsgDialog = new ChanMsgDialog(true); ChanMsgDialog *nMsgDialog = new ChanMsgDialog(true);
/* fill it in /* fill it in
* files are receommended already * files are receommended already
* just need to set peers * just need to set peers
@ -367,22 +368,22 @@ void SharedFilesDialog::sendHtmlLinkTo( )
std::cerr << "SharedFilesDialog::sendLinkTo()" << std::endl; std::cerr << "SharedFilesDialog::sendLinkTo()" << std::endl;
nMsgDialog->newMsg(); nMsgDialog->newMsg();
nMsgDialog->insertTitleText("RetroShare Link"); nMsgDialog->insertTitleText("RetroShare Link");
nMsgDialog->insertHtmlText(QApplication::clipboard()->text().toStdString()); // nMsgDialog->insertHtmlText(QApplication::clipboard()->text().toStdString());// not compatible with multiple links
nMsgDialog->insertMsgText(RSLinkClipboard::toHtml().toStdString());
nMsgDialog->show(); nMsgDialog->show();
} }
void SharedFilesDialog::sendLinktoChat() //void SharedFilesDialog::sendLinktoChat()
{ //{
copyLinkLocal (); // copyLinkLocal ();
//
static SendLinkDialog *slinkDialog = new SendLinkDialog(this); // static SendLinkDialog *slinkDialog = new SendLinkDialog(this);
//
slinkDialog->insertHtmlText(QApplication::clipboard()->text().toStdString()); // slinkDialog->insertMsgText(RSLinkClipboard::toHtml().toStdString());
// slinkDialog->show();
slinkDialog->show(); //
//}
}
void SharedFilesDialog::sendLinkToCloud() void SharedFilesDialog::sendLinkToCloud()
{ {
@ -673,8 +674,8 @@ void SharedFilesDialog::sharedDirTreeWidgetContextMenu( QPoint point )
sendhtmllinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Links (HTML)" ), this ); sendhtmllinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Links (HTML)" ), this );
connect( sendhtmllinkAct , SIGNAL( triggered() ), this, SLOT( sendHtmlLinkTo( ) ) ); connect( sendhtmllinkAct , SIGNAL( triggered() ), this, SLOT( sendHtmlLinkTo( ) ) );
sendchatlinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Links to Chat" ), this ); // sendchatlinkAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Links to Chat" ), this );
connect( sendchatlinkAct , SIGNAL( triggered() ), this, SLOT( sendLinktoChat( ) ) ); // connect( sendchatlinkAct , SIGNAL( triggered() ), this, SLOT( sendLinktoChat( ) ) );
sendlinkCloudAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Links to Cloud" ), this ); sendlinkCloudAct = new QAction(QIcon(IMAGE_COPYLINK), tr( "Send retroshare Links to Cloud" ), this );
connect( sendlinkCloudAct , SIGNAL( triggered() ), this, SLOT( sendLinkToCloud( ) ) ); connect( sendlinkCloudAct , SIGNAL( triggered() ), this, SLOT( sendLinkToCloud( ) ) );
@ -702,10 +703,10 @@ void SharedFilesDialog::sharedDirTreeWidgetContextMenu( QPoint point )
if(!localModel->isDir( midx ) ) if(!localModel->isDir( midx ) )
{ {
contextMnu2.addAction( copylinklocalAct); contextMnu2.addAction( copylinklocalAct);
contextMnu2.addAction( copylinklocalhtmlAct); // contextMnu2.addAction( copylinklocalhtmlAct);
contextMnu2.addAction( sendlinkAct); contextMnu2.addAction( sendlinkAct);
contextMnu2.addAction( sendhtmllinkAct); // contextMnu2.addAction( sendhtmllinkAct);
contextMnu2.addAction( sendchatlinkAct); // contextMnu2.addAction( sendchatlinkAct);
contextMnu2.addSeparator(); contextMnu2.addSeparator();
#ifndef RS_RELEASE_VERSION #ifndef RS_RELEASE_VERSION
contextMnu2.addAction( sendlinkCloudAct); contextMnu2.addAction( sendlinkCloudAct);

View File

@ -70,7 +70,7 @@ private slots:
void sendHtmlLinkTo(); void sendHtmlLinkTo();
void sendLinkToCloud(); void sendLinkToCloud();
void addLinkToCloud(); void addLinkToCloud();
void sendLinktoChat(); // void sendLinktoChat();
void showFrame(bool show); void showFrame(bool show);
void showFrameRemote(bool show); void showFrameRemote(bool show);

View File

@ -362,7 +362,7 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
for (int i = 0; i < lst.count (); i++) for (int i = 0; i < lst.count (); i++)
{ {
if ( lst[i].column() == 0 && info.downloadStatus == FT_STATE_WAITING ) if ( lst[i].column() == 0 && info.downloadStatus == FT_STATE_PAUSED )
all_downld = false ; all_downld = false ;
if ( lst[i].column() == 0 && info.downloadStatus == FT_STATE_DOWNLOADING ) if ( lst[i].column() == 0 && info.downloadStatus == FT_STATE_DOWNLOADING )
all_paused = false ; all_paused = false ;
@ -384,10 +384,6 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
if(all_downloading) if(all_downloading)
contextMnu.addMenu( chunkMenu); contextMnu.addMenu( chunkMenu);
if(!all_paused)
contextMnu.addAction( pauseAct);
if(!all_downld)
contextMnu.addAction( resumeAct);
if(info.downloadStatus != FT_STATE_COMPLETE) if(info.downloadStatus != FT_STATE_COMPLETE)
contextMnu.addAction( cancelAct); contextMnu.addAction( cancelAct);
@ -406,6 +402,11 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
contextMnu.addAction( openfolderAct); contextMnu.addAction( openfolderAct);
contextMnu.addAction( detailsfileAct); contextMnu.addAction( detailsfileAct);
contextMnu.addSeparator(); contextMnu.addSeparator();
if(info.downloadStatus == FT_STATE_PAUSED)
contextMnu.addAction( resumeAct);
else if(info.downloadStatus != FT_STATE_COMPLETE)
contextMnu.addAction( pauseAct);
} }
contextMnu.addAction( clearcompletedAct); contextMnu.addAction( clearcompletedAct);
@ -414,7 +415,9 @@ void TransfersDialog::downloadListCostumPopupMenu( QPoint point )
if(single) if(single)
contextMnu.addAction( copylinkAct); contextMnu.addAction( copylinkAct);
#endif #endif
if(!RSLinkClipboard::empty())
contextMnu.addAction( pastelinkAct); contextMnu.addAction( pastelinkAct);
contextMnu.addSeparator(); contextMnu.addSeparator();
// contextMnu.addAction( clearQueueAct); // contextMnu.addAction( clearQueueAct);
contextMnu.addSeparator(); contextMnu.addSeparator();
@ -670,7 +673,7 @@ void TransfersDialog::insertTransfers()
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);
qlonglong fileSize = info.size; qlonglong fileSize = info.size;
double fileDlspeed = info.tfRate * 1024.0; double fileDlspeed = (info.downloadStatus==FT_STATE_PAUSED)?0.0:(info.tfRate * 1024.0);
/* get the sources (number of online peers) */ /* get the sources (number of online peers) */
int online = 0; int online = 0;
@ -690,6 +693,7 @@ void TransfersDialog::insertTransfers()
case FT_STATE_DOWNLOADING: status = tr("Downloading"); break; case FT_STATE_DOWNLOADING: status = tr("Downloading"); break;
case FT_STATE_COMPLETE: status = tr("Complete"); break; case FT_STATE_COMPLETE: status = tr("Complete"); break;
case FT_STATE_QUEUED: status = tr("Queued"); break; case FT_STATE_QUEUED: status = tr("Queued"); break;
case FT_STATE_PAUSED: status = tr("Paused"); break;
default: status = tr("Unknown"); break; default: status = tr("Unknown"); break;
} }
@ -751,10 +755,8 @@ void TransfersDialog::insertTransfers()
default: status = tr(""); break; default: status = tr(""); break;
} }
double peerDlspeed = 0; double peerDlspeed = 0;
if ((uint32_t)pit->status == FT_STATE_DOWNLOADING) if ((uint32_t)pit->status == FT_STATE_DOWNLOADING && info.downloadStatus != FT_STATE_PAUSED)
{
peerDlspeed = pit->tfRate * 1024.0; peerDlspeed = pit->tfRate * 1024.0;
}
FileProgressInfo peerpinfo ; FileProgressInfo peerpinfo ;
peerpinfo.cmap = fcinfo.compressed_peer_availability_maps[pit->peerId]; peerpinfo.cmap = fcinfo.compressed_peer_availability_maps[pit->peerId];
@ -1072,15 +1074,12 @@ void TransfersDialog::showDetailsDialog()
void TransfersDialog::pasteLink() void TransfersDialog::pasteLink()
{ {
QList<QUrl> urllist = QApplication::clipboard()->mimeData()->urls() ; const std::vector<RetroShareLink>& links(RSLinkClipboard::pasteLinks()) ;
for(QList<QUrl>::const_iterator it(urllist.begin());it!=urllist.end();++it) for(uint32_t i=0;i<links.size();++i)
{ if (links[i].valid())
RetroShareLink link(*it) ; if(!rsFiles->FileRequest(links[i].name().toStdString(), links[i].hash().toStdString(),links[i].size(), "", RS_FILE_HINTS_NETWORK_WIDE, std::list<std::string>()))
QMessageBox::critical(NULL,"Download refused","The file "+links[i].name()+" could not be downloaded. Do you already have it ?") ;
if (link.valid())
rsFiles->FileRequest(link.name().toStdString(), link.hash().toStdString(),link.size(), "", RS_FILE_HINTS_NETWORK_WIDE, std::list<std::string>());
}
} }
void TransfersDialog::getIdOfSelectedItems(std::set<QStandardItem *>& items) void TransfersDialog::getIdOfSelectedItems(std::set<QStandardItem *>& items)
@ -1125,6 +1124,7 @@ bool TransfersDialog::controlTransferFile(uint32_t flags)
std::set<QStandardItem *>::iterator it; std::set<QStandardItem *>::iterator it;
getIdOfSelectedItems(items); getIdOfSelectedItems(items);
for (it = items.begin(); it != items.end(); it ++) { for (it = items.begin(); it != items.end(); it ++) {
std::cerr << "changing file mode for hash " << (*it)->data(Qt::DisplayRole).toString().toStdString() << " to " << flags << std::endl;
result &= rsFiles->FileControl((*it)->data(Qt::DisplayRole).toString().toStdString(), flags); result &= rsFiles->FileControl((*it)->data(Qt::DisplayRole).toString().toStdString(), flags);
} }

View File

@ -84,6 +84,9 @@ CreateForumMsg::CreateForumMsg(std::string fId, std::string pId)
void CreateForumMsg::forumMessageCostumPopupMenu( QPoint point ) void CreateForumMsg::forumMessageCostumPopupMenu( QPoint point )
{ {
if(RSLinkClipboard::empty())
return ;
contextMnu = new QMenu( this ); contextMnu = new QMenu( this );
pasteLinkAct = new QAction(QIcon(":/images/pasterslink.png"), tr( "Paste retroshare Link" ), this ); pasteLinkAct = new QAction(QIcon(":/images/pasterslink.png"), tr( "Paste retroshare Link" ), this );
@ -415,14 +418,6 @@ void CreateForumMsg::fileHashingFinished(AttachFileItem* file) {
void CreateForumMsg::pasteLink() void CreateForumMsg::pasteLink()
{ {
QList<QUrl> list = QApplication::clipboard()->mimeData()->urls(); ui.forumMessage->insertHtml(RSLinkClipboard::toHtml()) ;
for(QList<QUrl>::const_iterator it(list.begin());it!=list.end();++it)
{
RetroShareLink link(*it) ;
if(link.valid())
ui.forumMessage->insertHtml("<a href='" + link.toString() + "'> " + link.toString() + "</a> <br>") ;
}
} }