2 * Copyright (C) 2006, 2007 OpenedHand Ltd.
4 * Author: Jorn Baayen <jorn@openedhand.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
22 #include "gupnp-error.h"
23 #include "gupnp-error-private.h"
27 * @short_description: Error domains and codes.
33 * The #GQuark uniquely used by GUPnP's server errors.
35 * Returns: a #GQuark uniquely used by GUPnP's server errors.
38 gupnp_server_error_quark (void)
40 static GQuark quark = 0;
43 quark = g_quark_from_static_string ("gupnp-server-error");
49 * GUPNP_EVENTING_ERROR:
51 * The #GQuark uniquely used by GUPnP's eventing errors.
53 * Returns: a #GQuark uniquely used by GUPnP's eventing errors.
56 gupnp_eventing_error_quark (void)
58 static GQuark quark = 0;
61 quark = g_quark_from_static_string ("gupnp-eventing-error");
67 * GUPNP_CONTROL_ERROR:
69 * The #GQuark uniquely used by GUPnP's control errors.
71 * Returns: a #GQuark uniquely used by GUPnP's control errors.
74 gupnp_control_error_quark (void)
76 static GQuark quark = 0;
79 quark = g_quark_from_static_string ("gupnp-control-error");
87 * The #GQuark uniquely used by GUPnP XML processing errors.
89 * Returns: a #GQuark uniquely used by GUPnP XML processing errors.
92 gupnp_xml_error_quark (void)
94 static GQuark quark = 0;
97 quark = g_quark_from_static_string ("gupnp-xml-error");
102 /* Soup status code => GUPnPServerError */
104 code_from_status_code (int status_code)
106 switch (status_code) {
107 case SOUP_STATUS_INTERNAL_SERVER_ERROR:
108 return GUPNP_SERVER_ERROR_INTERNAL_SERVER_ERROR;
109 case SOUP_STATUS_NOT_IMPLEMENTED:
110 return GUPNP_SERVER_ERROR_NOT_IMPLEMENTED;
111 case SOUP_STATUS_NOT_FOUND:
112 return GUPNP_SERVER_ERROR_NOT_FOUND;
114 return GUPNP_SERVER_ERROR_OTHER;
118 /* Set status of @msg to @error */
120 _gupnp_error_set_server_error (GError **error,
123 g_set_error_literal (error,
125 code_from_status_code (msg->status_code),
129 /* Create a #GError with status of @msg */
131 _gupnp_error_new_server_error (SoupMessage *msg)
133 return g_error_new_literal (GUPNP_SERVER_ERROR,
134 code_from_status_code (msg->status_code),