1 /*
2  * Database record class for DMAP sharing
3  *
4  * Copyright (C) 2008 W. Michael Petullo <mike@flyn.org>
5  *
6  * This library 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  * This library 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 this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  */
20 
21 #include "test-dmap-container-record.h"
22 
23 enum {
24         PROP_0,
25 	PROP_NAME
26 };
27 
28 static DMAPDb *entries = NULL;
29 
30 static void
test_dmap_container_record_set_property(GObject * object,guint prop_id,const GValue * value,GParamSpec * pspec)31 test_dmap_container_record_set_property (GObject *object,
32                                          guint prop_id,
33                                          const GValue *value,
34                                          GParamSpec *pspec)
35 {
36         switch (prop_id) {
37                 case PROP_NAME:
38 			/* NOTE: do nothing; test name is always the same. */
39                         break;
40                 default:
41                         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
42                         break;
43         }
44 }
45 
46 static void
test_dmap_container_record_get_property(GObject * object,guint prop_id,GValue * value,GParamSpec * pspec)47 test_dmap_container_record_get_property (GObject *object,
48                                          guint prop_id,
49                                          GValue *value,
50                                          GParamSpec *pspec)
51 {
52         switch (prop_id) {
53                 case PROP_NAME:
54                         g_value_set_string (value, "Test");
55                         break;
56                 default:
57                         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
58                         break;
59         }
60 }
61 
62 
63 guint
test_dmap_container_record_get_id(DMAPContainerRecord * record)64 test_dmap_container_record_get_id (DMAPContainerRecord *record)
65 {
66 	return 2;
67 }
68 
69 void
test_dmap_container_record_add_entry(DMAPContainerRecord * container_record,DMAPRecord * record,gint id)70 test_dmap_container_record_add_entry (DMAPContainerRecord *container_record,
71 				      DMAPRecord *record,
72 				      gint id)
73 {
74 }
75 
76 guint64
test_dmap_container_record_get_entry_count(DMAPContainerRecord * record)77 test_dmap_container_record_get_entry_count (DMAPContainerRecord *record)
78 {
79         return 1;
80 }
81 
82 DMAPDb *
test_dmap_container_record_get_entries(DMAPContainerRecord * record)83 test_dmap_container_record_get_entries (DMAPContainerRecord *record)
84 {
85 	return g_object_ref (entries);
86 }
87 
88 static void
test_dmap_container_record_init(TestDMAPContainerRecord * record)89 test_dmap_container_record_init (TestDMAPContainerRecord *record)
90 {
91 	entries = DMAP_DB (test_dmap_db_new ());
92 }
93 
94 static void
test_dmap_container_record_class_init(TestDMAPContainerRecordClass * klass)95 test_dmap_container_record_class_init (TestDMAPContainerRecordClass *klass)
96 {
97 	GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
98 
99 	gobject_class->set_property = test_dmap_container_record_set_property;
100         gobject_class->get_property = test_dmap_container_record_get_property;
101 
102         g_object_class_override_property (gobject_class, PROP_NAME, "name");
103 }
104 
105 static void
test_dmap_container_record_interface_init(gpointer iface,gpointer data)106 test_dmap_container_record_interface_init (gpointer iface, gpointer data)
107 {
108 	DMAPContainerRecordIface *dmap_container_record = iface;
109 
110 	g_assert (G_TYPE_FROM_INTERFACE (dmap_container_record) == DMAP_TYPE_CONTAINER_RECORD);
111 
112 	dmap_container_record->get_id = test_dmap_container_record_get_id;
113 	dmap_container_record->add_entry = test_dmap_container_record_add_entry;
114 	dmap_container_record->get_entry_count = test_dmap_container_record_get_entry_count;
115 	dmap_container_record->get_entries = test_dmap_container_record_get_entries;
116 }
117 
G_DEFINE_TYPE_WITH_CODE(TestDMAPContainerRecord,test_dmap_container_record,G_TYPE_OBJECT,G_IMPLEMENT_INTERFACE (DMAP_TYPE_CONTAINER_RECORD,test_dmap_container_record_interface_init))118 G_DEFINE_TYPE_WITH_CODE (TestDMAPContainerRecord, test_dmap_container_record, G_TYPE_OBJECT,
119 			G_IMPLEMENT_INTERFACE (DMAP_TYPE_CONTAINER_RECORD,
120 					       test_dmap_container_record_interface_init))
121 
122 TestDMAPContainerRecord *test_dmap_container_record_new (void)
123 {
124 	TestDMAPContainerRecord *record;
125 
126 	record = TEST_DMAP_CONTAINER_RECORD (g_object_new (TYPE_TEST_DMAP_CONTAINER_RECORD, NULL));
127 
128 	return record;
129 }
130