From e82cd232fcd3216210109b480918fbb9fb70ebe6 Mon Sep 17 00:00:00 2001 From: Micke Prag Date: Thu, 17 Jun 2010 09:10:33 +0000 Subject: [PATCH] Added branding-options to TelldusCore 2.0. --- CMakeLists.txt | 1 + driver/libtelldus-core/CMakeLists.txt | 6 +++++ driver/libtelldus-core/Manager.cpp | 34 ++++++++++++++++++--------- driver/libtelldus-core/config.h.in | 18 ++++++++++++++ 4 files changed, 48 insertions(+), 11 deletions(-) create mode 100644 driver/libtelldus-core/config.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 090a66e5..1bd962d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ SET(BUILD_RFCMD_WITH_LIBFTDI FALSE CACHE BOOL "Enable support for using rfcmd wi SET(BUILD_TDTOOL TRUE CACHE BOOL "Build tdtool") SET(GENERATE_MAN FALSE CACHE BOOL "Enable generation of man-files") +SET(BRANDING "telldus" CACHE STRING "The brand to use") ADD_SUBDIRECTORY(driver) diff --git a/driver/libtelldus-core/CMakeLists.txt b/driver/libtelldus-core/CMakeLists.txt index 3f2957d1..2a081a37 100644 --- a/driver/libtelldus-core/CMakeLists.txt +++ b/driver/libtelldus-core/CMakeLists.txt @@ -28,6 +28,7 @@ SET( telldus-core_SRCS SET( telldus-core_HDRS telldus-core.h + ${CMAKE_CURRENT_BINARY_DIR}/include/config.h ) SET( telldus-core_MOC_HDRS @@ -50,6 +51,11 @@ IF (SUPPORT_USB) ) ENDIF (SUPPORT_USB) +CONFIGURE_FILE( + ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in + ${CMAKE_CURRENT_BINARY_DIR}/include/config.h +) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/include) ######## Configurable options for the platform ######## diff --git a/driver/libtelldus-core/Manager.cpp b/driver/libtelldus-core/Manager.cpp index 55cb3892..4c9f35e4 100644 --- a/driver/libtelldus-core/Manager.cpp +++ b/driver/libtelldus-core/Manager.cpp @@ -29,6 +29,7 @@ #include "TellStick.h" #endif #include "common.h" +#include "config.h" #include #include @@ -84,54 +85,65 @@ Device *Manager::getDevice(int intDeviceId){ std::string strName = settings.getName(intDeviceId); //each new brand must be added here - if (strcasecmp(protocol.c_str(), "arctech") == 0){ + if (0) { +#ifdef PROTOCOL_ARCTECH + } else if (strcasecmp(protocol.c_str(), "arctech") == 0){ dev = new DeviceNexa(intDeviceId, strModel, strName); ((DeviceNexa*)dev)->setHouse(settings.getDeviceParameter(intDeviceId, "house")); ((DeviceNexa*)dev)->setUnit(settings.getDeviceParameter(intDeviceId, "unit")); - +#endif +#ifdef PROTOCOL_BRATECK } else if (strcasecmp(protocol.c_str(), "brateck") == 0) { dev = new DeviceBrateck(intDeviceId, strModel, strName); ((DeviceBrateck*)dev)->setHouse(settings.getDeviceParameter(intDeviceId, "house")); - +#endif +#ifdef PROTOCOL_EVERFLOURISH } else if (strcasecmp(protocol.c_str(), "everflourish") == 0){ dev = new DeviceEverflourish(intDeviceId, strModel, strName); ((DeviceEverflourish*)dev)->setHouse(settings.getDeviceParameter(intDeviceId, "house")); ((DeviceEverflourish*)dev)->setUnit(settings.getDeviceParameter(intDeviceId, "unit")); - +#endif +#ifdef PROTOCOL_GROUP } else if (strcasecmp(protocol.c_str(), "group") == 0) { dev = new DeviceGroup(intDeviceId, strModel, strName); ((DeviceGroup*)dev)->setDevices(settings.getDeviceParameter(intDeviceId, "devices")); - +#endif +#ifdef PROTOCOL_RISINGSUN } else if (strcasecmp(protocol.c_str(), "risingsun") == 0) { dev = new DeviceRisingSun(intDeviceId, strModel, strName); ((DeviceRisingSun*)dev)->setHouse(settings.getDeviceParameter(intDeviceId, "house")); ((DeviceRisingSun*)dev)->setUnit(settings.getDeviceParameter(intDeviceId, "unit")); - +#endif +#ifdef PROTOCOL_WAVEMAN } else if (strcasecmp(protocol.c_str(), "Waveman") == 0) { dev = new DeviceWaveman(intDeviceId, strModel, strName); ((DeviceWaveman*)dev)->setHouse(settings.getDeviceParameter(intDeviceId, "house")); ((DeviceWaveman*)dev)->setUnit(settings.getDeviceParameter(intDeviceId, "unit")); - +#endif +#ifdef PROTOCOL_SARTANO } else if (strcasecmp(protocol.c_str(), "Sartano") == 0) { dev = new DeviceSartano(intDeviceId, strModel, strName); ((DeviceSartano*)dev)->setCode(settings.getDeviceParameter(intDeviceId, "code")); - +#endif +#ifdef PROTOCOL_IKEA } else if (strcasecmp(protocol.c_str(), "Ikea") == 0) { dev = new DeviceIkea(intDeviceId, strModel, strName); ((DeviceIkea*)dev)->setSystem(settings.getDeviceParameter(intDeviceId, "system")); ((DeviceIkea*)dev)->setUnits(settings.getDeviceParameter(intDeviceId, "units")); ((DeviceIkea*)dev)->setFade(settings.getDeviceParameter(intDeviceId, "fade")); - +#endif +#ifdef PROTOCOL_UPM } else if (strcasecmp(protocol.c_str(), "upm") == 0) { dev = new DeviceUpm(intDeviceId, strModel, strName); ((DeviceUpm*)dev)->setHouse(settings.getDeviceParameter(intDeviceId, "house")); ((DeviceUpm*)dev)->setUnit(settings.getDeviceParameter(intDeviceId, "unit")); - +#endif +#ifdef PROTOCOL_X10 } else if (strcasecmp(protocol.c_str(), "x10") == 0) { dev = new DeviceX10(intDeviceId, strModel, strName); ((DeviceX10*)dev)->setHouse(settings.getDeviceParameter(intDeviceId, "house")); ((DeviceX10*)dev)->setUnit(settings.getDeviceParameter(intDeviceId, "unit")); - +#endif } else { //This is a dummy device needed when the parameters isn't setup correctly. dev = new DeviceUndefined(intDeviceId, strModel, strName); diff --git a/driver/libtelldus-core/config.h.in b/driver/libtelldus-core/config.h.in new file mode 100644 index 00000000..36c254f7 --- /dev/null +++ b/driver/libtelldus-core/config.h.in @@ -0,0 +1,18 @@ + +#define BRANDING "${BRANDING}" +#define BRANDING_${BRANDING} + +#ifdef BRANDING_chacon + #define PROTOCOL_ARCTECH +#else + #define PROTOCOL_ARCTECH + #define PROTOCOL_BRATECK + #define PROTOCOL_EVERFLOURISH + #define PROTOCOL_GROUP + #define PROTOCOL_RISINGSUN + #define PROTOCOL_WAVEMAN + #define PROTOCOL_SARTANO + #define PROTOCOL_IKEA + #define PROTOCOL_UPM + #define PROTOCOL_X10 +#endif \ No newline at end of file