Fixed placement of curly braces according to Google style guidelines "whitespace/braces"
This commit is contained in:
parent
bca00ef148
commit
69c67e3c09
9 changed files with 39 additions and 44 deletions
|
@ -87,10 +87,10 @@ void Client::run() {
|
|||
d->eventSocket.connect(L"TelldusEvents");
|
||||
|
||||
while(d->running) {
|
||||
if(!d->eventSocket.isConnected()){
|
||||
if(!d->eventSocket.isConnected()) {
|
||||
debuglog(555, "Client, Trying to (re)connect to TelldusEvents");
|
||||
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
|
||||
msleep(2000);
|
||||
continue;
|
||||
|
@ -172,7 +172,7 @@ std::wstring Client::sendToService(const Message &msg) {
|
|||
continue; //retry
|
||||
}
|
||||
readData = s.read(1000); // TODO(stefan): changed to 10000 from 5000, how much does this do...?
|
||||
if(readData == L""){
|
||||
if(readData == L"") {
|
||||
msleep(500);
|
||||
continue; // TODO(stefan): can we be really sure it SHOULD be anything?
|
||||
// TODO(stefan): perhaps break here instead?
|
||||
|
|
|
@ -60,7 +60,7 @@ void EventHandler::signal(Event *event) {
|
|||
|
||||
bool EventHandler::waitForAny() {
|
||||
|
||||
while(1){
|
||||
while(1) {
|
||||
int result = WaitForMultipleObjects(d->eventCount, d->eventArray, FALSE, 1000);
|
||||
if (result == WAIT_TIMEOUT) {
|
||||
continue;
|
||||
|
|
|
@ -15,8 +15,7 @@ public:
|
|||
};
|
||||
|
||||
Event::Event(EventHandler *handler)
|
||||
:EventBase(handler)
|
||||
{
|
||||
:EventBase(handler) {
|
||||
d = new PrivateData;
|
||||
d->event = CreateEvent(NULL, true, false, NULL);
|
||||
}
|
||||
|
|
|
@ -29,8 +29,7 @@ Socket::Socket() {
|
|||
d->running = true;
|
||||
}
|
||||
|
||||
Socket::Socket(SOCKET_T hPipe)
|
||||
{
|
||||
Socket::Socket(SOCKET_T hPipe) {
|
||||
d = new PrivateData;
|
||||
d->hPipe = hPipe;
|
||||
d->connected = true;
|
||||
|
@ -38,7 +37,7 @@ Socket::Socket(SOCKET_T hPipe)
|
|||
}
|
||||
|
||||
|
||||
Socket::~Socket(void){
|
||||
Socket::~Socket(void) {
|
||||
d->running = false;
|
||||
SetEvent(d->readEvent); //signal for break
|
||||
if (d->hPipe != INVALID_HANDLE_VALUE) {
|
||||
|
@ -48,7 +47,7 @@ Socket::~Socket(void){
|
|||
delete d;
|
||||
}
|
||||
|
||||
void Socket::connect(const std::wstring &server){
|
||||
void Socket::connect(const std::wstring &server) {
|
||||
BOOL fSuccess = false;
|
||||
|
||||
std::wstring name(L"\\\\.\\pipe\\" + server);
|
||||
|
@ -79,7 +78,7 @@ void Socket::connect(const std::wstring &server){
|
|||
d->connected = true;
|
||||
}
|
||||
|
||||
void Socket::stopReadWait(){
|
||||
void Socket::stopReadWait() {
|
||||
d->running = false;
|
||||
SetEvent(d->readEvent);
|
||||
}
|
||||
|
@ -88,7 +87,7 @@ std::wstring Socket::read() {
|
|||
return read(INFINITE);
|
||||
}
|
||||
|
||||
std::wstring Socket::read(int timeout){
|
||||
std::wstring Socket::read(int timeout) {
|
||||
wchar_t buf[BUFSIZE];
|
||||
int result;
|
||||
DWORD cbBytesRead = 0;
|
||||
|
@ -102,7 +101,7 @@ std::wstring Socket::read(int timeout){
|
|||
std::wstring returnString;
|
||||
bool moreData = true;
|
||||
|
||||
while(moreData){
|
||||
while(moreData) {
|
||||
moreData = false;
|
||||
memset(&buf, 0, sizeof(buf));
|
||||
|
||||
|
@ -110,7 +109,7 @@ std::wstring Socket::read(int timeout){
|
|||
|
||||
result = WaitForSingleObject(oOverlap.hEvent, timeout);
|
||||
|
||||
if(!d->running){
|
||||
if(!d->running) {
|
||||
CancelIo(d->hPipe);
|
||||
WaitForSingleObject(oOverlap.hEvent, INFINITE);
|
||||
d->readEvent = 0;
|
||||
|
@ -127,17 +126,17 @@ std::wstring Socket::read(int timeout){
|
|||
if (!fSuccess) {
|
||||
DWORD err = GetLastError();
|
||||
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");
|
||||
}
|
||||
|
||||
if(err == ERROR_MORE_DATA){
|
||||
if(err == ERROR_MORE_DATA) {
|
||||
moreData = true;
|
||||
}
|
||||
else{
|
||||
else {
|
||||
buf[0] = 0;
|
||||
}
|
||||
if (err == ERROR_BROKEN_PIPE){
|
||||
if (err == ERROR_BROKEN_PIPE) {
|
||||
debuglog(static_cast<int>(err), "Got an error, close this socket");
|
||||
d->connected = false;
|
||||
break; // TODO(stefan): is this correct?
|
||||
|
@ -150,7 +149,7 @@ std::wstring Socket::read(int timeout){
|
|||
return returnString;
|
||||
}
|
||||
|
||||
void Socket::write(const std::wstring &msg){
|
||||
void Socket::write(const std::wstring &msg) {
|
||||
|
||||
OVERLAPPED oOverlap;
|
||||
DWORD bytesWritten = 0;
|
||||
|
@ -176,7 +175,7 @@ void Socket::write(const std::wstring &msg){
|
|||
return;
|
||||
}
|
||||
fSuccess = GetOverlappedResult(d->hPipe, &oOverlap, &bytesWritten, TRUE);
|
||||
if (!fSuccess){
|
||||
if (!fSuccess) {
|
||||
debuglog(result, "Error in GetOverlappedResult");
|
||||
result = GetLastError();
|
||||
debuglog(result, "Error in GetOverlappedResult, this message");
|
||||
|
@ -193,7 +192,7 @@ void Socket::write(const std::wstring &msg){
|
|||
}
|
||||
}
|
||||
|
||||
bool Socket::isConnected(){
|
||||
bool Socket::isConnected() {
|
||||
return d->connected;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ inline void dlog(const char *fmt, ...) {
|
|||
fflush(stdout);
|
||||
}
|
||||
|
||||
inline void debuglogfilename(const int intMessage, const std::string strMessage, const std::string filename){
|
||||
inline void debuglogfilename(const int intMessage, const std::string strMessage, const std::string filename) {
|
||||
|
||||
#ifdef _WINDOWS
|
||||
static bool firstRun = true;
|
||||
|
@ -76,12 +76,12 @@ inline void debuglogfilename(const int intMessage, const std::string strMessage,
|
|||
#endif
|
||||
}
|
||||
|
||||
inline void debuglogservice(const int intMessage, const std::string strMessage){
|
||||
inline void debuglogservice(const int intMessage, const std::string strMessage) {
|
||||
std::string filename("C:/telldus_service_debug.txt");
|
||||
debuglogfilename(intMessage, strMessage, filename);
|
||||
}
|
||||
|
||||
inline void debuglog(const int intMessage, const std::string strMessage){
|
||||
inline void debuglog(const int intMessage, const std::string strMessage) {
|
||||
std::string filename("C:/telldus_client_debug.txt");
|
||||
debuglogfilename(intMessage, strMessage, filename);
|
||||
}
|
||||
|
|
|
@ -23,8 +23,7 @@ public:
|
|||
TelldusCore::EventRef waitEvent;
|
||||
};
|
||||
|
||||
ConnectionListener::ConnectionListener(const std::wstring &name, TelldusCore::EventRef waitEvent)
|
||||
{
|
||||
ConnectionListener::ConnectionListener(const std::wstring &name, TelldusCore::EventRef waitEvent) {
|
||||
d = new PrivateData;
|
||||
d->hEvent = 0;
|
||||
|
||||
|
@ -65,8 +64,7 @@ ConnectionListener::ConnectionListener(const std::wstring &name, TelldusCore::Ev
|
|||
if (!SetSecurityDescriptorDacl(pSD,
|
||||
TRUE, // bDaclPresent flag
|
||||
pACL,
|
||||
FALSE)) // not a default DACL
|
||||
{
|
||||
FALSE)) { // not a default DACL
|
||||
LocalFree(pSD);
|
||||
FreeSid(pEveryoneSID);
|
||||
}
|
||||
|
@ -123,7 +121,7 @@ void ConnectionListener::run() {
|
|||
alreadyConnected = GetLastError() == ERROR_PIPE_CONNECTED;
|
||||
recreate = false;
|
||||
}
|
||||
if(!alreadyConnected){
|
||||
if(!alreadyConnected) {
|
||||
DWORD result = WaitForSingleObject(oOverlap.hEvent, 1000);
|
||||
if (!d->running) {
|
||||
CancelIo(hPipe);
|
||||
|
@ -131,7 +129,7 @@ void ConnectionListener::run() {
|
|||
break;
|
||||
}
|
||||
|
||||
if(result == WAIT_TIMEOUT){
|
||||
if(result == WAIT_TIMEOUT) {
|
||||
//CloseHandle(hPipe);
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
#include "common/Strings.h"
|
||||
#include "common/common.h" //debug
|
||||
|
||||
inline int random( unsigned int* seed ){
|
||||
inline int random( unsigned int* seed ) {
|
||||
#ifdef _WINDOWS
|
||||
unsigned int randomNumber;
|
||||
rand_s( &randomNumber ); //no seed needed
|
||||
|
|
|
@ -61,7 +61,7 @@ int Settings::getNumberOfNodes(Node type) const {
|
|||
|
||||
long lnExists = RegOpenKeyEx(d->rootKey, d->getNodePath(type).c_str(), 0, KEY_QUERY_VALUE, &hk);
|
||||
|
||||
if(lnExists == ERROR_SUCCESS){
|
||||
if(lnExists == ERROR_SUCCESS) {
|
||||
|
||||
std::wstring strNumSubKeys;
|
||||
DWORD dNumSubKeys;
|
||||
|
@ -83,7 +83,7 @@ int Settings::getNodeId(Node type, int intNodeIndex) const {
|
|||
|
||||
long lnExists = RegOpenKeyEx(d->rootKey, d->getNodePath(type).c_str(), 0, KEY_READ, &hk);
|
||||
|
||||
if(lnExists == ERROR_SUCCESS){
|
||||
if(lnExists == ERROR_SUCCESS) {
|
||||
|
||||
wchar_t* Buff = new wchar_t[intMaxRegValueLength];
|
||||
DWORD size = intMaxRegValueLength;
|
||||
|
@ -132,14 +132,14 @@ int Settings::getNextNodeId(Node type) const {
|
|||
|
||||
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 nResult(0);
|
||||
|
||||
long lngStatus = RegQueryValueEx(hk, L"LastUsedId", NULL, NULL, reinterpret_cast<LPBYTE>(&nResult), &dwLength);
|
||||
|
||||
if(lngStatus == ERROR_SUCCESS){
|
||||
if(lngStatus == ERROR_SUCCESS) {
|
||||
intReturn = nResult + 1;
|
||||
} else {
|
||||
intReturn = 1;
|
||||
|
@ -163,7 +163,7 @@ int Settings::removeNode(Node type, int intNodeId) {
|
|||
|
||||
long lngSuccess = RegDeleteKey(d->rootKey, strCompleteRegPath.c_str());
|
||||
|
||||
if(lngSuccess == ERROR_SUCCESS){
|
||||
if(lngSuccess == ERROR_SUCCESS) {
|
||||
//one of the deletions succeeded
|
||||
return TELLSTICK_SUCCESS;
|
||||
}
|
||||
|
@ -171,19 +171,19 @@ int Settings::removeNode(Node type, int intNodeId) {
|
|||
return TELLSTICK_ERROR_UNKNOWN;
|
||||
}
|
||||
|
||||
std::wstring Settings::getSetting(const std::wstring &strName) const{
|
||||
std::wstring Settings::getSetting(const std::wstring &strName) const {
|
||||
std::wstring strReturn;
|
||||
HKEY hk;
|
||||
|
||||
std::wstring strCompleteRegPath = d->strRegPath;
|
||||
long lnExists = RegOpenKeyEx(d->rootKey, strCompleteRegPath.c_str(), 0, KEY_QUERY_VALUE, &hk);
|
||||
|
||||
if(lnExists == ERROR_SUCCESS){
|
||||
if(lnExists == ERROR_SUCCESS) {
|
||||
wchar_t* Buff = new wchar_t[intMaxRegValueLength];
|
||||
DWORD dwLength = sizeof(wchar_t)*intMaxRegValueLength;
|
||||
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
|
||||
delete[] Buff;
|
||||
Buff = new wchar_t[dwLength];
|
||||
|
@ -206,12 +206,12 @@ std::wstring Settings::getStringSetting(Node type, int intNodeId, const std::wst
|
|||
strCompleteRegPath.append(TelldusCore::intToWstring(intNodeId));
|
||||
long lnExists = RegOpenKeyEx(d->rootKey, strCompleteRegPath.c_str(), 0, KEY_QUERY_VALUE, &hk);
|
||||
|
||||
if(lnExists == ERROR_SUCCESS){
|
||||
if(lnExists == ERROR_SUCCESS) {
|
||||
wchar_t* Buff = new wchar_t[intMaxRegValueLength];
|
||||
DWORD dwLength = sizeof(wchar_t)*intMaxRegValueLength;
|
||||
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
|
||||
delete[] Buff;
|
||||
Buff = new wchar_t[dwLength];
|
||||
|
@ -236,7 +236,7 @@ int Settings::setStringSetting(Node type, int intNodeId, const std::wstring &nam
|
|||
strCompleteRegPath.append(strNodeId);
|
||||
long lnExists = RegOpenKeyEx(d->rootKey, strCompleteRegPath.c_str(), 0, KEY_WRITE, &hk);
|
||||
|
||||
if (lnExists == ERROR_SUCCESS){
|
||||
if (lnExists == ERROR_SUCCESS) {
|
||||
int length = static_cast<int>(value.length()) * sizeof(wchar_t);
|
||||
RegSetValueEx(hk, name.c_str(), 0, REG_SZ, (LPBYTE)value.c_str(), length+1);
|
||||
} else {
|
||||
|
|
|
@ -20,8 +20,7 @@ static const GUID GUID_DEVINTERFACE_USBRAW =
|
|||
{ 0xA5DCBF10L, 0x6530, 0x11D2, { 0x90, 0x1F, 0x00, 0xC0, 0x4F, 0xB9, 0x51, 0xED } };
|
||||
|
||||
TelldusWinService::TelldusWinService()
|
||||
:tm(0)
|
||||
{
|
||||
:tm(0) {
|
||||
tm = new TelldusMain();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue