4 #include <Elementary.h>
5 #include <appcore-efl.h>
8 #include <notification.h>
10 #include <vconf-keys.h>
14 #define APP_NAME "org.tizen.message_daemon"
16 static OFono_Callback_List_Incoming_SMS_Node *inc_sms = NULL;
18 static char _img_path[PATH_MAX];
22 #define ERR(...) EINA_LOG_DOM_ERR(_log_domain, __VA_ARGS__)
23 #define INF(...) EINA_LOG_DOM_INFO(_log_domain, __VA_ARGS__)
24 #define DBG(...) EINA_LOG_DOM_DBG(_log_domain, __VA_ARGS__)
26 static void _notification_create(const char *sender, const char *message)
30 notification_error_e err;
32 noti = notification_new(NOTIFICATION_TYPE_NOTI,
33 NOTIFICATION_GROUP_ID_NONE,
34 NOTIFICATION_PRIV_ID_NONE);
35 EINA_SAFETY_ON_NULL_RETURN(noti);
37 err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
39 NOTIFICATION_VARIABLE_TYPE_NONE);
41 if (err != NOTIFICATION_ERROR_NONE)
42 ERR("Could not set the title");
44 err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT,
46 NOTIFICATION_VARIABLE_TYPE_NONE);
48 if (err != NOTIFICATION_ERROR_NONE)
49 ERR("Could not set the body");
51 err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, _img_path);
53 if (err != NOTIFICATION_ERROR_NONE)
54 ERR("Could not set the image");
56 err = notification_insert(noti, &id);
58 if (err != NOTIFICATION_ERROR_NONE)
59 ERR("Could not show the notification");
61 notification_free(noti);
64 static Eina_Bool _phone_locked(void)
67 if (vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock) == -1)
70 if (lock == VCONFKEY_IDLE_LOCK)
76 static void _inc_sms_cb(void *data __UNUSED__, unsigned int sms_class,
77 time_t timestamp __UNUSED__, const char *sender,
86 _notification_create(sender, message);
89 static int _create(void *data __UNUSED__)
94 inc_sms = ofono_incoming_sms_cb_add(_inc_sms_cb, NULL);
96 elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
98 snprintf(_img_path, sizeof(_img_path), "%s/img",
99 elm_app_data_dir_get());
103 static int _reset(bundle *b __UNUSED__, void *data __UNUSED__)
108 static int _resume(void *data __UNUSED__)
113 static int _pause(void *data __UNUSED__)
118 static int _terminate(void *data __UNUSED__)
120 ofono_incoming_sms_cb_del(inc_sms);
125 int main(int argc, char **argv)
127 int r = EXIT_FAILURE;
128 struct appcore_ops ops = {
133 .terminate = _terminate,
140 _log_domain = eina_log_domain_register("answer_daemon", NULL);
142 r = appcore_efl_main(APP_NAME, &argc, &argv, &ops);