tracker-0.16.2/src/libtracker-data/tracker-ontology.c

No issues found

  1 /*
  2  * Copyright (C) 2009, Nokia <ivan.frade@nokia.com>
  3  *
  4  * This library is free software; you can redistribute it and/or
  5  * modify it under the terms of the GNU Lesser General Public
  6  * License as published by the Free Software Foundation; either
  7  * version 2.1 of the License, or (at your option) any later version.
  8  *
  9  * This library is distributed in the hope that it will be useful,
 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 12  * Lesser General Public License for more details.
 13  *
 14  * You should have received a copy of the GNU Lesser General Public
 15  * License along with this library; if not, write to the
 16  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 17  * Boston, MA  02110-1301, USA.
 18  *
 19  * Author: Philip Van Hoof <philip@codeminded.be>
 20  */
 21 
 22 #include "config.h"
 23 
 24 #include <string.h>
 25 #include <stdlib.h>
 26 
 27 #include <glib.h>
 28 
 29 #include "tracker-ontology.h"
 30 
 31 #define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), TRACKER_TYPE_ONTOLOGY, TrackerOntologyPrivate))
 32 
 33 typedef struct _TrackerOntologyPrivate TrackerOntologyPrivate;
 34 
 35 struct _TrackerOntologyPrivate {
 36 	gchar *uri;
 37 	time_t last_modified;
 38 	gboolean is_new;
 39 };
 40 
 41 static void ontology_finalize     (GObject      *object);
 42 
 43 G_DEFINE_TYPE (TrackerOntology, tracker_ontology, G_TYPE_OBJECT);
 44 
 45 static void
 46 tracker_ontology_class_init (TrackerOntologyClass *klass)
 47 {
 48 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
 49 
 50 	object_class->finalize     = ontology_finalize;
 51 
 52 	g_type_class_add_private (object_class, sizeof (TrackerOntologyPrivate));
 53 }
 54 
 55 static void
 56 tracker_ontology_init (TrackerOntology *service)
 57 {
 58 }
 59 
 60 static void
 61 ontology_finalize (GObject *object)
 62 {
 63 	TrackerOntologyPrivate *priv;
 64 
 65 	priv = GET_PRIV (object);
 66 
 67 	g_free (priv->uri);
 68 
 69 	(G_OBJECT_CLASS (tracker_ontology_parent_class)->finalize) (object);
 70 }
 71 
 72 TrackerOntology *
 73 tracker_ontology_new (void)
 74 {
 75 	TrackerOntology *ontology;
 76 
 77 	ontology = g_object_new (TRACKER_TYPE_ONTOLOGY, NULL);
 78 
 79 	return ontology;
 80 }
 81 
 82 time_t
 83 tracker_ontology_get_last_modified (TrackerOntology *ontology)
 84 {
 85 	TrackerOntologyPrivate *priv;
 86 
 87 	g_return_val_if_fail (TRACKER_IS_ONTOLOGY (ontology), 0);
 88 
 89 	priv = GET_PRIV (ontology);
 90 
 91 	return priv->last_modified;
 92 }
 93 
 94 gboolean
 95 tracker_ontology_get_is_new (TrackerOntology *ontology)
 96 {
 97 	TrackerOntologyPrivate *priv;
 98 
 99 	g_return_val_if_fail (TRACKER_IS_ONTOLOGY (ontology), FALSE);
100 
101 	priv = GET_PRIV (ontology);
102 
103 	return priv->is_new;
104 }
105 
106 
107 void
108 tracker_ontology_set_last_modified (TrackerOntology *ontology,
109                                     time_t           value)
110 {
111 	TrackerOntologyPrivate *priv;
112 
113 	g_return_if_fail (TRACKER_IS_ONTOLOGY (ontology));
114 
115 	priv = GET_PRIV (ontology);
116 
117 	priv->last_modified = value;
118 }
119 
120 
121 const gchar *
122 tracker_ontology_get_uri (TrackerOntology *ontology)
123 {
124 	TrackerOntologyPrivate *priv;
125 
126 	g_return_val_if_fail (TRACKER_IS_ONTOLOGY (ontology), NULL);
127 
128 	priv = GET_PRIV (ontology);
129 
130 	return priv->uri;
131 }
132 
133 
134 void
135 tracker_ontology_set_uri (TrackerOntology *ontology,
136                           const gchar    *value)
137 {
138 	TrackerOntologyPrivate *priv;
139 
140 	g_return_if_fail (TRACKER_IS_ONTOLOGY (ontology));
141 
142 	priv = GET_PRIV (ontology);
143 
144 	g_free (priv->uri);
145 
146 	if (value) {
147 		priv->uri = g_strdup (value);
148 	} else {
149 		priv->uri = NULL;
150 	}
151 }
152 
153 void
154 tracker_ontology_set_is_new (TrackerOntology *ontology,
155                              gboolean         value)
156 {
157 	TrackerOntologyPrivate *priv;
158 
159 	g_return_if_fail (TRACKER_IS_ONTOLOGY (ontology));
160 
161 	priv = GET_PRIV (ontology);
162 
163 	priv->is_new = value;
164 }