1 /*
2 * Copyright (C) 2008 Marc Pavot <marc.pavot@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2, or (at your option)
7 * any later version.
8 *
9 * This program 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
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 *
18 */
19
20 #include "covers/ario-cover-provider.h"
21 #include <config.h>
22 #include "ario-debug.h"
23
G_DEFINE_TYPE(ArioCoverProvider,ario_cover_provider,G_TYPE_OBJECT)24 G_DEFINE_TYPE (ArioCoverProvider, ario_cover_provider, G_TYPE_OBJECT)
25
26 static gboolean
27 dummy_boolean (ArioCoverProvider *cover_provider,
28 const char *artist,
29 const char *album,
30 const char *file,
31 GArray **file_size,
32 GSList **file_contents,
33 ArioCoverProviderOperation operation)
34 {
35 return FALSE;
36 }
37
38 static gchar *
dummy_char(ArioCoverProvider * cover_provider)39 dummy_char (ArioCoverProvider *cover_provider)
40 {
41 return NULL;
42 }
43
44 static void
ario_cover_provider_class_init(ArioCoverProviderClass * klass)45 ario_cover_provider_class_init (ArioCoverProviderClass *klass)
46 {
47 klass->get_id = dummy_char;
48 klass->get_name = dummy_char;
49 klass->get_covers = dummy_boolean;
50 }
51
52 static void
ario_cover_provider_init(ArioCoverProvider * cover_provider)53 ario_cover_provider_init (ArioCoverProvider *cover_provider)
54 {
55 cover_provider->is_active = FALSE;
56 }
57
58 gchar *
ario_cover_provider_get_id(ArioCoverProvider * cover_provider)59 ario_cover_provider_get_id (ArioCoverProvider *cover_provider)
60 {
61 g_return_val_if_fail (ARIO_IS_COVER_PROVIDER (cover_provider), FALSE);
62
63 return ARIO_COVER_PROVIDER_GET_CLASS (cover_provider)->get_id (cover_provider);
64 }
65
66 gchar *
ario_cover_provider_get_name(ArioCoverProvider * cover_provider)67 ario_cover_provider_get_name (ArioCoverProvider *cover_provider)
68 {
69 g_return_val_if_fail (ARIO_IS_COVER_PROVIDER (cover_provider), FALSE);
70
71 return ARIO_COVER_PROVIDER_GET_CLASS (cover_provider)->get_name (cover_provider);
72 }
73
74 gboolean
ario_cover_provider_get_covers(ArioCoverProvider * cover_provider,const char * artist,const char * album,const char * file,GArray ** file_size,GSList ** file_contents,ArioCoverProviderOperation operation)75 ario_cover_provider_get_covers (ArioCoverProvider *cover_provider,
76 const char *artist,
77 const char *album,
78 const char *file,
79 GArray **file_size,
80 GSList **file_contents,
81 ArioCoverProviderOperation operation)
82 {
83 g_return_val_if_fail (ARIO_IS_COVER_PROVIDER (cover_provider), FALSE);
84
85 return ARIO_COVER_PROVIDER_GET_CLASS (cover_provider)->get_covers (cover_provider,
86 artist, album,
87 file,
88 file_size, file_contents,
89 operation);
90 }
91
92
93 gboolean
ario_cover_provider_is_active(ArioCoverProvider * cover_provider)94 ario_cover_provider_is_active (ArioCoverProvider *cover_provider)
95 {
96 ARIO_LOG_FUNCTION_START;
97 return cover_provider->is_active;
98 }
99
100 void
ario_cover_provider_set_active(ArioCoverProvider * cover_provider,gboolean is_active)101 ario_cover_provider_set_active (ArioCoverProvider *cover_provider,
102 gboolean is_active)
103 {
104 ARIO_LOG_FUNCTION_START;
105 cover_provider->is_active = is_active;
106 }
107
108