Showing the changes to libraries/script-engine/src/LocationScriptingInterface.cpp (1 of 6 files). Show all
Unified · Split
| @@ -0,0 +1,36 @@ | |||
| 1 | // | ||
| 2 | // LocationScriptingInterface.cpp | ||
| 3 | // libraries/script-engine/src | ||
| 4 | // | ||
| 5 | // Created by Ryan Huffman on 4/29/14. | ||
| 6 | // Copyright 2014 High Fidelity, Inc. | ||
| 7 | // | ||
| 8 | // Distributed under the Apache License, Version 2.0. | ||
| 9 | // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html | ||
| 10 | // | ||
| 11 | |||
| 12 | #include "LocationScriptingInterface.h" | ||
| 13 | |||
| 14 | #include <AddressManager.h> | ||
| 15 | #include "ScriptContext.h" | ||
| 16 | #include "ScriptEngine.h" | ||
| 17 | #include "ScriptValue.h" | ||
| 18 | |||
| 19 | LocationScriptingInterface* LocationScriptingInterface::getInstance() { | ||
| 20 | static LocationScriptingInterface sharedInstance; | ||
| 21 | return &sharedInstance; | ||
| 22 | } | ||
| 23 | |||
| 24 | ScriptValuePointer LocationScriptingInterface::locationGetter(ScriptContext* context, ScriptEngine* engine) { | ||
| 25 | return engine->newQObject(DependencyManager::get<AddressManager>().data()); | ||
| 26 | } | ||
| 27 | |||
| 28 | ScriptValuePointer LocationScriptingInterface::locationSetter(ScriptContext* context, ScriptEngine* engine) { | ||
| 29 | const QVariant& argumentVariant = context->argument(0)->toVariant(); | ||
| 30 | |||
| 31 | // just try and convert the argument to a string, should be a hifi:// address | ||
| 32 | QMetaObject::invokeMethod(DependencyManager::get<AddressManager>().data(), "handleLookupString", | ||
| 33 | Q_ARG(const QString&, argumentVariant.toString())); | ||
| 34 | |||
| 35 | return engine->undefinedValue(); | ||
| 36 | } | ||