Basic fixes for theoldreaders, login and folder/feed sync works.
This commit is contained in:
parent
6dc5e016f1
commit
b0e5773b22
2 changed files with 21 additions and 13 deletions
|
@ -13,7 +13,7 @@
|
||||||
#define GREADER_API_FULL_STATE_IMPORTANT "user/-/state/com.google/starred"
|
#define GREADER_API_FULL_STATE_IMPORTANT "user/-/state/com.google/starred"
|
||||||
|
|
||||||
// API.
|
// API.
|
||||||
#define GREADER_API_CLIENT_LOGIN "accounts/ClientLogin?Email=%1&Passwd=%2"
|
#define GREADER_API_CLIENT_LOGIN "accounts/ClientLogin"
|
||||||
#define GREADER_API_TAG_LIST "reader/api/0/tag/list?output=json"
|
#define GREADER_API_TAG_LIST "reader/api/0/tag/list?output=json"
|
||||||
#define GREADER_API_SUBSCRIPTION_LIST "reader/api/0/subscription/list?output=json"
|
#define GREADER_API_SUBSCRIPTION_LIST "reader/api/0/subscription/list?output=json"
|
||||||
#define GREADER_API_STREAM_CONTENTS "reader/api/0/stream/contents/%1?output=json&n=%2"
|
#define GREADER_API_STREAM_CONTENTS "reader/api/0/stream/contents/%1?output=json&n=%2"
|
||||||
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
// Misc.
|
// Misc.
|
||||||
#define GREADER_API_EDIT_TAG_BATCH 200
|
#define GREADER_API_EDIT_TAG_BATCH 200
|
||||||
|
#define GREADER_API_ANY_LABEL "user/-/label"
|
||||||
|
|
||||||
// FreshRSS.
|
// FreshRSS.
|
||||||
#define FRESHRSS_BASE_URL_PATH "api/greader.php/"
|
#define FRESHRSS_BASE_URL_PATH "api/greader.php/"
|
||||||
|
|
|
@ -195,9 +195,11 @@ RootItem* GreaderNetwork::decodeTagsSubscriptions(const QString& categories, con
|
||||||
|
|
||||||
for (const QJsonValue& obj : json) {
|
for (const QJsonValue& obj : json) {
|
||||||
auto label = obj.toObject();
|
auto label = obj.toObject();
|
||||||
|
QString label_id = label["id"].toString();
|
||||||
|
|
||||||
if (label["type"].toString() == QL1S("folder")) {
|
if ((label["type"].toString() == QL1S("folder")) ||
|
||||||
QString label_id = label["id"].toString();
|
(m_service == GreaderServiceRoot::Service::TheOldReader &&
|
||||||
|
label_id.startsWith(GREADER_API_ANY_LABEL))) {
|
||||||
|
|
||||||
// We have label (not "state").
|
// We have label (not "state").
|
||||||
auto* category = new Category();
|
auto* category = new Category();
|
||||||
|
@ -210,11 +212,10 @@ RootItem* GreaderNetwork::decodeTagsSubscriptions(const QString& categories, con
|
||||||
parent->appendChild(category);
|
parent->appendChild(category);
|
||||||
}
|
}
|
||||||
else if (label["type"] == QL1S("tag")) {
|
else if (label["type"] == QL1S("tag")) {
|
||||||
QString name_id = label["id"].toString();
|
QString plain_name = QRegularExpression(".+\\/([^\\/]+)").match(label_id).captured(1);
|
||||||
QString plain_name = QRegularExpression(".+\\/([^\\/]+)").match(name_id).captured(1);
|
auto* new_lbl = new Label(plain_name, TextFactory::generateColorFromText(label_id));
|
||||||
auto* new_lbl = new Label(plain_name, TextFactory::generateColorFromText(name_id));
|
|
||||||
|
|
||||||
new_lbl->setCustomId(name_id);
|
new_lbl->setCustomId(label_id);
|
||||||
lbls.append(new_lbl);
|
lbls.append(new_lbl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -252,6 +253,10 @@ RootItem* GreaderNetwork::decodeTagsSubscriptions(const QString& categories, con
|
||||||
if (!icon_url.isEmpty()) {
|
if (!icon_url.isEmpty()) {
|
||||||
QByteArray icon_data;
|
QByteArray icon_data;
|
||||||
|
|
||||||
|
if (icon_url.startsWith(QSL("//"))) {
|
||||||
|
icon_url = QSL("https:") + icon_url;
|
||||||
|
}
|
||||||
|
|
||||||
if (NetworkFactory::performNetworkOperation(icon_url, timeout,
|
if (NetworkFactory::performNetworkOperation(icon_url, timeout,
|
||||||
{}, icon_data,
|
{}, icon_data,
|
||||||
QNetworkAccessManager::Operation::GetOperation).first ==
|
QNetworkAccessManager::Operation::GetOperation).first ==
|
||||||
|
@ -282,11 +287,12 @@ QNetworkReply::NetworkError GreaderNetwork::clientLogin(const QNetworkProxy& pro
|
||||||
QString full_url = generateFullUrl(Operations::ClientLogin);
|
QString full_url = generateFullUrl(Operations::ClientLogin);
|
||||||
auto timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
|
auto timeout = qApp->settings()->value(GROUP(Feeds), SETTING(Feeds::UpdateTimeout)).toInt();
|
||||||
QByteArray output;
|
QByteArray output;
|
||||||
|
QByteArray args = QSL("Email=%1&Passwd=%2").arg(username(), password()).toUtf8();
|
||||||
auto network_result = NetworkFactory::performNetworkOperation(full_url,
|
auto network_result = NetworkFactory::performNetworkOperation(full_url,
|
||||||
timeout,
|
timeout,
|
||||||
{},
|
args,
|
||||||
output,
|
output,
|
||||||
QNetworkAccessManager::Operation::GetOperation,
|
QNetworkAccessManager::Operation::PostOperation,
|
||||||
{},
|
{},
|
||||||
false,
|
false,
|
||||||
{},
|
{},
|
||||||
|
@ -322,10 +328,8 @@ QNetworkReply::NetworkError GreaderNetwork::clientLogin(const QNetworkProxy& pro
|
||||||
m_authAuth = QString();
|
m_authAuth = QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_authAuth.isEmpty() ||
|
if (m_authAuth.isEmpty()) {
|
||||||
(service() == GreaderServiceRoot::Service::FreshRss && m_authSid.isEmpty())) {
|
|
||||||
clearCredentials();
|
clearCredentials();
|
||||||
|
|
||||||
return QNetworkReply::NetworkError::InternalServerError;
|
return QNetworkReply::NetworkError::InternalServerError;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -512,7 +516,7 @@ QString GreaderNetwork::sanitizedBaseUrl() const {
|
||||||
QString GreaderNetwork::generateFullUrl(GreaderNetwork::Operations operation) const {
|
QString GreaderNetwork::generateFullUrl(GreaderNetwork::Operations operation) const {
|
||||||
switch (operation) {
|
switch (operation) {
|
||||||
case Operations::ClientLogin:
|
case Operations::ClientLogin:
|
||||||
return sanitizedBaseUrl() + QSL(GREADER_API_CLIENT_LOGIN).arg(username(), password());
|
return sanitizedBaseUrl() + GREADER_API_CLIENT_LOGIN;
|
||||||
|
|
||||||
case Operations::TagList:
|
case Operations::TagList:
|
||||||
return sanitizedBaseUrl() + GREADER_API_TAG_LIST;
|
return sanitizedBaseUrl() + GREADER_API_TAG_LIST;
|
||||||
|
@ -525,5 +529,8 @@ QString GreaderNetwork::generateFullUrl(GreaderNetwork::Operations operation) co
|
||||||
|
|
||||||
case Operations::EditTag:
|
case Operations::EditTag:
|
||||||
return sanitizedBaseUrl() + GREADER_API_EDIT_TAG;
|
return sanitizedBaseUrl() + GREADER_API_EDIT_TAG;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return sanitizedBaseUrl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue