Branch data Line data Source code
1 : : // SPDX-License-Identifier: GPL-3.0-or-later
2 : : // SPDX-FileCopyrightText: Andy Holmes <andrew.g.r.holmes@gmail.com>
3 : :
4 : : #define G_LOG_DOMAIN "valent-resource"
5 : :
6 : : #include "config.h"
7 : :
8 : : #include <gio/gio.h>
9 : :
10 : : #include "valent-object.h"
11 : :
12 : : #include "valent-resource.h"
13 : :
14 : : /**
15 : : * ValentResource:
16 : : *
17 : : * `ValentResource` is an interface that represents a resource.
18 : : *
19 : : * It is based on the properties in the elements namespace of the Dublin Core
20 : : * DCMI Metadata Terms, primarily to represent SPARQL resources and runtime
21 : : * objects with similar semantics.
22 : : *
23 : : * See: https://www.dublincore.org/specifications/dublin-core/dcmi-terms/#section-3
24 : : *
25 : : * Since: 1.0
26 : : */
27 : :
28 : : typedef struct
29 : : {
30 : : GStrv contributor;
31 : : char *coverage;
32 : : char *creator;
33 : : GDateTime *date;
34 : : char *description;
35 : : char *format;
36 : : char *identifier;
37 : : char *iri;
38 : : char *language;
39 : : char *publisher;
40 : : GStrv relation;
41 : : char *rights;
42 : : ValentResource *source;
43 : : char *subject;
44 : : char *title;
45 : : char *type_hint;
46 : : } ValentResourcePrivate;
47 : :
48 [ + + + - ]: 9724 : G_DEFINE_TYPE_WITH_PRIVATE (ValentResource, valent_resource, VALENT_TYPE_OBJECT)
49 : :
50 : : typedef enum
51 : : {
52 : : PROP_CONTRIBUTOR = 1,
53 : : PROP_COVERAGE,
54 : : PROP_CREATOR,
55 : : PROP_DATE,
56 : : PROP_DESCRIPTION,
57 : : PROP_FORMAT,
58 : : PROP_IDENTIFIER,
59 : : PROP_IRI,
60 : : PROP_LANGUAGE,
61 : : PROP_PUBLISHER,
62 : : PROP_RELATION,
63 : : PROP_RIGHTS,
64 : : PROP_SOURCE,
65 : : PROP_SUBJECT,
66 : : PROP_TITLE,
67 : : PROP_TYPE_HINT,
68 : : } ValentResourceProperty;
69 : :
70 : : static GParamSpec *properties[PROP_TYPE_HINT + 1] = { NULL, };
71 : :
72 : : static void
73 : 250 : on_source_destroyed (ValentObject *object,
74 : : ValentResource *self)
75 : : {
76 : 250 : ValentResourcePrivate *priv = valent_resource_get_instance_private (self);
77 : :
78 [ + - ]: 250 : g_assert (VALENT_IS_OBJECT (object));
79 [ - + ]: 250 : g_assert (VALENT_IS_RESOURCE (self));
80 : :
81 : 250 : priv->source = NULL;
82 : 250 : }
83 : :
84 : : /*
85 : : * ValentResource
86 : : */
87 : : static void
88 : 1 : valent_resource_real_update (ValentResource *resource,
89 : : ValentResource *update)
90 : : {
91 [ + - ]: 1 : g_assert (VALENT_IS_RESOURCE (resource));
92 [ - + ]: 1 : g_assert (VALENT_IS_RESOURCE (update));
93 : 1 : }
94 : :
95 : : static void
96 : 629 : valent_resource_set_source (ValentResource *resource,
97 : : ValentResource *source)
98 : : {
99 : 629 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
100 : :
101 [ + - ]: 629 : g_assert (VALENT_IS_RESOURCE (resource));
102 [ + + - + ]: 629 : g_assert (source == NULL || VALENT_IS_RESOURCE (source));
103 : :
104 [ + + ]: 629 : if (source != NULL)
105 : : {
106 : 307 : priv->source = source;
107 : 307 : g_signal_connect_object (source,
108 : : "destroy",
109 : : G_CALLBACK (on_source_destroyed),
110 : : resource,
111 : : G_CONNECT_DEFAULT);
112 : : }
113 : 629 : }
114 : :
115 : : /*
116 : : * GObject
117 : : */
118 : : static void
119 : 581 : valent_resource_finalize (GObject *object)
120 : : {
121 : 581 : ValentResource *self = VALENT_RESOURCE (object);
122 : 581 : ValentResourcePrivate *priv = valent_resource_get_instance_private (self);
123 : :
124 [ - + ]: 581 : g_clear_pointer (&priv->contributor, g_strfreev);
125 [ + + ]: 581 : g_clear_pointer (&priv->coverage, g_free);
126 [ + + ]: 581 : g_clear_pointer (&priv->creator, g_free);
127 [ + + ]: 581 : g_clear_pointer (&priv->date, g_date_time_unref);
128 [ + + ]: 581 : g_clear_pointer (&priv->description, g_free);
129 [ + + ]: 581 : g_clear_pointer (&priv->format, g_free);
130 [ + + ]: 581 : g_clear_pointer (&priv->identifier, g_free);
131 [ + + ]: 581 : g_clear_pointer (&priv->iri, g_free);
132 [ + + ]: 581 : g_clear_pointer (&priv->language, g_free);
133 [ + + ]: 581 : g_clear_pointer (&priv->publisher, g_free);
134 [ - + ]: 581 : g_clear_pointer (&priv->relation, g_strfreev);
135 [ + + ]: 581 : g_clear_pointer (&priv->rights, g_free);
136 [ + + ]: 581 : g_clear_pointer (&priv->subject, g_free);
137 [ + + ]: 581 : g_clear_pointer (&priv->title, g_free);
138 [ + + ]: 581 : g_clear_pointer (&priv->type_hint, g_free);
139 : :
140 : 581 : G_OBJECT_CLASS (valent_resource_parent_class)->finalize (object);
141 : 581 : }
142 : :
143 : : static void
144 : 62 : valent_resource_get_property (GObject *object,
145 : : guint prop_id,
146 : : GValue *value,
147 : : GParamSpec *pspec)
148 : : {
149 : 62 : ValentResource *self = VALENT_RESOURCE (object);
150 : 62 : ValentResourcePrivate *priv = valent_resource_get_instance_private (self);
151 : :
152 [ + + + + : 62 : switch ((ValentResourceProperty)prop_id)
+ + + + +
+ + + + +
+ + - ]
153 : : {
154 : 1 : case PROP_CONTRIBUTOR:
155 : 1 : g_value_set_boxed (value, priv->contributor);
156 : 1 : break;
157 : :
158 : 1 : case PROP_COVERAGE:
159 : 1 : g_value_set_string (value, priv->coverage);
160 : 1 : break;
161 : :
162 : 1 : case PROP_CREATOR:
163 : 1 : g_value_set_string (value, priv->creator);
164 : 1 : break;
165 : :
166 : 1 : case PROP_DATE:
167 : 1 : g_value_set_boxed (value, priv->date);
168 : 1 : break;
169 : :
170 : 1 : case PROP_DESCRIPTION:
171 : 1 : g_value_set_string (value, priv->description);
172 : 1 : break;
173 : :
174 : 1 : case PROP_FORMAT:
175 : 1 : g_value_set_string (value, priv->format);
176 : 1 : break;
177 : :
178 : 1 : case PROP_IDENTIFIER:
179 : 1 : g_value_set_string (value, priv->identifier);
180 : 1 : break;
181 : :
182 : 35 : case PROP_IRI:
183 : 35 : g_value_set_string (value, priv->iri);
184 : 35 : break;
185 : :
186 : 1 : case PROP_LANGUAGE:
187 : 1 : g_value_set_string (value, priv->language);
188 : 1 : break;
189 : :
190 : 1 : case PROP_PUBLISHER:
191 : 1 : g_value_set_string (value, priv->publisher);
192 : 1 : break;
193 : :
194 : 1 : case PROP_RELATION:
195 : 1 : g_value_set_boxed (value, priv->relation);
196 : 1 : break;
197 : :
198 : 1 : case PROP_RIGHTS:
199 : 1 : g_value_set_string (value, priv->rights);
200 : 1 : break;
201 : :
202 : 10 : case PROP_SOURCE:
203 : 10 : g_value_set_object (value, priv->source);
204 : 10 : break;
205 : :
206 : 1 : case PROP_SUBJECT:
207 : 1 : g_value_set_string (value, priv->subject);
208 : 1 : break;
209 : :
210 : 4 : case PROP_TITLE:
211 : 4 : g_value_set_string (value, priv->title);
212 : 4 : break;
213 : :
214 : 1 : case PROP_TYPE_HINT:
215 : 1 : g_value_set_string (value, priv->type_hint);
216 : 1 : break;
217 : :
218 : 0 : default:
219 : 0 : G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
220 : : }
221 : 62 : }
222 : :
223 : : static void
224 : 2478 : valent_resource_set_property (GObject *object,
225 : : guint prop_id,
226 : : const GValue *value,
227 : : GParamSpec *pspec)
228 : : {
229 : 2478 : ValentResource *self = VALENT_RESOURCE (object);
230 : 2478 : ValentResourcePrivate *priv = valent_resource_get_instance_private (self);
231 : :
232 [ + + + + : 2478 : switch (prop_id)
+ + + + +
+ + + + +
+ + - ]
233 : : {
234 : 1 : case PROP_CONTRIBUTOR:
235 : 1 : valent_resource_set_contributor (self, g_value_get_boxed (value));
236 : 1 : break;
237 : :
238 : 1 : case PROP_COVERAGE:
239 : 1 : valent_resource_set_coverage (self, g_value_get_string (value));
240 : 1 : break;
241 : :
242 : 1 : case PROP_CREATOR:
243 : 1 : valent_resource_set_creator (self, g_value_get_string (value));
244 : 1 : break;
245 : :
246 : 1 : case PROP_DATE:
247 : 1 : valent_resource_set_date (self, g_value_get_boxed (value));
248 : 1 : break;
249 : :
250 : 279 : case PROP_DESCRIPTION:
251 : 279 : valent_resource_set_description (self, g_value_get_string (value));
252 : 279 : break;
253 : :
254 : 1 : case PROP_FORMAT:
255 : 1 : valent_resource_set_format (self, g_value_get_string (value));
256 : 1 : break;
257 : :
258 : 629 : case PROP_IDENTIFIER:
259 : 629 : valent_resource_set_identifier (self, g_value_get_string (value));
260 : 629 : break;
261 : :
262 : 629 : case PROP_IRI:
263 [ + - ]: 629 : g_assert (priv->iri == NULL);
264 : 629 : priv->iri = g_value_dup_string (value);
265 : 629 : break;
266 : :
267 : 1 : case PROP_LANGUAGE:
268 : 1 : valent_resource_set_language (self, g_value_get_string (value));
269 : 1 : break;
270 : :
271 : 1 : case PROP_PUBLISHER:
272 : 1 : valent_resource_set_publisher (self, g_value_get_string (value));
273 : 1 : break;
274 : :
275 : 1 : case PROP_RELATION:
276 : 1 : valent_resource_set_relation (self, g_value_get_boxed (value));
277 : 1 : break;
278 : :
279 : 1 : case PROP_RIGHTS:
280 : 1 : valent_resource_set_rights (self, g_value_get_string (value));
281 : 1 : break;
282 : :
283 : 629 : case PROP_SOURCE:
284 : 629 : valent_resource_set_source (self, g_value_get_object (value));
285 : 629 : break;
286 : :
287 : 1 : case PROP_SUBJECT:
288 : 1 : valent_resource_set_subject (self, g_value_get_string (value));
289 : 1 : break;
290 : :
291 : 301 : case PROP_TITLE:
292 : 301 : valent_resource_set_title (self, g_value_get_string (value));
293 : 301 : break;
294 : :
295 : 1 : case PROP_TYPE_HINT:
296 : 1 : valent_resource_set_type_hint (self, g_value_get_string (value));
297 : 1 : break;
298 : :
299 : 0 : default:
300 : 0 : G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
301 : : }
302 : 2478 : }
303 : :
304 : : static void
305 : 60 : valent_resource_class_init (ValentResourceClass *klass)
306 : : {
307 : 60 : GObjectClass *object_class = G_OBJECT_CLASS (klass);
308 : :
309 : 60 : object_class->finalize = valent_resource_finalize;
310 : 60 : object_class->get_property = valent_resource_get_property;
311 : 60 : object_class->set_property = valent_resource_set_property;
312 : :
313 : 60 : klass->update = valent_resource_real_update;
314 : :
315 : : /**
316 : : * ValentResource:contributor: (getter get_contributor) (setter set_contributor)
317 : : *
318 : : * An entity responsible for making contributions to the resource.
319 : : *
320 : : * The guidelines for using names of persons or organizations as creators also
321 : : * apply to contributors. Typically, the name of a Contributor should be used
322 : : * to indicate the entity.
323 : : *
324 : : * Since: 1.0
325 : : */
326 : 120 : properties[PROP_CONTRIBUTOR] =
327 : 60 : g_param_spec_boxed ("contributor", NULL, NULL,
328 : : G_TYPE_STRV,
329 : : (G_PARAM_READWRITE |
330 : : G_PARAM_EXPLICIT_NOTIFY |
331 : : G_PARAM_STATIC_STRINGS));
332 : :
333 : : /**
334 : : * ValentResource:coverage: (getter get_coverage) (setter set_coverage)
335 : : *
336 : : * The spatial or temporal topic of the resource, spatial applicability of
337 : : * the resource, or jurisdiction under which the resource is relevant.
338 : : *
339 : : * Spatial topic and spatial applicability may be a named place or a location
340 : : * specified by its geographic coordinates. Temporal topic may be a named
341 : : * period, date, or date range. A jurisdiction may be a named administrative
342 : : * entity or a geographic place to which the resource applies. Recommended
343 : : * practice is to use a controlled vocabulary such as the Getty Thesaurus of
344 : : * Geographic Names [TGN]. Where appropriate, named places or time periods
345 : : * may be used in preference to numeric identifiers such as sets of
346 : : * coordinates or date ranges.
347 : : *
348 : : * Since: 1.0
349 : : */
350 : 120 : properties[PROP_COVERAGE] =
351 : 60 : g_param_spec_string ("coverage", NULL, NULL,
352 : : NULL,
353 : : (G_PARAM_READWRITE |
354 : : G_PARAM_EXPLICIT_NOTIFY |
355 : : G_PARAM_STATIC_STRINGS));
356 : :
357 : : /**
358 : : * ValentResource:creator: (getter get_creator) (setter set_creator)
359 : : *
360 : : * An entity primarily responsible for making the resource.
361 : : *
362 : : * Examples of a Creator include a person, an organization, or a service.
363 : : * Typically, the name of a Creator should be used to indicate the entity.
364 : : *
365 : : * Since: 1.0
366 : : */
367 : 120 : properties[PROP_CREATOR] =
368 : 60 : g_param_spec_string ("creator", NULL, NULL,
369 : : NULL,
370 : : (G_PARAM_READWRITE |
371 : : G_PARAM_EXPLICIT_NOTIFY |
372 : : G_PARAM_STATIC_STRINGS));
373 : :
374 : : /**
375 : : * ValentResource:date: (getter get_date) (setter set_date)
376 : : *
377 : : * A point or period of time associated with an event in the lifecycle of
378 : : * the resource.
379 : : *
380 : : * Date may be used to express temporal information at any level of
381 : : * granularity. Recommended practice is to express the date, date/time, or
382 : : * period of time according to ISO 8601-1 [ISO 8601-1] or a published profile
383 : : * of the ISO standard, such as the W3C Note on Date and Time Formats [W3CDTF]
384 : : * or the Extended Date/Time Format Specification [EDTF]. If the full date is
385 : : * unknown, month and year (YYYY-MM) or just year (YYYY) may be used. Date
386 : : * ranges may be specified using ISO 8601 period of time specification in
387 : : * which start and end dates are separated by a '/' (slash) character. Either
388 : : * the start or end date may be missing.
389 : : *
390 : : * Since: 1.0
391 : : */
392 : 120 : properties[PROP_DATE] =
393 : 60 : g_param_spec_boxed ("date", NULL, NULL,
394 : : G_TYPE_DATE_TIME,
395 : : (G_PARAM_READWRITE |
396 : : G_PARAM_EXPLICIT_NOTIFY |
397 : : G_PARAM_STATIC_STRINGS));
398 : :
399 : : /**
400 : : * ValentResource:description: (getter get_description) (setter set_description)
401 : : *
402 : : * An account of the resource.
403 : : *
404 : : * Description may include but is not limited to: an abstract, a table of
405 : : * contents, a graphical representation, or a free-text account of the
406 : : * resource.
407 : : *
408 : : * Since: 1.0
409 : : */
410 : 120 : properties[PROP_DESCRIPTION] =
411 : 60 : g_param_spec_string ("description", NULL, NULL,
412 : : NULL,
413 : : (G_PARAM_READWRITE |
414 : : G_PARAM_EXPLICIT_NOTIFY |
415 : : G_PARAM_STATIC_STRINGS));
416 : :
417 : : /**
418 : : * ValentResource:format: (getter get_format) (setter set_format)
419 : : *
420 : : * The file format, physical medium, or dimensions of the resource.
421 : : *
422 : : * Recommended practice is to use a controlled vocabulary where available. For
423 : : * example, for file formats one could use the list of Internet Media Types
424 : : * [MIME](https://www.iana.org/assignments/media-types/media-types.xhtml).
425 : : *
426 : : * Since: 1.0
427 : : */
428 : 120 : properties[PROP_FORMAT] =
429 : 60 : g_param_spec_string ("format", NULL, NULL,
430 : : NULL,
431 : : (G_PARAM_READWRITE |
432 : : G_PARAM_EXPLICIT_NOTIFY |
433 : : G_PARAM_STATIC_STRINGS));
434 : :
435 : : /**
436 : : * ValentResource:identifier: (getter get_identifier) (setter set_identifier)
437 : : *
438 : : * An unambiguous reference to the resource within a given context.
439 : : *
440 : : * Recommended practice is to identify the resource by means of a string
441 : : * conforming to an identification system.
442 : : *
443 : : * Since: 1.0
444 : : */
445 : 120 : properties[PROP_IDENTIFIER] =
446 : 60 : g_param_spec_string ("identifier", NULL, NULL,
447 : : NULL,
448 : : (G_PARAM_READWRITE |
449 : : G_PARAM_CONSTRUCT_ONLY |
450 : : G_PARAM_STATIC_STRINGS));
451 : :
452 : : /**
453 : : * ValentResource:iri: (getter get_iri)
454 : : *
455 : : * The resource IRI (Internationalized Resource Identifier).
456 : : *
457 : : * Since: 1.0
458 : : */
459 : 120 : properties[PROP_IRI] =
460 : 60 : g_param_spec_string ("iri", NULL, NULL,
461 : : NULL,
462 : : (G_PARAM_READWRITE |
463 : : G_PARAM_CONSTRUCT_ONLY |
464 : : G_PARAM_STATIC_STRINGS));
465 : :
466 : : /**
467 : : * ValentResource:language: (getter get_language) (setter set_language)
468 : : *
469 : : * A list of related resources from which the described resource is derived.
470 : : *
471 : : * Recommended practice is to use either a non-literal value representing a
472 : : * language from a controlled vocabulary such as ISO 639-2 or ISO 639-3, or a
473 : : * literal value consisting of an IETF Best Current Practice 47 [IETF-BCP47]
474 : : * language tag.
475 : : *
476 : : * Since: 1.0
477 : : */
478 : 120 : properties[PROP_LANGUAGE] =
479 : 60 : g_param_spec_string ("language", NULL, NULL,
480 : : NULL,
481 : : (G_PARAM_READWRITE |
482 : : G_PARAM_EXPLICIT_NOTIFY |
483 : : G_PARAM_STATIC_STRINGS));
484 : :
485 : : /**
486 : : * ValentResource:publisher: (getter get_publisher) (setter set_publisher)
487 : : *
488 : : * An entity responsible for making the resource available.
489 : : *
490 : : * Examples of a Publisher include a person, an organization, or a service.
491 : : * Typically, the name of a Publisher should be used to indicate the entity.
492 : : *
493 : : * Since: 1.0
494 : : */
495 : 120 : properties[PROP_PUBLISHER] =
496 : 60 : g_param_spec_string ("publisher", NULL, NULL,
497 : : NULL,
498 : : (G_PARAM_READWRITE |
499 : : G_PARAM_EXPLICIT_NOTIFY |
500 : : G_PARAM_STATIC_STRINGS));
501 : :
502 : : /**
503 : : * ValentResource:relation: (getter get_relation) (setter set_relation)
504 : : *
505 : : * A related resource.
506 : : *
507 : : * Recommended practice is to identify the related resource by means of a
508 : : * URI. If this is not possible or feasible, a string conforming to a formal
509 : : * identification system may be provided.
510 : : *
511 : : * Since: 1.0
512 : : */
513 : 120 : properties[PROP_RELATION] =
514 : 60 : g_param_spec_boxed ("relation", NULL, NULL,
515 : : G_TYPE_STRV,
516 : : (G_PARAM_READWRITE |
517 : : G_PARAM_EXPLICIT_NOTIFY |
518 : : G_PARAM_STATIC_STRINGS));
519 : :
520 : : /**
521 : : * ValentResource:rights: (getter get_rights) (setter set_rights)
522 : : *
523 : : * Information about rights held in and over the resource.
524 : : *
525 : : * Typically, rights information includes a statement about various property
526 : : * rights associated with the resource, including intellectual property
527 : : * rights.
528 : : *
529 : : * Since: 1.0
530 : : */
531 : 120 : properties[PROP_RIGHTS] =
532 : 60 : g_param_spec_string ("rights", NULL, NULL,
533 : : NULL,
534 : : (G_PARAM_READWRITE |
535 : : G_PARAM_EXPLICIT_NOTIFY |
536 : : G_PARAM_STATIC_STRINGS));
537 : :
538 : : /**
539 : : * ValentResource:source: (getter get_source)
540 : : *
541 : : * A related resource from which the described resource is derived.
542 : : *
543 : : * The described resource may be derived from the related resource in whole
544 : : * or in part. Recommended best practice is to identify the related resource
545 : : * by means of a string conforming to a formal identification system.
546 : : *
547 : : * Since: 1.0
548 : : */
549 : 120 : properties[PROP_SOURCE] =
550 : 60 : g_param_spec_object ("source", NULL, NULL,
551 : : VALENT_TYPE_RESOURCE,
552 : : (G_PARAM_READWRITE |
553 : : G_PARAM_CONSTRUCT_ONLY |
554 : : G_PARAM_STATIC_STRINGS));
555 : :
556 : : /**
557 : : * ValentResource:subject: (getter get_subject) (setter set_subject)
558 : : *
559 : : * The topic of the resource.
560 : : *
561 : : * Typically, the subject will be represented using keywords, key phrases, or
562 : : * classification codes. Recommended best practice is to use a controlled
563 : : * vocabulary.
564 : : *
565 : : * Since: 1.0
566 : : */
567 : 120 : properties[PROP_SUBJECT] =
568 : 60 : g_param_spec_string ("subject", NULL, NULL,
569 : : NULL,
570 : : (G_PARAM_READWRITE |
571 : : G_PARAM_EXPLICIT_NOTIFY |
572 : : G_PARAM_STATIC_STRINGS));
573 : :
574 : : /**
575 : : * ValentResource:title: (getter get_title) (setter set_title)
576 : : *
577 : : * A name given to the resource.
578 : : *
579 : : * Since: 1.0
580 : : */
581 : 120 : properties[PROP_TITLE] =
582 : 60 : g_param_spec_string ("title", NULL, NULL,
583 : : NULL,
584 : : (G_PARAM_READWRITE |
585 : : G_PARAM_EXPLICIT_NOTIFY |
586 : : G_PARAM_STATIC_STRINGS));
587 : :
588 : : /**
589 : : * ValentResource:type-hint: (getter get_type_hint) (setter set_type_hint)
590 : : *
591 : : * The nature or genre of the resource.
592 : : *
593 : : * Recommended practice is to use a controlled vocabulary such as the DCMI
594 : : * Type Vocabulary [DCMI-TYPE]. To describe the file format, physical medium,
595 : : * or dimensions of the resource, use [property@Valent.Resource:format].
596 : : *
597 : : * Since: 1.0
598 : : */
599 : 120 : properties[PROP_TYPE_HINT] =
600 : 60 : g_param_spec_string ("type-hint", NULL, NULL,
601 : : NULL,
602 : : (G_PARAM_READWRITE |
603 : : G_PARAM_EXPLICIT_NOTIFY |
604 : : G_PARAM_STATIC_STRINGS));
605 : :
606 : 60 : g_object_class_install_properties (object_class, G_N_ELEMENTS (properties), properties);
607 : 60 : }
608 : :
609 : : static void
610 : 629 : valent_resource_init (ValentResource *self)
611 : : {
612 : 629 : }
613 : :
614 : : /**
615 : : * valent_resource_get_contributor: (get-property contributor)
616 : : * @resource: a `ValentResource`
617 : : *
618 : : * Gets the contributor of @resource.
619 : : *
620 : : * Returns: (transfer none) (nullable): the contributor of @resource
621 : : *
622 : : * Since: 1.0
623 : : */
624 : : GStrv
625 : 1 : valent_resource_get_contributor (ValentResource *resource)
626 : : {
627 : 1 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
628 : :
629 [ + - ]: 1 : g_return_val_if_fail (VALENT_IS_RESOURCE (resource), NULL);
630 : :
631 : 1 : return priv->contributor;
632 : : }
633 : :
634 : : /**
635 : : * valent_resource_set_contributor: (set-property contributor)
636 : : * @resource: a `ValentResource`
637 : : * @contributor: (nullable): the new contributor
638 : : *
639 : : * Gets the title of @resource.
640 : : *
641 : : * Since: 1.0
642 : : */
643 : : void
644 : 1 : valent_resource_set_contributor (ValentResource *resource,
645 : : GStrv contributor)
646 : : {
647 : 1 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
648 : :
649 [ + - ]: 1 : g_return_if_fail (VALENT_IS_RESOURCE (resource));
650 : :
651 [ - + ]: 1 : if (priv->contributor != contributor)
652 : : {
653 [ # # ]: 0 : g_clear_pointer (&priv->contributor, g_strfreev);
654 : 0 : priv->contributor = g_strdupv (contributor);
655 : 0 : g_object_notify_by_pspec (G_OBJECT (resource), properties[PROP_CONTRIBUTOR]);
656 : : }
657 : : }
658 : :
659 : : /**
660 : : * valent_resource_get_coverage: (get-property coverage)
661 : : * @resource: a `ValentResource`
662 : : *
663 : : * Gets the coverage of @resource.
664 : : *
665 : : * Returns: (transfer none) (nullable): the coverage of @resource
666 : : *
667 : : * Since: 1.0
668 : : */
669 : : const char *
670 : 1 : valent_resource_get_coverage (ValentResource *resource)
671 : : {
672 : 1 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
673 : :
674 [ + - ]: 1 : g_return_val_if_fail (VALENT_IS_RESOURCE (resource), NULL);
675 : :
676 : 1 : return priv->coverage;
677 : : }
678 : :
679 : : /**
680 : : * valent_resource_set_coverage: (set-property coverage)
681 : : * @resource: a `ValentResource`
682 : : * @coverage: (nullable): the new coverage
683 : : *
684 : : * Set the coverage of @resource to @coverage.
685 : : *
686 : : * Since: 1.0
687 : : */
688 : : void
689 : 1 : valent_resource_set_coverage (ValentResource *resource,
690 : : const char *coverage)
691 : : {
692 : 1 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
693 : :
694 [ + - ]: 1 : g_return_if_fail (VALENT_IS_RESOURCE (resource));
695 : :
696 [ + - ]: 1 : if (g_set_str (&priv->coverage, coverage))
697 : 1 : g_object_notify_by_pspec (G_OBJECT (resource), properties[PROP_COVERAGE]);
698 : : }
699 : :
700 : : /**
701 : : * valent_resource_get_creator: (get-property creator)
702 : : * @resource: a `ValentResource`
703 : : *
704 : : * Gets the creator of @resource.
705 : : *
706 : : * Returns: (transfer none) (nullable): the creator of @resource
707 : : *
708 : : * Since: 1.0
709 : : */
710 : : const char *
711 : 1 : valent_resource_get_creator (ValentResource *resource)
712 : : {
713 : 1 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
714 : :
715 [ + - ]: 1 : g_return_val_if_fail (VALENT_IS_RESOURCE (resource), NULL);
716 : :
717 : 1 : return priv->creator;
718 : : }
719 : :
720 : : /**
721 : : * valent_resource_set_creator: (set-property creator)
722 : : * @resource: a `ValentResource`
723 : : * @creator: (nullable): the new creator
724 : : *
725 : : * Set the creator of @resource to @creator.
726 : : *
727 : : * Since: 1.0
728 : : */
729 : : void
730 : 1 : valent_resource_set_creator (ValentResource *resource,
731 : : const char *creator)
732 : : {
733 : 1 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
734 : :
735 [ + - ]: 1 : g_return_if_fail (VALENT_IS_RESOURCE (resource));
736 : :
737 [ + - ]: 1 : if (g_set_str (&priv->creator, creator))
738 : 1 : g_object_notify_by_pspec (G_OBJECT (resource), properties[PROP_CREATOR]);
739 : : }
740 : :
741 : : /**
742 : : * valent_resource_get_date: (get-property date)
743 : : * @resource: a `ValentResource`
744 : : *
745 : : * Gets the date of @resource.
746 : : *
747 : : * Returns: (transfer none) (nullable): the date of @resource
748 : : *
749 : : * Since: 1.0
750 : : */
751 : : GDateTime *
752 : 1 : valent_resource_get_date (ValentResource *resource)
753 : : {
754 : 1 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
755 : :
756 [ + - ]: 1 : g_return_val_if_fail (VALENT_IS_RESOURCE (resource), NULL);
757 : :
758 : 1 : return priv->date;
759 : : }
760 : :
761 : : /**
762 : : * valent_resource_set_date: (set-property date)
763 : : * @resource: a `ValentResource`
764 : : * @date: (nullable): the new date
765 : : *
766 : : * Set the date of @resource to @date.
767 : : *
768 : : * Since: 1.0
769 : : */
770 : : void
771 : 1 : valent_resource_set_date (ValentResource *resource,
772 : : GDateTime *date)
773 : : {
774 : 1 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
775 : :
776 [ + - ]: 1 : g_return_if_fail (VALENT_IS_RESOURCE (resource));
777 : :
778 [ + - ]: 1 : if (priv->date == date)
779 : : return;
780 : :
781 [ - + - - : 1 : if (priv->date && date && g_date_time_equal (priv->date, date))
- - ]
782 : : return;
783 : :
784 [ - + ]: 1 : g_clear_pointer (&priv->date, g_date_time_unref);
785 [ + - ]: 1 : if (date != NULL)
786 : 1 : priv->date = g_date_time_ref (date);
787 : :
788 : 1 : g_object_notify_by_pspec (G_OBJECT (resource), properties[PROP_DATE]);
789 : : }
790 : :
791 : : /**
792 : : * valent_resource_get_description: (get-property description)
793 : : * @resource: a `ValentResource`
794 : : *
795 : : * Gets the description of @resource.
796 : : *
797 : : * Returns: (transfer none) (nullable): the description of @resource
798 : : *
799 : : * Since: 1.0
800 : : */
801 : : const char *
802 : 1 : valent_resource_get_description (ValentResource *resource)
803 : : {
804 : 1 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
805 : :
806 [ + - ]: 1 : g_return_val_if_fail (VALENT_IS_RESOURCE (resource), NULL);
807 : :
808 : 1 : return priv->description;
809 : : }
810 : :
811 : : /**
812 : : * valent_resource_set_description: (set-property description)
813 : : * @resource: a `ValentResource`
814 : : * @description: (nullable): the new description
815 : : *
816 : : * Set the description of @resource to @description.
817 : : *
818 : : * Since: 1.0
819 : : */
820 : : void
821 : 279 : valent_resource_set_description (ValentResource *resource,
822 : : const char *description)
823 : : {
824 : 279 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
825 : :
826 [ + - ]: 279 : g_return_if_fail (VALENT_IS_RESOURCE (resource));
827 : :
828 [ + - ]: 279 : if (g_set_str (&priv->description, description))
829 : 279 : g_object_notify_by_pspec (G_OBJECT (resource), properties[PROP_DESCRIPTION]);
830 : : }
831 : :
832 : : /**
833 : : * valent_resource_get_format: (get-property format)
834 : : * @resource: a `ValentResource`
835 : : *
836 : : * Gets the format of @resource.
837 : : *
838 : : * Returns: (transfer none) (nullable): the format of @resource
839 : : *
840 : : * Since: 1.0
841 : : */
842 : : const char *
843 : 1 : valent_resource_get_format (ValentResource *resource)
844 : : {
845 : 1 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
846 : :
847 [ + - ]: 1 : g_return_val_if_fail (VALENT_IS_RESOURCE (resource), NULL);
848 : :
849 : 1 : return priv->format;
850 : : }
851 : :
852 : : /**
853 : : * valent_resource_set_format: (set-property format)
854 : : * @resource: a `ValentResource`
855 : : * @format: (nullable): the new format
856 : : *
857 : : * Set the format of @resource to @format.
858 : : *
859 : : * Since: 1.0
860 : : */
861 : : void
862 : 1 : valent_resource_set_format (ValentResource *resource,
863 : : const char *format)
864 : : {
865 : 1 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
866 : :
867 [ + - ]: 1 : g_return_if_fail (VALENT_IS_RESOURCE (resource));
868 : :
869 [ + - ]: 1 : if (g_set_str (&priv->format, format))
870 : 1 : g_object_notify_by_pspec (G_OBJECT (resource), properties[PROP_FORMAT]);
871 : : }
872 : :
873 : : /**
874 : : * valent_resource_get_identifier: (get-property identifier)
875 : : * @resource: a `ValentResource`
876 : : *
877 : : * Gets the identifier of @resource.
878 : : *
879 : : * Returns: (transfer none) (nullable): the identifier of @resource
880 : : *
881 : : * Since: 1.0
882 : : */
883 : : const char *
884 : 1 : valent_resource_get_identifier (ValentResource *resource)
885 : : {
886 : 1 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
887 : :
888 [ + - ]: 1 : g_return_val_if_fail (VALENT_IS_RESOURCE (resource), NULL);
889 : :
890 : 1 : return priv->identifier;
891 : : }
892 : :
893 : : /**
894 : : * valent_resource_set_identifier: (set-property identifier)
895 : : * @resource: a `ValentResource`
896 : : * @identifier: (nullable): the new identifier
897 : : *
898 : : * Set the identifier of @resource to @identifier.
899 : : *
900 : : * Since: 1.0
901 : : */
902 : : void
903 : 629 : valent_resource_set_identifier (ValentResource *resource,
904 : : const char *identifier)
905 : : {
906 : 629 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
907 : :
908 [ + - ]: 629 : g_return_if_fail (VALENT_IS_RESOURCE (resource));
909 : :
910 [ + + ]: 629 : if (g_set_str (&priv->identifier, identifier))
911 : 1 : g_object_notify_by_pspec (G_OBJECT (resource), properties[PROP_IDENTIFIER]);
912 : : }
913 : :
914 : : /**
915 : : * valent_resource_get_iri: (get-property iri)
916 : : * @resource: a `ValentResource`
917 : : *
918 : : * Gets the IRI of @resource.
919 : : *
920 : : * Returns: (transfer none) (nullable): the IRI of @resource
921 : : *
922 : : * Since: 1.0
923 : : */
924 : : const char *
925 : 44 : valent_resource_get_iri (ValentResource *resource)
926 : : {
927 : 44 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
928 : :
929 [ + - ]: 44 : g_return_val_if_fail (VALENT_IS_RESOURCE (resource), NULL);
930 : :
931 : 44 : return priv->iri;
932 : : }
933 : :
934 : : /**
935 : : * valent_resource_get_language: (get-property language)
936 : : * @resource: a `ValentResource`
937 : : *
938 : : * Gets the language of @resource.
939 : : *
940 : : * Returns: (transfer none) (nullable): the language of @resource
941 : : *
942 : : * Since: 1.0
943 : : */
944 : : const char *
945 : 1 : valent_resource_get_language (ValentResource *resource)
946 : : {
947 : 1 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
948 : :
949 [ + - ]: 1 : g_return_val_if_fail (VALENT_IS_RESOURCE (resource), NULL);
950 : :
951 : 1 : return priv->language;
952 : : }
953 : :
954 : : /**
955 : : * valent_resource_set_language: (set-property language)
956 : : * @resource: a `ValentResource`
957 : : * @language: (nullable): the new language
958 : : *
959 : : * Set the language of @resource to @language.
960 : : *
961 : : * Since: 1.0
962 : : */
963 : : void
964 : 1 : valent_resource_set_language (ValentResource *resource,
965 : : const char *language)
966 : : {
967 : 1 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
968 : :
969 [ + - ]: 1 : g_return_if_fail (VALENT_IS_RESOURCE (resource));
970 : :
971 [ + - ]: 1 : if (g_set_str (&priv->language, language))
972 : 1 : g_object_notify_by_pspec (G_OBJECT (resource), properties[PROP_LANGUAGE]);
973 : : }
974 : :
975 : : /**
976 : : * valent_resource_get_publisher: (get-property publisher)
977 : : * @resource: a `ValentResource`
978 : : *
979 : : * Gets the publisher of @resource.
980 : : *
981 : : * Returns: (transfer none) (nullable): the publisher of @resource
982 : : *
983 : : * Since: 1.0
984 : : */
985 : : const char *
986 : 1 : valent_resource_get_publisher (ValentResource *resource)
987 : : {
988 : 1 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
989 : :
990 [ + - ]: 1 : g_return_val_if_fail (VALENT_IS_RESOURCE (resource), NULL);
991 : :
992 : 1 : return priv->publisher;
993 : : }
994 : :
995 : : /**
996 : : * valent_resource_set_publisher: (set-property publisher)
997 : : * @resource: a `ValentResource`
998 : : * @publisher: (nullable): the new publisher
999 : : *
1000 : : * Set the publisher of @resource to @publisher.
1001 : : *
1002 : : * Since: 1.0
1003 : : */
1004 : : void
1005 : 1 : valent_resource_set_publisher (ValentResource *resource,
1006 : : const char *publisher)
1007 : : {
1008 : 1 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
1009 : :
1010 [ + - ]: 1 : g_return_if_fail (VALENT_IS_RESOURCE (resource));
1011 : :
1012 [ + - ]: 1 : if (g_set_str (&priv->publisher, publisher))
1013 : 1 : g_object_notify_by_pspec (G_OBJECT (resource), properties[PROP_PUBLISHER]);
1014 : : }
1015 : :
1016 : : /**
1017 : : * valent_resource_get_relation: (get-property relation)
1018 : : * @resource: a `ValentResource`
1019 : : *
1020 : : * Gets the relation of @resource.
1021 : : *
1022 : : * Returns: (transfer none) (nullable): the relation of @resource
1023 : : *
1024 : : * Since: 1.0
1025 : : */
1026 : : GStrv
1027 : 1 : valent_resource_get_relation (ValentResource *resource)
1028 : : {
1029 : 1 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
1030 : :
1031 [ + - ]: 1 : g_return_val_if_fail (VALENT_IS_RESOURCE (resource), NULL);
1032 : :
1033 : 1 : return priv->relation;
1034 : : }
1035 : :
1036 : : /**
1037 : : * valent_resource_set_relation: (set-property relation)
1038 : : * @resource: a `ValentResource`
1039 : : * @relation: (nullable): the new relation
1040 : : *
1041 : : * Gets the title of @resource.
1042 : : *
1043 : : * Since: 1.0
1044 : : */
1045 : : void
1046 : 1 : valent_resource_set_relation (ValentResource *resource,
1047 : : GStrv relation)
1048 : : {
1049 : 1 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
1050 : :
1051 [ + - ]: 1 : g_return_if_fail (VALENT_IS_RESOURCE (resource));
1052 : :
1053 [ - + ]: 1 : if (priv->relation != relation)
1054 : : {
1055 [ # # ]: 0 : g_clear_pointer (&priv->relation, g_strfreev);
1056 : 0 : priv->contributor = g_strdupv (relation);
1057 : 0 : g_object_notify_by_pspec (G_OBJECT (resource), properties[PROP_RELATION]);
1058 : : }
1059 : : }
1060 : :
1061 : : /**
1062 : : * valent_resource_get_rights: (get-property rights)
1063 : : * @resource: a `ValentResource`
1064 : : *
1065 : : * Gets the rights of @resource.
1066 : : *
1067 : : * Returns: (transfer none) (nullable): the rights of @resource
1068 : : *
1069 : : * Since: 1.0
1070 : : */
1071 : : const char *
1072 : 1 : valent_resource_get_rights (ValentResource *resource)
1073 : : {
1074 : 1 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
1075 : :
1076 [ + - ]: 1 : g_return_val_if_fail (VALENT_IS_RESOURCE (resource), NULL);
1077 : :
1078 : 1 : return priv->rights;
1079 : : }
1080 : :
1081 : : /**
1082 : : * valent_resource_set_rights: (set-property rights)
1083 : : * @resource: a `ValentResource`
1084 : : * @rights: (nullable): the new rights
1085 : : *
1086 : : * Set the rights of @resource to @rights.
1087 : : *
1088 : : * Since: 1.0
1089 : : */
1090 : : void
1091 : 1 : valent_resource_set_rights (ValentResource *resource,
1092 : : const char *rights)
1093 : : {
1094 : 1 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
1095 : :
1096 [ + - ]: 1 : g_return_if_fail (VALENT_IS_RESOURCE (resource));
1097 : :
1098 [ + - ]: 1 : if (g_set_str (&priv->rights, rights))
1099 : 1 : g_object_notify_by_pspec (G_OBJECT (resource), properties[PROP_RIGHTS]);
1100 : : }
1101 : :
1102 : : /**
1103 : : * valent_resource_get_root:
1104 : : * @resource: a `ValentResource`
1105 : : *
1106 : : * Get the root source of @resource.
1107 : : *
1108 : : * In practice, the root of every resource should be a [class@Valent.DataSource].
1109 : : *
1110 : : * Returns: (type Valent.Resource) (transfer none) (nullable): the source
1111 : : * of @resource
1112 : : *
1113 : : * Since: 1.0
1114 : : */
1115 : : gpointer
1116 : 0 : valent_resource_get_root (ValentResource *resource)
1117 : : {
1118 : 0 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
1119 : 0 : ValentResource *root = resource;
1120 : :
1121 [ # # ]: 0 : g_return_val_if_fail (VALENT_IS_RESOURCE (resource), NULL);
1122 : :
1123 [ # # ]: 0 : while (priv->source != NULL)
1124 : : {
1125 : 0 : root = priv->source;
1126 : 0 : priv = valent_resource_get_instance_private (root);
1127 : : }
1128 : :
1129 : : return root;
1130 : : }
1131 : :
1132 : : /**
1133 : : * valent_resource_get_source: (get-property source)
1134 : : * @resource: a `ValentResource`
1135 : : *
1136 : : * Gets the source of @resource.
1137 : : *
1138 : : * Returns: (type Valent.Resource) (transfer none) (nullable): the source
1139 : : * of @resource
1140 : : *
1141 : : * Since: 1.0
1142 : : */
1143 : : gpointer
1144 : 604 : valent_resource_get_source (ValentResource *resource)
1145 : : {
1146 : 604 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
1147 : :
1148 [ + - ]: 604 : g_return_val_if_fail (VALENT_IS_RESOURCE (resource), NULL);
1149 : :
1150 : 604 : return priv->source;
1151 : : }
1152 : :
1153 : : /**
1154 : : * valent_resource_get_subject: (get-property subject)
1155 : : * @resource: a `ValentResource`
1156 : : *
1157 : : * Gets the subject of @resource.
1158 : : *
1159 : : * Returns: (transfer none) (nullable): the subject of @resource
1160 : : *
1161 : : * Since: 1.0
1162 : : */
1163 : : const char *
1164 : 1 : valent_resource_get_subject (ValentResource *resource)
1165 : : {
1166 : 1 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
1167 : :
1168 [ + - ]: 1 : g_return_val_if_fail (VALENT_IS_RESOURCE (resource), NULL);
1169 : :
1170 : 1 : return priv->subject;
1171 : : }
1172 : :
1173 : : /**
1174 : : * valent_resource_set_subject: (set-property subject)
1175 : : * @resource: a `ValentResource`
1176 : : * @subject: (nullable): the new subject
1177 : : *
1178 : : * Set the subject of @resource to @subject.
1179 : : *
1180 : : * Since: 1.0
1181 : : */
1182 : : void
1183 : 1 : valent_resource_set_subject (ValentResource *resource,
1184 : : const char *subject)
1185 : : {
1186 : 1 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
1187 : :
1188 [ + - ]: 1 : g_return_if_fail (VALENT_IS_RESOURCE (resource));
1189 : :
1190 [ + - ]: 1 : if (g_set_str (&priv->subject, subject))
1191 : 1 : g_object_notify_by_pspec (G_OBJECT (resource), properties[PROP_SUBJECT]);
1192 : : }
1193 : :
1194 : : /**
1195 : : * valent_resource_get_title: (get-property title)
1196 : : * @resource: a `ValentResource`
1197 : : *
1198 : : * Gets the title of @resource.
1199 : : *
1200 : : * Returns: (transfer none) (nullable): the title of @resource
1201 : : *
1202 : : * Since: 1.0
1203 : : */
1204 : : const char *
1205 : 9 : valent_resource_get_title (ValentResource *resource)
1206 : : {
1207 : 9 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
1208 : :
1209 [ + - ]: 9 : g_return_val_if_fail (VALENT_IS_RESOURCE (resource), NULL);
1210 : :
1211 : 9 : return priv->title;
1212 : : }
1213 : :
1214 : : /**
1215 : : * valent_resource_set_title: (set-property title)
1216 : : * @resource: a `ValentResource`
1217 : : * @title: (nullable): the new title
1218 : : *
1219 : : * Set the title of @resource to @title.
1220 : : *
1221 : : * Since: 1.0
1222 : : */
1223 : : void
1224 : 306 : valent_resource_set_title (ValentResource *resource,
1225 : : const char *title)
1226 : : {
1227 : 306 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
1228 : :
1229 [ + - ]: 306 : g_return_if_fail (VALENT_IS_RESOURCE (resource));
1230 : :
1231 [ + + ]: 306 : if (g_set_str (&priv->title, title))
1232 : 305 : g_object_notify_by_pspec (G_OBJECT (resource), properties[PROP_TITLE]);
1233 : : }
1234 : :
1235 : : /**
1236 : : * valent_resource_get_type_hint: (get-property type-hint)
1237 : : * @resource: a `ValentResource`
1238 : : *
1239 : : * Gets the type hint of @resource.
1240 : : *
1241 : : * Returns: (transfer none) (nullable): the nature or genre of @resource
1242 : : *
1243 : : * Since: 1.0
1244 : : */
1245 : : const char *
1246 : 1 : valent_resource_get_type_hint (ValentResource *resource)
1247 : : {
1248 : 1 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
1249 : :
1250 [ + - ]: 1 : g_return_val_if_fail (VALENT_IS_RESOURCE (resource), NULL);
1251 : :
1252 : 1 : return priv->type_hint;
1253 : : }
1254 : :
1255 : : /**
1256 : : * valent_resource_set_type_hint: (set-property type-hint)
1257 : : * @resource: a `ValentResource`
1258 : : * @type_hint: (nullable): the new type_hint
1259 : : *
1260 : : * Set the nature or genre of @resource to @type_hint.
1261 : : *
1262 : : * Since: 1.0
1263 : : */
1264 : : void
1265 : 1 : valent_resource_set_type_hint (ValentResource *resource,
1266 : : const char *type_hint)
1267 : : {
1268 : 1 : ValentResourcePrivate *priv = valent_resource_get_instance_private (resource);
1269 : :
1270 [ + - ]: 1 : g_return_if_fail (VALENT_IS_RESOURCE (resource));
1271 : :
1272 [ + - ]: 1 : if (g_set_str (&priv->type_hint, type_hint))
1273 : 1 : g_object_notify_by_pspec (G_OBJECT (resource), properties[PROP_TYPE_HINT]);
1274 : : }
1275 : :
1276 : : /**
1277 : : * valent_resource_update: (virtual update)
1278 : : * @resource: a `ValentResource`
1279 : : * @update: the resource update
1280 : : *
1281 : : * Update @resource from @update.
1282 : : *
1283 : : * Since: 1.0
1284 : : */
1285 : : void
1286 : 1 : valent_resource_update (ValentResource *resource,
1287 : : ValentResource *update)
1288 : : {
1289 [ + - ]: 1 : g_return_if_fail (VALENT_IS_RESOURCE (resource));
1290 [ - + ]: 1 : g_return_if_fail (VALENT_IS_RESOURCE (update));
1291 : :
1292 : 1 : VALENT_RESOURCE_GET_CLASS (resource)->update (resource, update);
1293 : : }
1294 : :
|