+++ /dev/null
-#ifndef TIZENAPIS_API_VEHICLE_EVENT_PROPERTY_CHANGED_H_
-#define TIZENAPIS_API_VEHICLE_EVENT_PROPERTY_CHANGED_H_
-
-#include <Commons/IEvent.h>
-#include <dpl/shared_ptr.h>
-
-namespace DeviceAPI {
-namespace Vehicle {
-
-class EventVehiclePropertyChanged : public WrtDeviceApis::Commons::IEvent<EventVehiclePropertyChanged>
-{
-private:
- /* parameter */
- std::string m_contextId;
-
-public:
- void setContextId(std::string contextId)
- {
- m_contextId = contextId;
- }
-
- std::string getContextId() const
- {
- return m_contextId;
- }
-
- EventVehiclePropertyChanged()
- {
- }
-};
-
-typedef DPL::SharedPtr<EventVehiclePropertyChanged> EventVehiclePropertyChangedPtr;
-
-} // Application
-} // DeviceAPI
-
-#endif
\ No newline at end of file
+++ /dev/null
-#include "JSVehicle.h"
-#include "Vehicle.h"
-
-#include <Logger.h>
-#include <Commons/Exception.h>
-#include <CommonsJavaScript/Utils.h>
-#include <CommonsJavaScript/JSCallbackManager.h>
-#include <JSWebAPIErrorFactory.h>
-#include <ArgumentValidator.h>
-#include <CommonsJavaScript/Converter.h>
-#include <sstream>
-
-#include <abstractpropertytype.h>
-
-namespace DeviceAPI {
-namespace Vehicle {
-
-using namespace DPL;
-using namespace DeviceAPI::Common;
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-
-JSClassDefinition JSVehicle::m_classInfo = {
- 0,
- kJSClassAttributeNone,
- "Vehicle",
- 0,
- NULL,
- m_function,
- initialize,
- finalize,
- NULL, //HasProperty,
- NULL, //GetProperty,
- NULL, //SetProperty,
- NULL, //DeleteProperty,
- NULL, //GetPropertyNames,
- NULL, //CallAsFunction,
- NULL, //CallAsConstructor,
- hasInstance,
- NULL, //ConvertToType
-};
-
-JSStaticFunction JSVehicle::m_function[] = {
- { "get", JSVehicle::get, kJSPropertyAttributeNone },
- { 0, 0, 0 }
-};
-
-const JSClassRef JSVehicle::getClassRef()
-{
- if (!m_jsClassRef)
- {
- m_jsClassRef = JSClassCreate(&m_classInfo);
- }
- return m_jsClassRef;
-}
-
-const JSClassDefinition* JSVehicle::getClassInfo()
-{
- return &m_classInfo;
-}
-
-JSClassRef JSVehicle::m_jsClassRef = JSClassCreate(JSVehicle::getClassInfo());
-
-void JSVehicle::initialize(JSContextRef context, JSObjectRef object)
-{
- VehiclePrivObject* priv = static_cast<VehiclePrivObject*>(JSObjectGetPrivate(object));
- if (!priv)
- {
- VehiclePtr vehicle(new VehicleMaster());
- priv = new VehiclePrivObject( context, vehicle);
- if(!JSObjectSetPrivate(object, static_cast<void*>(priv)))
- {
- LoggerE("Object can't store private data.");
- delete priv;
- }
- }
-
- LoggerD("JSVehicle::initialize ");
-}
-
-void JSVehicle::finalize(JSObjectRef object)
-{
- VehiclePrivObject* priv = static_cast<VehiclePrivObject*>(JSObjectGetPrivate(object));
- JSObjectSetPrivate(object, NULL);
- LoggerD("Deleting timeutil");
- delete priv;
-}
-
-bool JSVehicle::hasInstance(JSContextRef context,
- JSObjectRef constructor,
- JSValueRef possibleInstance,
- JSValueRef* exception)
-{
- return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
-}
-
-
-JSValueRef JSVehicle::get(JSContextRef context,
- JSObjectRef object,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception)
-{
- LoggerD("Entered ");
- //Try {
- VehiclePrivObject* privateObject = static_cast<VehiclePrivObject*>(JSObjectGetPrivate(thisObject));
- if (NULL == privateObject)
- {
- LoggerE("private object is null");
- //return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
- }
-
- ArgumentValidator validator(context, argumentCount, arguments);
- std::string property = validator.toString(0);
-
- VehiclePtr vehicle(privateObject->getObject());
-
- std::list<AbstractPropertyType*> properties = vehicle->get(property);
-
- std::stringstream json;
-
-
- json<<"{";
-
- for(auto itr = properties.begin(); itr != properties.end(); itr++)
- {
- if(json.str() != "{") json<<",";
-
- AbstractPropertyType* p = *itr;
-
- json<<"\""<<p->name<<"\" : "<<p->toString();
-
- }
-
- json << "}";
-
- Converter converter(context);
-
- return converter.toJSValueRef(json.str());
-
-
- /*} Catch (PlatformException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- } Catch(NullPointerException) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
- } Catch (WrtDeviceApis::Commons::Exception) {
- LoggerE("Exception: " << _rethrown_exception.GetMessage());
- }*/
-
- //return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-}
-}
-}
+++ /dev/null
-#ifndef JSVEHICLE_H
-#define JSVEHICLE_H
-
-#include "Vehicle.h"
-#include <dpl/shared_ptr.h>
-#include <JavaScriptCore/JavaScript.h>
-#include <CommonsJavaScript/JSPendingOperationPrivateObject.h>
-#include <CommonsJavaScript/PrivateObject.h>
-
-namespace DeviceAPI {
-namespace Vehicle {
-
-typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<VehiclePtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> VehiclePrivObject;
-
-class JSVehicle
-{
-public:
- static const JSClassDefinition* getClassInfo();
-
- static const JSClassRef getClassRef();
-
-private:
- /**
- * The callback invoked when an object is first created.
- */
- static void initialize(JSContextRef context,
- JSObjectRef object);
-
- /**
- * The callback invoked when an object is finalized.
- */
- static void finalize(JSObjectRef object);
-
- /**
- * The callback invoked when an object is used as the target of an 'instanceof' expression.
- */
- static bool hasInstance(JSContextRef ctx,
- JSObjectRef constructor,
- JSValueRef possibleInstance,
- JSValueRef* exception);
-
- static JSValueRef get(JSContextRef context,
- JSObjectRef object,
- JSObjectRef thisObject,
- size_t argumentCount,
- const JSValueRef arguments[],
- JSValueRef* exception);
-
- /**
- * This structure contains properties and callbacks that define a type of object.
- */
- static JSClassDefinition m_classInfo;
-
- /**
- * This structure describes a statically declared function.
- */
- static JSStaticFunction m_function[];
-
- static JSClassRef m_jsClassRef;
-};
-
-}
-}
-
-#endif // JSVEHICLE_H
+++ /dev/null
-#include "Vehicle.h"
-#include <gio/gio.h>
-#include <stdexcept>
-#include <list>
-
-#include <Commons/ThreadPool.h>
-
-#include <abstractpropertytype.h>
-#include <vehicleproperty.h>
-
-
-namespace DeviceAPI
-{
-namespace Vehicle
-{
-
-using namespace WrtDeviceApis::Commons;
-
-VehicleMaster::VehicleMaster()
-:EventRequestReceiver<EventVehiclePropertyChanged>(ThreadEnum::APPLICATION_THREAD)
-{
-}
-
-
-
-std::list<AbstractPropertyType *> VehicleMaster::get(std::string property)
-{
- GError* error = NULL;
- GDBusProxy* managerProxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, NULL,
- "org.automotive.message.broker",
- "/",
- "org.automotive.Manager",
- NULL,
- &error);
-
- if(error)
- {
- throw std::runtime_error("could not get automotive message broker Manager interface");
- }
-
-
- GVariant* objectPath = g_dbus_proxy_call_sync(managerProxy, "findProperty", g_variant_new("(s)", property.c_str()), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
-
- const char* objP = g_variant_get_string(objectPath, NULL);
-
- if(std::string(objP) == "")
- {
- throw std::runtime_error("could not find property "+ property);
- }
-
- GDBusProxy* propertiesProxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, NULL,
- "org.automotive.message.broker",
- objP,
- "org.freedesktop.DBus.Properties",
- NULL,
- &error);
- std::string interfaceName = "org.automotive." + property;
-
- GVariant* propertyMap = g_dbus_proxy_call_sync(propertiesProxy, "GetAll", g_variant_new("(s)", interfaceName.c_str()), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
-
- if(error)
- {
- throw std::runtime_error("failed to call GetAll on interface " + interfaceName);
- }
-
- GVariantIter* iter;
- char* key;
- GVariant *value;
-
- std::list<AbstractPropertyType*> returnValue;
-
- g_variant_get(propertyMap,"(a{sv})",&iter);
-
- while(g_variant_iter_next(iter,"{sv}", &key, &value))
- {
- AbstractPropertyType* val = VehicleProperty::getPropertyTypeForPropertyNameValue(key);
- val->fromVariant(value);
- returnValue.push_back(val);
- }
-
- return returnValue;
-}
-
-void VehicleMaster::addEventListener(std::string property, EventVehiclePropertyChangedPtr& event)
-{
-
-}
-
-}
-}
\ No newline at end of file
+++ /dev/null
-#ifndef VEHICLE_H
-#define VEHICLE_H
-
-#include <list>
-#include <string>
-#include <dpl/mutex.h>
-#include <dpl/shared_ptr.h>
-
-#include "EventVehiclePropertyChanged.h"
-
-class AbstractPropertyType;
-
-namespace DeviceAPI {
-namespace Vehicle {
-
-class VehicleMaster: public WrtDeviceApis::Commons::EventRequestReceiver<EventVehiclePropertyChanged>
-{
-public:
-
- VehicleMaster();
-
- std::list<AbstractPropertyType*> get(std::string property);
-
- void addEventListener(std::string property, EventVehiclePropertyChangedPtr& event);
-
-
- void OnRequestReceived(const EventVehiclePropertyChangedPtr &event)
- {
- }
-};
-
-typedef DPL::SharedPtr<VehicleMaster> VehiclePtr;
-
-
-}
-}
-#endif // VEHICLE_H
+++ /dev/null
-//
-// Tizen Web Device API
-// Copyright (c) 2012 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Apache License, Version 2.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
-
-#include <Commons/plugin_initializer_def.h>
-#include <Commons/WrtAccess/WrtAccess.h>
-#include "JSVehicle.h"
-#include <Logger.h>
-
-namespace DeviceAPI {
-namespace Vehicle {
-
-using namespace WrtDeviceApis;
-using namespace WrtDeviceApis::Commons;
-
-class_definition_options_t ConstructorClassOptions =
-{
- JS_INTERFACE,
- CREATE_INSTANCE,
- NONE_NOTICE,
- USE_OVERLAYED, //ignored
- NULL,
- NULL,
- NULL
-};
-
-void on_widget_start_callback(int widgetId) {
- LoggerD("[TIZEN\\Vehicle] on_widget_start_callback ("<<widgetId<<")");
- Try
- {
- WrtAccessSingleton::Instance().initialize(widgetId);
- }
- Catch(Commons::Exception)
- {
- LoggerE("WrtAccess initialization failed");
- }
-}
-
-void on_widget_stop_callback(int widgetId) {
- LoggerD("[TIZEN\\Vehicle] on_widget_stop_callback ("<<widgetId<<")");
- Try
- {
- WrtAccessSingleton::Instance().deinitialize(widgetId);
- }
- Catch(Commons::Exception)
- {
- LoggerE("WrtAccess deinitialization failed");
- }
-}
-
-PLUGIN_ON_WIDGET_START(on_widget_start_callback)
-PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
-
-PLUGIN_CLASS_MAP_BEGIN
-PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
- "vehicle",
- (js_class_template_getter)JSVehicle::getClassRef,
- NULL)
-
-PLUGIN_CLASS_MAP_END
-
-} // Time
-} // DeviceAPI