added team discovery and fixed token storage
This commit is contained in:
parent
9e3d418498
commit
ac17e1a8de
@ -85,8 +85,11 @@ void IntegrationPluginTempo::confirmPairing(ThingPairingInfo *info, const QStrin
|
|||||||
Tempo *tempo = new Tempo(hardwareManager()->networkManager(), atlassianAccountName, secret, this);
|
Tempo *tempo = new Tempo(hardwareManager()->networkManager(), atlassianAccountName, secret, this);
|
||||||
tempo->getAccounts();
|
tempo->getAccounts();
|
||||||
connect(info, &ThingPairingInfo::aborted, tempo, &Tempo::deleteLater);
|
connect(info, &ThingPairingInfo::aborted, tempo, &Tempo::deleteLater);
|
||||||
connect(tempo, &Tempo::authenticationStatusChanged, info, [info, tempo, this] (bool authenticated){
|
connect(tempo, &Tempo::authenticationStatusChanged, info, [info, tempo, secret, this] (bool authenticated){
|
||||||
if (authenticated) {
|
if (authenticated) {
|
||||||
|
pluginStorage()->beginGroup(info->thingId().toString());
|
||||||
|
pluginStorage()->setValue("token", secret);
|
||||||
|
pluginStorage()->endGroup();
|
||||||
m_setupTempoConnections.insert(info->thingId(), tempo);
|
m_setupTempoConnections.insert(info->thingId(), tempo);
|
||||||
info->finish(Thing::ThingErrorNoError);
|
info->finish(Thing::ThingErrorNoError);
|
||||||
}
|
}
|
||||||
@ -99,6 +102,10 @@ void IntegrationPluginTempo::confirmPairing(ThingPairingInfo *info, const QStrin
|
|||||||
void IntegrationPluginTempo::discoverThings(ThingDiscoveryInfo *info)
|
void IntegrationPluginTempo::discoverThings(ThingDiscoveryInfo *info)
|
||||||
{
|
{
|
||||||
qCDebug(dcTempo()) << "Discover things";
|
qCDebug(dcTempo()) << "Discover things";
|
||||||
|
if (m_tempoConnections.isEmpty()) {
|
||||||
|
return info->finish(Thing::ThingErrorHardwareNotAvailable, tr("Create a Tempo connection first"));
|
||||||
|
}
|
||||||
|
|
||||||
if (info->thingClassId() == accountThingClassId) {
|
if (info->thingClassId() == accountThingClassId) {
|
||||||
Q_FOREACH(Tempo *tempo, m_tempoConnections) {
|
Q_FOREACH(Tempo *tempo, m_tempoConnections) {
|
||||||
tempo->getAccounts();
|
tempo->getAccounts();
|
||||||
@ -109,6 +116,9 @@ void IntegrationPluginTempo::discoverThings(ThingDiscoveryInfo *info)
|
|||||||
}
|
}
|
||||||
connect(tempo, &Tempo::accountsReceived, info, [info, parentThing, this, tempo] (const QList<Tempo::Account> &accounts) {
|
connect(tempo, &Tempo::accountsReceived, info, [info, parentThing, this, tempo] (const QList<Tempo::Account> &accounts) {
|
||||||
Q_FOREACH(Tempo::Account account, accounts) {
|
Q_FOREACH(Tempo::Account account, accounts) {
|
||||||
|
if (account.status == Tempo::Status::Archived)
|
||||||
|
continue;
|
||||||
|
|
||||||
ThingDescriptor descriptor(accountThingClassId, account.name, account.customer.name, parentThing->id());
|
ThingDescriptor descriptor(accountThingClassId, account.name, account.customer.name, parentThing->id());
|
||||||
ParamList params;
|
ParamList params;
|
||||||
params << Param(accountThingKeyParamTypeId, account.key);
|
params << Param(accountThingKeyParamTypeId, account.key);
|
||||||
@ -125,6 +135,16 @@ void IntegrationPluginTempo::discoverThings(ThingDiscoveryInfo *info)
|
|||||||
qCWarning(dcTempo()) << "Parent not found";
|
qCWarning(dcTempo()) << "Parent not found";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
connect(tempo, &Tempo::teamsReceived, info, [info, parentThing, this, tempo] (const QList<Tempo::Team> &teams) {
|
||||||
|
Q_FOREACH(Tempo::Team team, teams) {
|
||||||
|
|
||||||
|
ThingDescriptor descriptor(teamThingClassId, team.name, team.summary, parentThing->id());
|
||||||
|
ParamList params;
|
||||||
|
params << Param(teamThingIdParamTypeId, team.id);
|
||||||
|
descriptor.setParams(params);
|
||||||
|
info->addThingDescriptor(descriptor);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QTimer::singleShot(5000, info, [info] {
|
QTimer::singleShot(5000, info, [info] {
|
||||||
@ -164,8 +184,6 @@ void IntegrationPluginTempo::setupThing(ThingSetupInfo *info)
|
|||||||
}
|
}
|
||||||
QString jiraInstanceName = thing->paramValue(tempoConnectionThingAtlassianAccountNameParamTypeId).toString();
|
QString jiraInstanceName = thing->paramValue(tempoConnectionThingAtlassianAccountNameParamTypeId).toString();
|
||||||
Tempo *tempo = new Tempo(hardwareManager()->networkManager(), jiraInstanceName, token, this);
|
Tempo *tempo = new Tempo(hardwareManager()->networkManager(), jiraInstanceName, token, this);
|
||||||
tempo->getAccounts();
|
|
||||||
|
|
||||||
connect(info, &ThingSetupInfo::aborted, tempo, &Tempo::deleteLater);
|
connect(info, &ThingSetupInfo::aborted, tempo, &Tempo::deleteLater);
|
||||||
connect(tempo, &Tempo::authenticationStatusChanged, info, [info, tempo, this] (bool authenticated){
|
connect(tempo, &Tempo::authenticationStatusChanged, info, [info, tempo, this] (bool authenticated){
|
||||||
if (authenticated) {
|
if (authenticated) {
|
||||||
@ -173,6 +191,7 @@ void IntegrationPluginTempo::setupThing(ThingSetupInfo *info)
|
|||||||
info->finish(Thing::ThingErrorNoError);
|
info->finish(Thing::ThingErrorNoError);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
tempo->getAccounts();
|
||||||
}
|
}
|
||||||
connect(tempo, &Tempo::connectionChanged, this, &IntegrationPluginTempo::onConnectionChanged);
|
connect(tempo, &Tempo::connectionChanged, this, &IntegrationPluginTempo::onConnectionChanged);
|
||||||
connect(tempo, &Tempo::authenticationStatusChanged, this, &IntegrationPluginTempo::onAuthenticationStatusChanged);
|
connect(tempo, &Tempo::authenticationStatusChanged, this, &IntegrationPluginTempo::onAuthenticationStatusChanged);
|
||||||
|
|||||||
@ -66,7 +66,6 @@
|
|||||||
"displayName": "Account",
|
"displayName": "Account",
|
||||||
"interfaces": ["connectable"],
|
"interfaces": ["connectable"],
|
||||||
"createMethods": ["discovery"],
|
"createMethods": ["discovery"],
|
||||||
"browsable": true,
|
|
||||||
"paramTypes": [
|
"paramTypes": [
|
||||||
{
|
{
|
||||||
"id": "c6aeddae-56af-496d-a419-1635ff9bae50",
|
"id": "c6aeddae-56af-496d-a419-1635ff9bae50",
|
||||||
@ -173,14 +172,13 @@
|
|||||||
"displayName": "Team",
|
"displayName": "Team",
|
||||||
"interfaces": ["connectable"],
|
"interfaces": ["connectable"],
|
||||||
"createMethods": ["discovery"],
|
"createMethods": ["discovery"],
|
||||||
"browsable": true,
|
|
||||||
"paramTypes": [
|
"paramTypes": [
|
||||||
{
|
{
|
||||||
"id": "bb90e986-fcfa-47e8-8783-f2b5a887314a",
|
"id": "bb90e986-fcfa-47e8-8783-f2b5a887314a",
|
||||||
"name": "key",
|
"name": "id",
|
||||||
"displayName": "Key",
|
"displayName": "Id",
|
||||||
"defaultValue": "",
|
"defaultValue": 0,
|
||||||
"type": "QString"
|
"type": "int"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"stateTypes": [
|
"stateTypes": [
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user