Add new API call for batteryinfo

Will return battery:"true/false" if one exists

If one exists, it will also return "level":"1-99"
and "status":"offline/charging/backup/unknown"

REST Request:
-------------------------------
PUT /sysadm/systeminfo
{
   "action" : "batteryinfo"
}

REST Response:
-------------------------------
{
    "args": {
        "batteryinfo": {
            "battery": "false"
        }
    }
}

WebSocket Request:
-------------------------------
{
   "namespace" : "sysadm",
   "name" : "systeminfo",
   "id" : "fooid",
   "args" : {
      "action" : "batteryinfo"
   }
}

WebSocket Response:
-------------------------------
{
  "args": {
    "batteryinfo": {
      "battery": "false"
    }
  },
  "id": "fooid",
  "name": "response",
  "namespace": "sysadm"
}
This commit is contained in:
Kris Moore
2016-01-20 13:26:38 -05:00
parent 783bca9dbf
commit 58e7e7a4e3
3 changed files with 42 additions and 3 deletions

View File

@@ -257,7 +257,11 @@ RestOutputStruct::ExitCode WebSocket::EvaluateSysadmSystemInfoRequest(const QJso
QString act = JsonValueToString(in_args.toObject().value("action"));
if(act=="externalmounts"){
ok = true;
out->insert("externalmounts", sysadm::SysInfo::ExternalDevicePaths());
out->insert("externalmounts", sysadm::SysInfo::externalDevicePaths());
}
if(act=="batteryinfo"){
ok = true;
out->insert("batteryinfo", sysadm::SysInfo::batteryInfo());
}
} //end of "action" key usage