WebDAV

The WebDAV classes are implementing the abstract job classes to allow accessing WebDAV servers. As all of these classes require - besides the minimal SynqClient::AbstractJob interface - also common shared properties, a new interface SynqClient::AbstractWebDAVJob is introduced which adds all of the shared, WebDAV-specific attributes to the WebDAV job classes.

General Notes

The WebDAV job classes map like this to the library:

Warnings

Please consider the following hints when working with the WebDAV jobs:

  • When uploading to the same file in quick succession, all of the upload jobs might return the same etag/sync attribute. Hence, if you rely on proper sync attributes, make sure you add a small pause between uploads to the same file. Usually, a second should be sufficient. When using the SynqClient::DirectorySynchronizer, this usually shouldn’t be an issue (most real world use cases will have a data base which takes some time to process and hence you anyway have some delay in between uploads). However, keep this in mind in case you use the functionality e.g. in artificial environments (namely, unit testing).

  • Deleting folders conditionally does not work. If you delete a remote folder, make sure you don’t set a sync attribute.

AbstractWebDAVJob

class AbstractWebDAVJob

Shared interface of all WebDAV related jobs.

This class defines a common interface for all of the WebDAV jobs. For example, as all jobs require a QNetWorkAccessManager, it is specified as a property in this class.

Generic WebDAV Access vs Specific Servers

By default, WebDAV jobs will assume the WebDAV server (which is specified by the url()) to be a generic, standards-compliant WebDAV server. This is indicated by the serverType() attribute.

On top, there is support for some specific WebDAV server implementations. This support can be enabled by setting the serverType() to the concrete backend implementation. This might affect the interpretation of certain attributes of the jobs. Refer to the WebDAVServerType enumeration to learn about supported backends and how they affect the job behaviour.

Subclassed by SynqClient::WebDAVCreateDirectoryJob, SynqClient::WebDAVDeleteJob, SynqClient::WebDAVDownloadFileJob, SynqClient::WebDAVGetFileInfoJob, SynqClient::WebDAVListFilesJob, SynqClient::WebDAVUploadFileJob

Public Functions

AbstractWebDAVJob()

Constructor.

~AbstractWebDAVJob()

Destructor.

QNetworkAccessManager *networkAccessManager() const

The network access manager used to run network requests.

void setNetworkAccessManager(QNetworkAccessManager *networkAccessManager)

Set the network request manager to be used by the job.

Note

The job does not take ownership of the object.

QUrl url() const

The base URL of the server.

This is the base URL of the WebDAV server to talk to. Concrete WebDAV jobs then specify paths to be relative to the base URL.

See also

serverType()

Note

The URL should contain the username and password to be used to authenticate against to the WebDAV server. If no login information is provided via the URL, you might have to listen for appropriate signals of the set networkAccessManager() to provide them instead.

void setUrl(const QUrl &url)

Set the base URL.

WebDAVServerType serverType() const

The type of WebDAV server we are talking to.

This can be used to specify which kind of WebDAV server we talk to.

void setServerType(WebDAVServerType serverType)

Set the type of WebDAV server we are talking to.

WebDAVWorkarounds workarounds() const

Workarounds required to work with the server.

This returns the workarounds needed to work with the server.

void setWorkarounds(WebDAVWorkarounds workarounds)

Set the workarounds needed for the server to run requests against.

QString userAgent() const

The user agent to be used when communicating with the WebDAV server.

void setUserAgent(const QString &userAgent)

Set the user agent to be used when talking to the WebDAV server.

Protected Functions

explicit AbstractWebDAVJob(AbstractWebDAVJobPrivate *d)

Constructor.

WebDAVGetFileInfoJob

class WebDAVGetFileInfoJob : public SynqClient::GetFileInfoJob, public SynqClient::AbstractWebDAVJob

Implementation of the GetFileInfoJob for WebDAV.

Public Functions

explicit WebDAVGetFileInfoJob(QObject *parent = nullptr)

Constructor.

~WebDAVGetFileInfoJob() override

Destructor..

virtual void start() override

Implementation of AbstractJob::start().

virtual void stop() override

Implementation of AbstractJob::stop().

Protected Functions

explicit WebDAVGetFileInfoJob(WebDAVGetFileInfoJobPrivate *d, QObject *parent = nullptr)

Constructor.

WebDAVListFilesJob

class WebDAVListFilesJob : public SynqClient::ListFilesJob, public SynqClient::AbstractWebDAVJob

Implementation of the ListFilesJob for WebDAV.

Public Functions

explicit WebDAVListFilesJob(QObject *parent = nullptr)

Constructor.

~WebDAVListFilesJob() override

Destructor.

virtual void start() override

Implementation of AbstractJob::start().

virtual void stop() override

Implementation of AbstractJob::stop().

Protected Functions

explicit WebDAVListFilesJob(WebDAVListFilesJobPrivate *d, QObject *parent = nullptr)

Constructor.

WebDAVCreateDirectoryJob

class WebDAVCreateDirectoryJob : public SynqClient::CreateDirectoryJob, public SynqClient::AbstractWebDAVJob

Implementation of the CreateDirectoryJob for WebDAV.

Public Functions

explicit WebDAVCreateDirectoryJob(QObject *parent = nullptr)

Constructor.

~WebDAVCreateDirectoryJob() override

Destructor.

virtual void start() override

Implementation of AbstractJob::start().

virtual void stop() override

Implementation of AbstractJob::stop().

Protected Functions

explicit WebDAVCreateDirectoryJob(WebDAVCreateDirectoryJobPrivate *d, QObject *parent = nullptr)

Constructor.

WebDAVUploadFileJob

class WebDAVUploadFileJob : public SynqClient::UploadFileJob, public SynqClient::AbstractWebDAVJob

Implementation of the UploadFileJob for WebDAV.

Public Functions

explicit WebDAVUploadFileJob(QObject *parent = nullptr)

Constructor.

~WebDAVUploadFileJob() override

Destructor.

virtual void start() override

Implementation of AbstractJob::start().

virtual void stop() override

Implementation of AbstractJob::stop().

Protected Functions

explicit WebDAVUploadFileJob(WebDAVUploadFileJobPrivate *d, QObject *parent = nullptr)

Constructor.

WebDAVDownloadFileJob

class WebDAVDownloadFileJob : public SynqClient::DownloadFileJob, public SynqClient::AbstractWebDAVJob

Implementation of the DownloadFileJob for WebDAV.

Public Functions

explicit WebDAVDownloadFileJob(QObject *parent = nullptr)

Constructor.

~WebDAVDownloadFileJob() override

Destructor.

virtual void start() override

Implementation of AbstractJob::start().

virtual void stop() override

Implementation of AbstractJob::stop().

Protected Functions

explicit WebDAVDownloadFileJob(WebDAVDownloadFileJobPrivate *d, QObject *parent = nullptr)

Constructor.

WebDAVDeleteJob

class WebDAVDeleteJob : public SynqClient::DeleteJob, public SynqClient::AbstractWebDAVJob

Implementation of the DeleteJob for WebDAV.

Public Functions

explicit WebDAVDeleteJob(QObject *parent = nullptr)

Constructor.

~WebDAVDeleteJob() override

Destructor.

virtual void start() override

Implementation of AbstractJob::start().

virtual void stop() override

Implementation of AbstractJob::stop().

Protected Functions

explicit WebDAVDeleteJob(WebDAVDeleteJobPrivate *d, QObject *parent = nullptr)

Constructor.

WebDAV Specific Types And Functions

WebDAVServerType

enum class SynqClient::WebDAVServerType : quint32

The type of WebDAV server to talk to.

It is used to finetune the behaviour depending on the concrete implementation of a WebDAV server we are talking to.

Values:

enumerator Generic

Do not assume any special server type.

Use this if you have an absolute path to the WebDAV server and want to talk to it “as-is”.

enumerator NextCloud

Assume we talk to a NextCloud instance.

When using this server type, the following changes apply compared to a generic server:

  • The URL (set via AbstractWebDAVJob::url()) should point to the NextCloud root folder, e.g. nextcloud.example.com/. Jobs will then automatically derive the path to the WebDAV backend (which would in this case be nextcloud.example.com/remote.php/webdav/.

enumerator OwnCloud

Assume we talk to an ownCloud instance.

When using this server type, the following changes apply compared to a generic server:

  • The URL (set via AbstractWebDAVJob::url()) should point to the ownCloud root folder, e.g. owncloud.example.com/. Jobs will then automatically derive the path to the WebDAV backend (which would in this case be owncloud.example.com/remote.php/webdav/.

WebDAVWorkaround

enum class SynqClient::WebDAVWorkaround : quint32

Workarounds required to use a specific WebDAV server.

The values in this type are used to identify issues that a particular WebDAV server has and where client code might try to workaround locally.

Values:

enumerator NoWorkarounds

No workarounds are required.

enumerator NoRecursiveFolderETags

The server does not recursively update ETags on changes.

Usually, ETags on folders should be updated if either the folder itself, an item within it or one (recursively) in a sub-folder changed. Some servers hwoever only report changes ETags for a folder, if a direct child of the folder changes. When running e.g. a sync, a possible workaround is to always follow sub-folders recursively, even if the server reports the same ETag as on the last sync.

enumerator InconsistentETagsUsingPROPFINDAndGET

ETags differ between GET and PROPFIND requests.

Usually, a server shall report the same ETag for a file, no matter if it has been downloaded via a GET request or if such information has been requested from the server via a PROPFIND request.

Some servers generate different ETags depending on which type of request is used. A possible workaround is that the client first issues a PROPFIND and then locally stores the ETag retrieved in that instead of the one from the GET request.

enumerator DerivePROPFINDETagsFromGETETagsForApache

Derive proper ETags on GET when using Apache servers.

Some Apache servers are configured in a way, such that they report insonsistent ETags depending if GET or PROPFIND is used.

On PROPFIND, such servers usually report an ETag of the form Y-ZZZZZ. On GET, the server returns an ETag of the form XXXX-Y-ZZZZ. As a workaround, the client can try to transform the GET ETag to the form returned by a PROPFIND.

enumerator BrokenIfMatch

The server rejects conditional requests even if the ETag matches.

Some servers report ETags but do not accept these same values in If-Match headers. In that case, guarded updates and deletes fail even though the client is working with the current remote version. A possible workaround is to omit If-Match headers for such servers.

WebDAVWorkarounds

typedef QFlags<WebDAVWorkaround> SynqClient::WebDAVWorkarounds

Workarounds needed to work with a particular WebDAV server.

This is a flags object which works with the values defined in the WebDAVWorkaround enum.