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
|
|
|
#include "sharemanager.h"
|
2015-10-29 13:09:10 +03:00
|
|
|
#include "ocssharejob.h"
|
|
|
|
#include "account.h"
|
|
|
|
|
|
|
|
#include <QUrl>
|
|
|
|
|
2016-01-21 16:10:37 +03:00
|
|
|
namespace {
|
|
|
|
struct CreateShare
|
|
|
|
{
|
|
|
|
QString path;
|
|
|
|
OCC::Share::ShareType shareType;
|
|
|
|
QString shareWith;
|
|
|
|
OCC::Share::Permissions permissions;
|
|
|
|
};
|
|
|
|
} // anonymous namespace
|
|
|
|
Q_DECLARE_METATYPE(CreateShare)
|
|
|
|
|
2015-10-29 13:09:10 +03:00
|
|
|
namespace OCC {
|
|
|
|
|
2016-09-14 16:31:05 +03:00
|
|
|
Share::Share(AccountPtr account,
|
|
|
|
const QString& id,
|
|
|
|
const QString& path,
|
2015-10-31 15:39:08 +03:00
|
|
|
const ShareType shareType,
|
|
|
|
const Permissions permissions,
|
2015-11-05 00:00:35 +03:00
|
|
|
const QSharedPointer<Sharee> shareWith)
|
2015-10-29 16:27:49 +03:00
|
|
|
: _account(account),
|
2015-10-29 13:09:10 +03:00
|
|
|
_id(id),
|
|
|
|
_path(path),
|
|
|
|
_shareType(shareType),
|
2015-10-31 15:39:08 +03:00
|
|
|
_permissions(permissions),
|
|
|
|
_shareWith(shareWith)
|
2015-10-29 13:09:10 +03:00
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-12-08 14:58:56 +03:00
|
|
|
AccountPtr Share::account() const
|
|
|
|
{
|
|
|
|
return _account;
|
|
|
|
}
|
|
|
|
|
2015-10-29 15:48:53 +03:00
|
|
|
QString Share::getId() const
|
2015-10-29 13:09:10 +03:00
|
|
|
{
|
|
|
|
return _id;
|
|
|
|
}
|
|
|
|
|
2015-10-29 23:47:47 +03:00
|
|
|
Share::ShareType Share::getShareType() const
|
2015-10-29 13:09:10 +03:00
|
|
|
{
|
|
|
|
return _shareType;
|
|
|
|
}
|
|
|
|
|
2015-11-05 00:00:35 +03:00
|
|
|
QSharedPointer<Sharee> Share::getShareWith() const
|
|
|
|
{
|
|
|
|
return _shareWith;
|
|
|
|
}
|
|
|
|
|
2015-10-31 15:39:08 +03:00
|
|
|
void Share::setPermissions(Permissions permissions)
|
|
|
|
{
|
2015-11-11 15:28:20 +03:00
|
|
|
OcsShareJob *job = new OcsShareJob(_account);
|
2015-10-31 15:39:08 +03:00
|
|
|
connect(job, SIGNAL(shareJobFinished(QVariantMap, QVariant)), SLOT(slotPermissionsSet(QVariantMap, QVariant)));
|
|
|
|
connect(job, SIGNAL(ocsError(int, QString)), SLOT(slotOcsError(int, QString)));
|
|
|
|
job->setPermissions(getId(), permissions);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Share::slotPermissionsSet(const QVariantMap &, const QVariant &value)
|
|
|
|
{
|
|
|
|
_permissions = (Permissions)value.toInt();
|
|
|
|
emit permissionsSet();
|
|
|
|
}
|
|
|
|
|
2015-10-29 23:47:47 +03:00
|
|
|
Share::Permissions Share::getPermissions() const
|
2015-10-29 13:09:10 +03:00
|
|
|
{
|
|
|
|
return _permissions;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Share::deleteShare()
|
|
|
|
{
|
2015-11-11 15:28:20 +03:00
|
|
|
OcsShareJob *job = new OcsShareJob(_account);
|
2015-10-29 18:56:23 +03:00
|
|
|
connect(job, SIGNAL(shareJobFinished(QVariantMap, QVariant)), SLOT(slotDeleted()));
|
|
|
|
connect(job, SIGNAL(ocsError(int, const QString &)), SLOT(slotOcsError(int, const QString &)));
|
2015-10-29 13:09:10 +03:00
|
|
|
job->deleteShare(getId());
|
|
|
|
}
|
|
|
|
|
2015-10-29 18:56:23 +03:00
|
|
|
void Share::slotDeleted()
|
2015-10-29 13:09:10 +03:00
|
|
|
{
|
|
|
|
emit shareDeleted();
|
|
|
|
}
|
|
|
|
|
2015-10-29 18:56:23 +03:00
|
|
|
void Share::slotOcsError(int statusCode, const QString &message)
|
|
|
|
{
|
2016-09-14 16:31:05 +03:00
|
|
|
emit serverError(statusCode, message);
|
2015-10-29 18:56:23 +03:00
|
|
|
}
|
|
|
|
|
2015-10-29 15:48:53 +03:00
|
|
|
QUrl LinkShare::getLink() const
|
2015-10-29 13:09:10 +03:00
|
|
|
{
|
|
|
|
return _url;
|
|
|
|
}
|
|
|
|
|
2015-10-29 15:48:53 +03:00
|
|
|
QDate LinkShare::getExpireDate() const
|
2015-10-29 13:09:10 +03:00
|
|
|
{
|
|
|
|
return _expireDate;
|
|
|
|
}
|
|
|
|
|
2015-10-29 15:48:53 +03:00
|
|
|
bool LinkShare::isPasswordSet() const
|
2015-10-29 13:09:10 +03:00
|
|
|
{
|
|
|
|
return _passwordSet;
|
|
|
|
}
|
|
|
|
|
|
|
|
LinkShare::LinkShare(AccountPtr account,
|
|
|
|
const QString& id,
|
|
|
|
const QString& path,
|
2017-04-12 12:09:20 +03:00
|
|
|
const QString& name,
|
|
|
|
const QString& token,
|
2015-10-29 23:47:47 +03:00
|
|
|
Permissions permissions,
|
2015-10-29 13:09:10 +03:00
|
|
|
bool passwordSet,
|
|
|
|
const QUrl& url,
|
2015-10-29 16:27:49 +03:00
|
|
|
const QDate& expireDate)
|
2015-10-29 23:47:47 +03:00
|
|
|
: Share(account, id, path, Share::TypeLink, permissions),
|
2017-04-05 10:38:46 +03:00
|
|
|
_name(name),
|
2017-04-12 12:09:20 +03:00
|
|
|
_token(token),
|
2015-10-29 13:09:10 +03:00
|
|
|
_passwordSet(passwordSet),
|
|
|
|
_expireDate(expireDate),
|
|
|
|
_url(url)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-10-29 13:47:14 +03:00
|
|
|
bool LinkShare::getPublicUpload()
|
|
|
|
{
|
2016-03-30 12:33:34 +03:00
|
|
|
return ((_permissions & SharePermissionUpdate) &&
|
|
|
|
(_permissions & SharePermissionCreate));
|
2015-10-29 13:47:14 +03:00
|
|
|
}
|
|
|
|
|
2015-10-29 13:09:10 +03:00
|
|
|
void LinkShare::setPublicUpload(bool publicUpload)
|
|
|
|
{
|
2015-11-11 15:28:20 +03:00
|
|
|
OcsShareJob *job = new OcsShareJob(_account);
|
2015-10-29 18:56:23 +03:00
|
|
|
connect(job, SIGNAL(shareJobFinished(QVariantMap, QVariant)), SLOT(slotPublicUploadSet(QVariantMap, QVariant)));
|
|
|
|
connect(job, SIGNAL(ocsError(int, QString)), SLOT(slotOcsError(int, QString)));
|
2015-10-29 13:09:10 +03:00
|
|
|
job->setPublicUpload(getId(), publicUpload);
|
|
|
|
}
|
|
|
|
|
2017-04-05 10:38:46 +03:00
|
|
|
QString LinkShare::getName() const
|
|
|
|
{
|
|
|
|
return _name;
|
|
|
|
}
|
|
|
|
|
2017-04-12 12:09:20 +03:00
|
|
|
void LinkShare::setName(const QString& name)
|
|
|
|
{
|
|
|
|
OcsShareJob *job = new OcsShareJob(_account);
|
|
|
|
connect(job, SIGNAL(shareJobFinished(QVariantMap,QVariant)), SLOT(slotNameSet(QVariantMap,QVariant)));
|
|
|
|
connect(job, SIGNAL(ocsError(int,QString)), SLOT(slotOcsError(int,QString)));
|
|
|
|
job->setName(getId(), name);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString LinkShare::getToken() const
|
|
|
|
{
|
|
|
|
return _token;
|
|
|
|
}
|
|
|
|
|
2015-10-29 18:56:23 +03:00
|
|
|
void LinkShare::slotPublicUploadSet(const QVariantMap&, const QVariant &value)
|
2015-10-29 13:09:10 +03:00
|
|
|
{
|
|
|
|
if (value.toBool()) {
|
2016-03-30 12:33:34 +03:00
|
|
|
_permissions = SharePermissionRead | SharePermissionUpdate | SharePermissionCreate;
|
2015-10-29 13:09:10 +03:00
|
|
|
} else {
|
2016-03-30 12:33:34 +03:00
|
|
|
_permissions = SharePermissionRead;
|
2015-10-29 13:09:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
emit publicUploadSet();
|
|
|
|
}
|
|
|
|
|
|
|
|
void LinkShare::setPassword(const QString &password)
|
|
|
|
{
|
2015-11-11 15:28:20 +03:00
|
|
|
OcsShareJob *job = new OcsShareJob(_account);
|
2015-10-29 18:56:23 +03:00
|
|
|
connect(job, SIGNAL(shareJobFinished(QVariantMap, QVariant)), SLOT(slotPasswordSet(QVariantMap, QVariant)));
|
2016-01-22 13:56:05 +03:00
|
|
|
connect(job, SIGNAL(ocsError(int, QString)), SLOT(slotSetPasswordError(int,QString)));
|
2015-10-29 13:09:10 +03:00
|
|
|
job->setPassword(getId(), password);
|
|
|
|
}
|
|
|
|
|
2015-10-29 18:56:23 +03:00
|
|
|
void LinkShare::slotPasswordSet(const QVariantMap&, const QVariant &value)
|
2015-10-29 13:09:10 +03:00
|
|
|
{
|
|
|
|
_passwordSet = value.toString() == "";
|
|
|
|
emit passwordSet();
|
|
|
|
}
|
|
|
|
|
|
|
|
void LinkShare::setExpireDate(const QDate &date)
|
|
|
|
{
|
2015-11-11 15:28:20 +03:00
|
|
|
OcsShareJob *job = new OcsShareJob(_account);
|
2015-10-29 18:56:23 +03:00
|
|
|
connect(job, SIGNAL(shareJobFinished(QVariantMap, QVariant)), SLOT(slotExpireDateSet(QVariantMap, QVariant)));
|
|
|
|
connect(job, SIGNAL(ocsError(int, QString)), SLOT(slotOcsError(int, QString)));
|
2015-10-29 13:09:10 +03:00
|
|
|
job->setExpireDate(getId(), date);
|
|
|
|
}
|
|
|
|
|
2016-04-19 12:22:32 +03:00
|
|
|
void LinkShare::slotExpireDateSet(const QVariantMap& reply, const QVariant &value)
|
2015-10-29 13:09:10 +03:00
|
|
|
{
|
2016-04-19 12:22:32 +03:00
|
|
|
auto data = reply.value("ocs").toMap().value("data").toMap();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the reply provides a data back (more REST style)
|
|
|
|
* they use this date.
|
|
|
|
*/
|
|
|
|
if (data.value("expiration").isValid()) {
|
|
|
|
_expireDate = QDate::fromString(data.value("expiration").toString(), "yyyy-MM-dd 00:00:00");
|
|
|
|
} else {
|
|
|
|
_expireDate = value.toDate();
|
|
|
|
}
|
2015-10-29 13:09:10 +03:00
|
|
|
emit expireDateSet();
|
|
|
|
}
|
|
|
|
|
2016-01-22 13:56:05 +03:00
|
|
|
void LinkShare::slotSetPasswordError(int statusCode, const QString &message)
|
|
|
|
{
|
|
|
|
emit passwordSetError(statusCode, message);
|
|
|
|
}
|
|
|
|
|
2017-04-12 12:09:20 +03:00
|
|
|
void LinkShare::slotNameSet(const QVariantMap &, const QVariant &value)
|
|
|
|
{
|
|
|
|
_name = value.toString();
|
|
|
|
emit nameSet();
|
|
|
|
}
|
|
|
|
|
2015-10-29 13:09:10 +03:00
|
|
|
ShareManager::ShareManager(AccountPtr account, QObject *parent)
|
|
|
|
: QObject(parent),
|
|
|
|
_account(account)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShareManager::createLinkShare(const QString &path,
|
2017-04-05 10:38:46 +03:00
|
|
|
const QString &name,
|
2015-10-29 13:09:10 +03:00
|
|
|
const QString &password)
|
|
|
|
{
|
2015-11-11 15:28:20 +03:00
|
|
|
OcsShareJob *job = new OcsShareJob(_account);
|
2015-10-29 18:56:23 +03:00
|
|
|
connect(job, SIGNAL(shareJobFinished(QVariantMap, QVariant)), SLOT(slotLinkShareCreated(QVariantMap)));
|
|
|
|
connect(job, SIGNAL(ocsError(int, QString)), SLOT(slotOcsError(int, QString)));
|
2017-04-05 10:38:46 +03:00
|
|
|
job->createLinkShare(path, name, password);
|
2015-10-29 13:09:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ShareManager::slotLinkShareCreated(const QVariantMap &reply)
|
|
|
|
{
|
|
|
|
QString message;
|
|
|
|
int code = OcsShareJob::getJsonReturnCode(reply, message);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Before we had decent sharing capabilities on the server a 403 "generally"
|
2015-10-29 15:39:29 +03:00
|
|
|
* meant that a share was password protected
|
2015-10-29 13:09:10 +03:00
|
|
|
*/
|
|
|
|
if (code == 403) {
|
2016-01-19 16:03:13 +03:00
|
|
|
emit linkShareRequiresPassword(message);
|
2015-10-29 15:31:36 +03:00
|
|
|
return;
|
2016-09-14 16:31:05 +03:00
|
|
|
}
|
2015-10-29 13:09:10 +03:00
|
|
|
|
|
|
|
//Parse share
|
|
|
|
auto data = reply.value("ocs").toMap().value("data").toMap();
|
|
|
|
QSharedPointer<LinkShare> share(parseLinkShare(data));
|
|
|
|
|
|
|
|
emit linkShareCreated(share);
|
|
|
|
}
|
|
|
|
|
2016-01-21 16:10:37 +03:00
|
|
|
|
2015-10-31 15:39:08 +03:00
|
|
|
void ShareManager::createShare(const QString& path,
|
|
|
|
const Share::ShareType shareType,
|
|
|
|
const QString shareWith,
|
|
|
|
const Share::Permissions permissions)
|
|
|
|
{
|
2016-01-21 16:10:37 +03:00
|
|
|
auto job = new OcsShareJob(_account);
|
|
|
|
|
|
|
|
// Store values that we need for creating this share later.
|
|
|
|
CreateShare continuation;
|
|
|
|
continuation.path = path;
|
|
|
|
continuation.shareType = shareType;
|
|
|
|
continuation.shareWith = shareWith;
|
|
|
|
continuation.permissions = permissions;
|
|
|
|
_jobContinuation[job] = QVariant::fromValue(continuation);
|
|
|
|
|
|
|
|
connect(job, SIGNAL(shareJobFinished(QVariantMap,QVariant)), SLOT(slotCreateShare(QVariantMap)));
|
|
|
|
connect(job, SIGNAL(ocsError(int,QString)), SLOT(slotOcsError(int,QString)));
|
|
|
|
job->getSharedWithMe();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShareManager::slotCreateShare(const QVariantMap &reply)
|
|
|
|
{
|
|
|
|
if (!_jobContinuation.contains(sender()))
|
|
|
|
return;
|
|
|
|
|
|
|
|
CreateShare cont = _jobContinuation[sender()].value<CreateShare>();
|
|
|
|
if (cont.path.isEmpty())
|
|
|
|
return;
|
|
|
|
_jobContinuation.remove(sender());
|
|
|
|
|
|
|
|
// Find existing share permissions (if this was shared with us)
|
2016-03-30 12:33:34 +03:00
|
|
|
Share::Permissions existingPermissions = SharePermissionDefault;
|
2016-01-21 16:10:37 +03:00
|
|
|
foreach (const QVariant & element, reply["ocs"].toMap()["data"].toList()) {
|
|
|
|
QVariantMap map = element.toMap();
|
|
|
|
if (map["file_target"] == cont.path)
|
|
|
|
existingPermissions = Share::Permissions(map["permissions"].toInt());
|
|
|
|
}
|
|
|
|
|
|
|
|
// Limit the permissions we request for a share to the ones the item
|
|
|
|
// was shared with initially.
|
2016-03-30 12:33:34 +03:00
|
|
|
if (cont.permissions == SharePermissionDefault) {
|
2016-01-21 16:10:37 +03:00
|
|
|
cont.permissions = existingPermissions;
|
2016-03-30 12:33:34 +03:00
|
|
|
} else if (existingPermissions != SharePermissionDefault) {
|
2016-01-21 16:10:37 +03:00
|
|
|
cont.permissions &= existingPermissions;
|
|
|
|
}
|
|
|
|
|
2015-11-11 15:28:20 +03:00
|
|
|
OcsShareJob *job = new OcsShareJob(_account);
|
2015-10-31 15:39:08 +03:00
|
|
|
connect(job, SIGNAL(shareJobFinished(QVariantMap, QVariant)), SLOT(slotShareCreated(QVariantMap)));
|
|
|
|
connect(job, SIGNAL(ocsError(int, QString)), SLOT(slotOcsError(int, QString)));
|
2016-01-21 16:10:37 +03:00
|
|
|
job->createShare(cont.path, cont.shareType, cont.shareWith, cont.permissions);
|
2015-10-31 15:39:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void ShareManager::slotShareCreated(const QVariantMap &reply)
|
|
|
|
{
|
|
|
|
//Parse share
|
|
|
|
auto data = reply.value("ocs").toMap().value("data").toMap();
|
|
|
|
QSharedPointer<Share> share(parseShare(data));
|
|
|
|
|
|
|
|
emit shareCreated(share);
|
|
|
|
}
|
|
|
|
|
2015-10-29 13:09:10 +03:00
|
|
|
void ShareManager::fetchShares(const QString &path)
|
|
|
|
{
|
2015-11-11 15:28:20 +03:00
|
|
|
OcsShareJob *job = new OcsShareJob(_account);
|
2015-10-29 18:56:23 +03:00
|
|
|
connect(job, SIGNAL(shareJobFinished(QVariantMap, QVariant)), SLOT(slotSharesFetched(QVariantMap)));
|
|
|
|
connect(job, SIGNAL(ocsError(int, QString)), SLOT(slotOcsError(int, QString)));
|
2015-10-29 13:09:10 +03:00
|
|
|
job->getShares(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShareManager::slotSharesFetched(const QVariantMap &reply)
|
|
|
|
{
|
|
|
|
auto tmpShares = reply.value("ocs").toMap().value("data").toList();
|
|
|
|
const QString versionString = _account->serverVersion();
|
|
|
|
qDebug() << Q_FUNC_INFO << versionString << "Fetched" << tmpShares.count() << "shares";
|
|
|
|
|
|
|
|
QList<QSharedPointer<Share>> shares;
|
|
|
|
|
2015-10-29 16:00:28 +03:00
|
|
|
foreach(const auto &share, tmpShares) {
|
2015-10-29 13:09:10 +03:00
|
|
|
auto data = share.toMap();
|
|
|
|
|
|
|
|
auto shareType = data.value("share_type").toInt();
|
|
|
|
|
2015-10-29 16:27:49 +03:00
|
|
|
QSharedPointer<Share> newShare;
|
2015-10-29 13:09:10 +03:00
|
|
|
|
2015-10-29 23:47:47 +03:00
|
|
|
if (shareType == Share::TypeLink) {
|
2015-10-29 13:09:10 +03:00
|
|
|
newShare = parseLinkShare(data);
|
|
|
|
} else {
|
2015-10-31 15:39:08 +03:00
|
|
|
newShare = parseShare(data);
|
2015-10-29 13:09:10 +03:00
|
|
|
}
|
|
|
|
|
2016-09-14 16:31:05 +03:00
|
|
|
shares.append(QSharedPointer<Share>(newShare));
|
2015-10-29 13:09:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
qDebug() << Q_FUNC_INFO << "Sending " << shares.count() << "shares";
|
|
|
|
emit sharesFetched(shares);
|
|
|
|
}
|
|
|
|
|
2017-04-12 12:09:20 +03:00
|
|
|
QSharedPointer<LinkShare> ShareManager::parseLinkShare(const QVariantMap &data)
|
|
|
|
{
|
2015-10-29 13:09:10 +03:00
|
|
|
QUrl url;
|
|
|
|
|
|
|
|
// From ownCloud server 8.2 the url field is always set for public shares
|
|
|
|
if (data.contains("url")) {
|
|
|
|
url = QUrl(data.value("url").toString());
|
2017-03-14 17:57:57 +03:00
|
|
|
} else if (_account->serverVersionInt() >= Account::makeServerVersion(8, 0, 0)) {
|
2015-10-29 13:09:10 +03:00
|
|
|
// From ownCloud server version 8 on, a different share link scheme is used.
|
2017-02-23 16:54:17 +03:00
|
|
|
url = QUrl(Utility::concatUrlPath(_account->url(), QLatin1String("index.php/s/") + data.value("token").toString())).toString();
|
2015-10-29 13:09:10 +03:00
|
|
|
} else {
|
|
|
|
QList<QPair<QString, QString>> queryArgs;
|
|
|
|
queryArgs.append(qMakePair(QString("service"), QString("files")));
|
|
|
|
queryArgs.append(qMakePair(QString("t"), data.value("token").toString()));
|
2016-10-25 13:04:22 +03:00
|
|
|
url = QUrl(Utility::concatUrlPath(_account->url(), QLatin1String("public.php"), queryArgs).toString());
|
2015-10-29 13:09:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
QDate expireDate;
|
|
|
|
if (data.value("expiration").isValid()) {
|
|
|
|
expireDate = QDate::fromString(data.value("expiration").toString(), "yyyy-MM-dd 00:00:00");
|
|
|
|
}
|
|
|
|
|
2015-10-29 16:27:49 +03:00
|
|
|
return QSharedPointer<LinkShare>(new LinkShare(_account,
|
|
|
|
data.value("id").toString(),
|
|
|
|
data.value("path").toString(),
|
2017-04-12 12:09:20 +03:00
|
|
|
data.value("name").toString(),
|
|
|
|
data.value("token").toString(),
|
2015-10-29 23:47:47 +03:00
|
|
|
(Share::Permissions)data.value("permissions").toInt(),
|
2015-10-29 16:27:49 +03:00
|
|
|
data.value("share_with").isValid(),
|
|
|
|
url,
|
|
|
|
expireDate));
|
2015-10-29 13:09:10 +03:00
|
|
|
}
|
|
|
|
|
2015-11-05 00:00:35 +03:00
|
|
|
QSharedPointer<Share> ShareManager::parseShare(const QVariantMap &data)
|
|
|
|
{
|
|
|
|
QSharedPointer<Sharee> sharee(new Sharee(data.value("share_with").toString(),
|
|
|
|
data.value("share_with_displayname").toString(),
|
|
|
|
(Sharee::Type)data.value("share_type").toInt()));
|
2016-09-14 16:31:05 +03:00
|
|
|
|
2015-10-31 15:39:08 +03:00
|
|
|
return QSharedPointer<Share>(new Share(_account,
|
|
|
|
data.value("id").toString(),
|
|
|
|
data.value("path").toString(),
|
|
|
|
(Share::ShareType)data.value("share_type").toInt(),
|
|
|
|
(Share::Permissions)data.value("permissions").toInt(),
|
2015-11-05 00:00:35 +03:00
|
|
|
sharee));
|
2015-10-31 15:39:08 +03:00
|
|
|
}
|
|
|
|
|
2015-10-29 18:56:23 +03:00
|
|
|
void ShareManager::slotOcsError(int statusCode, const QString &message)
|
|
|
|
{
|
2016-01-21 16:10:37 +03:00
|
|
|
emit serverError(statusCode, message);
|
2015-10-29 18:56:23 +03:00
|
|
|
}
|
|
|
|
|
2015-10-29 13:09:10 +03:00
|
|
|
}
|