OCSJob -> OcsJob and more docs

This commit is contained in:
Roeland Jago Douma 2015-10-15 20:54:52 +02:00
parent 3ea944d1b3
commit db1f4d4016
5 changed files with 24 additions and 16 deletions

View file

@ -20,42 +20,42 @@
namespace OCC {
OCSJob::OCSJob(AccountPtr account, QObject* parent)
OcsJob::OcsJob(AccountPtr account, QObject* parent)
: AbstractNetworkJob(account, "", parent)
{
_passStatusCodes.append(100);
setIgnoreCredentialFailure(true);
}
void OCSJob::setVerb(const QByteArray &verb)
void OcsJob::setVerb(const QByteArray &verb)
{
_verb = verb;
}
void OCSJob::setUrl(const QUrl &url)
void OcsJob::setUrl(const QUrl &url)
{
_url = url;
}
void OCSJob::setGetParams(const QList<QPair<QString, QString> >& getParams)
void OcsJob::setGetParams(const QList<QPair<QString, QString> >& getParams)
{
_url.setQueryItems(getParams);
}
void OCSJob::setPostParams(const QList<QPair<QString, QString> >& postParams)
void OcsJob::setPostParams(const QList<QPair<QString, QString> >& postParams)
{
_postParams = postParams;
}
void OCSJob::addPassStatusCode(int code)
void OcsJob::addPassStatusCode(int code)
{
_passStatusCodes.append(code);
}
void OCSJob::start()
void OcsJob::start()
{
QNetworkRequest req;
req.setRawHeader("OCS-APIREQUEST", "true");
req.setRawHeader("Ocs-APIREQUEST", "true");
req.setRawHeader("Content-Type", "application/x-www-form-urlencoded");
// Url encode the _postParams and put them in a buffer.
@ -81,7 +81,7 @@ void OCSJob::start()
AbstractNetworkJob::start();
}
bool OCSJob::finished()
bool OcsJob::finished()
{
const QString replyData = reply()->readAll();
@ -103,7 +103,7 @@ bool OCSJob::finished()
return true;
}
int OCSJob::getJsonReturnCode(const QVariantMap &json, QString &message)
int OcsJob::getJsonReturnCode(const QVariantMap &json, QString &message)
{
//TODO proper checking
int code = json.value("ocs").toMap().value("meta").toMap().value("statuscode").toInt();

View file

@ -27,13 +27,18 @@ namespace OCC {
/**
* @brief The OcsShareJob class
* @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
protected:
explicit OCSJob(AccountPtr account, QObject* parent = 0);
explicit OcsJob(AccountPtr account, QObject* parent = 0);
/**
* Set the verb for the job

View file

@ -21,13 +21,13 @@
namespace OCC {
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")));
}
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)));
}

View file

@ -24,8 +24,11 @@ namespace OCC {
/**
* @brief The OcsShareJob class
* @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
public:

View file

@ -201,7 +201,7 @@ void ShareDialog::setExpireDate(const QDate &date)
void ShareDialog::slotExpireSet(const QVariantMap &reply)
{
QString message;
int code = OCSJob::getJsonReturnCode(reply, message);
int code = OcsShareJob::getJsonReturnCode(reply, message);
if (code != 100) {
displayError(code);
}