mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
refactor: API split (#721)
* refactor: API split * refactor: cleanup hyperiond
This commit is contained in:
@@ -35,7 +35,7 @@ JsonCB::JsonCB(QObject* parent)
|
||||
, _prioMuxer(nullptr)
|
||||
{
|
||||
_availableCommands << "components-update" << "sessions-update" << "priorities-update" << "imageToLedMapping-update"
|
||||
<< "adjustment-update" << "videomode-update" << "effects-update" << "settings-update" << "leds-update" << "instance-update";
|
||||
<< "adjustment-update" << "videomode-update" << "effects-update" << "settings-update" << "leds-update" << "instance-update" << "token-update";
|
||||
}
|
||||
|
||||
bool JsonCB::subscribeFor(const QString& type, const bool & unsubscribe)
|
||||
@@ -131,6 +131,14 @@ bool JsonCB::subscribeFor(const QString& type, const bool & unsubscribe)
|
||||
connect(HyperionIManager::getInstance(), &HyperionIManager::change, this, &JsonCB::handleInstanceChange, Qt::UniqueConnection);
|
||||
}
|
||||
|
||||
if (type == "token-update")
|
||||
{
|
||||
if (unsubscribe)
|
||||
disconnect(AuthManager::getInstance(), &AuthManager::tokenChange, this, &JsonCB::handleTokenChange);
|
||||
else
|
||||
connect(AuthManager::getInstance(), &AuthManager::tokenChange, this, &JsonCB::handleTokenChange, Qt::UniqueConnection);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -401,3 +409,17 @@ void JsonCB::handleInstanceChange()
|
||||
}
|
||||
doCallback("instance-update", QVariant(arr));
|
||||
}
|
||||
|
||||
void JsonCB::handleTokenChange(const QVector<AuthManager::AuthDefinition> &def)
|
||||
{
|
||||
QJsonArray arr;
|
||||
for (const auto &entry : def)
|
||||
{
|
||||
QJsonObject sub;
|
||||
sub["comment"] = entry.comment;
|
||||
sub["id"] = entry.id;
|
||||
sub["last_use"] = entry.lastUse;
|
||||
arr.push_back(sub);
|
||||
}
|
||||
doCallback("token-update", QVariant(arr));
|
||||
}
|
||||
|
Reference in New Issue
Block a user