2012-02-15 12:30:37 +04:00
|
|
|
#ifndef CSYNCTHREAD_H
|
|
|
|
#define CSYNCTHREAD_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
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-04-14 14:16:30 +04:00
|
|
|
#include <csync.h>
|
2012-03-21 21:03:49 +04:00
|
|
|
|
2012-02-15 12:30:37 +04:00
|
|
|
class QProcess;
|
|
|
|
|
|
|
|
namespace Mirall {
|
|
|
|
|
2012-03-22 19:22:08 +04:00
|
|
|
enum walkErrorTypes {
|
|
|
|
WALK_ERROR_NONE = 0,
|
|
|
|
WALK_ERROR_WALK,
|
|
|
|
WALK_ERROR_INSTRUCTIONS,
|
|
|
|
WALK_ERROR_DIR_PERMS
|
|
|
|
};
|
|
|
|
|
2012-03-21 21:03:49 +04:00
|
|
|
struct walkStats_s {
|
2012-03-22 19:22:08 +04:00
|
|
|
const char *sourcePath;
|
|
|
|
int errorType;
|
|
|
|
|
2012-03-21 21:03:49 +04:00
|
|
|
ulong eval;
|
|
|
|
ulong removed;
|
|
|
|
ulong renamed;
|
|
|
|
ulong newFiles;
|
|
|
|
ulong conflicts;
|
|
|
|
ulong ignores;
|
|
|
|
ulong sync;
|
|
|
|
ulong error;
|
|
|
|
|
|
|
|
ulong seenFiles;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef walkStats_s WalkStats;
|
|
|
|
|
2012-02-15 12:30:37 +04:00
|
|
|
class CSyncThread : public QThread
|
|
|
|
{
|
2012-03-21 21:03:49 +04:00
|
|
|
Q_OBJECT
|
2012-02-15 12:30:37 +04:00
|
|
|
public:
|
2012-02-28 19:49:13 +04:00
|
|
|
CSyncThread(const QString &source, const QString &target, bool = false);
|
2012-02-15 12:30:37 +04:00
|
|
|
~CSyncThread();
|
|
|
|
|
|
|
|
virtual void run();
|
|
|
|
|
2012-03-13 20:37:43 +04:00
|
|
|
static void setUserPwd( const QString&, const QString& );
|
2012-03-21 21:03:49 +04:00
|
|
|
static int checkPermissions( TREE_WALK_FILE* file, void *data);
|
2012-04-30 10:56:56 +04:00
|
|
|
static QString csyncConfigDir();
|
2012-03-21 21:03:49 +04:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void treeWalkResult(WalkStats*);
|
2012-06-11 12:10:07 +04:00
|
|
|
void csyncError( const QString& );
|
|
|
|
|
|
|
|
void csyncStateDbFile( const QString& );
|
2012-06-25 16:18:13 +04:00
|
|
|
void wipeDb();
|
2012-03-13 20:37:43 +04:00
|
|
|
|
2012-02-15 12:30:37 +04:00
|
|
|
private:
|
2012-06-25 16:18:13 +04:00
|
|
|
void emitStateDb( CSYNC *csync );
|
|
|
|
|
2012-03-13 20:37:43 +04:00
|
|
|
static int getauth(const char *prompt,
|
|
|
|
char *buf,
|
|
|
|
size_t len,
|
|
|
|
int echo,
|
|
|
|
int verify,
|
|
|
|
void *userdata
|
2012-03-21 21:03:49 +04:00
|
|
|
);
|
2012-03-13 20:37:43 +04:00
|
|
|
|
2012-02-15 12:30:37 +04:00
|
|
|
static QMutex _mutex;
|
2012-03-22 19:22:08 +04:00
|
|
|
static QString _user;
|
|
|
|
static QString _passwd;
|
2012-04-30 10:56:56 +04:00
|
|
|
static QString _csyncConfigDir;
|
2012-03-22 19:22:08 +04:00
|
|
|
|
2012-02-15 12:30:37 +04:00
|
|
|
QString _source;
|
|
|
|
QString _target;
|
2012-03-21 21:03:49 +04:00
|
|
|
bool _localCheckOnly;
|
2012-02-15 12:30:37 +04:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // CSYNCTHREAD_H
|