From: Nibha Sharma Date: Fri, 3 Jun 2016 06:04:22 +0000 (+0900) Subject: [TBT][Runtime-info][DPTTIZEN-1952][Scenario No. 6,Added Vibrate,bluetooth,Location... X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F27%2F72927%2F3;p=test%2Ftct%2Fnative%2Fbehavior.git [TBT][Runtime-info][DPTTIZEN-1952][Scenario No. 6,Added Vibrate,bluetooth,Location,USB,GPS,AutoRotate,Location,Wifi Check,Number 4 storage,number 5 radio scenarios are added] Change-Id: I52bb7e3475c5b429b48eca0ca6b9dc6e487423cf Signed-off-by: Nibha Sharma --- diff --git a/tbtcoreapp/inc/model/tbt-info.h b/tbtcoreapp/inc/model/tbt-info.h index 7e59344..5a64272 100644 --- a/tbtcoreapp/inc/model/tbt-info.h +++ b/tbtcoreapp/inc/model/tbt-info.h @@ -178,7 +178,11 @@ typedef enum { TBT_APP_MTP, - TBT_APP_NSD_DNS_SD + TBT_APP_NSD_DNS_SD, + + TBT_APP_STORAGE, + + TBT_APP_RADIO } tbt_app_type_e; diff --git a/tbtcoreapp/inc/utils/app_module_config.h b/tbtcoreapp/inc/utils/app_module_config.h index 47148db..f7a9126 100644 --- a/tbtcoreapp/inc/utils/app_module_config.h +++ b/tbtcoreapp/inc/utils/app_module_config.h @@ -172,5 +172,10 @@ //#define TBT_MODULE_NSD //#define TBT_MODULE_APP_NSD_DNS_SD +#define TBT_MODULE_STORAGE +#define TBT_MODULE_APP_STORAGE + +#define TBT_MODULE_RADIO +#define TBT_MODULE_APP_RADIO #endif diff --git a/tbtcoreapp/inc/utils/config.h b/tbtcoreapp/inc/utils/config.h index 2438e8f..28ce17d 100644 --- a/tbtcoreapp/inc/utils/config.h +++ b/tbtcoreapp/inc/utils/config.h @@ -248,7 +248,7 @@ char file_path[MAX_LENGTH] = {'\0'}; #ifdef TIZEN_3_0 #ifdef DEVICE_TYPE_MOBILE - strncat(file_path, "edje/2.4/mobile/", sizeof("edje/2.4/mobile/")); + strncat(file_path, "edje/3.0/mobile/", sizeof("edje/3.0/mobile/")); #endif #ifdef DEVICE_TYPE_WEARABLE if(get_device_type() == DEVICE_WEARABLE) diff --git a/tbtcoreapp/inc/view/tbt-radio-view.h b/tbtcoreapp/inc/view/tbt-radio-view.h new file mode 100644 index 0000000..a1ba8d8 --- /dev/null +++ b/tbtcoreapp/inc/view/tbt-radio-view.h @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *******************************************************************************/ +/** + * @file tbt-radio-view.h + * @brief retrieves radio info + * @since_tizen 3.0 + * @author Nibha Sharma(nibha.sharma@samsung.com) + * @date June, 2016 + * @bug none + * @credit + * @credit + * + */ + +#ifndef __TBT_RADIO_VIEW_H__ +#define __TBT_RADIO_VIEW_H__ + +#include "utils/app_module_config.h" +#ifdef TBT_MODULE_RADIO + +#include +#include "model/tbt-list.h" +#include + + +/** + * @typedef radio_viewer_view + * @since_tizen 3.0 + * @brief A radio viewer view handle. + */ +typedef struct _radio_view radio_view; + +/** + * @brief Create radio view + * @since_tizen 3.0 + * @param[in] navi Parent naviframe + * @param[in] custom structute to hold tbt application information + * @param[in] item of the main tbt menu + * @return Pointer of radio on success, otherwise NULL + */ +radio_view *radio_view_add(Evas_Object *navi, tbt_info *tbt_info, Elm_Object_Item *item); + +#endif +#endif // __TBT_RADIO_VIEW_H__ diff --git a/tbtcoreapp/inc/view/tbt-storage-view.h b/tbtcoreapp/inc/view/tbt-storage-view.h new file mode 100644 index 0000000..421235a --- /dev/null +++ b/tbtcoreapp/inc/view/tbt-storage-view.h @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *******************************************************************************/ +/** + * @file tbt-storage-view.h + * @brief retrieves runtime info + * @since_tizen 3.0 + * @author Nibha Sharma(nibha.sharma@samsung.com) + * @date June, 2016 + * @bug none + * @credit + * @credit + * + */ + +#ifndef __TBT_STORAGE_VIEW_H__ +#define __TBT_STORAGE_VIEW_H__ + +#include "utils/app_module_config.h" +#ifdef TBT_MODULE_STORAGE + +#include +#include "model/tbt-list.h" +#include + + +/** + * @typedef storage_viewer_view + * @since_tizen 3.0 + * @brief A storage viewer view handle. + */ +typedef struct _storage_view storage_view; + +/** + * @brief Create storage view + * @since_tizen 3.0 + * @param[in] navi Parent naviframe + * @param[in] custom structute to hold tbt application information + * @param[in] item of the main tbt menu + * @return Pointer of storage on success, otherwise NULL + */ +storage_view *storage_view_add(Evas_Object *navi, tbt_info *tbt_info, Elm_Object_Item *item); + +#endif +#endif // __TBT_STORAGE_VIEW_H__ diff --git a/tbtcoreapp/res/edje/3.0/mobile/radio_viewer.edc b/tbtcoreapp/res/edje/3.0/mobile/radio_viewer.edc new file mode 100644 index 0000000..e232dec --- /dev/null +++ b/tbtcoreapp/res/edje/3.0/mobile/radio_viewer.edc @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define TEXT_HEIGHT 0.08 + +collections +{ + base_scale: 1.8; + group + { + name: "radio_viewer"; + parts{ + part{ + name: "radio_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; } + } + } + } + } +} diff --git a/tbtcoreapp/res/edje/3.0/mobile/runtimeinfo_viewer.edc b/tbtcoreapp/res/edje/3.0/mobile/runtimeinfo_viewer.edc index 4beb863..d460c89 100644 --- a/tbtcoreapp/res/edje/3.0/mobile/runtimeinfo_viewer.edc +++ b/tbtcoreapp/res/edje/3.0/mobile/runtimeinfo_viewer.edc @@ -14,7 +14,7 @@ * limitations under the License. */ -#define TEXT_HEIGHT 1.0 +#define TEXT_HEIGHT 0.08 collections { @@ -30,11 +30,100 @@ collections state: "default" 0.0; align: 0.0 0.0; visible: 1; - rel1 {relative: 0.02 0.0; } - rel2 {relative: 0.98 TEXT_HEIGHT; } + rel1 {relative: 0.0 0.0; } + rel2 {relative: 1.0 TEXT_HEIGHT; } + } + } + part{ + name: "vibrate_text"; + type: SWALLOW; + description{ + state: "default" 0.0; + align: 0.0 0.0; + visible: 1; + rel1 {relative: 0.0 TEXT_HEIGHT; } + rel2 {relative: 1.0 2*TEXT_HEIGHT; } } } + part{ + name: "battery_text"; + type: SWALLOW; + description{ + state: "default" 0.0; + align: 0.0 0.0; + visible: 1; + rel1 {relative: 0.0 2*TEXT_HEIGHT; } + rel2 {relative: 1.0 3*TEXT_HEIGHT; } + } + } + + part{ + name: "gps_text"; + type: SWALLOW; + description{ + state: "default" 0.0; + align: 0.0 0.0; + visible: 1; + rel1 {relative: 0.0 3*TEXT_HEIGHT; } + rel2 {relative: 1.0 4*TEXT_HEIGHT; } + } + } + part{ + name: "usb_text"; + type: SWALLOW; + description{ + state: "default" 0.0; + align: 0.0 0.0; + visible: 1; + rel1 {relative: 0.0 4*TEXT_HEIGHT; } + rel2 {relative: 1.0 5*TEXT_HEIGHT; } + } + } + part{ + name: "bluetooth_text"; + type: SWALLOW; + description{ + state: "default" 0.0; + align: 0.0 0.0; + visible: 1; + rel1 {relative: 0.0 5*TEXT_HEIGHT; } + rel2 {relative: 1.0 6*TEXT_HEIGHT; } + } + } + part{ + name: "rotate_text"; + type: SWALLOW; + description{ + state: "default" 0.0; + align: 0.0 0.0; + visible: 1; + rel1 {relative: 0.0 6*TEXT_HEIGHT; } + rel2 {relative: 1.0 7*TEXT_HEIGHT; } + } + } + part{ + name: "location_text"; + type: SWALLOW; + description{ + state: "default" 0.0; + align: 0.0 0.0; + visible: 1; + rel1 {relative: 0.0 7*TEXT_HEIGHT; } + rel2 {relative: 1.0 8*TEXT_HEIGHT; } + } + } + part{ + name: "wifi_text"; + type: SWALLOW; + description{ + state: "default" 0.0; + align: 0.0 0.0; + visible: 1; + rel1 {relative: 0.0 8*TEXT_HEIGHT; } + rel2 {relative: 1.0 9*TEXT_HEIGHT; } + } + } } } } diff --git a/tbtcoreapp/res/edje/3.0/mobile/storage_viewer.edc b/tbtcoreapp/res/edje/3.0/mobile/storage_viewer.edc new file mode 100644 index 0000000..e626ed7 --- /dev/null +++ b/tbtcoreapp/res/edje/3.0/mobile/storage_viewer.edc @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define TEXT_HEIGHT 0.08 + +collections +{ + base_scale: 1.8; + group + { + name: "storage_viewer"; + parts{ + part{ + name: "info_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; } + } + } + } + } +} diff --git a/tbtcoreapp/src/model/tbt-list.c b/tbtcoreapp/src/model/tbt-list.c index 7174f31..4f72367 100644 --- a/tbtcoreapp/src/model/tbt-list.c +++ b/tbtcoreapp/src/model/tbt-list.c @@ -1392,7 +1392,7 @@ static tbt_info tbtapps[] = .parent = "Runtime Info", .apptype = TBT_APP_RUNTIME_INFO, .icon_name = "dummy", - .info = "View Audio Jack
Insert Info", + .info = "Change status of All functionality
Mentioned above", .result = 0 }, #endif @@ -1470,6 +1470,36 @@ static tbt_info tbtapps[] = .icon_name = "dummy", .info = "Check NSD DNS-SD
", .result = 0 + }, + #endif +#endif +#ifdef TBT_MODULE_STORAGE + #ifdef TBT_MODULE_APP_STORAGE + + //Storage + { + .name = "SD-Card", + .parent = "Storage", + .apptype = TBT_APP_STORAGE, + .icon_name = "dummy", + .info = "Check Sd-Card
", + .result = 0 + }, + #endif +#endif +#ifdef TBT_MODULE_RADIO + #ifdef TBT_MODULE_APP_RADIO + + //RADIO + { + .name = "Radio", + .parent = "Radio", + .apptype = TBT_APP_RADIO, + .icon_name = "dummy", + .info = "Check Earphone", + .result = 0, + .required_features_count = 1, + .features_required = {6} } #endif #endif diff --git a/tbtcoreapp/src/view/tbt-genlist-view.c b/tbtcoreapp/src/view/tbt-genlist-view.c index 1ba3121..b5393dd 100644 --- a/tbtcoreapp/src/view/tbt-genlist-view.c +++ b/tbtcoreapp/src/view/tbt-genlist-view.c @@ -82,6 +82,8 @@ #include "view/tbt-attachpanel-view.h" #include "view/tbt-mtp-view.h" #include "view/tbt-nsd-dns-sd-view.h" +#include "view/tbt-storage-view.h" +#include "view/tbt-radio-view.h" typedef struct { @@ -98,6 +100,7 @@ typedef struct }item_data; static Elm_Object_Item *group_item_array[100]; static int group_item_count = 0; +int g_count = 0; static void tbt_genlist_view_fill(genlist_view *view); @@ -112,7 +115,6 @@ static void _gl_contracted_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUS static void _gl_longpressed_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info); static void _gl_group_selected_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info); - /** * @function tbt_genlist_view_create * @since_tizen 2.3 @@ -951,7 +953,16 @@ static void _gl_item_selected_cb(void *data, Evas_Object *obj EINA_UNUSED, void break; #endif - + #ifdef TBT_MODULE_STORAGE + case TBT_APP_STORAGE: + storage_view_add(view->navi, info, it); + break; + #endif + #ifdef TBT_MODULE_RADIO + case TBT_APP_RADIO: + radio_view_add(view->navi, info, it); + break; + #endif default: diff --git a/tbtcoreapp/src/view/tbt-radio-view.c b/tbtcoreapp/src/view/tbt-radio-view.c new file mode 100644 index 0000000..d117f55 --- /dev/null +++ b/tbtcoreapp/src/view/tbt-radio-view.c @@ -0,0 +1,235 @@ +/******************************************************************************* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *******************************************************************************/ +/** + * @file tbt-radio-view.c + * @brief retrieves radio info + * + * @author Nibha Sharma(nibha.sharma@samsung.com) + * @date June, 2016 + * @bug none + * @credit + * + */ +#include "utils/app_module_config.h" +#ifdef TBT_MODULE_RADIO + +#include +#include + +#include "utils/logger.h" +#include "utils/config.h" +#include "utils/ui-utils.h" +#include "view/tbt-radio-view.h" +#include "view/tbt-common-view.h" + +struct _radio_view +{ + common_view* view; + + Evas_Object *radio_label; +}; + +static void _app_destroy_cb(void* this); +static void _radio_interrupted_cb(radio_interrupted_code_e code, void *user_data); + +radio_h g_pstRadio; +bool is_not_supported = false; + +/** + * @function get_radio_type_error + * @since_tizen 3.0 + * @description Get radio Error + * @parameter int: Int + * @return char* + */ +char* get_radio_type_error(int ret) +{ + char* err_msg = NULL; + switch (ret) { + case RADIO_ERROR_NONE: + err_msg = "RADIO_ERROR_NONE"; + break; + case RADIO_ERROR_INVALID_PARAMETER: + err_msg = "RADIO_ERROR_INVALID_PARAMETER"; + break; + case RADIO_ERROR_INVALID_OPERATION: + err_msg = "RADIO_ERROR_INVALID_OPERATION"; + break; + case RADIO_ERROR_OUT_OF_MEMORY: + err_msg = "RADIO_ERROR_OUT_OF_MEMORY"; + break; + case RADIO_ERROR_INVALID_STATE: + err_msg = "RADIO_ERROR_INVALID_STATE"; + break; + case RADIO_ERROR_SOUND_POLICY: + err_msg = "RADIO_ERROR_SOUND_POLICY"; + break; + default: + err_msg = "Unknown Error"; + break; + } + + return err_msg; +} + +/** + * @function radio_view_add + * @since_tizen 3.0 + * @description Radio View Add + * @parameter Evas_Object*: Evas Object Pointer, tbt_info*: Tbt Info Pointer, Elm_Object_Item*: Elm Object Item Pointer + * @return radio_view* + */ +radio_view *radio_view_add(Evas_Object *navi, tbt_info *tbt_info, Elm_Object_Item *item) +{ + RETVM_IF(NULL == navi, NULL, "navi is null"); + int ret; + radio_view *this = NULL; + this = calloc(1, sizeof(radio_view)); + RETVM_IF(!this, NULL, "calloc failed"); + + + this->view = calloc(1, sizeof(common_view)); + RETVM_IF(!this->view, NULL, "calloc failed"); + + tbt_info->layout_group = "radio_viewer"; + tbt_info->layout_file = get_edje_path("radio_viewer.edj"); + + common_view_add(navi, tbt_info, item, this->view, _app_destroy_cb, this); + RETVM_IF(NULL == this->view, NULL, "navi is null"); + + ret = radio_create(&g_pstRadio); + RETVM_IF(ret != RADIO_ERROR_NONE && ret != RADIO_ERROR_NOT_SUPPORTED, NULL, "radio_create failed : %s", get_radio_type_error(ret)); + + ret = radio_start(g_pstRadio); + RETVM_IF(ret != RADIO_ERROR_NONE && ret != RADIO_ERROR_NOT_SUPPORTED, NULL, "radio_start failed : %s", get_radio_type_error(ret)); + + ret = radio_set_interrupted_cb(g_pstRadio,_radio_interrupted_cb, this); + RETVM_IF(ret != RADIO_ERROR_NONE && ret != RADIO_ERROR_NOT_SUPPORTED, NULL, "radio_set_interrupted_cb failed : %s", get_radio_type_error(ret)); + + this->radio_label = ui_utils_label_add(this->view->layout, "Latitude: "); + elm_label_line_wrap_set(this->radio_label, ELM_WRAP_WORD); + + if(ret == RADIO_ERROR_NOT_SUPPORTED) + { + is_not_supported = true; + Evas_Object *popup = ui_utils_popup_add(this->view->navi, "Message"); + elm_object_text_set(popup, "Radio is not supported"); + RETVM_IF(!this->view, NULL,"Radio is not supported"); + } + + radio_state_e estate; + ret = radio_get_state (g_pstRadio, &estate); + RETVM_IF(ret != RADIO_ERROR_NONE && ret != RADIO_ERROR_NOT_SUPPORTED, NULL, "radio_set_interrupted_cb failed : %s", get_radio_type_error(ret)); + + if(estate == RADIO_STATE_PLAYING) + { + ui_utils_label_set_text(this->radio_label, "RADIO is Playing", "left"); + } + + elm_object_part_content_set(this->view->layout, "radio_text", this->radio_label); + + return this; +} + + +/** + * @function _app_destroy_cb + * @since_tizen 2.3 + * @description App Destroy Cb + * @parameter void*: Void Pointer + * @return static void + */ +static void _app_destroy_cb(void* this) +{ + + RETM_IF(NULL == this, "data is NULL"); + + int result; + radio_view *view = NULL; + view = (radio_view*)this; + RETM_IF(NULL == view, "view is NULL"); + + if(is_not_supported == true) + { + view->view->tbt_info->result = TBT_INFO_RESULT_NOT_SUPPORTED; + elm_genlist_item_update(view->view->item); + } + + result = radio_unset_interrupted_cb(g_pstRadio); + RETM_IF(result != RADIO_ERROR_NONE, "radio_unset_interrupted_cb fail > Error = %s", get_radio_type_error(result)); + + result = radio_stop(g_pstRadio); + RETM_IF(result != RADIO_ERROR_NONE, "radio_stop fail > Error = %s", get_radio_type_error(result)); + + result = radio_destroy(g_pstRadio); + RETM_IF(result != RADIO_ERROR_NONE, "radio_destroy fail > Error = %s", get_radio_type_error(result)); + + SAFE_DELETE(view->view); + SAFE_DELETE(view); +} + + +/** + * @function _radio_interrupted_cb + * @since_tizen 3.0 + * @description radio interrupted Cb + * @parameter radio_interrupted_code_e code, void *user_data + * @return void + */ +static void _radio_interrupted_cb(radio_interrupted_code_e code, void *user_data) +{ + + RETM_IF(NULL == user_data, "user_data is null"); + radio_view *this = NULL; + this = (radio_view*) user_data; + RETM_IF(NULL == this, "view is NULL"); + + DBG("value: %d", code); + + switch (code) + { + case RADIO_INTERRUPTED_COMPLETED: + ui_utils_label_set_text(this->radio_label, "Interrupt completed", "left"); + break; + case RADIO_INTERRUPTED_BY_MEDIA: + ui_utils_label_set_text(this->radio_label, "Interrupted by a non-resumable media application", "left"); + break; + case RADIO_INTERRUPTED_BY_CALL: + ui_utils_label_set_text(this->radio_label, "Interrupted by an incoming call", "left"); + break; + case RADIO_INTERRUPTED_BY_EARJACK_UNPLUG : + ui_utils_label_set_text(this->radio_label, "Interrupted by unplugging headphones", "left"); + break; + case RADIO_INTERRUPTED_BY_RESOURCE_CONFLICT : + ui_utils_label_set_text(this->radio_label, "Interrupted by a resource conflict", "left"); + break; + case RADIO_INTERRUPTED_BY_ALARM : + ui_utils_label_set_text(this->radio_label, "Interrupted by an alarm", "left"); + break; + case RADIO_INTERRUPTED_BY_EMERGENCY : + ui_utils_label_set_text(this->radio_label, "Interrupted by a resumable media application", "left"); + break; + case RADIO_INTERRUPTED_BY_NOTIFICATION : + ui_utils_label_set_text(this->radio_label, "Interrupted by a notification", "left"); + break; + default: + ui_utils_label_set_text(this->radio_label, "unknown state", "left"); + break; + } + return ; +} + +#endif diff --git a/tbtcoreapp/src/view/tbt-runtimeinfo-view.c b/tbtcoreapp/src/view/tbt-runtimeinfo-view.c index dd27f9f..64634ae 100644 --- a/tbtcoreapp/src/view/tbt-runtimeinfo-view.c +++ b/tbtcoreapp/src/view/tbt-runtimeinfo-view.c @@ -40,11 +40,36 @@ struct _runtimeinfo_view common_view* view; Evas_Object *info_label; + Evas_Object *vibrate_label; + Evas_Object *battery_label; + Evas_Object *gps_label; + Evas_Object *usb_label; + Evas_Object *bluetooth_label; + Evas_Object *rotate_label; + Evas_Object *location_label; + Evas_Object *wifi_label; }; static void _app_destroy_cb(void* this); void _runtime_info_changed_cb(runtime_info_key_e key, void *user_data); - +static void _vibrate_state_changed_cb(runtime_info_key_e key, void *user_data); +static void _battery_state_changed_cb(runtime_info_key_e key, void *user_data); +static void _usb_state_changed_cb(runtime_info_key_e key, void *user_data); +static void _gps_state_changed_cb(runtime_info_key_e key, void *user_data); +static void _bluetooth_state_changed_cb(runtime_info_key_e key, void *user_data); +static void _rotate_state_changed_cb(runtime_info_key_e key, void *user_data); +static void _location_state_changed_cb(runtime_info_key_e key, void *user_data); +static void _wifi_state_changed_cb(runtime_info_key_e key, void *user_data); + +static bool is_audiojack_not_supported = false; +static bool is_gps_not_supported = false; +static bool is_bluetooth_not_supported = false; +static bool is_vibrate_not_supported = false; +static bool is_battery_not_supported = false; +static bool is_usb_not_supported = false; +static bool is_autorotate_not_supported = false; +static bool is_location_not_supported = false; +static bool is_wifi_not_supported = false; /** * @function get_runtime_info_error @@ -104,18 +129,18 @@ runtimeinfo_view *runtimeinfo_view_add(Evas_Object *navi, tbt_info *tbt_info, El { RETVM_IF(NULL == navi, NULL, "navi is null"); int ret, value; - runtimeinfo_view *this = NULL; - this = calloc(1, sizeof(runtimeinfo_view)); - RETVM_IF(!this, NULL, "calloc failed"); + runtimeinfo_view *this = NULL; + this = calloc(1, sizeof(runtimeinfo_view)); + RETVM_IF(!this, NULL, "calloc failed"); - this->view = calloc(1, sizeof(common_view)); - RETVM_IF(!this->view, NULL, "calloc failed"); + this->view = calloc(1, sizeof(common_view)); + RETVM_IF(!this->view, NULL, "calloc failed"); - tbt_info->layout_group = "runtimeinfo_viewer"; - tbt_info->layout_file = get_edje_path("runtimeinfo_viewer.edj"); + tbt_info->layout_group = "runtimeinfo_viewer"; + tbt_info->layout_file = get_edje_path("runtimeinfo_viewer.edj"); - common_view_add(navi, tbt_info, item, this->view, _app_destroy_cb, this); + common_view_add(navi, tbt_info, item, this->view, _app_destroy_cb, this); RETVM_IF(NULL == this->view, NULL, "navi is null"); ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, _runtime_info_changed_cb, this); @@ -126,44 +151,430 @@ runtimeinfo_view *runtimeinfo_view_add(Evas_Object *navi, tbt_info *tbt_info, El if(ret == RUNTIME_INFO_ERROR_NOT_SUPPORTED) { + is_audiojack_not_supported = true; ui_utils_label_set_text(this->info_label, "Audio Jack is not supported", "left"); elm_object_part_content_set(this->view->layout, "info_text", this->info_label); - return this; + } + else + { + ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, &value); + RETVM_IF(ret != RUNTIME_INFO_ERROR_NONE && ret != RUNTIME_INFO_ERROR_NOT_SUPPORTED, NULL, "runtime_info_get_value_int failed: %s",get_runtime_info_error(ret)); + if(ret == RUNTIME_INFO_ERROR_NOT_SUPPORTED) + { + is_audiojack_not_supported = true; + ui_utils_label_set_text(this->info_label, "Audio Jack is not supported", "left"); + elm_object_part_content_set(this->view->layout, "info_text", this->info_label); + } + else + { + DBG("value: %d", value); + switch(value) + { + case 0: + ui_utils_label_set_text(this->info_label, "Audio Jack Not connected", "left"); + break; + + case 1: + ui_utils_label_set_text(this->info_label, "Audio Jack Connected with 3 wire earjack", "left"); + break; + + case 2: + ui_utils_label_set_text(this->info_label, "Audio Jack Connected with 4 wire earjack", "left"); + break; + + default: + ui_utils_label_set_text(this->info_label, "Unknown status", "left"); + break; + + } + } } - ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_AUDIO_JACK_STATUS, &value); - RETVM_IF(ret != RUNTIME_INFO_ERROR_NONE && ret != RUNTIME_INFO_ERROR_NOT_SUPPORTED, NULL, "runtime_info_get_value_int failed: %s",get_runtime_info_error(ret)); + bool bvalue; + + ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_VIBRATION_ENABLED, _vibrate_state_changed_cb, this); + RETVM_IF(ret != RUNTIME_INFO_ERROR_NONE && ret != RUNTIME_INFO_ERROR_NOT_SUPPORTED, NULL, "runtime_info_set_changed_cb failed : %s", get_runtime_info_error(ret)); + + this->vibrate_label = ui_utils_label_add(this->view->layout, "Longitude: "); + elm_label_line_wrap_set(this->vibrate_label, ELM_WRAP_WORD); + if(ret == RUNTIME_INFO_ERROR_NOT_SUPPORTED) { - ui_utils_label_set_text(this->info_label, "Audio Jack is not supported", "left"); - elm_object_part_content_set(this->view->layout, "info_text", this->info_label); - return this; + is_vibrate_not_supported = true; + ui_utils_label_set_text(this->vibrate_label, "Vibration Mode is not supported", "left"); + elm_object_part_content_set(this->view->layout, "vibrate_text", this->vibrate_label); + } + else + { + ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_VIBRATION_ENABLED, &bvalue); + RETVM_IF(ret != RUNTIME_INFO_ERROR_NONE && ret != RUNTIME_INFO_ERROR_NOT_SUPPORTED, NULL, "runtime_info_get_value_int failed: %s",get_runtime_info_error(ret)); + if(ret == RUNTIME_INFO_ERROR_NOT_SUPPORTED) + { + is_vibrate_not_supported = true; + ui_utils_label_set_text(this->vibrate_label, "Vibration Mode is not supported", "left"); + elm_object_part_content_set(this->view->layout, "vibrate_text", this->vibrate_label); + } + else + { + DBG("value: %d", bvalue); + + switch(bvalue) + { + case 0: + ui_utils_label_set_text(this->vibrate_label, "Vibrate Mode is Not Enabled", "left"); + break; + + case 1: + ui_utils_label_set_text(this->vibrate_label, "Vibrate Mode is Enabled", "left"); + break; + } + } } - DBG("value: %d", value); + ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_BATTERY_IS_CHARGING, _battery_state_changed_cb, this); + RETVM_IF(ret != RUNTIME_INFO_ERROR_NONE && ret != RUNTIME_INFO_ERROR_NOT_SUPPORTED, NULL, "runtime_info_set_changed_cb failed : %s", get_runtime_info_error(ret)); -switch(value) -{ - case 0: - ui_utils_label_set_text(this->info_label, "Audio Jack Not connected", "left"); - break; + this->battery_label = ui_utils_label_add(this->view->layout, "Percentage: "); + elm_label_line_wrap_set(this->battery_label, ELM_WRAP_WORD); - case 1: - ui_utils_label_set_text(this->info_label, "Audio Jack Connected with 3 wire earjack", "left"); - break; + if(ret == RUNTIME_INFO_ERROR_NOT_SUPPORTED) + { + is_battery_not_supported = true; + ui_utils_label_set_text(this->battery_label, "Battery Charging is not supported", "left"); + elm_object_part_content_set(this->view->layout, "battery_text", this->battery_label); + } + else + { + ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_BATTERY_IS_CHARGING, &bvalue); + RETVM_IF(ret != RUNTIME_INFO_ERROR_NONE && ret != RUNTIME_INFO_ERROR_NOT_SUPPORTED, NULL, "runtime_info_get_value_int failed: %s",get_runtime_info_error(ret)); + if(ret == RUNTIME_INFO_ERROR_NOT_SUPPORTED) + { + is_battery_not_supported = true; + ui_utils_label_set_text(this->battery_label, "Battery Charging is not supported", "left"); + elm_object_part_content_set(this->view->layout, "battery_text", this->battery_label); + } + else + { + DBG("value: %d", bvalue); + switch(bvalue) + { + case 0: + ui_utils_label_set_text(this->battery_label, " Battery Not Charging", "left"); + break; + + case 1: + ui_utils_label_set_text(this->battery_label, "Battery Charging Started", "left"); + break; + } + } + } - case 2: - ui_utils_label_set_text(this->info_label, "Audio Jack Connected with 4 wire earjack", "left"); - break; + bool is_gps_supported = does_feature_exist("tizen.org/feature/location.gps"); + if(is_gps_supported == false) + { + is_gps_not_supported = true; + ui_utils_label_set_text(this->gps_label, "Feature:location.gps is not supported", "left"); + elm_object_part_content_set(this->view->layout, "gps_text", this->gps_label); + } + else + { - default: - ui_utils_label_set_text(this->info_label, "Unknown status", "left"); - break; + ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_GPS_STATUS , _gps_state_changed_cb, this); + RETVM_IF(ret != RUNTIME_INFO_ERROR_NONE && ret != RUNTIME_INFO_ERROR_NOT_SUPPORTED, NULL, "runtime_info_set_changed_cb failed : %s", get_runtime_info_error(ret)); + + this->gps_label = ui_utils_label_add(this->view->layout, "GPS: "); + elm_label_line_wrap_set(this->gps_label, ELM_WRAP_WORD); + if(ret == RUNTIME_INFO_ERROR_NOT_SUPPORTED) + { + is_gps_not_supported = true; + ui_utils_label_set_text(this->gps_label, "GPS is not supported", "left"); + elm_object_part_content_set(this->view->layout, "gps_text", this->gps_label); + } + else + { + + ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_GPS_STATUS , &value); + RETVM_IF(ret != RUNTIME_INFO_ERROR_NONE && ret != RUNTIME_INFO_ERROR_NOT_SUPPORTED, NULL, "runtime_info_get_value_int failed: %s",get_runtime_info_error(ret)); + if(ret == RUNTIME_INFO_ERROR_NOT_SUPPORTED) + { + is_gps_not_supported = true; + ui_utils_label_set_text(this->gps_label, "GPS is not supported", "left"); + elm_object_part_content_set(this->view->layout, "gps_text", this->gps_label); + } + else + { + DBG("value: %d", value); + switch(value) + { + case 0: + ui_utils_label_set_text(this->gps_label, "GPS is disabled", "left"); + break; + + case 1: + ui_utils_label_set_text(this->gps_label, "GPS is searching for satellites", "left"); + break; + + case 2: + ui_utils_label_set_text(this->gps_label, "GPS connection is established", "left"); + break; + + default: + ui_utils_label_set_text(this->gps_label, "Unknown status", "left"); + break; + + } + } } + } + + ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_USB_CONNECTED , _usb_state_changed_cb, this); + RETVM_IF(ret != RUNTIME_INFO_ERROR_NONE && ret != RUNTIME_INFO_ERROR_NOT_SUPPORTED, NULL, "runtime_info_set_changed_cb failed : %s", get_runtime_info_error(ret)); + this->usb_label = ui_utils_label_add(this->view->layout, "usb: "); + elm_label_line_wrap_set(this->usb_label, ELM_WRAP_WORD); + + if(ret == RUNTIME_INFO_ERROR_NOT_SUPPORTED) + { + + is_usb_not_supported = true; + ui_utils_label_set_text(this->usb_label, "USB is not supported", "left"); + elm_object_part_content_set(this->view->layout, "usb_text", this->usb_label); + } + else + { + ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_USB_CONNECTED , &bvalue); + RETVM_IF(ret != RUNTIME_INFO_ERROR_NONE && ret != RUNTIME_INFO_ERROR_NOT_SUPPORTED, NULL, "runtime_info_get_value_int failed: %s",get_runtime_info_error(ret)); + if(ret == RUNTIME_INFO_ERROR_NOT_SUPPORTED) + { + is_usb_not_supported = true; + ui_utils_label_set_text(this->usb_label, "USB is not supported", "left"); + elm_object_part_content_set(this->view->layout, "usb_text", this->usb_label); + } + else + { + DBG("value: %d", bvalue); + + switch(bvalue) + { + case 0: + ui_utils_label_set_text(this->usb_label, "USB Not Connected", "left"); + break; + + case 1: + ui_utils_label_set_text(this->usb_label, "USB is Connected", "left"); + break; + } + } + } + + bool is_bluetooth_supported = does_feature_exist("tizen.org/feature/network.bluetooth"); + if(is_bluetooth_supported == false) + { + is_bluetooth_not_supported = true; + ui_utils_label_set_text(this->bluetooth_label, "Feature:network.bluetooth is not supported", "left"); + elm_object_part_content_set(this->view->layout, "bluetooth_text", this->bluetooth_label); + } + else + { + ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_BLUETOOTH_ENABLED , _bluetooth_state_changed_cb, this); + RETVM_IF(ret != RUNTIME_INFO_ERROR_NONE && ret != RUNTIME_INFO_ERROR_NOT_SUPPORTED, NULL, "runtime_info_set_changed_cb failed : %s", get_runtime_info_error(ret)); + + this->bluetooth_label = ui_utils_label_add(this->view->layout, "bluetooth: "); + elm_label_line_wrap_set(this->bluetooth_label, ELM_WRAP_WORD); + + if(ret == RUNTIME_INFO_ERROR_NOT_SUPPORTED) + { + + is_bluetooth_not_supported = true; + ui_utils_label_set_text(this->bluetooth_label, "Bluetooth is not supported", "left"); + elm_object_part_content_set(this->view->layout, "bluetooth_text", this->bluetooth_label); + } + else + { + ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_BLUETOOTH_ENABLED , &bvalue); + RETVM_IF(ret != RUNTIME_INFO_ERROR_NONE && ret != RUNTIME_INFO_ERROR_NOT_SUPPORTED, NULL, "runtime_info_get_value_int failed: %s",get_runtime_info_error(ret)); + if(ret == RUNTIME_INFO_ERROR_NOT_SUPPORTED) + { + + is_bluetooth_not_supported = true; + ui_utils_label_set_text(this->bluetooth_label, "Bluetooth is not supported", "left"); + elm_object_part_content_set(this->view->layout, "bluetooth_text", this->bluetooth_label); + } + else + { + DBG("value: %d", bvalue); + switch(bvalue) + { + case 0: + ui_utils_label_set_text(this->bluetooth_label, "Bluetooth Not Enabled", "left"); + break; + + case 1: + ui_utils_label_set_text(this->bluetooth_label, "Bluetooth is Enabled", "left"); + break; + } + } + } + } + + bool is_orientation_supported = does_feature_exist("tizen.org/feature/screen.auto_rotation"); + if(is_orientation_supported == false) + { + + is_autorotate_not_supported = true; + ui_utils_label_set_text(this->rotate_label, "Feature:screen.auto_rotation is not supported", "left"); + elm_object_part_content_set(this->view->layout, "rotate_text", this->rotate_label); + } + else + { + + ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_AUTO_ROTATION_ENABLED , _rotate_state_changed_cb, this); + RETVM_IF(ret != RUNTIME_INFO_ERROR_NONE && ret != RUNTIME_INFO_ERROR_NOT_SUPPORTED, NULL, "runtime_info_set_changed_cb failed : %s", get_runtime_info_error(ret)); + + this->rotate_label = ui_utils_label_add(this->view->layout, "rotate: "); + elm_label_line_wrap_set(this->rotate_label, ELM_WRAP_WORD); + + if(ret == RUNTIME_INFO_ERROR_NOT_SUPPORTED) + { + is_autorotate_not_supported = true; + ui_utils_label_set_text(this->rotate_label, "AUTO_ROTATION is not supported", "left"); + elm_object_part_content_set(this->view->layout, "rotate_text", this->rotate_label); + } + else + { + ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_AUTO_ROTATION_ENABLED , &bvalue); + RETVM_IF(ret != RUNTIME_INFO_ERROR_NONE && ret != RUNTIME_INFO_ERROR_NOT_SUPPORTED, NULL, "runtime_info_get_value_int failed: %s",get_runtime_info_error(ret)); + if(ret == RUNTIME_INFO_ERROR_NOT_SUPPORTED) + { + is_autorotate_not_supported = true; + ui_utils_label_set_text(this->rotate_label, "AUTO_ROTATION is not supported", "left"); + elm_object_part_content_set(this->view->layout, "rotate_text", this->rotate_label); + } + else + { + DBG("value: %d", bvalue); + + switch(bvalue) + { + case 0: + ui_utils_label_set_text(this->rotate_label, "Auto Rotate Not Enabled", "left"); + break; + + case 1: + ui_utils_label_set_text(this->rotate_label, "Auto Rotate is Enabled", "left"); + break; + } + } + } + } + + bool is_location_supported = does_feature_exist("tizen.org/feature/location"); + if(is_location_supported == false) + { + + is_location_not_supported = true; + ui_utils_label_set_text(this->location_label, "Feature:location is not supported", "left"); + elm_object_part_content_set(this->view->layout, "location_text", this->location_label); + } + else + { + ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_LOCATION_SERVICE_ENABLED , _location_state_changed_cb, this); + RETVM_IF(ret != RUNTIME_INFO_ERROR_NONE && ret != RUNTIME_INFO_ERROR_NOT_SUPPORTED, NULL, "runtime_info_set_changed_cb failed : %s", get_runtime_info_error(ret)); + + this->location_label = ui_utils_label_add(this->view->layout, "location: "); + elm_label_line_wrap_set(this->location_label, ELM_WRAP_WORD); + + if(ret == RUNTIME_INFO_ERROR_NOT_SUPPORTED) + { + is_location_not_supported = true; + ui_utils_label_set_text(this->location_label, "Location is not supported", "left"); + elm_object_part_content_set(this->view->layout, "location_text", this->location_label); + } + else + { + ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_LOCATION_SERVICE_ENABLED , &bvalue); + RETVM_IF(ret != RUNTIME_INFO_ERROR_NONE && ret != RUNTIME_INFO_ERROR_NOT_SUPPORTED, NULL, "runtime_info_get_value_int failed: %s",get_runtime_info_error(ret)); + if(ret == RUNTIME_INFO_ERROR_NOT_SUPPORTED) + { + is_location_not_supported = true; + ui_utils_label_set_text(this->location_label, "Location is not supported", "left"); + elm_object_part_content_set(this->view->layout, "location_text", this->location_label); + } + else + { + DBG("value: %d", bvalue); + switch(bvalue) + { + case 0: + ui_utils_label_set_text(this->location_label, "Location Not Enabled", "left"); + break; + + case 1: + ui_utils_label_set_text(this->location_label, "Location is Enabled", "left"); + break; + } + } + } + } + + bool is_wifi_supported = does_feature_exist("tizen.org/feature/network.wifi"); + if(is_wifi_supported == false) + { + is_wifi_not_supported = true; + ui_utils_label_set_text(this->wifi_label, "Feature:network.wifi is not supported", "left"); + elm_object_part_content_set(this->view->layout, "wifi_text", this->wifi_label); + } + else + { + ret = runtime_info_set_changed_cb(RUNTIME_INFO_KEY_WIFI_HOTSPOT_ENABLED , _wifi_state_changed_cb, this); + RETVM_IF(ret != RUNTIME_INFO_ERROR_NONE && ret != RUNTIME_INFO_ERROR_NOT_SUPPORTED, NULL, "runtime_info_set_changed_cb failed : %s", get_runtime_info_error(ret)); + + this->wifi_label = ui_utils_label_add(this->view->layout, "wifi: "); + elm_label_line_wrap_set(this->wifi_label, ELM_WRAP_WORD); + + if(ret == RUNTIME_INFO_ERROR_NOT_SUPPORTED) + { + is_wifi_not_supported = true; + ui_utils_label_set_text(this->wifi_label, "Wifi Hotspot is not supported", "left"); + elm_object_part_content_set(this->view->layout, "wifi_text", this->wifi_label); + } + else + { + ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_WIFI_HOTSPOT_ENABLED , &bvalue); + RETVM_IF(ret != RUNTIME_INFO_ERROR_NONE && ret != RUNTIME_INFO_ERROR_NOT_SUPPORTED, NULL, "runtime_info_get_value_int failed: %s",get_runtime_info_error(ret)); + if(ret == RUNTIME_INFO_ERROR_NOT_SUPPORTED) + { + is_wifi_not_supported = true; + ui_utils_label_set_text(this->wifi_label, "Wifi Hotspot is not supported", "left"); + elm_object_part_content_set(this->view->layout, "wifi_text", this->wifi_label); + } + else + { + DBG("value: %d", bvalue); + switch(bvalue) + { + case 0: + ui_utils_label_set_text(this->wifi_label, "Wifi Hotspot Not Enabled", "left"); + break; + + case 1: + ui_utils_label_set_text(this->wifi_label, "Wifi Hotspot is Enabled", "left"); + break; + } + } + } + } elm_object_part_content_set(this->view->layout, "info_text", this->info_label); + elm_object_part_content_set(this->view->layout, "vibrate_text", this->vibrate_label); + elm_object_part_content_set(this->view->layout, "battery_text", this->battery_label); + elm_object_part_content_set(this->view->layout, "gps_text", this->gps_label); + elm_object_part_content_set(this->view->layout, "usb_text", this->usb_label); + elm_object_part_content_set(this->view->layout, "bluetooth_text", this->bluetooth_label); + elm_object_part_content_set(this->view->layout, "rotate_text", this->rotate_label); + elm_object_part_content_set(this->view->layout, "location_text", this->location_label); + elm_object_part_content_set(this->view->layout, "wifi_text", this->wifi_label); return this; @@ -186,6 +597,12 @@ static void _app_destroy_cb(void* this) view = (runtimeinfo_view*)this; RETM_IF(NULL == view, "view is NULL"); + if((is_audiojack_not_supported == true) && (is_gps_not_supported == true) && (is_bluetooth_not_supported == true) && (is_vibrate_not_supported == true) && (is_battery_not_supported == true) && (is_usb_not_supported == true) && (is_autorotate_not_supported == true) && (is_location_not_supported == true) && (is_wifi_not_supported == true)) + { + view->view->tbt_info->result = TBT_INFO_RESULT_NOT_SUPPORTED; + elm_genlist_item_update(view->view->item); + } + SAFE_DELETE(view->view); SAFE_DELETE(view); } @@ -236,4 +653,319 @@ switch(value) } } +/** + * @function _vibrate_state_changed_cb + * @since_tizen 2.3 + * @description vibrate State Changed Cb + * @parameter runtime_info_key_e key, void *user_data + * @return static void + */ +static void _vibrate_state_changed_cb(runtime_info_key_e key, void *user_data) +{ + RETM_IF(NULL == user_data, "user_data is null"); + int ret; + bool bvalue; + runtimeinfo_view *this = NULL; + this = (runtimeinfo_view*) user_data; + + ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_VIBRATION_ENABLED, &bvalue); + RETM_IF(ret != RUNTIME_INFO_ERROR_NONE && ret != RUNTIME_INFO_ERROR_NOT_SUPPORTED,"runtime_info_get_value_int failed :%s",get_runtime_info_error(ret)); + if(ret == RUNTIME_INFO_ERROR_NOT_SUPPORTED) + { + ui_utils_label_set_text(this->vibrate_label, "Device Vibration is not supported", "left"); + return; + } + + DBG("value: %d", bvalue); + +switch(bvalue) +{ + case 0: + ui_utils_label_set_text(this->vibrate_label, "Device Vibration is Not Enabled", "left"); + break; + + case 1: + ui_utils_label_set_text(this->vibrate_label, "Device Vibration is Enabled", "left"); + break; + } +} + +/** + * @function _battery_state_changed_cb + * @since_tizen 2.3 + * @description battery State Changed Cb + * @parameter runtime_info_key_e key, void *user_data + * @return static void + */ +static void _battery_state_changed_cb(runtime_info_key_e key, void *user_data) +{ + RETM_IF(NULL == user_data, "user_data is null"); + int ret; + bool bvalue; + runtimeinfo_view *this = NULL; + this = (runtimeinfo_view*) user_data; + + ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_BATTERY_IS_CHARGING, &bvalue); + RETM_IF(ret != RUNTIME_INFO_ERROR_NONE && ret != RUNTIME_INFO_ERROR_NOT_SUPPORTED,"runtime_info_get_value_int failed :%s",get_runtime_info_error(ret)); + if(ret == RUNTIME_INFO_ERROR_NOT_SUPPORTED) + { + ui_utils_label_set_text(this->vibrate_label, "Battery Charging is not supported", "left"); + return; + } + + DBG("value: %d", bvalue); + + switch(bvalue) + { + case 0: + ui_utils_label_set_text(this->battery_label, "Battery Not Charging", "left"); + break; + + case 1: + ui_utils_label_set_text(this->battery_label, "Battery Charging Started", "left"); + break; + } + +} + +/** + * @function _gps_state_changed_cb + * @since_tizen 2.3 + * @description gps state Changed Cb + * @parameter runtime_info_key_e key, void *user_data + * @return void + */ +void _gps_state_changed_cb(runtime_info_key_e key, void *user_data) +{ + + RETM_IF(NULL == user_data, "user_data is null"); + int ret, value; + runtimeinfo_view *this = NULL; + this = (runtimeinfo_view*) user_data; + + ret = runtime_info_get_value_int(RUNTIME_INFO_KEY_GPS_STATUS, &value); + RETM_IF(ret != RUNTIME_INFO_ERROR_NONE && ret != RUNTIME_INFO_ERROR_NOT_SUPPORTED,"runtime_info_get_value_int failed :%s",get_runtime_info_error(ret)); + if(ret == RUNTIME_INFO_ERROR_NOT_SUPPORTED) + { + ui_utils_label_set_text(this->gps_label, "GPS is not supported", "left"); + return; + } + + DBG("value: %d", value); + + switch(value) + { + case 0: + ui_utils_label_set_text(this->gps_label, "GPS is disabled", "left"); + break; + + case 1: + ui_utils_label_set_text(this->gps_label, "GPS is searching for satellites", "left"); + break; + + case 2: + ui_utils_label_set_text(this->gps_label, "GPS connection is established", "left"); + break; + + default: + ui_utils_label_set_text(this->gps_label, "Unknown status", "left"); + break; + + } +} + +/** + * @function _usb_state_changed_cb + * @since_tizen 2.3 + * @description usb State Changed Cb + * @parameter runtime_info_key_e key, void *user_data + * @return static void + */ +static void _usb_state_changed_cb(runtime_info_key_e key, void *user_data) +{ + RETM_IF(NULL == user_data, "user_data is null"); + int ret; + bool bvalue; + runtimeinfo_view *this = NULL; + this = (runtimeinfo_view*) user_data; + + ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_USB_CONNECTED, &bvalue); + RETM_IF(ret != RUNTIME_INFO_ERROR_NONE && ret != RUNTIME_INFO_ERROR_NOT_SUPPORTED,"runtime_info_get_value_int failed :%s",get_runtime_info_error(ret)); + if(ret == RUNTIME_INFO_ERROR_NOT_SUPPORTED) + { + ui_utils_label_set_text(this->usb_label, "USB is not supported", "left"); + return; + } + + DBG("value: %d", bvalue); + + switch(bvalue) + { + case 0: + ui_utils_label_set_text(this->usb_label, "USB Not Connected", "left"); + break; + + case 1: + ui_utils_label_set_text(this->usb_label, "USB is Connected", "left"); + break; + } + +} + +/** + * @function _bluetooth_state_changed_cb + * @since_tizen 2.3 + * @description bluetooth State Changed Cb + * @parameter runtime_info_key_e key, void *user_data + * @return static void + */ +static void _bluetooth_state_changed_cb(runtime_info_key_e key, void *user_data) +{ + RETM_IF(NULL == user_data, "user_data is null"); + int ret; + bool bvalue; + runtimeinfo_view *this = NULL; + this = (runtimeinfo_view*) user_data; + + ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_BLUETOOTH_ENABLED , &bvalue); + RETM_IF(ret != RUNTIME_INFO_ERROR_NONE && ret != RUNTIME_INFO_ERROR_NOT_SUPPORTED,"runtime_info_get_value_int failed :%s",get_runtime_info_error(ret)); + if(ret == RUNTIME_INFO_ERROR_NOT_SUPPORTED) + { + ui_utils_label_set_text(this->bluetooth_label, "Bluetooth is not supported", "left"); + return; + } + + DBG("value: %d", bvalue); + + switch(bvalue) + { + case 0: + ui_utils_label_set_text(this->bluetooth_label, "Bluetooth Not Enabled", "left"); + break; + + case 1: + ui_utils_label_set_text(this->bluetooth_label, "Bluetooth is Enabled", "left"); + break; + } + +} + +/** + * @function _rotate_state_changed_cb + * @since_tizen 2.3 + * @description rotate State Changed Cb + * @parameter runtime_info_key_e key, void *user_data + * @return static void + */ +static void _rotate_state_changed_cb(runtime_info_key_e key, void *user_data) +{ + RETM_IF(NULL == user_data, "user_data is null"); + int ret; + bool bvalue; + runtimeinfo_view *this = NULL; + this = (runtimeinfo_view*) user_data; + + ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_AUTO_ROTATION_ENABLED , &bvalue); + RETM_IF(ret != RUNTIME_INFO_ERROR_NONE && ret != RUNTIME_INFO_ERROR_NOT_SUPPORTED,"runtime_info_get_value_int failed :%s",get_runtime_info_error(ret)); + if(ret == RUNTIME_INFO_ERROR_NOT_SUPPORTED) + { + ui_utils_label_set_text(this->rotate_label, "Auto Rotate is not supported", "left"); + return; + } + + DBG("value: %d", bvalue); + + switch(bvalue) + { + case 0: + ui_utils_label_set_text(this->rotate_label, "Auto Rotate Not Enabled", "left"); + break; + + case 1: + ui_utils_label_set_text(this->rotate_label, "Auto Rotate is Enabled", "left"); + break; + } + + +} + +/** + * @function _location_state_changed_cb + * @since_tizen 2.3 + * @description location State Changed Cb + * @parameter runtime_info_key_e key, void *user_data + * @return static void + */ +static void _location_state_changed_cb(runtime_info_key_e key, void *user_data) +{ + RETM_IF(NULL == user_data, "user_data is null"); + int ret; + bool bvalue; + runtimeinfo_view *this = NULL; + this = (runtimeinfo_view*) user_data; + + ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_LOCATION_SERVICE_ENABLED , &bvalue); + RETM_IF(ret != RUNTIME_INFO_ERROR_NONE && ret != RUNTIME_INFO_ERROR_NOT_SUPPORTED,"runtime_info_get_value_int failed :%s",get_runtime_info_error(ret)); + if(ret == RUNTIME_INFO_ERROR_NOT_SUPPORTED) + { + ui_utils_label_set_text(this->location_label, "Location is not supported", "left"); + return; + } + + DBG("value: %d", bvalue); + + switch(bvalue) + { + case 0: + ui_utils_label_set_text(this->location_label, "Location Not Enabled", "left"); + break; + + case 1: + ui_utils_label_set_text(this->location_label, "Location is Enabled", "left"); + break; + } + + +} + +/** + * @function _wifi_state_changed_cb + * @since_tizen 2.3 + * @description wifi State Changed Cb + * @parameter runtime_info_key_e key, void *user_data + * @return static void + */ +static void _wifi_state_changed_cb(runtime_info_key_e key, void *user_data) +{ + RETM_IF(NULL == user_data, "user_data is null"); + int ret; + bool bvalue; + runtimeinfo_view *this = NULL; + this = (runtimeinfo_view*) user_data; + + ret = runtime_info_get_value_bool(RUNTIME_INFO_KEY_WIFI_HOTSPOT_ENABLED , &bvalue); + RETM_IF(ret != RUNTIME_INFO_ERROR_NONE && ret != RUNTIME_INFO_ERROR_NOT_SUPPORTED,"runtime_info_get_value_int failed :%s",get_runtime_info_error(ret)); + if(ret == RUNTIME_INFO_ERROR_NOT_SUPPORTED) + { + ui_utils_label_set_text(this->wifi_label, "Wifi Hotspot is not supported", "left"); + return; + } + + DBG("value: %d", bvalue); + + switch(bvalue) + { + case 0: + ui_utils_label_set_text(this->wifi_label, "Wifi Hotspot Not Enabled", "left"); + break; + + case 1: + ui_utils_label_set_text(this->wifi_label, "Wifi Hotspot is Enabled", "left"); + break; + } + + +} + + #endif diff --git a/tbtcoreapp/src/view/tbt-storage-view.c b/tbtcoreapp/src/view/tbt-storage-view.c new file mode 100644 index 0000000..5d3fafa --- /dev/null +++ b/tbtcoreapp/src/view/tbt-storage-view.c @@ -0,0 +1,220 @@ +/******************************************************************************* + * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *******************************************************************************/ +/** + * @file tbt-runtimeinfo-view.c + * @brief retrieves runtime info + * + * @author Nibha Sharma(nibha.sharma@samsung.com) + * @date June, 2016 + * @bug none + * @credit + * + */ +#include "utils/app_module_config.h" +#ifdef TBT_MODULE_STORAGE + +#include +#include + +#include "utils/logger.h" +#include "utils/config.h" +#include "utils/ui-utils.h" +#include "view/tbt-storage-view.h" +#include "view/tbt-common-view.h" + +struct _storage_view +{ + common_view* view; + + Evas_Object *info_label; +}; + +static void _app_destroy_cb(void* this); +static void _storage_state_changed_cb(int storage_id, storage_state_e state, void *user_data); +bool storage_device_supported_cb_p(int storage_id, storage_type_e type, storage_state_e state, const char *path, void *user_data); + +static int StorageID; +static bool is_not_supported = false; + +/** + * @function get_storage_error + * @since_tizen 3.0 + * @description Get Storage Error + * @parameter int: Int + * @return char* + */ +char* get_storage_type_error(int ret) +{ + char* err_msg = NULL; + switch (ret) { + case STORAGE_ERROR_NONE: + err_msg = "STORAGE_ERROR_NONE"; + break; + case STORAGE_ERROR_INVALID_PARAMETER: + err_msg = "STORAGE_ERROR_INVALID_PARAMETER"; + break; + case STORAGE_ERROR_OUT_OF_MEMORY: + err_msg = "STORAGE_ERROR_OUT_OF_MEMORY"; + break; + case STORAGE_ERROR_NOT_SUPPORTED: + err_msg = "STORAGE_ERROR_NOT_SUPPORTED"; + break; + case STORAGE_ERROR_OPERATION_FAILED: + err_msg = "STORAGE_ERROR_OPERATION_FAILED"; + break; + default: + err_msg = "Unknown Error"; + break; + } + + return err_msg; +} + + + +/** +* @function storage_device_supported_cb_p +* @description callback for supported devices +* @parameter storage_id : storage id, type : storage type, state : state, path : storage path, user_data : user data passed to callback +* @return bool +*/ +bool storage_device_supported_cb_p(int storage_id, storage_type_e type, storage_state_e state, const char *path, void *user_data) +{ + StorageID = 0; + storage_view *this = NULL; + this = (storage_view*) user_data; + if(type == STORAGE_TYPE_EXTERNAL) + { + StorageID=storage_id; + return false; + } + return true; +} + +/** + * @function storage_view_add + * @since_tizen 3.0 + * @description storage View Add + * @parameter Evas_Object*: Evas Object Pointer, tbt_info*: Tbt Info Pointer, Elm_Object_Item*: Elm Object Item Pointer + * @return storage_view* + */ +storage_view *storage_view_add(Evas_Object *navi, tbt_info *tbt_info, Elm_Object_Item *item) +{ + RETVM_IF(NULL == navi, NULL, "navi is null"); + int ret; + storage_view *this = NULL; + this = calloc(1, sizeof(storage_view)); + RETVM_IF(!this, NULL, "calloc failed"); + + this->view = calloc(1, sizeof(common_view)); + RETVM_IF(!this->view, NULL, "calloc failed"); + + tbt_info->layout_group = "storage_viewer"; + tbt_info->layout_file = get_edje_path("storage_viewer.edj"); + + common_view_add(navi, tbt_info, item, this->view, _app_destroy_cb, this); + RETVM_IF(NULL == this->view, NULL, "navi is null"); + + ret = storage_foreach_device_supported(storage_device_supported_cb_p, this); + RETVM_IF(ret != STORAGE_ERROR_NONE && ret != STORAGE_ERROR_NOT_SUPPORTED, NULL, "storage_foreach_device_supported failed : %s", get_storage_type_error(ret)); + if(ret == STORAGE_ERROR_NOT_SUPPORTED) + { + is_not_supported = true; + Evas_Object *popup = ui_utils_popup_add(this->view->navi, "Message"); + elm_object_text_set(popup, "Storage is not supported"); + RETVM_IF(!this->view, NULL,"Storage is not supported"); + } + + ret = storage_set_state_changed_cb(StorageID, _storage_state_changed_cb, this); + RETVM_IF(ret != STORAGE_ERROR_NONE, NULL, "storage_set_state_changed_cb failed : %s", get_storage_type_error(ret)); + + this->info_label = ui_utils_label_add(this->view->layout, "Please Change SD Card state[Remove/Insert]"); + elm_label_line_wrap_set(this->info_label, ELM_WRAP_WORD); + + elm_object_part_content_set(this->view->layout, "info_text", this->info_label); + + return this; +} + + +/** + * @function _app_destroy_cb + * @since_tizen 2.3 + * @description App Destroy Cb + * @parameter void*: Void Pointer + * @return static void + */ +static void _app_destroy_cb(void* this) +{ + + RETM_IF(NULL == this, "data is NULL"); + + storage_view *view = NULL; + view = (storage_view*)this; + RETM_IF(NULL == view, "view is NULL"); + + if(is_not_supported == true) + { + view->view->tbt_info->result = TBT_INFO_RESULT_NOT_SUPPORTED; + elm_genlist_item_update(view->view->item); + } + + int ret = storage_unset_state_changed_cb( StorageID, _storage_state_changed_cb); + RETM_IF(ret != STORAGE_ERROR_NONE, "storage_unset_state_changed_cb fail > Error = %s", get_storage_type_error(ret)); + + SAFE_DELETE(view->view); + SAFE_DELETE(view); +} + + +/** + * @function storage_state_changed_cb + * @since_tizen 3.0 + * @description storage Info Changed Cb + * @parameter int storage_id, storage_state_e state, void *user_data + * @return void + */ +static void _storage_state_changed_cb(int storage_id, storage_state_e state, void *user_data) +{ + + RETM_IF(NULL == user_data, "user_data is null"); + int ret; + storage_view *this = NULL; + this = (storage_view*) user_data; + + DBG("value: %d", state); + + switch (state) + { + case STORAGE_STATE_UNMOUNTABLE: + ui_utils_label_set_text(this->info_label, "STORAGE_STATE_UNMOUNTABLE", "left"); + break; + case STORAGE_STATE_REMOVED: + ui_utils_label_set_text(this->info_label, "STORAGE_STATE_REMOVED", "left"); + break; + case STORAGE_STATE_MOUNTED: + ui_utils_label_set_text(this->info_label, "STORAGE_STATE_MOUNTED", "left"); + break; + case STORAGE_STATE_MOUNTED_READ_ONLY: + ui_utils_label_set_text(this->info_label, "STORAGE_STATE_MOUNTED_READ_ONLY", "left"); + break; + default: + ui_utils_label_set_text(this->info_label, "unknown state", "left"); + break; + } +} + +#endif