" <arg type='i' name='ret' direction='out'/>"
" <arg type='s' name='reqkey' direction='out'/>"
" </method>"
+ " <method name='enable_apps'>"
+ " <arg type='u' name='uid' direction='in'/>"
+ " <arg type='as' name='appids' direction='in'/>"
+ " <arg type='i' name='ret' direction='out'/>"
+ " <arg type='s' name='reqkey' direction='out'/>"
+ " </method>"
+ " <method name='disable_apps'>"
+ " <arg type='u' name='uid' direction='in'/>"
+ " <arg type='as' name='appids' direction='in'/>"
+ " <arg type='i' name='ret' direction='out'/>"
+ " <arg type='s' name='reqkey' direction='out'/>"
+ " </method>"
" <method name='enable_global_app_for_uid'>"
" <arg type='u' name='uid' direction='in'/>"
" <arg type='s' name='appid' direction='in'/>"
" <arg type='s' name='label' direction='in'/>"
" <arg type='i' name='ret' direction='out'/>"
" </method>"
+ " <method name='migrate_external_image'>"
+ " <arg type='u' name='uid' direction='in'/>"
+ " <arg type='s' name='pkgid' direction='in'/>"
+ " <arg type='i' name='ret' direction='out'/>"
+ " </method>"
" </interface>"
"</node>";
static GDBusNodeInfo *instropection_data;
size = strlen(pkgid) + strlen(timestr) + 2;
str_req_key = (char *)calloc(size, sizeof(char));
if (str_req_key == NULL) {
- DBG("calloc failed");
+ ERR("calloc failed");
return NULL;
}
snprintf(str_req_key, size, "%s_%s", pkgid, timestr);
uid_t target_uid = (uid_t)-1;
char *arg_pkgtype = NULL;
const char *pkgtype;
- char *pkgpath = NULL;
+ const char *pkgpath = NULL;
char *args = NULL;
char *reqkey = NULL;
gchar **tmp_args = NULL;
GVariant *value;
int i = 0;
int len = 0;
+ size_t s = 0;
g_variant_get(parameters, "(u&s&s@as)", &target_uid, &arg_pkgtype,
&pkgpath, &value);
}
for (i = 0; i < args_count; i++) {
- strncat(args, tmp_args[i], strlen(tmp_args[i]));
- if (i != args_count - 1)
- strncat(args, " ", strlen(" "));
+ strncat(args, tmp_args[i], len - s - 1);
+ s += strlen(tmp_args[i]);
+ if (i != args_count - 1) {
+ strncat(args, " ", len - s - 1);
+ s += strlen(" ");
+ }
}
if (target_uid == (uid_t)-1 || pkgpath == NULL) {
uid_t target_uid = (uid_t)-1;
char *arg_pkgtype = NULL;
const char *pkgtype;
- char *pkgpath = NULL;
+ const char *pkgpath = NULL;
char *args = NULL;
char *reqkey = NULL;
gchar **tmp_args = NULL;
GVariant *value;
int i = 0;
int len = 0;
+ size_t s = 0;
g_variant_get(parameters, "(u&s&s@as)", &target_uid, &arg_pkgtype,
&pkgpath, &value);
}
for (i = 0; i < args_count; i++) {
- strncat(args, tmp_args[i], strlen(tmp_args[i]));
- if (i != args_count - 1)
- strncat(args, " ", strlen(" "));
+ strncat(args, tmp_args[i], len - s - 1);
+ s += strlen(tmp_args[i]);
+ if (i != args_count - 1) {
+ strncat(args, " ", len - s - 1);
+ s += strlen(" ");
+ }
}
if (target_uid == (uid_t)-1 || pkgpath == NULL) {
return 0;
}
+static int __handle_request_enable_apps(uid_t caller_uid,
+ GDBusMethodInvocation *invocation, GVariant *parameters)
+{
+ uid_t target_uid = (uid_t)-1;
+ char *appid;
+ char *reqkey;
+ char buf[MAX_PKG_ARGS_LEN];
+ GVariantIter *iter;
+
+ g_variant_get(parameters, "(uas)", &target_uid, &iter);
+ if (target_uid == (uid_t)-1 || iter == NULL) {
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(is)", PKGMGR_R_ECOMM, ""));
+ return -1;
+ }
+
+ reqkey = __generate_reqkey("enable_apps");
+ if (reqkey == NULL) {
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(is)", PKGMGR_R_ENOMEM, ""));
+ return -1;
+ }
+
+ while (g_variant_iter_next(iter, "&s", &appid)) {
+ if (_push_queue(target_uid, caller_uid, reqkey,
+ REQUEST_TYPE_ENABLE_APP,
+ "default", appid, buf)) {
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(is)",
+ PKGMGR_R_ESYSTEM, ""));
+ free(reqkey);
+ return -1;
+ }
+ }
+
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(is)", PKGMGR_R_OK, reqkey));
+
+ free(reqkey);
+ return 0;
+}
+
+static int __handle_request_disable_apps(uid_t caller_uid,
+ GDBusMethodInvocation *invocation, GVariant *parameters)
+{
+ uid_t target_uid = (uid_t)-1;
+ char *appid;
+ char *reqkey;
+ char buf[MAX_PKG_ARGS_LEN];
+ GVariantIter *iter;
+
+ g_variant_get(parameters, "(uas)", &target_uid, &iter);
+ if (target_uid == (uid_t)-1 || iter == NULL) {
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(is)", PKGMGR_R_ECOMM, ""));
+ return -1;
+ }
+
+ reqkey = __generate_reqkey("disable_apps");
+ if (reqkey == NULL) {
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(is)", PKGMGR_R_ENOMEM, ""));
+ return -1;
+ }
+
+ while (g_variant_iter_next(iter, "&s", &appid)) {
+ if (_push_queue(target_uid, caller_uid, reqkey,
+ REQUEST_TYPE_DISABLE_APP,
+ "default", appid, buf)) {
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(is)",
+ PKGMGR_R_ESYSTEM, ""));
+ free(reqkey);
+ return -1;
+ }
+ }
+
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(is)", PKGMGR_R_OK, reqkey));
+
+ free(reqkey);
+ return 0;
+
+}
+
static int __handle_request_enable_app(uid_t caller_uid,
GDBusMethodInvocation *invocation, GVariant *parameters)
{
GDBusMethodInvocation *invocation, GVariant *parameters)
{
uid_t target_uid = (uid_t)-1;
- char *pkgtype;
char *pkgid = NULL;
- char *reqkey = NULL;
+ char *pkgtype;
g_variant_get(parameters, "(u&s)", &target_uid, &pkgid);
if (target_uid == (uid_t)-1 || pkgid == NULL) {
pkgtype = _get_pkgtype_from_pkgid(pkgid, target_uid);
if (pkgtype == NULL) {
g_dbus_method_invocation_return_value(invocation,
- g_variant_new("(i)", PKGMGR_R_ENOPKG));
- return -1;
- }
-
- reqkey = __generate_reqkey(pkgid);
- if (reqkey == NULL) {
- g_dbus_method_invocation_return_value(invocation,
- g_variant_new("(i)", PKGMGR_R_ENOMEM));
- free(pkgtype);
+ g_variant_new("(is)", PKGMGR_R_ENOPKG, ""));
return -1;
}
- if (_push_queue(target_uid, caller_uid, reqkey, REQUEST_TYPE_CLEARDATA,
+ if (_push_queue(target_uid, caller_uid, NULL, REQUEST_TYPE_CLEARDATA,
pkgtype, pkgid, NULL)) {
g_dbus_method_invocation_return_value(invocation,
g_variant_new("(i)", PKGMGR_R_ESYSTEM));
- free(reqkey);
free(pkgtype);
return -1;
}
g_dbus_method_invocation_return_value(invocation,
g_variant_new("(i)", PKGMGR_R_OK));
-
- free(reqkey);
free(pkgtype);
return 0;
{
uid_t target_uid = (uid_t)-1;
char *pkgid = NULL;
+ char *pkgtype;
g_variant_get(parameters, "(u&s)", &target_uid, &pkgid);
if (target_uid == (uid_t)-1 || pkgid == NULL) {
return -1;
}
+ if (strcmp(PKG_CLEAR_ALL_CACHE, pkgid) == 0)
+ pkgtype = strdup("pkgtool");
+ else
+ pkgtype = _get_pkgtype_from_pkgid(pkgid, target_uid);
+ if (pkgtype == NULL) {
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(is)", PKGMGR_R_ENOPKG, ""));
+ return -1;
+ }
+
if (_push_queue(target_uid, caller_uid, NULL, REQUEST_TYPE_CLEARCACHE,
- "pkgtool", pkgid, NULL)) {
+ pkgtype, pkgid, NULL)) {
g_dbus_method_invocation_return_value(invocation,
g_variant_new("(i)", PKGMGR_R_ESYSTEM));
+ free(pkgtype);
return -1;
}
g_dbus_method_invocation_return_value(invocation,
g_variant_new("(i)", PKGMGR_R_OK));
+ free(pkgtype);
return 0;
}
return 0;
}
+static int __handle_request_migrate_external_image(uid_t uid,
+ GDBusMethodInvocation *invocation, GVariant *parameters)
+{
+ uid_t target_uid = (uid_t)-1;
+ char *pkgid = NULL;
+ char *pkgtype;
+ char *reqkey;
+
+ g_variant_get(parameters, "(us)", &target_uid, &pkgid);
+ if (target_uid == (uid_t)-1 || pkgid == NULL) {
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(i)", PKGMGR_R_ECOMM));
+ return -1;
+ }
+
+ pkgtype = _get_pkgtype_from_pkgid(pkgid, target_uid);
+ if (pkgtype == NULL) {
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(i)", PKGMGR_R_ENOPKG));
+ return -1;
+ }
+
+ reqkey = __generate_reqkey(pkgid);
+ if (reqkey == NULL) {
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(i)", PKGMGR_R_ENOMEM));
+ free(pkgtype);
+ return -1;
+ }
+
+ if (_push_queue(target_uid, uid, reqkey,
+ REQUEST_TYPE_MIGRATE_EXTERNAL_IMAGE,
+ pkgtype, pkgid, NULL)) {
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(i)", PKGMGR_R_ESYSTEM));
+ free(reqkey);
+ free(pkgtype);
+ return -1;
+ }
+
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(i)", PKGMGR_R_OK));
+
+ free(reqkey);
+ free(pkgtype);
+
+ return 0;
+}
+
static uid_t __get_caller_uid(GDBusConnection *connection, const char *name)
{
GError *err = NULL;
}
g_variant_get(result, "(u)", &uid);
+ g_variant_unref(result);
return uid;
}
ret = __handle_request_enable_app(uid, invocation, parameters);
else if (g_strcmp0(method_name, "disable_app") == 0)
ret = __handle_request_disable_app(uid, invocation, parameters);
+ else if (g_strcmp0(method_name, "enable_apps") == 0)
+ ret = __handle_request_enable_apps(uid, invocation, parameters);
+ else if (g_strcmp0(method_name, "disable_apps") == 0)
+ ret = __handle_request_disable_apps(uid, invocation, parameters);
else if (g_strcmp0(method_name, "enable_global_app_for_uid") == 0)
ret = __handle_request_enable_global_app_for_uid(uid,
invocation, parameters);
parameters);
else if (g_strcmp0(method_name, "set_app_label") == 0)
ret = __handle_request_set_app_label(uid, invocation, parameters);
+ else if (g_strcmp0(method_name, "migrate_external_image") == 0)
+ ret = __handle_request_migrate_external_image(uid, invocation,
+ parameters);
else
ret = -1;