Implement tdSetControllerValue in TelldusService
This commit is contained in:
parent
f8226be943
commit
979e6082c2
3 changed files with 23 additions and 0 deletions
|
@ -234,6 +234,12 @@ void ClientCommunicationHandler::parseMessage(const std::wstring &clientMessage,
|
||||||
} else if (function == L"tdController") {
|
} else if (function == L"tdController") {
|
||||||
(*wstringReturn) = d->controllerManager->getControllers();
|
(*wstringReturn) = d->controllerManager->getControllers();
|
||||||
|
|
||||||
|
} else if (function == L"tdSetControllerValue") {
|
||||||
|
int id = TelldusCore::Message::takeInt(&msg);
|
||||||
|
std::wstring name = TelldusCore::Message::takeString(&msg);
|
||||||
|
std::wstring value = TelldusCore::Message::takeString(&msg);
|
||||||
|
(*intReturn) = d->controllerManager->setControllerValue(id, name, value);
|
||||||
|
|
||||||
} else{
|
} else{
|
||||||
(*intReturn) = TELLSTICK_ERROR_UNKNOWN;
|
(*intReturn) = TELLSTICK_ERROR_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "TellStick.h"
|
#include "TellStick.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "Message.h"
|
#include "Message.h"
|
||||||
|
#include "Strings.h"
|
||||||
#include "../client/telldus-core.h"
|
#include "../client/telldus-core.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -219,3 +220,18 @@ std::wstring ControllerManager::getControllers() const {
|
||||||
}
|
}
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ControllerManager::setControllerValue(int id, const std::wstring &name, const std::wstring &value) {
|
||||||
|
TelldusCore::MutexLocker locker(&d->mutex);
|
||||||
|
|
||||||
|
ControllerMap::iterator it = d->controllers.find(id);
|
||||||
|
if (it == d->controllers.end()) {
|
||||||
|
return TELLSTICK_ERROR_NOT_FOUND;
|
||||||
|
}
|
||||||
|
if (name == L"name") {
|
||||||
|
it->second.name = TelldusCore::wideToString(value);
|
||||||
|
} else {
|
||||||
|
return TELLSTICK_ERROR_SYNTAX; //TODO: Is this the best error?
|
||||||
|
}
|
||||||
|
return TELLSTICK_SUCCESS;
|
||||||
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ public:
|
||||||
int resetController(Controller *controller);
|
int resetController(Controller *controller);
|
||||||
|
|
||||||
std::wstring getControllers() const;
|
std::wstring getControllers() const;
|
||||||
|
int setControllerValue(int id, const std::wstring &name, const std::wstring &value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class PrivateData;
|
class PrivateData;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue