* Switched to new rsFiles interface.

* Updated Transfers/SharedFiles/Messages.. etc Dialogs.
 * Disabled 'Recommendation Lists' for the moment.
 * updated Interface files.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@631 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2008-07-02 16:59:56 +00:00
parent be392405e8
commit 32973f0838
13 changed files with 215 additions and 213 deletions

View file

@ -47,6 +47,7 @@
#include "rsiface/rsiface.h"
#include "rsiface/rspeers.h"
#include "rsiface/rsfiles.h"
#include "gui/connect/InviteDialog.h"
#include "gui/connect/AddFriendDialog.h"
@ -455,8 +456,7 @@ void MainWindow::addSharedDirectory()
std::string dir = qdir.toStdString();
if (dir != "")
{
rsicontrol -> ConfigAddSharedDir(dir);
//rsicontrol -> ConfigSave();
rsFiles -> addSharedDirectory(dir);
}
}

View file

@ -28,6 +28,7 @@
#include "rsiface/rsiface.h"
#include "rsiface/rspeers.h"
#include "rsiface/rsmsgs.h"
#include "rsiface/rsfiles.h"
#include <sstream>
#include <QContextMenuEvent>
@ -282,7 +283,7 @@ void MessagesDialog::getallrecommended()
for(fit = fnames.begin(), hit = hashes.begin(), sit = sizes.begin();
fit != fnames.end(); fit++, hit++, sit++)
{
rsicontrol -> FileRequest(*fit, *hit, *sit, "");
rsFiles -> FileRequest(*fit, *hit, *sit, "", 0);
}
}

View file

@ -21,7 +21,7 @@
#include <rshare.h>
#include "rsiface/rsiface.h"
#include "rsiface/rsfiles.h"
#include "DirectoriesDialog.h"
@ -56,12 +56,9 @@ DirectoriesDialog::save(QString &errmsg)
/** Loads the settings for this page */
void DirectoriesDialog::load()
{
/* get the shared directories */
rsiface->lockData(); /* Lock Interface */
std::list<std::string>::const_iterator it;
const std::list<std::string> &dirs = rsiface->getConfig().sharedDirList;
std::list<std::string> dirs;
rsFiles->getSharedDirectories(dirs);
/* get a link to the table */
QListWidget *listWidget = ui.dirList;
@ -75,9 +72,7 @@ void DirectoriesDialog::load()
listWidget->addItem(QString::fromStdString(*it));
}
ui.incomingDir->setText(QString::fromStdString(rsiface->getConfig().incomingDir));
rsiface->unlockData(); /* UnLock Interface */
ui.incomingDir->setText(QString::fromStdString(rsFiles->getDownloadDirectory()));
listWidget->update(); /* update display */
@ -96,7 +91,7 @@ void DirectoriesDialog::addShareDirectory()
std::string dir = qdir.toStdString();
if (dir != "")
{
rsicontrol -> ConfigAddSharedDir(dir);
rsFiles->addSharedDirectory(dir);
load();
}
}
@ -109,7 +104,7 @@ void DirectoriesDialog::removeShareDirectory()
QListWidgetItem *qdir = listWidget -> currentItem();
if (qdir)
{
rsicontrol -> ConfigRemoveSharedDir( qdir->text().toStdString());
rsFiles->removeSharedDirectory( qdir->text().toStdString());
load();
}
}
@ -122,7 +117,7 @@ void DirectoriesDialog::setIncomingDirectory()
std::string dir = qdir.toStdString();
if (dir != "")
{
rsicontrol->ConfigSetIncomingDir(dir);
rsFiles->setDownloadDirectory(dir);
}
load();
}

View file

@ -24,6 +24,7 @@
#include "SearchDialog.h"
#include "rsiface/rsiface.h"
#include "rsiface/rsexpr.h"
#include "rsiface/rsfiles.h"
#include <iostream>
#include <sstream>
@ -226,10 +227,10 @@ void SearchDialog::download()
// call the download
if (item->text(SR_ID_COL) != "Local")
{
rsicontrol -> FileRequest((item->text(SR_NAME_COL)).toStdString(),
rsFiles -> FileRequest((item->text(SR_NAME_COL)).toStdString(),
(item->text(SR_HASH_COL)).toStdString(),
(item->text(SR_SIZE_COL)).toInt(),
"");
"", 0);
}
else
{
@ -378,7 +379,7 @@ void SearchDialog::advancedSearch(Expression* expression)
/* call to core */
std::list<FileDetail> results;
rsicontrol -> SearchBoolExp(expression, results);
rsFiles -> SearchBoolExp(expression, results);
/* abstraction to allow reusee of tree rendering code */
resultsToTree((advSearchDialog->getSearchAsString()).toStdString(), results);
@ -412,7 +413,7 @@ void SearchDialog::searchKeywords()
std::list<FileDetail> initialResults;
std::list<FileDetail> * finalResults = 0;
rsicontrol -> SearchKeywords(words, initialResults);
rsFiles -> SearchKeywords(words, initialResults);
/* which extensions do we use? */
QString qExt, qName;
int extIndex;

View file

@ -25,6 +25,7 @@
#include "rsiface/rsiface.h"
#include "rsiface/rspeers.h"
#include "rsiface/rsfiles.h"
#include "rsiface/RemoteDirModel.h"
#include "util/RsAction.h"
#include "msgs/ChanMsgDialog.h"
@ -135,7 +136,7 @@ SharedFilesDialog::SharedFilesDialog(QWidget *parent)
void SharedFilesDialog::checkUpdate()
{
/* update */
if (rsicontrol->InDirectoryCheck())
if (rsFiles->InDirectoryCheck())
{
ui.hashLabel->setPixmap(QPixmap(IMAGE_HASH_BUSY));
/*QMovie *movie = new QMovie(IMAGE_PROGRESS);
@ -153,7 +154,7 @@ void SharedFilesDialog::checkUpdate()
void SharedFilesDialog::forceCheck()
{
rsicontrol->ForceDirectoryCheck();
rsFiles->ForceDirectoryCheck();
return;
}
@ -191,32 +192,6 @@ void SharedFilesDialog::downloadRemoteSelected()
}
void SharedFilesDialog::addMsgRemoteSelected()
{
/* call back to the model (which does all the interfacing? */
std::cerr << "Recommending Files";
std::cerr << std::endl;
QItemSelectionModel *qism = ui.remoteDirTreeView->selectionModel();
model -> recommendSelected(qism->selectedIndexes());
}
void SharedFilesDialog::recommendfile()
{
/* call back to the model (which does all the interfacing? */
std::cerr << "Recommending Files";
std::cerr << std::endl;
QItemSelectionModel *qism = ui.localDirTreeView->selectionModel();
localModel -> recommendSelected(qism->selectedIndexes());
}
void SharedFilesDialog::playselectedfiles()
{
@ -235,7 +210,7 @@ void SharedFilesDialog::playselectedfiles()
for(it = paths.begin(); it != paths.end(); it++)
{
std::string fullpath;
rsicontrol->ConvertSharedFilePath(*it, fullpath);
rsFiles->ConvertSharedFilePath(*it, fullpath);
fullpaths.push_back(QString::fromStdString(fullpath));
std::cerr << "Playing: " << fullpath;
@ -246,6 +221,34 @@ void SharedFilesDialog::playselectedfiles()
}
#if 0
void SharedFilesDialog::addMsgRemoteSelected()
{
/* call back to the model (which does all the interfacing? */
std::cerr << "Recommending Files";
std::cerr << std::endl;
QItemSelectionModel *qism = ui.remoteDirTreeView->selectionModel();
model -> recommendSelected(qism->selectedIndexes());
}
void SharedFilesDialog::recommendfile()
{
/* call back to the model (which does all the interfacing? */
std::cerr << "Recommending Files";
std::cerr << std::endl;
QItemSelectionModel *qism = ui.localDirTreeView->selectionModel();
localModel -> recommendSelected(qism->selectedIndexes());
}
void SharedFilesDialog::recommendFileSetOnly()
@ -284,9 +287,9 @@ void SharedFilesDialog::recommendFilesTo( std::string rsid )
nMsgDialog->close();
}
void SharedFilesDialog::recommendFilesToMsg( std::string rsid )
void SharedFilesDialog::recommendFilesToMsg( std::string rsid )
{
recommendFileSetOnly();
@ -308,8 +311,9 @@ void SharedFilesDialog::recommendFilesToMsg( std::string rsid )
nMsgDialog->show();
}
#endif
void SharedFilesDialog::openfile()
{
/* call back to the model (which does all the interfacing? */
@ -364,9 +368,9 @@ void SharedFilesDialog::shareddirtreeWidgetCostumPopupMenu( QPoint point )
openfolderAct = new QAction(QIcon(IMAGE_DOWNLOAD), tr( "Play File(s)" ), this );
connect( openfolderAct , SIGNAL( triggered() ), this, SLOT( playselectedfiles() ) );
#if 0
openfileAct = new QAction(QIcon(IMAGE_ATTACHMENT), tr( "Add to Recommend List" ), this );
connect( openfileAct , SIGNAL( triggered() ), this, SLOT( recommendfile() ) );
/* now we're going to ask who to recommend it to...
* First Level.
@ -416,12 +420,14 @@ void SharedFilesDialog::shareddirtreeWidgetCostumPopupMenu( QPoint point )
/* create list of ids */
}
#endif
contextMnu2.addAction( openfolderAct);
contextMnu2.addAction( openfileAct);
contextMnu2.addSeparator();
contextMnu2.addMenu( recMenu);
contextMnu2.addMenu( msgMenu);
//contextMnu2.addAction( openfileAct);
//contextMnu2.addSeparator();
//contextMnu2.addMenu( recMenu);
//contextMnu2.addMenu( msgMenu);
contextMnu2.exec( mevent2->globalPos() );

View file

@ -56,16 +56,16 @@ private slots:
void shareddirtreeWidgetCostumPopupMenu( QPoint point );
void downloadRemoteSelected();
void addMsgRemoteSelected();
// void addMsgRemoteSelected();
void recommendfile();
// void recommendfile();
void playselectedfiles();
void openfile();
void openfolder();
void recommendFileSetOnly();
void recommendFilesTo( std::string rsid );
void recommendFilesToMsg( std::string rsid );
// void recommendFileSetOnly();
// void recommendFilesTo( std::string rsid );
// void recommendFilesToMsg( std::string rsid );
signals:
void playFiles(QStringList files);

View file

@ -36,7 +36,7 @@
#include <QStandardItemModel>
#include <sstream>
#include "rsiface/rsiface.h"
#include "rsiface/rsfiles.h"
/* Images for context menu icons */
#define IMAGE_INFO ":/images/fileinfo.png"
@ -198,9 +198,7 @@ void TransfersDialog::playSelectedTransfer()
std::cerr << "TransfersDialog::playSelectedTransfer()" << std::endl;
/* get the shared directories */
rsiface->lockData(); /* Lock Interface */
std::string incomingdir = rsiface->getConfig().incomingDir;
rsiface->unlockData(); /* UnLock Interface */
std::string incomingdir = rsFiles->getDownloadDirectory();
/* create the List of Files */
QStringList playList;
@ -371,33 +369,32 @@ void TransfersDialog::insertTransfers()
delUploadItem(i);
}
//nun aktuelle DownloadListe hinzufügen
rsiface->lockData(); /* Lock Interface */
std::list<FileTransferInfo>::const_iterator it;
const std::list<FileTransferInfo> &transfers = rsiface->getTransferList();
/* get the download and upload lists */
std::list<std::string> downHashes;
std::list<std::string> upHashes;
rsFiles->FileDownloads(downHashes);
rsFiles->FileUploads(upHashes);
uint32_t dlCount = 0;
uint32_t ulCount = 0;
for(it = transfers.begin(); it != transfers.end(); it++)
std::list<std::string>::iterator it;
for(it = downHashes.begin(); it != downHashes.end(); it++)
{
FileInfo info;
if (!rsFiles->FileDetails(*it, 0, info))
{
continue;
}
symbol = "";
coreId = "";
name = QString::fromStdString(it->fname);
sources = QString::fromStdString(it->source);
coreId = QString::fromStdString(info.hash);
name = QString::fromStdString(info.fname);
sources = QString::fromStdString(info.source);
/* Replace ID with HASH -> as thats what we need to cancel! */
//std::ostringstream out;
//out << it->id;
//coreId = QString::fromStdString(it->hashout.str());
coreId = QString::fromStdString(it->hash);
sources = QString::fromStdString(it->source);
switch(it->downloadStatus)
switch(info.downloadStatus)
{
/******** XXX HAND CODED!
@ -427,35 +424,78 @@ void TransfersDialog::insertTransfers()
}
dlspeed = it->tfRate * 1024.0;
fileSize = it->size;
completed = it->transfered;
progress = it->transfered * 100.0 / it->size;
remaining = (it->size - it->transfered) / (it->tfRate * 1024.0);
dlspeed = info.tfRate * 1024.0;
fileSize = info.size;
completed = info.transfered;
progress = info.transfered * 100.0 / info.size;
remaining = (info.size - info.transfered) / (info.tfRate * 1024.0);
if (it->download)
{
addItem(symbol, name, coreId, fileSize, progress,
dlspeed, sources, status, completed, remaining);
addItem(symbol, name, coreId, fileSize, progress,
dlspeed, sources, status, completed, remaining);
/* if found in selectedIds -> select again */
if (selectedIds.end() != std::find(selectedIds.begin(), selectedIds.end(), it->hash))
{
selection->select(DLListModel->index(dlCount, 0),
QItemSelectionModel::Rows | QItemSelectionModel::SelectCurrent);
}
dlCount++;
}
else
/* if found in selectedIds -> select again */
if (selectedIds.end() != std::find(selectedIds.begin(), selectedIds.end(), info.hash))
{
addUploadItem(symbol, name, coreId, fileSize, progress,
dlspeed, sources, status, completed, remaining);
ulCount++;
selection->select(DLListModel->index(dlCount, 0),
QItemSelectionModel::Rows | QItemSelectionModel::SelectCurrent);
}
dlCount++;
}
rsiface->unlockData(); /* UnLock Interface */
for(it = upHashes.begin(); it != upHashes.end(); it++)
{
FileInfo info;
if (!rsFiles->FileDetails(*it, 0, info))
{
continue;
}
symbol = "";
coreId = QString::fromStdString(info.hash);
name = QString::fromStdString(info.fname);
sources = QString::fromStdString(info.source);
switch(info.downloadStatus)
{
/******** XXX HAND CODED!
#define FT_STATE_FAILED 0
#define FT_STATE_OKAY 1
#define FT_STATE_WAITING 2
#define FT_STATE_DOWNLOADING 3
#define FT_STATE_COMPLETE 4
*******************/
case 0: /* FAILED */
status = "Failed";
break;
case 1: /* OKAY */
status = "Okay";
break;
case 2: /* WAITING */
status = "Waiting";
break;
case 3: /* DOWNLOADING */
status = "Downloading";
break;
case 4: /* COMPLETE */
default:
status = "Complete";
break;
}
dlspeed = info.tfRate * 1024.0;
fileSize = info.size;
completed = info.transfered;
progress = info.transfered * 100.0 / info.size;
remaining = (info.size - info.transfered) / (info.tfRate * 1024.0);
addUploadItem(symbol, name, coreId, fileSize, progress,
dlspeed, sources, status, completed, remaining);
ulCount++;
}
}
void TransfersDialog::cancel()
@ -468,17 +508,15 @@ void TransfersDialog::cancel()
* but otherwise, not exact filename .... BUG
*/
std::string name = (qname.trimmed()).toStdString();
// TODO
rsicontrol->FileCancel(name, id, 0); /* name, *hash*, size */
//std::cerr << "TranfersDialog::cancel(): " << name << ":" << id << ":" << 0 << std::endl;
rsFiles->FileCancel(id); /* hash */
}
}
}
void TransfersDialog::clearcompleted()
{
std::cerr << "TransfersDialog::clearcompleted()" << std::endl;
rsicontrol->FileClearCompleted();
std::cerr << "TransfersDialog::clearcompleted()" << std::endl;
rsFiles->FileClearCompleted();
}
double TransfersDialog::getProgress(int row, QStandardItemModel *model)