Added whitespaces to comments according to Google style guidelines "whitespace/comments"

This commit is contained in:
Stefan Persson 2012-12-05 12:10:16 +01:00
parent ce24cabff9
commit 8d90a4e14a
10 changed files with 40 additions and 40 deletions

View file

@ -102,12 +102,12 @@ void CallbackMainDispatcher::run() {
if (!cbd) { if (!cbd) {
continue; continue;
} }
//debuglog(333, "Callbackevent, signalled"); // debuglog(333, "Callbackevent, signalled");
TelldusCore::MutexLocker locker(&d->mutex); TelldusCore::MutexLocker locker(&d->mutex);
//debuglog(333, "Callbackevent, locked"); // debuglog(333, "Callbackevent, locked");
for(CallbackList::iterator callback_it = d->callbackList.begin(); callback_it != d->callbackList.end(); ++callback_it) { for(CallbackList::iterator callback_it = d->callbackList.begin(); callback_it != d->callbackList.end(); ++callback_it) {
if ( (*callback_it)->type == cbd->type ) { if ( (*callback_it)->type == cbd->type ) {
//debuglog((*callback_it)->id, "Callbackevent, sending"); // debuglog((*callback_it)->id, "Callbackevent, sending");
std::tr1::shared_ptr<TelldusCore::TDEventDispatcher> ptr(new TelldusCore::TDEventDispatcher(eventData, *callback_it, d->janitor)); std::tr1::shared_ptr<TelldusCore::TDEventDispatcher> ptr(new TelldusCore::TDEventDispatcher(eventData, *callback_it, d->janitor));
d->eventThreadList.push_back(ptr); d->eventThreadList.push_back(ptr);
} }

View file

@ -89,9 +89,9 @@ void Client::run() {
while(d->running) { while(d->running) {
if(!d->eventSocket.isConnected()) { if(!d->eventSocket.isConnected()) {
debuglog(555, "Client, Trying to (re)connect to TelldusEvents"); debuglog(555, "Client, Trying to (re)connect to TelldusEvents");
d->eventSocket.connect(L"TelldusEvents"); //try to reconnect to service d->eventSocket.connect(L"TelldusEvents"); // try to reconnect to service
if(!d->eventSocket.isConnected()) { if(!d->eventSocket.isConnected()) {
//reconnect didn't succeed, wait a while and try again // reconnect didn't succeed, wait a while and try again
msleep(2000); msleep(2000);
continue; continue;
} }
@ -160,7 +160,7 @@ std::wstring Client::sendToService(const Message &msg) {
} }
Socket s; Socket s;
s.connect(L"TelldusClient"); s.connect(L"TelldusClient");
if (!s.isConnected()) { //Connection failed if (!s.isConnected()) { // sConnection failed
debuglog(555, "Connection failed"); debuglog(555, "Connection failed");
msleep(500); msleep(500);
continue; // retry continue; // retry
@ -169,7 +169,7 @@ std::wstring Client::sendToService(const Message &msg) {
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); msleep(500);
debuglog(555, "Error in write, should retry"); debuglog(555, "Error in write, should retry");
continue; //retry continue; // retry
} }
readData = s.read(1000); // TODO(stefan): changed to 10000 from 5000, how much does this do...? readData = s.read(1000); // TODO(stefan): changed to 10000 from 5000, how much does this do...?
if(readData == L"") { if(readData == L"") {

View file

@ -40,7 +40,7 @@ Socket::Socket(SOCKET_T hPipe) {
Socket::~Socket(void) { Socket::~Socket(void) {
d->running = false; d->running = false;
SetEvent(d->readEvent); //signal for break SetEvent(d->readEvent); // signal for break
if (d->hPipe != INVALID_HANDLE_VALUE) { if (d->hPipe != INVALID_HANDLE_VALUE) {
CloseHandle(d->hPipe); CloseHandle(d->hPipe);
d->hPipe = 0; d->hPipe = 0;
@ -68,10 +68,10 @@ void Socket::connect(const std::wstring &server) {
DWORD dwMode = PIPE_READMODE_MESSAGE; DWORD dwMode = PIPE_READMODE_MESSAGE;
fSuccess = SetNamedPipeHandleState( fSuccess = SetNamedPipeHandleState(
d->hPipe, // pipe handle d->hPipe, // pipe handle
&dwMode, // new pipe mode &dwMode, // new pipe mode
NULL, // don't set maximum bytes NULL, // don't set maximum bytes
NULL); // don't set maximum time NULL); // don't set maximum time
if (!fSuccess) { if (!fSuccess) {
return; return;
@ -127,7 +127,7 @@ std::wstring Socket::read(int timeout) {
if (!fSuccess) { if (!fSuccess) {
DWORD err = GetLastError(); DWORD err = GetLastError();
debuglog(static_cast<int>(err), "Something read error"); debuglog(static_cast<int>(err), "Something read error");
if(err != ERROR_OPERATION_ABORTED) { //gets this "error" always when nothing was reads if(err != ERROR_OPERATION_ABORTED) { // gets this "error" always when nothing was reads
debuglog(static_cast<int>(err), "Socket read error"); debuglog(static_cast<int>(err), "Socket read error");
} }

View file

@ -102,16 +102,16 @@ void ConnectionListener::run() {
if (recreate) { if (recreate) {
hPipe = CreateNamedPipe( hPipe = CreateNamedPipe(
(const wchar_t *)d->pipename.c_str(), // pipe name (const wchar_t *)d->pipename.c_str(), // pipe name
PIPE_ACCESS_DUPLEX | // read/write access PIPE_ACCESS_DUPLEX | // read/write access
FILE_FLAG_OVERLAPPED, //Overlapped mode FILE_FLAG_OVERLAPPED, // Overlapped mode
PIPE_TYPE_MESSAGE | // message type pipe PIPE_TYPE_MESSAGE | // message type pipe
PIPE_READMODE_MESSAGE | // message-read mode PIPE_READMODE_MESSAGE | // message-read mode
PIPE_WAIT, // blocking mode PIPE_WAIT, // blocking mode
PIPE_UNLIMITED_INSTANCES, // max. instances PIPE_UNLIMITED_INSTANCES, // max. instances
BUFSIZE, // output buffer size BUFSIZE, // output buffer size
BUFSIZE, // input buffer size BUFSIZE, // input buffer size
0, // client time-out 0, // client time-out
&d->sa); // default security attribute &d->sa); // default security attribute
if (hPipe == INVALID_HANDLE_VALUE) { if (hPipe == INVALID_HANDLE_VALUE) {
return; return;
@ -130,7 +130,7 @@ void ConnectionListener::run() {
} }
if(result == WAIT_TIMEOUT) { if(result == WAIT_TIMEOUT) {
//CloseHandle(hPipe); // CloseHandle(hPipe);
continue; continue;
} }
BOOL connected = GetOverlappedResult(hPipe, &oOverlap, &cbBytesRead, false); BOOL connected = GetOverlappedResult(hPipe, &oOverlap, &cbBytesRead, false);

View file

@ -13,12 +13,12 @@
#include "service/Protocol.h" #include "service/Protocol.h"
#include "service/EventUpdateManager.h" #include "service/EventUpdateManager.h"
#include "common/Strings.h" #include "common/Strings.h"
#include "common/common.h" //debug #include "common/common.h" // debug
inline int random( unsigned int* seed ) { inline int random( unsigned int* seed ) {
#ifdef _WINDOWS #ifdef _WINDOWS
unsigned int randomNumber; unsigned int randomNumber;
rand_s( &randomNumber ); //no seed needed rand_s( &randomNumber ); // no seed needed
return randomNumber; return randomNumber;
#else #else
return rand_r( seed ); return rand_r( seed );

View file

@ -24,7 +24,7 @@
#include <vector> #include <vector>
#endif // _LINUX #endif // _LINUX
#include "common/common.h" //debug #include "common/common.h" // debug
#include "common/EventHandler.h" #include "common/EventHandler.h"
#include "common/Message.h" #include "common/Message.h"
#include "common/Socket.h" #include "common/Socket.h"
@ -164,7 +164,7 @@ void EventUpdateManager::sendMessageToClients(EventUpdateData *data) {
it++; it++;
} else { } else {
//connection is dead, remove it // connection is dead, remove it
debuglogservice(0, "Lost connection, removing it"); debuglogservice(0, "Lost connection, removing it");
delete *it; delete *it;
it = d->clients.erase(it); it = d->clients.erase(it);

View file

@ -111,7 +111,7 @@ int Settings::addNode(Node type) {
strCompleteRegPath.append(TelldusCore::intToWstring(intNodeId)); strCompleteRegPath.append(TelldusCore::intToWstring(intNodeId));
if (RegCreateKeyEx(d->rootKey, strCompleteRegPath.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hk, &dwDisp)) { if (RegCreateKeyEx(d->rootKey, strCompleteRegPath.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hk, &dwDisp)) {
//fail // fail
intNodeId = -1; intNodeId = -1;
} }
@ -123,12 +123,12 @@ int Settings::addNode(Node type) {
* Get next available device id * Get next available device id
*/ */
int Settings::getNextNodeId(Node type) const { int Settings::getNextNodeId(Node type) const {
//Private, no locks needed // Private, no locks needed
int intReturn = -1; int intReturn = -1;
HKEY hk; HKEY hk;
DWORD dwDisp; DWORD dwDisp;
long lnExists = RegCreateKeyEx(d->rootKey, d->getNodePath(type).c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hk, &dwDisp); //create or open if already created long lnExists = RegCreateKeyEx(d->rootKey, d->getNodePath(type).c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hk, &dwDisp); // create or open if already created
if(lnExists == ERROR_SUCCESS) { if(lnExists == ERROR_SUCCESS) {
DWORD dwLength = sizeof(DWORD); DWORD dwLength = sizeof(DWORD);
@ -160,7 +160,7 @@ int Settings::removeNode(Node type, int intNodeId) {
long lngSuccess = RegDeleteKey(d->rootKey, strCompleteRegPath.c_str()); long lngSuccess = RegDeleteKey(d->rootKey, strCompleteRegPath.c_str());
if(lngSuccess == ERROR_SUCCESS) { if(lngSuccess == ERROR_SUCCESS) {
//one of the deletions succeeded // one of the deletions succeeded
return TELLSTICK_SUCCESS; return TELLSTICK_SUCCESS;
} }
@ -180,7 +180,7 @@ std::wstring Settings::getSetting(const std::wstring &strName) const {
long lngStatus = RegQueryValueEx(hk, strName.c_str(), NULL, NULL, (LPBYTE)Buff, &dwLength); long lngStatus = RegQueryValueEx(hk, strName.c_str(), NULL, NULL, (LPBYTE)Buff, &dwLength);
if(lngStatus == ERROR_MORE_DATA) { if(lngStatus == ERROR_MORE_DATA) {
//The buffer is to small, recreate it // The buffer is to small, recreate it
delete[] Buff; delete[] Buff;
Buff = new wchar_t[dwLength]; Buff = new wchar_t[dwLength];
lngStatus = RegQueryValueEx(hk, strName.c_str(), NULL, NULL, (LPBYTE)Buff, &dwLength); lngStatus = RegQueryValueEx(hk, strName.c_str(), NULL, NULL, (LPBYTE)Buff, &dwLength);
@ -208,7 +208,7 @@ std::wstring Settings::getStringSetting(Node type, int intNodeId, const std::wst
long lngStatus = RegQueryValueEx(hk, name.c_str(), NULL, NULL, (LPBYTE)Buff, &dwLength); long lngStatus = RegQueryValueEx(hk, name.c_str(), NULL, NULL, (LPBYTE)Buff, &dwLength);
if(lngStatus == ERROR_MORE_DATA) { if(lngStatus == ERROR_MORE_DATA) {
//The buffer is to small, recreate it // The buffer is to small, recreate it
delete[] Buff; delete[] Buff;
Buff = new wchar_t[dwLength]; Buff = new wchar_t[dwLength];
lngStatus = RegQueryValueEx(hk, name.c_str(), NULL, NULL, (LPBYTE)Buff, &dwLength); lngStatus = RegQueryValueEx(hk, name.c_str(), NULL, NULL, (LPBYTE)Buff, &dwLength);

View file

@ -9,7 +9,7 @@
#include <list> #include <list>
#include <memory> #include <memory>
#include "common/common.h" //debug #include "common/common.h" // debug
#include "common/EventHandler.h" #include "common/EventHandler.h"
#include "service/ClientCommunicationHandler.h" #include "service/ClientCommunicationHandler.h"
#include "service/ConnectionListener.h" #include "service/ConnectionListener.h"

View file

@ -75,7 +75,7 @@ DWORD WINAPI TelldusWinService::deviceNotificationHandler( DWORD controlCode, DW
std::wstring name(pDevInf->dbcc_name); std::wstring name(pDevInf->dbcc_name);
transform(name.begin(), name.end(), name.begin(), toupper); transform(name.begin(), name.end(), name.begin(), toupper);
//Parse VID // Parse VID
size_t posStart = name.find(L"VID_"); size_t posStart = name.find(L"VID_");
if (posStart == std::wstring::npos) { if (posStart == std::wstring::npos) {
return ERROR_CALL_NOT_IMPLEMENTED; return ERROR_CALL_NOT_IMPLEMENTED;
@ -87,7 +87,7 @@ DWORD WINAPI TelldusWinService::deviceNotificationHandler( DWORD controlCode, DW
} }
std::wstring strVID = name.substr(posStart, posEnd-posStart); std::wstring strVID = name.substr(posStart, posEnd-posStart);
//Parse PID // Parse PID
posStart = name.find(L"PID_"); posStart = name.find(L"PID_");
if (posStart == std::wstring::npos) { if (posStart == std::wstring::npos) {
return ERROR_CALL_NOT_IMPLEMENTED; return ERROR_CALL_NOT_IMPLEMENTED;
@ -125,7 +125,7 @@ DWORD WINAPI TelldusWinService::serviceControlHandler( DWORD controlCode, DWORD
void WINAPI TelldusWinService::serviceMain( DWORD argc, TCHAR* argv[] ) { void WINAPI TelldusWinService::serviceMain( DWORD argc, TCHAR* argv[] ) {
TelldusWinService instance; TelldusWinService instance;
//Enable debug if we hade this supplied // Enable debug if we hade this supplied
for(unsigned int i = 1; i < argc; ++i) { for(unsigned int i = 1; i < argc; ++i) {
if (wcscmp(argv[i], L"--debug") == 0) { if (wcscmp(argv[i], L"--debug") == 0) {
Log::setDebug(); Log::setDebug();
@ -165,7 +165,7 @@ void WINAPI TelldusWinService::serviceMain( DWORD argc, TCHAR* argv[] ) {
Log::notice("TelldusService started"); Log::notice("TelldusService started");
//Start our main-loop // Start our main-loop
instance.tm->start(); instance.tm->start();
Log::notice("TelldusService stopping"); Log::notice("TelldusService stopping");

View file

@ -8,7 +8,7 @@
#include <Dbt.h> #include <Dbt.h>
#include "service/TelldusWinService_win.h" #include "service/TelldusWinService_win.h"
//#include <QCoreApplication> // #include <QCoreApplication>
int main(int argc, char **argv) { int main(int argc, char **argv) {
g_argc = argc; g_argc = argc;