Exported tdUp(), tdDown() and tdStop() to the script engine

This commit is contained in:
Micke Prag 2011-02-24 10:20:12 +00:00
parent 18b56f2069
commit 75affe3f5c
3 changed files with 38 additions and 8 deletions

View file

@ -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 );

View file

@ -28,6 +28,9 @@ public slots:
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 );

View file

@ -21,6 +21,9 @@ 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);