Create string tightly when retrive string from cbhm callback event
[framework/web/webkit-efl.git] / Source / WebKit2 / UIProcess / API / efl / ewk_error.h
1 /*
2  * Copyright (C) 2012 Intel Corporation. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 /**
27  * @file    ewk_error.h
28  * @brief   Describes the Web Error API.
29  */
30
31 #ifndef ewk_error_h
32 #define ewk_error_h
33
34 #include <Eina.h>
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39
40 /** Creates a type name for @a Ewk_Error. */
41 typedef struct Ewk_Error Ewk_Error;
42 typedef struct Ewk_Error Ewk_Web_Error; // deprecated, please use Ewk_Error
43
44 /// Creates a type name for Ewk_Error_Type.
45 typedef enum {
46     EWK_ERROR_TYPE_NONE,
47     EWK_ERROR_TYPE_INTERNAL,
48     EWK_ERROR_TYPE_NETWORK,
49     EWK_ERROR_TYPE_POLICY,
50     EWK_ERROR_TYPE_PLUGIN,
51     EWK_ERROR_TYPE_DOWNLOAD,
52     EWK_ERROR_TYPE_PRINT
53 } Ewk_Error_Type;
54
55 //#if OS(TIZEN)
56 typedef enum {
57     EWK_ERROR_CODE_CANNOTSHOWMIMETYPE = 100,
58     EWK_ERROR_CODE_CANNOTSHOWURL,
59     EWK_ERROR_CODE_FRAMELOADINTERRUPTEDBYPOLICYCHANGE,
60     EWK_ERROR_CODE_CANNOTUSERESTRICTEDPORT,
61     EWK_ERROR_CODE_CANNOTFINDPLUGIN = 200,
62     EWK_ERROR_CODE_CANNOTLOADPLUGIN,
63     EWK_ERROR_CODE_JAVAUNAVAILABLE,
64     EWK_ERROR_CODE_PLUGINCANCELLEDCONNECTION,
65     EWK_ERROR_CODE_PLUGINWILLHANDLELOAD,
66 } Ewk_Error_Code;
67
68 typedef enum {
69     EWK_ERROR_NETWORK_STATUS_NONE,
70
71     /* Transport Errors */
72     EWK_ERROR_NETWORK_STATUS_CANCELLED = 1,
73     EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE,
74     EWK_ERROR_NETWORK_STATUS_CANT_RESOLVE_PROXY,
75     EWK_ERROR_NETWORK_STATUS_CANT_CONNECT,
76     EWK_ERROR_NETWORK_STATUS_CANT_CONNECT_PROXY,
77     EWK_ERROR_NETWORK_STATUS_SSL_FAILED,
78     EWK_ERROR_NETWORK_STATUS_IO_ERROR,
79     EWK_ERROR_NETWORK_STATUS_MALFORMED,
80     EWK_ERROR_NETWORK_STATUS_TRY_AGAIN,
81     EWK_ERROR_NETWORK_STATUS_TOO_MANY_REDIRECTS,
82     EWK_ERROR_NETWORK_STATUS_TLS_FAILED,
83
84     /* HTTP Status Codes */
85     EWK_ERROR_NETWORK_STATUS_CONTINUE = 100,
86     EWK_ERROR_NETWORK_STATUS_SWITCHING_PROTOCOLS,
87     EWK_ERROR_NETWORK_STATUS_PROCESSING,
88
89     EWK_ERROR_NETWORK_STATUS_OK = 200,
90     EWK_ERROR_NETWORK_STATUS_CREATED,
91     EWK_ERROR_NETWORK_STATUS_ACCEPTED,
92     EWK_ERROR_NETWORK_STATUS_NON_AUTHORITATIVE,
93     EWK_ERROR_NETWORK_STATUS_NO_CONTENT,
94     EWK_ERROR_NETWORK_STATUS_RESET_CONTENT,
95     EWK_ERROR_NETWORK_STATUS_PARTIAL_CONTENT,
96     EWK_ERROR_NETWORK_STATUS_MULTI_STATUS,
97
98     EWK_ERROR_NETWORK_STATUS_MULTIPLE_CHOICES = 300,
99     EWK_ERROR_NETWORK_STATUS_MOVED_PERMANENTLY,
100     EWK_ERROR_NETWORK_STATUS_FOUND = 302,
101     EWK_ERROR_NETWORK_STATUS_MOVED_TEMPORARILY = 302,
102     EWK_ERROR_NETWORK_STATUS_SEE_OTHER,
103     EWK_ERROR_NETWORK_STATUS_NOT_MODIFIED,
104     EWK_ERROR_NETWORK_STATUS_USE_PROXY,
105     EWK_ERROR_NETWORK_STATUS_NOT_APPEARING_IN_THIS_PROTOCOL,
106     EWK_ERROR_NETWORK_STATUS_TEMPORARY_REDIRECT,
107
108     EWK_ERROR_NETWORK_STATUS_BAD_REQUEST = 400,
109     EWK_ERROR_NETWORK_STATUS_UNAUTHORIZED,
110     EWK_ERROR_NETWORK_STATUS_PAYMENT_REQUIRED,
111     EWK_ERROR_NETWORK_STATUS_FORBIDDEN,
112     EWK_ERROR_NETWORK_STATUS_NOT_FOUND,
113     EWK_ERROR_NETWORK_STATUS_METHOD_NOT_ALLOWED,
114     EWK_ERROR_NETWORK_STATUS_NOT_ACCEPTABLE,
115     EWK_ERROR_NETWORK_STATUS_PROXY_AUTHENTICATION_REQUIRED,
116     EWK_ERROR_NETWORK_STATUS_PROXY_UNAUTHORIZED = EWK_ERROR_NETWORK_STATUS_PROXY_AUTHENTICATION_REQUIRED,
117     EWK_ERROR_NETWORK_STATUS_REQUEST_TIMEOUT,
118     EWK_ERROR_NETWORK_STATUS_CONFLICT,
119     EWK_ERROR_NETWORK_STATUS_GONE,
120     EWK_ERROR_NETWORK_STATUS_LENGTH_REQUIRED,
121     EWK_ERROR_NETWORK_STATUS_PRECONDITION_FAILED,
122     EWK_ERROR_NETWORK_STATUS_REQUEST_ENTITY_TOO_LARGE,
123     EWK_ERROR_NETWORK_STATUS_REQUEST_URI_TOO_LONG,
124     EWK_ERROR_NETWORK_STATUS_UNSUPPORTED_MEDIA_TYPE,
125     EWK_ERROR_NETWORK_STATUS_REQUESTED_RANGE_NOT_SATISFIABLE,
126     EWK_ERROR_NETWORK_STATUS_INVALID_RANGE = EWK_ERROR_NETWORK_STATUS_REQUESTED_RANGE_NOT_SATISFIABLE,
127     EWK_ERROR_NETWORK_STATUS_EXPECTATION_FAILED,
128     EWK_ERROR_NETWORK_STATUS_UNPROCESSABLE_ENTITY = 422,
129     EWK_ERROR_NETWORK_STATUS_LOCKED,
130     EWK_ERROR_NETWORK_STATUS_FAILED_DEPENDENCY,
131
132     EWK_ERROR_NETWORK_STATUS_INTERNAL_SERVER_ERROR = 500,
133     EWK_ERROR_NETWORK_STATUS_NOT_IMPLEMENTED,
134     EWK_ERROR_NETWORK_STATUS_BAD_GATEWAY,
135     EWK_ERROR_NETWORK_STATUS_SERVICE_UNAVAILABLE,
136     EWK_ERROR_NETWORK_STATUS_GATEWAY_TIMEOUT,
137     EWK_ERROR_NETWORK_STATUS_HTTP_VERSION_NOT_SUPPORTED,
138     EWK_ERROR_NETWORK_STATUS_INSUFFICIENT_STORAGE = 507,
139     EWK_ERROR_NETWORK_STATUS_NOT_EXTENDED = 510
140 } Ewk_Error_Network_Status;
141
142 typedef enum {
143     EWK_ERROR_IO_CODE_FAILED,
144     EWK_ERROR_IO_CODE_NOT_FOUND,
145     EWK_ERROR_IO_CODE_EXISTS,
146     EWK_ERROR_IO_CODE_IS_DIRECTORY,
147     EWK_ERROR_IO_CODE_NOT_DIRECTORY,
148     EWK_ERROR_IO_CODE_NOT_EMPTY,
149     EWK_ERROR_IO_CODE_NOT_REGULAR_FILE,
150     EWK_ERROR_IO_CODE_NOT_SYMBOLIC_LINK,
151     EWK_ERROR_IO_CODE_NOT_MOUNTABLE_FILE,
152     EWK_ERROR_IO_CODE_FILENAME_TOO_LONG,
153     EWK_ERROR_IO_CODE_INVALID_FILENAME,
154     EWK_ERROR_IO_CODE_TOO_MANY_LINKS,
155     EWK_ERROR_IO_CODE_NO_SPACE,
156     EWK_ERROR_IO_CODE_INVALID_ARGUMENT,
157     EWK_ERROR_IO_CODE_PERMISSION_DENIED,
158     EWK_ERROR_IO_CODE_NOT_SUPPORTED,
159     EWK_ERROR_IO_CODE_NOT_MOUNTED,
160     EWK_ERROR_IO_CODE_ALREADY_MOUNTED,
161     EWK_ERROR_IO_CODE_CLOSED,
162     EWK_ERROR_IO_CODE_CANCELLED,
163     EWK_ERROR_IO_CODE_PENDING,
164     EWK_ERROR_IO_CODE_READ_ONLY,
165     EWK_ERROR_IO_CODE_CANT_CREATE_BACKUP,
166     EWK_ERROR_IO_CODE_WRONG_ETAG,
167     EWK_ERROR_IO_CODE_TIMED_OUT,
168     EWK_ERROR_IO_CODE_WOULD_RECURSE,
169     EWK_ERROR_IO_CODE_BUSY,
170     EWK_ERROR_IO_CODE_WOULD_BLOCK,
171     EWK_ERROR_IO_CODE_HOST_NOT_FOUND,
172     EWK_ERROR_IO_CODE_WOULD_MERGE,
173     EWK_ERROR_IO_CODE_FAILED_HANDLED,
174     EWK_ERROR_IO_CODE_TOO_MANY_OPEN_FILES,
175     EWK_ERROR_IO_CODE_NOT_INITIALIZED,
176     EWK_ERROR_IO_CODE_ADDRESS_IN_USE,
177     EWK_ERROR_IO_CODE_PARTIAL_INPUT,
178     EWK_ERROR_IO_CODE_INVALID_DATA,
179     EWK_ERROR_IO_CODE_DBUS_ERROR,
180     EWK_ERROR_IO_CODE_HOST_UNREACHABLE,
181     EWK_ERROR_IO_CODE_NETWORK_UNREACHABLE,
182     EWK_ERROR_IO_CODE_CONNECTION_REFUSED,
183     EWK_ERROR_IO_CODE_PROXY_FAILED,
184     EWK_ERROR_IO_CODE_PROXY_AUTH_FAILED,
185     EWK_ERROR_IO_CODE_PROXY_NEED_AUTH,
186     EWK_ERROR_IO_CODE_PROXY_NOT_ALLOWED
187 } Ewk_Error_Io_Code;
188 //#endif
189
190 /**
191  * Query type for this error.
192  *
193  * @param error error object to query.
194  *
195  * @return the error type, that may be @c NULL. This pointer is
196  *         guaranteed to be eina_stringshare, so whenever possible
197  *         save yourself some cpu cycles and use
198  *         eina_stringshare_ref() instead of eina_stringshare_add() or
199  *         strdup().
200  */
201 EAPI Ewk_Error_Type ewk_error_type_get(const Ewk_Error *error);
202
203 /**
204  * Query failing URL for this error.
205  *
206  * URL that failed loading.
207  *
208  * @param error error object to query.
209  *
210  * @return the URL pointer, that may be @c NULL. This pointer is
211  *         guaranteed to be eina_stringshare, so whenever possible
212  *         save yourself some cpu cycles and use
213  *         eina_stringshare_ref() instead of eina_stringshare_add() or
214  *         strdup().
215  */
216 EAPI const char *ewk_error_url_get(const Ewk_Error *error);
217
218 /**
219  * Query HTTP error code.
220  *
221  * @param error error object to query.
222  *
223  * #if OS(TIZEN)
224  * @note If ewk_error_domain_get returns "WebKitErrorDomain", the error code represents Ewk_Error_Code.
225  *       If "soup_http_error_quark", it represents Ewk_Error_Network_Status.
226  *       If "g-io-error-quark", it represents Ewk_Error_Io_Code.
227  * #endif
228  *
229  * @return the HTTP error code.
230  */
231 EAPI int ewk_error_code_get(const Ewk_Error *error);
232
233 /**
234  * Query description for this error.
235  *
236  * @param error error object to query.
237  *
238  * @return the description pointer, that may be @c NULL. This pointer is
239  *         guaranteed to be eina_stringshare, so whenever possible
240  *         save yourself some cpu cycles and use
241  *         eina_stringshare_ref() instead of eina_stringshare_add() or
242  *         strdup().
243  */
244 EAPI const char *ewk_error_description_get(const Ewk_Error *error);
245
246 /**
247  * Query if error should be treated as a cancellation.
248  *
249  * @param error error object to query.
250  *
251  * @return @c EINA_TRUE if this error should be treated as a cancellation, @c EINA_FALSE otherwise
252  */
253 EAPI Eina_Bool ewk_error_cancellation_get(const Ewk_Error *error);
254
255 //#if OS(TIZEN)
256 /**
257  * Returns domain from Ewk_Error.
258  *
259  * @param error Ewk_Error object received from "load,error" evas object smart callback
260  *
261  * @return @c domain string on success or empty string on failure
262  */
263 EAPI const char* ewk_error_domain_get(const Ewk_Error* error);
264 //#endif
265
266 #ifdef __cplusplus
267 }
268 #endif
269
270 #endif // ewk_error_h