2015-10-29 13:09:10 +03:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Roeland Jago Douma <rullzer@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
|
2016-10-25 12:00:07 +03:00
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
2015-10-29 13:09:10 +03:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2016-09-14 16:31:05 +03:00
|
|
|
#ifndef SHAREMANAGER_H
|
|
|
|
#define SHAREMANAGER_H
|
2015-10-29 13:09:10 +03:00
|
|
|
|
|
|
|
#include "accountfwd.h"
|
2015-11-05 00:00:35 +03:00
|
|
|
#include "sharee.h"
|
2016-03-30 12:33:34 +03:00
|
|
|
#include "sharepermissions.h"
|
2015-10-29 13:09:10 +03:00
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QDate>
|
|
|
|
#include <QString>
|
|
|
|
#include <QList>
|
|
|
|
#include <QSharedPointer>
|
|
|
|
#include <QUrl>
|
2017-04-26 12:38:10 +03:00
|
|
|
|
|
|
|
class QJsonDocument;
|
|
|
|
class QJsonObject;
|
2015-10-29 13:09:10 +03:00
|
|
|
|
|
|
|
namespace OCC {
|
|
|
|
|
2021-09-20 16:31:03 +03:00
|
|
|
class OcsShareJob;
|
|
|
|
|
2015-10-29 13:09:10 +03:00
|
|
|
class Share : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2022-07-25 19:57:18 +03:00
|
|
|
Q_PROPERTY(AccountPtr account READ account CONSTANT)
|
|
|
|
Q_PROPERTY(QString path READ path CONSTANT)
|
|
|
|
Q_PROPERTY(QString id READ getId CONSTANT)
|
|
|
|
Q_PROPERTY(QString uidOwner READ getUidOwner CONSTANT)
|
|
|
|
Q_PROPERTY(QString ownerDisplayName READ getOwnerDisplayName CONSTANT)
|
|
|
|
Q_PROPERTY(ShareType shareType READ getShareType CONSTANT)
|
|
|
|
Q_PROPERTY(ShareePtr shareWith READ getShareWith CONSTANT)
|
|
|
|
Q_PROPERTY(Permissions permissions READ getPermissions WRITE setPermissions NOTIFY permissionsSet)
|
|
|
|
Q_PROPERTY(bool isPasswordSet READ isPasswordSet NOTIFY passwordSet)
|
2015-10-29 13:09:10 +03:00
|
|
|
|
|
|
|
public:
|
2015-10-29 23:47:47 +03:00
|
|
|
/**
|
|
|
|
* Possible share types
|
2015-11-19 12:50:21 +03:00
|
|
|
* Need to be in sync with Sharee::Type
|
2015-10-29 23:47:47 +03:00
|
|
|
*/
|
|
|
|
enum ShareType {
|
2023-01-12 20:55:04 +03:00
|
|
|
TypeSecureFileDropPlaceholderLink = -3,
|
2022-11-04 21:30:22 +03:00
|
|
|
TypeInternalLink = -2,
|
2022-07-25 19:57:18 +03:00
|
|
|
TypePlaceholderLink = -1,
|
2015-11-19 12:50:21 +03:00
|
|
|
TypeUser = Sharee::User,
|
|
|
|
TypeGroup = Sharee::Group,
|
2015-10-29 23:47:47 +03:00
|
|
|
TypeLink = 3,
|
2020-12-04 14:01:04 +03:00
|
|
|
TypeEmail = Sharee::Email,
|
2020-03-05 12:44:06 +03:00
|
|
|
TypeRemote = Sharee::Federated,
|
2020-12-04 14:01:04 +03:00
|
|
|
TypeCircle = Sharee::Circle,
|
2022-07-25 19:57:18 +03:00
|
|
|
TypeRoom = Sharee::Room,
|
2015-10-29 23:47:47 +03:00
|
|
|
};
|
2022-07-25 19:57:18 +03:00
|
|
|
Q_ENUM(ShareType);
|
2015-10-29 23:47:47 +03:00
|
|
|
|
2020-08-12 16:23:11 +03:00
|
|
|
using Permissions = SharePermissions;
|
2015-10-29 23:47:47 +03:00
|
|
|
|
2015-10-29 13:09:10 +03:00
|
|
|
/*
|
2015-10-29 15:48:53 +03:00
|
|
|
* Constructor for shares
|
2015-10-29 13:09:10 +03:00
|
|
|
*/
|
|
|
|
explicit Share(AccountPtr account,
|
|
|
|
const QString &id,
|
2019-06-21 19:36:45 +03:00
|
|
|
const QString &owner,
|
|
|
|
const QString &ownerDisplayName,
|
2015-10-29 13:09:10 +03:00
|
|
|
const QString &path,
|
2015-10-31 15:39:08 +03:00
|
|
|
const ShareType shareType,
|
2021-04-20 17:36:42 +03:00
|
|
|
bool isPasswordSet = false,
|
2016-03-30 12:33:34 +03:00
|
|
|
const Permissions permissions = SharePermissionDefault,
|
2022-07-25 19:57:18 +03:00
|
|
|
const ShareePtr shareWith = ShareePtr(nullptr));
|
2015-10-29 13:09:10 +03:00
|
|
|
|
2015-12-08 14:58:56 +03:00
|
|
|
/**
|
|
|
|
* The account the share is defined on.
|
|
|
|
*/
|
2022-09-30 20:12:08 +03:00
|
|
|
[[nodiscard]] AccountPtr account() const;
|
2015-12-08 14:58:56 +03:00
|
|
|
|
2022-09-30 20:12:08 +03:00
|
|
|
[[nodiscard]] QString path() const;
|
2017-10-23 20:08:46 +03:00
|
|
|
|
2015-10-29 13:09:10 +03:00
|
|
|
/*
|
|
|
|
* Get the id
|
|
|
|
*/
|
2022-09-30 20:12:08 +03:00
|
|
|
[[nodiscard]] QString getId() const;
|
2015-10-29 13:09:10 +03:00
|
|
|
|
2019-06-21 19:36:45 +03:00
|
|
|
/*
|
|
|
|
* Get the uid_owner
|
|
|
|
*/
|
2022-09-30 20:12:08 +03:00
|
|
|
[[nodiscard]] QString getUidOwner() const;
|
2019-06-21 19:36:45 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the owner display name
|
|
|
|
*/
|
2022-09-30 20:12:08 +03:00
|
|
|
[[nodiscard]] QString getOwnerDisplayName() const;
|
2019-06-21 19:36:45 +03:00
|
|
|
|
2015-10-29 13:09:10 +03:00
|
|
|
/*
|
|
|
|
* Get the shareType
|
|
|
|
*/
|
2022-09-30 20:12:08 +03:00
|
|
|
[[nodiscard]] ShareType getShareType() const;
|
2015-10-29 13:09:10 +03:00
|
|
|
|
2015-10-31 15:39:08 +03:00
|
|
|
/*
|
|
|
|
* Get the shareWith
|
|
|
|
*/
|
2022-07-25 19:57:18 +03:00
|
|
|
[[nodiscard]] ShareePtr getShareWith() const;
|
2015-10-31 15:39:08 +03:00
|
|
|
|
2015-10-29 13:09:10 +03:00
|
|
|
/*
|
|
|
|
* Get permissions
|
|
|
|
*/
|
2022-09-30 20:12:08 +03:00
|
|
|
[[nodiscard]] Permissions getPermissions() const;
|
2015-10-29 13:09:10 +03:00
|
|
|
|
2022-10-01 02:16:52 +03:00
|
|
|
/*
|
|
|
|
* Get whether the share has a password set
|
|
|
|
*/
|
|
|
|
[[nodiscard]] Q_REQUIRED_RESULT bool isPasswordSet() const;
|
2022-07-25 19:57:18 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Is it a share with a user or group (local or remote)
|
|
|
|
*/
|
|
|
|
[[nodiscard]] static bool isShareTypeUserGroupEmailRoomOrRemote(const ShareType type);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void permissionsSet();
|
|
|
|
void shareDeleted();
|
|
|
|
void serverError(int code, const QString &message);
|
|
|
|
void passwordSet();
|
2023-04-19 21:28:07 +03:00
|
|
|
void hideDownloadSet();
|
2022-07-25 19:57:18 +03:00
|
|
|
void passwordSetError(int statusCode, const QString &message);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
/*
|
|
|
|
* Deletes a share
|
|
|
|
*
|
|
|
|
* On success the shareDeleted signal is emitted
|
|
|
|
* In case of a server error the serverError signal is emitted.
|
|
|
|
*/
|
|
|
|
void deleteShare();
|
|
|
|
|
2015-10-29 13:09:10 +03:00
|
|
|
/*
|
|
|
|
* Set the permissions of a share
|
|
|
|
*
|
|
|
|
* On success the permissionsSet signal is emitted
|
|
|
|
* In case of a server error the serverError signal is emitted.
|
|
|
|
*/
|
2022-10-24 17:00:50 +03:00
|
|
|
void setPermissions(OCC::Share::Permissions permissions);
|
2015-10-29 13:09:10 +03:00
|
|
|
|
2021-04-20 17:36:42 +03:00
|
|
|
/*
|
|
|
|
* Set the password for remote share
|
|
|
|
*
|
|
|
|
* On success the passwordSet signal is emitted
|
|
|
|
* In case of a server error the passwordSetError signal is emitted.
|
|
|
|
*/
|
|
|
|
void setPassword(const QString &password);
|
|
|
|
|
2015-10-29 13:09:10 +03:00
|
|
|
protected:
|
|
|
|
AccountPtr _account;
|
|
|
|
QString _id;
|
2019-06-21 19:36:45 +03:00
|
|
|
QString _uidowner;
|
|
|
|
QString _ownerDisplayName;
|
2015-10-29 13:09:10 +03:00
|
|
|
QString _path;
|
2015-10-29 23:47:47 +03:00
|
|
|
ShareType _shareType;
|
2021-04-20 17:36:42 +03:00
|
|
|
bool _isPasswordSet;
|
2015-10-29 23:47:47 +03:00
|
|
|
Permissions _permissions;
|
2022-07-25 19:57:18 +03:00
|
|
|
ShareePtr _shareWith;
|
2015-10-29 13:09:10 +03:00
|
|
|
|
2015-10-29 18:56:23 +03:00
|
|
|
protected slots:
|
|
|
|
void slotOcsError(int statusCode, const QString &message);
|
2021-04-20 17:36:42 +03:00
|
|
|
void slotPasswordSet(const QJsonDocument &, const QVariant &value);
|
|
|
|
void slotSetPasswordError(int statusCode, const QString &message);
|
2015-10-29 18:56:23 +03:00
|
|
|
|
2015-10-29 13:09:10 +03:00
|
|
|
private slots:
|
2015-10-29 18:56:23 +03:00
|
|
|
void slotDeleted();
|
2017-04-26 12:38:10 +03:00
|
|
|
void slotPermissionsSet(const QJsonDocument &, const QVariant &value);
|
2015-10-29 13:09:10 +03:00
|
|
|
};
|
|
|
|
|
2022-07-25 19:57:18 +03:00
|
|
|
using SharePtr = QSharedPointer<Share>;
|
|
|
|
|
2015-10-29 13:09:10 +03:00
|
|
|
/**
|
|
|
|
* A Link share is just like a regular share but then slightly different.
|
|
|
|
* There are several methods in the API that either work differently for
|
|
|
|
* link shares or are only available to link shares.
|
|
|
|
*/
|
|
|
|
class LinkShare : public Share
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2022-07-25 19:57:18 +03:00
|
|
|
Q_PROPERTY(QUrl link READ getLink CONSTANT)
|
|
|
|
Q_PROPERTY(QUrl directDownloadLink READ getDirectDownloadLink CONSTANT)
|
|
|
|
Q_PROPERTY(bool publicCanUpload READ getPublicUpload CONSTANT)
|
|
|
|
Q_PROPERTY(bool publicCanReadDirectory READ getShowFileListing CONSTANT)
|
|
|
|
Q_PROPERTY(QString name READ getName WRITE setName NOTIFY nameSet)
|
|
|
|
Q_PROPERTY(QString note READ getNote WRITE setNote NOTIFY noteSet)
|
|
|
|
Q_PROPERTY(QString label READ getLabel WRITE setLabel NOTIFY labelSet)
|
2023-04-19 21:28:07 +03:00
|
|
|
Q_PROPERTY(bool hideDownload READ getHideDownload WRITE setHideDownload NOTIFY hideDownloadSet)
|
2022-07-25 19:57:18 +03:00
|
|
|
Q_PROPERTY(QDate expireDate READ getExpireDate WRITE setExpireDate NOTIFY expireDateSet)
|
|
|
|
Q_PROPERTY(QString token READ getToken CONSTANT)
|
|
|
|
|
2015-10-29 13:09:10 +03:00
|
|
|
public:
|
|
|
|
explicit LinkShare(AccountPtr account,
|
|
|
|
const QString &id,
|
2019-06-21 19:36:45 +03:00
|
|
|
const QString &uidowner,
|
|
|
|
const QString &ownerDisplayName,
|
2015-10-29 13:09:10 +03:00
|
|
|
const QString &path,
|
2017-04-05 10:38:46 +03:00
|
|
|
const QString &name,
|
2017-04-12 12:09:20 +03:00
|
|
|
const QString &token,
|
2015-10-31 15:39:08 +03:00
|
|
|
const Permissions permissions,
|
2021-04-20 17:36:42 +03:00
|
|
|
bool isPasswordSet,
|
2015-10-29 13:09:10 +03:00
|
|
|
const QUrl &url,
|
2021-09-14 21:57:28 +03:00
|
|
|
const QDate &expireDate,
|
2021-09-14 15:10:44 +03:00
|
|
|
const QString ¬e,
|
2023-04-19 21:28:07 +03:00
|
|
|
const QString &label,
|
|
|
|
const bool hideDownload);
|
2015-10-29 13:09:10 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the share link
|
|
|
|
*/
|
2022-09-30 20:12:08 +03:00
|
|
|
[[nodiscard]] QUrl getLink() const;
|
2015-10-29 13:09:10 +03:00
|
|
|
|
2017-05-02 13:58:01 +03:00
|
|
|
/*
|
|
|
|
* The share's link for direct downloading.
|
|
|
|
*/
|
2022-09-30 20:12:08 +03:00
|
|
|
[[nodiscard]] QUrl getDirectDownloadLink() const;
|
2017-05-02 13:58:01 +03:00
|
|
|
|
2015-10-29 13:47:14 +03:00
|
|
|
/*
|
|
|
|
* Get the publicUpload status of this share
|
|
|
|
*/
|
2022-09-30 20:12:08 +03:00
|
|
|
[[nodiscard]] bool getPublicUpload() const;
|
2015-10-29 13:47:14 +03:00
|
|
|
|
2015-10-29 13:09:10 +03:00
|
|
|
/*
|
2017-06-15 16:38:22 +03:00
|
|
|
* Whether directory listings are available (READ permission)
|
2015-10-29 13:09:10 +03:00
|
|
|
*/
|
2022-09-30 20:12:08 +03:00
|
|
|
[[nodiscard]] bool getShowFileListing() const;
|
2016-09-14 16:31:05 +03:00
|
|
|
|
2017-04-05 10:38:46 +03:00
|
|
|
/*
|
2017-04-12 12:09:20 +03:00
|
|
|
* Returns the name of the link share. Can be empty.
|
2017-04-05 10:38:46 +03:00
|
|
|
*/
|
2022-09-30 20:12:08 +03:00
|
|
|
[[nodiscard]] QString getName() const;
|
2017-04-05 10:38:46 +03:00
|
|
|
|
2019-09-18 14:37:49 +03:00
|
|
|
/*
|
|
|
|
* Returns the note of the link share.
|
|
|
|
*/
|
2022-09-30 20:12:08 +03:00
|
|
|
[[nodiscard]] QString getNote() const;
|
2021-09-14 15:10:44 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Returns the label of the link share.
|
|
|
|
*/
|
2022-09-30 20:12:08 +03:00
|
|
|
[[nodiscard]] QString getLabel() const;
|
2019-09-18 14:37:49 +03:00
|
|
|
|
2023-04-19 21:28:07 +03:00
|
|
|
/*
|
|
|
|
* Returns if the link share's hideDownload is true or false
|
|
|
|
*/
|
|
|
|
[[nodiscard]] bool getHideDownload() const;
|
|
|
|
|
2022-07-25 19:57:18 +03:00
|
|
|
/*
|
|
|
|
* Returns the token of the link share.
|
|
|
|
*/
|
|
|
|
[[nodiscard]] QString getToken() const;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the expiration date
|
|
|
|
*/
|
|
|
|
[[nodiscard]] QDate getExpireDate() const;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create OcsShareJob and connect to signal/slots
|
|
|
|
*/
|
|
|
|
template <typename LinkShareSlot>
|
|
|
|
OcsShareJob *createShareJob(const LinkShareSlot slotFunction);
|
|
|
|
|
|
|
|
public slots:
|
2017-04-12 12:09:20 +03:00
|
|
|
/*
|
|
|
|
* Set the name of the link share.
|
|
|
|
*
|
|
|
|
* Emits either nameSet() or serverError().
|
|
|
|
*/
|
|
|
|
void setName(const QString &name);
|
|
|
|
|
2019-09-18 14:37:49 +03:00
|
|
|
/*
|
|
|
|
* Set the note of the link share.
|
|
|
|
*/
|
|
|
|
void setNote(const QString ¬e);
|
|
|
|
|
2015-10-29 13:09:10 +03:00
|
|
|
/*
|
|
|
|
* Set the expiration date
|
|
|
|
*
|
|
|
|
* On success the expireDateSet signal is emitted
|
|
|
|
* In case of a server error the serverError signal is emitted.
|
|
|
|
*/
|
|
|
|
void setExpireDate(const QDate &expireDate);
|
2022-07-25 19:57:18 +03:00
|
|
|
|
2021-09-14 15:10:44 +03:00
|
|
|
/*
|
|
|
|
* Set the label of the share link.
|
|
|
|
*/
|
|
|
|
void setLabel(const QString &label);
|
2023-04-19 21:28:07 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the hideDownload flag of the share link.
|
|
|
|
*/
|
|
|
|
void setHideDownload(const bool hideDownload);
|
2021-09-14 15:10:44 +03:00
|
|
|
|
2015-10-29 13:09:10 +03:00
|
|
|
signals:
|
|
|
|
void expireDateSet();
|
2019-09-18 14:37:49 +03:00
|
|
|
void noteSet();
|
2017-04-12 12:09:20 +03:00
|
|
|
void nameSet();
|
2021-09-14 15:10:44 +03:00
|
|
|
void labelSet();
|
2023-04-19 21:28:07 +03:00
|
|
|
void hideDownloadSet();
|
2015-10-29 13:09:10 +03:00
|
|
|
|
|
|
|
private slots:
|
2019-09-18 14:37:49 +03:00
|
|
|
void slotNoteSet(const QJsonDocument &, const QVariant &value);
|
2017-04-26 12:38:10 +03:00
|
|
|
void slotExpireDateSet(const QJsonDocument &reply, const QVariant &value);
|
|
|
|
void slotNameSet(const QJsonDocument &, const QVariant &value);
|
2021-09-14 15:10:44 +03:00
|
|
|
void slotLabelSet(const QJsonDocument &, const QVariant &value);
|
2023-04-19 21:28:07 +03:00
|
|
|
void slotHideDownloadSet(const QJsonDocument &jsonDoc, const QVariant &hideDownload);
|
2015-10-29 13:09:10 +03:00
|
|
|
|
|
|
|
private:
|
2017-04-05 10:38:46 +03:00
|
|
|
QString _name;
|
2017-04-12 12:09:20 +03:00
|
|
|
QString _token;
|
2019-09-18 14:37:49 +03:00
|
|
|
QString _note;
|
2015-10-29 13:09:10 +03:00
|
|
|
QDate _expireDate;
|
|
|
|
QUrl _url;
|
2021-09-14 15:10:44 +03:00
|
|
|
QString _label;
|
2023-04-19 21:28:07 +03:00
|
|
|
bool _hideDownload = false;
|
2015-10-29 13:09:10 +03:00
|
|
|
};
|
|
|
|
|
2021-04-14 17:36:16 +03:00
|
|
|
class UserGroupShare : public Share
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2022-07-25 19:57:18 +03:00
|
|
|
Q_PROPERTY(QString note READ getNote WRITE setNote NOTIFY noteSet)
|
|
|
|
Q_PROPERTY(QDate expireDate READ getExpireDate WRITE setExpireDate NOTIFY expireDateSet)
|
2021-04-14 17:36:16 +03:00
|
|
|
public:
|
|
|
|
UserGroupShare(AccountPtr account,
|
|
|
|
const QString &id,
|
|
|
|
const QString &owner,
|
|
|
|
const QString &ownerDisplayName,
|
|
|
|
const QString &path,
|
|
|
|
const ShareType shareType,
|
2021-04-20 17:36:42 +03:00
|
|
|
bool isPasswordSet,
|
2021-04-14 17:36:16 +03:00
|
|
|
const Permissions permissions,
|
2022-07-25 19:57:18 +03:00
|
|
|
const ShareePtr shareWith,
|
2021-04-15 16:47:10 +03:00
|
|
|
const QDate &expireDate,
|
|
|
|
const QString ¬e);
|
2021-04-14 17:36:16 +03:00
|
|
|
|
2022-09-30 20:12:08 +03:00
|
|
|
[[nodiscard]] QString getNote() const;
|
|
|
|
[[nodiscard]] QDate getExpireDate() const;
|
2021-04-15 14:06:53 +03:00
|
|
|
|
2022-07-25 19:57:18 +03:00
|
|
|
public slots:
|
|
|
|
void setNote(const QString ¬e);
|
|
|
|
void setExpireDate(const QDate &date);
|
2021-04-15 14:06:53 +03:00
|
|
|
|
2021-04-14 17:36:16 +03:00
|
|
|
signals:
|
|
|
|
void noteSet();
|
2021-04-16 19:16:34 +03:00
|
|
|
void noteSetError();
|
2021-04-15 14:06:53 +03:00
|
|
|
void expireDateSet();
|
2021-04-14 17:36:16 +03:00
|
|
|
|
2022-07-25 19:57:18 +03:00
|
|
|
private slots:
|
|
|
|
void slotNoteSet(const QJsonDocument &json, const QVariant ¬e);
|
|
|
|
void slotExpireDateSet(const QJsonDocument &reply, const QVariant &value);
|
|
|
|
|
2021-04-14 17:36:16 +03:00
|
|
|
private:
|
|
|
|
QString _note;
|
2021-04-15 14:06:53 +03:00
|
|
|
QDate _expireDate;
|
2021-04-14 17:36:16 +03:00
|
|
|
};
|
|
|
|
|
2015-10-29 13:09:10 +03:00
|
|
|
/**
|
|
|
|
* The share manager allows for creating, retrieving and deletion
|
|
|
|
* of shares. It abstracts away from the OCS Share API, all the usages
|
|
|
|
* shares should talk to this manager and not use OCS Share Job directly
|
|
|
|
*/
|
|
|
|
class ShareManager : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2018-11-11 12:56:22 +03:00
|
|
|
explicit ShareManager(AccountPtr _account, QObject *parent = nullptr);
|
2015-10-29 13:09:10 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tell the manager to create a link share
|
|
|
|
*
|
|
|
|
* @param path The path of the linkshare relative to the user folder on the server
|
2017-04-05 10:38:46 +03:00
|
|
|
* @param name The name of the created share, may be empty
|
|
|
|
* @param password The password of the share, may be empty
|
2015-10-29 13:09:10 +03:00
|
|
|
*
|
|
|
|
* On success the signal linkShareCreated is emitted
|
|
|
|
* For older server the linkShareRequiresPassword signal is emitted when it seems appropiate
|
|
|
|
* In case of a server error the serverError signal is emitted
|
|
|
|
*/
|
|
|
|
void createLinkShare(const QString &path,
|
2017-04-05 10:38:46 +03:00
|
|
|
const QString &name,
|
|
|
|
const QString &password);
|
2015-10-29 13:09:10 +03:00
|
|
|
|
2023-01-12 20:55:04 +03:00
|
|
|
void createSecureFileDropShare(const QString &path, const QString &name, const QString &password);
|
|
|
|
|
2015-10-31 15:39:08 +03:00
|
|
|
/**
|
|
|
|
* Tell the manager to create a new share
|
|
|
|
*
|
|
|
|
* @param path The path of the share relative to the user folder on the server
|
|
|
|
* @param shareType The type of share (TypeUser, TypeGroup, TypeRemote)
|
|
|
|
* @param Permissions The share permissions
|
|
|
|
*
|
|
|
|
* On success the signal shareCreated is emitted
|
|
|
|
* In case of a server error the serverError signal is emitted
|
|
|
|
*/
|
|
|
|
void createShare(const QString &path,
|
|
|
|
const Share::ShareType shareType,
|
|
|
|
const QString shareWith,
|
2021-04-20 17:36:42 +03:00
|
|
|
const Share::Permissions permissions,
|
|
|
|
const QString &password = "");
|
2015-10-31 15:39:08 +03:00
|
|
|
|
2015-10-29 13:09:10 +03:00
|
|
|
/**
|
|
|
|
* Fetch all the shares for path
|
|
|
|
*
|
|
|
|
* @param path The path to get the shares for relative to the users folder on the server
|
|
|
|
*
|
|
|
|
* On success the sharesFetched signal is emitted
|
|
|
|
* In case of a server error the serverError signal is emitted
|
|
|
|
*/
|
|
|
|
void fetchShares(const QString &path);
|
|
|
|
|
|
|
|
signals:
|
2022-10-24 17:00:50 +03:00
|
|
|
void shareCreated(const OCC::SharePtr &share);
|
|
|
|
void linkShareCreated(const QSharedPointer<OCC::LinkShare> &share);
|
|
|
|
void sharesFetched(const QList<OCC::SharePtr> &shares);
|
2015-10-29 13:09:10 +03:00
|
|
|
void serverError(int code, const QString &message);
|
|
|
|
|
2016-01-19 16:03:13 +03:00
|
|
|
/** Emitted when creating a link share with password fails.
|
|
|
|
*
|
|
|
|
* @param message the error message reported by the server
|
|
|
|
*
|
|
|
|
* See createLinkShare().
|
|
|
|
*/
|
|
|
|
void linkShareRequiresPassword(const QString &message);
|
|
|
|
|
2015-10-29 13:09:10 +03:00
|
|
|
private slots:
|
2017-04-26 12:38:10 +03:00
|
|
|
void slotSharesFetched(const QJsonDocument &reply);
|
|
|
|
void slotLinkShareCreated(const QJsonDocument &reply);
|
|
|
|
void slotShareCreated(const QJsonDocument &reply);
|
2015-10-29 18:56:23 +03:00
|
|
|
void slotOcsError(int statusCode, const QString &message);
|
2015-10-29 13:09:10 +03:00
|
|
|
private:
|
2017-04-26 12:38:10 +03:00
|
|
|
QSharedPointer<LinkShare> parseLinkShare(const QJsonObject &data);
|
2021-04-14 17:36:16 +03:00
|
|
|
QSharedPointer<UserGroupShare> parseUserGroupShare(const QJsonObject &data);
|
2022-07-25 19:57:18 +03:00
|
|
|
SharePtr parseShare(const QJsonObject &data) const;
|
2015-10-29 13:09:10 +03:00
|
|
|
|
|
|
|
AccountPtr _account;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-11-30 12:34:49 +03:00
|
|
|
Q_DECLARE_METATYPE(OCC::SharePtr)
|
2022-07-25 19:57:18 +03:00
|
|
|
|
2016-09-14 16:31:05 +03:00
|
|
|
#endif // SHAREMANAGER_H
|