Debian Codegraph @

libgupnp-av/gupnp-feature.c

raw symbols SCIP
1 /*
2 * Copyright (C) 2012 Intel Corporation
3 *
4 * Authors: Regis Merlino <[email protected]>
5 *
6 * SPDX-License-Identifier: LGPL-2.1-or-later
7 *
8 */
9
10 /**
11 * GUPnPFeature:
12 *
13 * ContentDirectory feature
14 *
15 * #GUPnPFeature respresent a Feature element.
16 */
17
18 #include <config.h>
19
20 #include "gupnp-feature.h"
21
22 struct _GUPnPFeaturePrivate {
23 char *name;
24 char *version;
25 char *object_ids;
26 };
27 typedef struct _GUPnPFeaturePrivate GUPnPFeaturePrivate;
28
29 G_DEFINE_TYPE_WITH_PRIVATE (GUPnPFeature,
30 gupnp_feature,
31 G_TYPE_OBJECT)
32
33 enum {
34 PROP_0,
35 PROP_NAME,
36 PROP_VERSION,
37 PROP_OBJECT_IDS
38 };
39
40 static void
41 gupnp_feature_init (GUPnPFeature *object)
42 {
43 }
44
45 static void
46 gupnp_feature_finalize (GObject *object)
47 {
48 GObjectClass *object_class;
49 GUPnPFeaturePrivate *priv;
50
51 priv = gupnp_feature_get_instance_private (GUPNP_FEATURE (object));
52
53 g_free (priv->name);
54 g_free (priv->version);
55 g_free (priv->object_ids);
56
57 object_class = G_OBJECT_CLASS (gupnp_feature_parent_class);
58 object_class->finalize (object);
59 }
60
61 static void
62 gupnp_feature_get_property (GObject *object,
63 guint property_id,
64 GValue *value,
65 GParamSpec *pspec)
66 {
67 GUPnPFeature *feature;
68
69 feature = GUPNP_FEATURE (object);
70
71 switch (property_id) {
72 case PROP_NAME:
73 g_value_set_string (value, gupnp_feature_get_name (feature));
74 break;
75 case PROP_VERSION:
76 g_value_set_string (value, gupnp_feature_get_version (feature));
77 break;
78 case PROP_OBJECT_IDS:
79 g_value_set_string (value,
80 gupnp_feature_get_object_ids (feature));
81 break;
82 default:
83 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
84 break;
85 }
86 }
87
88 static void
89 gupnp_feature_set_property (GObject *object,
90 guint property_id,
91 const GValue *value,
92 GParamSpec *pspec)
93 {
94 GUPnPFeaturePrivate *priv =
95 gupnp_feature_get_instance_private (GUPNP_FEATURE (object));
96
97 switch (property_id) {
98 case PROP_NAME:
99 priv->name = g_value_dup_string (value);
100 break;
101 case PROP_VERSION:
102 priv->version = g_value_dup_string (value);
103 break;
104 case PROP_OBJECT_IDS:
105 priv->object_ids = g_value_dup_string (value);
106 break;
107 default:
108 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
109 break;
110 }
111 }
112
113 static void
114 gupnp_feature_class_init (GUPnPFeatureClass *klass)
115 {
116 GObjectClass *object_class;
117
118 object_class = G_OBJECT_CLASS (klass);
119
120 object_class->get_property = gupnp_feature_get_property;
121 object_class->set_property = gupnp_feature_set_property;
122 object_class->finalize = gupnp_feature_finalize;
123
124 /**
125 * GUPnPFeature:name:
126 *
127 * The name of this feature.
128 **/
129 g_object_class_install_property
130 (object_class,
131 PROP_NAME,
132 g_param_spec_string ("name",
133 "Name",
134 "The name of this feature.",
135 NULL,
136 G_PARAM_READWRITE |
137 G_PARAM_CONSTRUCT_ONLY |
138 G_PARAM_STATIC_NAME |
139 G_PARAM_STATIC_NICK |
140 G_PARAM_STATIC_BLURB));
141
142 /**
143 * GUPnPFeature:version:
144 *
145 * The version of this feature.
146 **/
147 g_object_class_install_property
148 (object_class,
149 PROP_VERSION,
150 g_param_spec_string ("version",
151 "Version",
152 "The version of this feature.",
153 NULL,
154 G_PARAM_READWRITE |
155 G_PARAM_CONSTRUCT_ONLY |
156 G_PARAM_STATIC_NAME |
157 G_PARAM_STATIC_NICK |
158 G_PARAM_STATIC_BLURB));
159
160 /**
161 * GUPnPFeature:object-ids:
162 *
163 * The object IDs related to this feature.
164 **/
165 g_object_class_install_property
166 (object_class,
167 PROP_OBJECT_IDS,
168 g_param_spec_string ("object-ids",
169 "Object IDs",
170 "The object IDs of this feature.",
171 NULL,
172 G_PARAM_READWRITE |
173 G_PARAM_CONSTRUCT_ONLY |
174 G_PARAM_STATIC_NAME |
175 G_PARAM_STATIC_NICK |
176 G_PARAM_STATIC_BLURB));
177 }
178
179 /**
180 * gupnp_feature_get_name:
181 * @feature: #GUPnPFeature
182 *
183 * Get the name of the @feature.
184 *
185 * Return value: The name of the @feature.
186 **/
187 const char *
188 gupnp_feature_get_name (GUPnPFeature *feature)
189 {
190 GUPnPFeaturePrivate *priv =
191 gupnp_feature_get_instance_private (GUPNP_FEATURE (feature));
192
193 return priv->name;
194 }
195
196 /**
197 * gupnp_feature_get_version:
198 * @feature: #GUPnPFeature
199 *
200 * Get the version of the @feature.
201 *
202 * Return value: The version of the @feature.
203 **/
204 const char *
205 gupnp_feature_get_version (GUPnPFeature *feature)
206 {
207 GUPnPFeaturePrivate *priv =
208 gupnp_feature_get_instance_private (GUPNP_FEATURE (feature));
209
210 return priv->version;
211 }
212
213 /**
214 * gupnp_feature_get_object_ids:
215 * @feature: #GUPnPFeature
216 *
217 * Get the object IDs related to the @feature.
218 *
219 * Return value: The object IDs related to the @feature.
220 **/
221 const char *
222 gupnp_feature_get_object_ids (GUPnPFeature *feature)
223 {
224 GUPnPFeaturePrivate *priv =
225 gupnp_feature_get_instance_private (GUPNP_FEATURE (feature));
226
227 return priv->object_ids;
228 }