Connect the SocketApi directly to the SyncFileStatusTracker

Don't go through the Folder->ProgressDispatcher->SocketApi route and
keep the path logic in SyncFileStatusTracker.
Esse commit está contido em:
Jocelyn Turcotte
2016-03-21 12:35:57 +01:00
commit ea5e6d367b
8 arquivos alterados com 42 adições e 58 exclusões
+2 -43
Ver Arquivo
@@ -114,10 +114,6 @@ SocketApi::SocketApi(QObject* parent)
// folder watcher
connect(FolderMan::instance(), SIGNAL(folderSyncStateChange(Folder*)), this, SLOT(slotUpdateFolderView(Folder*)));
connect(ProgressDispatcher::instance(), SIGNAL(itemCompleted(QString, const SyncFileItem &, const PropagatorJob &)),
SLOT(slotItemCompleted(QString, const SyncFileItem &)));
connect(ProgressDispatcher::instance(), SIGNAL(syncItemDiscovered(QString, const SyncFileItem &)),
this, SLOT(slotSyncItemDiscovered(QString, const SyncFileItem &)));
}
SocketApi::~SocketApi()
@@ -225,48 +221,11 @@ void SocketApi::slotUpdateFolderView(Folder *f)
}
}
void SocketApi::slotItemCompleted(const QString &folder, const SyncFileItem &item)
void SocketApi::slotFileStatusChanged(const QString& systemFileName, SyncFileStatus fileStatus)
{
if (_listeners.isEmpty()) {
return;
}
Folder *f = FolderMan::instance()->folder(folder);
if (!f) {
return;
}
auto status = f->syncEngine().syncFileStatusTracker().fileStatus(item.destination());
const QString path = f->path() + item.destination();
broadcastMessage(QLatin1String("STATUS"), path, status.toSocketAPIString());
broadcastMessage(QLatin1String("STATUS"), systemFileName, fileStatus.toSocketAPIString());
}
void SocketApi::slotSyncItemDiscovered(const QString &folder, const SyncFileItem &item)
{
if (_listeners.isEmpty()) {
return;
}
Folder *f = FolderMan::instance()->folder(folder);
if (!f) {
return;
}
QString path = f->path() + item.destination();
// the trailing slash for directories must be appended as the filenames coming in
// from the plugins have that too. Otherwise the matching entry item is not found
// in the plugin.
if( item._type == SyncFileItem::Type::Directory ) {
path += QLatin1Char('/');
}
const QString command = QLatin1String("SYNC");
broadcastMessage(QLatin1String("STATUS"), path, command);
}
void SocketApi::sendMessage(QIODevice *socket, const QString& message, bool doWait)
{
DEBUG << "Sending message: " << message;