--- /dev/null
+/*******************************************************************************
+ * 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-usb-host-view.h
+ * @brief retrieves usb host info
+ * @since_tizen 4.0
+ * @author Nibha Sharma(nibha.sharma@samsung.com)
+ * @date April, 2017
+ * @bug none
+ * @credit
+ * @credit
+ *
+ */
+
+#ifndef __TBT_USB_HOST_VIEW_H__
+#define __TBT_USB_HOST_VIEW_H__
+
+#include "utils/app_module_config.h"
+#ifdef TBT_MODULE_USBHOST
+
+#include <Evas.h>
+#include "model/tbt-list.h"
+#include <usb_host.h>
+
+
+/**
+ * @typedef usb_host_viewer view
+ * @since_tizen 4.0
+ * @brief A usb host viewer view handle.
+ */
+typedef struct _usbhost_view usbhost_view;
+
+/**
+ * @brief Create usbhost view
+ * @since_tizen 2.3
+ * @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 runtimeinfo on success, otherwise NULL
+ */
+usbhost_view *usbhost_view_add(Evas_Object *navi, tbt_info *tbt_info, Elm_Object_Item *item);
+
+#endif
+#endif // __TBT_USB_HOST_VIEW_H__
\ No newline at end of file
--- /dev/null
+/*******************************************************************************
+ * 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-usb-host-view.c
+ * @brief retrieves usb-host info
+ *
+ * @author Nibha Sharma(nibha.sharma@samsung.com)
+ * @date June, 2016
+ * @bug none
+ * @credit
+ *
+ */
+#include "utils/app_module_config.h"
+#ifdef TBT_MODULE_USBHOST
+
+#include <Elementary.h>
+#include <locations.h>
+#include <notification.h>
+
+#include "utils/logger.h"
+#include "utils/config.h"
+#include "utils/ui-utils.h"
+#include "view/tbt-usb-host-view.h"
+#include "view/tbt-common-view.h"
+
+struct _usbhost_view
+{
+ common_view* view;
+ Evas_Object *info_label;
+ Evas_Object *device_label;
+};
+
+static void _app_destroy_cb(void* this);
+void _usb_host_hotplug_cb(usb_host_device_h dev, void *user_data);
+
+static bool is_not_supported = false;
+bool usb_cb_hit = false;
+usb_host_context_h hCtxHandle;
+usb_host_hotplug_h hHandle;
+
+/**
+ * @function get_usbhost_error
+ * @since_tizen 4.0
+ * @description Get Usb-Host Error
+ * @parameter int: Int
+ * @return char*
+ */
+char* get_usbhost_error(int ret)
+{
+ char* err_msg = NULL;
+
+ switch (ret) {
+ case USB_HOST_ERROR_NONE:
+ err_msg = "USB_HOST_ERROR_NONE";
+ break;
+ case USB_HOST_ERROR_IO_ERROR:
+ err_msg = "USB_HOST_ERROR_IO_ERROR";
+ break;
+ case USB_HOST_ERROR_INVALID_PARAMETER:
+ err_msg = "USB_HOST_ERROR_INVALID_PARAMETER";
+ break;
+ case USB_HOST_ERROR_PERMISSION_DENIED:
+ err_msg = "USB_HOST_ERROR_PERMISSION_DENIED";
+ break;
+ case USB_HOST_ERROR_NO_SUCH_DEVICE:
+ err_msg = "USB_HOST_ERROR_NO_SUCH_DEVICE";
+ break;
+ case USB_HOST_ERROR_NOT_FOUND:
+ err_msg = "USB_HOST_ERROR_NOT_FOUND";
+ break;
+ case USB_HOST_ERROR_RESOURCE_BUSY:
+ err_msg = "USB_HOST_ERROR_RESOURCE_BUSY";
+ break;
+ case USB_HOST_ERROR_TIMED_OUT:
+ err_msg = "USB_HOST_ERROR_TIMED_OUT";
+ break;
+ case USB_HOST_ERROR_OVERFLOW:
+ err_msg = "USB_HOST_ERROR_OVERFLOW";
+ break;
+ case USB_HOST_ERROR_DEVICE_NOT_OPENED:
+ err_msg = "USB_HOST_ERROR_DEVICE_NOT_OPENED";
+ break;
+ case USB_HOST_ERROR_BROKEN_PIPE:
+ err_msg = "USB_HOST_ERROR_BROKEN_PIPE";
+ break;
+ case USB_HOST_ERROR_INTERRUPTED_SYS_CALL:
+ err_msg = "USB_HOST_ERROR_INTERRUPTED_SYS_CALL";
+ break;
+ case USB_HOST_ERROR_OUT_OF_MEMORY:
+ err_msg = "USB_HOST_ERROR_OUT_OF_MEMORY";
+ break;
+ case USB_HOST_ERROR_NOT_SUPPORTED:
+ err_msg = "USB_HOST_ERROR_NOT_SUPPORTED";
+ break;
+ default:
+ err_msg = "Unknown Error";
+ }
+ return err_msg;
+}
+
+
+/**
+ * @function usbhost_view_add
+ * @since_tizen 4.0
+ * @description usb host View Add
+ * @parameter Evas_Object*: Evas Object Pointer, tbt_info*: Tbt Info Pointer, Elm_Object_Item*: Elm Object Item Pointer
+ * @return usbhost_view*
+ */
+usbhost_view *usbhost_view_add(Evas_Object *navi, tbt_info *tbt_info, Elm_Object_Item *item)
+{
+ RETVM_IF(NULL == navi, NULL, "navi is null");
+ int ret, value;
+ usbhost_view *this = NULL;
+ this = calloc(1, sizeof(usbhost_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 = "usb_host_viewer";
+ tbt_info->layout_file = get_edje_path("usb_host_viewer.edj");
+
+ common_view_add(navi, tbt_info, item, this->view, _app_destroy_cb, this);
+ RETVM_IF(NULL == this->view, NULL, "navi is null");
+
+ //ui_utils_guide_instruction_popup_button(navi, "* Please run "devicectl usb-host-test start" or "devicectl usb-host-test stop" command in sdb shell<br/><b>Note:You can also refer info section</b><br/>");
+
+ ret = usb_host_create(&hCtxHandle);
+ RETVM_IF(ret != USB_HOST_ERROR_NONE && ret != USB_HOST_ERROR_NOT_SUPPORTED, NULL, "usb_host_create failed : %s", get_usbhost_error(ret));
+ if(ret == USB_HOST_ERROR_NOT_SUPPORTED)
+ {
+ is_not_supported = true;
+ Evas_Object *popup = ui_utils_popup_add(this->view->navi, "Message");
+ elm_object_text_set(popup, "Usb Hotplug is not supported");
+ RETVM_IF(!this->view, NULL,"Usb Hotplug is not supported");
+ }
+
+ ret = usb_host_set_hotplug_cb(hCtxHandle, _usb_host_hotplug_cb, USB_HOST_HOTPLUG_EVENT_ANY, this, &hHandle);
+ RETVM_IF(ret != USB_HOST_ERROR_NONE , NULL, "usb_host_set_hotplug_cb failed : %s", get_usbhost_error(ret));
+
+ this->info_label = ui_utils_label_add(this->view->layout, "Please run usb host command in shell");
+ elm_label_line_wrap_set(this->info_label, ELM_WRAP_WORD);
+
+ if(usb_cb_hit == true)
+ {
+ ui_utils_label_set_text(this->info_label, "Callback Hit !!!", "left");
+ }
+ else
+ {
+ ui_utils_label_set_text(this->info_label, "Callback Not Hit !!!", "left");
+ }
+
+ 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");
+
+ usbhost_view *view = NULL;
+ view = (usbhost_view*)this;
+ RETM_IF(NULL == view, "view is NULL");
+ usb_cb_hit = false;
+ if(is_not_supported == true)
+ {
+ view->view->tbt_info->result = TBT_INFO_RESULT_NOT_SUPPORTED;
+ elm_genlist_item_update(view->view->item);
+ }
+ if(hHandle)
+ {
+ int ret = usb_host_unset_hotplug_cb(hHandle);
+ RETM_IF(ret != USB_HOST_ERROR_NONE ,"usb_host_unset_hotplug_cb failed : %s", get_usbhost_error(ret));
+ }
+
+ SAFE_DELETE(view->view);
+ SAFE_DELETE(view);
+}
+
+/**
+ * @function _usb_host_hotplug_cb
+ * @since_tizen 4.0
+ * @description Usb Host hotplug Cb
+ * @parameter usb_host_device_h dev, void *user_data
+ * @return void
+ */
+void _usb_host_hotplug_cb(usb_host_device_h dev, void *user_data)
+{
+ usb_cb_hit = true;
+ RETM_IF(NULL == user_data, "user_data is null");
+ usbhost_view *this = NULL;
+ this = (usbhost_view*) user_data;
+ ui_utils_label_set_text(this->info_label, "Callback Hit !!!", "left");
+}
+
+#endif