1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * Copyright (C) 2011 Shaun McCance <shaunm@gnome.org>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, see <http://www.gnu.org/licenses/>.
18 * Author: Shaun McCance <shaunm@gnome.org>
21 #include "yelp-storage.h"
22 #include "yelp-sqlite-storage.h"
24 G_DEFINE_INTERFACE (YelpStorage
, yelp_storage
, G_TYPE_OBJECT
)
26 static YelpStorage
*default_storage
;
29 yelp_storage_default_init (YelpStorageInterface
*iface
)
31 default_storage
= NULL
;
35 yelp_storage_set_default (YelpStorage
*storage
)
37 default_storage
= g_object_ref (storage
);
41 yelp_storage_get_default (void)
44 g_mutex_lock (&mutex
);
45 if (default_storage
== NULL
)
46 default_storage
= yelp_sqlite_storage_new (":memory:");
47 g_mutex_unlock (&mutex
);
48 return default_storage
;
52 yelp_storage_update (YelpStorage
*storage
,
54 const gchar
*full_uri
,
60 YelpStorageInterface
*iface
;
62 g_return_if_fail (YELP_IS_STORAGE (storage
));
64 iface
= YELP_STORAGE_GET_INTERFACE (storage
);
67 (*iface
->update
) (storage
,
74 yelp_storage_search (YelpStorage
*storage
,
78 YelpStorageInterface
*iface
;
80 g_return_val_if_fail (YELP_IS_STORAGE (storage
), NULL
);
82 iface
= YELP_STORAGE_GET_INTERFACE (storage
);
85 return (*iface
->search
) (storage
, doc_uri
, text
);
91 yelp_storage_get_root_title (YelpStorage
*storage
,
94 YelpStorageInterface
*iface
;
96 g_return_val_if_fail (YELP_IS_STORAGE (storage
), NULL
);
98 iface
= YELP_STORAGE_GET_INTERFACE (storage
);
101 return (*iface
->get_root_title
) (storage
, doc_uri
);
107 yelp_storage_set_root_title (YelpStorage
*storage
,
108 const gchar
*doc_uri
,
111 YelpStorageInterface
*iface
;
113 g_return_if_fail (YELP_IS_STORAGE (storage
));
115 iface
= YELP_STORAGE_GET_INTERFACE (storage
);
118 (*iface
->set_root_title
) (storage
, doc_uri
, title
);