From f331fe1591658d4981a6223807be1afd82282046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Wed, 25 Feb 2015 15:53:45 +0100 Subject: [PATCH] added input types in plugin json files --- .../deviceplugincommandlauncher.json | 12 +++-- .../conrad/devicepluginconrad.json | 6 ++- .../datetime/deviceplugindatetime.json | 4 +- .../deviceplugins/eq-3/deviceplugineq-3.json | 6 ++- .../deviceplugingenericelements.json | 9 ++-- .../intertechno/devicepluginintertechno.json | 1 + .../leynew/devicepluginleynew.json | 1 + .../lgsmarttv/devicepluginlgsmarttv.json | 21 +++++--- .../lircd/devicepluginlircd.json | 3 +- .../devicepluginmailnotification.json | 51 ++++++++++++------- .../devicepluginopenweathermap.json | 12 +++-- .../philipshue/devicepluginphilipshue.json | 6 ++- .../wakeonlan/devicepluginwakeonlan.json | 8 +-- .../deviceplugins/wemo/devicepluginwemo.json | 9 ++-- .../devicepluginwifidetector.json | 3 +- server/jsonrpc/jsontypes.cpp | 6 +++ 16 files changed, 108 insertions(+), 50 deletions(-) diff --git a/plugins/deviceplugins/commandlauncher/deviceplugincommandlauncher.json b/plugins/deviceplugins/commandlauncher/deviceplugincommandlauncher.json index 21305038..acd43995 100644 --- a/plugins/deviceplugins/commandlauncher/deviceplugincommandlauncher.json +++ b/plugins/deviceplugins/commandlauncher/deviceplugincommandlauncher.json @@ -14,11 +14,13 @@ "paramTypes": [ { "name": "name", - "type": "QString" + "type": "QString", + "inputType": "TextLine" }, { "name": "command", - "type": "QString" + "type": "QString", + "inputType": "Url" } ], "stateTypes": [ @@ -51,11 +53,13 @@ "paramTypes": [ { "name": "name", - "type": "QString" + "type": "QString", + "inputType": "TextLine" }, { "name": "script", - "type": "QString" + "type": "QString", + "inputType": "Url" } ], "stateTypes": [ diff --git a/plugins/deviceplugins/conrad/devicepluginconrad.json b/plugins/deviceplugins/conrad/devicepluginconrad.json index e544b272..42d52f90 100644 --- a/plugins/deviceplugins/conrad/devicepluginconrad.json +++ b/plugins/deviceplugins/conrad/devicepluginconrad.json @@ -14,7 +14,8 @@ "paramTypes": [ { "name": "name", - "type": "QString" + "type": "QString", + "inputType": "TextLine" } ], "eventTypes": [ @@ -47,7 +48,8 @@ "paramTypes": [ { "name": "name", - "type": "QString" + "type": "QString", + "inputType": "TextLine" } ], "actionTypes": [ diff --git a/plugins/deviceplugins/datetime/deviceplugindatetime.json b/plugins/deviceplugins/datetime/deviceplugindatetime.json index 2995279e..30d6347d 100644 --- a/plugins/deviceplugins/datetime/deviceplugindatetime.json +++ b/plugins/deviceplugins/datetime/deviceplugindatetime.json @@ -15,13 +15,15 @@ { "name": "continent", "type": "QString", + "inputType": "TextLine", "allowedValues": ["Africa", "America", "Antarctica", "Asia", "Atlantic", "Australia", "Europe", "Indian", "Pacific"] } ], "paramTypes": [ { "name": "timezone", - "type": "QString" + "type": "QString", + "inputType": "TextLine" } ], "stateTypes": [ diff --git a/plugins/deviceplugins/eq-3/deviceplugineq-3.json b/plugins/deviceplugins/eq-3/deviceplugineq-3.json index 450c8e59..0dc277ab 100644 --- a/plugins/deviceplugins/eq-3/deviceplugineq-3.json +++ b/plugins/deviceplugins/eq-3/deviceplugineq-3.json @@ -14,7 +14,8 @@ "paramTypes": [ { "name": "host address", - "type": "QString" + "type": "QString", + "inputType": "IPv4Address" }, { "name": "port", @@ -22,7 +23,8 @@ }, { "name": "serial number", - "type": "QString" + "type": "QString", + "inputType": "TextLine" }, { "name": "firmware version", diff --git a/plugins/deviceplugins/genericelements/deviceplugingenericelements.json b/plugins/deviceplugins/genericelements/deviceplugingenericelements.json index b437cad9..e2ce535e 100644 --- a/plugins/deviceplugins/genericelements/deviceplugingenericelements.json +++ b/plugins/deviceplugins/genericelements/deviceplugingenericelements.json @@ -14,7 +14,8 @@ "paramTypes": [ { "name": "name", - "type": "QString" + "type": "QString", + "inputType": "TextLine" } ], "stateTypes": [ @@ -42,7 +43,8 @@ "paramTypes": [ { "name": "name", - "type": "QString" + "type": "QString", + "inputType": "TextLine" } ], "actionTypes": [ @@ -68,7 +70,8 @@ "paramTypes": [ { "name": "name", - "type": "QString" + "type": "QString", + "inputType": "TextLine" } ], "actionTypes": [ diff --git a/plugins/deviceplugins/intertechno/devicepluginintertechno.json b/plugins/deviceplugins/intertechno/devicepluginintertechno.json index 8e5ffdac..6c224405 100644 --- a/plugins/deviceplugins/intertechno/devicepluginintertechno.json +++ b/plugins/deviceplugins/intertechno/devicepluginintertechno.json @@ -15,6 +15,7 @@ { "name": "familyCode", "type": "QString", + "inputType": "TextLine", "allowedValues": ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P"] } ], diff --git a/plugins/deviceplugins/leynew/devicepluginleynew.json b/plugins/deviceplugins/leynew/devicepluginleynew.json index 448a8be7..5b0b233e 100644 --- a/plugins/deviceplugins/leynew/devicepluginleynew.json +++ b/plugins/deviceplugins/leynew/devicepluginleynew.json @@ -15,6 +15,7 @@ { "name": "ID", "type": "QString", + "inputType": "TextLine", "allowedValues": ["0008", "0115", "0014"] } ], diff --git a/plugins/deviceplugins/lgsmarttv/devicepluginlgsmarttv.json b/plugins/deviceplugins/lgsmarttv/devicepluginlgsmarttv.json index f2a35a86..d436588a 100644 --- a/plugins/deviceplugins/lgsmarttv/devicepluginlgsmarttv.json +++ b/plugins/deviceplugins/lgsmarttv/devicepluginlgsmarttv.json @@ -14,19 +14,23 @@ "paramTypes": [ { "name": "name", - "type": "QString" + "type": "QString", + "inputType": "TextLine" }, { "name": "uuid", - "type": "QString" + "type": "QString", + "inputType": "TextLine" }, { "name": "model", - "type": "QString" + "type": "QString", + "inputType": "TextLine" }, { "name": "host address", - "type": "QString" + "type": "QString", + "inputType": "IPv4Address" }, { "name": "port", @@ -34,15 +38,18 @@ }, { "name": "location", - "type": "QString" + "type": "QString", + "inputType": "Url" }, { "name": "manufacturer", - "type": "QString" + "type": "QString", + "inputType": "TextLine" }, { "name": "key", - "type": "QString" + "type": "QString", + "inputType": "Password" } ], "stateTypes": [ diff --git a/plugins/deviceplugins/lircd/devicepluginlircd.json b/plugins/deviceplugins/lircd/devicepluginlircd.json index 976ab3ae..1410bcf5 100644 --- a/plugins/deviceplugins/lircd/devicepluginlircd.json +++ b/plugins/deviceplugins/lircd/devicepluginlircd.json @@ -13,7 +13,8 @@ "paramTypes": [ { "name": "remoteName", - "type": "QString" + "type": "QString", + "inputType": "TextLine" } ], "eventTypes": [ diff --git a/plugins/deviceplugins/mailnotification/devicepluginmailnotification.json b/plugins/deviceplugins/mailnotification/devicepluginmailnotification.json index d725b027..43a8d334 100644 --- a/plugins/deviceplugins/mailnotification/devicepluginmailnotification.json +++ b/plugins/deviceplugins/mailnotification/devicepluginmailnotification.json @@ -14,23 +14,28 @@ "paramTypes": [ { "name": "sender mail", - "type": "QString" + "type": "QString", + "inputType": "Mail" }, { "name": "user", - "type": "QString" + "type": "QString", + "inputType": "TextLine" }, { "name": "password", - "type": "QString" + "type": "QString", + "inputType": "Password" }, { "name": "recipient", - "type": "QString" + "type": "QString", + "inputType": "Mail" }, { "name": "SMTP server", - "type": "QString" + "type": "QString", + "inputType": "Url" }, { "name": "port", @@ -56,11 +61,13 @@ "paramTypes": [ { "name": "subject", - "type": "QString" + "type": "QString", + "inputType": "TextLine" }, { "name": "body", - "type": "QString" + "type": "QString", + "inputType": "TextArea" } ] } @@ -80,15 +87,18 @@ "paramTypes": [ { "name": "user", - "type": "QString" + "type": "QString", + "inputType": "Mail" }, { "name": "password", - "type": "QString" + "type": "QString", + "inputType": "Password" }, { "name": "recipient", - "type": "QString" + "type": "QString", + "inputType": "Mail" } ], "actionTypes": [ @@ -99,11 +109,13 @@ "paramTypes": [ { "name": "subject", - "type": "QString" + "type": "QString", + "inputType": "TextLine" }, { "name": "body", - "type": "QString" + "type": "QString", + "inputType": "TextArea" } ] } @@ -123,15 +135,18 @@ "paramTypes": [ { "name": "user", - "type": "QString" + "type": "QString", + "inputType": "Mail" }, { "name": "password", - "type": "QString" + "type": "QString", + "inputType": "Password" }, { "name": "recipient", - "type": "QString" + "type": "QString", + "inputType": "Mail" } ], "actionTypes": [ @@ -141,11 +156,13 @@ "paramTypes": [ { "name": "subject", - "type": "QString" + "type": "QString", + "inputType": "TextLine" }, { "name": "body", - "type": "QString" + "type": "QString", + "inputType": "TextArea" } ] } diff --git a/plugins/deviceplugins/openweathermap/devicepluginopenweathermap.json b/plugins/deviceplugins/openweathermap/devicepluginopenweathermap.json index dac65eb0..3bef0c96 100644 --- a/plugins/deviceplugins/openweathermap/devicepluginopenweathermap.json +++ b/plugins/deviceplugins/openweathermap/devicepluginopenweathermap.json @@ -14,21 +14,25 @@ "discoveryParamTypes": [ { "name": "location", - "type": "QString" + "type": "QString", + "inputType": "Search" } ], "paramTypes": [ { "name": "location", - "type": "QString" + "type": "QString", + "inputType": "TextLine" }, { "name": "country", - "type": "QString" + "type": "QString", + "inputType": "TextLine" }, { "name": "id", - "type": "QString" + "type": "QString", + "inputType": "TextLine" } ], "actionTypes": [ diff --git a/plugins/deviceplugins/philipshue/devicepluginphilipshue.json b/plugins/deviceplugins/philipshue/devicepluginphilipshue.json index 3b76b087..f089c12c 100644 --- a/plugins/deviceplugins/philipshue/devicepluginphilipshue.json +++ b/plugins/deviceplugins/philipshue/devicepluginphilipshue.json @@ -16,11 +16,13 @@ "paramTypes": [ { "name": "ip", - "type" : "QString" + "type" : "QString", + "inputType": "IPv4Address" }, { "name": "username", - "type" : "QString" + "type" : "QString", + "inputType": "TextLine" }, { "name": "lightId", diff --git a/plugins/deviceplugins/wakeonlan/devicepluginwakeonlan.json b/plugins/deviceplugins/wakeonlan/devicepluginwakeonlan.json index 965870d9..3f9dc7b1 100644 --- a/plugins/deviceplugins/wakeonlan/devicepluginwakeonlan.json +++ b/plugins/deviceplugins/wakeonlan/devicepluginwakeonlan.json @@ -13,11 +13,13 @@ "paramTypes": [ { "name": "name", - "type": "QString" + "type": "QString", + "inputType": "TextLine" }, { - "name": "MAC", - "type": "QString" + "name": "Mac", + "type": "QString", + "inputType": "MacAddress" } ], "actionTypes": [ diff --git a/plugins/deviceplugins/wemo/devicepluginwemo.json b/plugins/deviceplugins/wemo/devicepluginwemo.json index 133e849e..b84c051c 100644 --- a/plugins/deviceplugins/wemo/devicepluginwemo.json +++ b/plugins/deviceplugins/wemo/devicepluginwemo.json @@ -14,11 +14,13 @@ "paramTypes": [ { "name": "name", - "type": "QString" + "type": "QString", + "inputType": "TextLine" }, { "name": "host address", - "type": "QString" + "type": "QString", + "inputType": "IPv4Address" }, { "name": "port", @@ -26,7 +28,8 @@ }, { "name": "serial number", - "type": "QString" + "type": "QString", + "inputType": "TextLine" } ], "stateTypes": [ diff --git a/plugins/deviceplugins/wifidetector/devicepluginwifidetector.json b/plugins/deviceplugins/wifidetector/devicepluginwifidetector.json index 9028ba38..7b1a486b 100644 --- a/plugins/deviceplugins/wifidetector/devicepluginwifidetector.json +++ b/plugins/deviceplugins/wifidetector/devicepluginwifidetector.json @@ -13,7 +13,8 @@ "paramTypes": [ { "name": "MAC", - "type": "QString" + "type": "QString", + "inputType": "MacAddress" } ], "stateTypes": [ diff --git a/server/jsonrpc/jsontypes.cpp b/server/jsonrpc/jsontypes.cpp index c13dcd8a..a1b939fb 100644 --- a/server/jsonrpc/jsontypes.cpp +++ b/server/jsonrpc/jsontypes.cpp @@ -899,6 +899,12 @@ QPair JsonTypes::validateVariant(const QVariant &templateVariant, qDebug() << QString("value %1 not allowed in %2").arg(variant.toString()).arg(loggingEventTypeRef()); return result; } + } else if (refName == inputTypeRef()) { + QPair result = validateEnum(s_inputType, variant); + if (!result.first) { + qDebug() << QString("value %1 not allowed in %2").arg(variant.toString()).arg(inputTypeRef()); + return result; + } } else { Q_ASSERT_X(false, "JsonTypes", QString("Unhandled ref: %1").arg(refName).toLatin1().data()); return report(false, QString("Unhandled ref %1. Server implementation incomplete.").arg(refName));