Make it compile with new files.
[mmediamanager.git] / src / mm-attribute-base-manager.c
blobbad4fbcf8a3c33c4f50988fcfb90797ce5429d74
1 /* MManager - a Desktop wide manager for multimedia applications.
3 * Copyright (C) 2008 Cosimo Cecchi <cosimoc@gnome.org>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library 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 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
21 #include <glib.h>
22 #include <glib-object.h>
23 #include <glib/gi18n.h>
25 #include "mm-attribute-manager.h"
26 #include "mm-attribute-base-manager.h"
27 #include "mm-base-attributes.h"
29 static MMAttributeManager *base_manager = NULL;
31 static void mm_attribute_manager_iface_init (MMAttributeManagerIface *iface);
33 G_DEFINE_TYPE_WITH_CODE (MMAttributeBaseManager, mm_attribute_base_manager,
34 G_TYPE_OBJECT,
35 G_IMPLEMENT_INTERFACE (MM_TYPE_ATTRIBUTE_MANAGER,
36 mm_attribute_manager_iface_init));
37 /* base attributes */
39 static const char * attribute_ids [] = {
40 MM_ATTRIBUTE_BASE_URI,
41 MM_ATTRIBUTE_BASE_NAME
44 static const GType attribute_types [] = {
45 G_TYPE_STRING,
46 G_TYPE_STRING
49 static const char * attribute_names [] = {
50 N_("URI"),
51 N_("Name")
54 static const char * attribute_descriptions [] = {
55 N_("URI of the resource"),
56 N_("Name of the resource")
59 /* MMAttributeManager interface implementation */
61 static MMAttribute *
62 impl_lookup_attribute (MMAttributeManager *m,
63 const char *id)
65 int idx;
66 gboolean found = FALSE;
68 for (idx = 0; idx < G_N_ELEMENTS (attribute_ids); idx++) {
69 if (g_strcmp0 (attribute_ids[idx], id) == 0) {
70 found = TRUE;
71 break;
75 if (found) {
76 return mm_attribute_new (attribute_types[idx],
77 attribute_ids[idx],
78 attribute_names[idx],
79 attribute_descriptions[idx]);
80 } else {
81 return NULL;
85 static GList *
86 impl_get_supported_attributes (MMAttributeManager *m)
88 GList *attributes = NULL;
89 int idx;
90 MMAttribute *attr;
92 for (idx = 0; idx < G_N_ELEMENTS (attribute_ids); idx++) {
93 attr = mm_attribute_new (attribute_types[idx],
94 attribute_ids[idx],
95 attribute_names[idx],
96 attribute_descriptions[idx]);
97 attributes = g_list_prepend (attributes, attr);
100 return g_list_reverse (attributes);
103 static void
104 mm_attribute_manager_iface_init (MMAttributeManagerIface *iface)
106 iface->lookup_attribute = impl_lookup_attribute;
107 iface->get_supported_attributes = impl_get_supported_attributes;
110 MMAttributeManager *
111 mm_attribute_base_manager_get (void)
113 if (!base_manager) {
114 base_manager = MM_ATTRIBUTE_MANAGER (g_object_new (MM_TYPE_ATTRIBUTE_BASE_MANAGER, NULL));
117 return base_manager;
120 static void
121 mm_attribute_base_manager_init (MMAttributeBaseManager *abm)
125 static void
126 mm_attribute_base_manager_class_init (MMAttributeBaseManagerClass *klass)