save
This commit is contained in:
parent
01240dda24
commit
8aa9c19cdf
3 changed files with 34 additions and 4 deletions
|
@ -19,5 +19,6 @@
|
||||||
#define FEEDLY_API_URL_TOKEN "auth/token"
|
#define FEEDLY_API_URL_TOKEN "auth/token"
|
||||||
#define FEEDLY_API_URL_PROFILE "profile"
|
#define FEEDLY_API_URL_PROFILE "profile"
|
||||||
#define FEEDLY_API_URL_COLLETIONS "collections"
|
#define FEEDLY_API_URL_COLLETIONS "collections"
|
||||||
|
#define FEEDLY_API_URL_TAGS "tags"
|
||||||
|
|
||||||
#endif // FEEDLY_DEFINITIONS_H
|
#endif // FEEDLY_DEFINITIONS_H
|
||||||
|
|
|
@ -142,14 +142,14 @@ QVariantHash FeedlyNetwork::profile(const QNetworkProxy& network_proxy) {
|
||||||
|
|
||||||
QString target_url = fullUrl(Service::Profile);
|
QString target_url = fullUrl(Service::Profile);
|
||||||
int timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
|
int timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
|
||||||
QByteArray output_msgs;
|
QByteArray output;
|
||||||
|
|
||||||
// This method uses proxy via parameter,
|
// This method uses proxy via parameter,
|
||||||
// not via "m_service" field.
|
// not via "m_service" field.
|
||||||
auto result = NetworkFactory::performNetworkOperation(target_url,
|
auto result = NetworkFactory::performNetworkOperation(target_url,
|
||||||
timeout,
|
timeout,
|
||||||
{},
|
{},
|
||||||
output_msgs,
|
output,
|
||||||
QNetworkAccessManager::Operation::GetOperation,
|
QNetworkAccessManager::Operation::GetOperation,
|
||||||
{ bearerHeader(bear) },
|
{ bearerHeader(bear) },
|
||||||
false,
|
false,
|
||||||
|
@ -161,10 +161,35 @@ QVariantHash FeedlyNetwork::profile(const QNetworkProxy& network_proxy) {
|
||||||
throw NetworkException(result.first);
|
throw NetworkException(result.first);
|
||||||
}
|
}
|
||||||
|
|
||||||
return QJsonDocument::fromJson(output_msgs).object().toVariantHash();
|
return QJsonDocument::fromJson(output).object().toVariantHash();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<RootItem*> FeedlyNetwork::tags() {
|
QList<RootItem*> FeedlyNetwork::tags() {
|
||||||
|
QString bear = bearer();
|
||||||
|
|
||||||
|
if (bear.isEmpty()) {
|
||||||
|
qCriticalNN << LOGSEC_FEEDLY << "Cannot obtain tags, because bearer is empty.";
|
||||||
|
throw NetworkException(QNetworkReply::NetworkError::AuthenticationRequiredError);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString target_url = fullUrl(Service::Tags);
|
||||||
|
int timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
|
||||||
|
QByteArray output;
|
||||||
|
auto result = NetworkFactory::performNetworkOperation(target_url,
|
||||||
|
timeout,
|
||||||
|
{},
|
||||||
|
output,
|
||||||
|
QNetworkAccessManager::Operation::GetOperation,
|
||||||
|
{ bearerHeader(bear) },
|
||||||
|
false,
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
m_service->networkProxy());
|
||||||
|
|
||||||
|
if (result.first != QNetworkReply::NetworkError::NoError) {
|
||||||
|
throw NetworkException(result.first);
|
||||||
|
}
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,6 +275,9 @@ QString FeedlyNetwork::fullUrl(FeedlyNetwork::Service service) const {
|
||||||
case Service::Collections:
|
case Service::Collections:
|
||||||
return QSL(FEEDLY_API_URL_BASE) + FEEDLY_API_URL_COLLETIONS;
|
return QSL(FEEDLY_API_URL_BASE) + FEEDLY_API_URL_COLLETIONS;
|
||||||
|
|
||||||
|
case Service::Tags:
|
||||||
|
return QSL(FEEDLY_API_URL_BASE) + FEEDLY_API_URL_TAGS;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return FEEDLY_API_URL_BASE;
|
return FEEDLY_API_URL_BASE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,8 @@ class FeedlyNetwork : public QObject {
|
||||||
private:
|
private:
|
||||||
enum class Service {
|
enum class Service {
|
||||||
Profile,
|
Profile,
|
||||||
Collections
|
Collections,
|
||||||
|
Tags
|
||||||
};
|
};
|
||||||
|
|
||||||
QString fullUrl(Service service) const;
|
QString fullUrl(Service service) const;
|
||||||
|
|
Loading…
Add table
Reference in a new issue