Add new AppControl operations
authorDoHyun Pyun <dh79.pyun@samsung.com>
Wed, 3 Apr 2013 04:50:10 +0000 (13:50 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Wed, 3 Apr 2013 04:54:34 +0000 (13:54 +0900)
BT Pick / Visibility operation name and output key will be changed.
For the compatibility with previous operations, add new AppControl
operations. After applying in OSP package, we will remove original
operations.

Change-Id: If05e4aa18fcf4b46996589560fb550d1849698e1

data/ug-bluetooth-efl.xml
include/bt-type-define.h
src/ui/bt-main-view.c

index 60f6603..9dfaf6a 100644 (file)
                <application-service>
                        <operation name="http://tizen.org/appcontrol/operation/pick"/>
                </application-service>
+               <application-service>
+                       <operation name="http://tizen.org/appcontrol/operation/bluetooth/pick"/>
+               </application-service>
+               <application-service>
+                       <operation name="http://tizen.org/appcontrol/operation/configure/bluetooth/visibility"/>
+               </application-service>
        </ui-application>
 </manifest>
index c5458c5..204814f 100644 (file)
@@ -99,6 +99,22 @@ extern "C" {
 
 #define BT_VCONF_VISIBLE_TIME "file/private/libug-setting-bluetooth-efl/visibility_time"
 
+/* AppControl Operation */
+#define BT_APPCONTROL_PICK_OPERATION "http://tizen.org/appcontrol/operation/bluetooth/pick"
+#define BT_APPCONTROL_VISIBILITY_OPERATION "http://tizen.org/appcontrol/operation/configure/bluetooth/visibility"
+
+/* AppControl Output */
+#define BT_APPCONTROL_ADDRESS "http://tizen.org/appcontrol/data/bluetooth/address"
+#define BT_APPCONTROL_NAME "http://tizen.org/appcontrol/data/bluetooth/name"
+#define BT_APPCONTROL_RSSI "http://tizen.org/appcontrol/data/bluetooth/rssi"
+#define BT_APPCONTROL_IS_PAIRED "http://tizen.org/appcontrol/data/bluetooth/is_paired"
+#define BT_APPCONTROL_MAJOR_CLASS "http://tizen.org/appcontrol/data/bluetooth/major_class"
+#define BT_APPCONTROL_MINOR_CLASS "http://tizen.org/appcontrol/data/bluetooth/minor_class"
+#define BT_APPCONTROL_SERVICE_CLASS "http://tizen.org/appcontrol/data/bluetooth/service_class"
+#define BT_APPCONTROL_SERVICE_TYPE "http://tizen.org/appcontrol/data/bluetooth/service_type"
+#define BT_APPCONTROL_UUID_LIST "http://tizen.org/appcontrol/data/bluetooth/uuid_list"
+#define BT_APPCONTROL_VISIBILITY "http://tizen.org/appcontrol/data/bluetooth/visibility"
+
 /* Access information */
 #define BT_STR_ACCES_INFO_MAX_LEN 512
 #define BT_STR_ACC_ICON "Icon"
@@ -122,6 +138,12 @@ typedef enum {
 } bt_visible_time_t;
 
 typedef enum {
+       BT_VISIBLE_OFF = 0,
+       BT_VISIBLE_ALWAYS = 1,
+       BT_VISIBLE_TIME_LIMITED = 2,
+} bt_visible_result_t;
+
+typedef enum {
        BT_SEARCH_ALL_DEVICE = 0,
        BT_SEARCH_PHONE,
        BT_SEARCH_HEADSET,
index 70be90b..0248fe7 100644 (file)
@@ -799,6 +799,7 @@ static service_h __bt_main_get_visibility_result(bt_ug_data *ugd,
        service_h service = NULL;
        char mode_str[BT_RESULT_STR_MAX] = { 0 };
        const char *result_str;
+       int visibility = BT_VISIBLE_OFF;
 
        retv_if(ugd == NULL, NULL);
 
@@ -816,6 +817,7 @@ static service_h __bt_main_get_visibility_result(bt_ug_data *ugd,
                BT_DBG("Fail to add extra data");
        }
 
+       /* Original output fields will be removed */
        snprintf(mode_str, BT_RESULT_STR_MAX, "%d", (int)ugd->selected_radio);
 
        if (service_add_extra_data(service, "visibility",
@@ -823,6 +825,32 @@ static service_h __bt_main_get_visibility_result(bt_ug_data *ugd,
                BT_DBG("Fail to add extra data");
        }
 
+       /* Convert the radio value to result */
+       switch (ugd->selected_radio) {
+       case 0:
+               visibility = BT_VISIBLE_OFF;
+               break;
+       case 1:
+       case 2:
+       case 3:
+               visibility = BT_VISIBLE_TIME_LIMITED;
+               break;
+       case 4:
+               visibility = BT_VISIBLE_ALWAYS;
+               break;
+       default:
+               visibility = BT_VISIBLE_OFF;
+               break;
+       }
+
+       memset(mode_str, 0x00, BT_RESULT_STR_MAX);
+       snprintf(mode_str, BT_RESULT_STR_MAX, "%d", visibility);
+
+       if (service_add_extra_data(service, BT_APPCONTROL_VISIBILITY,
+                                       (const char *)mode_str) < 0) {
+               BT_DBG("Fail to add extra data");
+       }
+
        return service;
 }
 
@@ -856,16 +884,27 @@ static service_h __bt_main_get_pick_result(bt_ug_data *ugd,
 
        _bt_util_addr_type_to_addr_result_string(address, dev->bd_addr);
 
+       /* Original output fields will be removed */
        if (service_add_extra_data(service, "address",
                                        (const char *)address) < 0) {
                BT_DBG("Fail to add extra data");
        }
 
+       if (service_add_extra_data(service, BT_APPCONTROL_ADDRESS,
+                       (const char *)address) < 0) {
+               BT_DBG("Fail to add extra data");
+       }
+
        if (service_add_extra_data(service, "name",
                                        (const char *)dev->name) < 0) {
                BT_DBG("Fail to add extra data");
        }
 
+       if (service_add_extra_data(service, BT_APPCONTROL_NAME,
+                                       (const char *)dev->name) < 0) {
+               BT_DBG("Fail to add extra data");
+       }
+
        snprintf(value_str, BT_RESULT_STR_MAX, "%d", dev->rssi);
 
        if (service_add_extra_data(service, "rssi",
@@ -873,6 +912,11 @@ static service_h __bt_main_get_pick_result(bt_ug_data *ugd,
                BT_DBG("Fail to add extra data");
        }
 
+       if (service_add_extra_data(service, BT_APPCONTROL_RSSI,
+                                       (const char *)value_str) < 0) {
+               BT_DBG("Fail to add extra data");
+       }
+
        memset(value_str, 0x00, sizeof(value_str));
        snprintf(value_str, BT_RESULT_STR_MAX, "%d", dev->is_bonded);
 
@@ -881,6 +925,11 @@ static service_h __bt_main_get_pick_result(bt_ug_data *ugd,
                BT_DBG("Fail to add extra data");
        }
 
+       if (service_add_extra_data(service, BT_APPCONTROL_IS_PAIRED,
+                                       (const char *)value_str) < 0) {
+               BT_DBG("Fail to add extra data");
+       }
+
        memset(value_str, 0x00, sizeof(value_str));
        snprintf(value_str, BT_RESULT_STR_MAX, "%d", dev->major_class);
 
@@ -889,6 +938,11 @@ static service_h __bt_main_get_pick_result(bt_ug_data *ugd,
                BT_DBG("Fail to add extra data");
        }
 
+       if (service_add_extra_data(service, BT_APPCONTROL_MAJOR_CLASS,
+                                       (const char *)value_str) < 0) {
+               BT_DBG("Fail to add extra data");
+       }
+
        memset(value_str, 0x00, sizeof(value_str));
        snprintf(value_str, BT_RESULT_STR_MAX, "%d", dev->minor_class);
 
@@ -897,6 +951,11 @@ static service_h __bt_main_get_pick_result(bt_ug_data *ugd,
                BT_DBG("Fail to add extra data");
        }
 
+       if (service_add_extra_data(service, BT_APPCONTROL_MINOR_CLASS,
+                                       (const char *)value_str) < 0) {
+               BT_DBG("Fail to add extra data");
+       }
+
        memset(value_str, 0x00, sizeof(value_str));
        snprintf(value_str, BT_RESULT_STR_MAX, "%ld",
                                (long int)dev->service_class);
@@ -906,12 +965,23 @@ static service_h __bt_main_get_pick_result(bt_ug_data *ugd,
                BT_DBG("Fail to add extra data");
        }
 
+       if (service_add_extra_data(service, BT_APPCONTROL_SERVICE_CLASS ,
+                                       (const char *)value_str) < 0) {
+               BT_DBG("Fail to add extra data");
+       }
+
        if (service_add_extra_data_array(service, "uuids",
                                        (const char **)dev->uuids,
                                        dev->uuid_count) < 0) {
                BT_DBG("Fail to add extra data");
        }
 
+       if (service_add_extra_data_array(service, BT_APPCONTROL_UUID_LIST,
+                                       (const char **)dev->uuids,
+                                       dev->uuid_count) < 0) {
+               BT_DBG("Fail to add extra data");
+       }
+
        return service;
 }
 
@@ -3588,6 +3658,12 @@ void __bt_main_parse_service(bt_ug_data *ugd, service_h service)
 
                if (service_add_extra_data(service, "files", file_path) < 0)
                        BT_ERR("Fail to add extra data");
+       } else if (g_strcmp0(operation, BT_APPCONTROL_PICK_OPERATION) == 0) {
+               BT_DBG("Pick Operation");
+               launch_type = strdup("pick");
+       } else if (g_strcmp0(operation, BT_APPCONTROL_VISIBILITY_OPERATION) == 0) {
+               BT_DBG("Visibility Operation");
+               launch_type = strdup("visibility");
        } else if (service_get_extra_data(service, "launch-type",
                                                &launch_type) == SERVICE_ERROR_NONE) {
                if (service_add_extra_data(service, "type", "file") < 0)