24 #include "syncml_internals.h"
25 #include "sml_error_internals.h"
49 if (SML_ERROR_UNKNOWN)
50 return "An unkown error occured.";
63 case SML_ERROR_MULTIPLE_CHOICES:
64 return "Multiple choices. The requested target is one of a number of " \
65 "multiple alternatives requested target. The alternative SHOULD " \
66 "also be returned in the Item element type in the Status.";
67 case SML_ERROR_MOVED_PERMANENTLY:
68 return "Moved permanently. The requested target has a new URI. The new " \
69 "URI SHOULD also be returned in the Item element type in the " \
71 case SML_ERROR_FOUND_RETRY:
72 return "Found. The requested target has temporarily moved to a different " \
73 "URI. The original URI SHOULD continue to be used. The URI of " \
74 "the temporary location SHOULD also be returned in the Item " \
75 "element type in the Status. The requestor SHOULD confirm the " \
76 "identity and authority of the temporary URI to act on behalf of the " \
77 "original target URI.";
78 case SML_ERROR_SEE_OTHER_RETRY:
79 return "See other. The requested target can be found at another URI. The " \
80 "other URI SHOULD be returned in the Item element type in the " \
82 case SML_ERROR_NOT_MODIFIED:
83 return "Not modified. The requested SyncML command was not executed " \
84 "on the target. This is an additional response that can be added to " \
85 "any of the other Redirection response codes.";
86 case SML_ERROR_USE_PROXY:
87 return "Use proxy. The requested target MUST be accessed through the " \
88 "specified proxy URI. The proxy URI SHOULD also be returned in " \
89 "the Item element type in the Status.";
92 case SML_ERROR_BAD_REQUEST:
93 return "Bad request. The requested command could not be performed " \
94 "because of malformed syntax in the command. The malformed " \
95 "command MAY also be returned in the Item element type in the " \
97 case SML_ERROR_AUTH_REJECTED:
98 return "Invalid credentials. The requested command failed because the " \
99 "requestor MUST provide proper authentication. If the property type " \
100 "of authentication was presented in the original request, then the " \
101 "response code indicates that the requested command has been " \
102 "refused for those credentials.";
103 case SML_ERROR_PAYMENT_NEEDED:
104 return "Paymentneeded. The requested command failed because proper " \
105 "payment isneeded. This version of SyncML does not standardize " \
106 "the payment mechanism.";
107 case SML_ERROR_FORBIDDEN:
108 return "Forbidden. The requested command failed, but the recipient " \
109 "understood the requested command. Authentication will not help " \
110 "and the request SHOULD NOT be repeated. If the recipient wishes " \
111 "to make public why the request was denied, then a description " \
112 "MAY be specified in the Item element type in the Status. If the " \
113 "recipient does not wish to make public why the request was denied " \
114 "then the response code 404 MAY be used instead.";
115 case SML_ERROR_NOT_FOUND:
116 return "Not found. The requested target was not found. No indication is " \
117 "given as to whether this is a temporary or permanent condition. The " \
118 "response code 410 SHOULD be used when the condition is " \
119 "permanent and the recipient wishes to make this fact public. This " \
120 "response code is also used when the recipient does not want to " \
121 "make public the reason for why a requested command is not " \
122 "allowed or when no other response code is appropriate.";
123 case SML_ERROR_UNSUPPORTED_FEATURE:
124 return "Optional feature not supported. The requested command failed " \
125 "because an OPTIONAL feature in the request was not supported. " \
126 "The unsupported feature SHOULD be specified by the Item " \
127 "element type in the Status.";
128 case SML_ERROR_RETRY_LATER:
129 return "Retry later. The request failed at this time and the originator " \
130 "SHOULD retry the request later. The recipient SHOULD specify a " \
131 "RespURI with the response URI and the date/time that the " \
132 "command SHOULD be repeated.";
133 case SML_ERROR_ALREADY_EXISTS:
134 return "Already exists. The requested Put or Add command failed " \
135 "because the target already exists.";
136 case SML_ERROR_SIZE_MISMATCH:
137 return "Size mismatch. The chunked object was received, but the size of " \
138 "the received object did not match the size declared within the first " \
142 case SML_ERROR_GENERIC:
143 return "Command failed. The recipient encountered an unexpected " \
144 "condition which prevented it from fulfilling the request.";
145 case SML_ERROR_NOT_IMPLEMENTED:
146 return "Command not implemented. The recipient does not support the " \
147 "command REQUIRED to fulfill the request. This is the appropriate " \
148 "response when the recipient does not recognize the requested " \
149 "command and is not capable of supporting it for any resource.";
150 case SML_ERROR_SERVICE_UNAVAILABLE:
151 return "Service unavailable. The recipient is currently unable to handle the " \
152 "request due to a temporary overloading or maintenance of the " \
153 "recipient. The implication is that this is a temporary condition; " \
154 "which will be alleviated after some delay. The recipient SHOULD " \
155 "specify the URI and date/time after which the originator SHOULD " \
156 "retry in the RespURI in the response.";
157 case SML_ERROR_REQUIRE_REFRESH:
158 return "RefreshREQUIRED. An error occurred that necessitates a refresh " \
159 "of the current synchronization state of the client with the server. " \
160 "Client is requested to initiate the session type specified in the " \
161 "server's ALERT (which is included in the same package as the " \
162 "Status 508). The only valid values for this ALERT are either a slow " \
163 "sync (201) or a refresh with the server.";
164 case SML_ERROR_SERVER_FAILURE:
165 return "Server failure. A severe error occurred in the server while " \
166 "processing the request. The originator SHOULD NOT retry the " \
170 case SML_ERROR_INTERNAL_IO_ERROR:
171 return "An internal I/O error occured.";
172 case SML_ERROR_INTERNAL_TIMEOUT:
173 return "An internal timeout occured.";
174 case SML_ERROR_INTERNAL_FILE_NOT_FOUND:
175 return "An internal error occured because of a missing file.";
176 case SML_ERROR_INTERNAL_MISCONFIGURATION:
177 return "An internal misconfiguration was detected.";
178 case SML_ERROR_INTERNAL_NO_MEMORY:
179 return "An internal I/O error occured.";
196 return_if_fail(error);
198 return_if_fail(format);
201 return_if_fail(*error);
202 (*error)->message = g_strdup_vprintf(format, args);
203 (*error)->type = type;
206 (*error)->printMessage = g_strdup((*error)->message);
207 }
else if (strlen(msg) == 0) {
208 (*error)->printMessage = g_strdup_printf(
213 (*error)->printMessage = g_strdup_printf(
218 (*error)->refCount = 1;
238 g_atomic_int_inc(&(*error)->refCount);
243 void smlErrorDeref(
SmlError **error)
248 if (!g_atomic_int_dec_and_test(&((*error)->refCount))) {
253 if ((*error)->message)
254 smlSafeCFree (&((*error)->message));
256 if ((*error)->printMessage)
257 smlSafeCFree (&((*error)->printMessage));
259 smlSafeFree((gpointer *)error);
290 return (*error)->type;
304 return (*error)->printMessage;
321 char *old = (*error)->message;
323 va_start(args, format);
324 (*error)->message = g_strdup_vprintf(format, args);
339 return_if_fail(target != NULL);
358 va_start(args, format);
371 return_if_fail(error != NULL);
373 (*error)->type = type;
385 return SML_ERRORCLASS_SUCCESS;
387 if ((*error)->type == SML_NO_ERROR)
388 return SML_ERRORCLASS_SUCCESS;
390 return (
int)((*error)->type / 100);