2 * Network Configuration Module
4 * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
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.
21 * This file implements wifi direct manager dbus error functions.
23 * @file wifi-direct-error.c
24 * @author Nishant Chaprana (n.chaprana@samsung.com)
29 #include "wifi-direct-error.h"
30 #include "wifi-direct-dbus.h"
31 #include "wifi-direct-log.h"
33 #define WFD_MANAGER_QUARK (g_quark_from_string("wifi-direct-error-quark"))
36 static void wfd_error_invalid_parameter(GError **error)
38 *error = g_dbus_error_new_for_dbus_error(
39 "net.wifidirect.Error.InvalidParameter",
40 "net.wifidirect.Error.InvalidParameter");
44 WIFI_DIRECT_ERROR_INVALID_PARAMETER,
45 WFD_MANAGER_ERROR_INTERFACE ".InvalidParameter");
49 static void wfd_error_not_permitted(GError **error)
51 *error = g_dbus_error_new_for_dbus_error(
52 "net.wifidirect.Error.NotPermitted",
53 "net.wifidirect.Error.NotPermitted");
57 WIFI_DIRECT_ERROR_NOT_PERMITTED,
58 WFD_MANAGER_ERROR_INTERFACE ".NotPermitted");
62 static void wfd_error_operation_failed(GError **error)
64 *error = g_dbus_error_new_for_dbus_error(
65 "net.wifidirect.Error.OperationFailed",
66 "net.wifidirect.Error.OperationFailed");
70 WIFI_DIRECT_ERROR_OPERATION_FAILED,
71 WFD_MANAGER_ERROR_INTERFACE ".OperationFailed");
75 static void wfd_error_too_many_client(GError **error)
77 *error = g_dbus_error_new_for_dbus_error(
78 "net.wifidirect.Error.TooManyClient",
79 "net.wifidirect.Error.TooManyClient");
83 WIFI_DIRECT_ERROR_TOO_MANY_CLIENT,
84 WFD_MANAGER_ERROR_INTERFACE ".TooManyClient");
88 void wfd_error_set_gerror(wifi_direct_error_e error_code, GError **error)
91 case WIFI_DIRECT_ERROR_INVALID_PARAMETER:
92 wfd_error_invalid_parameter(error);
94 case WIFI_DIRECT_ERROR_NOT_PERMITTED:
95 wfd_error_not_permitted(error);
97 case WIFI_DIRECT_ERROR_OPERATION_FAILED:
98 wfd_error_operation_failed(error);
100 case WIFI_DIRECT_ERROR_TOO_MANY_CLIENT:
101 wfd_error_too_many_client(error);
104 WDS_LOGD("Error Not handled [%d]", error_code);
105 wfd_error_operation_failed(error);
108 void wfd_error_register(void)
110 g_dbus_error_register_error(WFD_MANAGER_QUARK,
111 WIFI_DIRECT_ERROR_INVALID_PARAMETER,
112 "net.wifidirect.Error.InvalidParameter");
115 g_dbus_error_register_error(WFD_MANAGER_QUARK,
116 WIFI_DIRECT_ERROR_NOT_PERMITTED,
117 "net.wifidirect.Error.NotPermitted");
120 g_dbus_error_register_error(WFD_MANAGER_QUARK,
121 WIFI_DIRECT_ERROR_OPERATION_FAILED,
122 "net.wifidirect.Error.OperationFailed");
125 g_dbus_error_register_error(WFD_MANAGER_QUARK,
126 WIFI_DIRECT_ERROR_TOO_MANY_CLIENT,
127 "net.wifidirect.Error.TooManyClient");
130 void wfd_error_deregister(void)
132 g_dbus_error_unregister_error(WFD_MANAGER_QUARK,
133 WIFI_DIRECT_ERROR_INVALID_PARAMETER,
134 "net.wifidirect.Error.InvalidParameter");
137 g_dbus_error_unregister_error(WFD_MANAGER_QUARK,
138 WIFI_DIRECT_ERROR_NOT_PERMITTED,
139 "net.wifidirect.Error.NotPermitted");
142 g_dbus_error_unregister_error(WFD_MANAGER_QUARK,
143 WIFI_DIRECT_ERROR_OPERATION_FAILED,
144 "net.wifidirect.Error.OperationFailed");
147 g_dbus_error_unregister_error(WFD_MANAGER_QUARK,
148 WIFI_DIRECT_ERROR_TOO_MANY_CLIENT,
149 "net.wifidirect.Error.TooManyClient");