-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Thing that matters with this, this allows for templated InnertubeReply. No more qOverload garbage. Breaks pretty much all old code, but it's for the better, things are a lot less gross :D
- Loading branch information
1 parent
3a3c263
commit a0c7330
Showing
10 changed files
with
98 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "lib/verdigris"] | ||
path = lib/verdigris | ||
url = https://github.com/woboq/verdigris |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,21 @@ | ||
#ifndef INNERTUBEEXCEPTION_H | ||
#define INNERTUBEEXCEPTION_H | ||
#include <QException> | ||
#include <wobjectdefs.h> | ||
|
||
class InnertubeException : public QException | ||
{ | ||
public: | ||
enum class Severity { Normal, Minor }; | ||
explicit InnertubeException(const QString& message, Severity severity = Severity::Normal) : _message(message), _severity(severity) {} | ||
QString message() const { return _message; } | ||
Severity severity() const { return _severity; } | ||
explicit InnertubeException(const QString& message, Severity severity = Severity::Normal) | ||
: m_message(message), m_severity(severity) {} | ||
QString message() const { return m_message; } | ||
Severity severity() const { return m_severity; } | ||
private: | ||
QString _message; | ||
Severity _severity; | ||
QString m_message; | ||
Severity m_severity; | ||
}; | ||
|
||
W_REGISTER_ARGTYPE(InnertubeException) | ||
|
||
#endif // INNERTUBEEXCEPTION_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,38 @@ | ||
#ifndef INNERTUBEREPLY_H | ||
#define INNERTUBEREPLY_H | ||
#include <wobjectimpl.h> | ||
#include "endpoints/innertubeendpoints.h" | ||
#include "innertubeexception.h" | ||
|
||
template<class T, class... U> | ||
static constexpr bool innertube_is_any_v = std::disjunction_v<std::is_same<T, U>...>; | ||
|
||
/** | ||
* @brief An @ref InnertubeEndpoints::BaseEndpoint "Innertube endpoint" that returns data. | ||
* @details The @ref InnertubeEndpoints::Like "Like", @ref InnertubeEndpoints::SendMessage "SendMessage", | ||
* and @ref InnertubeEndpoints::Subscribe "Subscribe" endpoints cannot be used here.<br> | ||
* Use their respective methods in the InnerTube class as opposed to the | ||
* @ref InnerTube::get "get" and @ref InnerTube::getBlocking "getBlocking" methods. | ||
*/ | ||
template<class C> | ||
concept EndpointWithData = requires(C c) | ||
{ | ||
[]<InnertubeEndpoints::CompTimeStr X>(InnertubeEndpoints::BaseEndpoint<X>&){}(c); | ||
} && !innertube_is_any_v<C, InnertubeEndpoints::Like, InnertubeEndpoints::SendMessage, InnertubeEndpoints::Subscribe>; | ||
|
||
/** | ||
* @brief An object that emits signals related to Innertube requests. Used by @ref InnerTube::get and @ref InnerTube::getRaw. | ||
*/ | ||
template<EndpointWithData E> | ||
class InnertubeReply : public QObject | ||
{ | ||
Q_OBJECT | ||
signals: | ||
void exception(const InnertubeException&); | ||
void finished(const InnertubeEndpoints::AccountMenu&); | ||
void finished(const InnertubeEndpoints::BrowseChannel&); | ||
void finished(const InnertubeEndpoints::BrowseHistory&); | ||
void finished(const InnertubeEndpoints::BrowseHome&); | ||
void finished(const InnertubeEndpoints::BrowseSubscriptions&); | ||
void finished(const InnertubeEndpoints::BrowseTrending&); | ||
void finished(const InnertubeEndpoints::GetLiveChat&); | ||
void finished(const InnertubeEndpoints::GetLiveChatReplay&); | ||
void finished(const InnertubeEndpoints::GetNotificationMenu&); | ||
void finished(const InnertubeEndpoints::ModifyChannelPreference&); | ||
void finished(const InnertubeEndpoints::Next&); | ||
void finished(const InnertubeEndpoints::Player&); | ||
void finished(const InnertubeEndpoints::Search&); | ||
void finished(const InnertubeEndpoints::SendMessage&); | ||
void finished(const InnertubeEndpoints::Subscribe&); | ||
void finished(const InnertubeEndpoints::UnseenCount&); | ||
void finished(const InnertubeEndpoints::UpdatedMetadata&); | ||
void finishedRaw(const QJsonValue&); | ||
W_OBJECT(InnertubeReply) | ||
public /* signals */: | ||
void exception(const InnertubeException& ex) W_SIGNAL(exception, ex) | ||
void finished(const E& endpoint) W_SIGNAL(finished, endpoint) | ||
void finishedRaw(const QJsonValue& value) W_SIGNAL(finishedRaw, value) | ||
}; | ||
|
||
W_OBJECT_IMPL_INLINE(InnertubeReply<E>, template<EndpointWithData E>) | ||
|
||
#endif // INNERTUBEREPLY_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters