[Pkg-owncloud-commits] [owncloud-client] 85/484: Now only 1 constructor to ocssharejob

Sandro Knauß hefee-guest at moszumanska.debian.org
Wed Dec 16 00:37:18 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 40ab3ee751644262e496b0535770d25e49692cfa
Author: Roeland Jago Douma <rullzer at owncloud.com>
Date:   Fri Oct 16 08:28:13 2015 +0200

    Now only 1 constructor to ocssharejob
    
    * Pass the share_id to the functions that need it
---
 src/gui/ocsjob.cpp      |  5 +++++
 src/gui/ocsjob.h        |  8 ++++++++
 src/gui/ocssharejob.cpp | 18 ++++++++----------
 src/gui/ocssharejob.h   | 13 ++++---------
 src/gui/sharedialog.cpp | 18 +++++++++---------
 5 files changed, 34 insertions(+), 28 deletions(-)

diff --git a/src/gui/ocsjob.cpp b/src/gui/ocsjob.cpp
index 961e84f..9381908 100644
--- a/src/gui/ocsjob.cpp
+++ b/src/gui/ocsjob.cpp
@@ -42,6 +42,11 @@ void OcsJob::addPassStatusCode(int code)
     _passStatusCodes.append(code);
 }
 
+void OcsJob::appendPath(int id)
+{
+    setPath(path() + QString("/%1").arg(id));
+}
+
 void OcsJob::start()
 {
     QNetworkRequest req;
diff --git a/src/gui/ocsjob.h b/src/gui/ocsjob.h
index 36f2eb0..19bbdf0 100644
--- a/src/gui/ocsjob.h
+++ b/src/gui/ocsjob.h
@@ -73,6 +73,14 @@ protected:
      */
     void addPassStatusCode(int code);
 
+    /**
+     * The base path for an OcsJob is always the same. But it could be that case that
+     * certain operations need to append something to the URL.
+     *
+     * This functions appends the common id. so <PATH>/<ID>
+     */
+    void appendPath(int id);
+
 public:
     /**
      * Parse the response and return the status code and the message of the
diff --git a/src/gui/ocssharejob.cpp b/src/gui/ocssharejob.cpp
index feb5eaf..dea9b53 100644
--- a/src/gui/ocssharejob.cpp
+++ b/src/gui/ocssharejob.cpp
@@ -26,12 +26,6 @@ OcsShareJob::OcsShareJob(AccountPtr account, QObject* parent)
     setPath("ocs/v1.php/apps/files_sharing/api/v1/shares");
 }
 
-OcsShareJob::OcsShareJob(int shareId, AccountPtr account, QObject* parent)
-: OcsJob(account, parent)
-{
-    setPath(QString("ocs/v1.php/apps/files_sharing/api/v1/shares/%1").arg(shareId));
-}
-
 void OcsShareJob::getShares(const QString &path)
 {
     setVerb("GET");
@@ -42,15 +36,17 @@ void OcsShareJob::getShares(const QString &path)
     start();
 }
 
-void OcsShareJob::deleteShare()
+void OcsShareJob::deleteShare(int shareId)
 {
+    appendPath(shareId);
     setVerb("DELETE");
 
     start();
 }
 
-void OcsShareJob::setExpireDate(const QDate &date)
+void OcsShareJob::setExpireDate(int shareId, const QDate &date)
 {
+    appendPath(shareId);
     setVerb("PUT");
 
     if (date.isValid()) {
@@ -62,8 +58,9 @@ void OcsShareJob::setExpireDate(const QDate &date)
     start();
 }
 
-void OcsShareJob::setPassword(const QString &password)
+void OcsShareJob::setPassword(int shareId, const QString &password)
 {
+    appendPath(shareId);
     setVerb("PUT");
 
     addParam(QString::fromLatin1("password"), password);
@@ -71,8 +68,9 @@ void OcsShareJob::setPassword(const QString &password)
     start();
 }
 
-void OcsShareJob::setPublicUpload(bool publicUpload)
+void OcsShareJob::setPublicUpload(int shareId, bool publicUpload)
 {
+    appendPath(shareId);
     setVerb("PUT");
 
     const QString value = QString::fromLatin1(publicUpload ? "true" : "false");
diff --git a/src/gui/ocssharejob.h b/src/gui/ocssharejob.h
index 5156a52..337f33b 100644
--- a/src/gui/ocssharejob.h
+++ b/src/gui/ocssharejob.h
@@ -57,11 +57,6 @@ public:
     explicit OcsShareJob(AccountPtr account, QObject *parent = 0);
 
     /**
-     * Constructors for existing shares of which we know the shareId
-     */
-    explicit OcsShareJob(int shareId, AccountPtr account, QObject *parent = 0);
-
-    /**
      * Get all the shares
      *
      * @param path Path to request shares for (default all shares)
@@ -71,7 +66,7 @@ public:
     /**
      * Delete the current Share
      */
-    void deleteShare();
+    void deleteShare(int shareId);
 
     /**
      * Set the expiration date of a share
@@ -79,7 +74,7 @@ public:
      * @param date The expire date, if this date is invalid the expire date
      * will be removed
      */
-    void setExpireDate(const QDate& date);
+    void setExpireDate(int shareId, const QDate& date);
 
     /**
      * Set the password of a share
@@ -87,14 +82,14 @@ public:
      * @param password The password of the share, if the password is empty the
      * share will be removed
      */
-    void setPassword(const QString& password);
+    void setPassword(int shareId, const QString& password);
 
     /**
      * Void set the a share to be public upload
      * 
      * @param publicUpload Set or remove public upload
      */
-    void setPublicUpload(bool publicUpload);
+    void setPublicUpload(int shareId, bool publicUpload);
 
     /**
      * Create a new share
diff --git a/src/gui/sharedialog.cpp b/src/gui/sharedialog.cpp
index 8be6bf0..5cf7118 100644
--- a/src/gui/sharedialog.cpp
+++ b/src/gui/sharedialog.cpp
@@ -184,9 +184,9 @@ void ShareDialog::setExpireDate(const QDate &date)
     }
     _pi_date->startAnimation();
 
-    OcsShareJob *job = new OcsShareJob(_public_share_id, _account, this);
+    OcsShareJob *job = new OcsShareJob(_account, this);
     connect(job, SIGNAL(jobFinished(QVariantMap)), this, SLOT(slotExpireSet(QVariantMap)));
-    job->setExpireDate(date);
+    job->setExpireDate(_public_share_id, date);
 }
 
 void ShareDialog::slotExpireSet(const QVariantMap &reply)
@@ -235,11 +235,11 @@ void ShareDialog::setPassword(const QString &password)
     QString path;
 
     if( _public_share_id > 0 ) {
-        OcsShareJob *job = new OcsShareJob(_public_share_id, _account, this);
+        OcsShareJob *job = new OcsShareJob(_account, this);
         connect(job, SIGNAL(jobFinished(QVariantMap)), this, SLOT(slotPasswordSet(QVariantMap)));
-        job->setPassword(password);
+        job->setPassword(_public_share_id, password);
     } else {
-        OcsShareJob *job = new OcsShareJob(_public_share_id, _account, this);
+        OcsShareJob *job = new OcsShareJob(_account, this);
         connect(job, SIGNAL(jobFinished(QVariantMap)), this, SLOT(slotPasswordSet(QVariantMap)));
         connect(job, SIGNAL(jobFinished(QVariantMap)), this, SLOT(slotCreateShareFetched(QVariantMap)));
 
@@ -471,9 +471,9 @@ void ShareDialog::slotCheckBoxShareLinkClicked()
         job->createShare(_sharePath, OcsShareJob::SHARETYPE::LINK);
     } else {
         _pi_link->startAnimation();
-        OcsShareJob *job = new OcsShareJob(_public_share_id, _account, this);
+        OcsShareJob *job = new OcsShareJob(_account, this);
         connect(job, SIGNAL(jobFinished(QVariantMap)), this, SLOT(slotDeleteShareFetched(QVariantMap)));
-        job->deleteShare();
+        job->deleteShare(_public_share_id);
     }
 }
 
@@ -553,9 +553,9 @@ void ShareDialog::setPublicUpload(bool publicUpload)
     _ui->checkBox_editing->setEnabled(false);
     _pi_editing->startAnimation();
 
-    OcsShareJob *job = new OcsShareJob(_public_share_id, _account, this);
+    OcsShareJob *job = new OcsShareJob(_account, this);
     connect(job, SIGNAL(jobFinished(QVariantMap)), this, SLOT(slotPublicUploadSet(QVariantMap)));
-    job->setPublicUpload(publicUpload);
+    job->setPublicUpload(_public_share_id, publicUpload);
 }
 
 void ShareDialog::slotPublicUploadSet(const QVariantMap &reply)

-- 
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