1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
2 /*
3  * GData Client
4  * Copyright (C) Philip Withnall 2009–2010 <philip@tecnocode.co.uk>
5  *
6  * GData Client is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * GData Client 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  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with GData Client.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 /**
21  * SECTION:gdata-gd-phone-number
22  * @short_description: GData phone number element
23  * @stability: Stable
24  * @include: gdata/gd/gdata-gd-phone-number.h
25  *
26  * #GDataGDPhoneNumber represents a "phoneNumber" element from the
27  * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdPhoneNumber">GData specification</ulink>.
28  *
29  * Since: 0.4.0
30  */
31 
32 #include <glib.h>
33 #include <libxml/parser.h>
34 #include <string.h>
35 
36 #include "gdata-gd-phone-number.h"
37 #include "gdata-parsable.h"
38 #include "gdata-parser.h"
39 #include "gdata-comparable.h"
40 
41 static void gdata_gd_phone_number_comparable_init (GDataComparableIface *iface);
42 static void gdata_gd_phone_number_finalize (GObject *object);
43 static void gdata_gd_phone_number_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
44 static void gdata_gd_phone_number_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
45 static gboolean pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error);
46 static gboolean parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error);
47 static void pre_get_xml (GDataParsable *parsable, GString *xml_string);
48 static void get_xml (GDataParsable *parsable, GString *xml_string);
49 static void get_namespaces (GDataParsable *parsable, GHashTable *namespaces);
50 
51 struct _GDataGDPhoneNumberPrivate {
52 	gchar *number;
53 	gchar *uri;
54 	gchar *relation_type;
55 	gchar *label;
56 	gboolean is_primary;
57 };
58 
59 enum {
60 	PROP_NUMBER = 1,
61 	PROP_URI,
62 	PROP_RELATION_TYPE,
63 	PROP_LABEL,
64 	PROP_IS_PRIMARY
65 };
66 
G_DEFINE_TYPE_WITH_CODE(GDataGDPhoneNumber,gdata_gd_phone_number,GDATA_TYPE_PARSABLE,G_IMPLEMENT_INTERFACE (GDATA_TYPE_COMPARABLE,gdata_gd_phone_number_comparable_init))67 G_DEFINE_TYPE_WITH_CODE (GDataGDPhoneNumber, gdata_gd_phone_number, GDATA_TYPE_PARSABLE,
68                          G_IMPLEMENT_INTERFACE (GDATA_TYPE_COMPARABLE, gdata_gd_phone_number_comparable_init))
69 
70 static void
71 gdata_gd_phone_number_class_init (GDataGDPhoneNumberClass *klass)
72 {
73 	GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
74 	GDataParsableClass *parsable_class = GDATA_PARSABLE_CLASS (klass);
75 
76 	g_type_class_add_private (klass, sizeof (GDataGDPhoneNumberPrivate));
77 
78 	gobject_class->get_property = gdata_gd_phone_number_get_property;
79 	gobject_class->set_property = gdata_gd_phone_number_set_property;
80 	gobject_class->finalize = gdata_gd_phone_number_finalize;
81 
82 	parsable_class->pre_parse_xml = pre_parse_xml;
83 	parsable_class->parse_xml = parse_xml;
84 	parsable_class->pre_get_xml = pre_get_xml;
85 	parsable_class->get_xml = get_xml;
86 	parsable_class->get_namespaces = get_namespaces;
87 	parsable_class->element_name = "phoneNumber";
88 	parsable_class->element_namespace = "gd";
89 
90 	/**
91 	 * GDataGDPhoneNumber:number:
92 	 *
93 	 * Human-readable phone number; may be in any telephone number format.
94 	 *
95 	 * For more information, see the
96 	 * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdPhoneNumber">GData specification</ulink>.
97 	 *
98 	 * Since: 0.4.0
99 	 */
100 	g_object_class_install_property (gobject_class, PROP_NUMBER,
101 	                                 g_param_spec_string ("number",
102 	                                                      "Number", "Human-readable phone number; may be in any telephone number format.",
103 	                                                      NULL,
104 	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
105 
106 	/**
107 	 * GDataGDPhoneNumber:uri:
108 	 *
109 	 * An optional "tel URI" used to represent the number in a formal way. Useful for programmatic access, such as a VoIP/PSTN bridge.
110 	 *
111 	 * For more information, see the
112 	 * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdPhoneNumber">GData specification</ulink>.
113 	 *
114 	 * Since: 0.4.0
115 	 */
116 	g_object_class_install_property (gobject_class, PROP_URI,
117 	                                 g_param_spec_string ("uri",
118 	                                                      "URI", "An optional \"tel URI\" used to represent the number in a formal way.",
119 	                                                      NULL,
120 	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
121 
122 	/**
123 	 * GDataGDPhoneNumber:relation-type:
124 	 *
125 	 * A programmatic value that identifies the type of phone number. For example: %GDATA_GD_PHONE_NUMBER_WORK or %GDATA_GD_PHONE_NUMBER_PAGER.
126 	 *
127 	 * For more information, see the
128 	 * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdPhoneNumber">GData specification</ulink>.
129 	 *
130 	 * Since: 0.4.0
131 	 */
132 	g_object_class_install_property (gobject_class, PROP_RELATION_TYPE,
133 	                                 g_param_spec_string ("relation-type",
134 	                                                      "Relation type", "A programmatic value that identifies the type of phone number.",
135 	                                                      NULL,
136 	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
137 
138 	/**
139 	 * GDataGDPhoneNumber:label:
140 	 *
141 	 * A simple string value used to name this phone number. It allows UIs to display a label such as "Mobile", "Home", "Work", etc.
142 	 *
143 	 * For more information, see the
144 	 * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdPhoneNumber">GData specification</ulink>.
145 	 *
146 	 * Since: 0.4.0
147 	 */
148 	g_object_class_install_property (gobject_class, PROP_LABEL,
149 	                                 g_param_spec_string ("label",
150 	                                                      "Label", "A simple string value used to name this phone number.",
151 	                                                      NULL,
152 	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
153 
154 	/**
155 	 * GDataGDPhoneNumber:is-primary:
156 	 *
157 	 * Indicates which phone number out of a group is primary.
158 	 *
159 	 * For more information, see the
160 	 * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdPhoneNumber">GData specification</ulink>.
161 	 *
162 	 * Since: 0.4.0
163 	 */
164 	g_object_class_install_property (gobject_class, PROP_IS_PRIMARY,
165 	                                 g_param_spec_boolean ("is-primary",
166 	                                                       "Primary?", "Indicates which phone number out of a group is primary.",
167 	                                                       FALSE,
168 	                                                       G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
169 }
170 
171 static gint
compare_with(GDataComparable * self,GDataComparable * other)172 compare_with (GDataComparable *self, GDataComparable *other)
173 {
174 	GDataGDPhoneNumber *a = (GDataGDPhoneNumber*) self, *b = (GDataGDPhoneNumber*) other;
175 	gint number_comparison, uri_comparison;
176 
177 	number_comparison = g_strcmp0 (a->priv->number, b->priv->number);
178 	uri_comparison = g_strcmp0 (a->priv->uri, b->priv->uri);
179 
180 	/* NULL URIs should not compare equal. */
181 	if (a->priv->uri == NULL && b->priv->uri == NULL) {
182 		uri_comparison = 1;
183 	}
184 
185 	/* If the numbers or the URIs are equal, the objects are equal. */
186 	if (number_comparison == 0 || uri_comparison == 0) {
187 		return 0;
188 	}
189 
190 	return number_comparison;
191 }
192 
193 static void
gdata_gd_phone_number_comparable_init(GDataComparableIface * iface)194 gdata_gd_phone_number_comparable_init (GDataComparableIface *iface)
195 {
196 	iface->compare_with = compare_with;
197 }
198 
199 static void
gdata_gd_phone_number_init(GDataGDPhoneNumber * self)200 gdata_gd_phone_number_init (GDataGDPhoneNumber *self)
201 {
202 	self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GDATA_TYPE_GD_PHONE_NUMBER, GDataGDPhoneNumberPrivate);
203 }
204 
205 static void
gdata_gd_phone_number_finalize(GObject * object)206 gdata_gd_phone_number_finalize (GObject *object)
207 {
208 	GDataGDPhoneNumberPrivate *priv = GDATA_GD_PHONE_NUMBER (object)->priv;
209 
210 	g_free (priv->number);
211 	g_free (priv->uri);
212 	g_free (priv->relation_type);
213 	g_free (priv->label);
214 
215 	/* Chain up to the parent class */
216 	G_OBJECT_CLASS (gdata_gd_phone_number_parent_class)->finalize (object);
217 }
218 
219 static void
gdata_gd_phone_number_get_property(GObject * object,guint property_id,GValue * value,GParamSpec * pspec)220 gdata_gd_phone_number_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
221 {
222 	GDataGDPhoneNumberPrivate *priv = GDATA_GD_PHONE_NUMBER (object)->priv;
223 
224 	switch (property_id) {
225 		case PROP_NUMBER:
226 			g_value_set_string (value, priv->number);
227 			break;
228 		case PROP_URI:
229 			g_value_set_string (value, priv->uri);
230 			break;
231 		case PROP_RELATION_TYPE:
232 			g_value_set_string (value, priv->relation_type);
233 			break;
234 		case PROP_LABEL:
235 			g_value_set_string (value, priv->label);
236 			break;
237 		case PROP_IS_PRIMARY:
238 			g_value_set_boolean (value, priv->is_primary);
239 			break;
240 		default:
241 			/* We don't have any other property... */
242 			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
243 			break;
244 	}
245 }
246 
247 static void
gdata_gd_phone_number_set_property(GObject * object,guint property_id,const GValue * value,GParamSpec * pspec)248 gdata_gd_phone_number_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
249 {
250 	GDataGDPhoneNumber *self = GDATA_GD_PHONE_NUMBER (object);
251 
252 	switch (property_id) {
253 		case PROP_NUMBER:
254 			gdata_gd_phone_number_set_number (self, g_value_get_string (value));
255 			break;
256 		case PROP_URI:
257 			gdata_gd_phone_number_set_uri (self, g_value_get_string (value));
258 			break;
259 		case PROP_RELATION_TYPE:
260 			gdata_gd_phone_number_set_relation_type (self, g_value_get_string (value));
261 			break;
262 		case PROP_LABEL:
263 			gdata_gd_phone_number_set_label (self, g_value_get_string (value));
264 			break;
265 		case PROP_IS_PRIMARY:
266 			gdata_gd_phone_number_set_is_primary (self, g_value_get_boolean (value));
267 			break;
268 		default:
269 			/* We don't have any other property... */
270 			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
271 			break;
272 	}
273 }
274 
275 static gboolean
pre_parse_xml(GDataParsable * parsable,xmlDoc * doc,xmlNode * root_node,gpointer user_data,GError ** error)276 pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error)
277 {
278 	xmlChar *number, *rel;
279 	gboolean primary_bool;
280 	GDataGDPhoneNumberPrivate *priv = GDATA_GD_PHONE_NUMBER (parsable)->priv;
281 
282 	/* Is it the primary phone number? */
283 	if (gdata_parser_boolean_from_property (root_node, "primary", &primary_bool, 0, error) == FALSE)
284 		return FALSE;
285 
286 	number = xmlNodeListGetString (doc, root_node->children, TRUE);
287 	if (number == NULL || *number == '\0') {
288 		xmlFree (number);
289 		return gdata_parser_error_required_content_missing (root_node, error);
290 	}
291 
292 	rel = xmlGetProp (root_node, (xmlChar*) "rel");
293 	if (rel != NULL && *rel == '\0') {
294 		xmlFree (rel);
295 		xmlFree (number);
296 		return gdata_parser_error_required_property_missing (root_node, "rel", error);
297 	}
298 
299 	gdata_gd_phone_number_set_number (GDATA_GD_PHONE_NUMBER (parsable), (gchar*) number);
300 	priv->uri = (gchar*) xmlGetProp (root_node, (xmlChar*) "uri");
301 	priv->relation_type = (gchar*) rel;
302 	priv->label = (gchar*) xmlGetProp (root_node, (xmlChar*) "label");
303 	priv->is_primary = primary_bool;
304 
305 	xmlFree (number);
306 
307 	return TRUE;
308 }
309 
310 static gboolean
parse_xml(GDataParsable * parsable,xmlDoc * doc,xmlNode * node,gpointer user_data,GError ** error)311 parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error)
312 {
313 	/* Textual content's handled in pre_parse_xml */
314 	if (node->type != XML_ELEMENT_NODE)
315 		return TRUE;
316 
317 	return GDATA_PARSABLE_CLASS (gdata_gd_phone_number_parent_class)->parse_xml (parsable, doc, node, user_data, error);
318 }
319 
320 static void
pre_get_xml(GDataParsable * parsable,GString * xml_string)321 pre_get_xml (GDataParsable *parsable, GString *xml_string)
322 {
323 	GDataGDPhoneNumberPrivate *priv = GDATA_GD_PHONE_NUMBER (parsable)->priv;
324 
325 	if (priv->uri != NULL)
326 		gdata_parser_string_append_escaped (xml_string, " uri='", priv->uri, "'");
327 	if (priv->relation_type != NULL)
328 		gdata_parser_string_append_escaped (xml_string, " rel='", priv->relation_type, "'");
329 	if (priv->label != NULL)
330 		gdata_parser_string_append_escaped (xml_string, " label='", priv->label, "'");
331 
332 	if (priv->is_primary == TRUE)
333 		g_string_append (xml_string, " primary='true'");
334 	else
335 		g_string_append (xml_string, " primary='false'");
336 }
337 
338 static void
get_xml(GDataParsable * parsable,GString * xml_string)339 get_xml (GDataParsable *parsable, GString *xml_string)
340 {
341 	gdata_parser_string_append_escaped (xml_string, NULL, GDATA_GD_PHONE_NUMBER (parsable)->priv->number, NULL);
342 }
343 
344 static void
get_namespaces(GDataParsable * parsable,GHashTable * namespaces)345 get_namespaces (GDataParsable *parsable, GHashTable *namespaces)
346 {
347 	g_hash_table_insert (namespaces, (gchar*) "gd", (gchar*) "http://schemas.google.com/g/2005");
348 }
349 
350 /**
351  * gdata_gd_phone_number_new:
352  * @number: the phone number, in human-readable format
353  * @relation_type: (allow-none): the relationship between the phone number and its owner, or %NULL
354  * @label: (allow-none): a human-readable label for the phone number, or %NULL
355  * @uri: (allow-none): a "tel URI" to represent the number formally (see
356  * <ulink type="http" url="http://www.ietf.org/rfc/rfc3966.txt">RFC 3966</ulink>), or %NULL
357  * @is_primary: %TRUE if this phone number is its owner's primary number, %FALSE otherwise
358  *
359  * Creates a new #GDataGDPhoneNumber. More information is available in the <ulink type="http"
360  * url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdPhoneNumber">GData specification</ulink>.
361  *
362  * Return value: a new #GDataGDPhoneNumber, or %NULL; unref with g_object_unref()
363  *
364  * Since: 0.2.0
365  */
366 GDataGDPhoneNumber *
gdata_gd_phone_number_new(const gchar * number,const gchar * relation_type,const gchar * label,const gchar * uri,gboolean is_primary)367 gdata_gd_phone_number_new (const gchar *number, const gchar *relation_type, const gchar *label, const gchar *uri, gboolean is_primary)
368 {
369 	g_return_val_if_fail (number != NULL && *number != '\0', NULL);
370 	g_return_val_if_fail (relation_type == NULL || *relation_type != '\0', NULL);
371 	return g_object_new (GDATA_TYPE_GD_PHONE_NUMBER, "number", number, "uri", uri, "relation-type", relation_type,
372 	                     "label", label, "is-primary", is_primary, NULL);
373 }
374 
375 /**
376  * gdata_gd_phone_number_get_number:
377  * @self: a #GDataGDPhoneNumber
378  *
379  * Gets the #GDataGDPhoneNumber:number property.
380  *
381  * Return value: the phone number itself
382  *
383  * Since: 0.4.0
384  */
385 const gchar *
gdata_gd_phone_number_get_number(GDataGDPhoneNumber * self)386 gdata_gd_phone_number_get_number (GDataGDPhoneNumber *self)
387 {
388 	g_return_val_if_fail (GDATA_IS_GD_PHONE_NUMBER (self), NULL);
389 	return self->priv->number;
390 }
391 
392 /**
393  * gdata_gd_phone_number_set_number:
394  * @self: a #GDataGDPhoneNumber
395  * @number: the new phone number
396  *
397  * Sets the #GDataGDPhoneNumber:number property to @number.
398  *
399  * Since: 0.4.0
400  */
401 void
gdata_gd_phone_number_set_number(GDataGDPhoneNumber * self,const gchar * number)402 gdata_gd_phone_number_set_number (GDataGDPhoneNumber *self, const gchar *number)
403 {
404 	g_return_if_fail (GDATA_IS_GD_PHONE_NUMBER (self));
405 	g_return_if_fail (number != NULL && *number != '\0');
406 
407 	/* Trim leading and trailing whitespace from the number.
408 	 * See here: http://code.google.com/apis/gdata/docs/1.0/elements.html#gdPhoneNumber */
409 	g_free (self->priv->number);
410 	self->priv->number = gdata_parser_utf8_trim_whitespace (number);
411 	g_object_notify (G_OBJECT (self), "number");
412 }
413 
414 /**
415  * gdata_gd_phone_number_get_uri:
416  * @self: a #GDataGDPhoneNumber
417  *
418  * Gets the #GDataGDPhoneNumber:uri property.
419  *
420  * Return value: the phone number's URI, or %NULL
421  *
422  * Since: 0.4.0
423  */
424 const gchar *
gdata_gd_phone_number_get_uri(GDataGDPhoneNumber * self)425 gdata_gd_phone_number_get_uri (GDataGDPhoneNumber *self)
426 {
427 	g_return_val_if_fail (GDATA_IS_GD_PHONE_NUMBER (self), NULL);
428 	return self->priv->uri;
429 }
430 
431 /**
432  * gdata_gd_phone_number_set_uri:
433  * @self: a #GDataGDPhoneNumber
434  * @uri: (allow-none): the new URI for the phone number, or %NULL
435  *
436  * Sets the #GDataGDPhoneNumber:uri property to @uri.
437  *
438  * Set @uri to %NULL to unset the property in the phone number.
439  *
440  * Since: 0.4.0
441  */
442 void
gdata_gd_phone_number_set_uri(GDataGDPhoneNumber * self,const gchar * uri)443 gdata_gd_phone_number_set_uri (GDataGDPhoneNumber *self, const gchar *uri)
444 {
445 	g_return_if_fail (GDATA_IS_GD_PHONE_NUMBER (self));
446 
447 	g_free (self->priv->uri);
448 	self->priv->uri = g_strdup (uri);
449 	g_object_notify (G_OBJECT (self), "uri");
450 }
451 
452 /**
453  * gdata_gd_phone_number_get_relation_type:
454  * @self: a #GDataGDPhoneNumber
455  *
456  * Gets the #GDataGDPhoneNumber:relation-type property.
457  *
458  * Return value: the phone number's relation type, or %NULL
459  *
460  * Since: 0.4.0
461  */
462 const gchar *
gdata_gd_phone_number_get_relation_type(GDataGDPhoneNumber * self)463 gdata_gd_phone_number_get_relation_type (GDataGDPhoneNumber *self)
464 {
465 	g_return_val_if_fail (GDATA_IS_GD_PHONE_NUMBER (self), NULL);
466 	return self->priv->relation_type;
467 }
468 
469 /**
470  * gdata_gd_phone_number_set_relation_type:
471  * @self: a #GDataGDPhoneNumber
472  * @relation_type: (allow-none): the new relation type for the phone number, or %NULL
473  *
474  * Sets the #GDataGDPhoneNumber:relation-type property to @relation_type.
475  *
476  * Set @relation_type to %NULL to unset the property in the phone number.
477  *
478  * Since: 0.4.0
479  */
480 void
gdata_gd_phone_number_set_relation_type(GDataGDPhoneNumber * self,const gchar * relation_type)481 gdata_gd_phone_number_set_relation_type (GDataGDPhoneNumber *self, const gchar *relation_type)
482 {
483 	g_return_if_fail (GDATA_IS_GD_PHONE_NUMBER (self));
484 	g_return_if_fail (relation_type == NULL || *relation_type != '\0');
485 
486 	g_free (self->priv->relation_type);
487 	self->priv->relation_type = g_strdup (relation_type);
488 	g_object_notify (G_OBJECT (self), "relation-type");
489 }
490 
491 /**
492  * gdata_gd_phone_number_get_label:
493  * @self: a #GDataGDPhoneNumber
494  *
495  * Gets the #GDataGDPhoneNumber:label property.
496  *
497  * Return value: the phone number's label, or %NULL
498  *
499  * Since: 0.4.0
500  */
501 const gchar *
gdata_gd_phone_number_get_label(GDataGDPhoneNumber * self)502 gdata_gd_phone_number_get_label (GDataGDPhoneNumber *self)
503 {
504 	g_return_val_if_fail (GDATA_IS_GD_PHONE_NUMBER (self), NULL);
505 	return self->priv->label;
506 }
507 
508 /**
509  * gdata_gd_phone_number_set_label:
510  * @self: a #GDataGDPhoneNumber
511  * @label: (allow-none): the new label for the phone number, or %NULL
512  *
513  * Sets the #GDataGDPhoneNumber:label property to @label.
514  *
515  * Set @label to %NULL to unset the property in the phone number.
516  *
517  * Since: 0.4.0
518  */
519 void
gdata_gd_phone_number_set_label(GDataGDPhoneNumber * self,const gchar * label)520 gdata_gd_phone_number_set_label (GDataGDPhoneNumber *self, const gchar *label)
521 {
522 	g_return_if_fail (GDATA_IS_GD_PHONE_NUMBER (self));
523 
524 	g_free (self->priv->label);
525 	self->priv->label = g_strdup (label);
526 	g_object_notify (G_OBJECT (self), "label");
527 }
528 
529 /**
530  * gdata_gd_phone_number_is_primary:
531  * @self: a #GDataGDPhoneNumber
532  *
533  * Gets the #GDataGDPhoneNumber:is-primary property.
534  *
535  * Return value: %TRUE if this is the primary phone number, %FALSE otherwise
536  *
537  * Since: 0.4.0
538  */
539 gboolean
gdata_gd_phone_number_is_primary(GDataGDPhoneNumber * self)540 gdata_gd_phone_number_is_primary (GDataGDPhoneNumber *self)
541 {
542 	g_return_val_if_fail (GDATA_IS_GD_PHONE_NUMBER (self), FALSE);
543 	return self->priv->is_primary;
544 }
545 
546 /**
547  * gdata_gd_phone_number_set_is_primary:
548  * @self: a #GDataGDPhoneNumber
549  * @is_primary: %TRUE if this is the primary phone number, %FALSE otherwise
550  *
551  * Sets the #GDataGDPhoneNumber:is-primary property to @is_primary.
552  *
553  * Since: 0.4.0
554  */
555 void
gdata_gd_phone_number_set_is_primary(GDataGDPhoneNumber * self,gboolean is_primary)556 gdata_gd_phone_number_set_is_primary (GDataGDPhoneNumber *self, gboolean is_primary)
557 {
558 	g_return_if_fail (GDATA_IS_GD_PHONE_NUMBER (self));
559 
560 	self->priv->is_primary = is_primary;
561 	g_object_notify (G_OBJECT (self), "is-primary");
562 }
563