From 57e74dd4966c2bb0038ddad8c643dda9dbdec140 Mon Sep 17 00:00:00 2001 From: Micke Prag Date: Thu, 10 Jul 2008 09:23:13 +0000 Subject: [PATCH] Added #include to a lot of files --- .../driver/TellUsbD101/DeviceIkea.cpp | 6 ++-- .../driver/TellUsbD101/DeviceNexa.cpp | 28 +++++++++---------- .../driver/TellUsbD101/TellUsbD101.cpp | 17 +++++------ .../driver/TellUsbD101/linux/Device.cpp | 7 +++-- .../TellUsbD101/settings/TelldusSettings.cpp | 18 ++++++------ 5 files changed, 39 insertions(+), 37 deletions(-) diff --git a/telldus-core/driver/TellUsbD101/DeviceIkea.cpp b/telldus-core/driver/TellUsbD101/DeviceIkea.cpp index f80ef8e1..6f0a188f 100644 --- a/telldus-core/driver/TellUsbD101/DeviceIkea.cpp +++ b/telldus-core/driver/TellUsbD101/DeviceIkea.cpp @@ -1,10 +1,10 @@ // #include "StdAfx.h" //Needed? #include "DeviceIkea.h" -#include #include #include #include #include +#include using namespace std; @@ -21,7 +21,7 @@ DeviceIkea::DeviceIkea(char *strSystem, char *strUnits, char *strFadeStyle) } if (strUnits != NULL && strlen(strUnits) > 0) { intUnits = 0; //Start without any units - + char *strTemp = strtok(strUnits, ","); do { int intUnit = atoi(strTemp); @@ -100,7 +100,7 @@ void DeviceIkea::dim(unsigned char level){ * Convert an integer to byte string where 0 is represented by ª and 1 by TT */ string DeviceIkea::getStringCode(unsigned char level){ - + string strReturn = "STTTTTTª"; //Startcode, always like this; try{ diff --git a/telldus-core/driver/TellUsbD101/DeviceNexa.cpp b/telldus-core/driver/TellUsbD101/DeviceNexa.cpp index bbffaeb0..d8392d5b 100644 --- a/telldus-core/driver/TellUsbD101/DeviceNexa.cpp +++ b/telldus-core/driver/TellUsbD101/DeviceNexa.cpp @@ -1,6 +1,6 @@ // #include "StdAfx.h" #include "DeviceNexa.h" -#include +#include #include #include #include @@ -19,7 +19,7 @@ DeviceNexa::DeviceNexa(char *strNewHouse, char *strNewCode) } else { intHouse = 0; } - + if (strNewCode != NULL && strlen(strNewCode) > 0) { intCode = atoi(strNewCode) - 1; } else { @@ -45,10 +45,10 @@ void DeviceNexa::turnOn(void){ string strCode = getStringCode(intHouse); string strUnit = getStringCode(intCode); strCode.append(strUnit); - + strCode.insert(0, "S"); strCode.append("$k$k$kk$$kk$$kk$$k+"); //the "turn on"-code, keeps it like this, doesn't have to be regenerated each time - + char* strMessage = const_cast(strCode.c_str()); Device::send(strMessage); @@ -62,17 +62,17 @@ void DeviceNexa::turnOn(void){ * Turn off this device */ void DeviceNexa::turnOff(void){ - + try{ string strCode = getStringCode(intHouse); string strUnit = getStringCode(intCode); strCode.append(strUnit); - + strCode.insert(0, "S"); strCode.append("$k$k$kk$$kk$$k$k$k+"); //the "turn off"-code, keeps it like this, doesn't have to be regenerated each time - + char* strMessage = const_cast(strCode.c_str()); - + Device::send(strMessage); } catch(...){ @@ -84,16 +84,16 @@ void DeviceNexa::turnOff(void){ * Send a bell */ void DeviceNexa::bell(void){ - + try{ string strCode = getStringCode(intHouse); strCode.append("$kk$$kk$$kk$$k$k"); //the unit-code is always 7, doesn't have to be regenerated each time strCode.insert(0, "S"); strCode.append("$kk$$kk$$kk$$kk$$k+"); //the "bell"-code, keeps it like this, doesn't have to be regenerated each time - + char* strMessage = const_cast(strCode.c_str()); - + Device::send(strMessage); } catch(...){ @@ -105,12 +105,12 @@ void DeviceNexa::bell(void){ * Convert an integer to byte string where 0 is represented by $k and 1 by k$, reversed and padded with 0's as needed */ string DeviceNexa::getStringCode(int intToConvert){ - + string strReturn = ""; try{ bitset<4> bs ((long)intToConvert); - + strReturn = bs.to_string(); reverse(strReturn.begin(), strReturn.end()); @@ -125,7 +125,7 @@ string DeviceNexa::getStringCode(int intToConvert){ strReturn.replace(intPos, 1, "k$"); intPos = (int)strReturn.find("1", intPos + 1); } - + intPos = 0; while (intPos < (int)strReturn.length()){ strReturn.insert(intPos, "$k"); diff --git a/telldus-core/driver/TellUsbD101/TellUsbD101.cpp b/telldus-core/driver/TellUsbD101/TellUsbD101.cpp index 110f3617..010f8ded 100644 --- a/telldus-core/driver/TellUsbD101/TellUsbD101.cpp +++ b/telldus-core/driver/TellUsbD101/TellUsbD101.cpp @@ -10,6 +10,7 @@ #include #include #include +#include void handleException(std::exception e); using namespace std; @@ -22,13 +23,13 @@ using namespace std; //comment (just copy from the called methods) bool WINAPI devTurnOn(int intDeviceId){ - + try{ TelldusSettings ts; Device* dev = ts.getDevice(intDeviceId); if(dev != NULL){ dev->turnOn(); - + delete(dev); return true; } @@ -43,13 +44,13 @@ bool WINAPI devTurnOn(int intDeviceId){ } bool WINAPI devTurnOff(int intDeviceId){ - + try{ TelldusSettings ts; Device* dev = ts.getDevice(intDeviceId); if(dev != NULL){ dev->turnOff(); - + delete(dev); return true; } @@ -64,13 +65,13 @@ bool WINAPI devTurnOff(int intDeviceId){ } bool WINAPI devBell(int intDeviceId){ - + try{ TelldusSettings ts; Device* dev = ts.getDevice(intDeviceId); if(dev != NULL){ dev->bell(); - + delete(dev); return true; } @@ -85,7 +86,7 @@ bool WINAPI devBell(int intDeviceId){ } bool WINAPI devDim(int intDeviceId, unsigned char level){ - + try{ TelldusSettings ts; Device* dev = ts.getDevice(intDeviceId); @@ -225,7 +226,7 @@ bool WINAPI devSetModel(int intDeviceId, const char* strNewModel){ } bool WINAPI devSetArgument(int intDeviceId, const char *strName, const char *strValue){ - + try{ TelldusSettings ts; return ts.setArgument(intDeviceId, strName, strValue); diff --git a/telldus-core/driver/TellUsbD101/linux/Device.cpp b/telldus-core/driver/TellUsbD101/linux/Device.cpp index a0fb3e2b..98e9ca5d 100644 --- a/telldus-core/driver/TellUsbD101/linux/Device.cpp +++ b/telldus-core/driver/TellUsbD101/linux/Device.cpp @@ -2,6 +2,7 @@ #include #include #include +#include /* * Send message to the USB dongle @@ -9,11 +10,11 @@ void Device::send(char* strMessage) { int fd = -1; struct termios tio; - + if( 0 > ( fd = open( strDevice, O_RDWR ) ) ) { return; } - + /* adjust serial port parameters */ bzero(&tio, sizeof(tio)); /* clear struct for new port settings */ tio.c_cflag = B4800 | CS8 | CLOCAL | CREAD; /* CREAD not used yet */ @@ -23,7 +24,7 @@ void Device::send(char* strMessage) { tcsetattr(fd,TCSANOW,&tio); write(fd, strMessage, strlen(strMessage)); - + close(fd); } diff --git a/telldus-core/driver/TellUsbD101/settings/TelldusSettings.cpp b/telldus-core/driver/TellUsbD101/settings/TelldusSettings.cpp index a106a9c3..2ace6e18 100644 --- a/telldus-core/driver/TellUsbD101/settings/TelldusSettings.cpp +++ b/telldus-core/driver/TellUsbD101/settings/TelldusSettings.cpp @@ -3,7 +3,7 @@ #include "../DeviceWaveman.h" #include "../DeviceSartano.h" #include "../DeviceIkea.h" - +#include /* * Get the requested device @@ -12,39 +12,39 @@ Device* TelldusSettings::getDevice(int intDeviceId){ Device* dev = NULL; - + try{ char* vendor = getVendor(intDeviceId); - + //each new brand must be added here if (strcmp(vendor, "Nexa") == 0){ char *strHouse = getArgument(intDeviceId, "nexa_house"); char *strCode = getArgument(intDeviceId, "nexa_unit"); dev = new DeviceNexa(strHouse, strCode); - + } else if (strcmp(vendor, "Waveman") == 0) { char *strHouse = getArgument(intDeviceId, "nexa_house"); char *strCode = getArgument(intDeviceId, "nexa_unit"); dev = new DeviceWaveman(strHouse, strCode); - + } else if (strcmp(vendor, "Sartano") == 0) { char *strCode = getArgument(intDeviceId, "sartano_code"); dev = new DeviceSartano(strCode); - + } else if (strcmp(vendor, "Ikea") == 0) { char *strSystem = getArgument(intDeviceId, "ikea_system"); char *strUnits = getArgument(intDeviceId, "ikea_units"); char *strFade = getArgument(intDeviceId, "ikea_fade"); dev = new DeviceIkea(strSystem, strUnits, strFade); - + } else { return NULL; } - + #ifndef _WINDOWS dev->setDevice( getSetting("deviceNode") ); #endif - + } catch(...){ throw;