#include <glib.h>
#include <gio/gio.h>
#include <bundle.h>
-#include <systemd/sd-login.h>
#include <aul.h>
#include "syspopup_core.h"
syspopup_info_t *info;
int ret = -1;
int is_bundle = 0;
- int uid_max;
- int i;
- char *state = NULL;
- uid_t *uids = NULL;
- uid_t cuid = getuid();
if (popup_name == NULL) {
_E("popup_name is NULL");
if (b == NULL) {
b = bundle_create();
+ if (b == NULL) {
+ _E("out of memory");
+ _syspopup_info_free(info);
+ return -1;
+ }
is_bundle = 1;
}
if (_syspopup_set_name_to_bundle(b, popup_name) < 0) {
_E("bundle set error\n");
_syspopup_info_free(info);
- if (is_bundle == 1)
+ if (is_bundle)
bundle_free(b);
-
return -1;
}
- if (cuid >= REGULAR_UID_MIN) {
- if (cuid != uid) {
- _E("Cannot launch syspopup %s in other users",
- popup_name);
- ret = -1;
- goto end;
- }
-
- ret = aul_launch_app_for_uid(info->pkgname, b, uid);
- if (ret < 0)
- _E("syspopup launch error - %d", ret);
- } else {
- if (uid >= REGULAR_UID_MIN) {
- ret = aul_launch_app_for_uid(info->pkgname, b, uid);
- if (ret < 0)
- _E("syspopup launch error - %d", ret);
- } else {
- uid_max = sd_get_uids(&uids);
- if (uid_max <= 0) {
- _E("Failed to get uid list");
- ret = -1;
- goto end;
- }
-
- for (i = 0; i < uid_max; i++) {
- if (sd_uid_get_state(uids[i], &state) < 0)
- continue;
-
- if (state && (!strcmp(state, "online") ||
- !strcmp(state, "opening"))) {
- ret = aul_launch_app_for_uid(
- info->pkgname,
- b, uids[i]);
- if (ret < 0) {
- _E("syspopup launch error - %d",
- ret);
- }
- }
- }
- }
+ ret = aul_launch_app_async_for_uid(info->pkgname, b, uid);
+ if (ret < 0) {
+ _E("syspopup launch error - %d", ret);
+ _syspopup_info_free(info);
+ if (is_bundle)
+ bundle_free(b);
+ return -1;
}
-end:
if (is_bundle)
bundle_free(b);
_syspopup_info_free(info);
- return ret > 0 ? 0 : -1;
+ return 0;
}
API int syspopup_launch(char *popup_name, bundle *b)