Fixed: Coding rule issues.
[platform/core/connectivity/wifi-direct-manager.git] / src / wifi-direct-error.c
1 /*
2  * Network Configuration Module
3  *
4  * Copyright (c) 2015 Samsung Electronics Co., Ltd. All rights reserved.
5  *
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
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  */
19
20 /**
21  * This file implements wifi direct manager dbus error functions.
22  *
23  * @file        wifi-direct-error.c
24  * @author      Nishant Chaprana (n.chaprana@samsung.com)
25  * @version     0.1
26  */
27
28 #include <glib.h>
29 #include "wifi-direct-error.h"
30 #include "wifi-direct-dbus.h"
31 #include "wifi-direct-log.h"
32
33 #define WFD_MANAGER_QUARK (g_quark_from_string("wifi-direct-error-quark"))
34
35 static void wfd_error_invalid_parameter(GError **error)
36 {
37         *error = g_dbus_error_new_for_dbus_error(
38                 "net.wifidirect.Error.InvalidParameter",
39                 "net.wifidirect.Error.InvalidParameter");
40         /*
41         g_set_error(error,
42                         WFD_MANAGER_QUARK,
43                         WIFI_DIRECT_ERROR_INVALID_PARAMETER,
44                         WFD_MANAGER_ERROR_INTERFACE ".InvalidParameter");
45                         */
46 }
47
48 static void wfd_error_not_permitted(GError **error)
49 {
50         *error = g_dbus_error_new_for_dbus_error(
51                 "net.wifidirect.Error.NotPermitted",
52                 "net.wifidirect.Error.NotPermitted");
53 /*
54         g_set_error(error,
55                         WFD_MANAGER_QUARK,
56                         WIFI_DIRECT_ERROR_NOT_PERMITTED,
57                         WFD_MANAGER_ERROR_INTERFACE ".NotPermitted");
58                         */
59 }
60
61 static void wfd_error_operation_failed(GError **error)
62 {
63         *error = g_dbus_error_new_for_dbus_error(
64                 "net.wifidirect.Error.OperationFailed",
65                 "net.wifidirect.Error.OperationFailed");
66         /*
67         g_set_error(error,
68                         WFD_MANAGER_QUARK,
69                         WIFI_DIRECT_ERROR_OPERATION_FAILED,
70                         WFD_MANAGER_ERROR_INTERFACE ".OperationFailed");
71                         */
72 }
73
74 static void wfd_error_too_many_client(GError **error)
75 {
76         *error = g_dbus_error_new_for_dbus_error(
77                 "net.wifidirect.Error.TooManyClient",
78                 "net.wifidirect.Error.TooManyClient");
79 /*
80         g_set_error(error,
81                         WFD_MANAGER_QUARK,
82                         WIFI_DIRECT_ERROR_TOO_MANY_CLIENT,
83                         WFD_MANAGER_ERROR_INTERFACE ".TooManyClient");
84                         */
85 }
86
87 void wfd_error_set_gerror(wifi_direct_error_e error_code, GError **error)
88 {
89         switch (error_code) {
90         case WIFI_DIRECT_ERROR_INVALID_PARAMETER:
91                 wfd_error_invalid_parameter(error);
92                 break;
93         case WIFI_DIRECT_ERROR_NOT_PERMITTED:
94                 wfd_error_not_permitted(error);
95                 break;
96         case WIFI_DIRECT_ERROR_OPERATION_FAILED:
97                 wfd_error_operation_failed(error);
98                 break;
99         case WIFI_DIRECT_ERROR_TOO_MANY_CLIENT:
100                 wfd_error_too_many_client(error);
101                 break;
102         default:
103                 WDS_LOGD("Error Not handled [%d]", error_code);
104                 wfd_error_operation_failed(error);
105         }
106 }
107
108 void wfd_error_register(void)
109 {
110         g_dbus_error_register_error(WFD_MANAGER_QUARK,
111                         WIFI_DIRECT_ERROR_INVALID_PARAMETER,
112                         "net.wifidirect.Error.InvalidParameter");
113
114
115         g_dbus_error_register_error(WFD_MANAGER_QUARK,
116                         WIFI_DIRECT_ERROR_NOT_PERMITTED,
117                         "net.wifidirect.Error.NotPermitted");
118
119
120         g_dbus_error_register_error(WFD_MANAGER_QUARK,
121                         WIFI_DIRECT_ERROR_OPERATION_FAILED,
122                         "net.wifidirect.Error.OperationFailed");
123
124
125         g_dbus_error_register_error(WFD_MANAGER_QUARK,
126                         WIFI_DIRECT_ERROR_TOO_MANY_CLIENT,
127                         "net.wifidirect.Error.TooManyClient");
128 }
129
130 void wfd_error_deregister(void)
131 {
132         g_dbus_error_unregister_error(WFD_MANAGER_QUARK,
133                         WIFI_DIRECT_ERROR_INVALID_PARAMETER,
134                         "net.wifidirect.Error.InvalidParameter");
135
136
137         g_dbus_error_unregister_error(WFD_MANAGER_QUARK,
138                         WIFI_DIRECT_ERROR_NOT_PERMITTED,
139                         "net.wifidirect.Error.NotPermitted");
140
141
142         g_dbus_error_unregister_error(WFD_MANAGER_QUARK,
143                         WIFI_DIRECT_ERROR_OPERATION_FAILED,
144                         "net.wifidirect.Error.OperationFailed");
145
146
147         g_dbus_error_unregister_error(WFD_MANAGER_QUARK,
148                         WIFI_DIRECT_ERROR_TOO_MANY_CLIENT,
149                         "net.wifidirect.Error.TooManyClient");
150
151 }