hythmbox-2.98/plugins/audioscrobbler/rb-audioscrobbler-radio-track-entry-type.c

No issues found

 1 /*
 2  * rb-audioscrobbler-radio-track-entry.c
 3  *
 4  * Copyright (C) 2010 Jamie Nicol <jamie@thenicols.net>
 5  *
 6  * This program is free software; you can redistribute it and/or modify
 7  * it under the terms of the GNU General Public License as published by
 8  * the Free Software Foundation; either version 2, or (at your option)
 9  * any later version.
10  *
11  * The Rhythmbox authors hereby grant permission for non-GPL compatible
12  * GStreamer plugins to be used and distributed together with GStreamer
13  * and Rhythmbox. This permission is above and beyond the permissions granted
14  * by the GPL license by which Rhythmbox is covered. If you modify this code
15  * you may extend this exception to your version of the code, but you are not
16  * obligated to do so. If you do not wish to do so, delete this exception
17  * statement from your version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA.
27  */
28 
29 #include "rb-audioscrobbler-radio-track-entry-type.h"
30 
31 typedef struct _RhythmDBEntryType RBAudioscrobblerRadioEntryType;
32 typedef struct _RhythmDBEntryTypeClass RBAudioscrobblerRadioEntryTypeClass;
33 
34 GType rb_audioscrobbler_radio_entry_type_get_type (void);
35 
36 G_DEFINE_DYNAMIC_TYPE (RBAudioscrobblerRadioEntryType, rb_audioscrobbler_radio_entry_type, RHYTHMDB_TYPE_ENTRY_TYPE);
37 
38 static RhythmDBEntryType *radio_track_entry_type = NULL;
39 
40 static void
41 track_data_destroy (RhythmDBEntryType *entry_type, RhythmDBEntry *entry)
42 {
43 	RBAudioscrobblerRadioTrackData *data;
44 	data = RHYTHMDB_ENTRY_GET_TYPE_DATA (entry, RBAudioscrobblerRadioTrackData);
45 
46 	g_free (data->image_url);
47 	g_free (data->track_auth);
48 	g_free (data->download_url);
49 }
50 
51 static void
52 rb_audioscrobbler_radio_entry_type_class_init (RBAudioscrobblerRadioEntryTypeClass *klass)
53 {
54 	RhythmDBEntryTypeClass *etype_class = RHYTHMDB_ENTRY_TYPE_CLASS (klass);
55 	etype_class->destroy_entry = track_data_destroy;
56 }
57 
58 static void
59 rb_audioscrobbler_radio_entry_type_class_finalize (RBAudioscrobblerRadioEntryTypeClass *klass)
60 {
61 }
62 
63 static void
64 rb_audioscrobbler_radio_entry_type_init (RBAudioscrobblerRadioEntryType *etype)
65 {
66 }
67 
68 RhythmDBEntryType *
69 rb_audioscrobbler_radio_track_get_entry_type (void)
70 {
71 	return radio_track_entry_type;
72 }
73 
74 void
75 rb_audioscrobbler_radio_track_register_entry_type (RhythmDB *db)
76 {
77 	g_assert (radio_track_entry_type == NULL);
78 
79 	radio_track_entry_type = g_object_new (rb_audioscrobbler_radio_entry_type_get_type (),
80 	                                       "db", db,
81 	                                       "name", "audioscrobbler-radio-track",
82 	                                       "save-to-disk", FALSE,
83 	                                       "category", RHYTHMDB_ENTRY_NORMAL,
84 	                                       "type-data-size", sizeof (RBAudioscrobblerRadioTrackData),
85 	                                       NULL);
86 
87 	rhythmdb_register_entry_type (db, radio_track_entry_type);
88 }
89 
90 void
91 _rb_audioscrobbler_radio_track_entry_type_register_type (GTypeModule *module)
92 {
93 	rb_audioscrobbler_radio_entry_type_register_type (module);
94 }