From bda20c75f0eb821d64296ee21455637a7489723b Mon Sep 17 00:00:00 2001 From: Erik Johansson Date: Tue, 6 Mar 2012 13:51:06 +0100 Subject: [PATCH 1/7] Remove stray statement --- telldus-core/client/telldus-core.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telldus-core/client/telldus-core.cpp b/telldus-core/client/telldus-core.cpp index 8108f761..b75ff14f 100644 --- a/telldus-core/client/telldus-core.cpp +++ b/telldus-core/client/telldus-core.cpp @@ -110,7 +110,7 @@ void WINAPI tdInit(void) { * Added in version 2.0.0. **/ int WINAPI tdRegisterDeviceEvent( TDDeviceEvent eventFunction, void *context ) { - eventFunction; Client *client = Client::getInstance(); + Client *client = Client::getInstance(); return client->registerEvent( CallbackStruct::DeviceEvent, (void *)eventFunction, context ); } From e921be65b427d1473693ad89d469c4e15449b773 Mon Sep 17 00:00:00 2001 From: Erik Johansson Date: Tue, 6 Mar 2012 13:53:39 +0100 Subject: [PATCH 2/7] Fix variable name in code example --- docs/01-telldus-core.dox | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/01-telldus-core.dox b/docs/01-telldus-core.dox index d7df9100..b5987450 100644 --- a/docs/01-telldus-core.dox +++ b/docs/01-telldus-core.dox @@ -44,7 +44,7 @@ * \code * int intNumberOfDevices = tdGetNumberOfDevices(); * for (int i = 0; i < intNumberOfDevices; i++) { - * int id = tdGetDeviceId( index ); + * int id = tdGetDeviceId( i ); * char *name = tdGetName( id ); * printf("%d\t%s\n", id, name); * tdReleaseString(name); From 1108f3fad26f744c2418d22a547a17669522ce2e Mon Sep 17 00:00:00 2001 From: Erik Johansson Date: Tue, 6 Mar 2012 13:58:31 +0100 Subject: [PATCH 3/7] Return type for callbacks is void, not void* --- examples/python/callbacks.py | 10 +++++----- examples/python/sensors/sensorscallback.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/python/callbacks.py b/examples/python/callbacks.py index 2108fd28..a5a02a27 100644 --- a/examples/python/callbacks.py +++ b/examples/python/callbacks.py @@ -58,11 +58,11 @@ def rawcallbackfunction(data, controllerId, callbackId, context): print string_at(data) if (platform.system() == 'Windows'): - CMPFUNC = WINFUNCTYPE(c_void_p, c_int, c_int, POINTER(c_ubyte), c_int, c_void_p) #first is return type - CMPFUNCRAW = WINFUNCTYPE(c_void_p, POINTER(c_ubyte), c_int, c_int, c_void_p) + CMPFUNC = WINFUNCTYPE(None, c_int, c_int, POINTER(c_ubyte), c_int, c_void_p) #first is return type + CMPFUNCRAW = WINFUNCTYPE(None, POINTER(c_ubyte), c_int, c_int, c_void_p) else: - CMPFUNC = CFUNCTYPE(c_void_p, c_int, c_int, POINTER(c_ubyte), c_int, c_void_p) - CMPFUNCRAW = CFUNCTYPE(c_void_p, POINTER(c_ubyte), c_int, c_int, c_void_p) + CMPFUNC = CFUNCTYPE(None, c_int, c_int, POINTER(c_ubyte), c_int, c_void_p) + CMPFUNCRAW = CFUNCTYPE(None, POINTER(c_ubyte), c_int, c_int, c_void_p) cmp_func = CMPFUNC(callbackfunction) cmp_funcraw = CMPFUNCRAW(rawcallbackfunction) @@ -73,4 +73,4 @@ lib.tdRegisterDeviceEvent(cmp_func, 0) print "Waiting for events..." while(1): - time.sleep(0.5) #don't exit \ No newline at end of file + time.sleep(0.5) #don't exit diff --git a/examples/python/sensors/sensorscallback.py b/examples/python/sensors/sensorscallback.py index 7a592b89..8dc5ffd8 100644 --- a/examples/python/sensors/sensorscallback.py +++ b/examples/python/sensors/sensorscallback.py @@ -29,9 +29,9 @@ def callbackfunction(protocol, model, id, dataType, value, timestamp, callbackId if (platform.system() == 'Windows'): - CMPFUNC = WINFUNCTYPE(c_void_p, POINTER(c_ubyte), POINTER(c_ubyte), c_int, c_int, POINTER(c_ubyte), c_int, c_int, c_void_p) #first is return type + CMPFUNC = WINFUNCTYPE(None, POINTER(c_ubyte), POINTER(c_ubyte), c_int, c_int, POINTER(c_ubyte), c_int, c_int, c_void_p) #first is return type else: - CMPFUNC = CFUNCTYPE(c_void_p, POINTER(c_ubyte), POINTER(c_ubyte), c_int, c_int, POINTER(c_ubyte), c_int, c_int, c_void_p) + CMPFUNC = CFUNCTYPE(None, POINTER(c_ubyte), POINTER(c_ubyte), c_int, c_int, POINTER(c_ubyte), c_int, c_int, c_void_p) cmp_func = CMPFUNC(callbackfunction) From 902c12d88d93b6cd0438380e4cce3a7ad409bbb1 Mon Sep 17 00:00:00 2001 From: Erik Johansson Date: Sat, 17 Mar 2012 19:16:27 +0100 Subject: [PATCH 4/7] The controller added callback should pass the controller type This unifies the behavior between loadControllers() and loadStoredControllers(). --- telldus-core/service/ControllerManager.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/telldus-core/service/ControllerManager.cpp b/telldus-core/service/ControllerManager.cpp index 2ccfa9a6..449bf0eb 100644 --- a/telldus-core/service/ControllerManager.cpp +++ b/telldus-core/service/ControllerManager.cpp @@ -199,9 +199,10 @@ void ControllerManager::loadStoredControllers() { int id = d->settings.getNodeId(Settings::Controller, i); d->controllers[id].controller = NULL; d->controllers[id].name = d->settings.getName(Settings::Controller, id); - d->controllers[id].type = d->settings.getControllerType(id); + const int type = d->settings.getControllerType(id); + d->controllers[id].type = type; d->controllers[id].serial = d->settings.getControllerSerial(id); - signalControllerEvent(id, TELLSTICK_DEVICE_ADDED, 0, L""); + signalControllerEvent(id, TELLSTICK_DEVICE_ADDED, type, L""); } } From bd0e01bfad11eb25ae31c148bd8352cb8f904939 Mon Sep 17 00:00:00 2001 From: Erik Johansson Date: Mon, 19 Mar 2012 10:50:43 +0100 Subject: [PATCH 5/7] Correct spelling in error message --- telldus-core/client/telldus-core.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telldus-core/client/telldus-core.cpp b/telldus-core/client/telldus-core.cpp index b75ff14f..211966cb 100644 --- a/telldus-core/client/telldus-core.cpp +++ b/telldus-core/client/telldus-core.cpp @@ -594,7 +594,7 @@ char * WINAPI tdGetErrorString(int intErrorNo) { "Received an unknown response", "Syntax error", "Broken pipe" - "An error occured while communicating with the Telldus Service" + "An error occurred while communicating with the Telldus Service" }; std::string strReturn; intErrorNo = abs(intErrorNo); //We don't use negative values here. From 5492623ecd4ceae1c3128c43a2a3f6ba3e9f2e3f Mon Sep 17 00:00:00 2001 From: Erik Johansson Date: Tue, 20 Mar 2012 16:37:56 +0100 Subject: [PATCH 6/7] Avoid one extra strlen --- telldus-core/common/Strings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telldus-core/common/Strings.cpp b/telldus-core/common/Strings.cpp index 5bee53a9..c1f53411 100644 --- a/telldus-core/common/Strings.cpp +++ b/telldus-core/common/Strings.cpp @@ -39,7 +39,7 @@ std::wstring TelldusCore::charToWstring(const char *value) { size_t outbytesLeft = utf8Length*sizeof(wchar_t); //Copy the instring - char *inString = new char[strlen(value)+1]; + char *inString = new char[utf8Length+1]; strcpy(inString, value); //Create buffer for output From 3bedad336a51ad14afdfd3c50223dea77ade23fb Mon Sep 17 00:00:00 2001 From: Erik Johansson Date: Wed, 21 Mar 2012 16:20:23 +0100 Subject: [PATCH 7/7] Make tdadmin handle only one parameter w/o crashing Fixes SIGSEGV when running tdadmin - (ticket #194). --- telldus-core/tdadmin/main.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/telldus-core/tdadmin/main.cpp b/telldus-core/tdadmin/main.cpp index cb4b3b59..66f7fcb0 100644 --- a/telldus-core/tdadmin/main.cpp +++ b/telldus-core/tdadmin/main.cpp @@ -47,6 +47,9 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) { argp_usage (state); case ARGP_KEY_ARG: + if (state->next == state->argc) { + argp_usage (state); + } command = arg; action = state->argv[state->next]; state->next = state->argc;