#define IMAGE_RECENT_ICON_GALLERY IMAGEDIR"/ic_thumbnail_gallery.png"
#define IMAGE_RECENT_ICON_MUSIC IMAGEDIR"/ic_thumbnail_music.png"
#define IMAGE_RECENT_ICON_WEB IMAGEDIR"/ic_thumbnail_web.png"
+#define IMAGE_RECENT_THUMB_NOTI IMAGEDIR"/btn_menu_notification_foc.png"
#define IMAGE_RECENT_THUMB_APP IMAGEDIR"/ic_default_app.png"
#define IMAGE_RECENT_THUMB_CHANNEL IMAGEDIR"/ic_default_tv.png"
#define IMAGE_RECENT_THUMB_SETTING IMAGEDIR"/ic_default_setting"
#define MESSAGE_USER_ADD "is added."
#define MESSAGE_USER_DELETE "is removed."
#define MESSAGE_USER_UPDATE "is updated."
+#define MESSAGE_NOTIFICATION "Notification"
#define GUM_ATTR_NAME "username"
#define GUM_ATTR_USERTYPE "usertype"
Evas_Object *utils_add_rectangle(Evas_Object *base, int r, int g, int b, int a);
Evas_Object *utils_add_toast(Evas_Object *base, char *message);
bool utils_launch_app(const char *pkg, const char *key, const char *value);
+int utils_get_notification_count(void);
#endif /* __AIR_HOME_UTILS_H__ */
#include <notification_internal.h>
#include <pwd.h>
#include <gum/gum-user.h>
-#include <app_contents.h>
#include "data_home.h"
#include "datamgr.h"
return val;
}
-static inline void _get_notification_count(notification_type_e type, int *count)
-{
- int basis_time, r;
- time_t noti_time;
- notification_list_h list = NULL;
- notification_h noti;
-
- app_contents_get_basis_time(CONTENTS_NOTI, &basis_time);
- if (basis_time < 0) {
- _ERR("failed to get basis time");
- return;
- }
-
- notification_get_list(type, -1, &list);
- if (!list)
- return;
-
- while (list) {
- noti = notification_list_get_data(list);
- if (!noti) {
- _ERR("failed to get noti data");
- list = notification_list_get_next(list);
- continue;
- }
-
- r = notification_get_insert_time(noti, ¬i_time);
- if (r != NOTIFICATION_ERROR_NONE) {
- _ERR("failed to get time of notification");
- list = notification_list_get_next(list);
- continue;
- }
-
- if (noti_time < basis_time)
- break;
-
- (*count)++;
- list = notification_list_get_next(list);
- }
-
- notification_free_list(list);
-}
-
-static void _get_notification(char **noti)
-{
- int count = 0;
- char buf[MAX_BUF];
-
- _get_notification_count(NOTIFICATION_TYPE_ONGOING, &count);
- _get_notification_count(NOTIFICATION_TYPE_NOTI, &count);
-
- if (count > 99)
- count = 99;
-
- snprintf(buf, sizeof(buf), "%d", count);
- *noti = strdup(buf);
-}
-
static void _get_login_user(char **name, char **icon, char **focus_icon)
{
GumUser *user;
struct datamgr_item *di;
char *name, *icon, *parameter, *focus_icon, *action;
gboolean noti;
+ char buf[MAX_BUF];
if (!reader) {
_ERR("Invalid argument");
di->focus_icon = strdup(focus_icon);
di->parameter = strdup(parameter);
di->noti = noti;
- if (noti)
- _get_notification(&di->subtitle);
+ if (noti) {
+ snprintf(buf, sizeof(buf), "%d",
+ utils_get_notification_count());
+ di->subtitle = strdup(buf);
+ }
return di;
err:
Eina_List *l;
struct datamgr *dm;
struct datamgr_item *di;
+ char buf[MAX_BUF];
if (!data) {
_ERR("Invalid argument");
dm = data;
- _get_notification(¬i);
- viewmgr_update_view(VIEW_HOME, UPDATE_TYPE_NOTI, noti);
+ snprintf(buf, sizeof(buf), "%d", utils_get_notification_count());
+ noti = strdup(buf);
+ viewmgr_update_view(VIEW_HOME, UPDATE_TYPE_NOTI, noti);
EINA_LIST_FOREACH(dm->list, l, di) {
if (di->noti)
di->subtitle = noti;
#include <media_content.h>
#include <app_media.h>
#include <app_define.h>
+#include <app_contents.h>
#include <time.h>
#include <ctype.h>
#include "defs.h"
#define BUF_TITLE_MAX 128
+#define MAX_BUF 64
#define CHANNEL_GULLIVER IMAGEDIR"/gulliver.png"
return -1;
}
+static bool _load_recent_notification(struct datamgr *dm)
+{
+ struct datamgr_item *di;
+ int time;
+ char buf[MAX_BUF];
+
+ snprintf(buf, sizeof(buf), "%d", utils_get_notification_count());
+
+ app_contents_get_basis_time(CONTENTS_NOTI, &time);
+ if (time < 0) {
+ _ERR("Invalid time");
+ return false;
+ }
+
+ di = _new_datamgr_item(MESSAGE_NOTIFICATION, IMAGE_RECENT_THUMB_NOTI,
+ buf, APP_ID_INFOSQUARE, NULL, NULL,
+ IMAGE_RECENT_ICON_APP, 0, time);
+ if (di)
+ dm->list = eina_list_append(dm->list, di);
+
+ return true;
+}
+
static Eina_List *_get_items(struct datamgr *dm)
{
if (!dm) {
if (!_load_recent(dm, CONTENTS_MUSIC, 1, _music_list_foreach))
_ERR("failed to load recent music contents");
+ if (!_load_recent_notification(dm))
+ _ERR("failed to load recent notification contents");
+
dm->list = eina_list_sort(dm->list, 0, _sort_list);
return dm->list;
#include <app_debug.h>
#include <stdbool.h>
#include <app.h>
+#include <notification.h>
+#include <notification_internal.h>
+#include <app_contents.h>
#include "utils.h"
#include "defs.h"
return true;
}
+
+static void _get_notification_count(notification_type_e type, int *count)
+{
+ int basis_time, r;
+ time_t noti_time;
+ notification_list_h list = NULL;
+ notification_h noti;
+
+ app_contents_get_basis_time(CONTENTS_NOTI, &basis_time);
+ if (basis_time < 0) {
+ _ERR("failed to get basis time");
+ return;
+ }
+
+ notification_get_list(type, -1, &list);
+ if (!list)
+ return;
+
+ while (list) {
+ noti = notification_list_get_data(list);
+ if (!noti) {
+ _ERR("failed to get noti data");
+ list = notification_list_get_next(list);
+ continue;
+ }
+
+ r = notification_get_insert_time(noti, ¬i_time);
+ if (r != NOTIFICATION_ERROR_NONE) {
+ _ERR("failed to get time of notification");
+ list = notification_list_get_next(list);
+ continue;
+ }
+
+ if (noti_time < basis_time)
+ break;
+
+ (*count)++;
+ list = notification_list_get_next(list);
+ }
+
+ notification_free_list(list);
+}
+
+int utils_get_notification_count(void)
+{
+ int count = 0;
+
+ _get_notification_count(NOTIFICATION_TYPE_ONGOING, &count);
+ _get_notification_count(NOTIFICATION_TYPE_NOTI, &count);
+
+ if (count > 99)
+ count = 99;
+
+ return count;
+}