File indexing completed on 2024-12-22 04:57:55

0001 /*
0002     SPDX-FileCopyrightText: 2016 Stefan Stäglich <sstaeglich@kdemail.net>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "tomboyjobbase.h"
0008 
0009 TomboyJobBase::TomboyJobBase(QNetworkAccessManager *manager, QObject *parent)
0010     : KCompositeJob(parent)
0011     , mManager(manager)
0012     , mO1(new O1Tomboy(this))
0013 {
0014     mRequestor = new O1Requestor(mManager, mO1, this);
0015 }
0016 
0017 void TomboyJobBase::setServerURL(const QString &apiurl, const QString &contenturl)
0018 {
0019     mO1->setBaseURL(apiurl);
0020     mApiURL = apiurl + QStringLiteral("/api/1.0");
0021     mContentURL = contenturl;
0022 }
0023 
0024 void TomboyJobBase::setAuthentication(const QString &token, const QString &secret)
0025 {
0026     mO1->restoreAuthData(token, secret);
0027 }
0028 
0029 void TomboyJobBase::checkReplyError()
0030 {
0031     switch (mReply->error()) {
0032     case QNetworkReply::NoError:
0033         setError(TomboyJobError::NoError);
0034         break;
0035     case QNetworkReply::RemoteHostClosedError:
0036     case QNetworkReply::HostNotFoundError:
0037     case QNetworkReply::TimeoutError:
0038         setError(TomboyJobError::TemporaryError);
0039         break;
0040     default:
0041         setError(TomboyJobError::PermanentError);
0042         break;
0043     }
0044 }
0045 
0046 #include "moc_tomboyjobbase.cpp"