#define LOW_STORAGE_WARNING "lowstorage_warning"
#define LOW_STORAGE_CRITICAL "lowstorage_critical"
+#define LOW_STORAGE_FULL "lowstorage_full"
#define LOW_STORAGE_REMOVE "lowstorage_remove"
#define INTERNAL_STORAGE_NOTION "InternalStorageNotiOn"
SIGNAL_NEED_CLEANUP, "ss", arr);
}
-static void __noti_cb(void *data, DBusMessage *msg, int err)
+static void _noti_cb(void *data, DBusMessage *msg, int err)
{
DBusError r_err;
int ret, id;
return ret;
}
-static int launch_memory_notification(char *type)
+static int remove_notification(void)
{
+ DBusMessage *msg;
char *param[1];
char id_str[16];
- int ret = 0;
+ int ret;
+
+ snprintf(id_str, sizeof(id_str), "%d", noti_id);
+ param[0] = id_str;
+
+ ret = call_dbus_method_sync(POPUP_BUS_NAME,
+ POPUP_PATH_NOTI,
+ POPUP_INTERFACE_NOTI,
+ INTERNAL_STORAGE_NOTIOFF,
+ "i",
+ param,
+ -1,
+ &msg);
+ if (ret < 0)
+ _E("Fail to remove noti : %d", noti_id);
+
+ return ret;
+}
+
+static int create_notification(void)
+{
+ int ret;
+
+ ret = call_dbus_method_async(POPUP_BUS_NAME,
+ POPUP_PATH_NOTI,
+ POPUP_INTERFACE_NOTI,
+ INTERNAL_STORAGE_NOTION,
+ NULL,
+ NULL,
+ _noti_cb,
+ -1,
+ NULL);
+ if (ret < 0)
+ _E("Fail to create noti");
+
+ return ret;
+}
+
+static int launch_memory_notification(char *type)
+{
+ int ret = -1;
if (!type)
return -EINVAL;
- if (strncmp(type, INTERNAL_STORAGE_NOTION,
- sizeof(INTERNAL_STORAGE_NOTION)) == 0) {
- ret = call_dbus_method_async(POPUP_BUS_NAME,
- POPUP_PATH_NOTI,
- POPUP_INTERFACE_NOTI,
- type,
- NULL,
- NULL,
- __noti_cb,
- -1,
- NULL);
- } else if (strncmp(type, INTERNAL_STORAGE_NOTIOFF,
- sizeof(INTERNAL_STORAGE_NOTIOFF)) == 0) {
+ if (!strncmp(type, INTERNAL_STORAGE_NOTION, sizeof(INTERNAL_STORAGE_NOTION))) {
if (noti_id) {
- snprintf(id_str, sizeof(id_str), "%d", noti_id);
- param[0] = id_str;
-
- ret = call_dbus_method_async(POPUP_BUS_NAME,
- POPUP_PATH_NOTI,
- POPUP_INTERFACE_NOTI,
- type,
- "i",
- param,
- NULL,
- -1,
- NULL);
+ ret = remove_notification();
if (ret < 0)
- _E("Fail to remove memory noti : %d", noti_id);
- else
- noti_id = 0;
+ return ret;
+ noti_id = 0;
}
- } else {
- _E("Invalid noti type : %d", type);
- ret = -1;
- }
+ ret = create_notification();
+ } else if (!strncmp(type, INTERNAL_STORAGE_NOTIOFF, sizeof(INTERNAL_STORAGE_NOTIOFF))) {
+ if (!noti_id)
+ return -1;
+
+ ret = remove_notification();
+ } else
+ _E("Invalid noti type : %s", type);
return ret;
}
char *popup_value = NULL;
char *noti_value = NULL;
- if (level != MEMNOTI_LEVEL_WARNING && level != MEMNOTI_LEVEL_CRITICAL && level != MEMNOTI_LEVEL_NORMAL) {
+ if (level < 0 || level > MEMNOTI_LEVEL_NORMAL) {
_E("level check error : %d", level);
return 0;
}
} else if (level == MEMNOTI_LEVEL_CRITICAL) {
popup_value = LOW_STORAGE_CRITICAL;
noti_value = INTERNAL_STORAGE_NOTION;
+ } else if (level == MEMNOTI_LEVEL_FULL) {
+ popup_value = LOW_STORAGE_FULL;
+ noti_value = INTERNAL_STORAGE_NOTION;
} else if (level == MEMNOTI_LEVEL_NORMAL) {
popup_value = LOW_STORAGE_REMOVE;
noti_value = INTERNAL_STORAGE_NOTIOFF;