mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-27 09:30:13 +03:00
OCSJob -> OcsJob and more docs
This commit is contained in:
parent
3ea944d1b3
commit
db1f4d4016
5 changed files with 24 additions and 16 deletions
|
@ -20,42 +20,42 @@
|
||||||
|
|
||||||
namespace OCC {
|
namespace OCC {
|
||||||
|
|
||||||
OCSJob::OCSJob(AccountPtr account, QObject* parent)
|
OcsJob::OcsJob(AccountPtr account, QObject* parent)
|
||||||
: AbstractNetworkJob(account, "", parent)
|
: AbstractNetworkJob(account, "", parent)
|
||||||
{
|
{
|
||||||
_passStatusCodes.append(100);
|
_passStatusCodes.append(100);
|
||||||
setIgnoreCredentialFailure(true);
|
setIgnoreCredentialFailure(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OCSJob::setVerb(const QByteArray &verb)
|
void OcsJob::setVerb(const QByteArray &verb)
|
||||||
{
|
{
|
||||||
_verb = verb;
|
_verb = verb;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OCSJob::setUrl(const QUrl &url)
|
void OcsJob::setUrl(const QUrl &url)
|
||||||
{
|
{
|
||||||
_url = url;
|
_url = url;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OCSJob::setGetParams(const QList<QPair<QString, QString> >& getParams)
|
void OcsJob::setGetParams(const QList<QPair<QString, QString> >& getParams)
|
||||||
{
|
{
|
||||||
_url.setQueryItems(getParams);
|
_url.setQueryItems(getParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OCSJob::setPostParams(const QList<QPair<QString, QString> >& postParams)
|
void OcsJob::setPostParams(const QList<QPair<QString, QString> >& postParams)
|
||||||
{
|
{
|
||||||
_postParams = postParams;
|
_postParams = postParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OCSJob::addPassStatusCode(int code)
|
void OcsJob::addPassStatusCode(int code)
|
||||||
{
|
{
|
||||||
_passStatusCodes.append(code);
|
_passStatusCodes.append(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OCSJob::start()
|
void OcsJob::start()
|
||||||
{
|
{
|
||||||
QNetworkRequest req;
|
QNetworkRequest req;
|
||||||
req.setRawHeader("OCS-APIREQUEST", "true");
|
req.setRawHeader("Ocs-APIREQUEST", "true");
|
||||||
req.setRawHeader("Content-Type", "application/x-www-form-urlencoded");
|
req.setRawHeader("Content-Type", "application/x-www-form-urlencoded");
|
||||||
|
|
||||||
// Url encode the _postParams and put them in a buffer.
|
// Url encode the _postParams and put them in a buffer.
|
||||||
|
@ -81,7 +81,7 @@ void OCSJob::start()
|
||||||
AbstractNetworkJob::start();
|
AbstractNetworkJob::start();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OCSJob::finished()
|
bool OcsJob::finished()
|
||||||
{
|
{
|
||||||
const QString replyData = reply()->readAll();
|
const QString replyData = reply()->readAll();
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ bool OCSJob::finished()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int OCSJob::getJsonReturnCode(const QVariantMap &json, QString &message)
|
int OcsJob::getJsonReturnCode(const QVariantMap &json, QString &message)
|
||||||
{
|
{
|
||||||
//TODO proper checking
|
//TODO proper checking
|
||||||
int code = json.value("ocs").toMap().value("meta").toMap().value("statuscode").toInt();
|
int code = json.value("ocs").toMap().value("meta").toMap().value("statuscode").toInt();
|
||||||
|
|
|
@ -27,13 +27,18 @@ namespace OCC {
|
||||||
/**
|
/**
|
||||||
* @brief The OcsShareJob class
|
* @brief The OcsShareJob class
|
||||||
* @ingroup gui
|
* @ingroup gui
|
||||||
|
*
|
||||||
|
* Base class for jobs that talk to the OCS endpoints on the server.
|
||||||
|
* All the comminication logic is handled in this class.
|
||||||
|
*
|
||||||
|
* All OCS jobs (e.g. sharing) should extend this class.
|
||||||
*/
|
*/
|
||||||
class OCSJob : public AbstractNetworkJob {
|
class OcsJob : public AbstractNetworkJob {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
explicit OCSJob(AccountPtr account, QObject* parent = 0);
|
explicit OcsJob(AccountPtr account, QObject* parent = 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the verb for the job
|
* Set the verb for the job
|
||||||
|
|
|
@ -21,13 +21,13 @@
|
||||||
namespace OCC {
|
namespace OCC {
|
||||||
|
|
||||||
OcsShareJob::OcsShareJob(AccountPtr account, QObject* parent)
|
OcsShareJob::OcsShareJob(AccountPtr account, QObject* parent)
|
||||||
: OCSJob(account, parent)
|
: OcsJob(account, parent)
|
||||||
{
|
{
|
||||||
setUrl(Account::concatUrlPath(account->url(), QString("ocs/v1.php/apps/files_sharing/api/v1/shares")));
|
setUrl(Account::concatUrlPath(account->url(), QString("ocs/v1.php/apps/files_sharing/api/v1/shares")));
|
||||||
}
|
}
|
||||||
|
|
||||||
OcsShareJob::OcsShareJob(int shareId, AccountPtr account, QObject* parent)
|
OcsShareJob::OcsShareJob(int shareId, AccountPtr account, QObject* parent)
|
||||||
: OCSJob(account, parent)
|
: OcsJob(account, parent)
|
||||||
{
|
{
|
||||||
setUrl(Account::concatUrlPath(account->url(), QString("ocs/v1.php/apps/files_sharing/api/v1/shares/%1").arg(shareId)));
|
setUrl(Account::concatUrlPath(account->url(), QString("ocs/v1.php/apps/files_sharing/api/v1/shares/%1").arg(shareId)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,11 @@ namespace OCC {
|
||||||
/**
|
/**
|
||||||
* @brief The OcsShareJob class
|
* @brief The OcsShareJob class
|
||||||
* @ingroup gui
|
* @ingroup gui
|
||||||
|
*
|
||||||
|
* Handle talking to the OCS Share API.
|
||||||
|
* For creation, deletion and modification of shares.
|
||||||
*/
|
*/
|
||||||
class OcsShareJob : public OCSJob {
|
class OcsShareJob : public OcsJob {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
|
@ -201,7 +201,7 @@ void ShareDialog::setExpireDate(const QDate &date)
|
||||||
void ShareDialog::slotExpireSet(const QVariantMap &reply)
|
void ShareDialog::slotExpireSet(const QVariantMap &reply)
|
||||||
{
|
{
|
||||||
QString message;
|
QString message;
|
||||||
int code = OCSJob::getJsonReturnCode(reply, message);
|
int code = OcsShareJob::getJsonReturnCode(reply, message);
|
||||||
if (code != 100) {
|
if (code != 100) {
|
||||||
displayError(code);
|
displayError(code);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue