Remove unmatched quotes
[platform/core/connectivity/net-config.git] / src / neterror.c
1 /*
2  * Network Configuration Module
3  *
4  * Copyright (c) 2000 - 2012 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 #include <glib.h>
21
22 #include "netdbus.h"
23 #include "neterror.h"
24 #include "log.h"
25
26 #define NETCONFIG_ERROR_INTERFACE NETCONFIG_SERVICE ".Error"
27 #define CONNMAN_AGENT_ERROR_INTERFACE "net.connman.Agent.Error"
28
29 GQuark netconfig_error_quark(void)
30 {
31         static GQuark quark = 0;
32
33         if (!quark)
34                 quark = g_quark_from_static_string("netconfig_error");
35
36         return quark;
37 }
38
39 GQuark netconfig_connman_agent_error_quark(void)
40 {
41         static GQuark quark = 0;
42
43         if (!quark)
44                 quark = g_quark_from_static_string("netconfig_connman_agent_error");
45
46         return quark;
47 }
48
49 void netconfig_error_no_profile(GDBusMethodInvocation *context)
50 {
51         ERR("dbus method return error");
52         g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
53                         NETCONFIG_ERROR_NO_PROFILE,
54                         NETCONFIG_ERROR_INTERFACE ".NoProfile");
55 }
56
57 void netconfig_error_inprogress(GDBusMethodInvocation *context)
58 {
59         ERR("dbus method return error");
60         g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
61                         NETCONFIG_ERROR_INPROGRESS,
62                         NETCONFIG_ERROR_INTERFACE ".InProgress");
63 }
64
65 void netconfig_error_already_exists(GDBusMethodInvocation *context)
66 {
67         ERR("dbus method return error");
68         g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
69                         NETCONFIG_ERROR_ALREADYEXISTS,
70                         NETCONFIG_ERROR_INTERFACE ".AlreadyExists");
71 }
72
73 void netconfig_error_invalid_parameter(GDBusMethodInvocation *context)
74 {
75         ERR("dbus method return error");
76         g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
77                         NETCONFIG_ERROR_INVALID_PARAMETER,
78                         NETCONFIG_ERROR_INTERFACE ".InvalidParameter");
79 }
80
81 void netconfig_error_permission_denied(GDBusMethodInvocation *context)
82 {
83         ERR("dbus method return error");
84         g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
85                         NETCONFIG_ERROR_PERMISSION_DENIED,
86                         NETCONFIG_ERROR_INTERFACE ".PermissionDenied");
87 }
88
89 void netconfig_error_wifi_driver_failed(GDBusMethodInvocation *context)
90 {
91         ERR("dbus method return error");
92         g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
93                         NETCONFIG_ERROR_WIFI_DRIVER_FAILURE,
94                         NETCONFIG_ERROR_INTERFACE ".WifiDriverFailed");
95 }
96
97 void netconfig_error_wifi_direct_failed(GDBusMethodInvocation *context)
98 {
99         ERR("dbus method return error");
100         g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
101                         NETCONFIG_ERROR_WIFI_DRIVER_FAILURE,
102                         NETCONFIG_ERROR_INTERFACE ".WifiDirectFailed");
103 }
104
105 EXPORT_SYM void netconfig_error_fail_get_imsi(GDBusMethodInvocation *context)
106 {
107         ERR("dbus method return error");
108         g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
109                         NETCONFIG_ERROR_FAILED_GET_IMSI,
110                         NETCONFIG_ERROR_INTERFACE".FailGetSimImsi");
111 }
112
113 EXPORT_SYM void netconfig_error_fail_req_sim_auth(GDBusMethodInvocation *context)
114 {
115         ERR("dbus method return error");
116         g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
117                         NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH,
118                         NETCONFIG_ERROR_INTERFACE".FailReqSimAuth");
119 }
120
121 EXPORT_SYM void netconfig_error_fail_req_sim_auth_wrong_param(GDBusMethodInvocation *context)
122 {
123         ERR("dbus method return error");
124         g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
125                         NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH_WRONG_PARAM,
126                         NETCONFIG_ERROR_INTERFACE".FailReqSimAuthWrongParam");
127 }
128
129 EXPORT_SYM void netconfig_error_fail_get_sim_auth_wrong_data(GDBusMethodInvocation *context)
130 {
131         ERR("dbus method return error");
132         g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
133                         NETCONFIG_ERROR_FAILED_GET_SIM_AUTH_WRONG_DATA,
134                         NETCONFIG_ERROR_INTERFACE".FailGetSimAuthWrongData");
135 }
136
137 EXPORT_SYM void netconfig_error_fail_get_sim_auth_delay(GDBusMethodInvocation *context)
138 {
139         ERR("dbus method return error");
140         g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
141                         NETCONFIG_ERROR_FAILED_GET_SIM_AUTH_DELAY,
142                         NETCONFIG_ERROR_INTERFACE".FailGetSimAuthDelay");
143 }
144
145 void netconfig_error_fail_save_congifuration(GDBusMethodInvocation *context)
146 {
147         ERR("dbus method return error");
148         g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
149                         NETCONFIG_ERROR_INTERNAL,
150                         NETCONFIG_ERROR_INTERFACE".FailSaveConfiguration");
151 }
152
153 void netconfig_error_fail_ethernet_cable_state(GDBusMethodInvocation *context)
154 {
155         g_dbus_method_invocation_return_error(context, netconfig_error_quark(),
156                         NETCONFIG_ERROR_INTERNAL,
157                         NETCONFIG_ERROR_INTERFACE".FailGetEthernetCableState");
158 }
159
160 #include <glib/gprintf.h>
161 void netconfig_error_dbus_method_return(GDBusMethodInvocation *context, netconfig_error_e error, const gchar *message)
162 {
163         gchar *msg = NULL;
164
165         ERR("dbus method return error");
166
167         msg = g_strdup_printf("%s.%s", NETCONFIG_ERROR_INTERFACE, message);
168         g_dbus_method_invocation_return_error(context, netconfig_error_quark(), error, "%s", msg);
169
170         g_free(msg);
171 }
172
173 void netconfig_error_init(void)
174 {
175         g_dbus_error_register_error(NETCONFIG_ERROR_QUARK,
176                         NETCONFIG_ERROR_INTERNAL,
177                         "net.netconfig.Error.Internal");
178
179         g_dbus_error_register_error(NETCONFIG_ERROR_QUARK,
180                         NETCONFIG_ERROR_NO_SERVICE,
181                         "net.netconfig.Error.NoService");
182
183         g_dbus_error_register_error(NETCONFIG_ERROR_QUARK,
184                         NETCONFIG_ERROR_NO_PROFILE,
185                         "net.netconfig.Error.NoProfile");
186
187         g_dbus_error_register_error(NETCONFIG_ERROR_QUARK,
188                         NETCONFIG_ERROR_WRONG_PROFILE,
189                         "net.netconfig.Error.WrongProfile");
190
191         g_dbus_error_register_error(NETCONFIG_ERROR_QUARK,
192                         NETCONFIG_ERROR_INPROGRESS,
193                         "net.netconfig.Error.InProgress");
194
195         g_dbus_error_register_error(NETCONFIG_ERROR_QUARK,
196                         NETCONFIG_ERROR_ALREADYEXISTS,
197                         "net.netconfig.Error.AlreadyExists");
198
199         g_dbus_error_register_error(NETCONFIG_ERROR_QUARK,
200                         NETCONFIG_ERROR_INVALID_PARAMETER,
201                         "net.netconfig.Error.InvalidParameter");
202
203         g_dbus_error_register_error(NETCONFIG_ERROR_QUARK,
204                         NETCONFIG_ERROR_PERMISSION_DENIED,
205                         "net.netconfig.Error.PermissionDenied");
206
207         g_dbus_error_register_error(NETCONFIG_ERROR_QUARK,
208                         NETCONFIG_ERROR_WIFI_DRIVER_FAILURE,
209                         "net.netconfig.Error.WifiDriverFailed");
210
211         g_dbus_error_register_error(NETCONFIG_ERROR_QUARK,
212                         NETCONFIG_ERROR_FAILED_GET_IMSI,
213                         "net.netconfig.Error.FailGetSimImsi");
214
215         g_dbus_error_register_error(NETCONFIG_ERROR_QUARK,
216                         NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH,
217                         "net.netconfig.Error.FailReqSimAuthWrongParam");
218
219         g_dbus_error_register_error(NETCONFIG_ERROR_QUARK,
220                         NETCONFIG_ERROR_FAILED_REQ_SIM_AUTH_WRONG_PARAM,
221                         "net.netconfig.Error.FailReqSimAuthWrongParam");
222
223         g_dbus_error_register_error(NETCONFIG_ERROR_QUARK,
224                         NETCONFIG_ERROR_FAILED_GET_SIM_AUTH_WRONG_DATA,
225                         "net.netconfig.Error.FailGetSimAuthWrongData");
226
227         g_dbus_error_register_error(NETCONFIG_ERROR_QUARK,
228                         NETCONFIG_ERROR_FAILED_GET_SIM_AUTH_DELAY,
229                         "net.netconfig.Error.FailGetSimAuthDelay");
230 }