2013-05-03 21:11:00 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Olivier Goffart <ogoffart@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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef OWNCLOUDPROPAGATOR_H
|
|
|
|
#define OWNCLOUDPROPAGATOR_H
|
|
|
|
|
2013-05-05 13:41:31 +04:00
|
|
|
#include <neon/ne_request.h>
|
2013-05-15 17:22:20 +04:00
|
|
|
#include <QHash>
|
2013-05-16 15:54:22 +04:00
|
|
|
#include <QObject>
|
2013-05-05 13:41:31 +04:00
|
|
|
|
2013-05-03 21:11:00 +04:00
|
|
|
#include "syncfileitem.h"
|
|
|
|
|
|
|
|
struct ne_session_s;
|
|
|
|
struct ne_decompress_s;
|
|
|
|
|
|
|
|
namespace Mirall {
|
|
|
|
|
2013-05-06 18:59:11 +04:00
|
|
|
class ProgressDatabase;
|
|
|
|
|
2013-05-16 15:54:22 +04:00
|
|
|
class OwncloudPropagator : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
2013-05-03 21:11:00 +04:00
|
|
|
QString _localDir; // absolute path to the local directory. ends with '/'
|
|
|
|
QString _remoteDir; // path to the root of the remote. ends with '/'
|
|
|
|
ne_session_s *_session;
|
2013-05-06 18:59:11 +04:00
|
|
|
ProgressDatabase *_progressDb;
|
2013-05-03 21:11:00 +04:00
|
|
|
|
2013-05-04 18:12:51 +04:00
|
|
|
bool check_neon_session();
|
2013-05-03 21:11:00 +04:00
|
|
|
|
|
|
|
|
|
|
|
csync_instructions_e localRemove(const SyncFileItem &);
|
|
|
|
csync_instructions_e localMkdir(const SyncFileItem &);
|
|
|
|
csync_instructions_e remoteRemove(const SyncFileItem &);
|
|
|
|
csync_instructions_e remoteMkdir(const SyncFileItem &);
|
2013-05-05 13:14:40 +04:00
|
|
|
csync_instructions_e downloadFile(const SyncFileItem &, bool isConflict = false);
|
2013-05-03 21:11:00 +04:00
|
|
|
csync_instructions_e uploadFile(const SyncFileItem &);
|
|
|
|
csync_instructions_e remoteRename(const SyncFileItem &);
|
|
|
|
|
2013-05-04 17:32:11 +04:00
|
|
|
void updateMTimeAndETag(const char *uri, time_t);
|
|
|
|
|
2013-05-03 21:11:00 +04:00
|
|
|
/* fetch the error code and string from the session */
|
2013-05-05 13:41:31 +04:00
|
|
|
bool updateErrorFromSession(int neon_code = 0, ne_request *req = NULL);
|
2013-05-03 21:11:00 +04:00
|
|
|
|
|
|
|
|
|
|
|
public:
|
2013-05-06 18:59:11 +04:00
|
|
|
OwncloudPropagator(ne_session_s *session, const QString &localDir, const QString &remoteDir,
|
|
|
|
ProgressDatabase *progressDb)
|
2013-05-03 21:11:00 +04:00
|
|
|
: _session(session)
|
|
|
|
, _localDir(localDir)
|
2013-05-06 18:59:11 +04:00
|
|
|
, _remoteDir(remoteDir)
|
2013-05-08 15:30:30 +04:00
|
|
|
, _progressDb(progressDb)
|
|
|
|
, _errorCode(CSYNC_ERR_NONE)
|
|
|
|
, _httpStatusCode(0)
|
|
|
|
, _hasFatalError(false)
|
|
|
|
{
|
2013-05-03 21:11:00 +04:00
|
|
|
if (!localDir.endsWith(QChar('/'))) _localDir+='/';
|
|
|
|
if (!remoteDir.endsWith(QChar('/'))) _remoteDir+='/';
|
|
|
|
}
|
2013-05-16 15:54:22 +04:00
|
|
|
void propagate(const SyncFileItem &);
|
2013-05-08 15:30:30 +04:00
|
|
|
QString _errorString;
|
2013-05-04 18:12:51 +04:00
|
|
|
CSYNC_ERROR_CODE _errorCode;
|
|
|
|
int _httpStatusCode;
|
2013-05-08 15:30:30 +04:00
|
|
|
bool _hasFatalError;
|
2013-05-04 19:14:25 +04:00
|
|
|
QByteArray _etag;
|
2013-05-16 15:54:22 +04:00
|
|
|
csync_instructions_e _instruction;
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void completed(const SyncFileItem &);
|
2013-05-03 21:11:00 +04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|