Return an appropriate error code instead of true/false in tdUnregisterCallback(), closes #200

This commit is contained in:
Micke Prag 2012-04-13 11:22:47 +02:00
parent 8babf9913d
commit 1e6767fa65
5 changed files with 7 additions and 7 deletions

View file

@ -64,7 +64,7 @@ int CallbackMainDispatcher::registerCallback(CallbackStruct::CallbackType type,
return id; return id;
} }
bool CallbackMainDispatcher::unregisterCallback(int callbackId) { int CallbackMainDispatcher::unregisterCallback(int callbackId) {
CallbackList newEventList; CallbackList newEventList;
{ {
TelldusCore::MutexLocker locker(&d->mutex); TelldusCore::MutexLocker locker(&d->mutex);
@ -83,9 +83,9 @@ bool CallbackMainDispatcher::unregisterCallback(int callbackId) {
} }
delete (*it); delete (*it);
newEventList.erase(it); newEventList.erase(it);
return true; return TELLSTICK_SUCCESS;
} }
return false; return TELLSTICK_ERROR_NOT_FOUND;
} }
void CallbackMainDispatcher::run(){ void CallbackMainDispatcher::run(){

View file

@ -26,7 +26,7 @@ namespace TelldusCore {
EventRef retrieveCallbackEvent(); EventRef retrieveCallbackEvent();
int registerCallback( TelldusCore::CallbackStruct::CallbackType type, void *eventFunction, void *context ); int registerCallback( TelldusCore::CallbackStruct::CallbackType type, void *eventFunction, void *context );
bool unregisterCallback( int callbackId ); int unregisterCallback( int callbackId );
protected: protected:
void run(); void run();

View file

@ -185,7 +185,7 @@ void Client::stopThread(){
d->eventSocket.stopReadWait(); d->eventSocket.stopReadWait();
} }
bool Client::unregisterCallback( int callbackId ) { int Client::unregisterCallback( int callbackId ) {
return d->callbackMainDispatcher.unregisterCallback(callbackId); return d->callbackMainDispatcher.unregisterCallback(callbackId);
} }

View file

@ -17,7 +17,7 @@ namespace TelldusCore {
int registerEvent(CallbackStruct::CallbackType type, void *eventFunction, void *context ); int registerEvent(CallbackStruct::CallbackType type, void *eventFunction, void *context );
void stopThread(void); void stopThread(void);
bool unregisterCallback( int callbackId ); int unregisterCallback( int callbackId );
int getSensor(char *protocol, int protocolLen, char *model, int modelLen, int *id, int *dataTypes); int getSensor(char *protocol, int protocolLen, char *model, int modelLen, int *id, int *dataTypes);
int getController(int *controllerId, int *controllerType, char *name, int nameLen, int *available); int getController(int *controllerId, int *controllerType, char *name, int nameLen, int *available);

View file

@ -425,7 +425,7 @@ int WINAPI tdRegisterControllerEvent( TDControllerEvent eventFunction, void *con
* The returned id from one of the tdRegister* functions. * The returned id from one of the tdRegister* functions.
* *
* @returns * @returns
* 1 on success, or 0 on failure. * @ref TELLSTICK_SUCCESS on success or appropriate error code on failure.
* *
* @sa @ref sec_events_registering * @sa @ref sec_events_registering
* @since Version 2.1.0 * @since Version 2.1.0