nextcloud-desktop/src/mirall/csyncthread.h

101 lines
2.6 KiB
C
Raw Normal View History

/*
* Copyright (C) by Duncan Mac-Vicar P. <duncan@kde.org>
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
2013-02-13 20:13:25 +04:00
#ifndef CSYNCTHREAD_H
#define CSYNCTHREAD_H
2012-03-01 19:11:56 +04:00
#include <stdint.h>
#include <QMutex>
#include <QThread>
#include <QString>
#include <QNetworkProxy>
2012-04-14 14:16:30 +04:00
#include <csync.h>
2013-01-15 23:41:52 +04:00
#include "mirall/syncfileitem.h"
class QProcess;
namespace Mirall {
class CSyncThread : public QObject
{
Q_OBJECT
// Keep the actions that have been performed, in order to update the db
struct Action {
QByteArray etag;
csync_instructions_e instruction;
};
QHash<QByteArray, Action> _performedActions;
public:
CSyncThread(CSYNC *, const QString &localPath, const QString &remotePath);
~CSyncThread();
QString csyncErrorToString(CSYNC_ERROR_CODE) const;
Q_INVOKABLE void startSync();
signals:
void fileReceived( const QString& );
2012-12-12 22:30:28 +04:00
void fileRemoved( const QString& );
void csyncError( const QString& );
void csyncWarning( const QString& );
void csyncUnavailable();
2013-01-15 23:41:52 +04:00
void treeWalkResult(const SyncFileItemVector&);
void csyncStateDbFile( const QString& );
void wipeDb();
void finished();
void started();
private:
void handleSyncError(CSYNC *ctx, const char *state);
static void progress(const char *remote_url,
enum csync_notify_type_e kind,
long long o1, long long o2,
void *userdata);
2013-01-15 23:41:52 +04:00
static int treewalkLocal( TREE_WALK_FILE*, void *);
static int treewalkRemote( TREE_WALK_FILE*, void *);
int treewalkFile( TREE_WALK_FILE*, bool );
2013-05-04 17:32:11 +04:00
int treewalkFinalize( TREE_WALK_FILE* );
2013-01-15 23:41:52 +04:00
static int walkFinalize(TREE_WALK_FILE*, void* );
static QMutex _mutex;
static QMutex _syncMutex;
2013-01-15 23:41:52 +04:00
SyncFileItemVector _syncedItems;
CSYNC *_csync_ctx;
bool _needsUpdate;
QString _localPath;
QString _remotePath;
// maps the origin and the target of the folders that have been renamed
QHash<QString, QString> _renamedFolders;
QString adjustRenamedPath(const QString &original);
friend class CSyncRunScopeHelper;
};
}
#endif // CSYNCTHREAD_H