const JSValueRef arguments[],
JSValueRef* exception)
{
- LoggerD("Entered ");
+ LoggerD("Entered awesome");
//Try {
VehiclePrivObject* privateObject = static_cast<VehiclePrivObject*>(JSObjectGetPrivate(thisObject));
if (NULL == privateObject)
//return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
}
+ LoggerD("Validating arguments: " << argumentCount);
+
ArgumentValidator validator(context, argumentCount, arguments);
std::string property = validator.toString(0);
+
+ LoggerD("property to get: " << property);
VehiclePtr vehicle(privateObject->getObject());
std::list<AbstractPropertyType*> properties = vehicle->get(property);
+ LoggerD("properties in dbus object: "<<properties.size());
+
std::stringstream json;
+
+
json<<"{";
for(auto itr = properties.begin(); itr != properties.end(); itr++)
json << "}";
Converter converter(context);
+
+ LoggerD("get json: " << json.str().c_str());
- return converter.toJSValueRef(json.str());
+ JSStringRef jsonString = converter.toJSStringRef(json.str());
+
+ return JSValueMakeFromJSONString(context, jsonString);
/*} Catch (PlatformException) {
#include <gio/gio.h>
#include <stdexcept>
#include <list>
+#include <Logger.h>
#include <Commons/ThreadPool.h>
VehicleMaster::VehicleMaster()
:EventRequestReceiver<EventVehiclePropertyChanged>(ThreadEnum::APPLICATION_THREAD)
{
+ VehicleProperty::factory();
}
std::list<AbstractPropertyType *> VehicleMaster::get(std::string property)
{
+ LoggerD("Entered");
+
+ std::list<AbstractPropertyType*> returnValue;
+
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",
if(error)
{
- throw std::runtime_error("could not get automotive message broker Manager interface");
+ LoggerE("could not get automotive message broker Manager interface");
+ return returnValue;
}
-
+ LoggerD("calling findProperty() with " <<property);
+
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);
+ LoggerD("returned object path: " << g_variant_get_type_string(objectPath));
+
+ gchar * objP;
+ g_variant_get(objectPath,"(o)", &objP);
+
+ LoggerD("findProperty() returned object path: " <<objP);
+
+ if(error)
+ {
+ LoggerD("error calling findProperty "<< error->message);
+ return returnValue;
+ }
+
+ std::string objPStr = objP;
- if(std::string(objP) == "")
+ if(objPStr == "")
{
- throw std::runtime_error("could not find property "+ property);
+ LoggerD("could not find property " << property);
+ return returnValue;
}
+ LoggerD("Getting properties interface");
+
GDBusProxy* propertiesProxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, NULL,
"org.automotive.message.broker",
objP,
if(error)
{
- throw std::runtime_error("failed to call GetAll on interface " + interfaceName);
+ LoggerD("failed to call GetAll on interface " << interfaceName);
+ return returnValue;
}
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))
{
+ LoggerD("getting property for key: " << key);
AbstractPropertyType* val = VehicleProperty::getPropertyTypeForPropertyNameValue(key);
+ if(!val)
+ {
+ LoggerD("Error creating abstractpropertytype for key");
+ return returnValue;
+ }
val->fromVariant(value);
returnValue.push_back(val);
}