+++ /dev/null
-[general]
-upstream_branch = tizen
-upstream_tag = ${upstreamversion}
+* Mon Jul 29 2013 <kevron.m.rees@intel.com>
+- added supported() call
+- fix for callback garbage collection
+- cleaned up code
+- sr to tizen
+
* Fri Jul 19 15:09:00 PST 2013 - <kevron.m.rees@intel.com>
- initial add of changelog
Name: wrt-plugins-ivi
Summary: JavaScript plugins for WebRuntime for IVI
-Version: 0.2.0
+Version: 0.3.0
Release: 1
Group: Development/Libraries
License: Apache License, Version 2.0
JSStaticFunction JSVehicle::m_function[] = {
{ "get", JSVehicle::get, kJSPropertyAttributeNone },
{ "subscribe", JSVehicle::subscribe, kJSPropertyAttributeNone },
+ { "supported", JSVehicle::supported, kJSPropertyAttributeNone },
{ 0, 0, 0 }
};
if (NULL == privateObject)
{
LoggerE("private object is null");
- //return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+ return JSValueMakeUndefined(context);
}
LoggerD("Validating arguments: " << argumentCount);
std::stringstream json;
+ if(!properties.size())
+ return JSValueMakeUndefined(context);
+
json<<"{";
for(auto itr = properties.begin(); itr != properties.end(); itr++)
// successCallback
JSObjectRef successCallback = validator.toFunction(1, true);
+
+ JSValueProtect(context, successCallback);
// errorCallback
//JSObjectRef errorCallback = validator.toFunction(2, true);
return JSValueMakeUndefined(context);
}
+JSValueRef JSVehicle::supported(JSContextRef context,
+ JSObjectRef object,
+ JSObjectRef thisObject,
+ size_t argumentCount,
+ const JSValueRef arguments[],
+ JSValueRef* exception)
+{
+ LoggerD("Entered");
+ 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");
+ }
+
+ VehiclePtr vehicle(privateObject->getObject());
+
+ GVariant * value = vehicle->listObjects();
+
+ gsize size;
+ std::string script;
+ std::string valStr = json_gvariant_serialize_data(value,&size);
+
+ LoggerD("array: " << valStr);
+
+ script = "return " + valStr;
+
+ JSStringRef scriptJS = JSStringCreateWithUTF8CString(script.c_str());
+ JSObjectRef fn = JSObjectMakeFunction(context, NULL, 0, NULL, scriptJS, NULL, 1, NULL);
+ JSValueRef result = JSObjectCallAsFunction(context, fn, NULL, 0, NULL, NULL);
+ JSStringRelease(scriptJS);
+
+ return result;
+}
+
}
}
size_t argumentCount,
const JSValueRef arguments[],
JSValueRef* exception);
+
+ static JSValueRef supported(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.
std::string VehicleMaster::findProperty(std::string objectName)
{
GDBusProxy* managerProxy = automotiveManager();
-
+
GError *error = nullptr;
GVariant* objectPath = g_dbus_proxy_call_sync(managerProxy, "findProperty", g_variant_new("(s)", objectName.c_str()), G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
LoggerE("Could not find property");
return "";
}
-
+
if(error)
{
LoggerD("error calling findProperty "<< error->message);
g_error_free(error);
return "";
}
-
+
LoggerD("returned object path: " << g_variant_get_type_string(objectPath));
-
+
gchar * objP;
g_variant_get(objectPath,"(o)", &objP);
-
+
LoggerD("findProperty() returned object path: " <<objP);
-
+
g_object_unref(managerProxy);
g_variant_unref(objectPath);
-
+
return objP;
}
void VehicleMaster::onSignalReceived(std::string objectName, std::map<std::string, GVariant*> propertyMap)
{
LoggerD("Entered");
-
+
std::stringstream json;
-
+
json<<"{";
for(auto itr = propertyMap.begin(); itr != propertyMap.end(); itr++)
LoggerD("get json: " << json.str().c_str());
JSStringRef jsonString = JSStringCreateWithUTF8CString(json.str().c_str());
-
+
std::list<VehicleSubscribeCB> cbs = objectToFunctionListMap[objectName];
-
+
if(!cbs.size())
{
LoggerD("No callbacks for this signal. aborting");
return;
}
-
+
auto cbitr = cbs.begin();
JSValueRef value = JSValueMakeFromJSONString((*cbitr).context, jsonString);
}
const JSValueRef arguments[1] = { value };
-
+
try{
for(auto itr = cbs.begin(); itr != cbs.end(); itr++)
{
}
}
+GVariant* VehicleMaster::listObjects()
+{
+ LoggerD("Entered");
+
+ GDBusProxy* managerProxy = automotiveManager();
+
+ GError *error = nullptr;
+
+ GVariant* supportedList = g_dbus_proxy_call_sync(managerProxy, "list", NULL, G_DBUS_CALL_FLAGS_NONE, -1, NULL, &error);
+
+ if(error)
+ {
+ LoggerD("error calling list "<< error->message);
+ g_error_free(error);
+ g_object_unref(managerProxy);
+ return NULL;
+ }
+
+ g_object_unref(managerProxy);
+ return supportedList;
+}
+
}
}
\ No newline at end of file
void subscribe(std::string objectName, JSObjectRef successCallback, JSContextRef context);
+ GVariant* listObjects();
+
void onSignalReceived(std::string objectName, std::map<std::string, GVariant*> propertyMap);
private: /// methods:
interface Vehicle {
/**
- * \brief returns supported properties
- * \arg VehiclePropertyCallback successCallback function to be called when method has completed successfully
- * \arg VehiclePropertyErrorCallback errorCallback this function is called when an error has occured.
+ * \brief returns supported object types
**/
- getSupported(SupportedPropertiesCallback successCallback, optional VehiclePropertyErrorCallback errorCallback);
+ sequence<DOMString> supported();
/**
- * \brief fetch the current value for 'property'.
- * \arg DOMString property is the requested property to be retrieved.
- * \returns object representing the requested 'property'
+ * \brief fetch the current value for 'objectType'.
+ * \arg DOMString objectType is the requested property to be retrieved.
+ * \returns object representing the requested 'objectType'
**/
- any get(DOMString property);
+ any get(DOMString objectType);
/** \brief subscribe to the given property and get callbacks when it changes
* \arg DOMString property property to set