[Pkg-owncloud-commits] [owncloud-client] 63/484: Add SHARE_STATUS socketAPI command
Sandro Knauß
hefee-guest at moszumanska.debian.org
Wed Dec 16 00:37:13 UTC 2015
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 028dc8d6c33f4b937dcc1ae3707d1ff36efb8375
Author: Roeland Jago Douma <rullzer at owncloud.com>
Date: Tue Oct 6 09:39:24 2015 +0200
Add SHARE_STATUS socketAPI command
This command allows to retrieve the share status of a file. In other
words if it can be shared.
---
src/gui/socketapi.cpp | 35 +++++++++++++++++++++++++++++++++++
src/gui/socketapi.h | 1 +
2 files changed, 36 insertions(+)
diff --git a/src/gui/socketapi.cpp b/src/gui/socketapi.cpp
index e145f81..5305d00 100644
--- a/src/gui/socketapi.cpp
+++ b/src/gui/socketapi.cpp
@@ -28,6 +28,8 @@
#include "version.h"
#include "account.h"
#include "accountstate.h"
+#include "account.h"
+#include "capabilities.h"
#include <QDebug>
#include <QUrl>
@@ -406,6 +408,39 @@ void SocketApi::command_VERSION(const QString&, QIODevice* socket)
sendMessage(socket, QLatin1String("VERSION:" MIRALL_VERSION_STRING ":" MIRALL_SOCKET_API_VERSION));
}
+void SocketApi::command_SHARE_STATUS(const QString &localFile, QIODevice *socket)
+{
+ if (!socket) {
+ qDebug() << Q_FUNC_INFO << "No valid socket object.";
+ return;
+ }
+
+ qDebug() << Q_FUNC_INFO << localFile;
+
+ Folder *shareFolder = FolderMan::instance()->folderForPath(localFile);
+
+ if (!shareFolder) {
+ const QString message = QLatin1String("SHARE_STATUS:NOP:")+QDir::toNativeSeparators(localFile);
+ sendMessage(socket, message);
+ } else {
+ const Capabilities capabilities = shareFolder->accountState()->account()->capabilities();
+
+ if (!capabilities.shareAPI()) {
+ const QString message = QLatin1String("SHARE_STATUS:DISABLED:")+QDir::toNativeSeparators(localFile);
+ sendMessage(socket, message);
+ } else {
+ QString available = "USER,GROUP";
+
+ if (capabilities.sharePublicLink()) {
+ available += ",LINK";
+ }
+
+ const QString message = QLatin1String("SHARE_STATUS:") + available + ":" + QDir::toNativeSeparators(localFile);
+ sendMessage(socket, message);
+ }
+ }
+}
+
void SocketApi::command_SHARE_MENU_TITLE(const QString &, QIODevice* socket)
{
sendMessage(socket, QLatin1String("SHARE_MENU_TITLE:") + tr("Share with %1", "parameter is ownCloud").arg(Theme::instance()->appNameGUI()));
diff --git a/src/gui/socketapi.h b/src/gui/socketapi.h
index 355e93a..238c342 100644
--- a/src/gui/socketapi.h
+++ b/src/gui/socketapi.h
@@ -77,6 +77,7 @@ private:
Q_INVOKABLE void command_VERSION(const QString& argument, QIODevice* socket);
+ Q_INVOKABLE void command_SHARE_STATUS(const QString& localFile, QIODevice *socket);
Q_INVOKABLE void command_SHARE_MENU_TITLE(const QString& argument, QIODevice* socket);
QString buildRegisterPathMessage(const QString& path);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list