diff --git a/saoriaccount.cpp b/saoriaccount.cpp index 201ba0f..642ead7 100644 --- a/saoriaccount.cpp +++ b/saoriaccount.cpp @@ -25,6 +25,7 @@ ***/ #include "saoriaccount.h" +#include "saoriview.h" #include "saoridef.h" SaoriAccount::SaoriAccount(const QString accountName, Saoridon *instance, const QString accsessToken, QObject *parent) : QObject(parent) @@ -106,3 +107,21 @@ return tl; } + +void SaoriAccount::getTimelineData(const QString timeline) +{ + QUrl url = instance()->timelineUrl(timeline); + if (url.isEmpty()) return; + auto manager = new QNetworkAccessManager(); + QNetworkRequest request = createHearder(); + request.setUrl(url); + auto *reply = manager->get(request); + connect(manager,&QNetworkAccessManager::finished,[=](){ + if (reply->NoError == QNetworkReply::NoError) { + auto view = SaoriView::findView(timeline,m_name); + if (view != nullptr) view->recived(reply->readAll()); + } + manager->deleteLater(); + }); + return; +} diff --git a/saoriaccount.h b/saoriaccount.h index 6adbb17..0fde318 100644 --- a/saoriaccount.h +++ b/saoriaccount.h @@ -51,6 +51,9 @@ const QString accountInfo(const QString key); const QStringList timelineList(); +public slots: + void getTimelineData(const QString timeline); + protected: void getAccountInfomation(); QNetworkRequest createHearder(); diff --git a/saoridef.h b/saoridef.h index 234bd60..8f76e9a 100644 --- a/saoridef.h +++ b/saoridef.h @@ -40,7 +40,7 @@ #define SAORI_MASTODON_APIPATH_TOKEN "/oauth/token" #define SAORI_MASTODON_APIPATH_INSTANCE "/api/v1/instance" #define SAORI_MASTODON_APIPATH_ACCOUNTS "/api/v1/accounts" -#define SAORI_MASTODON_APIPATH_TIMELINE "/api/v1/timeline" +#define SAORI_MASTODON_APIPATH_TIMELINE "/api/v1/timelines" #endif // SAORIDEF_H diff --git a/saoriview.cpp b/saoriview.cpp index 9aa6d06..3132d50 100644 --- a/saoriview.cpp +++ b/saoriview.cpp @@ -26,6 +26,8 @@ #include "saoriview.h" #include "ui_saoriview.h" +#include +#include #include QList SaoriView::m_viewList; @@ -54,7 +56,7 @@ return nullptr; } -void SaoriView::recived(QMap result) +void SaoriView::recived(QString result) { qDebug() << result; } diff --git a/saoriview.h b/saoriview.h index 2f793be..0d7f589 100644 --- a/saoriview.h +++ b/saoriview.h @@ -49,7 +49,7 @@ static QList m_viewList; public slots: - void recived(QMap result); + void recived(QString result); private: Ui::SaoriView *ui; diff --git a/saoriwindow.cpp b/saoriwindow.cpp index 85af945..0efc0bd 100644 --- a/saoriwindow.cpp +++ b/saoriwindow.cpp @@ -133,8 +133,9 @@ { auto account = SaoriApplication::findAccount(item->text(1)); if (account) { - qDebug() << account->instance()->timelineUrl(item->text(2)); openView(QStringList() << item->text(1) << item->text(2)); + qDebug() << item->text(2); + account->getTimelineData(item->text(2)); } }