Skip to content

Commit

Permalink
Add APICall Api_GetBunniesInformation to fetch information on all
Browse files Browse the repository at this point in the history
connected bunny. Informations fetched are : name, Mac, sleep, color,
apiEnable, apiPublic, lastRecord, lastLocate, LastCron
  • Loading branch information
htristra committed Nov 5, 2011
1 parent b5a773c commit 07ee93a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
31 changes: 31 additions & 0 deletions server/plugins/system/stats/plugin_stats.cpp
Expand Up @@ -18,6 +18,8 @@ void PluginStats::InitApiCalls()
DECLARE_PLUGIN_API_CALL("getbunniesip()", PluginStats, Api_GetBunniesIP);
DECLARE_PLUGIN_API_CALL("getbunniesname()", PluginStats, Api_GetBunniesName);
DECLARE_PLUGIN_API_CALL("getbunniesstatus()", PluginStats, Api_GetBunniesStatus);
DECLARE_PLUGIN_API_CALL("getbunniesinformation()",PluginStats, Api_GetBunniesInformation);

}

PLUGIN_API_CALL(PluginStats::Api_GetPlugins)
Expand Down Expand Up @@ -111,3 +113,32 @@ PLUGIN_API_CALL(PluginStats::Api_GetBunniesStatus)
return new ApiManager::ApiMappedList(list);
}

PLUGIN_API_CALL(PluginStats::Api_GetBunniesInformation)
{
Q_UNUSED(account);
Q_UNUSED(hRequest);

QString xml = "";
QString awake;
QList<QByteArray> listB = BunnyManager::GetConnectedBunniesList();

QMap<QString, QVariant> list;
foreach(QByteArray id, listB)
{
Bunny * b = BunnyManager::GetBunny(id);
list.insert(QString(b->GetID()), b->GetBunnyName());
awake = b->IsSleeping() ? "1" : "0";
xml += "<bunny>";
xml += " <name>" + b->GetBunnyName() + "</name>";
xml += " <ID>" + QString(b->GetID()) + "</ID>";
xml += " <sleep>" + awake + "</sleep>";
xml += " <color>" + b->GetPluginSetting("colorbreathing", "color", QString("violet")).toString() + "</color>";
xml += " <apiEnable>"+ b->GetGlobalSetting("VApiEnable", false).toString() + "</apiEnable>";
xml += " <apiPublic>" + b->GetGlobalSetting("VApiPublic", false).toString() + "</apiPublic>";
xml += " <lastRecord>" + b->GetGlobalSetting("LastRecord","").toString() + "</lastRecord>";
xml += " <lastLocate>" + b->GetGlobalSetting("LastLocate","").toString() + "<lastLocate>";
xml += " <LastCron>" + b->GetGlobalSetting("LastCron","").toString() + "<LastCron>";
xml += "</bunny>";
}
return new ApiManager::ApiXml(xml);
}
1 change: 1 addition & 0 deletions server/plugins/system/stats/plugin_stats.h
Expand Up @@ -18,6 +18,7 @@ class PluginStats : public PluginInterface
PLUGIN_API_CALL(Api_GetBunniesIP);
PLUGIN_API_CALL(Api_GetBunniesName);
PLUGIN_API_CALL(Api_GetBunniesStatus);
PLUGIN_API_CALL(Api_GetBunniesInformation);

};

Expand Down

0 comments on commit 07ee93a

Please sign in to comment.