diff --git a/telldus-gui/Plugins/TelldusCore/tellduscoreobject.cpp b/telldus-gui/Plugins/TelldusCore/tellduscoreobject.cpp index 4a9528c4..ada1a586 100644 --- a/telldus-gui/Plugins/TelldusCore/tellduscoreobject.cpp +++ b/telldus-gui/Plugins/TelldusCore/tellduscoreobject.cpp @@ -77,6 +77,30 @@ int TelldusCoreObject::turnOff(int deviceId) { return retval; } +int TelldusCoreObject::up(int deviceId) { + int retval = tdUp( deviceId ); + if (retval != TELLSTICK_SUCCESS) { + triggerError(deviceId, retval); + } + return retval; +} + +int TelldusCoreObject::down(int deviceId) { + int retval = tdDown( deviceId ); + if (retval != TELLSTICK_SUCCESS) { + triggerError(deviceId, retval); + } + return retval; +} + +int TelldusCoreObject::stop(int deviceId) { + int retval = tdStop( deviceId ); + if (retval != TELLSTICK_SUCCESS) { + triggerError(deviceId, retval); + } + return retval; +} + void TelldusCoreObject::triggerError(int deviceId, int errorId) { char *errorString = tdGetErrorString( errorId ); QString message = QString::fromUtf8( errorString ); diff --git a/telldus-gui/Plugins/TelldusCore/tellduscoreobject.h b/telldus-gui/Plugins/TelldusCore/tellduscoreobject.h index b7a8acb2..d8e14a78 100644 --- a/telldus-gui/Plugins/TelldusCore/tellduscoreobject.h +++ b/telldus-gui/Plugins/TelldusCore/tellduscoreobject.h @@ -10,7 +10,7 @@ class TelldusCoreObject : public QObject public: TelldusCoreObject( QObject * parent = 0 ); virtual ~TelldusCoreObject(); - + signals: void deviceChange( int deviceId, int eventId ); void deviceEvent( int deviceId, int method, const QString &data ); @@ -25,19 +25,22 @@ public slots: int lastSentCommand( int deviceId, int methodsSupported ); QString lastSentValue( int deviceId ); int methods( int deviceId, int methodsSupported ); - + int turnOn( int deviceId ); int turnOff( int deviceId ); - + int up( int deviceId ); + int down( int deviceId ); + int stop( int deviceId ); + private: void triggerError( int, int ); - + static void WINAPI deviceChangeEventCallback(int deviceId, int eventId, int changeType, int callbackId, void *context); static void WINAPI deviceEventCallback(int deviceId, int method, const char *data, int callbackId, void *context); - + int deviceEventId; int deviceChangeEventId; - + }; #endif // TELLDUSCOREOBJECT_H diff --git a/telldus-gui/Plugins/TelldusCore/tellduscoreplugin.cpp b/telldus-gui/Plugins/TelldusCore/tellduscoreplugin.cpp index a9fde239..cdc8d9b6 100644 --- a/telldus-gui/Plugins/TelldusCore/tellduscoreplugin.cpp +++ b/telldus-gui/Plugins/TelldusCore/tellduscoreplugin.cpp @@ -21,12 +21,15 @@ void TelldusCorePlugin::initialize ( const QString & key, QScriptEngine * engine value.setProperty("TELLSTICK_BELL", TELLSTICK_BELL); value.setProperty("TELLSTICK_TOGGLE", TELLSTICK_TOGGLE); value.setProperty("TELLSTICK_DIM", TELLSTICK_DIM); - + value.setProperty("TELLSTICK_UP", TELLSTICK_UP); + value.setProperty("TELLSTICK_DOWN", TELLSTICK_DOWN); + value.setProperty("TELLSTICK_STOP", TELLSTICK_STOP); + value.setProperty("TELLSTICK_DEVICE_ADDED", TELLSTICK_DEVICE_ADDED); value.setProperty("TELLSTICK_DEVICE_CHANGED", TELLSTICK_DEVICE_CHANGED); value.setProperty("TELLSTICK_DEVICE_REMOVED", TELLSTICK_DEVICE_REMOVED); value.setProperty("TELLSTICK_DEVICE_STATE_CHANGED", TELLSTICK_DEVICE_STATE_CHANGED); - + engine->globalObject().property("com").property("telldus").setProperty("core", value); } }