From: nazib.ullah Date: Thu, 3 Nov 2016 08:10:22 +0000 (+0600) Subject: [TBT][tizen_3.0_mobile][IoT modules Updated, issue fixed] X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d8e7e4d4c43042c3799213a08c398b11ce32b2b2;p=test%2Ftct%2Fnative%2Fbehavior.git [TBT][tizen_3.0_mobile][IoT modules Updated, issue fixed] Change-Id: I520c7381965dc5b54222908e039f63ef5cee53e7 --- diff --git a/release/binary-armv7l/install.sh b/release/binary-armv7l/install.sh index 3690e9f..98791d3 100755 --- a/release/binary-armv7l/install.sh +++ b/release/binary-armv7l/install.sh @@ -42,11 +42,6 @@ sdb push tbt_push_auth.xml /home/owner/media/Others sdb push iotcon-test-svr-db-client.dat /home/owner/media/Others sdb push iotcon-test-svr-db-server.dat /home/owner/media/Others -sdb root on -sdb shell chown owner:priv_mediastorage /home/owner/media/Others/iotcon-test-svr-db-client.dat -sdb shell chown owner:priv_mediastorage /home/owner/media/Others/iotcon-test-svr-db-server.dat -sdb root off - sdb shell pkgcmd -i -t tpk -p /tmp/org.tizen.coretbt_dataprovider-1.0.0-arm.tpk sdb shell pkgcmd -i -t tpk -p /tmp/org.tizen.coretbt_serviceapp-1.0.0-arm.tpk sdb shell pkgcmd -i -t tpk -p /tmp/org.tizen.coretbt_uiapp-1.0.0-arm.tpk diff --git a/release/binary-armv7l/org.tizen.tbtcoreapp-1.0.0-arm.tpk b/release/binary-armv7l/org.tizen.tbtcoreapp-1.0.0-arm.tpk index b5ddb14..410913a 100644 Binary files a/release/binary-armv7l/org.tizen.tbtcoreapp-1.0.0-arm.tpk and b/release/binary-armv7l/org.tizen.tbtcoreapp-1.0.0-arm.tpk differ diff --git a/tbtcoreapp/res/edje/3.0/mobile/iotcon_viewer.edc b/tbtcoreapp/res/edje/3.0/mobile/iotcon_viewer.edc index dca1675..c209a96 100644 --- a/tbtcoreapp/res/edje/3.0/mobile/iotcon_viewer.edc +++ b/tbtcoreapp/res/edje/3.0/mobile/iotcon_viewer.edc @@ -18,47 +18,47 @@ collections { - base_scale: 1.8; - group - { - name: "iotcon_viewer"; - parts{ - part{ - name: "iotcon_text"; - type: SWALLOW; - description{ - state: "default" 0.0; - align: 0.0 0.0; - visible: 1; - rel1 {relative: 0.0 0.0; } - rel2 {relative: 1.0 TEXT_HEIGHT; } - } + base_scale: 1.8; + group + { + name: "iotcon_viewer"; + parts{ + part{ + name: "iotcon_text"; + type: SWALLOW; + description{ + state: "default" 0.0; + align: 0.0 0.0; + visible: 1; + rel1 {relative: 0.0 0.0; } + rel2 {relative: 1.0 TEXT_HEIGHT; } } - - part{ - name: "iotcon_info_view"; - type: SWALLOW; - description{ - state: "default" 0.0; - align: 0.0 0.0; - visible: 1; - rel1 {relative: 0.0 0.1; } - rel2 {relative: 1.0 0.8; } - } + } + + part{ + name: "iotcon_info_view"; + type: SWALLOW; + description{ + state: "default" 0.0; + align: 0.0 0.0; + visible: 1; + rel1 {relative: 0.0 0.1; } + rel2 {relative: 1.0 0.9; } } - - - part{ - name: "iotcon_btn"; - type: SWALLOW; - description{ - state: "default" 0.0; - align: 0.0 0.0; - visible: 1; - rel1 {relative: 0.0 0.8; } - rel2 {relative: 1.0 1.0; } - } + } + + + part{ + name: "iotcon_btn"; + type: SWALLOW; + description{ + state: "default" 0.0; + align: 0.0 0.0; + visible: 1; + rel1 {relative: 0.0 0.9; } + rel2 {relative: 1.0 1.0; } } - } - } + } + } + } } diff --git a/tbtcoreapp/src/model/tbt-list.c b/tbtcoreapp/src/model/tbt-list.c index 3644c4b..0549bab 100644 --- a/tbtcoreapp/src/model/tbt-list.c +++ b/tbtcoreapp/src/model/tbt-list.c @@ -2392,31 +2392,39 @@ static tbt_info tbtapps[] = #ifdef TBT_MODULE_APP_IOTCON_BASIC_SERVER //iotcon basic server { - .name = "IoTcon Basic Server", + .name = "IoTCon Basic Server", .parent = "IoT", .apptype = TBT_APP_IOTCON_BASIC_SERVER, .icon_name = "dummy", - .info = "IoTcon Basic Server", + .info = "1. Run IoTCon Basic Client in Other Device after run this module.
" + "2. Make sure both Server and Client Device connected in Same Wifi AP.
" + "3. Follow the Instructions of IoTCon Basic Client module.
" + "4. After Open/Close Door button enabled, Press this button and Corresponding Change will be shown in Client end.", .result = 0, - .required_features_count = 0, //1 - .features_required = {} //http://tizen.org/feature/iot.ocf + .required_features_count = 1, + .features_required = {FEATURE_IOT_OCF} }, #endif #ifdef TBT_MODULE_APP_IOTCON_BASIC_CLIENT //iotcon basic client { - .name = "IoTcon Basic Client", + .name = "IoTCon Basic Client", .parent = "IoT", .apptype = TBT_APP_IOTCON_BASIC_CLIENT, .icon_name = "dummy", - .info = "IoTcon Basic Client", + .info = "1. Run IoTCon Basic Server module in Other Device before run this module.
" + "2. A resource ID will be shown in List.
" + "3. Select resource ID, Then GET button will be enabled.
" + "4. Press GET button, GET will be shown in Server end and PUT button will be enabled in Client end.
" + "5. Press PUT button, PUT will be shown in Server end and POST button will be enabled in Client end.
" + "6. Press POST button, POST will be shown in Server end and DELETE button will be enabled in Client end.
" + "7. Press DELETE button, DELETE will be shown in Server end and Open/Close> Door button will be enabled in Server end.", .result = 0, - .required_features_count = 0, //1 - .features_required = {} //http://tizen.org/feature/iot.ocf + .required_features_count = 1, + .features_required = {FEATURE_IOT_OCF} }, #endif #endif - #ifdef TBT_MODULE_DALI #ifdef TBT_MODULE_APP_DALI_ACTOR diff --git a/tbtcoreapp/src/view/tbt-iotcon-view.c b/tbtcoreapp/src/view/tbt-iotcon-view.c index ac4bfe4..b71f04e 100644 --- a/tbtcoreapp/src/view/tbt-iotcon-view.c +++ b/tbtcoreapp/src/view/tbt-iotcon-view.c @@ -15,7 +15,7 @@ *******************************************************************************/ /** * @file tbt-iotcon-view.c - * @brief covers IoTvitiy connection reiotconed apis + * @brief covers IoT Connectivity apis * @since_tizen 3.0 * @author A. B. M. Nazibullah(nazib.ullah@samsung.com) * @date October, 2016 @@ -48,7 +48,8 @@ static char *door_resource_device_id; /* Door Resource */ -typedef struct _door_resource_s { +typedef struct _door_resource_s +{ bool attributes; char *uri_path; char *type; @@ -65,23 +66,18 @@ struct _iotcon_view Evas_Object *iotcon_label; Evas_Object *iotcon_btn; - Evas_Object* get_btn; Evas_Object* post_btn; Evas_Object* put_btn; Evas_Object* del_btn; - Evas_Object* info_list; GList *device_id_list; - door_resource_s my_door; iotcon_query_h query; - iotcon_remote_resource_h resource_clone; bool opened; - char *host; char *created_uri_path; iotcon_connectivity_type_e connectivity_type; @@ -91,7 +87,6 @@ struct _iotcon_view static void _app_destroy_cb(void* this); static char* get_iotcon_error(iotcon_error_e err); - static int _set_door_resource(door_resource_s *door); static iotcon_resource_h _create_door_resource(char *uri_path, char *type, iotcon_resource_interfaces_h ifaces, uint8_t policies, void *user_data); static void _iotcon_server_change_state_btn_pressed_cb(void *data, Evas_Object *obj, void *event_info); @@ -101,9 +96,8 @@ static int _set_door_representation(door_resource_s *door, iotcon_representation static int _send_response(iotcon_request_h request, iotcon_representation_h repr, iotcon_response_result_e result); static void _request_handler(iotcon_resource_h resource, iotcon_request_h request, void *user_data); static int _request_handler_delete(iotcon_resource_h resource, iotcon_request_h request); -static int _request_handler_post(door_resource_s *door, iotcon_request_h request); +static int _request_handler_post(door_resource_s *door, iotcon_request_h request, void *user_data); static int _request_handler_put(door_resource_s *door, iotcon_request_h request); - static bool _found_resource(iotcon_remote_resource_h resource, iotcon_error_e result, void *user_data); static void _on_response(iotcon_remote_resource_h resource, iotcon_error_e err, iotcon_request_type_e request_type, iotcon_response_h response, void *user_data); static void disable_control_button(iotcon_view *this, bool get, bool post, bool put, bool del); @@ -117,6 +111,78 @@ static void _on_observe(iotcon_remote_resource_h resource, iotcon_error_e err, i static void discovered_resource_list_show(iotcon_view *this); static void _resource_selected_cb(void *data, Evas_Object *obj, void *event_info); +#define USE_GENLIST + +#ifdef USE_GENLIST +typedef struct +{ + int index; + Elm_Object_Item *item; + char* text; +}item_data; + +static void _gl_del_cb(void *data, Evas_Object *obj EINA_UNUSED); +static char *_gl_text_get_cb(void *data, Evas_Object *obj, const char *part); +Elm_Object_Item* _iotcon_elm_genlist_item_append(Evas_Object* list, char *item_text, Evas_Smart_Cb func, void* data); +#endif + +#ifdef USE_GENLIST +static void _gl_del_cb(void *data, Evas_Object *obj EINA_UNUSED) +{ + DBG("_gl_del_cb"); + item_data *id = data; + RETM_IF(!id, "item is NULL"); + SAFE_DELETE(id); +} + +static char *_gl_text_get_cb(void *data, Evas_Object *obj, const char *part) +{ + DBG("_gl_text_get_cb"); + item_data *id = data; + if(part && !strcmp(part, "elm.text")) + { + char buf[1024]; + snprintf(buf, 1023,"%s", id->text); + return strdup(buf); + } + return NULL; +} + +Elm_Object_Item* _iotcon_elm_genlist_item_append(Evas_Object* list, char *item_text, Evas_Smart_Cb func, void* data) +{ + + DBG("_pick_elm_genlist_item_append%s:", item_text); + static int index = 1; + Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new(); + + itc->item_style = "default"; + itc->func.text_get = _gl_text_get_cb; + itc->func.content_get = NULL; + itc->func.del = _gl_del_cb; + + item_data *id = calloc(sizeof(item_data), 1); + id->index = index++; + id->text = strdup(item_text); + + elm_scroller_single_direction_set(list, ELM_SCROLLER_SINGLE_DIRECTION_HARD); + + //HOMOGENEOUS MODE + //If item height is same when each style name is same, Use homogeneous mode. + elm_genlist_homogeneous_set(list, EINA_TRUE); + + //COMPRESS MODE + //For the Mobile view, because it has full window, compresse mode should be used. + elm_genlist_mode_set(list, ELM_LIST_COMPRESS); + + Elm_Object_Item *item = elm_genlist_item_append(list, itc,id, NULL, ELM_GENLIST_ITEM_NONE, func, data); + id->item = item; + + elm_genlist_item_class_free(itc); + + return item; +} +#endif + /** * @function iotcon_view_add @@ -143,23 +209,30 @@ iotcon_view *iotcon_view_add(Evas_Object *navi, tbt_info *tbt_info, Elm_Object_I RETVM_IF(NULL == this->view, NULL, "navi is null"); this->iotcon_label = ui_utils_label_add(this->view->layout, ""); - ui_utils_label_set_text(this->iotcon_label, "Info: ", "left"); + ui_utils_label_set_text(this->iotcon_label, "", "left"); elm_object_part_content_set(this->view->layout, "iotcon_text", this->iotcon_label); +#ifdef USE_GENLIST + this->info_list = elm_genlist_add(this->view->layout); + RETVM_IF(!this->info_list, NULL, "elm_genlist_add failed"); +#else this->info_list = elm_list_add(this->view->layout); RETVM_IF(!this->info_list, NULL, "elm_list_add failed"); +#endif + evas_object_data_set(this->info_list, "view_data", this); elm_object_part_content_set(this->view->layout, "iotcon_info_view", this->info_list); +#ifndef USE_GENLIST elm_list_go(this->info_list); +#endif evas_object_show(this->info_list); char db_file_path[256]={'\0',}; - if(this->view->tbt_info->apptype == TBT_APP_IOTCON_BASIC_SERVER) { - this->iotcon_btn = ui_utils_push_button_add(this, this->view->layout, "Open/Close", _iotcon_server_change_state_btn_pressed_cb); + this->iotcon_btn = ui_utils_push_button_add(this, this->view->layout, "Open/Close Door", _iotcon_server_change_state_btn_pressed_cb); elm_object_part_content_set(this->view->layout, "iotcon_btn", this->iotcon_btn); elm_object_disabled_set(this->iotcon_btn, true); @@ -231,19 +304,27 @@ static void _app_destroy_cb(void* this) view = (iotcon_view*)this; RETM_IF(NULL == view, "view is NULL"); + int ret; + if(view->view->tbt_info->apptype == TBT_APP_IOTCON_BASIC_SERVER) { - iotcon_stop_presence(); - iotcon_resource_destroy(view->my_door.handle); + ret = iotcon_stop_presence(); + DBG("iotcon_stop_presence : %s", get_iotcon_error(ret)); + ret = iotcon_resource_destroy(view->my_door.handle); + DBG("iotcon_resource_destroy : %s", get_iotcon_error(ret)); _free_door_resource(&view->my_door); _resource_created = false; } if(view->view->tbt_info->apptype == TBT_APP_IOTCON_BASIC_CLIENT) { - iotcon_query_destroy(view->query); + ret = iotcon_query_destroy(view->query); + DBG("iotcon_query_destroy : %s", get_iotcon_error(ret)); + ret = iotcon_remote_resource_observe_deregister(view->resource_clone); + DBG("iotcon_remote_resource_observe_deregister : %s", get_iotcon_error(ret)); } /* deinitialize iotcon */ - iotcon_deinitialize(); + ret = iotcon_deinitialize(); + DBG("iotcon_deinitialize : %s", get_iotcon_error(ret)); SAFE_DELETE(view->view); SAFE_DELETE(view); } @@ -253,8 +334,8 @@ static void _free_door_resource(door_resource_s *door) { iotcon_observers_destroy(door->observers); iotcon_resource_interfaces_destroy(door->ifaces); - free(door->type); - free(door->uri_path); + SAFE_DELETE(door->type); + SAFE_DELETE(door->uri_path); } static void _get_button_pressed_cb(void *data, Evas_Object *obj, void *event_info) @@ -269,10 +350,6 @@ static void _get_button_pressed_cb(void *data, Evas_Object *obj, void *event_inf iotcon_query_h query; int result; - - result = iotcon_remote_resource_observe_register(this->resource_clone, IOTCON_OBSERVE_IGNORE_OUT_OF_ORDER, NULL, _on_observe, this); - RETM_IF(IOTCON_ERROR_NONE != result, "iotcon_remote_resource_observe_register result(%s)", get_iotcon_error(result)); - result = iotcon_query_create(&query); RETM_IF(IOTCON_ERROR_NONE != result, "iotcon_query_create result(%s)", get_iotcon_error(result)); @@ -300,14 +377,14 @@ static void _post_button_pressed_cb(void *data, Evas_Object *obj, void *event_in ret = iotcon_representation_create(&send_repr); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_representation_create() Fail(%d)", ret); + ERR("iotcon_representation_create() Fail(%s)", get_iotcon_error(ret)); return; } /* send POST request */ ret = iotcon_remote_resource_post(this->resource_clone, send_repr, NULL, _on_response, this); if (IOTCON_ERROR_NONE != ret) - ERR("iotcon_remote_resource_post() Fail(%d)", ret); + ERR("iotcon_remote_resource_post() Fail(%s)", get_iotcon_error(ret)); iotcon_representation_destroy(send_repr); } @@ -329,14 +406,16 @@ static void _put_button_pressed_cb(void *data, Evas_Object *obj, void *event_inf RETM_IF(IOTCON_ERROR_NONE != ret, "iotcon_representation_create result(%s)", get_iotcon_error(ret)); ret = iotcon_attributes_create(&send_attributes); - if (IOTCON_ERROR_NONE != ret) { + if (IOTCON_ERROR_NONE != ret) + { ERR("iotcon_attributes_create() Fail(%d)", ret); iotcon_representation_destroy(send_repr); return; } ret = iotcon_attributes_add_bool(send_attributes, "opened", !this->opened); - if (IOTCON_ERROR_NONE != ret) { + if (IOTCON_ERROR_NONE != ret) + { ERR("iotcon_attributes_add_bool() Fail(%d)", ret); iotcon_attributes_destroy(send_attributes); iotcon_representation_destroy(send_repr); @@ -344,8 +423,9 @@ static void _put_button_pressed_cb(void *data, Evas_Object *obj, void *event_inf } ret = iotcon_representation_set_attributes(send_repr, send_attributes); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_representation_set_attributes() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_representation_set_attributes() Fail(%s)", get_iotcon_error(ret)); iotcon_attributes_destroy(send_attributes); iotcon_representation_destroy(send_repr); return; @@ -376,17 +456,22 @@ static void _del_button_pressed_cb(void *data, Evas_Object *obj, void *event_inf ret = iotcon_remote_resource_create(this->host, this->connectivity_type, this->created_uri_path, IOTCON_RESOURCE_SECURE, this->types, this->ifaces, &new_door_resource); - if (IOTCON_ERROR_NONE != ret) { + if (IOTCON_ERROR_NONE != ret) + { ERR("iotcon_remote_resource_create() Fail(%s)", get_iotcon_error(ret)); return; } ret = iotcon_remote_resource_delete(new_door_resource, _on_response, this); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_remote_resource_delete() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_remote_resource_delete() Fail(%s)", get_iotcon_error(ret)); iotcon_remote_resource_destroy(new_door_resource); return; } + + int result = iotcon_remote_resource_observe_register(this->resource_clone, IOTCON_OBSERVE_IGNORE_OUT_OF_ORDER, NULL, _on_observe, this); + RETM_IF(IOTCON_ERROR_NONE != result, "iotcon_remote_resource_observe_register result(%s)", get_iotcon_error(result)); } static void disable_control_button(iotcon_view *this, bool get, bool put, bool post, bool del) @@ -418,7 +503,7 @@ static Evas_Object *add_control_layout(iotcon_view *this, Evas_Object *parent) this->post_btn = ui_utils_push_button_add(this, table, "POST", _post_button_pressed_cb); elm_table_pack(table, this->post_btn, 2, 0, 1, 1); - this->del_btn = ui_utils_push_button_add(this, table, "DEL", _del_button_pressed_cb); + this->del_btn = ui_utils_push_button_add(this, table, "DELETE", _del_button_pressed_cb); elm_table_pack(table, this->del_btn, 3, 0, 1, 1); disable_control_button(this, true, true, true, true); @@ -426,8 +511,6 @@ static Evas_Object *add_control_layout(iotcon_view *this, Evas_Object *parent) return table; } - -///////////////////////////////////////////client/////////////////////////////////////////////////// static void _on_observe(iotcon_remote_resource_h resource, iotcon_error_e err, int sequence_number, iotcon_response_h response, void *user_data) { @@ -443,57 +526,78 @@ static void _on_observe(iotcon_remote_resource_h resource, iotcon_error_e err, iotcon_representation_h repr; iotcon_response_result_e response_result; - RETM_IF(IOTCON_ERROR_NONE != err, "_on_observe error(%d)", err); + if(i==0) + { + #ifdef USE_GENLIST + elm_genlist_clear(this->info_list); + #else + elm_list_clear(this->info_list); + #endif + i=1; + } + + RETM_IF(IOTCON_ERROR_NONE != err, "_on_observe error(%s)", get_iotcon_error(err)); ret = iotcon_response_get_result(response, &response_result); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_response_get_result() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_response_get_result() Fail(%s)", get_iotcon_error(ret)); return; } - if (IOTCON_RESPONSE_OK != response_result) { + if (IOTCON_RESPONSE_OK != response_result) + { ERR("_on_response_observe Response error(%d)", response_result); return; } ret = iotcon_response_get_representation(response, &repr); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_response_get_representation() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_response_get_representation() Fail(%s)", get_iotcon_error(ret)); return; } ret = iotcon_representation_get_attributes(repr, &attributes); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_representation_get_attributes() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_representation_get_attributes() Fail(%s)", get_iotcon_error(ret)); return; } ret = iotcon_attributes_get_bool(attributes, "opened", &opened); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_attributes_get_bool() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_attributes_get_bool() Fail(%s)", get_iotcon_error(ret)); return; } DBG("notify_cb information"); - switch ((int)opened) { + switch ((int)opened) + { case true: DBG("[Door] opened."); - elm_list_item_append(this->info_list,"[Door] opened.", NULL, NULL, NULL, NULL); +#ifdef USE_GENLIST + _iotcon_elm_genlist_item_append(this->info_list, "[Door] opened.",NULL,NULL); +#else + elm_list_item_append(this->info_list, "[Door] opened.", NULL, NULL, NULL, NULL); +#endif break; case false: DBG("[Door] closed."); - elm_list_item_append(this->info_list,"[Door] closed.", NULL, NULL, NULL, NULL); +#ifdef USE_GENLIST + _iotcon_elm_genlist_item_append(this->info_list, "[Door] closed.",NULL,NULL); +#else + elm_list_item_append(this->info_list, "[Door] closed.", NULL, NULL, NULL, NULL); +#endif break; default: break; } -// if (5 == i++) { -// iotcon_remote_resource_observe_deregister(resource); -// iotcon_remote_resource_destroy(resource); -// } - +#ifndef USE_GENLIST elm_list_go(this->info_list); +#endif } static void _on_response_delete(iotcon_remote_resource_h resource, @@ -508,27 +612,23 @@ static void _on_response_delete(iotcon_remote_resource_h resource, iotcon_response_result_e response_result; ret = iotcon_response_get_result(response, &response_result); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_response_get_result() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_response_get_result() Fail(%s)", get_iotcon_error(ret)); return; } - if (IOTCON_RESPONSE_OK != response_result - && IOTCON_RESPONSE_RESOURCE_DELETED != response_result) { + if (IOTCON_RESPONSE_OK != response_result && IOTCON_RESPONSE_RESOURCE_DELETED != response_result) + { ERR("_on_response_delete Response error(%d)", response_result); return; } - iotcon_remote_resource_observe_deregister(resource); - DBG("DELETE request was successful"); disable_control_button(this, true, true, true, true); - /* delete callback operations */ - iotcon_remote_resource_destroy(resource); } -static void _on_response_post(iotcon_remote_resource_h resource, - iotcon_response_h response, void *user_data) +static void _on_response_post(iotcon_remote_resource_h resource, iotcon_response_h response, void *user_data) { RETM_IF(NULL == user_data, "data is NULL"); @@ -546,58 +646,67 @@ static void _on_response_post(iotcon_remote_resource_h resource, this->ifaces = NULL; ret = iotcon_response_get_result(response, &response_result); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_response_get_result() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_response_get_result() Fail(%s)", get_iotcon_error(ret)); return; } - if (IOTCON_RESPONSE_RESOURCE_CREATED != response_result) { + if (IOTCON_RESPONSE_RESOURCE_CREATED != response_result) + { ERR("_on_response_post Response error(%d)", response_result); return; } DBG("POST request was successful"); ret = iotcon_response_get_representation(response, &recv_repr); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_response_get_representation() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_response_get_representation() Fail(%s)", get_iotcon_error(ret)); return; } ret = iotcon_representation_get_attributes(recv_repr, &recv_attributes); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_representation_get_attributes() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_representation_get_attributes() Fail(%s)", get_iotcon_error(ret)); return; } ret = iotcon_attributes_get_str(recv_attributes, "createduripath", &created_uri_path); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_attributes_get_str() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_attributes_get_str() Fail(%s)", get_iotcon_error(ret)); return; } this->created_uri_path = strdup(created_uri_path); DBG("New resource created : %s", this->created_uri_path); ret = iotcon_remote_resource_get_host_address(resource, &this->host); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_remote_resource_get_host_address() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_remote_resource_get_host_address() Fail(%s)", get_iotcon_error(ret)); return; } ret = iotcon_remote_resource_get_connectivity_type(resource, &this->connectivity_type); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_remote_resource_get_connectivity_type() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_remote_resource_get_connectivity_type() Fail(%s)", get_iotcon_error(ret)); return; } ret = iotcon_remote_resource_get_types(resource, &this->types); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_remote_resource_get_types() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_remote_resource_get_types() Fail(%s)", get_iotcon_error(ret)); return; } ret = iotcon_remote_resource_get_interfaces(resource, &this->ifaces); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_remote_resource_get_interfaces() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_remote_resource_get_interfaces() Fail(%s)", get_iotcon_error(ret)); return; } @@ -617,12 +726,14 @@ static void _on_response_put(iotcon_remote_resource_h resource, iotcon_response_result_e response_result; ret = iotcon_response_get_result(response, &response_result); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_response_get_result() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_response_get_result() Fail(%s)", get_iotcon_error(ret)); return; } - if (IOTCON_RESPONSE_RESOURCE_CHANGED != response_result) { + if (IOTCON_RESPONSE_RESOURCE_CHANGED != response_result) + { ERR("_on_response_put Response error(%d)", response_result); return; } @@ -689,8 +800,7 @@ static bool _get_res_type_cb(const char *string, void *user_data) return IOTCON_FUNC_CONTINUE; } -static void _presence_handler(iotcon_presence_h presence, iotcon_error_e err, - iotcon_presence_response_h response, void *user_data) +static void _presence_handler(iotcon_presence_h presence, iotcon_error_e err, iotcon_presence_response_h response, void *user_data) { char *host_address; char *resource_type; @@ -699,37 +809,43 @@ static void _presence_handler(iotcon_presence_h presence, iotcon_error_e err, iotcon_presence_trigger_e trigger; iotcon_connectivity_type_e connectivity_type; - RETM_IF(IOTCON_ERROR_NONE != err, "_presence_handler error(%d)", err); + RETM_IF(IOTCON_ERROR_NONE != err, "_presence_handler error(%s)", get_iotcon_error(err)); ret = iotcon_presence_response_get_result(response, &result); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_presence_response_get_result() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_presence_response_get_result() Fail(%s)", get_iotcon_error(ret)); return; } - if (IOTCON_PRESENCE_OK == result) { + if (IOTCON_PRESENCE_OK == result) + { ret = iotcon_presence_response_get_trigger(response, &trigger); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_presence_response_get_trigger() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_presence_response_get_trigger() Fail(%s)", get_iotcon_error(ret)); return; } } ret = iotcon_presence_response_get_host_address(response, &host_address); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_presence_response_get_host_address() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_presence_response_get_host_address() Fail(%s)", get_iotcon_error(ret)); return; } ret = iotcon_presence_response_get_connectivity_type(response, &connectivity_type); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_presence_response_get_connectivity_type() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_presence_response_get_connectivity_type() Fail(%s)", get_iotcon_error(ret)); return; } ret = iotcon_presence_response_get_resource_type(response, &resource_type); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_presence_response_get_resource_type() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_presence_response_get_resource_type() Fail(%s)", get_iotcon_error(ret)); return; } @@ -755,10 +871,11 @@ static void _on_response(iotcon_remote_resource_h resource, iotcon_error_e err, this = (iotcon_view*)user_data; RETM_IF(NULL == this, "view is NULL"); - RETM_IF(IOTCON_ERROR_NONE != err, "_on_response error(%d)", err); + RETM_IF(IOTCON_ERROR_NONE != err, "_on_response error(%s)", get_iotcon_error(err)); DBG("request(%d) was successful", request_type); - switch (request_type) { + switch (request_type) + { case IOTCON_REQUEST_GET: _on_response_get(resource, response, this); break; @@ -799,9 +916,7 @@ static bool _found_resource(iotcon_remote_resource_h resource, iotcon_error_e re RETVM_IF(IOTCON_ERROR_NONE != result, IOTCON_FUNC_STOP, "Invalid result(%s)", get_iotcon_error(result)); RETVM_IF(NULL == resource, IOTCON_FUNC_CONTINUE, "NULL == resource"); - DBG("===== resource found ====="); - /* get the resource URI */ ret = iotcon_remote_resource_get_uri_path(resource, &resource_uri_path); RETVM_IF(IOTCON_ERROR_NONE != ret, IOTCON_FUNC_CONTINUE, "iotcon_remote_resource_get_uri_path result(%s)", get_iotcon_error(ret)); @@ -864,37 +979,39 @@ static void discovered_resource_list_show(iotcon_view *this) { DBG(" discovered_resource_list_show "); RETM_IF(NULL == this, "view is NULL"); - +#ifdef USE_GENLIST + elm_genlist_clear(this->info_list); +#else elm_list_clear(this->info_list); +#endif GList *l; iotcon_remote_resource_h resource; for(l = this->device_id_list; l != NULL; l = l->next) { - char* resource_uri_path = NULL; resource = (iotcon_remote_resource_h)l->data; - int result; - result = iotcon_remote_resource_get_uri_path(resource, &resource_uri_path); RETM_IF(IOTCON_ERROR_NONE != result, "iotcon_remote_resource_get_uri_path result(%s)", get_iotcon_error(result)); - - if (!strncmp(DOOR_RESOURCE_URI_PREFIX, resource_uri_path,strlen(DOOR_RESOURCE_URI_PREFIX))) { char* resource_device_id; result = iotcon_remote_resource_get_device_id(resource, &resource_device_id); RETM_IF(IOTCON_ERROR_NONE != result, "iotcon_remote_resource_get_device_id result(%s)", get_iotcon_error(result)); - - elm_list_item_append(this->info_list,resource_device_id, NULL, NULL, _resource_selected_cb, resource); +#ifdef USE_GENLIST + _iotcon_elm_genlist_item_append(this->info_list, resource_device_id,_resource_selected_cb, resource); +#else + elm_list_item_append(this->info_list,resource_device_id, NULL, NULL, _resource_selected_cb, resource); +#endif } - } +#ifndef USE_GENLIST elm_list_go(this->info_list); +#endif evas_object_show(this->info_list); } @@ -924,12 +1041,8 @@ static void _resource_selected_cb(void *data, Evas_Object *obj, void *event_info DBG("resource_device_id: %s", resource_device_id); } -///////////////////////////////////////////////////////////////////////////////////////////////////// - - -static iotcon_resource_h _create_door_resource(char *uri_path, char *type, - iotcon_resource_interfaces_h ifaces, uint8_t policies, void *user_data) +static iotcon_resource_h _create_door_resource(char *uri_path, char *type, iotcon_resource_interfaces_h ifaces, uint8_t policies, void *user_data) { RETVM_IF(NULL == user_data, false, "data is NULL"); @@ -943,22 +1056,24 @@ static iotcon_resource_h _create_door_resource(char *uri_path, char *type, iotcon_resource_types_h resource_types; ret = iotcon_resource_types_create(&resource_types); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_resource_types_create() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_resource_types_create() Fail(%s)", get_iotcon_error(ret)); return NULL; } ret = iotcon_resource_types_add(resource_types, type); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_resource_types_add() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_resource_types_add() Fail(%s)", get_iotcon_error(ret)); iotcon_resource_types_destroy(resource_types); return NULL; } /* register door resource */ - ret = iotcon_resource_create(uri_path, resource_types, ifaces, policies, - _request_handler, this, &handle); - if (IOTCON_ERROR_NONE != ret) { + ret = iotcon_resource_create(uri_path, resource_types, ifaces, policies, _request_handler, this, &handle); + if (IOTCON_ERROR_NONE != ret) + { ERR("iotcon_resource_create() Fail"); iotcon_resource_types_destroy(resource_types); return NULL; @@ -1003,7 +1118,7 @@ static void _iotcon_server_change_state_btn_pressed_cb(void *user_data, Evas_Obj ret = iotcon_resource_notify(door->handle, repr, door->observers, IOTCON_QOS_HIGH); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_resource_notify() Fail(%d)", ret); + ERR("iotcon_resource_notify() Fail(%s)", get_iotcon_error(ret)); iotcon_representation_destroy(repr); return; } @@ -1020,38 +1135,43 @@ static iotcon_representation_h _get_door_representation(door_resource_s *door) /* create a door Representation */ ret = iotcon_representation_create(&repr); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_representation_create() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_representation_create() Fail(%s)", get_iotcon_error(ret)); return NULL; } /* create a door attributes */ ret = iotcon_attributes_create(&attributes); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_attributes_create() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_attributes_create() Fail(%s)", get_iotcon_error(ret)); iotcon_representation_destroy(repr); return NULL; } ret = iotcon_representation_set_uri_path(repr, door->uri_path); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_representation_set_uri_path() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_representation_set_uri_path() Fail(%s)", get_iotcon_error(ret)); iotcon_attributes_destroy(attributes); iotcon_representation_destroy(repr); return NULL; } ret = iotcon_attributes_add_bool(attributes, "opened", door->attributes); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_attributes_add_bool() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_attributes_add_bool() Fail(%s)", get_iotcon_error(ret)); iotcon_attributes_destroy(attributes); iotcon_representation_destroy(repr); return NULL; } ret = iotcon_representation_set_attributes(repr, attributes); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_representation_set_attributes() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_representation_set_attributes() Fail(%s)", get_iotcon_error(ret)); iotcon_attributes_destroy(attributes); iotcon_representation_destroy(repr); return NULL; @@ -1078,13 +1198,15 @@ static int _set_door_representation(door_resource_s *door, iotcon_attributes_h attributes; ret = iotcon_representation_get_attributes(repr, &attributes); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_representation_get_attributes() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_representation_get_attributes() Fail(%s)", get_iotcon_error(ret)); return -1; } ret = iotcon_attributes_get_bool(attributes, "opened", &bval); - if (IOTCON_ERROR_NONE != ret) { + if (IOTCON_ERROR_NONE != ret) + { ERR("iotcon_attributes_get_bool() Fail(%d)", ret); return -1; } @@ -1097,7 +1219,6 @@ static int _set_door_representation(door_resource_s *door, static bool _query_cb(const char *key, const char *value, void *user_data) { DBG("key : %s, value : %s", key, value); - return IOTCON_FUNC_CONTINUE; } @@ -1121,16 +1242,18 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques RETM_IF(NULL == request, "request is NULL"); ret = iotcon_request_get_host_address(request, &host_address); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_request_get_host_address() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_request_get_host_address() Fail(%s)", get_iotcon_error(ret)); _send_response(request, NULL, IOTCON_RESPONSE_ERROR); return; } DBG("host_address : %s", host_address); ret = iotcon_request_get_query(request, &query); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_request_get_query() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_request_get_query() Fail(%s)", get_iotcon_error(ret)); _send_response(request, NULL, IOTCON_RESPONSE_ERROR); return; } @@ -1138,8 +1261,9 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques iotcon_query_foreach(query, _query_cb, NULL); ret = iotcon_request_get_request_type(request, &type); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_request_get_request_type() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_request_get_request_type() Fail(%s)", get_iotcon_error(ret)); _send_response(request, NULL, IOTCON_RESPONSE_ERROR); return; } @@ -1149,92 +1273,119 @@ static void _request_handler(iotcon_resource_h resource, iotcon_request_h reques if (IOTCON_REQUEST_GET == type) { ret = _request_handler_get(door, request); + if(ret == -1)return; str = format_string("%s", "GET"); - elm_list_item_append(this->info_list, str, NULL, NULL, NULL, NULL); +#ifdef USE_GENLIST + _iotcon_elm_genlist_item_append(this->info_list, str,NULL,NULL); +#else + elm_list_item_append(this->info_list, str, NULL, NULL, NULL, NULL); +#endif SAFE_DELETE(str); } else if (IOTCON_REQUEST_PUT == type) { ret = _request_handler_put(door, request); + if(ret == -1)return; str = format_string("%s", "PUT"); - elm_list_item_append(this->info_list, str, NULL, NULL, NULL, NULL); +#ifdef USE_GENLIST + _iotcon_elm_genlist_item_append(this->info_list, str,NULL,NULL); +#else + elm_list_item_append(this->info_list, str, NULL, NULL, NULL, NULL); +#endif SAFE_DELETE(str); } else if (IOTCON_REQUEST_POST == type) { - ret = _request_handler_post(door, request); + ret = _request_handler_post(door, request, this); + if(ret == -1)return; str = format_string("%s", "POST"); - elm_list_item_append(this->info_list, str, NULL, NULL, NULL, NULL); +#ifdef USE_GENLIST + _iotcon_elm_genlist_item_append(this->info_list, str,NULL,NULL); +#else + elm_list_item_append(this->info_list, str, NULL, NULL, NULL, NULL); +#endif SAFE_DELETE(str); } - else if (IOTCON_REQUEST_DELETE == type) { ret = _request_handler_delete(resource, request); + if(ret == -1)return; str = format_string("%s", "DELETE"); - elm_list_item_append(this->info_list, str, NULL, NULL, NULL, NULL); +#ifdef USE_GENLIST + _iotcon_elm_genlist_item_append(this->info_list, str,NULL,NULL); +#else + elm_list_item_append(this->info_list, str, NULL, NULL, NULL, NULL); +#endif SAFE_DELETE(str); elm_object_disabled_set(this->iotcon_btn, false); DBG("Delete Request get"); } - +#ifndef USE_GENLIST elm_list_go(this->info_list); -// evas_object_show(this->info_list); - - if (0 != ret) { +#endif + if (0 != ret) + { _send_response(request, NULL, IOTCON_RESPONSE_ERROR); return; } ret = iotcon_request_get_observe_type(request, &observe_type); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_request_get_observe_type() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_request_get_observe_type() Fail(%s)", get_iotcon_error(ret)); return; } - if (IOTCON_OBSERVE_REGISTER == observe_type) { + if (IOTCON_OBSERVE_REGISTER == observe_type) + { ret = iotcon_request_get_observe_id(request, &observe_id); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_request_get_observe_id() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_request_get_observe_id() Fail(%s)", get_iotcon_error(ret)); return; } ret = iotcon_observers_add(door->observers, observe_id); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_observers_add() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_observers_add() Fail(%s)", get_iotcon_error(ret)); return; } - } else if (IOTCON_OBSERVE_DEREGISTER == observe_type) { + } + else if (IOTCON_OBSERVE_DEREGISTER == observe_type) + { ret = iotcon_request_get_observe_id(request, &observe_id); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_request_get_observe_id() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_request_get_observe_id() Fail(%s)", get_iotcon_error(ret)); return; } ret = iotcon_observers_remove(door->observers, observe_id); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_observers_remove() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_observers_remove() Fail(%s)", get_iotcon_error(ret)); return; } } - } -static int _request_handler_delete(iotcon_resource_h resource, - iotcon_request_h request) +static int _request_handler_delete(iotcon_resource_h resource, iotcon_request_h request) { int ret; DBG("DELETE request"); ret = iotcon_resource_destroy(resource); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_resource_destroy() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_resource_destroy() Fail(%s)", get_iotcon_error(ret)); return -1; } ret = _send_response(request, NULL, IOTCON_RESPONSE_RESOURCE_DELETED); - if (0 != ret) { + if (0 != ret) + { ERR("_send_response() Fail(%d)", ret); return -1; } @@ -1243,22 +1394,28 @@ static int _request_handler_delete(iotcon_resource_h resource, } -static int _request_handler_post(door_resource_s *door, iotcon_request_h request) +static int _request_handler_post(door_resource_s *door, iotcon_request_h request, void* user_data) { int ret; iotcon_attributes_h resp_attributes; iotcon_representation_h resp_repr = NULL; iotcon_resource_h new_door_handle; DBG("POST request"); + RETVM_IF(NULL == user_data,-1, "data is NULL"); + iotcon_view *this = NULL; + this = (iotcon_view*)user_data; + RETVM_IF(NULL == this,-1, "view is NULL"); + - if (_resource_created) { + if (_resource_created) + { ERR("Resource(%s) is already created", DOOR_RESOURCE_URI2); return -1; } - new_door_handle = _create_door_resource(DOOR_RESOURCE_URI2, door->type, - door->ifaces, IOTCON_RESOURCE_SECURE, door); - if (NULL == new_door_handle) { + new_door_handle = _create_door_resource(DOOR_RESOURCE_URI2, door->type, door->ifaces, IOTCON_RESOURCE_SECURE, this); + if (NULL == new_door_handle) + { ERR("_create_door_resource() Fail"); return -1; } @@ -1267,28 +1424,31 @@ static int _request_handler_post(door_resource_s *door, iotcon_request_h request /* send information that new resource was created */ ret = iotcon_representation_create(&resp_repr); if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_representation_create() Fail(%d)", ret); + ERR("iotcon_representation_create() Fail(%s)", get_iotcon_error(ret)); return -1; } ret = iotcon_attributes_create(&resp_attributes); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_attributes_create() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_attributes_create() Fail(%s)", get_iotcon_error(ret)); iotcon_representation_destroy(resp_repr); return -1; } ret = iotcon_attributes_add_str(resp_attributes, "createduripath", DOOR_RESOURCE_URI2); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_attributes_add_str() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_attributes_add_str() Fail(%s)", get_iotcon_error(ret)); iotcon_attributes_destroy(resp_attributes); iotcon_representation_destroy(resp_repr); return -1; } ret = iotcon_representation_set_attributes(resp_repr, resp_attributes); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_representation_set_attributes() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_representation_set_attributes() Fail(%s)", get_iotcon_error(ret)); iotcon_attributes_destroy(resp_attributes); iotcon_representation_destroy(resp_repr); return -1; @@ -1297,8 +1457,9 @@ static int _request_handler_post(door_resource_s *door, iotcon_request_h request iotcon_attributes_destroy(resp_attributes); ret = _send_response(request, resp_repr, IOTCON_RESPONSE_RESOURCE_CREATED); - if (0 != ret) { - ERR("_send_response() Fail(%d)", ret); + if (0 != ret) + { + ERR("_send_response() Fail(%s)", get_iotcon_error(ret)); iotcon_representation_destroy(resp_repr); return -1; } @@ -1315,28 +1476,32 @@ static int _request_handler_put(door_resource_s *door, iotcon_request_h request) DBG("PUT request"); ret = iotcon_request_get_representation(request, &req_repr); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_request_get_representation() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_request_get_representation() Fail(%s)", get_iotcon_error(ret)); return -1; } ret = _set_door_representation(door, req_repr); - if (0 != ret) { - ERR("_set_door_representation() Fail(%d)", ret); + if (0 != ret) + { + ERR("_set_door_representation() Fail(%s)", get_iotcon_error(ret)); return -1; } _check_door_attributes(*door); resp_repr = _get_door_representation(door); - if (NULL == resp_repr) { + if (NULL == resp_repr) + { ERR("_get_door_representation() Fail"); return -1; } ret = _send_response(request, resp_repr, IOTCON_RESPONSE_OK); - if (0 != ret) { - ERR("_send_response() Fail(%d)", ret); + if (0 != ret) + { + ERR("_send_response() Fail(%s)", get_iotcon_error(ret)); iotcon_representation_destroy(resp_repr); return -1; } @@ -1344,7 +1509,7 @@ static int _request_handler_put(door_resource_s *door, iotcon_request_h request) /* notify */ ret = iotcon_resource_notify(door->handle, resp_repr, door->observers, IOTCON_QOS_HIGH); if (IOTCON_ERROR_NONE != ret) - ERR("iotcon_resource_notify() Fail(%d)", ret); + ERR("iotcon_resource_notify() Fail(%s)", get_iotcon_error(ret)); iotcon_representation_destroy(resp_repr); @@ -1359,14 +1524,16 @@ static int _request_handler_get(door_resource_s *door, iotcon_request_h request) DBG("GET request"); resp_repr = _get_door_representation(door); - if (NULL == resp_repr) { + if (NULL == resp_repr) + { ERR("_get_door_representation() Fail"); return -1; } ret = _send_response(request, resp_repr, IOTCON_RESPONSE_OK); - if (0 != ret) { - ERR("_send_response() Fail(%d)", ret); + if (0 != ret) + { + ERR("_send_response() Fail(%s)", get_iotcon_error(ret)); iotcon_representation_destroy(resp_repr); return -1; } @@ -1383,35 +1550,38 @@ static int _send_response(iotcon_request_h request, iotcon_representation_h repr iotcon_response_h response; ret = iotcon_response_create(request, &response); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_response_create() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_response_create() Fail(%s)", get_iotcon_error(ret)); return -1; } ret = iotcon_response_set_result(response, result); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_response_set_result() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_response_set_result() Fail(%s)", get_iotcon_error(ret)); iotcon_response_destroy(response); return -1; } ret = iotcon_response_set_representation(response, repr); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_response_set_representation() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_response_set_representation() Fail(%s)", get_iotcon_error(ret)); iotcon_response_destroy(response); return -1; } /* send Representation to the client */ ret = iotcon_response_send(response); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_response_send() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_response_send() Fail(%s)", get_iotcon_error(ret)); iotcon_response_destroy(response); return -1; } iotcon_response_destroy(response); - return 0; } @@ -1422,29 +1592,33 @@ static int _set_door_resource(door_resource_s *door) door->attributes = false; door->uri_path = strdup(DOOR_RESOURCE_URI); - if (NULL == door->uri_path) { + if (NULL == door->uri_path) + { ERR("strdup(%s) Fail", DOOR_RESOURCE_URI); return -1; } door->type = strdup(DOOR_RESOURCE_TYPE); - if (NULL == door->type) { + if (NULL == door->type) + { ERR("strdup(%s) Fail", DOOR_RESOURCE_TYPE); SAFE_DELETE(door->uri_path); return -1; } ret = iotcon_resource_interfaces_create(&door->ifaces); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_resource_interfaces_create() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_resource_interfaces_create() Fail(%s)", get_iotcon_error(ret)); SAFE_DELETE(door->type); SAFE_DELETE(door->uri_path); return ret; } ret = iotcon_resource_interfaces_add(door->ifaces, IOTCON_INTERFACE_DEFAULT); - if (IOTCON_ERROR_NONE != ret) { - ERR("iotcon_resource_interfaces_add() Fail(%d)", ret); + if (IOTCON_ERROR_NONE != ret) + { + ERR("iotcon_resource_interfaces_add() Fail(%s)", get_iotcon_error(ret)); iotcon_resource_interfaces_destroy(door->ifaces); SAFE_DELETE(door->type); SAFE_DELETE(door->uri_path); @@ -1455,7 +1629,8 @@ static int _set_door_resource(door_resource_s *door) | IOTCON_RESOURCE_SECURE; ret = iotcon_observers_create(&door->observers); - if (IOTCON_ERROR_NONE != ret) { + if (IOTCON_ERROR_NONE != ret) + { ERR("iotcon_observers_create() Fail"); iotcon_resource_interfaces_destroy(door->ifaces); SAFE_DELETE(door->type); @@ -1471,7 +1646,8 @@ static char* get_iotcon_error(iotcon_error_e err) { char* err_msg; - switch (err) { + switch (err) + { case IOTCON_ERROR_NONE: err_msg = "IOTCON_ERROR_NONE"; break;