banshee r4381 - in trunk/banshee: . build src/Dap src/Dap/Banshee.Dap.Karma src/Dap/Banshee.Dap.Karma/Banshee.Dap.Karma
- From: blorentz svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r4381 - in trunk/banshee: . build src/Dap src/Dap/Banshee.Dap.Karma src/Dap/Banshee.Dap.Karma/Banshee.Dap.Karma
- Date: Fri, 15 Aug 2008 21:00:37 +0000 (UTC)
Author: blorentz
Date: Fri Aug 15 21:00:37 2008
New Revision: 4381
URL: http://svn.gnome.org/viewvc/banshee?rev=4381&view=rev
Log:
2008-08-15 Bertrand Lorentz <bertrand lorentz gmail com>
* src/Dap/Banshee.Dap.Karma/Banshee.Dap.Karma.addin.xml:
* src/Dap/Banshee.Dap.Karma/Banshee.Dap.Karma/KarmaTrackInfo.cs:
* src/Dap/Banshee.Dap.Karma/Banshee.Dap.Karma/KarmaSource.cs:
* src/Dap/Banshee.Dap.Karma/Makefile.am:
* src/Dap/Makefile.am:
* build/build.environment.mk:
* configure.ac: Patch from Bob Copeland to add Karma DAP support. It is
enabled through the --enable-karma configure option and requires karma-sharp
(BGO #541828).
Added:
trunk/banshee/src/Dap/Banshee.Dap.Karma/
trunk/banshee/src/Dap/Banshee.Dap.Karma/Banshee.Dap.Karma/
trunk/banshee/src/Dap/Banshee.Dap.Karma/Banshee.Dap.Karma.addin.xml
trunk/banshee/src/Dap/Banshee.Dap.Karma/Banshee.Dap.Karma/KarmaSource.cs
trunk/banshee/src/Dap/Banshee.Dap.Karma/Banshee.Dap.Karma/KarmaTrackInfo.cs
trunk/banshee/src/Dap/Banshee.Dap.Karma/Makefile.am
Modified:
trunk/banshee/ChangeLog
trunk/banshee/build/build.environment.mk
trunk/banshee/configure.ac
trunk/banshee/src/Dap/Makefile.am
Modified: trunk/banshee/build/build.environment.mk
==============================================================================
--- trunk/banshee/build/build.environment.mk (original)
+++ trunk/banshee/build/build.environment.mk Fri Aug 15 21:00:37 2008
@@ -66,6 +66,11 @@
LINK_MTP = -r:$(DIR_BIN)/Mtp.dll
LINK_MTP_DEPS = $(REF_MTP) $(LINK_MTP)
+# Karma
+REF_KARMA = $(LINK_SYSTEM) $(LINK_MONO_POSIX)
+LINK_KARMA = $(KARMASHARP_LIBS)
+LINK_KARMA_DEPS = $(REF_KARMA) $(LINK_KARMA)
+
# MusicBrainz
REF_MUSICBRAINZ = $(LINK_SYSTEM)
LINK_MUSICBRAINZ = -r:$(DIR_BIN)/MusicBrainz.dll
@@ -101,6 +106,7 @@
REF_DAP_MASS_STORAGE = $(LINK_DAP_DEPS)
REF_DAP_MTP = $(LINK_DAP_DEPS) $(LINK_MTP_DEPS)
REF_DAP_IPOD = $(LINK_DAP_DEPS) $(LINK_IPOD)
+REF_DAP_KARMA = $(LINK_DAP_DEPS) $(LINK_KARMA_DEPS)
# Extensions
REF_EXTENSION_AUDIOCD = $(LINK_BANSHEE_THICKCLIENT_DEPS) $(LINK_MUSICBRAINZ_DEPS)
Modified: trunk/banshee/configure.ac
==============================================================================
--- trunk/banshee/configure.ac (original)
+++ trunk/banshee/configure.ac Fri Aug 15 21:00:37 2008
@@ -86,6 +86,7 @@
dnl DAP support (each module is optional)
BANSHEE_CHECK_DAP_MTP
BANSHEE_CHECK_DAP_IPOD
+BANSHEE_CHECK_DAP_KARMA
dnl DAAP support (optional)
BANSHEE_CHECK_DAAP
@@ -165,6 +166,7 @@
src/Dap/Banshee.Dap.Ipod/Makefile
src/Dap/Banshee.Dap.MassStorage/Makefile
src/Dap/Banshee.Dap.Mtp/Makefile
+src/Dap/Banshee.Dap.Karma/Makefile
src/Extensions/Makefile
src/Extensions/Banshee.AudioCd/Makefile
@@ -202,6 +204,7 @@
Mass Storage: yes
MTP: ${enable_libmtp}
iPod: ${enable_ipodsharp}
+ Karma: ${enable_karmasharp}
DAAP Support: ${enable_daap}
Podcast Support: ${enable_podcast}
Added: trunk/banshee/src/Dap/Banshee.Dap.Karma/Banshee.Dap.Karma.addin.xml
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Dap/Banshee.Dap.Karma/Banshee.Dap.Karma.addin.xml Fri Aug 15 21:00:37 2008
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Addin
+ id="Banshee.Dap.Karma"
+ version="1.0"
+ compatVersion="1.0"
+ copyright="Â 2008 Bob Copeland. Licensed under the MIT X11 license."
+ name="Karma Support"
+ category="Hardware"
+ description="Provides support for Rio Karma devices."
+ author="Bob Copeland"
+ url="http://banshee-project.org/"
+ defaultEnabled="true">
+
+ <Dependencies>
+ <Addin id="Banshee.Dap" version="1.0"/>
+ </Dependencies>
+
+ <Extension path="/Banshee/Dap/DeviceClass">
+ <DeviceClass class="Banshee.Dap.Karma.KarmaSource"/>
+ </Extension>
+
+</Addin>
Added: trunk/banshee/src/Dap/Banshee.Dap.Karma/Banshee.Dap.Karma/KarmaSource.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Dap/Banshee.Dap.Karma/Banshee.Dap.Karma/KarmaSource.cs Fri Aug 15 21:00:37 2008
@@ -0,0 +1,167 @@
+/***************************************************************************
+ * Karma.cs
+ *
+ * Copyright (C) 2006-2008 Bob Copeland <me bobcopeland com>
+ ****************************************************************************/
+
+/* THIS FILE IS LICENSED UNDER THE MIT LICENSE AS OUTLINED IMMEDIATELY BELOW:
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+using System;
+using System.IO;
+using System.Collections.Generic;
+using Mono.Unix;
+
+using KarmaLib=Karma;
+
+using Hyena;
+using Banshee.Base;
+using Banshee.Configuration;
+using Banshee.Dap;
+using Banshee.Hardware;
+using Banshee.Collection.Database;
+
+namespace Banshee.Dap.Karma
+{
+ public class KarmaSource : DapSource
+ {
+ private KarmaLib.Device device;
+ private String mount_point;
+
+ // for getting karma track given a DatabaseTrackInfo
+ private Dictionary<int, KarmaTrackInfo> track_map =
+ new Dictionary<int, KarmaTrackInfo>();
+
+ public override void DeviceInitialize(IDevice dev)
+ {
+ base.DeviceInitialize(dev);
+
+ if (!IsKarma(dev))
+ throw new InvalidDeviceException();
+
+ try
+ {
+ device = new KarmaLib.Device(mount_point);
+ device.ProgressChanged += OnFileUploaded;
+ } catch(Exception e) {
+ Log.Exception("Could not load KarmaLib", e);
+ throw new InvalidDeviceException();
+ }
+
+ Initialize();
+ }
+
+ protected override void LoadFromDevice()
+ {
+ ReloadDatabase();
+ }
+
+ private bool IsKarma(IDevice dev)
+ {
+ IBlockDevice bdev = dev as IBlockDevice;
+
+ if (bdev == null ||
+ dev.Name.IndexOf("Rio Karma") < 0) {
+ return false;
+ }
+
+ // now check for a mounted disk (pick the largest partition)
+ bool found = false;
+ ulong max_size = 0;
+ foreach (IVolume volume in bdev.Volumes) {
+ if (volume.FileSystem.Equals("omfs") &&
+ volume.Capacity > max_size) {
+ Name = volume.Name;
+ mount_point = volume.MountPoint;
+ found = true;
+ }
+ }
+ return found;
+ }
+
+ private void ReloadDatabase()
+ {
+ foreach (KarmaLib.Song song in device.GetSongs()) {
+ KarmaTrackInfo track = new KarmaTrackInfo(song,
+ mount_point);
+ track.PrimarySource = this;
+ track.Save(false);
+ track_map[track.TrackId] = track;
+ }
+ }
+
+ public override void Import()
+ {
+ Log.Information("Unimplemented");
+ }
+
+ protected override void DeleteTrack(DatabaseTrackInfo track)
+ {
+ KarmaTrackInfo karma_track = track_map[track.TrackId];
+ if (karma_track == null)
+ return;
+
+ lock (device) {
+ device.DeleteSong(karma_track.KarmaId);
+ device.Save();
+ track_map.Remove(track.TrackId);
+ }
+ }
+
+ protected override void AddTrackToDevice(DatabaseTrackInfo track, SafeUri fromUri)
+ {
+ if (track.PrimarySourceId == DbId)
+ return;
+
+ lock (device) {
+ device.QueueAddSong(fromUri.LocalPath);
+ device.Save();
+ }
+ }
+
+ private void OnFileUploaded(KarmaLib.Song song)
+ {
+ KarmaTrackInfo karma_track = new KarmaTrackInfo(song, mount_point);
+ karma_track.PrimarySource = this;
+ karma_track.Save(false);
+ track_map[karma_track.TrackId] = karma_track;
+ }
+
+ public override long BytesCapacity {
+ get {
+ return (long) device.GetStorageDetails().StorageSize;
+ }
+ }
+
+ public override long BytesUsed {
+ get {
+ KarmaLib.StorageDetails details = device.GetStorageDetails();
+ return (long) (details.StorageSize - details.FreeSpace);
+ }
+ }
+
+ public override bool IsReadOnly {
+ get {
+ return false;
+ }
+ }
+ }
+}
Added: trunk/banshee/src/Dap/Banshee.Dap.Karma/Banshee.Dap.Karma/KarmaTrackInfo.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Dap/Banshee.Dap.Karma/Banshee.Dap.Karma/KarmaTrackInfo.cs Fri Aug 15 21:00:37 2008
@@ -0,0 +1,34 @@
+using System;
+using KarmaLib=Karma;
+using Banshee.Base;
+using Banshee.Collection.Database;
+
+namespace Banshee.Dap.Karma
+{
+ public class KarmaTrackInfo : DatabaseTrackInfo
+ {
+ private int karma_id;
+
+ public KarmaTrackInfo(KarmaLib.Song song, string mount)
+ {
+ string fidstr = String.Format("{0:x8}", song.Id);
+ Uri = new SafeUri(String.Format("file://{0}/fids0/_{1}/{2}", mount,
+ fidstr.Substring(0,5), fidstr.Substring(5)));
+ karma_id = song.Id;
+ AlbumTitle = song.Album;
+ ArtistName = song.Artist;
+ TrackTitle = song.Title;
+ Genre = song.Genre;
+ Duration = new TimeSpan(song.Duration * 1000L);
+ PlayCount = (int) song.PlayCount;
+ LastPlayed = song.LastPlayed;
+ TrackCount = 0;
+ TrackNumber = (int) song.TrackNumber;
+ Year = song.Year;
+ }
+
+ public int KarmaId {
+ get { return karma_id; }
+ }
+ }
+}
Added: trunk/banshee/src/Dap/Banshee.Dap.Karma/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Dap/Banshee.Dap.Karma/Makefile.am Fri Aug 15 21:00:37 2008
@@ -0,0 +1,28 @@
+ASSEMBLY = Banshee.Dap.Karma
+TARGET = library
+LINK = $(REF_DAP_KARMA)
+INSTALL_DIR = $(EXTENSIONS_INSTALL_DIR)
+
+SOURCES = \
+ Banshee.Dap.Karma/KarmaSource.cs \
+ Banshee.Dap.Karma/KarmaTrackInfo.cs
+
+RESOURCES = Banshee.Dap.Karma.addin.xml
+
+EXTRA_BUNDLE = $(KARMASHARP_ASSEMBLIES)
+
+if ENABLE_KARMA
+include $(top_srcdir)/build/build.mk
+
+install-data-hook:
+ for ASM in $(KARMASHARP_ASSEMBLIES); do \
+ $(INSTALL) -m 0755 $$ASM $(DESTDIR)$(moduledir); \
+ done;
+
+uninstall-hook:
+ for ASM in $(KARMASHARP_ASSEMBLIES); do \
+ rm -f $(DESTDIR)$(moduledir)/`basename $$ASM`; \
+ done;
+else
+EXTRA_DIST = $(SOURCES) $(RESOURCES)
+endif
Modified: trunk/banshee/src/Dap/Makefile.am
==============================================================================
--- trunk/banshee/src/Dap/Makefile.am (original)
+++ trunk/banshee/src/Dap/Makefile.am Fri Aug 15 21:00:37 2008
@@ -2,7 +2,8 @@
Banshee.Dap \
Banshee.Dap.Ipod \
Banshee.Dap.MassStorage \
- Banshee.Dap.Mtp
+ Banshee.Dap.Mtp \
+ Banshee.Dap.Karma
run:
@pushd $(top_builddir); \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]