2012-02-15 12:30:37 +04:00
|
|
|
/*
|
|
|
|
* 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>
|
|
|
|
|
2012-02-15 12:30:37 +04:00
|
|
|
#include <QMutex>
|
|
|
|
#include <QThread>
|
|
|
|
#include <QString>
|
2012-10-09 04:34:22 +04:00
|
|
|
#include <QNetworkProxy>
|
2013-07-17 18:27:18 +04:00
|
|
|
#include <QNetworkCookie>
|
2012-02-15 12:30:37 +04:00
|
|
|
|
2012-04-14 14:16:30 +04:00
|
|
|
#include <csync.h>
|
2012-03-21 21:03:49 +04:00
|
|
|
|
2013-01-15 23:41:52 +04:00
|
|
|
#include "mirall/syncfileitem.h"
|
2013-07-05 20:46:43 +04:00
|
|
|
#include "mirall/progressdispatcher.h"
|
2013-01-15 23:41:52 +04:00
|
|
|
|
2012-02-15 12:30:37 +04:00
|
|
|
class QProcess;
|
|
|
|
|
|
|
|
namespace Mirall {
|
|
|
|
|
2012-08-26 13:47:45 +04:00
|
|
|
class CSyncThread : public QObject
|
2012-02-15 12:30:37 +04:00
|
|
|
{
|
2012-03-21 21:03:49 +04:00
|
|
|
Q_OBJECT
|
2012-02-15 12:30:37 +04:00
|
|
|
public:
|
2013-04-20 14:15:27 +04:00
|
|
|
CSyncThread(CSYNC *);
|
2012-02-15 12:30:37 +04:00
|
|
|
~CSyncThread();
|
|
|
|
|
2013-06-19 20:17:32 +04:00
|
|
|
static QString csyncErrorToString( CSYNC_ERROR_CODE, const char * );
|
2012-12-06 22:05:03 +04:00
|
|
|
|
2012-08-26 13:47:45 +04:00
|
|
|
Q_INVOKABLE void startSync();
|
|
|
|
|
2013-07-17 18:27:18 +04:00
|
|
|
void setLastAuthCookies(QList<QNetworkCookie> c);
|
|
|
|
|
2012-03-21 21:03:49 +04:00
|
|
|
signals:
|
2012-12-11 15:49:48 +04:00
|
|
|
void fileReceived( const QString& );
|
2012-12-12 22:30:28 +04:00
|
|
|
void fileRemoved( const QString& );
|
2012-06-11 12:10:07 +04:00
|
|
|
void csyncError( const QString& );
|
2012-12-19 21:05:58 +04:00
|
|
|
void csyncWarning( const QString& );
|
2013-01-16 17:39:43 +04:00
|
|
|
void csyncUnavailable();
|
2013-01-15 23:41:52 +04:00
|
|
|
void treeWalkResult(const SyncFileItemVector&);
|
2012-06-11 12:10:07 +04:00
|
|
|
|
2013-07-25 18:28:36 +04:00
|
|
|
void transmissionProgress( Progress::Info progress );
|
2013-07-24 16:38:58 +04:00
|
|
|
void fileTransmissionProgress( Progress::Kind, const QString&, qint64, qint64);
|
|
|
|
void overallTransmissionProgress( const QString& file, int file_no, int file_cnt, qint64 o1, qint64 o2 );
|
2012-06-11 12:10:07 +04:00
|
|
|
void csyncStateDbFile( const QString& );
|
2012-06-25 16:18:13 +04:00
|
|
|
void wipeDb();
|
2012-03-13 20:37:43 +04:00
|
|
|
|
2012-08-26 13:47:45 +04:00
|
|
|
void finished();
|
|
|
|
void started();
|
|
|
|
|
2013-06-10 17:57:23 +04:00
|
|
|
void aboutToRemoveAllFiles(SyncFileItem::Direction direction, bool *cancel);
|
2013-06-08 17:40:45 +04:00
|
|
|
|
2012-02-15 12:30:37 +04:00
|
|
|
private:
|
2013-02-15 22:29:27 +04:00
|
|
|
void handleSyncError(CSYNC *ctx, const char *state);
|
2013-07-19 15:05:30 +04:00
|
|
|
static void cb_file_progress(const char *remote_url,
|
|
|
|
enum csync_notify_type_e kind,
|
|
|
|
long long o1, long long o2,
|
|
|
|
void *userdata);
|
|
|
|
static void cb_overall_progress(const char *file_name, int file_no,
|
|
|
|
int file_cnt, long long o1, long long o2, void *userdata);
|
2013-07-25 18:28:36 +04:00
|
|
|
static void cb_progress( CSYNC_PROGRESS *progress, 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 );
|
|
|
|
int treewalkError( TREE_WALK_FILE* );
|
|
|
|
|
|
|
|
static int walkFinalize(TREE_WALK_FILE*, void* );
|
|
|
|
|
2013-04-20 14:15:27 +04:00
|
|
|
|
2012-03-13 20:37:43 +04:00
|
|
|
|
2012-02-15 12:30:37 +04:00
|
|
|
static QMutex _mutex;
|
2013-04-15 17:55:54 +04:00
|
|
|
static QMutex _syncMutex;
|
2013-01-15 23:41:52 +04:00
|
|
|
SyncFileItemVector _syncedItems;
|
|
|
|
|
2013-04-20 14:15:27 +04:00
|
|
|
CSYNC *_csync_ctx;
|
2013-02-14 19:25:00 +04:00
|
|
|
bool _needsUpdate;
|
2013-02-15 22:29:27 +04:00
|
|
|
|
2013-06-08 17:40:45 +04:00
|
|
|
bool _hasFiles; // true if there is at least one file that is not ignored or removed
|
|
|
|
|
2013-07-17 18:27:18 +04:00
|
|
|
QList<QNetworkCookie> _lastAuthCookies;
|
|
|
|
|
2013-02-15 22:29:27 +04:00
|
|
|
friend class CSyncRunScopeHelper;
|
2012-02-15 12:30:37 +04:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // CSYNCTHREAD_H
|