mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-07 06:02:41 -04:00
Merge pull request #1200 from csoler/v0.6-SecurityFixes
V0.6 security fixes
This commit is contained in:
commit
952ff03a13
1 changed files with 44 additions and 39 deletions
|
@ -264,22 +264,24 @@ public:
|
||||||
|
|
||||||
QVariant sizeHintRole(int col) const
|
QVariant sizeHintRole(int col) const
|
||||||
{
|
{
|
||||||
|
float factor = QFontMetricsF(QApplication::font()).height()/14.0f ;
|
||||||
|
|
||||||
switch(col)
|
switch(col)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case COLUMN_NAME: return QVariant( 170 );
|
case COLUMN_NAME: return QVariant( factor * 170 );
|
||||||
case COLUMN_SIZE: return QVariant( 70 );
|
case COLUMN_SIZE: return QVariant( factor * 70 );
|
||||||
case COLUMN_COMPLETED: return QVariant( 75 );
|
case COLUMN_COMPLETED: return QVariant( factor * 75 );
|
||||||
case COLUMN_DLSPEED: return QVariant( 75 );
|
case COLUMN_DLSPEED: return QVariant( factor * 75 );
|
||||||
case COLUMN_PROGRESS: return QVariant( 170 );
|
case COLUMN_PROGRESS: return QVariant( factor * 170 );
|
||||||
case COLUMN_SOURCES: return QVariant( 90 );
|
case COLUMN_SOURCES: return QVariant( factor * 90 );
|
||||||
case COLUMN_STATUS: return QVariant( 100 );
|
case COLUMN_STATUS: return QVariant( factor * 100 );
|
||||||
case COLUMN_PRIORITY: return QVariant( 100 );
|
case COLUMN_PRIORITY: return QVariant( factor * 100 );
|
||||||
case COLUMN_REMAINING: return QVariant( 100 );
|
case COLUMN_REMAINING: return QVariant( factor * 100 );
|
||||||
case COLUMN_DOWNLOADTIME: return QVariant( 100 );
|
case COLUMN_DOWNLOADTIME: return QVariant( factor * 100 );
|
||||||
case COLUMN_ID: return QVariant( 100 );
|
case COLUMN_ID: return QVariant( factor * 100 );
|
||||||
case COLUMN_LASTDL: return QVariant( 100 );
|
case COLUMN_LASTDL: return QVariant( factor * 100 );
|
||||||
case COLUMN_PATH: return QVariant( 100 );
|
case COLUMN_PATH: return QVariant( factor * 100 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,7 +448,7 @@ public:
|
||||||
{
|
{
|
||||||
FileChunksInfo fcinfo;
|
FileChunksInfo fcinfo;
|
||||||
if (!rsFiles->FileDownloadChunksDetails(fileInfo.hash, fcinfo))
|
if (!rsFiles->FileDownloadChunksDetails(fileInfo.hash, fcinfo))
|
||||||
return -1;
|
return QVariant();
|
||||||
|
|
||||||
FileProgressInfo pinfo;
|
FileProgressInfo pinfo;
|
||||||
pinfo.cmap = fcinfo.chunks;
|
pinfo.cmap = fcinfo.chunks;
|
||||||
|
@ -480,34 +482,20 @@ public:
|
||||||
{
|
{
|
||||||
case COLUMN_PROGRESS:
|
case COLUMN_PROGRESS:
|
||||||
{
|
{
|
||||||
FileProgressInfo peerpinfo ;
|
FileChunksInfo fcinfo;
|
||||||
|
if (!rsFiles->FileDownloadChunksDetails(fileInfo.hash, fcinfo))
|
||||||
if(!rsFiles->FileUploadChunksDetails(fileInfo.hash, fileInfo.peers[source_id].peerId, peerpinfo.cmap) )
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
// Estimate the completion. We need something more accurate, meaning that we need to
|
RsPeerId pid = fileInfo.peers[source_id].peerId;
|
||||||
// transmit the completion info.
|
CompressedChunkMap& cmap(fcinfo.compressed_peer_availability_maps[pid]) ;
|
||||||
//
|
|
||||||
uint32_t chunk_size = 1024*1024 ;
|
|
||||||
uint32_t nb_chunks = (uint32_t)((fileInfo.size + (uint64_t)chunk_size - 1) / (uint64_t)(chunk_size)) ;
|
|
||||||
|
|
||||||
uint32_t filled_chunks = peerpinfo.cmap.filledChunks(nb_chunks) ;
|
FileProgressInfo pinfo;
|
||||||
peerpinfo.type = FileProgressInfo::UPLOAD_LINE ;
|
pinfo.cmap = cmap;
|
||||||
peerpinfo.nb_chunks = peerpinfo.cmap._map.empty()?0:nb_chunks ;
|
pinfo.type = FileProgressInfo::DOWNLOAD_SOURCE;
|
||||||
qlonglong completed ;
|
pinfo.progress = 0.0; // we dont display completion for sources
|
||||||
|
pinfo.nb_chunks = pinfo.cmap._map.empty() ? 0 : fcinfo.chunks.size();
|
||||||
|
|
||||||
if(filled_chunks > 0 && nb_chunks > 0)
|
return QVariant::fromValue(pinfo);
|
||||||
{
|
|
||||||
completed = peerpinfo.cmap.computeProgress(fileInfo.size,chunk_size) ;
|
|
||||||
peerpinfo.progress = completed / (float)fileInfo.size * 100.0f ;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
completed = fileInfo.peers[source_id].transfered % chunk_size ; // use the position with respect to last request.
|
|
||||||
peerpinfo.progress = (fileInfo.size>0)?((fileInfo.peers[source_id].transfered % chunk_size)*100.0/fileInfo.size):0 ;
|
|
||||||
}
|
|
||||||
|
|
||||||
return QVariant::fromValue(peerpinfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case COLUMN_ID: return QVariant(QString::fromStdString(fileInfo.hash.toStdString()) + QString::fromStdString(fileInfo.peers[source_id].peerId.toStdString()));
|
case COLUMN_ID: return QVariant(QString::fromStdString(fileInfo.hash.toStdString()) + QString::fromStdString(fileInfo.peers[source_id].peerId.toStdString()));
|
||||||
|
@ -556,7 +544,7 @@ public:
|
||||||
else if(mDownloads.size() < old_size)
|
else if(mDownloads.size() < old_size)
|
||||||
{
|
{
|
||||||
beginRemoveRows(QModelIndex(), mDownloads.size(), old_size-1);
|
beginRemoveRows(QModelIndex(), mDownloads.size(), old_size-1);
|
||||||
removeRows(old_size, old_size - mDownloads.size());
|
removeRows(mDownloads.size(), old_size - mDownloads.size());
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -567,7 +555,24 @@ public:
|
||||||
for(auto it(downHashes.begin());it!=downHashes.end();++it,++i)
|
for(auto it(downHashes.begin());it!=downHashes.end();++it,++i)
|
||||||
{
|
{
|
||||||
FileInfo& fileInfo(mDownloads[i]);
|
FileInfo& fileInfo(mDownloads[i]);
|
||||||
|
int old_size = fileInfo.peers.size() ;
|
||||||
|
|
||||||
rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, fileInfo);
|
rsFiles->FileDetails(*it, RS_FILE_HINTS_DOWNLOAD, fileInfo);
|
||||||
|
|
||||||
|
int new_size = fileInfo.peers.size() ;
|
||||||
|
|
||||||
|
if(old_size < new_size)
|
||||||
|
{
|
||||||
|
beginInsertRows(index(i,0), old_size, new_size-1);
|
||||||
|
insertRows(old_size, new_size - old_size,index(i,0));
|
||||||
|
endInsertRows();
|
||||||
|
}
|
||||||
|
else if(new_size < old_size)
|
||||||
|
{
|
||||||
|
beginRemoveRows(index(i,0), new_size, old_size-1);
|
||||||
|
removeRows(new_size, old_size - new_size,index(i,0));
|
||||||
|
endRemoveRows();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// endResetModel();
|
// endResetModel();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue