[rhythmbox] audioscrobbler: Add Libre.fm support in parallel to Last.fm
- From: Jonathan Matthew <jmatthew src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rhythmbox] audioscrobbler: Add Libre.fm support in parallel to Last.fm
- Date: Tue, 21 Sep 2010 10:53:07 +0000 (UTC)
commit 7a97ffde9b88ea1c14980a81bffd4ed2ecd64c43
Author: Jamie Nicol <jamie thenicols net>
Date: Tue Jul 20 15:21:07 2010 +0100
audioscrobbler: Add Libre.fm support in parallel to Last.fm
.../{as-icon.png => Last.fm-icon.png} | Bin 1014 -> 1014 bytes
.../{as-icon.svg => Last.fm-icon.svg} | 0
plugins/audioscrobbler/Libre.fm-icon.png | Bin 0 -> 803 bytes
plugins/audioscrobbler/Makefile.am | 6 +++-
plugins/audioscrobbler/rb-audioscrobbler-plugin.c | 23 +++++++++++++------
.../rb-audioscrobbler-profile-source.c | 12 +++++++---
plugins/audioscrobbler/rb-audioscrobbler-service.c | 23 +++++++++++++++++++-
plugins/audioscrobbler/rb-audioscrobbler-service.h | 3 +-
8 files changed, 52 insertions(+), 15 deletions(-)
---
diff --git a/plugins/audioscrobbler/as-icon.png b/plugins/audioscrobbler/Last.fm-icon.png
similarity index 100%
rename from plugins/audioscrobbler/as-icon.png
rename to plugins/audioscrobbler/Last.fm-icon.png
diff --git a/plugins/audioscrobbler/as-icon.svg b/plugins/audioscrobbler/Last.fm-icon.svg
similarity index 100%
rename from plugins/audioscrobbler/as-icon.svg
rename to plugins/audioscrobbler/Last.fm-icon.svg
diff --git a/plugins/audioscrobbler/Libre.fm-icon.png b/plugins/audioscrobbler/Libre.fm-icon.png
new file mode 100644
index 0000000..816153a
Binary files /dev/null and b/plugins/audioscrobbler/Libre.fm-icon.png differ
diff --git a/plugins/audioscrobbler/Makefile.am b/plugins/audioscrobbler/Makefile.am
index 2cf9a7c..3c582de 100644
--- a/plugins/audioscrobbler/Makefile.am
+++ b/plugins/audioscrobbler/Makefile.am
@@ -68,14 +68,16 @@ BUILT_SOURCES = \
plugin_DATA = \
$(BUILT_SOURCES) \
- $(top_srcdir)/plugins/audioscrobbler/as-icon.png \
+ $(top_srcdir)/plugins/audioscrobbler/Last.fm-icon.png \
+ $(top_srcdir)/plugins/audioscrobbler/Libre.fm-icon.png \
$(NULL)
EXTRA_DIST = \
$(plugin_in_files) \
$(uixml_DATA) \
$(gtkbuilder_DATA) \
- $(top_srcdir)/plugins/audioscrobbler/as-icon.png \
+ $(top_srcdir)/plugins/audioscrobbler/Last.fm-icon.png \
+ $(top_srcdir)/plugins/audioscrobbler/Libre.fm-icon.png \
$(top_srcdir)/plugins/audioscrobbler/as-powered.png \
$(NULL)
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-plugin.c b/plugins/audioscrobbler/rb-audioscrobbler-plugin.c
index 93ede36..244d37c 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-plugin.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler-plugin.c
@@ -57,7 +57,8 @@ typedef struct
RBPlugin parent;
guint ui_merge_id;
- RBSource *source;
+ RBSource *lastfm_source;
+ RBSource *librefm_source;
} RBAudioscrobblerPlugin;
typedef struct
@@ -112,7 +113,8 @@ impl_activate (RBPlugin *bplugin,
RBAudioscrobblerPlugin *plugin;
GtkUIManager *ui_manager;
char *file;
- RBAudioscrobblerService *service;
+ RBAudioscrobblerService *lastfm;
+ RBAudioscrobblerService *librefm;
plugin = RB_AUDIOSCROBBLER_PLUGIN (bplugin);
@@ -123,11 +125,15 @@ impl_activate (RBPlugin *bplugin,
NULL);
g_free (file);
- service = rb_audioscrobbler_service_new ();
- plugin->source = rb_audioscrobbler_profile_source_new (shell, bplugin, service);
+ lastfm = rb_audioscrobbler_service_new_lastfm ();
+ plugin->lastfm_source = rb_audioscrobbler_profile_source_new (shell, bplugin, lastfm);
+
+ librefm = rb_audioscrobbler_service_new_librefm ();
+ plugin->librefm_source = rb_audioscrobbler_profile_source_new (shell, bplugin, librefm);
g_object_unref (ui_manager);
- g_object_unref (service);
+ g_object_unref (lastfm);
+ g_object_unref (librefm);
}
static void
@@ -140,8 +146,11 @@ impl_deactivate (RBPlugin *bplugin,
g_object_get (shell, "ui-manager", &ui_manager, NULL);
gtk_ui_manager_remove_ui (ui_manager, plugin->ui_merge_id);
- rb_source_delete_thyself (plugin->source);
- plugin->source = NULL;
+ rb_source_delete_thyself (plugin->lastfm_source);
+ plugin->lastfm_source = NULL;
+
+ rb_source_delete_thyself (plugin->librefm_source);
+ plugin->librefm_source = NULL;
g_object_unref (ui_manager);
}
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-profile-source.c b/plugins/audioscrobbler/rb-audioscrobbler-profile-source.c
index 84c3269..29f5177 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-profile-source.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler-profile-source.c
@@ -234,16 +234,19 @@ rb_audioscrobbler_profile_source_new (RBShell *shell, RBPlugin *plugin, RBAudios
RBSource *source;
RhythmDB *db;
char *name;
- gchar *icon_filename;
+ gchar *icon_name;
+ gchar *icon_path;
gint icon_size;
GdkPixbuf *icon_pixbuf;
g_object_get (shell, "db", &db, NULL);
g_object_get (service, "name", &name, NULL);
- icon_filename = rb_plugin_find_file (plugin, "as-icon.png");
+
+ icon_name = g_strconcat (rb_audioscrobbler_service_get_name (service), "-icon.png", NULL);
+ icon_path = rb_plugin_find_file (plugin, icon_name);
gtk_icon_size_lookup (GTK_ICON_SIZE_LARGE_TOOLBAR, &icon_size, NULL);
- icon_pixbuf = gdk_pixbuf_new_from_file_at_size (icon_filename, icon_size, icon_size, NULL);
+ icon_pixbuf = gdk_pixbuf_new_from_file_at_size (icon_path, icon_size, icon_size, NULL);
source = RB_SOURCE (g_object_new (RB_TYPE_AUDIOSCROBBLER_PROFILE_SOURCE,
"shell", shell,
@@ -257,7 +260,8 @@ rb_audioscrobbler_profile_source_new (RBShell *shell, RBPlugin *plugin, RBAudios
g_object_unref (db);
g_free (name);
- g_free (icon_filename);
+ g_free (icon_name);
+ g_free (icon_path);
g_object_unref (icon_pixbuf);
return source;
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-service.c b/plugins/audioscrobbler/rb-audioscrobbler-service.c
index 1ca8fd6..7484570 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-service.c
+++ b/plugins/audioscrobbler/rb-audioscrobbler-service.c
@@ -38,6 +38,13 @@
#define LASTFM_API_KEY "0337ff3c59299b6a31d75164041860b6"
#define LASTFM_API_SECRET "776c85a04a445efa8f9ed7705473c606"
+#define LIBREFM_NAME "Libre.fm"
+#define LIBREFM_AUTH_URL "http://alpha.libre.fm/api/auth/"
+#define LIBREFM_SCROBBLER_URL "http://turtle.libre.fm/"
+#define LIBREFM_API_URL "http://alpha.libre.fm/2.0/"
+#define LIBREFM_API_KEY "a string 32 characters in length"
+#define LIBREFM_API_SECRET "a string 32 characters in length"
+
struct _RBAudioscrobblerServicePrivate {
char *name;
char *auth_url;
@@ -75,7 +82,7 @@ enum
G_DEFINE_TYPE (RBAudioscrobblerService, rb_audioscrobbler_service, G_TYPE_OBJECT)
RBAudioscrobblerService *
-rb_audioscrobbler_service_new (void)
+rb_audioscrobbler_service_new_lastfm (void)
{
/* create a Last.fm service */
return g_object_new (RB_TYPE_AUDIOSCROBBLER_SERVICE,
@@ -88,6 +95,20 @@ rb_audioscrobbler_service_new (void)
NULL);
}
+RBAudioscrobblerService *
+rb_audioscrobbler_service_new_librefm (void)
+{
+ /* create a Libre.fm service */
+ return g_object_new (RB_TYPE_AUDIOSCROBBLER_SERVICE,
+ "name", LIBREFM_NAME,
+ "auth-url", LIBREFM_AUTH_URL,
+ "scrobbler-url", LIBREFM_SCROBBLER_URL,
+ "api-url", LIBREFM_API_URL,
+ "api-key", LIBREFM_API_KEY,
+ "api-secret", LIBREFM_API_SECRET,
+ NULL);
+}
+
static void
rb_audioscrobbler_service_class_init (RBAudioscrobblerServiceClass *klass)
{
diff --git a/plugins/audioscrobbler/rb-audioscrobbler-service.h b/plugins/audioscrobbler/rb-audioscrobbler-service.h
index 5d0fa78..0b3df5c 100644
--- a/plugins/audioscrobbler/rb-audioscrobbler-service.h
+++ b/plugins/audioscrobbler/rb-audioscrobbler-service.h
@@ -54,7 +54,8 @@ typedef struct {
GType rb_audioscrobbler_service_get_type (void);
-RBAudioscrobblerService *rb_audioscrobbler_service_new (void);
+RBAudioscrobblerService *rb_audioscrobbler_service_new_lastfm (void);
+RBAudioscrobblerService *rb_audioscrobbler_service_new_librefm (void);
const char *rb_audioscrobbler_service_get_name (RBAudioscrobblerService *service);
const char *rb_audioscrobbler_service_get_auth_url (RBAudioscrobblerService *service);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]