2 * Copyright (C) 2007 Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
3 * Copyright (C) 2006, 2007 OpenedHand Ltd.
5 * Author: Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
25 * @short_description: Extra types for use when calling UPnP actions.
27 * These GTypes are used to marshal to and from string data to particular UPnP
28 * types when invoking actions on a #GUPnPServiceProxy.
33 #include "gupnp-types.h"
34 #include "gupnp-types-private.h"
37 gupnp_string_type_to_string (const GValue *src_value,
42 str = gupnp_value_get_string (src_value);
44 g_value_set_string (dest_value, str);
48 gupnp_string_to_string_type (const GValue *src_value,
53 str = g_value_get_string (src_value);
55 g_value_set_boxed (dest_value, str);
59 register_string_type (const char *name)
63 type = g_boxed_type_register_static (
64 g_intern_static_string (name),
65 (GBoxedCopyFunc) g_strdup,
66 (GBoxedFreeFunc) g_free);
67 g_value_register_transform_func (
70 gupnp_string_type_to_string);
71 g_value_register_transform_func (
74 gupnp_string_to_string_type);
80 gupnp_bin_base64_get_type (void)
82 static GType type = 0;
85 type = register_string_type ("GUPnPBinBase64");
91 gupnp_bin_hex_get_type (void)
93 static GType type = 0;
96 type = register_string_type ("GUPnPBinHex");
102 gupnp_date_get_type (void)
104 static GType type = 0;
107 type = register_string_type ("GUPnPDate");
113 gupnp_date_time_get_type (void)
115 static GType type = 0;
118 type = register_string_type ("GUPnPDateTime");
124 gupnp_date_time_tz_get_type (void)
126 static GType type = 0;
129 type = register_string_type ("GUPnPDateTimeTZ");
135 gupnp_time_get_type (void)
137 static GType type = 0;
140 type = register_string_type ("GUPnPTime");
146 gupnp_time_tz_get_type (void)
148 static GType type = 0;
151 type = register_string_type ("GUPnPTimeTZ");
157 gupnp_uri_get_type (void)
159 static GType type = 0;
162 type = register_string_type ("GUPnPURI");
168 gupnp_uuid_get_type (void)
170 static GType type = 0;
173 type = register_string_type ("GUPnPUUID");
179 gupnp_data_type_to_gtype (const char *data_type)
181 if (g_ascii_strcasecmp ("UUID", data_type) == 0)
182 return GUPNP_TYPE_UUID;
183 else if (g_ascii_strcasecmp ("URI", data_type) == 0)
184 return GUPNP_TYPE_URI;
185 else if (g_ascii_strcasecmp ("time.tz", data_type) == 0)
186 return GUPNP_TYPE_TIME_TZ;
187 else if (g_ascii_strcasecmp ("dateTime.tz", data_type) == 0)
188 return GUPNP_TYPE_DATE_TIME_TZ;
189 else if (g_ascii_strcasecmp ("dateTime", data_type) == 0)
190 return GUPNP_TYPE_DATE_TIME;
191 else if (g_ascii_strcasecmp ("date", data_type) == 0)
192 return GUPNP_TYPE_DATE;
193 else if (g_ascii_strcasecmp ("time", data_type) == 0)
194 return GUPNP_TYPE_TIME;
195 else if (g_ascii_strcasecmp ("bin.base64", data_type) == 0)
196 return GUPNP_TYPE_BIN_BASE64;
197 else if (g_ascii_strcasecmp ("bin.hex", data_type) == 0)
198 return GUPNP_TYPE_BIN_BASE64;
200 return G_TYPE_INVALID;