Changeset a766fe


Ignore:
Timestamp:
02/23/12 12:34:31 (9 years ago)
Author:
Micke Prag <micke.prag@…>
Branches:
('master', 'cc326285c5d9e5d35ef50c97ddab57539e602594')
Children:
5238978d3243c07c73ee031758dea8a6745bdeb5
Parents:
3de0a98f89a6481ab9ffe89bb3d0a056599b8bda
git-author:
Micke Prag <micke.prag@telldus.se>2012-02-23 12:34:31+01:00
git-committer:
Micke Prag <micke.prag@telldus.se>2012-02-23 12:34:31+01:00
Message:

Add public function tdRemoveController() to telldus-core, see #108

Location:
telldus-core
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • telldus-core/client/telldus-core.cpp

    r345ff6 ra766fe  
    759759} 
    760760 
     761/** 
     762 * This function removes a controller from the list 
     763 * of controllers. The controller must not be 
     764 * available (disconnected) for this to work. 
     765 * 
     766 * Added in version 2.1.2. 
     767 * @param controllerId The controller to remove 
     768 * @returns TELLSTICK_SUCCESS if the controller was 
     769 * removed, TELLSTICK_ERROR_NOT_FOUND if the controller was 
     770 * not found, and TELLSTICK_ERROR_PERMISSION_DENIED if the 
     771 * controller is still connected. 
     772 **/ 
     773int WINAPI tdRemoveController(int controllerId) { 
     774        Message msg(L"tdRemoveController"); 
     775        msg.addArgument(controllerId); 
     776        return Client::getIntegerFromService(msg); 
     777} 
     778 
    761779/* @} */ 
  • telldus-core/client/telldus-core.h

    r345ff6 ra766fe  
    9090        TELLSTICK_API int WINAPI tdControllerValue(int controllerId, const char *name, char *value, int valueLen); 
    9191        TELLSTICK_API int WINAPI tdSetControllerValue(int controllerId, const char *name, const char *value); 
     92        TELLSTICK_API int WINAPI tdRemoveController(int controllerId); 
    9293 
    9394#ifdef __cplusplus 
  • telldus-core/service/ClientCommunicationHandler.cpp

    r345ff6 ra766fe  
    246246                (*intReturn) = d->controllerManager->setControllerValue(id, name, value); 
    247247 
     248        } else if (function == L"tdRemoveController") { 
     249                int controllerId = TelldusCore::Message::takeInt(&msg); 
     250                (*intReturn) = d->controllerManager->removeController(controllerId); 
     251 
    248252        } else{ 
    249253                (*intReturn) = TELLSTICK_ERROR_UNKNOWN; 
  • telldus-core/service/ControllerManager.cpp

    r345ff6 ra766fe  
    277277} 
    278278 
     279int ControllerManager::removeController(int id) { 
     280        TelldusCore::MutexLocker locker(&d->mutex); 
     281 
     282        ControllerMap::iterator it = d->controllers.find(id); 
     283        if (it == d->controllers.end()) { 
     284                return TELLSTICK_ERROR_NOT_FOUND; 
     285        } 
     286        if (it->second.controller) { 
     287                //Still connected 
     288                return TELLSTICK_ERROR_PERMISSION_DENIED; 
     289        } 
     290 
     291        int ret = d->settings.removeNode(Settings::Controller, id); 
     292        if (ret != TELLSTICK_SUCCESS) { 
     293                return ret; 
     294        } 
     295 
     296        d->controllers.erase(it); 
     297 
     298        //TODO: signal 
     299        return TELLSTICK_SUCCESS; 
     300} 
     301 
    279302int ControllerManager::setControllerValue(int id, const std::wstring &name, const std::wstring &value) { 
    280303        TelldusCore::MutexLocker locker(&d->mutex); 
  • telldus-core/service/ControllerManager.h

    r345ff6 ra766fe  
    2424        std::wstring getControllers() const; 
    2525        std::wstring getControllerValue(int id, const std::wstring &name); 
     26        int removeController(int id); 
    2627        int setControllerValue(int id, const std::wstring &name, const std::wstring &value); 
    2728 
Note: See TracChangeset for help on using the changeset viewer.