2015-09-07 14:50:01 +03:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Roeland Jago Douma <roeland@famdouma.nl>
|
|
|
|
*
|
|
|
|
* 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-09-07 14:50:01 +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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef OCSSHAREJOB_H
|
|
|
|
#define OCSSHAREJOB_H
|
|
|
|
|
|
|
|
#include "ocsjob.h"
|
2016-09-14 16:31:05 +03:00
|
|
|
#include "sharemanager.h"
|
2015-09-07 14:50:01 +03:00
|
|
|
#include <QVector>
|
|
|
|
#include <QList>
|
|
|
|
#include <QPair>
|
|
|
|
|
2018-04-06 18:13:29 +03:00
|
|
|
class QJsonDocument;
|
|
|
|
|
2015-09-07 14:50:01 +03:00
|
|
|
namespace OCC {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The OcsShareJob class
|
|
|
|
* @ingroup gui
|
2015-10-15 21:54:52 +03:00
|
|
|
*
|
2018-07-26 15:43:21 +03:00
|
|
|
* Handle talking to the OCS Share API.
|
2015-10-15 21:54:52 +03:00
|
|
|
* For creation, deletion and modification of shares.
|
2015-09-07 14:50:01 +03:00
|
|
|
*/
|
2015-10-15 21:54:52 +03:00
|
|
|
class OcsShareJob : public OcsJob
|
|
|
|
{
|
2015-09-07 14:50:01 +03:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Constructor for new shares or listing of shares
|
|
|
|
*/
|
2015-11-11 15:28:20 +03:00
|
|
|
explicit OcsShareJob(AccountPtr account);
|
2015-09-07 14:50:01 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get all the shares
|
|
|
|
*
|
|
|
|
* @param path Path to request shares for (default all shares)
|
|
|
|
*/
|
|
|
|
void getShares(const QString &path = "");
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete the current Share
|
|
|
|
*/
|
2015-10-29 13:09:10 +03:00
|
|
|
void deleteShare(const QString &shareId);
|
2015-09-07 14:50:01 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the expiration date of a share
|
|
|
|
*
|
|
|
|
* @param date The expire date, if this date is invalid the expire date
|
|
|
|
* will be removed
|
|
|
|
*/
|
2015-10-29 13:09:10 +03:00
|
|
|
void setExpireDate(const QString &shareId, const QDate &date);
|
2015-09-07 14:50:01 +03:00
|
|
|
|
2019-09-18 14:37:49 +03:00
|
|
|
/**
|
|
|
|
* Set note a share
|
|
|
|
*
|
|
|
|
* @param note The note to a share, if the note is empty the
|
|
|
|
* share will be removed
|
|
|
|
*/
|
|
|
|
void setNote(const QString &shareId, const QString ¬e);
|
|
|
|
|
2015-09-07 14:50:01 +03:00
|
|
|
/**
|
|
|
|
* Set the password of a share
|
|
|
|
*
|
|
|
|
* @param password The password of the share, if the password is empty the
|
|
|
|
* share will be removed
|
|
|
|
*/
|
2015-10-29 13:09:10 +03:00
|
|
|
void setPassword(const QString &shareId, const QString &password);
|
2015-09-07 14:50:01 +03:00
|
|
|
|
2015-10-15 21:34:56 +03:00
|
|
|
/**
|
2017-04-12 12:09:20 +03:00
|
|
|
* Set the share to be public upload
|
2018-07-26 15:43:21 +03:00
|
|
|
*
|
2015-10-15 21:34:56 +03:00
|
|
|
* @param publicUpload Set or remove public upload
|
|
|
|
*/
|
2015-10-29 13:09:10 +03:00
|
|
|
void setPublicUpload(const QString &shareId, bool publicUpload);
|
2015-10-15 21:34:56 +03:00
|
|
|
|
2017-04-12 12:09:20 +03:00
|
|
|
/**
|
|
|
|
* Change the name of a share
|
|
|
|
*/
|
|
|
|
void setName(const QString &shareId, const QString &name);
|
|
|
|
|
2015-10-31 15:39:08 +03:00
|
|
|
/**
|
|
|
|
* Set the permissions
|
|
|
|
*
|
|
|
|
* @param permissions
|
|
|
|
*/
|
|
|
|
void setPermissions(const QString &shareId,
|
|
|
|
const Share::Permissions permissions);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new link share
|
|
|
|
*
|
|
|
|
* @param path The path of the file/folder to share
|
|
|
|
* @param password Optionally a password for the share
|
|
|
|
*/
|
2018-07-26 15:43:21 +03:00
|
|
|
void createLinkShare(const QString &path, const QString &name,
|
2017-04-05 10:38:46 +03:00
|
|
|
const QString &password);
|
2015-10-31 15:39:08 +03:00
|
|
|
|
2015-09-07 14:50:01 +03:00
|
|
|
/**
|
|
|
|
* Create a new share
|
|
|
|
*
|
|
|
|
* @param path The path of the file/folder to share
|
|
|
|
* @param shareType The type of share (user/group/link/federated)
|
2015-10-31 15:39:08 +03:00
|
|
|
* @param shareWith The uid/gid/federated id to share with
|
|
|
|
* @param permissions The permissions the share will have
|
2015-09-07 14:50:01 +03:00
|
|
|
*/
|
2015-10-31 15:39:08 +03:00
|
|
|
void createShare(const QString &path,
|
|
|
|
const Share::ShareType shareType,
|
|
|
|
const QString &shareWith = "",
|
2016-03-30 12:33:34 +03:00
|
|
|
const Share::Permissions permissions = SharePermissionRead);
|
2015-10-29 13:09:10 +03:00
|
|
|
|
2016-01-21 16:10:37 +03:00
|
|
|
/**
|
|
|
|
* Returns information on the items shared with the current user.
|
|
|
|
*/
|
|
|
|
void getSharedWithMe();
|
|
|
|
|
2015-10-29 13:09:10 +03:00
|
|
|
signals:
|
|
|
|
/**
|
|
|
|
* Result of the OCS request
|
|
|
|
* The value parameter is only set if this was a put request.
|
|
|
|
* e.g. if we set the password to 'foo' the QVariant will hold a QString with 'foo'.
|
|
|
|
* This is needed so we can update the share objects properly
|
|
|
|
*
|
|
|
|
* @param reply The reply
|
2015-10-29 15:39:29 +03:00
|
|
|
* @param value To what did we set a variable (if we set any).
|
2015-10-29 13:09:10 +03:00
|
|
|
*/
|
2017-04-26 12:38:10 +03:00
|
|
|
void shareJobFinished(QJsonDocument reply, QVariant value);
|
2015-10-29 13:09:10 +03:00
|
|
|
|
|
|
|
private slots:
|
2017-04-26 12:38:10 +03:00
|
|
|
void jobDone(QJsonDocument reply);
|
2015-10-29 13:09:10 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
QVariant _value;
|
2015-09-07 14:50:01 +03:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // OCSSHAREJOB_H
|