Should have a space between // and comment "whitespace/comments"

This commit is contained in:
Micke Prag 2012-02-28 22:20:03 +01:00
parent e1608f94a8
commit 75f21588e5
39 changed files with 225 additions and 224 deletions

View file

@ -33,7 +33,7 @@ CallbackMainDispatcher::CallbackMainDispatcher()
d = new PrivateData;
d->stopEvent = d->eventHandler.addEvent();
d->generalCallbackEvent = d->eventHandler.addEvent();
d->janitor = d->eventHandler.addEvent(); //Used for cleanups
d->janitor = d->eventHandler.addEvent(); // Used for cleanups
d->lastCallbackId = 0;
}
@ -77,7 +77,7 @@ int CallbackMainDispatcher::unregisterCallback(int callbackId) {
}
if (newEventList.size()) {
CallbackList::iterator it = newEventList.begin();
{ //Lock and unlock to make sure no one else uses the object
{ // Lock and unlock to make sure no one else uses the object
TelldusCore::MutexLocker locker( &(*it)->mutex );
}
delete (*it);
@ -109,7 +109,7 @@ void CallbackMainDispatcher::run() {
}
}
if (d->janitor->isSignaled()) {
//Clear all of them if there is more than one
// Clear all of them if there is more than one
while(d->janitor->isSignaled()) {
d->janitor->popSignal();
}
@ -121,7 +121,7 @@ void CallbackMainDispatcher::run() {
void CallbackMainDispatcher::cleanupCallbacks() {
bool again = false;
//Device Event
// Device Event
do {
again = false;
MutexLocker locker(&d->mutex);

View file

@ -96,7 +96,7 @@ void Client::run() {
}
}
std::wstring clientMessage = d->eventSocket.read(1000); //testing 5 second timeout
std::wstring clientMessage = d->eventSocket.read(1000); // testing 5 second timeout
while(clientMessage != L"") {
// a message arrived
@ -140,7 +140,7 @@ void Client::run() {
d->callbackMainDispatcher.retrieveCallbackEvent()->signal(data);
} else {
clientMessage = L""; //cleanup, if message contained garbage/unhandled data
clientMessage = L""; // cleanup, if message contained garbage/unhandled data
}
}
}
@ -159,25 +159,25 @@ std::wstring Client::sendToService(const Message &msg) {
}
Socket s;
s.connect(L"TelldusClient");
if (!s.isConnected()) { //Connection failed
if (!s.isConnected()) { // Connection failed
msleep(500);
continue; //retry
continue; // retry
}
s.write(msg.data());
if (!s.isConnected()) { //Connection failed sometime during operation... (better check here, instead of 5 seconds timeout later)
if (!s.isConnected()) { // Connection failed sometime during operation... (better check here, instead of 5 seconds timeout later)
msleep(500);
continue; //retry
continue; // retry
}
readData = s.read(8000); // TODO changed to 10000 from 5000, how much does this do...?
if(readData == L"") {
msleep(500);
continue; //TODO can we be really sure it SHOULD be anything?
//TODO perhaps break here instead?
continue; // TODO can we be really sure it SHOULD be anything?
// TODO perhaps break here instead?
}
if (!s.isConnected()) { //Connection failed sometime during operation...
if (!s.isConnected()) { // Connection failed sometime during operation...
msleep(500);
continue; //retry
continue; // retry
}
break;
}

View file

@ -319,7 +319,7 @@ using namespace TelldusCore;
* @since Version 2.0.0
**/
void WINAPI tdInit(void) {
Client::getInstance(); //Create the manager-object
Client::getInstance(); // Create the manager-object
}
/**
@ -1023,7 +1023,7 @@ char * WINAPI tdGetErrorString(int intErrorNo) {
"Syntax error in the configuration file"
};
std::string strReturn;
intErrorNo = abs(intErrorNo); //We don't use negative values here.
intErrorNo = abs(intErrorNo); // We don't use negative values here.
if (intErrorNo >= numResponses) {
strReturn = "Unknown error";
} else {

View file

@ -103,7 +103,7 @@ extern "C" {
}
#endif
//Device methods
// Device methods
#define TELLSTICK_TURNON 1
#define TELLSTICK_TURNOFF 2
#define TELLSTICK_BELL 4
@ -115,11 +115,11 @@ extern "C" {
#define TELLSTICK_DOWN 256
#define TELLSTICK_STOP 512
//Sensor value types
// Sensor value types
#define TELLSTICK_TEMPERATURE 1
#define TELLSTICK_HUMIDITY 2
//Error codes
// Error codes
#define TELLSTICK_SUCCESS 0
#define TELLSTICK_ERROR_NOT_FOUND -1
#define TELLSTICK_ERROR_PERMISSION_DENIED -2
@ -134,23 +134,23 @@ extern "C" {
#define TELLSTICK_ERROR_CONFIG_SYNTAX -11
#define TELLSTICK_ERROR_UNKNOWN -99
//Device typedef
// Device typedef
#define TELLSTICK_TYPE_DEVICE 1
#define TELLSTICK_TYPE_GROUP 2
#define TELLSTICK_TYPE_SCENE 3
//Controller typedef
// Controller typedef
#define TELLSTICK_CONTROLLER_TELLSTICK 1
#define TELLSTICK_CONTROLLER_TELLSTICK_DUO 2
#define TELLSTICK_CONTROLLER_TELLSTICK_NET 3
//Device changes
// Device changes
#define TELLSTICK_DEVICE_ADDED 1
#define TELLSTICK_DEVICE_CHANGED 2
#define TELLSTICK_DEVICE_REMOVED 3
#define TELLSTICK_DEVICE_STATE_CHANGED 4
//Change types
// Change types
#define TELLSTICK_CHANGE_NAME 1
#define TELLSTICK_CHANGE_PROTOCOL 2
#define TELLSTICK_CHANGE_MODEL 3

View file

@ -34,7 +34,7 @@ EventHandler::~EventHandler(void) {
std::list<EventRef>::const_iterator it = d->eventList.begin();
for(; it != d->eventList.end(); ++it) {
//We clear the handler if someone else still has a reference to the event
// We clear the handler if someone else still has a reference to the event
(*it)->clearHandler();
}
@ -62,7 +62,7 @@ bool EventHandler::listIsSignalled() {
void EventHandler::signal(Event *event) {
pthread_mutex_lock(&d->mutex);
//event->setSignaled();
// event->setSignaled();
pthread_cond_signal(&d->event);
pthread_mutex_unlock(&d->mutex);
}

View file

@ -27,18 +27,18 @@ Message::~Message(void) {
}
void Message::addArgument(const std::wstring &value) {
//std::wstringstream st;
//st << (int)value.size();
this->append(TelldusCore::intToWstring(value.size())); //st.str());
// std::wstringstream st;
// st << (int)value.size();
this->append(TelldusCore::intToWstring(value.size())); // st.str());
this->append(L":");
this->append(value);
}
void Message::addArgument(int value) {
//std::wstringstream st;
//st << (int)value;
// std::wstringstream st;
// st << (int)value;
this->append(L"i");
this->append(TelldusCore::intToWstring(value)); // st.str());
this->append(TelldusCore::intToWstring(value)); // st.str());
this->append(L"s");
}

View file

@ -17,9 +17,9 @@ namespace TelldusCore {
~Message(void);
void addArgument(const std::wstring &);
//void addSpecialArgument(const std::wstring &);
//void addSpecialArgument(int);
//void addSpecialArgument(const char *);
// void addSpecialArgument(const std::wstring &);
// void addSpecialArgument(int);
// void addSpecialArgument(const char *);
void addArgument(int);
void addArgument(const char *);

View file

@ -22,7 +22,7 @@ namespace TelldusCore {
virtual void unlock();
private:
Mutex(const Mutex&); //Disable copy
Mutex(const Mutex&); // Disable copy
Mutex& operator = (const Mutex&);
class PrivateData;
PrivateData *d;

View file

@ -35,4 +35,5 @@ namespace TelldusCore {
PrivateData *d;
};
}
#endif // TELLDUS_CORE_COMMON_SOCKET_H_

View file

@ -121,7 +121,7 @@ std::wstring Socket::read(int timeout) {
void Socket::stopReadWait() {
TelldusCore::MutexLocker locker(&d->mutex);
d->connected = false;
//TODO somehow signal the socket here?
// TODO somehow signal the socket here?
}
void Socket::write(const std::wstring &msg) {

View file

@ -26,7 +26,7 @@
std::wstring TelldusCore::charToWstring(const char *value) {
#ifdef _WINDOWS
//Determine size
// Determine size
int size = MultiByteToWideChar(CP_UTF8, 0, value, -1, NULL, 0);
if (size == 0) {
return L"";
@ -44,11 +44,11 @@ std::wstring TelldusCore::charToWstring(const char *value) {
size_t utf8Length = strlen(value);
size_t outbytesLeft = utf8Length*sizeof(wchar_t);
//Copy the instring
// Copy the instring
char *inString = new char[utf8Length+1];
strcpy(inString, value);
//Create buffer for output
// Create buffer for output
char *outString = (char*)new wchar_t[utf8Length+1];
memset(outString, 0, sizeof(wchar_t)*(utf8Length+1));
@ -65,7 +65,7 @@ std::wstring TelldusCore::charToWstring(const char *value) {
std::wstring retval( (wchar_t *)outString );
//Cleanup
// Cleanup
delete[] inString;
delete[] outString;
@ -99,17 +99,17 @@ bool TelldusCore::comparei(std::wstring stringA, std::wstring stringB) {
std::wstring TelldusCore::intToWstring(int value) {
#ifdef _WINDOWS
//no stream used
//TODO! Make effective and safe...
wchar_t numstr[21]; // enough to hold all numbers up to 64-bits
// no stream used
// TODO! Make effective and safe...
wchar_t numstr[21]; // enough to hold all numbers up to 64-bits
_itow_s(value, numstr, sizeof(numstr), 10);
std::wstring newstring(numstr);
return newstring;
//return TelldusCore::charToWstring(stdstring.c_str());
//std::wstring temp = TelldusCore::charToWstring(stdstring.c_str());
//std::wstring temp(stdstring.length(), L' ');
//std::copy(stdstring.begin(), stdstring.end(), temp.begin());
//return temp;
// return TelldusCore::charToWstring(stdstring.c_str());
// std::wstring temp = TelldusCore::charToWstring(stdstring.c_str());
// std::wstring temp(stdstring.length(), L' ');
// std::copy(stdstring.begin(), stdstring.end(), temp.begin());
// return temp;
#else
std::wstringstream st;
st << value;
@ -118,9 +118,9 @@ std::wstring TelldusCore::intToWstring(int value) {
}
std::string TelldusCore::intToString(int value) {
//Not sure if this is neecssary (for ordinary stringstream that is)
// Not sure if this is neecssary (for ordinary stringstream that is)
#ifdef _WINDOWS
char numstr[21]; // enough to hold all numbers up to 64-bits
char numstr[21]; // enough to hold all numbers up to 64-bits
_itoa_s(value, numstr, sizeof(numstr), 10);
std::string stdstring(numstr);
return stdstring;
@ -170,7 +170,7 @@ int TelldusCore::wideToInteger(const std::wstring &input) {
std::string TelldusCore::wideToString(const std::wstring &input) {
#ifdef _WINDOWS
//Determine size
// Determine size
int size = WideCharToMultiByte(CP_UTF8, 0, input.c_str(), -1, NULL, 0, NULL, NULL);
if (size == 0) {
return "";
@ -186,13 +186,13 @@ std::string TelldusCore::wideToString(const std::wstring &input) {
#else
size_t wideSize = sizeof(wchar_t)*input.length();
size_t outbytesLeft = wideSize+sizeof(char); //We cannot know how many wide character there is yet
size_t outbytesLeft = wideSize+sizeof(char); // We cannot know how many wide character there is yet
//Copy the instring
// Copy the instring
char *inString = (char*)new wchar_t[input.length()+1];
memcpy(inString, input.c_str(), wideSize+sizeof(wchar_t));
//Create buffer for output
// Create buffer for output
char *outString = new char[outbytesLeft];
memset(outString, 0, sizeof(char)*(outbytesLeft));
@ -209,7 +209,7 @@ std::string TelldusCore::wideToString(const std::wstring &input) {
std::string retval(outString);
//Cleanup
// Cleanup
delete[] inString;
delete[] outString;
@ -226,7 +226,7 @@ std::string TelldusCore::formatf(const char *format, ...) {
}
std::string TelldusCore::sformatf(const char *format, va_list ap) {
//This code is based on code from the Linux man-pages project (man vsprintf)
// This code is based on code from the Linux man-pages project (man vsprintf)
int n;
int size = 100; /* Guess we need no more than 100 bytes. */
char *p, *np;

View file

@ -25,7 +25,7 @@ namespace TelldusCore {
bool comparei(std::wstring stringA, std::wstring stringB);
std::wstring intToWstring(int value);
//std::wstring intToWStringSafe(int value);
// std::wstring intToWStringSafe(int value);
std::string intToString(int value);
uint64_t hexTo64l(const std::string data);
std::string wideToString(const std::wstring &input);

View file

@ -61,7 +61,7 @@ void ClientCommunicationHandler::run() {
msg.append(L"\n");
d->clientSocket->write(msg);
//We are done, signal for removal
// We are done, signal for removal
d->done = true;
d->event->signal();
}
@ -74,7 +74,7 @@ bool ClientCommunicationHandler::isDone() {
void ClientCommunicationHandler::parseMessage(const std::wstring &clientMessage, int *intReturn, std::wstring *wstringReturn) {
(*intReturn) = 0;
(*wstringReturn) = L"";
std::wstring msg(clientMessage); //Copy
std::wstring msg(clientMessage); // Copy
std::wstring function(TelldusCore::Message::takeString(&msg));
if (function == L"tdTurnOn") {

View file

@ -45,7 +45,7 @@ ConnectionListener::~ConnectionListener(void) {
void ConnectionListener::run() {
struct timeval tv = { 0, 0 };
//Timeout for select
// Timeout for select
SOCKET_T serverSocket;
struct sockaddr_un name;
@ -62,7 +62,7 @@ void ConnectionListener::run() {
bind(serverSocket, (struct sockaddr *)&name, size);
listen(serverSocket, 5);
//Change permissions to allow everyone
// Change permissions to allow everyone
chmod(d->name.c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
len = sizeof(struct sockaddr_un);
@ -80,7 +80,7 @@ void ConnectionListener::run() {
} else if (response < 0 ) {
continue;
}
//Make sure it is a new connection
// Make sure it is a new connection
if (!FD_ISSET(serverSocket, &infds)) {
continue;
}

View file

@ -55,11 +55,11 @@ ControllerManager::~ControllerManager() {
}
void ControllerManager::deviceInsertedOrRemoved(int vid, int pid, const std::string &serial, bool inserted) {
if (vid == 0x0 && pid == 0x0) { //All
if (vid == 0x0 && pid == 0x0) { // All
if (inserted) {
loadControllers();
} else {
//Disconnect all
// Disconnect all
TelldusCore::MutexLocker locker(&d->mutex);
while(d->controllers.size()) {
ControllerMap::iterator it = d->controllers.begin();
@ -79,7 +79,7 @@ void ControllerManager::deviceInsertedOrRemoved(int vid, int pid, const std::str
if (inserted) {
loadControllers();
} else {
//Autodetect which has been disconnected
// Autodetect which has been disconnected
TelldusCore::MutexLocker locker(&d->mutex);
for(ControllerMap::iterator it = d->controllers.begin(); it != d->controllers.end(); ++it) {
if (!it->second.controller) {
@ -117,7 +117,7 @@ Controller *ControllerManager::getBestControllerById(int id) {
if (it != d->controllers.end() && it->second.controller) {
return it->second.controller;
}
//Find first available controller
// Find first available controller
for(it = d->controllers.begin(); it != d->controllers.end(); ++it) {
if (it->second.controller) {
return it->second.controller;
@ -134,8 +134,8 @@ void ControllerManager::loadControllers() {
std::list<TellStickDescriptor>::iterator it = list.begin();
for(; it != list.end(); ++it) {
//Most backend only report non-opened devices.
//If they don't make sure we don't open them twice
// Most backend only report non-opened devices.
// If they don't make sure we don't open them twice
bool found = false;
ControllerMap::const_iterator cit = d->controllers.begin();
for(; cit != d->controllers.end(); ++cit) {
@ -160,7 +160,7 @@ void ControllerManager::loadControllers() {
type = TELLSTICK_CONTROLLER_TELLSTICK_DUO;
}
int controllerId = 0;
//See if the controller matches one of the loaded, non available controllers
// See if the controller matches one of the loaded, non available controllers
std::wstring serial = TelldusCore::charToWstring((*it).serial.c_str());
for(cit = d->controllers.begin(); cit != d->controllers.end(); ++cit) {
if (cit->second.type == type && cit->second.serial.compare(serial) == 0) {
@ -182,7 +182,7 @@ void ControllerManager::loadControllers() {
d->settings.setControllerSerial(controllerId, d->controllers[controllerId].serial);
}
//int controllerId = d->lastControllerId+1;
// int controllerId = d->lastControllerId+1;
TellStick *controller = new TellStick(controllerId, d->event, d->updateEvent, *it);
if (!controller->isOpen()) {
delete controller;
@ -251,10 +251,10 @@ void ControllerManager::queryControllerStatus() {
int ControllerManager::resetController(Controller *controller) {
TellStick *tellstick = reinterpret_cast<TellStick*>(controller);
if (!tellstick) {
return true; //not tellstick, nothing to reset at the moment, just return true
return true; // not tellstick, nothing to reset at the moment, just return true
}
int success = tellstick->reset();
deviceInsertedOrRemoved(tellstick->vid(), tellstick->pid(), tellstick->serial(), false); //remove from list and delete
deviceInsertedOrRemoved(tellstick->vid(), tellstick->pid(), tellstick->serial(), false); // remove from list and delete
return success;
}
@ -304,7 +304,7 @@ int ControllerManager::removeController(int id) {
return TELLSTICK_ERROR_NOT_FOUND;
}
if (it->second.controller) {
//Still connected
// Still connected
return TELLSTICK_ERROR_PERMISSION_DENIED;
}
@ -331,7 +331,7 @@ int ControllerManager::setControllerValue(int id, const std::wstring &name, cons
d->settings.setName(Settings::Controller, id, value);
signalControllerEvent(id, TELLSTICK_DEVICE_CHANGED, TELLSTICK_CHANGE_NAME, value);
} else {
return TELLSTICK_ERROR_SYNTAX; //TODO: Is this the best error?
return TELLSTICK_ERROR_SYNTAX; // TODO: Is this the best error?
}
return TELLSTICK_SUCCESS;
}

View file

@ -22,7 +22,7 @@ public:
ControllerMessage::ControllerMessage(const std::string &message) {
d = new PrivateData;
//Process our message into bits
// Process our message into bits
size_t prevPos = 0;
size_t pos = message.find(";");
while(pos != std::string::npos) {

View file

@ -43,7 +43,7 @@ int Device::getLastSentCommand(int methodsSupported) {
int lastSentCommand = Device::maskUnsupportedMethods(d->state, methodsSupported);
if (lastSentCommand == TELLSTICK_BELL) {
//Bell is not a state
// Bell is not a state
lastSentCommand = TELLSTICK_TURNOFF;
}
if (lastSentCommand == 0) {
@ -146,13 +146,13 @@ int Device::getType() {
int Device::doAction(int action, unsigned char data, Controller *controller) {
Protocol *p = this->retrieveProtocol();
if (!p) {
//Syntax error in configuration, no such protocol
// Syntax error in configuration, no such protocol
return TELLSTICK_ERROR_CONFIG_SYNTAX;
}
//Try to determine if we need to call another method due to masking
// Try to determine if we need to call another method due to masking
int methods = p->methods();
if ((action & methods) == 0) {
//Loop all methods an see if any method masks to this one
// Loop all methods an see if any method masks to this one
for(int i = 1; i <= methods; i<<=1) {
if ((i & methods) == 0) {
continue;
@ -171,7 +171,7 @@ int Device::doAction(int action, unsigned char data, Controller *controller) {
return TELLSTICK_ERROR_METHOD_NOT_SUPPORTED;
}
if (code[0] != 'S' && code[0] != 'T' && code[0] != 'P' && code[0] != 'R') {
//Try autodetect sendtype
// Try autodetect sendtype
TellStick *tellstick = reinterpret_cast<TellStick *>(controller);
if (!tellstick) {
return TELLSTICK_ERROR_UNKNOWN;
@ -181,7 +181,7 @@ int Device::doAction(int action, unsigned char data, Controller *controller) {
maxlength = 512;
}
if (code.length() <= maxlength) {
//S is enough
// S is enough
code.insert(0, 1, 'S');
code.append(1, '+');
} else {
@ -227,7 +227,7 @@ int Device::maskUnsupportedMethods(int methods, int supportedMethods) {
methods |= TELLSTICK_TURNON;
}
//Cut of the rest of the unsupported methods we don't have a fallback for
// Cut of the rest of the unsupported methods we don't have a fallback for
return methods & supportedMethods;
}

View file

@ -41,11 +41,11 @@ DeviceManager::~DeviceManager(void) {
{
TelldusCore::MutexLocker deviceListLocker(&d->lock);
for (DeviceMap::iterator it = d->devices.begin(); it != d->devices.end(); ++it) {
{TelldusCore::MutexLocker deviceLocker(it->second);} //aquire lock, and release it, just to see that the device it's not in use anywhere
{TelldusCore::MutexLocker deviceLocker(it->second);} // aquire lock, and release it, just to see that the device it's not in use anywhere
delete(it->second);
}
for (std::list<Sensor *>::iterator it = d->sensorList.begin(); it != d->sensorList.end(); ++it) {
{TelldusCore::MutexLocker sensorLocker(*it);} //aquire lock, and release it, just to see that the device it's not in use anywhere
{TelldusCore::MutexLocker sensorLocker(*it);} // aquire lock, and release it, just to see that the device it's not in use anywhere
delete(*it);
}
}
@ -133,7 +133,7 @@ int DeviceManager::getDeviceMethods(int deviceId, std::set<int> &duplicateDevice
std::wstring protocol;
{
//devices locked
// devices locked
TelldusCore::MutexLocker deviceListLocker(&d->lock);
if (!d->devices.size()) {
@ -379,10 +379,10 @@ void DeviceManager::disconnectTellStickController(int vid, int pid, const std::s
int DeviceManager::doAction(int deviceId, int action, unsigned char data) {
Device *device = 0;
//On the stack and will be released if we have a device lock.
// On the stack and will be released if we have a device lock.
std::auto_ptr<TelldusCore::MutexLocker> deviceLocker(0);
{
//devicelist locked
// devicelist locked
TelldusCore::MutexLocker deviceListLocker(&d->lock);
if (!d->devices.size()) {
@ -390,12 +390,12 @@ int DeviceManager::doAction(int deviceId, int action, unsigned char data) {
}
DeviceMap::iterator it = d->devices.find(deviceId);
if (it == d->devices.end()) {
return TELLSTICK_ERROR_DEVICE_NOT_FOUND; //not found
return TELLSTICK_ERROR_DEVICE_NOT_FOUND; // not found
}
//device locked
// device locked
deviceLocker = std::auto_ptr<TelldusCore::MutexLocker>(new TelldusCore::MutexLocker(it->second));
device = it->second;
} //devicelist unlocked
} // devicelist unlocked
int retval = TELLSTICK_ERROR_UNKNOWN;
@ -407,8 +407,8 @@ int DeviceManager::doAction(int deviceId, int action, unsigned char data) {
delete duplicateDeviceIds;
{
//reaquire device lock, make sure it still exists
//devicelist locked
// reaquire device lock, make sure it still exists
// devicelist locked
TelldusCore::MutexLocker deviceListLocker(&d->lock);
if (!d->devices.size()) {
@ -416,18 +416,18 @@ int DeviceManager::doAction(int deviceId, int action, unsigned char data) {
}
DeviceMap::iterator it = d->devices.find(deviceId);
if (it == d->devices.end()) {
return TELLSTICK_ERROR_DEVICE_NOT_FOUND; //not found
return TELLSTICK_ERROR_DEVICE_NOT_FOUND; // not found
}
//device locked
// device locked
deviceLocker = std::auto_ptr<TelldusCore::MutexLocker>(new TelldusCore::MutexLocker(it->second));
device = it->second;
} //devicelist unlocked
} // devicelist unlocked
}
else {
Controller *controller = d->controllerManager->getBestControllerById(device->getPreferredControllerId());
if(!controller) {
Log::warning("Trying to execute action, but no controller found. Rescanning USB ports");
//no controller found, scan for one, and retry once
// no controller found, scan for one, and retry once
d->controllerManager->loadControllers();
controller = d->controllerManager->getBestControllerById(device->getPreferredControllerId());
}
@ -446,7 +446,7 @@ int DeviceManager::doAction(int deviceId, int action, unsigned char data) {
Log::error("No contoller (TellStick) found, even after reset. Giving up.");
return TELLSTICK_ERROR_NOT_FOUND;
}
retval = device->doAction(action, data, controller); //retry one more time
retval = device->doAction(action, data, controller); // retry one more time
}
} else {
Log::error("No contoller (TellStick) found after one retry. Giving up.");
@ -454,7 +454,7 @@ int DeviceManager::doAction(int deviceId, int action, unsigned char data) {
}
}
if(retval == TELLSTICK_SUCCESS && device->getType() != TELLSTICK_TYPE_SCENE && device->getMethods() & action) {
//if method isn't explicitly supported by device, but used anyway as a fallback (i.e. bell), don't change state
// if method isn't explicitly supported by device, but used anyway as a fallback (i.e. bell), don't change state
std::wstring datastring = TelldusCore::charUnsignedToWstring(data);
if (this->triggerDeviceStateChange(deviceId, action, datastring)) {
device->setLastSentCommand(action, datastring);
@ -563,7 +563,7 @@ int DeviceManager::executeScene(std::wstring singledevice, int groupDeviceId) {
int DeviceManager::removeDevice(int deviceId) {
Device *device = 0;
{
int ret = d->set.removeNode(Settings::Device, deviceId); //remove from register/settings
int ret = d->set.removeNode(Settings::Device, deviceId); // remove from register/settings
if (ret != TELLSTICK_SUCCESS) {
return ret;
}
@ -575,13 +575,13 @@ int DeviceManager::removeDevice(int deviceId) {
DeviceMap::iterator it = d->devices.find(deviceId);
if (it != d->devices.end()) {
device = it->second;
d->devices.erase(it); //remove from list, keep reference
d->devices.erase(it); // remove from list, keep reference
}
else {
return TELLSTICK_ERROR_DEVICE_NOT_FOUND;
}
}
{TelldusCore::MutexLocker lock(device);} //waiting for device lock, if it's aquired, just unlock again. Device is removed from list, and cannot be accessed from anywhere else
{TelldusCore::MutexLocker lock(device);} // waiting for device lock, if it's aquired, just unlock again. Device is removed from list, and cannot be accessed from anywhere else
delete device;
return TELLSTICK_SUCCESS;
@ -638,7 +638,7 @@ std::wstring DeviceManager::getSensorValue(const std::wstring &protocol, const s
void DeviceManager::handleControllerMessage(const ControllerEventData &eventData) {
//Trigger raw-event
// Trigger raw-event
EventUpdateData *eventUpdateData = new EventUpdateData();
eventUpdateData->messageType = L"TDRawDeviceEvent";
eventUpdateData->controllerId = eventData.controllerId;
@ -749,7 +749,7 @@ int DeviceManager::sendRawCommand(const std::wstring &command, int reserved) {
if(!controller) {
return TELLSTICK_ERROR_NOT_FOUND;
}
retval = controller->send(TelldusCore::wideToString(command)); //retry one more time
retval = controller->send(TelldusCore::wideToString(command)); // retry one more time
}
return retval;
} else {

View file

@ -85,7 +85,7 @@ void EventUpdateManager::sendMessageToClients(EventUpdateData *data) {
msg.addArgument("TDDeviceEvent");
msg.addArgument(data->deviceId);
msg.addArgument(data->eventState);
msg.addArgument(data->eventValue); //string
msg.addArgument(data->eventValue); // string
}
else if(data->messageType == L"TDDeviceChangeEvent") {
msg.addArgument("TDDeviceChangeEvent");
@ -95,7 +95,7 @@ void EventUpdateManager::sendMessageToClients(EventUpdateData *data) {
}
else if(data->messageType == L"TDRawDeviceEvent") {
msg.addArgument("TDRawDeviceEvent");
msg.addArgument(data->eventValue); //string
msg.addArgument(data->eventValue); // string
msg.addArgument(data->controllerId);
}
else if(data->messageType == L"TDSensorEvent") {

View file

@ -20,7 +20,7 @@ public:
int eventState;
std::wstring eventValue;
//Sensor event
// Sensor event
std::wstring protocol;
std::wstring model;
int sensorId;

View file

@ -38,7 +38,7 @@ Log::Log()
#elif defined(_MACOSX)
d->logOutput = Log::StdOut;
#elif defined(_WINDOWS)
//Add ourselves to the registy
// Add ourselves to the registy
HKEY hRegKey = NULL;
DWORD dwError = 0;
TCHAR filePath[MAX_PATH];
@ -120,7 +120,7 @@ void Log::setDebug() {
void Log::setLogOutput(LogOutput logOutput) {
#ifdef _MACOSX
//Always stdout
// Always stdout
return;
#endif
Log *log = Log::instance();

View file

@ -47,7 +47,7 @@ Protocol::~Protocol(void) {
std::wstring Protocol::model() const {
std::wstring strModel = d->model;
//Strip anything after : if it is found
// Strip anything after : if it is found
size_t pos = strModel.find(L":");
if (pos != std::wstring::npos) {
strModel = strModel.substr(0, pos);
@ -176,7 +176,7 @@ std::list<std::string> Protocol::getParametersForProtocol(const std::wstring &pr
} else if (TelldusCore::comparei(protocolName, L"ikea")) {
parameters.push_back("system");
parameters.push_back("units");
//parameters.push_back("fade");
// parameters.push_back("fade");
} else if (TelldusCore::comparei(protocolName, L"risingsun")) {
parameters.push_back("house");

View file

@ -13,7 +13,7 @@ int ProtocolComen::methods() const {
std::string ProtocolComen::getStringForMethod(int method, unsigned char level, Controller *) {
int intHouse = getIntParameter(L"house", 1, 33554431);
intHouse <<= 1; //They seem to only accept even codes?
intHouse <<= 1; // They seem to only accept even codes?
int intCode = getIntParameter(L"unit", 1, 16)-1;
return getStringSelflearningForCode(intHouse, intCode, method, level);
}

View file

@ -30,8 +30,8 @@ std::string ProtocolEverflourish::getStringForMethod(int method, unsigned char,
}
const char ssss = 85;
const char sssl = 84; // 0
const char slss = 69; // 1
const char sssl = 84; // 0
const char slss = 69; // 1
const char bits[2] = {sssl,slss};
int i, check;
@ -108,7 +108,7 @@ std::string ProtocolEverflourish::decodeData(ControllerMessage &dataMsg) {
unit = allData & 0x300;
unit >>= 8;
unit++; //unit from 1 to 4
unit++; // unit from 1 to 4
method = allData & 0xF;
@ -129,7 +129,7 @@ std::string ProtocolEverflourish::decodeData(ControllerMessage &dataMsg) {
retString << "learn;";
}
else {
//not everflourish
// not everflourish
return "";
}

View file

@ -25,7 +25,7 @@ std::string ProtocolFuhaote::getStringForMethod(int method, unsigned char, Contr
return "";
}
//House code
// House code
for(size_t i = 0; i < 5; ++i) {
if (strCode[i] == '0') {
strReturn.append(B0);
@ -33,7 +33,7 @@ std::string ProtocolFuhaote::getStringForMethod(int method, unsigned char, Contr
strReturn.append(B1);
}
}
//Unit code
// Unit code
for(size_t i = 5; i < 10; ++i) {
if (strCode[i] == '0') {
strReturn.append(B0);

View file

@ -50,8 +50,8 @@ std::string ProtocolHasta::getStringForMethod(int method, unsigned char, Control
strReturn.append(convertByte(0x0));
strReturn.append(convertByte(0x0));
//Remove the last pulse
strReturn.erase(strReturn.end()-1,strReturn.end());
// Remove the last pulse
strReturn.erase(strReturn.end()-1, strReturn.end());
return strReturn;
}

View file

@ -33,7 +33,7 @@ std::string ProtocolIkea::getStringForMethod(int method, unsigned char level, Co
}
std::string strUnits(TelldusCore::wideToString(wstrUnits));
int intUnits = 0; //Start without any units
int intUnits = 0; // Start without any units
char *tempUnits = new char[strUnits.size()+1];
#ifdef _WINDOWS
@ -53,7 +53,7 @@ std::string ProtocolIkea::getStringForMethod(int method, unsigned char level, Co
delete[] tempUnits;
std::string strReturn = "STTTTTTª"; //Startcode, always like this;
std::string strReturn = "STTTTTTª"; // Startcode, always like this;
std::string strChannels = "";
int intCode = (intSystem << 10) | intUnits;
@ -70,14 +70,14 @@ std::string ProtocolIkea::getStringForMethod(int method, unsigned char level, Co
strChannels.append("ª");
}
}
strReturn.append(strChannels); //System + Units
strReturn.append(strChannels); // System + Units
strReturn.append(checksum1 %2 == 0 ? "TT" : "ª"); //1st checksum
strReturn.append(checksum2 %2 == 0 ? "TT" : "ª"); //2nd checksum
strReturn.append(checksum1 %2 == 0 ? "TT" : "ª"); // 1st checksum
strReturn.append(checksum2 %2 == 0 ? "TT" : "ª"); // 2nd checksum
int intLevel = 0;
if (level <= 12) {
intLevel = 10; // Level 10 is actually off
intLevel = 10; // Level 10 is actually off
} else if (level <= 37) {
intLevel = 1;
} else if (level <= 62) {
@ -97,17 +97,17 @@ std::string ProtocolIkea::getStringForMethod(int method, unsigned char level, Co
} else if (level <= 237) {
intLevel = 9;
} else {
intLevel = 0; // Level 0 is actually full on
intLevel = 0; // Level 0 is actually full on
}
int intFade = 0;
if (intFadeStyle == 1) {
intFade = 11 << 4; //Smooth
intFade = 11 << 4; // Smooth
} else {
intFade = 1 << 4; //Instant
intFade = 1 << 4; // Instant
}
intCode = intLevel | intFade; //Concat level and fade
intCode = intLevel | intFade; // Concat level and fade
checksum1 = 0;
checksum2 = 0;
@ -123,8 +123,8 @@ std::string ProtocolIkea::getStringForMethod(int method, unsigned char level, Co
}
}
strReturn.append(checksum1 %2 == 0 ? "TT" : "ª"); //1st checksum
strReturn.append(checksum2 %2 == 0 ? "TT" : "ª"); //2nd checksum
strReturn.append(checksum1 %2 == 0 ? "TT" : "ª"); // 1st checksum
strReturn.append(checksum2 %2 == 0 ? "TT" : "ª"); // 2nd checksum
strReturn.append("+");

View file

@ -10,7 +10,7 @@
#include "service/TellStick.h"
#include "common/Strings.h"
int ProtocolNexa::lastArctecCodeSwitchWasTurnOff=0; //TODO, always removing first turnon now, make more flexible (waveman too)
int ProtocolNexa::lastArctecCodeSwitchWasTurnOff=0; // TODO, always removing first turnon now, make more flexible (waveman too)
int ProtocolNexa::methods() const {
if (TelldusCore::comparei(model(), L"codeswitch")) {
@ -35,27 +35,27 @@ std::string ProtocolNexa::getStringForMethod(int method, unsigned char data, Con
return getStringBell();
}
if ((method == TELLSTICK_TURNON) && TelldusCore::comparei(model(), L"selflearning-dimmer")) {
//Workaround for not letting a dimmer do into "dimming mode"
// Workaround for not letting a dimmer do into "dimming mode"
return getStringSelflearning(TELLSTICK_DIM, 255);
}
if (method == TELLSTICK_LEARN) {
std::string str = getStringSelflearning(TELLSTICK_TURNON, data);
//Check to see if we are an old TellStick (fw <= 2, batch <= 8)
// Check to see if we are an old TellStick (fw <= 2, batch <= 8)
TellStick *ts = reinterpret_cast<TellStick *>(controller);
if (!ts) {
return str;
}
if (ts->pid() == 0x0c30 && ts->firmwareVersion() <= 2) {
//Workaround for the bug in early firmwares
//The TellStick have a fixed pause (max) between two packets.
//It is only correct between the first and second packet.
//It seems faster to send two packes at a time and some
//receivers seems picky about this when learning.
//We also return the last packet so Device::doAction() doesn't
//report TELLSTICK_ERROR_METHOD_NOT_SUPPORTED
// Workaround for the bug in early firmwares
// The TellStick have a fixed pause (max) between two packets.
// It is only correct between the first and second packet.
// It seems faster to send two packes at a time and some
// receivers seems picky about this when learning.
// We also return the last packet so Device::doAction() doesn't
// report TELLSTICK_ERROR_METHOD_NOT_SUPPORTED
str.insert(0, 1, 2); //Repeat two times
str.insert(0, 1, 2); // Repeat two times
str.insert(0, 1, 'R');
for (int i = 0; i < 5; ++i) {
controller->send(str);
@ -90,8 +90,8 @@ std::string ProtocolNexa::getStringBell() {
std::wstring house = getStringParameter(L"house", L"A");
int intHouse = house[0] - L'A';
strReturn.append(getCodeSwitchTuple(intHouse));
strReturn.append("$kk$$kk$$kk$$k$k"); //Unit 7
strReturn.append("$kk$$kk$$kk$$kk$$k+"); //Bell
strReturn.append("$kk$$kk$$kk$$k$k"); // Unit 7
strReturn.append("$kk$$kk$$kk$$kk$$k+"); // Bell
return strReturn;
}
@ -102,19 +102,19 @@ std::string ProtocolNexa::getStringSelflearning(int method, unsigned char level)
}
std::string ProtocolNexa::getStringSelflearningForCode(int intHouse, int intCode, int method, unsigned char level) {
const unsigned char START[] = {'T',127,255,24,1,0};
// const char START[] = {'T',130,255,26,24,0};
const unsigned char START[] = {'T', 127, 255, 24, 1, 0};
// const char START[] = {'T',130,255,26,24,0};
std::string strMessage(reinterpret_cast<const char*>(START));
strMessage.append(1,(method == TELLSTICK_DIM ? 147 : 132)); //Number of pulses
strMessage.append(1, (method == TELLSTICK_DIM ? 147 : 132)); // Number of pulses
std::string m;
for (int i = 25; i >= 0; --i) {
m.append( intHouse & 1 << i ? "10" : "01" );
}
m.append("01"); //Group
m.append("01"); // Group
//On/off
// On/off
if (method == TELLSTICK_DIM) {
m.append("00");
} else if (method == TELLSTICK_TURNOFF) {
@ -136,18 +136,18 @@ std::string ProtocolNexa::getStringSelflearningForCode(int intHouse, int intCode
}
}
//The number of data is odd.
//Add this to make it even, otherwise the following loop will not work
// The number of data is odd.
// Add this to make it even, otherwise the following loop will not work
m.append("0");
unsigned char code = 9; //b1001, startcode
unsigned char code = 9; // b1001, startcode
for (unsigned int i = 0; i < m.length(); ++i) {
code <<= 4;
if (m[i] == '1') {
code |= 8; //b1000
code |= 8; // b1000
} else {
code |= 10; //b1010
// code |= 11; //b1011
code |= 10; // b1010
// code |= 11; //b1011
}
if (i % 2 == 0) {
strMessage.append(1,code);
@ -210,7 +210,7 @@ std::string ProtocolNexa::decodeDataSelfLearning(long allData) {
retString << "turnoff;";
}
else {
//not arctech selflearning
// not arctech selflearning
return "";
}
@ -236,12 +236,12 @@ std::string ProtocolNexa::decodeDataCodeSwitch(long allData) {
return "";
}
house = house + 'A'; //house from A to P
house = house + 'A'; // house from A to P
if(method != 6 && lastArctecCodeSwitchWasTurnOff == 1) {
lastArctecCodeSwitchWasTurnOff = 0;
return ""; //probably a stray turnon or bell (perhaps: only certain time interval since last, check that it's the same house/unit... Will lose
//one turnon/bell, but it's better than the alternative...
return ""; // probably a stray turnon or bell (perhaps: only certain time interval since last, check that it's the same house/unit... Will lose
// one turnon/bell, but it's better than the alternative...
}
if(method == 6) {
@ -261,7 +261,7 @@ std::string ProtocolNexa::decodeDataCodeSwitch(long allData) {
retString << ";method:bell;";
}
else {
//not arctech codeswitch
// not arctech codeswitch
return "";
}
@ -271,9 +271,9 @@ std::string ProtocolNexa::decodeDataCodeSwitch(long allData) {
std::string ProtocolNexa::getCodeSwitchTuple(int intCode) {
std::string strReturn = "";
for( int i = 0; i < 4; ++i ) {
if (intCode & 1) { //Convert 1
if (intCode & 1) { // Convert 1
strReturn.append("$kk$");
} else { //Convert 0
} else { // Convert 0
strReturn.append("$k$k");
}
intCode >>= 1;

View file

@ -102,7 +102,7 @@ std::string ProtocolOregon::decode1A2D(const std::string &data) {
checksum += 0x1 + 0xA + 0x2 + 0xD - 0xA;
//TODO: Find out how checksum2 works
// TODO: Find out how checksum2 works
if (checksum != checksum1) {
return "";
}

View file

@ -14,11 +14,11 @@ int ProtocolUpm::methods() const {
std::string ProtocolUpm::getStringForMethod(int method, unsigned char, Controller *) {
const char S = ';';
const char L = '~';
const char START[] = {S,0};
const char B1[] = {L,S,0};
const char B0[] = {S,L,0};
//const char BON[] = {S,L,L,S,0};
//const char BOFF[] = {S,L,S,L,0};
const char START[] = {S, 0};
const char B1[] = {L, S, 0};
const char B0[] = {S, L, 0};
// const char BON[] = {S,L,L,S,0};
// const char BOFF[] = {S,L,S,L,0};
int intUnit = this->getIntParameter(L"unit", 1, 4)-1;
std::string strReturn;
@ -32,7 +32,7 @@ std::string ProtocolUpm::getStringForMethod(int method, unsigned char, Controlle
}
code >>= 1;
}
strReturn.insert(0, START); //Startcode, first
strReturn.insert(0, START); // Startcode, first
code = 0;
if (method == TELLSTICK_TURNON || method == TELLSTICK_LEARN) {

View file

@ -44,12 +44,12 @@ std::string ProtocolWaveman::decodeData(ControllerMessage& dataMsg) {
return "";
}
house = house + 'A'; //house from A to P
house = house + 'A'; // house from A to P
if(method != 6 && lastArctecCodeSwitchWasTurnOff == 1) {
lastArctecCodeSwitchWasTurnOff = 0;
return ""; //probably a stray turnon or bell (perhaps: only certain time interval since last, check that it's the same house/unit... Will lose
//one turnon/bell, but it's better than the alternative...
return ""; // probably a stray turnon or bell (perhaps: only certain time interval since last, check that it's the same house/unit... Will lose
// one turnon/bell, but it's better than the alternative...
}
if(method == 6) {
@ -66,7 +66,7 @@ std::string ProtocolWaveman::decodeData(ControllerMessage& dataMsg) {
retString << ";unit:" << unit << ";method:turnon;";
}
else {
//not waveman
// not waveman
return "";
}

View file

@ -32,7 +32,7 @@ std::string ProtocolX10::getStringForMethod(int method, unsigned char data, Cont
} else if (intHouse > 15) {
intHouse = 15;
}
//Translate it
// Translate it
intHouse = HOUSES[intHouse];
int intCode = getIntParameter(L"unit", 1, 16)-1;
@ -68,7 +68,7 @@ std::string ProtocolX10::getStringForMethod(int method, unsigned char data, Cont
strReturn.append( B0 );
strComplement.append( B1 );
if (intCode >> 2 & 1) { //Bit 2 of intCode
if (intCode >> 2 & 1) { // Bit 2 of intCode
strReturn.append(B1);
strComplement.append(B0);
} else {
@ -86,7 +86,7 @@ std::string ProtocolX10::getStringForMethod(int method, unsigned char data, Cont
return "";
}
if (intCode & 1) { //Bit 0 of intCode
if (intCode & 1) { // Bit 0 of intCode
strReturn.append(B1);
strComplement.append(B0);
} else {
@ -94,7 +94,7 @@ std::string ProtocolX10::getStringForMethod(int method, unsigned char data, Cont
strComplement.append(B1);
}
if (intCode >> 1 & 1) { //Bit 1 of intCode
if (intCode >> 1 & 1) { // Bit 1 of intCode
strReturn.append(B1);
strComplement.append(B0);
} else {

View file

@ -81,7 +81,7 @@ int Settings::getNumberOfNodes(Node node) const {
}
int Settings::getNodeId(Node type, int intDeviceIndex) const {
if (intDeviceIndex >= getNumberOfNodes(type)) { //Out of bounds
if (intDeviceIndex >= getNumberOfNodes(type)) { // Out of bounds
return -1;
}
TelldusCore::MutexLocker locker(&mutex);
@ -106,15 +106,15 @@ int Settings::addNode(Node type) {
if (!fp) {
return TELLSTICK_ERROR_PERMISSION_DENIED;
}
cfg_print(d->cfg, fp); //Print the config-file
cfg_print(d->cfg, fp); // Print the config-file
if (type == Device) {
fprintf(fp, "device {\n id=%d\n}\n", intNodeId); //Print the new device
fprintf(fp, "device {\n id=%d\n}\n", intNodeId); // Print the new device
} else if (type == Controller) {
fprintf(fp, "controller {\n id=%d\n}\n", intNodeId); //Print the new controller
fprintf(fp, "controller {\n id=%d\n}\n", intNodeId); // Print the new controller
}
fclose(fp);
//Re-read config-file
// Re-read config-file
cfg_free(d->cfg);
readConfig(&d->cfg);
return intNodeId;
@ -124,7 +124,7 @@ int Settings::addNode(Node type) {
* Get next available node id
*/
int Settings::getNextNodeId(Node type) const {
//Private, no locks needed
// Private, no locks needed
int intNodeId = 0;
cfg_t *cfg_node;
std::string strType;
@ -166,7 +166,7 @@ int Settings::removeNode(Node type, int intNodeId) {
cfg_t *cfg_node;
for (int i = 0; i < cfg_size(d->cfg, strType.c_str()); ++i) {
cfg_node = cfg_getnsec(d->cfg, strType.c_str(), i);
if (cfg_getint(cfg_node, "id") != intNodeId) { //This isn't the one to skip
if (cfg_getint(cfg_node, "id") != intNodeId) { // This isn't the one to skip
fprintf(fp, "%s {\n", strType.c_str());
cfg_print_indent(cfg_node, fp, 1);
fprintf(fp, "}\n");
@ -176,7 +176,7 @@ int Settings::removeNode(Node type, int intNodeId) {
}
fclose(fp);
//Re-read config-file
// Re-read config-file
cfg_free(d->cfg);
readConfig(&d->cfg);
@ -205,7 +205,7 @@ bool Settings::setDeviceState( int intDeviceId, int intDeviceState, const std::w
return true;
}
}
// The device is not found in the file, we must create it manualy...
// The device is not found in the file, we must create it manualy...
FILE *fp = fopen(VAR_CONFIG_FILE, "w");
if(!fp) {
fprintf(stderr, "Failed to write state to %s: %s\n",
@ -213,11 +213,11 @@ bool Settings::setDeviceState( int intDeviceId, int intDeviceState, const std::w
return false;
}
cfg_print(d->var_cfg, fp); //Print the config-file
fprintf(fp, "device %d {\n}\n", intDeviceId); //Print the new device
cfg_print(d->var_cfg, fp); // Print the config-file
fprintf(fp, "device %d {\n}\n", intDeviceId); // Print the new device
fclose(fp);
//Re-read config-file
// Re-read config-file
cfg_free(d->var_cfg);
readVarConfig(&d->var_cfg);
@ -258,7 +258,7 @@ std::wstring Settings::getDeviceStateValue( int intDeviceId ) const {
}
std::wstring Settings::getStringSetting(Node type, int intNodeId, const std::wstring &name, bool parameter) const {
//already locked
// already locked
if (d->cfg == 0) {
return L"";
}
@ -283,7 +283,7 @@ std::wstring Settings::getStringSetting(Node type, int intNodeId, const std::wst
}
int Settings::setStringSetting(Node type, int intDeviceId, const std::wstring &name, const std::wstring &value, bool parameter) {
//already locked
// already locked
if (d->cfg == 0) {
return TELLSTICK_ERROR_PERMISSION_DENIED;
}
@ -315,7 +315,7 @@ int Settings::setStringSetting(Node type, int intDeviceId, const std::wstring &n
}
int Settings::getIntSetting(Node type, int intDeviceId, const std::wstring &name, bool parameter) const {
//already locked
// already locked
if (d->cfg == 0) {
return 0;
}
@ -334,7 +334,7 @@ int Settings::getIntSetting(Node type, int intDeviceId, const std::wstring &name
}
int Settings::setIntSetting(Node type, int intDeviceId, const std::wstring &name, int value, bool parameter) {
//already locked
// already locked
if (d->cfg == 0) {
return TELLSTICK_ERROR_PERMISSION_DENIED;
}
@ -363,7 +363,7 @@ int Settings::setIntSetting(Node type, int intDeviceId, const std::wstring &name
bool readConfig(cfg_t **cfg) {
//All the const_cast keywords is to remove the compiler warnings generated by the C++-compiler.
// All the const_cast keywords is to remove the compiler warnings generated by the C++-compiler.
cfg_opt_t controller_opts[] = {
CFG_INT(const_cast<char *>("id"), -1, CFGF_NONE),
CFG_STR(const_cast<char *>("name"), const_cast<char *>(""), CFGF_NONE),
@ -374,7 +374,7 @@ bool readConfig(cfg_t **cfg) {
};
cfg_opt_t device_parameter_opts[] = {
//Groups
// Groups
CFG_STR(const_cast<char *>("devices"), 0, CFGF_NONE),
CFG_STR(const_cast<char *>("house"), 0, CFGF_NONE),

View file

@ -14,7 +14,7 @@ std::string TellStick::createTPacket( const std::string &msg ) {
std::string data;
int index = 0;
for(size_t i = 0; i < msg.length(); ++i) {
//Search to se if it already exists and get the index
// Search to se if it already exists and get the index
if (times.find(msg.at(i)) == times.end()) {
times[msg.at(i)] = index++;
if (times.size() > 4) {
@ -23,7 +23,7 @@ std::string TellStick::createTPacket( const std::string &msg ) {
}
data.append(1, times[msg.at(i)]);
}
//Reorder the times
// Reorder the times
unsigned char t0 = 1, t1 = 1, t2 = 1, t3 = 1;
for(std::map<unsigned char, char>::const_iterator it = times.begin(); it != times.end(); ++it) {
if ((*it).second == 0) {

View file

@ -122,10 +122,10 @@ bool TellStick::isSameAsDescriptor(const TellStickDescriptor &td) const {
void TellStick::processData( const std::string &data ) {
for (unsigned int i = 0; i < data.length(); ++i) {
if (data[i] == 13) { // Skip \r
if (data[i] == 13) { // Skip \r
continue;
} else if (data[i] == 10) { // \n found
if (d->message.substr(0,2).compare("+V") == 0) {
} else if (data[i] == 10) { // \n found
if (d->message.substr(0, 2).compare("+V") == 0) {
setFirmwareVersion(TelldusCore::charToInteger(d->message.substr(2).c_str()));
} else if (d->message.substr(0,2).compare("+R") == 0) {
this->publishData(d->message.substr(2));
@ -133,7 +133,7 @@ void TellStick::processData( const std::string &data ) {
this->decodePublishData(d->message.substr(2));
}
d->message.clear();
} else { // Append the character
} else { // Append the character
d->message.append( 1, data[i] );
}
}
@ -159,12 +159,12 @@ void TellStick::run() {
d->running = true;
}
//Send a firmware version request
// Send a firmware version request
unsigned char msg[] = "V+";
ftdi_write_data( &d->ftHandle, msg, 2 ) ;
while(1) {
//Is there any better way then sleeping between reads?
// Is there any better way then sleeping between reads?
msleep(100);
TelldusCore::MutexLocker locker(&d->mutex);
if (!d->running) {
@ -173,9 +173,9 @@ void TellStick::run() {
memset(buf, 0, sizeof(buf));
dwBytesRead = ftdi_read_data(&d->ftHandle, buf, sizeof(buf));
if (dwBytesRead < 0) {
//An error occured, avoid flooding by sleeping longer
//Hopefully if will start working again
msleep(1000); //1s
// An error occured, avoid flooding by sleeping longer
// Hopefully if will start working again
msleep(1000); // 1s
}
if (dwBytesRead < 1) {
continue;
@ -193,9 +193,9 @@ int TellStick::send( const std::string &strMessage ) {
unsigned char *tempMessage = new unsigned char[strMessage.size()];
memcpy(tempMessage, strMessage.c_str(), strMessage.size());
//This lock does two things
// 1 Prevents two calls from different threads to this function
// 2 Prevents our running thread from receiving the data we are interested in here
// This lock does two things
// 1 Prevents two calls from different threads to this function
// 2 Prevents our running thread from receiving the data we are interested in here
TelldusCore::MutexLocker locker(&d->mutex);
int ret;
@ -232,9 +232,9 @@ int TellStick::send( const std::string &strMessage ) {
if (in == '\n') {
return TELLSTICK_SUCCESS;
}
} else if(ret == 0) { // No data available
} else if(ret == 0) { // No data available
usleep(100);
} else { //Error
} else { // Error
Log::debug("Broken pipe on read");
return TELLSTICK_ERROR_BROKEN_PIPE;
}
@ -322,7 +322,7 @@ void TellStick::stop() {
TelldusCore::MutexLocker locker(&d->mutex);
d->running = false;
}
//Unlock the wait-condition
// Unlock the wait-condition
pthread_cond_broadcast(&d->eh.eCondVar);
}

View file

@ -64,9 +64,9 @@ void TelldusMain::suspend() {
void TelldusMain::start(void) {
TelldusCore::EventRef clientEvent = d->eventHandler.addEvent();
TelldusCore::EventRef dataEvent = d->eventHandler.addEvent();
TelldusCore::EventRef janitor = d->eventHandler.addEvent(); //Used for regular cleanups
Timer supervisor(janitor); //Tells the janitor to go back to work
supervisor.setInterval(60); //Once every minute
TelldusCore::EventRef janitor = d->eventHandler.addEvent(); // Used for regular cleanups
Timer supervisor(janitor); // Tells the janitor to go back to work
supervisor.setInterval(60); // Once every minute
supervisor.start();
EventUpdateManager eventUpdateManager;
@ -82,7 +82,7 @@ void TelldusMain::start(void) {
TelldusCore::EventRef handlerEvent = d->eventHandler.addEvent();
#ifdef _MACOSX
//This is only needed on OS X
// This is only needed on OS X
ControllerListener controllerListener(d->controllerChangeEvent);
#endif
@ -92,7 +92,7 @@ void TelldusMain::start(void) {
continue;
}
if (clientEvent->isSignaled()) {
//New client connection
// New client connection
TelldusCore::EventDataRef eventDataRef = clientEvent->takeSignal();
ConnectionListenerEventData *data = reinterpret_cast<ConnectionListenerEventData*>(eventDataRef.get());
if (data) {
@ -131,7 +131,7 @@ void TelldusMain::start(void) {
}
}
if (janitor->isSignaled()) {
//Clear all of them if there is more than one
// Clear all of them if there is more than one
while(janitor->isSignaled()) {
janitor->popSignal();
}

View file

@ -15,7 +15,7 @@ public:
void start();
void stop();
//Thread safe!
// Thread safe!
void deviceInsertedOrRemoved(int vid, int pid, bool inserted);
void resume();
void suspend();

View file

@ -60,7 +60,7 @@ void Timer::stop() {
d->running = false;
SetEvent(d->cond);
#else
//Signal event
// Signal event
pthread_mutex_lock(&d->waitMutex);
if (d->running) {
d->running = false;

View file

@ -77,9 +77,9 @@ int main(int argc, char **argv) {
exit(EXIT_FAILURE);
}
if (pid > 0) {
//We are the parent
//Let the parent store the clients pid,
//This way anyone starting the daemon can read the pidfile immediately
// We are the parent
// Let the parent store the clients pid,
// This way anyone starting the daemon can read the pidfile immediately
// Record the pid
fd = fopen(PID_FILE,"w");
@ -103,7 +103,7 @@ int main(int argc, char **argv) {
sid = setsid();
if (sid < 0) {
//Something went wrong
// Something went wrong
printf("Could not set sid\n");
exit(EXIT_FAILURE);
}