3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #ifndef __TIZEN_SYSTEM_USB_ACCESSORY_PRIVATE_H__
19 #define __TIZEN_SYSTEM_USB_ACCESSORY_PRIVATE_H__
27 #include <sys/types.h>
30 #include <sys/socket.h>
37 #include <sys/utsname.h>
40 #define ACC_ELEMENT_LEN 256
41 #define SOCK_PATH "/tmp/usb_server_sock"
42 #define ACC_SOCK_PATH "/tmp/usb_acc_sock"
43 #define USB_ACCESSORY_NODE "/dev/usb_accessory"
45 #define SOCK_STR_LEN 1542
47 #define USB_TAG "USB_ACCESSORY"
49 #define USB_LOG(format, args...) \
50 LOG(LOG_VERBOSE, USB_TAG, "[%s][Ln: %d] " format, \
51 (char*)(strrchr(__FILE__, '/')+1), __LINE__, ##args)
53 #define USB_LOG_ERROR(format, args...) \
54 LOG(LOG_ERROR, USB_TAG, "[%s][Ln: %d] " format, \
55 (char*)(strrchr(__FILE__, '/')+1), __LINE__, ##args)
57 #define __USB_FUNC_ENTER__ \
58 USB_LOG("Entering: %s()\n", __func__)
60 #define __USB_FUNC_EXIT__ \
61 USB_LOG("Exit: %s()\n", __func__)
71 #define um_retvm_if(expr, val, fmt, arg...) \
74 USB_LOG_ERROR(fmt, ##arg); \
79 #define um_retm_if(expr, fmt, arg...) \
82 USB_LOG_ERROR(fmt, ##arg); \
95 ERROR_POPUP_OK_BTN = 0,
99 LAUNCH_APP_FOR_ACC = 20,
102 REQ_ACC_PERM_NOTI_YES_BTN,
103 REQ_ACC_PERM_NOTI_NO_BTN,
107 LAUNCH_APP_FOR_HOST = 40,
110 REQ_HOST_PERM_NOTI_YES_BTN,
111 REQ_HOST_PERM_NOTI_NO_BTN,
113 } REQUEST_TO_USB_MANGER;
117 ACC_MANUFACTURER = 0,
125 struct usb_accessory_s {
128 char manufacturer[ACC_ELEMENT_LEN];
129 char model[ACC_ELEMENT_LEN];
130 char description[ACC_ELEMENT_LEN];
131 char version[ACC_ELEMENT_LEN];
132 char uri[ACC_ELEMENT_LEN];
133 char serial[ACC_ELEMENT_LEN];
136 struct usb_accessory_list {
137 struct usb_accessory_s *accessory;
138 struct usb_accessory_list *next;
143 void (*connection_cb_func)(struct usb_accessory_s *accessory, bool is_connected, void *data);
144 void (*request_perm_cb_func)(struct usb_accessory_s *accessory, bool is_granted);
145 struct usb_accessory_s *accessory;
148 int ipc_request_client_init(int *sock_remote);
149 int ipc_request_client_close(int *sock_remote);
150 int request_to_usb_server(int sock_remote, int request, char *answer, char *pkgName);
152 void accessory_status_changed_cb(keynode_t *in_key, void* data);
153 bool getAccList(struct usb_accessory_list **accList);
154 bool freeAccList(struct usb_accessory_list *accList);
155 int ipc_noti_client_init(void);
156 int ipc_noti_client_close(int *sock_remote);
157 gboolean ipc_noti_client_cb(GIOChannel *g_io_ch, GIOCondition condition, gpointer data);
159 #endif /* __TIZEN_SYSTEM_USB_ACCESSORY_PRIVATE_H__ */