From 805e22beae6751f91d7687bc3a5538326aad009c Mon Sep 17 00:00:00 2001 From: Mu-Woong Date: Mon, 17 Aug 2015 21:58:29 +0900 Subject: [PATCH] Sync with Tizen 2.4 - Add the init routine for registering trigger item specifications - Cleanup context item names Change-Id: Ia850574412761db870700f8f6b7cf9d04388bec2 Signed-off-by: Mu-Woong --- src/activity/activity.h | 7 +++++++ src/activity/activity_types.h | 9 ++++----- src/device_context_provider.cpp | 1 + src/device_status/battery.cpp | 10 ++++++++++ src/device_status/battery.h | 1 + src/device_status/device_status_types.h | 17 +++++++++-------- src/device_status/headphone.cpp | 10 ++++++++++ src/device_status/headphone.h | 1 + src/device_status/psmode.cpp | 6 ++++++ src/device_status/psmode.h | 1 + src/device_status/runtime-info/charger.cpp | 6 ++++++ src/device_status/runtime-info/charger.h | 1 + src/device_status/runtime-info/gps.cpp | 9 +++++++++ src/device_status/runtime-info/gps.h | 1 + src/device_status/runtime-info/usb.cpp | 6 ++++++ src/device_status/runtime-info/usb.h | 1 + src/device_status/wifi.cpp | 10 ++++++++++ src/device_status/wifi.h | 1 + src/social_status/call.cpp | 11 +++++++++++ src/social_status/call.h | 1 + src/social_status/email.cpp | 9 +++++++++ src/social_status/email.h | 1 + src/social_status/message.cpp | 11 +++++++++++ src/social_status/message.h | 1 + src/social_status/social_status_types.h | 6 +++--- 25 files changed, 122 insertions(+), 16 deletions(-) diff --git a/src/activity/activity.h b/src/activity/activity.h index d23b208..d0e0951 100644 --- a/src/activity/activity.h +++ b/src/activity/activity.h @@ -35,6 +35,13 @@ { \ return get_system_info_bool("tizen.org/feature/sensor.activity_recognition"); \ } \ + static void submit_trigger_item() \ + { \ + context_manager::register_trigger_item((act_subj), OPS_SUBSCRIBE, \ + "{\"Event\":{\"type\":\"string\", \"values\":[\"Detected\"]}}", \ + "{\"Accuracy\":{\"type\":\"string\", \"values\":[\"Low\", \"Normal\", \"High\"]}}" \ + ); \ + } \ protected: \ void destroy_self() \ { \ diff --git a/src/activity/activity_types.h b/src/activity/activity_types.h index da38941..c15bbb4 100644 --- a/src/activity/activity_types.h +++ b/src/activity/activity_types.h @@ -18,11 +18,10 @@ #define __CONTEXT_USER_ACTIVITY_TYPES_H__ // Subject -#define USER_ACT_SUBJ_CYCLING "activity/event/cycling" -#define USER_ACT_SUBJ_IN_VEHICLE "activity/event/in_vehicle" -#define USER_ACT_SUBJ_RUNNING "activity/event/running" -#define USER_ACT_SUBJ_STATIONARY "activity/event/stationary" -#define USER_ACT_SUBJ_WALKING "activity/event/walking" +#define USER_ACT_SUBJ_IN_VEHICLE "activity/in_vehicle" +#define USER_ACT_SUBJ_RUNNING "activity/running" +#define USER_ACT_SUBJ_STATIONARY "activity/stationary" +#define USER_ACT_SUBJ_WALKING "activity/walking" // Data Key #define USER_ACT_EVENT "Event" diff --git a/src/device_context_provider.cpp b/src/device_context_provider.cpp index 940cd75..d0665fe 100644 --- a/src/device_context_provider.cpp +++ b/src/device_context_provider.cpp @@ -61,6 +61,7 @@ void register_provider(const char *subject, const char *privilege) ctx::context_provider_info provider_info(provider::create, provider::destroy, NULL, privilege); ctx::context_manager::register_provider(subject, provider_info); + provider::submit_trigger_item(); } EXTAPI bool ctx::init_device_context_provider() diff --git a/src/device_status/battery.cpp b/src/device_status/battery.cpp index d38f099..7aada51 100644 --- a/src/device_status/battery.cpp +++ b/src/device_status/battery.cpp @@ -33,6 +33,16 @@ bool ctx::device_status_battery::is_supported() return true; } +void ctx::device_status_battery::submit_trigger_item() +{ + context_manager::register_trigger_item(DEVICE_ST_SUBJ_BATTERY, OPS_SUBSCRIBE | OPS_READ, + "{" + "\"Level\":{\"type\":\"string\",\"values\":[\"Empty\",\"Critical\",\"Low\",\"Normal\",\"High\",\"Full\"]}," + TRIG_BOOL_ITEM_DEF("IsCharging") + "}", + NULL); +} + void ctx::device_status_battery::update_cb(device_callback_e device_type, void* value, void* user_data) { IF_FAIL_VOID(device_type == DEVICE_CALLBACK_BATTERY_LEVEL); diff --git a/src/device_status/battery.h b/src/device_status/battery.h index 951e9d1..6fc3fdf 100644 --- a/src/device_status/battery.h +++ b/src/device_status/battery.h @@ -32,6 +32,7 @@ namespace ctx { int unsubscribe(); int read(); static bool is_supported(); + static void submit_trigger_item(); private: device_status_battery(); diff --git a/src/device_status/device_status_types.h b/src/device_status/device_status_types.h index a978625..3abff42 100644 --- a/src/device_status/device_status_types.h +++ b/src/device_status/device_status_types.h @@ -18,14 +18,13 @@ #define __CONTEXT_DEVICESTATUS_TYPES_H__ // Subject -#define DEVICE_ST_SUBJ_BATTERY "system/state/battery" -#define DEVICE_ST_SUBJ_CHARGER "system/state/charger" -#define DEVICE_ST_SUBJ_HEADPHONE "system/state/headphone" -#define DEVICE_ST_SUBJ_WIFI "system/state/wifi" -#define DEVICE_ST_SUBJ_USB "system/state/usb" -#define DEVICE_ST_SUBJ_GPS "system/state/gps" -#define DEVICE_ST_SUBJ_VIBRATION_MODE "system/state/vibration_mode" -#define DEVICE_ST_SUBJ_PSMODE "system/state/ps_mode" +#define DEVICE_ST_SUBJ_BATTERY "system/battery" +#define DEVICE_ST_SUBJ_CHARGER "system/charger" +#define DEVICE_ST_SUBJ_HEADPHONE "system/headphone" +#define DEVICE_ST_SUBJ_WIFI "system/wifi" +#define DEVICE_ST_SUBJ_USB "system/usb" +#define DEVICE_ST_SUBJ_GPS "system/gps" +#define DEVICE_ST_SUBJ_PSMODE "system/psmode" // Data Key #define DEVICE_ST_EVENT "Event" @@ -56,4 +55,6 @@ #define DEVICE_ST_HEADSET "Headset" #define DEVICE_ST_BLUETOOTH "Bluetooth" +#define TRIG_BOOL_ITEM_DEF(sbj) "\"" sbj "\":{\"type\":\"integer\",\"min\":0,\"max\":1}" + #endif //__CONTEXT_DEVICESTATUS_TYPES_H__ diff --git a/src/device_status/headphone.cpp b/src/device_status/headphone.cpp index c73ae0b..eb237ee 100644 --- a/src/device_status/headphone.cpp +++ b/src/device_status/headphone.cpp @@ -42,6 +42,16 @@ bool ctx::device_status_headphone::is_supported() return true; } +void ctx::device_status_headphone::submit_trigger_item() +{ + context_manager::register_trigger_item(DEVICE_ST_SUBJ_HEADPHONE, OPS_SUBSCRIBE | OPS_READ, + "{" + TRIG_BOOL_ITEM_DEF("IsConnected") "," + "\"Type\":{\"type\":\"string\",\"values\":[\"Normal\",\"Headset\",\"Bluetooth\"]}" + "}", + NULL); +} + int ctx::device_status_headphone::subscribe() { connected = get_current_status(); diff --git a/src/device_status/headphone.h b/src/device_status/headphone.h index 50fc5c3..16c2f1e 100644 --- a/src/device_status/headphone.h +++ b/src/device_status/headphone.h @@ -33,6 +33,7 @@ namespace ctx { int unsubscribe(); int read(); static bool is_supported(); + static void submit_trigger_item(); private: bool connected; diff --git a/src/device_status/psmode.cpp b/src/device_status/psmode.cpp index 2122d08..1806c2b 100644 --- a/src/device_status/psmode.cpp +++ b/src/device_status/psmode.cpp @@ -33,6 +33,12 @@ bool ctx::device_status_psmode::is_supported() return true; } +void ctx::device_status_psmode::submit_trigger_item() +{ + context_manager::register_trigger_item(DEVICE_ST_SUBJ_PSMODE, OPS_SUBSCRIBE | OPS_READ, + "{" TRIG_BOOL_ITEM_DEF("IsEnabled") "}", NULL); +} + void ctx::device_status_psmode::update_cb(keynode_t *node, void* user_data) { device_status_psmode *instance = static_cast(user_data); diff --git a/src/device_status/psmode.h b/src/device_status/psmode.h index fc4275c..2cc1660 100644 --- a/src/device_status/psmode.h +++ b/src/device_status/psmode.h @@ -31,6 +31,7 @@ namespace ctx { int unsubscribe(); int read(); static bool is_supported(); + static void submit_trigger_item(); private: device_status_psmode(); diff --git a/src/device_status/runtime-info/charger.cpp b/src/device_status/runtime-info/charger.cpp index df1b63c..85cd290 100644 --- a/src/device_status/runtime-info/charger.cpp +++ b/src/device_status/runtime-info/charger.cpp @@ -34,6 +34,12 @@ bool ctx::device_status_charger::is_supported() return true; } +void ctx::device_status_charger::submit_trigger_item() +{ + context_manager::register_trigger_item(DEVICE_ST_SUBJ_CHARGER, OPS_SUBSCRIBE | OPS_READ, + "{" TRIG_BOOL_ITEM_DEF("IsConnected") "}", NULL); +} + void ctx::device_status_charger::handle_update() { bool charger_status = false; diff --git a/src/device_status/runtime-info/charger.h b/src/device_status/runtime-info/charger.h index 70020a0..52aeb4c 100644 --- a/src/device_status/runtime-info/charger.h +++ b/src/device_status/runtime-info/charger.h @@ -28,6 +28,7 @@ namespace ctx { public: int read(); static bool is_supported(); + static void submit_trigger_item(); private: device_status_charger(); diff --git a/src/device_status/runtime-info/gps.cpp b/src/device_status/runtime-info/gps.cpp index ccd6ee6..bf8b251 100644 --- a/src/device_status/runtime-info/gps.cpp +++ b/src/device_status/runtime-info/gps.cpp @@ -52,6 +52,15 @@ bool ctx::device_status_gps::is_supported() return get_system_info_bool("tizen.org/feature/location.gps"); } +void ctx::device_status_gps::submit_trigger_item() +{ + context_manager::register_trigger_item(DEVICE_ST_SUBJ_GPS, OPS_SUBSCRIBE | OPS_READ, + "{" + "\"State\":{\"type\":\"string\",\"values\":[\"Disabled\",\"Searching\",\"Connected\"]}" + "}", + NULL); +} + void ctx::device_status_gps::handle_update() { int gps_status; diff --git a/src/device_status/runtime-info/gps.h b/src/device_status/runtime-info/gps.h index fdbe0cf..4d94cc0 100644 --- a/src/device_status/runtime-info/gps.h +++ b/src/device_status/runtime-info/gps.h @@ -28,6 +28,7 @@ namespace ctx { public: int read(); static bool is_supported(); + static void submit_trigger_item(); private: device_status_gps(); diff --git a/src/device_status/runtime-info/usb.cpp b/src/device_status/runtime-info/usb.cpp index cefb72e..5f92307 100644 --- a/src/device_status/runtime-info/usb.cpp +++ b/src/device_status/runtime-info/usb.cpp @@ -34,6 +34,12 @@ bool ctx::device_status_usb::is_supported() return get_system_info_bool("tizen.org/feature/usb.host"); } +void ctx::device_status_usb::submit_trigger_item() +{ + context_manager::register_trigger_item(DEVICE_ST_SUBJ_USB, OPS_SUBSCRIBE | OPS_READ, + "{" TRIG_BOOL_ITEM_DEF("IsConnected") "}", NULL); +} + void ctx::device_status_usb::handle_update() { bool status = false; diff --git a/src/device_status/runtime-info/usb.h b/src/device_status/runtime-info/usb.h index 2242bd0..bc01425 100644 --- a/src/device_status/runtime-info/usb.h +++ b/src/device_status/runtime-info/usb.h @@ -28,6 +28,7 @@ namespace ctx { public: int read(); static bool is_supported(); + static void submit_trigger_item(); private: device_status_usb(); diff --git a/src/device_status/wifi.cpp b/src/device_status/wifi.cpp index 86b4412..6064b74 100644 --- a/src/device_status/wifi.cpp +++ b/src/device_status/wifi.cpp @@ -36,6 +36,16 @@ bool ctx::device_status_wifi::is_supported() return get_system_info_bool("tizen.org/feature/network.wifi"); } +void ctx::device_status_wifi::submit_trigger_item() +{ + context_manager::register_trigger_item(DEVICE_ST_SUBJ_WIFI, OPS_SUBSCRIBE | OPS_READ, + "{" + "\"State\":{\"type\":\"string\",\"values\":[\"Disabled\",\"Unconnected\",\"Connected\"]}," + "\"BSSID\":{\"type\":\"string\"}" + "}", + NULL); +} + bool ctx::device_status_wifi::get_current_state() { int err; diff --git a/src/device_status/wifi.h b/src/device_status/wifi.h index 1f5d304..2fff2ba 100644 --- a/src/device_status/wifi.h +++ b/src/device_status/wifi.h @@ -32,6 +32,7 @@ namespace ctx { int unsubscribe(); int read(); static bool is_supported(); + static void submit_trigger_item(); private: enum _state_e { diff --git a/src/social_status/call.cpp b/src/social_status/call.cpp index 82e8550..53daca3 100644 --- a/src/social_status/call.cpp +++ b/src/social_status/call.cpp @@ -49,6 +49,17 @@ bool ctx::social_status_call::is_supported() return get_system_info_bool("tizen.org/feature/network.telephony"); } +void ctx::social_status_call::submit_trigger_item() +{ + context_manager::register_trigger_item(SOCIAL_ST_SUBJ_CALL, OPS_SUBSCRIBE | OPS_READ, + "{" + "\"Medium\":{\"type\":\"string\",\"values\":[\"Voice\",\"Video\"]}," + "\"State\":{\"type\":\"string\",\"values\":[\"Idle\",\"Connecting\",\"Connected\"]}," + "\"Address\":{\"type\":\"string\"}" + "}", + NULL); +} + void ctx::social_status_call::call_event_cb(telephony_h handle, telephony_noti_e noti_id, void *data, void *user_data) { social_status_call *instance = static_cast(user_data); diff --git a/src/social_status/call.h b/src/social_status/call.h index c130c23..baef3cb 100644 --- a/src/social_status/call.h +++ b/src/social_status/call.h @@ -31,6 +31,7 @@ namespace ctx { int unsubscribe(); int read(); static bool is_supported(); + static void submit_trigger_item(); private: telephony_handle_list_s handle_list; diff --git a/src/social_status/email.cpp b/src/social_status/email.cpp index a0a98f2..8c3d93a 100644 --- a/src/social_status/email.cpp +++ b/src/social_status/email.cpp @@ -37,6 +37,15 @@ bool ctx::social_status_email::is_supported() return get_system_info_bool("tizen.org/feature/network.telephony"); } +void ctx::social_status_email::submit_trigger_item() +{ + context_manager::register_trigger_item(SOCIAL_ST_SUBJ_EMAIL, OPS_SUBSCRIBE, + "{" + "\"Event\":{\"type\":\"string\",\"values\":[\"Received\",\"Sent\"]}" + "}", + NULL); +} + void ctx::social_status_email::on_signal_received(const char* sender, const char* path, const char* iface, const char* name, GVariant* param) { gint sub_type = 0; diff --git a/src/social_status/email.h b/src/social_status/email.h index 3156067..cbfc671 100644 --- a/src/social_status/email.h +++ b/src/social_status/email.h @@ -31,6 +31,7 @@ namespace ctx { int unsubscribe(); void on_signal_received(const char* sender, const char* path, const char* iface, const char* name, GVariant* param); static bool is_supported(); + static void submit_trigger_item(); private: int64_t dbus_signal_id; diff --git a/src/social_status/message.cpp b/src/social_status/message.cpp index 1d75ef3..8c41232 100644 --- a/src/social_status/message.cpp +++ b/src/social_status/message.cpp @@ -37,6 +37,17 @@ bool ctx::social_status_message::is_supported() return get_system_info_bool("tizen.org/feature/network.telephony"); } +void ctx::social_status_message::submit_trigger_item() +{ + context_manager::register_trigger_item(SOCIAL_ST_SUBJ_MESSAGE, OPS_SUBSCRIBE, + "{" + "\"Event\":{\"type\":\"string\",\"values\":[\"Received\"]}," + "\"Type\":{\"type\":\"string\",\"values\":[\"SMS\",\"MMS\"]}," + "\"Address\":{\"type\":\"string\"}" + "}", + NULL); +} + void ctx::social_status_message::state_change_cb(msg_handle_t handle, msg_struct_t msg, void* user_data) { social_status_message *instance = static_cast(user_data); diff --git a/src/social_status/message.h b/src/social_status/message.h index bb7383c..1c1d15b 100644 --- a/src/social_status/message.h +++ b/src/social_status/message.h @@ -31,6 +31,7 @@ namespace ctx { int subscribe(); int unsubscribe(); static bool is_supported(); + static void submit_trigger_item(); private: msg_handle_t message_handle; diff --git a/src/social_status/social_status_types.h b/src/social_status/social_status_types.h index 870bb46..5d158f0 100644 --- a/src/social_status/social_status_types.h +++ b/src/social_status/social_status_types.h @@ -18,9 +18,9 @@ #define __CONTEXT_SOCIAL_STATUS_TYPES_INTERNAL_H__ // Subject -#define SOCIAL_ST_SUBJ_CALL "social/state/call" -#define SOCIAL_ST_SUBJ_EMAIL "social/event/email" -#define SOCIAL_ST_SUBJ_MESSAGE "social/event/message" +#define SOCIAL_ST_SUBJ_CALL "social/call" +#define SOCIAL_ST_SUBJ_EMAIL "social/email" +#define SOCIAL_ST_SUBJ_MESSAGE "social/message" // Data Key #define SOCIAL_ST_STATE "State" -- 2.7.4