Sync with Tizen 2.4 76/46176/1
authorMu-Woong <muwoong.lee@samsung.com>
Mon, 17 Aug 2015 12:58:29 +0000 (21:58 +0900)
committerMu-Woong <muwoong.lee@samsung.com>
Mon, 17 Aug 2015 12:58:29 +0000 (21:58 +0900)
- Add the init routine for registering trigger item specifications
- Cleanup context item names

Change-Id: Ia850574412761db870700f8f6b7cf9d04388bec2
Signed-off-by: Mu-Woong <muwoong.lee@samsung.com>
25 files changed:
src/activity/activity.h
src/activity/activity_types.h
src/device_context_provider.cpp
src/device_status/battery.cpp
src/device_status/battery.h
src/device_status/device_status_types.h
src/device_status/headphone.cpp
src/device_status/headphone.h
src/device_status/psmode.cpp
src/device_status/psmode.h
src/device_status/runtime-info/charger.cpp
src/device_status/runtime-info/charger.h
src/device_status/runtime-info/gps.cpp
src/device_status/runtime-info/gps.h
src/device_status/runtime-info/usb.cpp
src/device_status/runtime-info/usb.h
src/device_status/wifi.cpp
src/device_status/wifi.h
src/social_status/call.cpp
src/social_status/call.h
src/social_status/email.cpp
src/social_status/email.h
src/social_status/message.cpp
src/social_status/message.h
src/social_status/social_status_types.h

index d23b208..d0e0951 100644 (file)
                { \
                        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() \
                { \
index da38941..c15bbb4 100644 (file)
 #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"
index 940cd75..d0665fe 100644 (file)
@@ -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()
index d38f099..7aada51 100644 (file)
@@ -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);
index 951e9d1..6fc3fdf 100644 (file)
@@ -32,6 +32,7 @@ namespace ctx {
                int unsubscribe();
                int read();
                static bool is_supported();
+               static void submit_trigger_item();
 
        private:
                device_status_battery();
index a978625..3abff42 100644 (file)
 #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__
index c73ae0b..eb237ee 100644 (file)
@@ -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();
index 50fc5c3..16c2f1e 100644 (file)
@@ -33,6 +33,7 @@ namespace ctx {
                int unsubscribe();
                int read();
                static bool is_supported();
+               static void submit_trigger_item();
 
        private:
                bool connected;
index 2122d08..1806c2b 100644 (file)
@@ -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<device_status_psmode*>(user_data);
index fc4275c..2cc1660 100644 (file)
@@ -31,6 +31,7 @@ namespace ctx {
                int unsubscribe();
                int read();
                static bool is_supported();
+               static void submit_trigger_item();
 
        private:
                device_status_psmode();
index df1b63c..85cd290 100644 (file)
@@ -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;
index 70020a0..52aeb4c 100644 (file)
@@ -28,6 +28,7 @@ namespace ctx {
        public:
                int read();
                static bool is_supported();
+               static void submit_trigger_item();
 
        private:
                device_status_charger();
index ccd6ee6..bf8b251 100644 (file)
@@ -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;
index fdbe0cf..4d94cc0 100644 (file)
@@ -28,6 +28,7 @@ namespace ctx {
        public:
                int read();
                static bool is_supported();
+               static void submit_trigger_item();
 
        private:
                device_status_gps();
index cefb72e..5f92307 100644 (file)
@@ -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;
index 2242bd0..bc01425 100644 (file)
@@ -28,6 +28,7 @@ namespace ctx {
        public:
                int read();
                static bool is_supported();
+               static void submit_trigger_item();
 
        private:
                device_status_usb();
index 86b4412..6064b74 100644 (file)
@@ -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;
index 1f5d304..2fff2ba 100644 (file)
@@ -32,6 +32,7 @@ namespace ctx {
                int unsubscribe();
                int read();
                static bool is_supported();
+               static void submit_trigger_item();
 
        private:
                enum _state_e {
index 82e8550..53daca3 100644 (file)
@@ -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<social_status_call*>(user_data);
index c130c23..baef3cb 100644 (file)
@@ -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;
index a0a98f2..8c3d93a 100644 (file)
@@ -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;
index 3156067..cbfc671 100644 (file)
@@ -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;
index 1d75ef3..8c41232 100644 (file)
@@ -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<social_status_message*>(user_data);
index bb7383c..1c1d15b 100644 (file)
@@ -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;
index 870bb46..5d158f0 100644 (file)
@@ -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"