static bool initialized = false;
static void *plugin_handle = NULL;
+static OrgTizenUpdateManager *proxy = NULL;
API int update_control_initialize(void)
{
CHECK_FEATURE_SUPPORTED(DEVICE_UPDATE_FEATURE);
+ _I("update_control_initialize called");
- int ret;
- int (*plugin_update_control_initialize)(void) = NULL;
+ GError *error = NULL;
- if (initialized) {
+ if (proxy != NULL) {
_D("Already initialized");
return UPDATE_CONTROL_ERROR_NONE;
}
- if (access(UPDATE_CONTROL_PLUGIN, F_OK) != 0) {
- _E("update-control plugin is not found");
- return UPDATE_CONTROL_ERROR_INVALID_OPERATION;
- }
-
- plugin_handle = dlopen(UPDATE_CONTROL_PLUGIN, RTLD_NOW);
- if (!plugin_handle) {
- _E("dlopen failed: %s", dlerror());
+ proxy = org_tizen_update_manager_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE,
+ "org.tizen.update.manager", "/org/tizen/update/manager", NULL, &error);
+ if (error != NULL) {
+ _E("Failed get proxy for org.tizen.update.manager : %s", error->message);
return UPDATE_CONTROL_ERROR_SYSTEM_ERROR;
}
- plugin_update_control_initialize = dlsym(plugin_handle,
- "update_control_initialize");
- if (!plugin_update_control_initialize) {
- _E("dlsym failed: %s", dlerror());
- return UPDATE_CONTROL_ERROR_INVALID_OPERATION;
- }
-
- ret = plugin_update_control_initialize();
- if (ret != UPDATE_CONTROL_ERROR_NONE) {
- _E("update_control_initialize error: %d", ret);
- return ret;
- }
-
- initialized = true;
-
+ _I("Success to get proxy for org.tizen.update.manager");
return UPDATE_CONTROL_ERROR_NONE;
}
-
API int update_control_deinitialize(void)
{
CHECK_FEATURE_SUPPORTED(DEVICE_UPDATE_FEATURE);
API int update_control_do_update(void)
{
CHECK_FEATURE_SUPPORTED(DEVICE_UPDATE_FEATURE);
- _I("Try to start update ...");
+ _I("update_control_do_update called");
- static OrgTizenUpdateManager *proxy = NULL;
gint status = 0;
GError *error = NULL;
if (proxy == NULL) {
- proxy = org_tizen_update_manager_proxy_new_for_bus_sync(
- G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE,
- "org.tizen.update.manager", "/org/tizen/update/manager", NULL, &error);
- if (error == NULL) {
- _I("Success to get proxy for org.tizen.update.manager");
- } else {
- _E("Failed get proxy for org.tizen.update.manager : %s", error->message);
- return UPDATE_CONTROL_ERROR_SYSTEM_ERROR;
- }
+ _E("Not initialized");
+ return UPDATE_CONTROL_ERROR_SYSTEM_ERROR;
}
org_tizen_update_manager_call_install_sync(proxy, &status, NULL, &error);
- if (error == NULL) {
- _I("Success to call install to daemon");
- if (status < 0) {
- _E("Failed to do update : %d", status);
- return UPDATE_CONTROL_ERROR_INVALID_OPERATION;
- }
- } else {
- _E("Failed to call install to daemon : %s", error->message);
+ if (error != NULL) {
+ _E("Failed to method call <install> to dbus : %s", error->message);
return UPDATE_CONTROL_ERROR_SYSTEM_ERROR;
}
+ _I("Success to method call <install> to dbus");
+ if (status < 0) {
+ _E("Failed to do update : %d", status);
+ return UPDATE_CONTROL_ERROR_INVALID_OPERATION;
+ }
+
+ _I("Success to do update : %d", status);
return UPDATE_CONTROL_ERROR_NONE;
}
API int update_control_get_property(update_control_property_e property, void **value)
{
CHECK_FEATURE_SUPPORTED(DEVICE_UPDATE_FEATURE);
+ _I("update_control_get_property called");
- int ret;
- int (*plugin_update_control_get_property)(update_control_property_e, void **) = NULL;
+ gint status = 0;
+ GError *error = NULL;
- if (!plugin_handle) {
- _E("plugin not opened");
- return UPDATE_CONTROL_ERROR_INVALID_OPERATION;
+ if (proxy == NULL) {
+ _E("Not initialized");
+ return UPDATE_CONTROL_ERROR_SYSTEM_ERROR;
}
- plugin_update_control_get_property = dlsym(plugin_handle,
- "update_control_get_property");
- if (!plugin_update_control_get_property) {
- _E("dlsym failed: %s", dlerror());
- return UPDATE_CONTROL_ERROR_INVALID_OPERATION;
- }
+ switch(property) {
+ case UPDATE_CONTROL_PROPERTY_RESULT:
+ org_tizen_update_manager_call_result_sync(proxy, &status, NULL, &error);
+ if (error != NULL) {
+ _E("Failed to method call <result> to dbus : %s", error->message);
+ return UPDATE_CONTROL_ERROR_SYSTEM_ERROR;
+ }
- ret = plugin_update_control_get_property(property, value);
- if (ret != UPDATE_CONTROL_ERROR_NONE) {
- _E("update_control_get_property error: %d", ret);
- return ret;
- }
+ _I("Success to method call <result> to dbus");
+ if (status < 0) {
+ _E("Failed to get result : %d", status);
+ return UPDATE_CONTROL_ERROR_INVALID_OPERATION;
+ }
- return UPDATE_CONTROL_ERROR_NONE;
+ _I("Success to get result : %d", status);
+ *value = (void *)(status);
+ return UPDATE_CONTROL_ERROR_NONE;
+ default:
+ _I("Unsupported property : %d", property);
+ return UPDATE_CONTROL_ERROR_NOT_SUPPORTED;
+ }
}