4 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the License);
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 #include "usb-client.h"
21 #include "core/edbus-handler.h"
23 #define CHANGE_USB_MODE "ChangeUsbMode"
25 static void change_usb_client_mode(void *data, DBusMessage *msg)
30 if (dbus_message_is_signal(msg, DEVICED_INTERFACE_USB, CHANGE_USB_MODE) == 0) {
31 _E("The signal is not for changing usb mode");
35 dbus_error_init(&err);
37 if (dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &mode, DBUS_TYPE_INVALID) == 0) {
38 _E("FAIL: dbus_message_get_args");
45 case SET_USB_RNDIS_DIAG:
49 case SET_USB_SDB_DIAG:
50 case SET_USB_RNDIS_SDB:
54 _E("(%d) is unknown usb mode", mode);
58 if (vconf_set_int(VCONFKEY_USB_SEL_MODE, mode) != 0)
59 _E("Failed to set usb mode (%d)", mode);
61 if (vconf_set_bool(VCONFKEY_SETAPPL_USB_DEBUG_MODE_BOOL, debug) != 0)
62 _E("Failed to set usb debug toggle (%d)", debug);
65 dbus_error_free(&err);
70 int register_usb_client_change_request(void)
72 return register_edbus_signal_handler(DEVICED_PATH_USB,
73 DEVICED_INTERFACE_USB,
74 CHANGE_USB_MODE, change_usb_client_mode);