From 08c02530a6a4d60236532fd16fbb410d86899652 Mon Sep 17 00:00:00 2001 From: Micke Prag Date: Fri, 8 Feb 2008 15:52:06 +0000 Subject: [PATCH] Removed function bool devHasMethod(int id, int method) and replaced with int devMethods(int id) --- driver/TellUsbD101/Device.cpp | 6 +++--- driver/TellUsbD101/Device.h | 2 +- driver/TellUsbD101/DeviceIkea.cpp | 8 +++----- driver/TellUsbD101/DeviceIkea.h | 2 +- driver/TellUsbD101/DeviceNexa.cpp | 12 ++++-------- driver/TellUsbD101/DeviceNexa.h | 2 +- driver/TellUsbD101/DeviceSartano.cpp | 17 ++--------------- driver/TellUsbD101/DeviceSartano.h | 2 +- driver/TellUsbD101/DeviceWaveman.cpp | 17 ++--------------- driver/TellUsbD101/DeviceWaveman.h | 2 +- driver/TellUsbD101/TellUsbD101.cpp | 10 +++++----- driver/TellUsbD101/TellUsbD101.def | 2 +- driver/TellUsbD101/TellUsbD101.h | 2 +- 13 files changed, 26 insertions(+), 58 deletions(-) diff --git a/driver/TellUsbD101/Device.cpp b/driver/TellUsbD101/Device.cpp index 3d6a6322..0281375a 100644 --- a/driver/TellUsbD101/Device.cpp +++ b/driver/TellUsbD101/Device.cpp @@ -45,8 +45,8 @@ void Device::dim(unsigned char level){ } /* -* Has Method, virtual +* Methods, virtual */ -bool Device::hasMethod(int methodname, char* strModel){ - return false; +int Device::methods(char* strModel){ + return 0; } diff --git a/driver/TellUsbD101/Device.h b/driver/TellUsbD101/Device.h index 4f4e5f1d..f4aec627 100644 --- a/driver/TellUsbD101/Device.h +++ b/driver/TellUsbD101/Device.h @@ -14,7 +14,7 @@ public: virtual void turnOff(void); virtual void bell(void); virtual void dim(unsigned char level); - virtual bool hasMethod(int methodname, char* strModel); + virtual int methods(char* strModel); static int getDongleIndex(); static void debugLog(char* debugstring); diff --git a/driver/TellUsbD101/DeviceIkea.cpp b/driver/TellUsbD101/DeviceIkea.cpp index a32f00ff..c83f1a50 100644 --- a/driver/TellUsbD101/DeviceIkea.cpp +++ b/driver/TellUsbD101/DeviceIkea.cpp @@ -130,12 +130,10 @@ string DeviceIkea::getStringCode(unsigned char level){ /* * Has the device got the method? */ -bool DeviceIkea::hasMethod(int methodname, char* strModel){ +int DeviceIkea::methods(char* strModel){ if(strcmp(strModel, TELLSTICK_DEVICE_KOPPLA) == 0) { - if(methodname == TELLSTICK_TURNON || methodname == TELLSTICK_TURNOFF || methodname == TELLSTICK_DIM){ - return true; - } + return (TELLSTICK_TURNON | TELLSTICK_TURNOFF | TELLSTICK_DIM); } - return false; + return 0; } diff --git a/driver/TellUsbD101/DeviceIkea.h b/driver/TellUsbD101/DeviceIkea.h index bbe34c75..4a672653 100644 --- a/driver/TellUsbD101/DeviceIkea.h +++ b/driver/TellUsbD101/DeviceIkea.h @@ -9,7 +9,7 @@ public: virtual void turnOn(void); virtual void turnOff(void); virtual void dim(unsigned char level); - virtual bool hasMethod(int methodname, char* strModel); + virtual int methods(char* strModel); public: ~DeviceIkea(void); diff --git a/driver/TellUsbD101/DeviceNexa.cpp b/driver/TellUsbD101/DeviceNexa.cpp index 4deb98d7..97a194fc 100644 --- a/driver/TellUsbD101/DeviceNexa.cpp +++ b/driver/TellUsbD101/DeviceNexa.cpp @@ -132,7 +132,7 @@ string DeviceNexa::getStringCode(int intToConvert){ /* * Has the device got the method? */ -bool DeviceNexa::hasMethod(int methodname, char* strModel){ +int DeviceNexa::methods(char* strModel){ if( strcmp(strModel, TELLSTICK_DEVICE_YCR3500) == 0 || strcmp(strModel, TELLSTICK_DEVICE_YCR300D) == 0 || @@ -151,13 +151,9 @@ bool DeviceNexa::hasMethod(int methodname, char* strModel){ strcmp(strModel, TELLSTICK_DEVICE_EL2010) == 0 ) { - if(methodname == TELLSTICK_TURNON || methodname == TELLSTICK_TURNOFF){ - return true; - } + return (TELLSTICK_TURNON | TELLSTICK_TURNOFF); } else if ( strcmp(strModel, TELLSTICK_DEVICE_ML7100) == 0 ) { - if(methodname == TELLSTICK_BELL) { - return true; - } + return TELLSTICK_BELL; } - return false; + return 0; } diff --git a/driver/TellUsbD101/DeviceNexa.h b/driver/TellUsbD101/DeviceNexa.h index 9ae10a72..abe8fa0d 100644 --- a/driver/TellUsbD101/DeviceNexa.h +++ b/driver/TellUsbD101/DeviceNexa.h @@ -9,7 +9,7 @@ public: virtual void turnOn(void); virtual void turnOff(void); virtual void bell(void); - virtual bool hasMethod(int methodname, char* strModel); + virtual int methods(char* strModel); public: ~DeviceNexa(void); diff --git a/driver/TellUsbD101/DeviceSartano.cpp b/driver/TellUsbD101/DeviceSartano.cpp index c06a7f0b..1f38a2dc 100644 --- a/driver/TellUsbD101/DeviceSartano.cpp +++ b/driver/TellUsbD101/DeviceSartano.cpp @@ -72,21 +72,8 @@ void DeviceSartano::turnOff(void){ /* * Has the device got the method? */ -bool DeviceSartano::hasMethod(int methodname, char* strModel){ - - bool blnExists = false; - - try{ -// if(strModel == "xxxx" || strModel == "yyyy"){ - if(methodname == TELLSTICK_TURNON || methodname == TELLSTICK_TURNOFF){ - blnExists = true; -// } - } - } - catch(...){ - throw; - } - return blnExists; +int DeviceSartano::methods(char* strModel){ + return (TELLSTICK_TURNON | TELLSTICK_TURNOFF); } /* diff --git a/driver/TellUsbD101/DeviceSartano.h b/driver/TellUsbD101/DeviceSartano.h index 929cf32d..c7c86324 100644 --- a/driver/TellUsbD101/DeviceSartano.h +++ b/driver/TellUsbD101/DeviceSartano.h @@ -9,7 +9,7 @@ public: DeviceSartano(int intSystem, int intCode, int intDeviceIndex); virtual void turnOn(void); virtual void turnOff(void); - virtual bool hasMethod(int methodname, char* strModel); + virtual int methods(char* strModel); ~DeviceSartano(void); diff --git a/driver/TellUsbD101/DeviceWaveman.cpp b/driver/TellUsbD101/DeviceWaveman.cpp index dbbf3f69..855afe5c 100644 --- a/driver/TellUsbD101/DeviceWaveman.cpp +++ b/driver/TellUsbD101/DeviceWaveman.cpp @@ -40,19 +40,6 @@ void DeviceWaveman::turnOff(void){ /* * Has the device got the method? */ -bool DeviceWaveman::hasMethod(int methodname, char* strModel){ - - bool blnExists = false; - - try{ -// if(strModel == "xxxx" || strModel == "yyyy"){ - if(methodname == TELLSTICK_TURNON || methodname == TELLSTICK_TURNOFF){ - blnExists = true; -// } - } - } - catch(...){ - throw; - } - return blnExists; +int DeviceWaveman::methods(char* strModel){ + return (TELLSTICK_TURNON | TELLSTICK_TURNOFF); } diff --git a/driver/TellUsbD101/DeviceWaveman.h b/driver/TellUsbD101/DeviceWaveman.h index ab013172..c099a563 100644 --- a/driver/TellUsbD101/DeviceWaveman.h +++ b/driver/TellUsbD101/DeviceWaveman.h @@ -7,5 +7,5 @@ class DeviceWaveman : public DeviceNexa public: DeviceWaveman(int intHouse, int intCode, int intDeviceIndex); virtual void turnOff(void); - virtual bool hasMethod(int methodname, char* strModel); + virtual int methods(char* strModel); }; diff --git a/driver/TellUsbD101/TellUsbD101.cpp b/driver/TellUsbD101/TellUsbD101.cpp index c2945454..abae47c4 100644 --- a/driver/TellUsbD101/TellUsbD101.cpp +++ b/driver/TellUsbD101/TellUsbD101.cpp @@ -285,22 +285,22 @@ bool __stdcall devRemoveDevice(int intDeviceId){ return blnSuccess; } -bool __stdcall devHasMethod(int id, int methodname){ +int __stdcall devMethods(int id){ - bool blnExists = false; + int intMethods = 0; try{ TelldusSettings ts; char* strModel = ts.getModel(id); Device* dev = ts.getDevice(id); if (dev != NULL) { - blnExists = dev->hasMethod(methodname, strModel); + intMethods = dev->methods(strModel); } } catch(exception e){ - blnExists = false; + intMethods = 0; handleException(e); } - return blnExists; + return intMethods; } diff --git a/driver/TellUsbD101/TellUsbD101.def b/driver/TellUsbD101/TellUsbD101.def index e79daad8..fc32ffca 100644 --- a/driver/TellUsbD101/TellUsbD101.def +++ b/driver/TellUsbD101/TellUsbD101.def @@ -17,7 +17,7 @@ EXPORTS devAddDevice @12 devRemoveDevice @13 - devHasMethod @14 + devMethods @14 devTurnOn @16 devTurnOff @17 devBell @18 diff --git a/driver/TellUsbD101/TellUsbD101.h b/driver/TellUsbD101/TellUsbD101.h index a5aeb6b8..8227ae1f 100644 --- a/driver/TellUsbD101/TellUsbD101.h +++ b/driver/TellUsbD101/TellUsbD101.h @@ -40,7 +40,7 @@ extern "C" { TELLSTICK_API int WINAPI devAddDeviceWithArguments(char* strVendor, int* intArguments[], int intNumberOfArguments); TELLSTICK_API bool WINAPI devRemoveDevice(int intDeviceId); TELLSTICK_API int WINAPI devGetDeviceId(int intDeviceIndex); - TELLSTICK_API bool WINAPI devHasMethod(int id, int methodname); + TELLSTICK_API int WINAPI devMethods(int id); } #define TELLSTICK_TURNON 1