banshee r3711 - in trunk/banshee: . build build/m4/banshee src/Dap src/Dap/Banshee.Dap.Mtp src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp src/Extensions/Banshee.Daap src/Libraries src/Libraries/Mtp src/Libraries/Mtp/Base src/Libraries/Mtp/Functions src/Libraries/Mtp/Mtp
- From: gburt svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r3711 - in trunk/banshee: . build build/m4/banshee src/Dap src/Dap/Banshee.Dap.Mtp src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp src/Extensions/Banshee.Daap src/Libraries src/Libraries/Mtp src/Libraries/Mtp/Base src/Libraries/Mtp/Functions src/Libraries/Mtp/Mtp
- Date: Tue, 8 Apr 2008 03:18:44 +0100 (BST)
Author: gburt
Date: Tue Apr 8 03:18:44 2008
New Revision: 3711
URL: http://svn.gnome.org/viewvc/banshee?rev=3711&view=rev
Log:
2008-04-07 Gabriel Burt <gabriel burt gmail com>
* build/build.environment.mk: Add Mtp and Banshee.Dap.Mtp deps.
* build/build.rules.mk: Handle *.config files.
* build/m4/banshee/mono-zeroconf.m4:
* src/Extensions/Banshee.Daap/Makefile.am: Make Daap support optional,
though on by default.
* build/m4/banshee/dap-mtp.m4:
* configure.ac: Check for libmtp, and make MTP support optional (currently
off by default, enable with --enable-mtp).
* src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp.addin.xml:
* src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp.mdp:
* src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs:
* src/Dap/Banshee.Dap.Mtp/Makefile.am:
* src/Dap/Dap.mds:
* src/Dap/Makefile.am: New skeleton for Mtp device support.
* src/Libraries/Libraries.mds:
* src/Libraries/Makefile.am:
* src/Libraries/Mtp/*: Move libmtp-sharp code over from latest in stable.
Reorganize.
Added:
trunk/banshee/src/Dap/Banshee.Dap.Mtp/ (props changed)
trunk/banshee/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/
trunk/banshee/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp.addin.xml
trunk/banshee/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp.mdp
trunk/banshee/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
trunk/banshee/src/Dap/Banshee.Dap.Mtp/Makefile.am
trunk/banshee/src/Libraries/Mtp/ (props changed)
- copied from r3709, /branches/banshee/stable/ext/libmtp-sharp/
trunk/banshee/src/Libraries/Mtp/Mtp/
trunk/banshee/src/Libraries/Mtp/Mtp.mdp (props changed)
- copied unchanged from r3709, /branches/banshee/stable/ext/libmtp-sharp/libmtp-sharp.mdp
trunk/banshee/src/Libraries/Mtp/Mtp/Album.cs (contents, props changed)
- copied, changed from r3709, /branches/banshee/stable/ext/libmtp-sharp/Album.cs
trunk/banshee/src/Libraries/Mtp/Mtp/Error.cs (contents, props changed)
- copied, changed from r3709, /branches/banshee/stable/ext/libmtp-sharp/Base/Error.cs
trunk/banshee/src/Libraries/Mtp/Mtp/ErrorCode.cs
trunk/banshee/src/Libraries/Mtp/Mtp/File.cs (contents, props changed)
- copied, changed from r3709, /branches/banshee/stable/ext/libmtp-sharp/Base/File.cs
trunk/banshee/src/Libraries/Mtp/Mtp/FileSampleData.cs (contents, props changed)
- copied, changed from r3709, /branches/banshee/stable/ext/libmtp-sharp/Base/FileSampleData.cs
trunk/banshee/src/Libraries/Mtp/Mtp/FileType.cs
trunk/banshee/src/Libraries/Mtp/Mtp/Folder.cs (contents, props changed)
- copied, changed from r3709, /branches/banshee/stable/ext/libmtp-sharp/Folder.cs
trunk/banshee/src/Libraries/Mtp/Mtp/MtpDevice.cs (contents, props changed)
- copied, changed from r3709, /branches/banshee/stable/ext/libmtp-sharp/MtpDevice.cs
trunk/banshee/src/Libraries/Mtp/Mtp/Playlist.cs (contents, props changed)
- copied, changed from r3709, /branches/banshee/stable/ext/libmtp-sharp/Base/Playlist.cs
trunk/banshee/src/Libraries/Mtp/Mtp/Track.cs (contents, props changed)
- copied, changed from r3709, /branches/banshee/stable/ext/libmtp-sharp/Track.cs
Removed:
trunk/banshee/src/Libraries/Mtp/Album.cs
trunk/banshee/src/Libraries/Mtp/AssemblyInfo.cs
trunk/banshee/src/Libraries/Mtp/Base/
trunk/banshee/src/Libraries/Mtp/Folder.cs
trunk/banshee/src/Libraries/Mtp/Functions/
trunk/banshee/src/Libraries/Mtp/MtpDevice.cs
trunk/banshee/src/Libraries/Mtp/Track.cs
trunk/banshee/src/Libraries/Mtp/libmtp-sharp.mdp
Modified:
trunk/banshee/ChangeLog
trunk/banshee/build/build.environment.mk
trunk/banshee/build/build.rules.mk
trunk/banshee/build/m4/banshee/dap-mtp.m4
trunk/banshee/build/m4/banshee/mono-zeroconf.m4
trunk/banshee/configure.ac
trunk/banshee/src/Dap/Dap.mds
trunk/banshee/src/Dap/Makefile.am
trunk/banshee/src/Extensions/Banshee.Daap/Makefile.am
trunk/banshee/src/Libraries/Libraries.mds
trunk/banshee/src/Libraries/Makefile.am
trunk/banshee/src/Libraries/Mtp/Makefile.am
Modified: trunk/banshee/build/build.environment.mk
==============================================================================
--- trunk/banshee/build/build.environment.mk (original)
+++ trunk/banshee/build/build.environment.mk Tue Apr 8 03:18:44 2008
@@ -79,6 +79,11 @@
LINK_MONO_MEDIA = -r:$(DIR_BIN)/Mono.Media.dll
LINK_MONO_MEDIA_DEPS = $(REF_MONO_MEDIA) $(LINK_MONO_MEDIA)
+# Mtp
+REF_MTP = $(LINK_SYSTEM) $(LINK_MONO_POSIX)
+LINK_MTP = -r:$(DIR_BIN)/Mtp.dll
+LINK_MTP_DEPS = $(REF_MTP) $(LINK_MTP)
+
# MusicBrainz
REF_MUSICBRAINZ = $(LINK_SYSTEM)
LINK_MUSICBRAINZ = -r:$(DIR_BIN)/MusicBrainz.dll
@@ -119,6 +124,7 @@
LINK_DAP = -r:$(DIR_BIN)/Banshee.Dap.dll
LINK_DAP_DEPS = $(REF_DAP) $(LINK_DAP)
REF_DAP_MASS_STORAGE = $(LINK_BANSHEE_SERVICES_DEPS) $(LINK_DAP_DEPS)
+REF_DAP_MTP = $(LINK_BANSHEE_SERVICES_DEPS) $(LINK_DAP_DEPS)
# Backends
REF_BACKEND_GNOME = $(LINK_BANSHEE_SERVICES_DEPS) $(LINK_GCONF) $(LINK_GNOME)
Modified: trunk/banshee/build/build.rules.mk
==============================================================================
--- trunk/banshee/build/build.rules.mk (original)
+++ trunk/banshee/build/build.rules.mk Tue Apr 8 03:18:44 2008
@@ -12,6 +12,8 @@
THEME_ICONS_SOURCE = $(wildcard $(srcdir)/ThemeIcons/*/*/*.png)
THEME_ICONS_RELATIVE = $(subst $(srcdir)/ThemeIcons/, , $(THEME_ICONS_SOURCE))
+CONFIG_FILES_IN = $(wildcard $(srcdir)/*.config.in)
+
ASSEMBLY_EXTENSION = $(strip $(patsubst library, dll, $(TARGET)))
ASSEMBLY_FILE = $(top_builddir)/bin/$(ASSEMBLY).$(ASSEMBLY_EXTENSION)
@@ -60,9 +62,9 @@
uninstall-local: $(THEME_ICONS_SOURCE)
@$(INSTALL_ICONS) -u "$(DESTDIR)$(pkgdatadir)" "$(srcdir)" $(THEME_ICONS_RELATIVE)
-EXTRA_DIST = $(SOURCES_BUILD) $(RESOURCES_EXPANDED) $(THEME_ICONS_SOURCE)
+EXTRA_DIST = $(SOURCES_BUILD) $(RESOURCES_EXPANDED) $(THEME_ICONS_SOURCE) $(CONFIG_FILES_IN)
-CLEANFILES = $(OUTPUT_FILES) *.dll *.mdb *.exe
+CLEANFILES = $(OUTPUT_FILES) *.dll *.mdb *.exe $(CONFIG_FILES_IN)
DISTCLEANFILES = *.pidb
MAINTAINERCLEANFILES = Makefile.in
Modified: trunk/banshee/build/m4/banshee/dap-mtp.m4
==============================================================================
--- trunk/banshee/build/m4/banshee/dap-mtp.m4 (original)
+++ trunk/banshee/build/m4/banshee/dap-mtp.m4 Tue Apr 8 03:18:44 2008
@@ -1,28 +1,25 @@
AC_DEFUN([BANSHEE_CHECK_DAP_MTP],
[
- LIBGPHOTO2SHARP_REQUIRED=2.3.0
+ LIBMTP_REQUIRED=0.2.0
AC_ARG_ENABLE(mtp, AC_HELP_STRING([--enable-mtp],
[Enable MTP DAP support]), , enable_mtp="no")
enable_mtp_dap="${enable_mtp}"
- PKG_CHECK_MODULES(LIBGPHOTO2SHARP,
- libgphoto2-sharp >= $LIBGPHOTO2SHARP_REQUIRED,
+ PKG_CHECK_MODULES(LIBMTP,
+ libmtp >= $LIBMTP_REQUIRED,
enable_mtp_dap="$enable_mtp_dap", enable_mtp_dap=no)
if test "x$enable_mtp" != "xno" -a "x$enable_mtp_dap" = "xno"; then
- AC_MSG_ERROR([libgphoto2-sharp was not found or is not up to date. Please install libgphoto2-sharp of at least version $LIBGPHOTO2SHARP_REQUIRED, or disable MTP support by not passing --enable-mtp])
+ AC_MSG_ERROR([libmtp was not found or is not up to date. Please install libmtp of at least version $LIBMTP_REQUIRED, or disable MTP support by not passing --enable-mtp])
fi
- AC_MSG_RESULT([$enable_mtp_dap])
-
if test "x$enable_mtp_dap" = "xyes"; then
- LIBGPHOTO2SHARP_ASSEMBLIES="`$PKG_CONFIG --variable=Libraries libgphoto2-sharp`"
- AC_SUBST(LIBGPHOTO2SHARP_ASSEMBLIES)
- AC_SUBST(LIBGPHOTO2SHARP_LIBS)
+ LIBMTP_SO_MAP=$(basename $(find $($PKG_CONFIG --variable=libdir libmtp) -maxdepth 1 -regex '.*libmtp\.so\.\w+$' | sort | tail -n 1))
fi
-
+
+ AC_SUBST(LIBMTP_SO_MAP)
AM_CONDITIONAL(ENABLE_MTP, test "x$enable_mtp_dap" = "xyes")
])
Modified: trunk/banshee/build/m4/banshee/mono-zeroconf.m4
==============================================================================
--- trunk/banshee/build/m4/banshee/mono-zeroconf.m4 (original)
+++ trunk/banshee/build/m4/banshee/mono-zeroconf.m4 Tue Apr 8 03:18:44 2008
@@ -1,5 +1,21 @@
AC_DEFUN([BANSHEE_CHECK_MONO_ZEROCONF],
[
- PKG_CHECK_MODULES(MONO_ZEROCONF, mono-zeroconf >= 0.7.3)
- AC_SUBST(MONO_ZEROCONF_LIBS)
+ AC_ARG_ENABLE([daap], AC_HELP_STRING([--disable-daap],
+ [Do not build with DAAP support]),
+ [
+ if test "x$enableval" = "xno"; then
+ enable_daap=no
+ elif test "x$enableval" = "xyes"; then
+ enable_daap=yes
+ fi
+ ], enable_daap=yes
+ )
+
+ if test "x$enable_daap" = "xyes"; then
+ PKG_CHECK_MODULES(MONO_ZEROCONF, mono-zeroconf >= 0.7.3)
+ AC_SUBST(MONO_ZEROCONF_LIBS)
+ AM_CONDITIONAL(DAAP_ENABLED, true)
+ else
+ AM_CONDITIONAL(DAAP_ENABLED, false)
+ fi
])
Modified: trunk/banshee/configure.ac
==============================================================================
--- trunk/banshee/configure.ac (original)
+++ trunk/banshee/configure.ac Tue Apr 8 03:18:44 2008
@@ -96,7 +96,7 @@
dnl DAP support (each module is optional)
#BANSHEE_CHECK_DAP_IPOD
#BANSHEE_CHECK_DAP_NJB
-#BANSHEE_CHECK_DAP_MTP
+BANSHEE_CHECK_DAP_MTP
#BANSHEE_CHECK_DAP_KARMA
dnl DAAP support (optional)
@@ -155,11 +155,14 @@
src/Libraries/Lastfm/Makefile
src/Libraries/Lastfm.Gui/Makefile
src/Libraries/Mono.Media/Makefile
+src/Libraries/Mtp/Makefile
+src/Libraries/Mtp/Mtp.dll.config
src/Libraries/MusicBrainz/Makefile
src/Dap/Makefile
src/Dap/Banshee.Dap/Makefile
src/Dap/Banshee.Dap.MassStorage/Makefile
+src/Dap/Banshee.Dap.Mtp/Makefile
src/Extensions/Makefile
src/Extensions/Banshee.AudioCd/Makefile
@@ -191,6 +194,12 @@
Mono Runtime: ${MONO}
Mono >= 1.2.4: ${HAVE_MONO_1_2_4}
Gtk# >= 2.10: ${HAVE_GTK_2_10}
+
+ Digital Audio Player (DAP) Support:
+ Mass Storage: yes (unstable)
+ MTP: ${enable_mtp_dap} (unstable)
+
+ DAAP Support: ${enable_daap} (unstable)
"
# Digital Audio Players (DAP):
# iPod: ${enable_ipodsharp}
Added: trunk/banshee/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp.addin.xml
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp.addin.xml Tue Apr 8 03:18:44 2008
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Addin
+ id="Banshee.Dap.Mtp"
+ version="1.0"
+ compatVersion="1.0"
+ copyright="Â 2008 Novell Inc. Licensed under the MIT X11 license."
+ name="MTP Audio Player Support"
+ category="Hardware"
+ description="Provides support for Digital Audio Players that use MTP for transfer."
+ author="Gabriel Burt"
+ 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.Mtp.MtpSource"/>
+ </Extension>
+
+</Addin>
Added: trunk/banshee/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp.mdp
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp.mdp Tue Apr 8 03:18:44 2008
@@ -0,0 +1,29 @@
+<Project name="Banshee.Dap.Mtp" fileversion="2.0" language="C#" clr-version="Net_2_0" ctype="DotNetProject">
+ <Configurations active="Debug">
+ <Configuration name="Debug" ctype="DotNetProjectConfiguration">
+ <Output directory="../../../bin" assemblyKeyFile="." assembly="Banshee.AudioCd" />
+ <Build debugmode="True" target="Library" />
+ <Execution runwithwarnings="True" consolepause="True" runtime="MsNet" clr-version="Net_2_0" />
+ <CodeGeneration compiler="Mcs" warninglevel="4" optimize="True" unsafecodeallowed="False" generateoverflowchecks="True" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
+ </Configuration>
+ </Configurations>
+ <Contents>
+ <File name="Banshee.Dap.Mtp/MtpSource.cs" subtype="Code" buildaction="Compile" />
+ <File name="Banshee.Dap.Mtp.addin.xml" subtype="Code" buildaction="EmbedAsResource" />
+ </Contents>
+ <References>
+ <ProjectReference type="Project" localcopy="True" refto="Banshee.Core" />
+ <ProjectReference type="Project" localcopy="True" refto="Banshee.Services" />
+ <ProjectReference type="Project" localcopy="True" refto="Hyena" />
+ <ProjectReference type="Project" localcopy="True" refto="Banshee.Dap" />
+ </References>
+ <MonoDevelop.Autotools.MakefileInfo IntegrationEnabled="True" RelativeMakefileName="./Makefile.am">
+ <BuildFilesVar Sync="True" Name="SOURCES" />
+ <DeployFilesVar />
+ <ResourcesVar Sync="True" Name="RESOURCES" />
+ <OthersVar />
+ <GacRefVar />
+ <AsmRefVar />
+ <ProjectRefVar />
+ </MonoDevelop.Autotools.MakefileInfo>
+</Project>
Added: trunk/banshee/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Dap/Banshee.Dap.Mtp/Banshee.Dap.Mtp/MtpSource.cs Tue Apr 8 03:18:44 2008
@@ -0,0 +1,119 @@
+//
+// MassStorageSource.cs
+//
+// Author:
+// Gabriel Burt <gburt novell com>
+//
+// Copyright (C) 2008 Novell, Inc.
+//
+// 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.Collections.Generic;
+using System.Threading;
+using Mono.Unix;
+
+using Hyena;
+using Hyena.Collections;
+
+using Banshee.Base;
+using Banshee.ServiceStack;
+using Banshee.Library;
+using Banshee.Sources;
+using Banshee.Collection;
+using Banshee.Collection.Database;
+using Banshee.Hardware;
+
+namespace Banshee.Dap.Mtp
+{
+ public class MtpSource : DapSource
+ {
+ protected IDevice device;
+
+ public MtpSource () : base ()
+ {
+ }
+
+ public override bool Initialize (IDevice device)
+ {
+ this.device = device;
+
+ type_unique_id = device.Uuid;
+
+ Name = volume.Name;
+ GenericName = Catalog.GetString ("Audio Player");
+
+ Initialize ();
+
+ Properties.SetStringList ("Icon.Name", "");
+
+ // TODO differentiate between Audio Players and normal Disks, and include the size, eg "2GB Audio Player"?
+ //GenericName = Catalog.GetString ("Audio Player");
+
+ // TODO construct device-specific icon name as preferred icon
+ //Properties.SetStringList ("Icon.Name", "media-player");
+
+ SetStatus (String.Format (Catalog.GetString ("Loading {0}"), Name), false);
+ /*DatabaseImportManager importer = new DatabaseImportManager (this);
+ importer.KeepUserJobHidden = true;
+ importer.ImportFinished += delegate { HideStatus (); };
+ importer.QueueSource (BaseDirectory);*/
+
+ return true;
+ }
+
+ public override void Import ()
+ {
+ //new LibraryImportManager (true).QueueSource (BaseDirectory);
+ }
+
+ public override long BytesUsed {
+ get { return BytesCapacity - volume.Available; }
+ }
+
+ public override long BytesCapacity {
+ get { return (long) volume.Capacity; }
+ }
+
+ protected override bool IsReadOnly {
+ get { return volume.IsReadOnly; }
+ }
+
+ protected override void DeleteTrack (DatabaseTrackInfo track)
+ {
+ /*try {
+ Banshee.IO.Utilities.DeleteFileTrimmingParentDirectories (track.Uri);
+ } catch (System.IO.FileNotFoundException) {
+ } catch (System.IO.DirectoryNotFoundException) {
+ }*/
+ }
+
+ protected override void Eject ()
+ {
+ /*if (volume.CanUnmount)
+ volume.Unmount ();
+
+ if (volume.CanEject)
+ volume.Eject ();
+ */
+ }
+ }
+}
Added: trunk/banshee/src/Dap/Banshee.Dap.Mtp/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Dap/Banshee.Dap.Mtp/Makefile.am Tue Apr 8 03:18:44 2008
@@ -0,0 +1,11 @@
+ASSEMBLY = Banshee.Dap.Mtp
+TARGET = library
+LINK = $(REF_DAP_MTP)
+INSTALL_DIR = $(EXTENSIONS_INSTALL_DIR)
+
+SOURCES = Banshee.Dap.Mtp/MtpSource.cs
+
+RESOURCES = Banshee.Dap.Mtp.addin.xml
+
+include $(top_srcdir)/build/build.mk
+
Modified: trunk/banshee/src/Dap/Dap.mds
==============================================================================
--- trunk/banshee/src/Dap/Dap.mds (original)
+++ trunk/banshee/src/Dap/Dap.mds Tue Apr 8 03:18:44 2008
@@ -3,14 +3,17 @@
<Configuration name="Debug" ctype="CombineConfiguration">
<Entry build="True" name="Banshee.Dap" configuration="Debug" />
<Entry build="True" name="Banshee.Dap.MassStorage" configuration="Debug" />
+ <Entry build="True" name="Banshee.Dap.Mtp" configuration="Debug" />
</Configuration>
</Configurations>
<StartMode startupentry="Banshee.DapCore" single="True">
<Execute type="None" entry="Banshee.Dap" />
<Execute type="None" entry="Banshee.Dap.MassStorage" />
+ <Execute type="None" entry="Banshee.Dap.Mtp" />
</StartMode>
<Entries>
<Entry filename="Banshee.Dap/Banshee.Dap.mdp" />
<Entry filename="Banshee.Dap.MassStorage/Banshee.Dap.MassStorage.mdp" />
+ <Entry filename="Banshee.Dap.Mtp/Banshee.Dap.Mtp.mdp" />
</Entries>
-</Combine>
\ No newline at end of file
+</Combine>
Modified: trunk/banshee/src/Dap/Makefile.am
==============================================================================
--- trunk/banshee/src/Dap/Makefile.am (original)
+++ trunk/banshee/src/Dap/Makefile.am Tue Apr 8 03:18:44 2008
@@ -1,6 +1,7 @@
SUBDIRS = \
Banshee.Dap \
- Banshee.Dap.MassStorage
+ Banshee.Dap.MassStorage \
+ Banshee.Dap.Mtp
run:
@pushd $(top_builddir); \
Modified: trunk/banshee/src/Extensions/Banshee.Daap/Makefile.am
==============================================================================
--- trunk/banshee/src/Extensions/Banshee.Daap/Makefile.am (original)
+++ trunk/banshee/src/Extensions/Banshee.Daap/Makefile.am Tue Apr 8 03:18:44 2008
@@ -1,3 +1,4 @@
+if DAAP_ENABLED
ASSEMBLY = Banshee.Daap
TARGET = library
LINK = $(REF_EXTENSION_DAAP)
@@ -34,3 +35,4 @@
include $(top_srcdir)/build/build.mk
+endif
Modified: trunk/banshee/src/Libraries/Libraries.mds
==============================================================================
--- trunk/banshee/src/Libraries/Libraries.mds (original)
+++ trunk/banshee/src/Libraries/Libraries.mds Tue Apr 8 03:18:44 2008
@@ -6,6 +6,7 @@
<Entry build="True" name="Lastfm" configuration="Debug" />
<Entry build="True" name="Lastfm.Gui" configuration="Debug" />
<Entry build="True" name="Mono.Media" configuration="Debug" />
+ <Entry build="True" name="Mtp" configuration="Debug" />
<Entry build="True" name="MusicBrainz" configuration="Debug" />
</Configuration>
</Configurations>
@@ -15,6 +16,7 @@
<Execute type="None" entry="Lastfm" />
<Execute type="None" entry="Lastfm.Gui" />
<Execute type="None" entry="Mono.Media" />
+ <Execute type="None" entry="Mtp" />
<Execute type="None" entry="MusicBrainz" />
</StartMode>
<Entries>
@@ -22,7 +24,8 @@
<Entry filename="Hyena.Gui/Hyena.Gui.mdp" />
<Entry filename="Lastfm/Lastfm.mdp" />
<Entry filename="Lastfm.Gui/Lastfm.Gui.mdp" />
+ <Entry filename="Mtp/Mtp.mdp" />
<Entry filename="Mono.Media/Mono.Media.mdp" />
<Entry filename="MusicBrainz/MusicBrainz.mdp" />
</Entries>
-</Combine>
\ No newline at end of file
+</Combine>
Modified: trunk/banshee/src/Libraries/Makefile.am
==============================================================================
--- trunk/banshee/src/Libraries/Makefile.am (original)
+++ trunk/banshee/src/Libraries/Makefile.am Tue Apr 8 03:18:44 2008
@@ -2,6 +2,7 @@
Hyena \
Hyena.Gui \
Mono.Media \
+ Mtp \
MusicBrainz \
Lastfm \
Lastfm.Gui
Modified: trunk/banshee/src/Libraries/Mtp/Makefile.am
==============================================================================
--- /branches/banshee/stable/ext/libmtp-sharp/Makefile.am (original)
+++ trunk/banshee/src/Libraries/Mtp/Makefile.am Tue Apr 8 03:18:44 2008
@@ -1,41 +1,19 @@
-include $(top_srcdir)/build/Common.Makefile
-
-ASSEMBLY_NAME = Mtp
-ASSEMBLY = $(ASSEMBLY_NAME).dll
-
-asmdir = $(pkglibdir)/Banshee.Dap
-asm_SCRIPTS = $(ASSEMBLY) $(ASSEMBLY).mdb $(ASSEMBLY).config
-
-ASSEMBLY_SOURCES = \
- $(srcdir)/Base/Enums.cs \
- $(srcdir)/Base/Playlist.cs \
- $(srcdir)/Base/DeviceStorage.cs \
- $(srcdir)/Base/TrackStruct.cs \
- $(srcdir)/Base/DeviceEntry.cs \
- $(srcdir)/Base/Album.cs \
- $(srcdir)/Base/FolderStruct.cs \
- $(srcdir)/Base/File.cs \
- $(srcdir)/Base/Error.cs \
- $(srcdir)/Base/FileSampleData.cs \
- $(srcdir)/Base/MtpDeviceStruct.cs \
- $(srcdir)/Album.cs \
- $(srcdir)/AssemblyInfo.cs \
- $(srcdir)/Folder.cs \
- $(srcdir)/MtpDevice.cs \
- $(srcdir)/Track.cs \
- $(srcdir)/Functions/AlbumManagement.cs \
- $(srcdir)/Functions/FunctionCalls.cs \
- $(srcdir)/Functions/FolderManagement.cs \
- $(srcdir)/Functions/PlaylistManagement.cs \
- $(srcdir)/Functions/FileManagement.cs \
- $(srcdir)/Functions/TrackManagement.cs
-
-all: $(ASSEMBLY)
-
-$(ASSEMBLY): $(ASSEMBLY_SOURCES)
- $(BUILD_LIB) -out:$@ $(ASSEMBLY_SOURCES)
-
-EXTRA_DIST = $(ASSEMBLY_SOURCES) $(ASSEMBLY).config.in
-CLEANFILES = $(asm_SCRIPTS) *.pidb
-MAINTAINERCLEANFILES = Makefile.in
+if ENABLE_MTP
+ASSEMBLY = Mtp
+TARGET = library
+LINK = $(REF_MTP)
+
+#EXTRA_DIST = $(ASSEMBLY_SOURCES) $(ASSEMBLY).config.in
+
+SOURCES = \
+ Mtp/FileType.cs \
+ Mtp/ErrorCode.cs \
+ Mtp/Error.cs \
+ Mtp/FileSampleData.cs \
+ Mtp/Album.cs \
+ Mtp/Folder.cs \
+ Mtp/MtpDevice.cs \
+ Mtp/Track.cs
+include $(top_srcdir)/build/build.mk
+endif
Copied: trunk/banshee/src/Libraries/Mtp/Mtp/Album.cs (from r3709, /branches/banshee/stable/ext/libmtp-sharp/Album.cs)
==============================================================================
--- /branches/banshee/stable/ext/libmtp-sharp/Album.cs (original)
+++ trunk/banshee/src/Libraries/Mtp/Mtp/Album.cs Tue Apr 8 03:18:44 2008
@@ -127,9 +127,9 @@
}
if (saved) {
- saved = AlbumManagement.LIBMTP_Update_Album (device.Handle, album) == 0;
+ saved = LIBMTP_Update_Album (device.Handle, album) == 0;
} else {
- saved = AlbumManagement.LIBMTP_Create_New_Album (device.Handle, ref album, 0) == 0;
+ saved = LIBMTP_Create_New_Album (device.Handle, ref album, 0) == 0;
}
if (album.tracks != IntPtr.Zero) {
@@ -151,7 +151,7 @@
cover.height = height;
cover.filetype = FileType.JPEG;
- if (FileManagement.LIBMTP_Send_Representative_Sample (device.Handle, AlbumId, ref cover) != 0) {
+ if (FileSample.LIBMTP_Send_Representative_Sample (device.Handle, AlbumId, ref cover) != 0) {
//Console.WriteLine ("failed to send representative sample file");
}
Marshal.FreeHGlobal (cover.data);
@@ -177,12 +177,50 @@
public void Remove ()
{
- LibMtp.LIBMTP_Delete_Object(device.Handle, AlbumId);
+ MtpDevice.LIBMTP_Delete_Object(device.Handle, AlbumId);
}
public override string ToString ()
{
return String.Format ("Album < Id: {4}, '{0}' by '{1}', genre '{2}', tracks {3} >", Name, Artist, Genre, TrackCount, AlbumId);
}
+
+ [DllImport("libmtp.dll")]
+ internal static extern IntPtr LIBMTP_new_album_t (); // LIBMTP_album_t*
+
+ [DllImport("libmtp.dll")]
+ internal static extern void LIBMTP_destroy_album_t (ref AlbumStruct album);
+
+ [DllImport("libmtp.dll")]
+ internal static extern IntPtr LIBMTP_Get_Album_List (MtpDeviceHandle handle); // LIBMTP_album_t*
+
+ [DllImport("libmtp.dll")]
+ internal static extern IntPtr LIBMTP_Get_Album (MtpDeviceHandle handle, uint albumId); // LIBMTP_album_t*
+
+ [DllImport("libmtp.dll")]
+ internal static extern int LIBMTP_Create_New_Album (MtpDeviceHandle handle, ref AlbumStruct album, uint parentId);
+
+ [DllImport("libmtp.dll")]
+ internal static extern int LIBMTP_Update_Album (MtpDeviceHandle handle, AlbumStruct album);
}
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct AlbumStruct
+ {
+ public uint album_id;
+
+ [MarshalAs(UnmanagedType.LPStr)]
+ public string name;
+
+ [MarshalAs(UnmanagedType.LPStr)]
+ public string artist;
+
+ [MarshalAs(UnmanagedType.LPStr)]
+ public string genre;
+
+ public IntPtr tracks;
+ public uint no_tracks;
+
+ public IntPtr next; // LIBMTP_album_t*
+ }
}
Copied: trunk/banshee/src/Libraries/Mtp/Mtp/Error.cs (from r3709, /branches/banshee/stable/ext/libmtp-sharp/Base/Error.cs)
==============================================================================
--- /branches/banshee/stable/ext/libmtp-sharp/Base/Error.cs (original)
+++ trunk/banshee/src/Libraries/Mtp/Mtp/Error.cs Tue Apr 8 03:18:44 2008
@@ -34,42 +34,36 @@
{
public class LibMtpException : Exception
{
- private ErrorCode errorCode;
-
- public LibMtpException(ErrorCode error)
- : this (error, error.ToString(), null)
+ public LibMtpException (ErrorCode error) : this (error, error.ToString (), null)
{
- errorCode = error;
}
- public LibMtpException(ErrorCode error, string message)
- : this (error, message, null)
+ public LibMtpException (ErrorCode error, string message) : this (error, message, null)
{
}
- public LibMtpException(ErrorCode error, string message, Exception innerException)
+ public LibMtpException (ErrorCode error, string message, Exception innerException)
: base (message, innerException)
{
- this.errorCode = error;
}
- internal static void CheckErrorStack(MtpDeviceHandle handle)
+ internal static void CheckErrorStack (MtpDeviceHandle handle)
{
- IntPtr ptr = LibMtp.GetErrorStack (handle);
+ IntPtr ptr = MtpDevice.GetErrorStack (handle);
if (ptr == IntPtr.Zero)
return;
LibMtpException ex = null;
while (ptr != IntPtr.Zero)
{
- Error e = (Error)Marshal.PtrToStructure(ptr, typeof(Error));
- ex = new LibMtpException(e.errornumber, e.error_text, ex);
+ Error e = (Error)Marshal.PtrToStructure (ptr, typeof(Error));
+ ex = new LibMtpException (e.errornumber, e.error_text, ex);
ptr = e.next;
}
// Once we throw the exception, clear the error stack
- LibMtp.ClearErrorStack (handle);
+ MtpDevice.ClearErrorStack (handle);
throw ex;
}
}
@@ -80,10 +74,11 @@
[MarshalAs(UnmanagedType.LPStr)] public string error_text;
public IntPtr next; // LIBMTP_error_t*
- public static void CheckError(ErrorCode errorCode)
+ public static void CheckError (ErrorCode errorCode)
{
- if(errorCode != ErrorCode.LIBMTP_ERROR_NONE)
- throw new LibMtpException(errorCode, errorCode.ToString());
+ if (errorCode != ErrorCode.None) {
+ throw new LibMtpException (errorCode, errorCode.ToString ());
+ }
}
}
}
Added: trunk/banshee/src/Libraries/Mtp/Mtp/ErrorCode.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Libraries/Mtp/Mtp/ErrorCode.cs Tue Apr 8 03:18:44 2008
@@ -0,0 +1,57 @@
+/***************************************************************************
+ * MtpDevice.cs
+ *
+ * Copyright (C) 2006-2007 Alan McGovern
+ * Authors:
+ * Alan McGovern (alan mcgovern gmail 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.Collections.Generic;
+using System.Runtime.InteropServices;
+
+namespace Mtp
+{
+ public enum ErrorCode
+ {
+ /*LIBMTP_ERROR_NONE,
+ LIBMTP_ERROR_GENERAL,
+ LIBMTP_ERROR_PTP_LAYER,
+ LIBMTP_ERROR_USB_LAYER,
+ LIBMTP_ERROR_MEMORY_ALLOCATION,
+ LIBMTP_ERROR_NO_DEVICE_ATTACHED,
+ LIBMTP_ERROR_STORAGE_FULL,
+ LIBMTP_ERROR_CONNECTING,
+ LIBMTP_ERROR_CANCELLED*/
+ None,
+ General,
+ PtpLayer,
+ UsbLayer,
+ MemoryAllocation,
+ NoDeviceAttached,
+ StorageFull,
+ Connecting,
+ Cancelled
+ }
+}
Copied: trunk/banshee/src/Libraries/Mtp/Mtp/File.cs (from r3709, /branches/banshee/stable/ext/libmtp-sharp/Base/File.cs)
==============================================================================
--- /branches/banshee/stable/ext/libmtp-sharp/Base/File.cs (original)
+++ trunk/banshee/src/Libraries/Mtp/Mtp/File.cs Tue Apr 8 03:18:44 2008
@@ -32,6 +32,40 @@
namespace Mtp
{
+
+ // File Management
+ [DllImport("libmtp.dll")]
+ private static extern IntPtr LIBMTP_new_file_t (); // LIBMTP_file_t *
+ [DllImport("libmtp.dll")]
+ private static extern void LIBMTP_destroy_file_t (ref File file); // LIBMTP_file_t *
+ [DllImport("libmtp.dll")]
+ private static extern string LIBMTP_Get_Filetype_Description (FileType type); // char const *
+ [DllImport("libmtp.dll")]
+ private static extern IntPtr LIBMTP_Get_Filelisting (MtpDeviceHandle handle); // LIBMTP_file_t *
+ [DllImport("libmtp.dll")]
+ private static extern IntPtr LIBMTP_Get_Filelisting_With_Callback (MtpDeviceHandle handle, ProgressFunction function, IntPtr data); // LIBMTP_file_t *
+ [DllImport("libmtp.dll")]
+ private static extern IntPtr LIBMTP_Get_Filemetadata (MtpDeviceHandle handle, uint fileid); // LIBMTP_file_t *
+ [DllImport("libmtp.dll")]
+ private static extern int LIBMTP_Get_File_To_File (MtpDeviceHandle handle, uint fileId, string path, ProgressFunction function, IntPtr data);
+
+ [DllImport("libmtp.dll")]
+ private static extern int LIBMTP_Send_File_From_File (MtpDeviceHandle handle, string path, ref File fileData, ProgressFunction function, IntPtr data, uint parentHandle);
+ //int LIBMTP_Get_File_To_File_Descriptor (MtpDeviceHandle handle, uint32_t const, int const, ProgressFunction function, void const *const)
+ //int LIBMTP_Send_File_From_File_Descriptor (MtpDeviceHandle handle, int const, LIBMTP_file_t *const, ProgressFunction function, void const *const, uint32_t const)
+
+ //[DllImport("libmtp.dll")]
+ //public static extern IntPtr LIBMTP_new_filesampledata_t (); // LIBMTP_filesampledata_t *
+
+ [DllImport("libmtp.dll")]
+ public static extern void LIBMTP_destroy_filesampledata_t (ref FileSampleData data); // LIBMTP_filesampledata_t *
+
+ [DllImport("libmtp.dll")]
+ public static extern int LIBMTP_Get_Representative_Sample_Format (MtpDeviceHandle handle, FileType type, IntPtr data_array);
+
+ [DllImport("libmtp.dll")]
+ public static extern int LIBMTP_Send_Representative_Sample (MtpDeviceHandle handle, uint id, ref FileSampleData sample);
+
[StructLayout(LayoutKind.Sequential)]
internal struct File
{
Copied: trunk/banshee/src/Libraries/Mtp/Mtp/FileSampleData.cs (from r3709, /branches/banshee/stable/ext/libmtp-sharp/Base/FileSampleData.cs)
==============================================================================
--- /branches/banshee/stable/ext/libmtp-sharp/Base/FileSampleData.cs (original)
+++ trunk/banshee/src/Libraries/Mtp/Mtp/FileSampleData.cs Tue Apr 8 03:18:44 2008
@@ -32,6 +32,18 @@
namespace Mtp
{
+ internal static class FileSample
+ {
+ [DllImport("libmtp.dll")]
+ public static extern void LIBMTP_destroy_filesampledata_t (ref FileSampleData data); // LIBMTP_filesampledata_t *
+
+ [DllImport("libmtp.dll")]
+ public static extern int LIBMTP_Get_Representative_Sample_Format (MtpDeviceHandle handle, FileType type, IntPtr data_array);
+
+ [DllImport("libmtp.dll")]
+ public static extern int LIBMTP_Send_Representative_Sample (MtpDeviceHandle handle, uint id, ref FileSampleData sample);
+ }
+
[StructLayout(LayoutKind.Sequential)]
internal struct FileSampleData
{
Added: trunk/banshee/src/Libraries/Mtp/Mtp/FileType.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Libraries/Mtp/Mtp/FileType.cs Tue Apr 8 03:18:44 2008
@@ -0,0 +1,79 @@
+/***************************************************************************
+ * Enums.cs
+ *
+ * Copyright (C) 2006-2007 Alan McGovern
+ * Authors:
+ * Alan McGovern (alan mcgovern gmail 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;
+
+namespace Mtp
+{
+ public enum FileType
+ {
+ WAV,
+ MP3,
+ WMA,
+ OGG,
+ AUDIBLE,
+ MP4,
+ UNDEF_AUDIO,
+ WMV,
+ AVI,
+ MPEG,
+ ASF,
+ QT,
+ UNDEF_VIDEO,
+ JPEG,
+ JFIF,
+ TIFF,
+ BMP,
+ GIF,
+ PICT,
+ PNG,
+ VCALENDAR1,
+ VCALENDAR2,
+ VCARD2,
+ VCARD3,
+ WINDOWSIMAGEFORMAT,
+ WINEXEC,
+ TEXT,
+ HTML,
+ FIRMWARE,
+ AAC,
+ MEDIACARD,
+ FLAC,
+ MP2,
+ M4A,
+ DOC,
+ XML,
+ XLS,
+ PPT,
+ MHT,
+ JP2,
+ JPX,
+ UNKNOWN
+ }
+}
Copied: trunk/banshee/src/Libraries/Mtp/Mtp/Folder.cs (from r3709, /branches/banshee/stable/ext/libmtp-sharp/Folder.cs)
==============================================================================
--- /branches/banshee/stable/ext/libmtp-sharp/Folder.cs (original)
+++ trunk/banshee/src/Libraries/Mtp/Mtp/Folder.cs Tue Apr 8 03:18:44 2008
@@ -75,7 +75,7 @@
throw new ArgumentNullException("name");
// First create the folder on the device and check for error
- uint id = FolderManagement.CreateFolder (device.Handle, name, FolderId);
+ uint id = CreateFolder (device.Handle, name, FolderId);
FolderStruct f = new FolderStruct();
f.folder_id = id;
@@ -87,11 +87,11 @@
public List<Folder> GetChildren ()
{
- using (FolderHandle handle = FolderManagement.GetFolderList(device.Handle))
+ using (FolderHandle handle = GetFolderList(device.Handle))
{
// Find the pointer to the folderstruct representing this folder
IntPtr ptr = handle.DangerousGetHandle();
- ptr = FolderManagement.Find (ptr, folderId);
+ ptr = Find (ptr, folderId);
FolderStruct f = (FolderStruct)Marshal.PtrToStructure(ptr, typeof(FolderStruct));
@@ -110,13 +110,13 @@
public void Remove()
{
- LibMtp.DeleteObject(device.Handle, FolderId);
+ MtpDevice.DeleteObject(device.Handle, FolderId);
}
internal static List<Folder> GetRootFolders (MtpDevice device)
{
List<Folder> folders = new List<Folder>();
- using (FolderHandle handle = FolderManagement.GetFolderList (device.Handle))
+ using (FolderHandle handle = GetFolderList (device.Handle))
{
for (IntPtr ptr = handle.DangerousGetHandle(); ptr != IntPtr.Zero;)
{
@@ -127,5 +127,151 @@
return folders;
}
}
+
+ internal static uint CreateFolder (MtpDeviceHandle handle, string name, uint parentId)
+ {
+ uint result = LIBMTP_Create_Folder (handle, name, parentId);
+ if (result == 0)
+ {
+ LibMtpException.CheckErrorStack(handle);
+ throw new LibMtpException(ErrorCode.General, "Could not create folder on the device");
+ }
+
+ return result;
+ }
+
+ internal static void DestroyFolder (IntPtr folder)
+ {
+ LIBMTP_destroy_folder_t (folder);
+ }
+
+ internal static IntPtr Find (IntPtr folderList, uint folderId )
+ {
+ return LIBMTP_Find_Folder (folderList, folderId);
+ }
+
+ internal static FolderHandle GetFolderList (MtpDeviceHandle handle)
+ {
+ IntPtr ptr = LIBMTP_Get_Folder_List (handle);
+ return new FolderHandle(ptr);
+ }
+
+ // Folder Management
+ //[DllImport("libmtp.dll")]
+ //private static extern IntPtr LIBMTP_new_folder_t (); // LIBMTP_folder_t*
+
+ [DllImport("libmtp.dll")]
+ private static extern void LIBMTP_destroy_folder_t (IntPtr folder);
+
+ [DllImport("libmtp.dll")]
+ private static extern IntPtr LIBMTP_Get_Folder_List (MtpDeviceHandle handle); // LIBMTP_folder_t*
+
+ [DllImport("libmtp.dll")]
+ private static extern IntPtr LIBMTP_Find_Folder (IntPtr folderList, uint folderId); // LIBMTP_folder_t*
+
+ [DllImport("libmtp.dll")]
+ private static extern uint LIBMTP_Create_Folder (MtpDeviceHandle handle, string name, uint parentId);
+ }
+
+ internal class FolderHandle : SafeHandle
+ {
+ private FolderHandle()
+ : base(IntPtr.Zero, true)
+ {
+
+ }
+
+ internal FolderHandle(IntPtr ptr)
+ : this(ptr, true)
+ {
+
+ }
+
+ internal FolderHandle(IntPtr ptr, bool ownsHandle)
+ : base (IntPtr.Zero, ownsHandle)
+ {
+ SetHandle (ptr);
+ }
+
+ public override bool IsInvalid
+ {
+ get { return handle == IntPtr.Zero; }
+ }
+
+ protected override bool ReleaseHandle ()
+ {
+ Folder.DestroyFolder (handle);
+ return true;
+ }
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct FolderStruct
+ {
+ public uint folder_id;
+ public uint parent_id;
+ [MarshalAs(UnmanagedType.LPStr)] public string name;
+ public IntPtr sibling; // LIBMTP_folder_t*
+ public IntPtr child; // LIBMTP_folder_t*
+ /*
+ public object NextSibling
+ {
+ get
+ {
+ if(sibling == IntPtr.Zero)
+ return null;
+ return (FolderStruct)Marshal.PtrToStructure(sibling, typeof(Folder));
+ }
+ }
+
+ public object NextChild
+ {
+ get
+ {
+ if(child == IntPtr.Zero)
+ return null;
+ return (FolderStruct)Marshal.PtrToStructure(child, typeof(Folder));
+ }
+ }
+
+ public Folder? Sibling
+ {
+ get
+ {
+ if (sibling == IntPtr.Zero)
+ return null;
+ return (Folder)Marshal.PtrToStructure(sibling, typeof(Folder));
+ }
+ }
+
+ public Folder? Child
+ {
+ get
+ {
+ if (child == IntPtr.Zero)
+ return null;
+ return (Folder)Marshal.PtrToStructure(child, typeof(Folder));
+ }
+ }*/
+
+ /*public IEnumerable<Folder> Children()
+ {
+ Folder? current = Child;
+ while(current.HasValue)
+ {
+ yield return current.Value;
+ current = current.Value.Child;
+ }
+ }*/
+
+ /*public IEnumerable<Folder> Siblings()
+ {
+ Folder? current = Sibling;
+ while(current.HasValue)
+ {
+ yield return current.Value;
+ current = current.Value.Sibling;
+ }
+ }*/
}
}
Copied: trunk/banshee/src/Libraries/Mtp/Mtp/MtpDevice.cs (from r3709, /branches/banshee/stable/ext/libmtp-sharp/MtpDevice.cs)
==============================================================================
--- /branches/banshee/stable/ext/libmtp-sharp/MtpDevice.cs (original)
+++ trunk/banshee/src/Libraries/Mtp/Mtp/MtpDevice.cs Tue Apr 8 03:18:44 2008
@@ -33,6 +33,8 @@
namespace Mtp
{
+ public delegate int ProgressFunction(ulong sent, ulong total, IntPtr data);
+
public class MtpDevice : IDisposable
{
internal MtpDeviceHandle Handle;
@@ -48,29 +50,29 @@
private Folder videoFolder;
static MtpDevice() {
- LibMtp.Init();
+ Init();
}
public int BatteryLevel {
get {
ushort level, maxLevel;
- LibMtp.GetBatteryLevel (Handle, out maxLevel, out level);
+ GetBatteryLevel (Handle, out maxLevel, out level);
return (int)((level * 100.0) / maxLevel);
}
}
public string SerialNumber {
- get { return LibMtp.GetSerialnumber (Handle); }
+ get { return GetSerialnumber (Handle); }
}
public string Version {
- get { return LibMtp.GetDeviceversion (Handle); }
+ get { return GetDeviceversion (Handle); }
}
public string Name {
get { return name; }
set {
- if (LibMtp.SetFriendlyName (Handle, value)) {
+ if (SetFriendlyName (Handle, value)) {
name = value;
}
}
@@ -112,7 +114,7 @@
{
this.device = device;
this.Handle = handle;
- this.name = LibMtp.GetFriendlyName(Handle);
+ this.name = GetFriendlyName(Handle);
SetDefaultFolders ();
}
@@ -169,14 +171,14 @@
public List<Track> GetAllTracks(ProgressFunction callback)
{
- IntPtr ptr = TrackManagement.GetTrackListing(Handle, callback, IntPtr.Zero);
+ IntPtr ptr = Track.GetTrackListing(Handle, callback, IntPtr.Zero);
List<Track> tracks = new List<Track>();
while (ptr != IntPtr.Zero)
{
TrackStruct track = (TrackStruct)Marshal.PtrToStructure(ptr, typeof(TrackStruct));
- TrackManagement.DestroyTrack (ptr);
+ Track.DestroyTrack (ptr);
tracks.Add(new Track(track, this));
ptr = track.next;
}
@@ -188,7 +190,7 @@
{
List<Album> albums = new List<Album> ();
- IntPtr ptr = AlbumManagement.LIBMTP_Get_Album_List (Handle);
+ IntPtr ptr = Album.LIBMTP_Get_Album_List (Handle);
while (ptr != IntPtr.Zero)
{
AlbumStruct d = (AlbumStruct)Marshal.PtrToStructure(ptr, typeof(AlbumStruct));
@@ -199,7 +201,6 @@
return albums;
}
-
public List<DeviceStorage> GetStorage ()
{
List<DeviceStorage> storages = new List<DeviceStorage>();
@@ -208,14 +209,14 @@
{
DeviceStorage storage = (DeviceStorage)Marshal.PtrToStructure(ptr, typeof(DeviceStorage));
storages.Add(storage);
- ptr = storage.next;
+ ptr = storage.Next;
}
return storages;
}
public void Remove (Track track)
{
- LibMtp.DeleteObject(Handle, track.FileId);
+ DeleteObject(Handle, track.FileId);
}
public void UploadTrack (string path, Track track, Folder folder)
@@ -241,13 +242,13 @@
throw new ArgumentNullException("track");
// We send the trackstruct by ref so that when the file_id gets filled in, our copy is updated
- TrackManagement.SendTrack (Handle, path, ref track.trackStruct, callback, IntPtr.Zero, folder.FolderId);
+ Track.SendTrack (Handle, path, ref track.trackStruct, callback, IntPtr.Zero, folder.FolderId);
// LibMtp.GetStorage (Handle, 0);
}
public FileType [] GetFileTypes ()
{
- Int16 [] ints = LibMtp.GetFileTypes (Handle);
+ Int16 [] ints = GetFileTypes (Handle);
FileType [] file_types = new FileType [ints.Length];
for (int i = 0; i < ints.Length; i++) {
file_types[i] = (FileType) ints[i];
@@ -259,7 +260,7 @@
public static List<MtpDevice> Detect ()
{
IntPtr ptr;
- LibMtp.GetConnectedDevices(out ptr);
+ GetConnectedDevices(out ptr);
List<MtpDevice> devices = new List<MtpDevice>();
while (ptr != IntPtr.Zero)
@@ -271,5 +272,258 @@
return devices;
}
+
+ internal static void ClearErrorStack(MtpDeviceHandle handle)
+ {
+ LIBMTP_Clear_Errorstack (handle);
+ }
+
+ internal static void DeleteObject(MtpDeviceHandle handle, uint object_id)
+ {
+ if (LIBMTP_Delete_Object(handle, object_id) != 0)
+ {
+ LibMtpException.CheckErrorStack(handle);
+ throw new LibMtpException(ErrorCode.General, "Could not delete the track");
+ }
+ }
+
+ internal static void GetBatteryLevel (MtpDeviceHandle handle, out ushort maxLevel, out ushort currentLevel)
+ {
+ int result = LIBMTP_Get_Batterylevel (handle, out maxLevel, out currentLevel);
+ if (result != 0)
+ throw new LibMtpException (ErrorCode.General, "Could not retrieve battery stats");
+ }
+
+ internal static void GetConnectedDevices (out IntPtr list)
+ {
+ Error.CheckError (LIBMTP_Get_Connected_Devices (out list));
+ }
+
+ internal static IntPtr GetErrorStack (MtpDeviceHandle handle)
+ {
+ return LIBMTP_Get_Errorstack(handle);
+ }
+
+ internal static string GetDeviceversion(MtpDeviceHandle handle)
+ {
+ IntPtr ptr = LIBMTP_Get_Deviceversion(handle);
+ if (ptr == IntPtr.Zero)
+ return null;
+
+ return StringFromIntPtr (ptr);
+ }
+
+
+ internal static string GetFriendlyName(MtpDeviceHandle handle)
+ {
+ IntPtr ptr = LIBMTP_Get_Friendlyname(handle);
+ if (ptr == IntPtr.Zero)
+ return null;
+
+ return StringFromIntPtr (ptr);
+ }
+
+ internal static bool SetFriendlyName(MtpDeviceHandle handle, string name)
+ {
+ bool success = LIBMTP_Set_Friendlyname (handle, name) == 0;
+ return success;
+ }
+
+ internal static string GetSerialnumber(MtpDeviceHandle handle)
+ {
+ IntPtr ptr = LIBMTP_Get_Serialnumber(handle);
+ if (ptr == IntPtr.Zero)
+ return null;
+
+ return StringFromIntPtr (ptr);
+ }
+
+ internal static void GetStorage (MtpDeviceHandle handle, int sortMode)
+ {
+ LIBMTP_Get_Storage (handle, sortMode);
+ }
+
+ internal static Int16 [] GetFileTypes (MtpDeviceHandle handle)
+ {
+ IntPtr types = IntPtr.Zero;
+ ushort count = 0;
+ if (LIBMTP_Get_Supported_Filetypes (handle, ref types, ref count) == 0) {
+ Int16 [] type_ary = new Int16 [count];
+ Marshal.Copy (types, type_ary, 0, (int)count);
+ Marshal.FreeHGlobal (types);
+ return type_ary;
+ }
+
+ return new Int16[0];
+ }
+
+ internal static void Init ()
+ {
+ LIBMTP_Init ();
+ }
+
+ internal static void ReleaseDevice (IntPtr handle)
+ {
+ LIBMTP_Release_Device(handle);
+ }
+
+ private static string StringFromIntPtr (IntPtr ptr)
+ {
+ int i = 0;
+ while (Marshal.ReadByte (ptr, i) != (byte) 0) ++i;
+ byte[] s_buf = new byte [i];
+ Marshal.Copy (ptr, s_buf, 0, s_buf.Length);
+ string s = System.Text.Encoding.UTF8.GetString (s_buf);
+ Marshal.FreeCoTaskMem(ptr);
+ return s;
+ }
+
+ // Device Management
+ [DllImport("libmtp.dll")]
+ private static extern void LIBMTP_Init ();
+
+ // Clears out the error stack and frees any allocated memory.
+ [DllImport("libmtp.dll")]
+ private static extern void LIBMTP_Clear_Errorstack (MtpDeviceHandle handle);
+
+ [DllImport("libmtp.dll")]
+ internal static extern int LIBMTP_Delete_Object (MtpDeviceHandle handle, uint object_id);
+
+ // Gets the first connected device:
+ //[DllImport("libmtp.dll")]
+ //private static extern IntPtr LIBMTP_Get_First_Device (); // LIBMTP_mtpdevice_t *
+
+ // Gets the storage information
+ [DllImportAttribute("libmtp.dll")]
+ private static extern int LIBMTP_Get_Storage (MtpDeviceHandle handle, int sortMode);
+
+ // Formats the supplied storage device attached to the device
+ //[DllImportAttribute("libmtp.dll")]
+ //private static extern int LIBMTP_Format_Storage (MtpDeviceHandle handle, ref DeviceStorage storage);
+
+ // Counts the devices in the list
+ //[DllImportAttribute("libmtp.dll")]
+ //private static extern uint LIBMTP_Number_Devices_In_List (MtpDeviceHandle handle);
+
+ [DllImportAttribute("libmtp.dll")]
+ private static extern ErrorCode LIBMTP_Get_Connected_Devices (out IntPtr list); //LIBMTP_mtpdevice_t **
+
+ // Deallocates the memory for the device
+ [DllImportAttribute("libmtp.dll")]
+ private static extern void LIBMTP_Release_Device (IntPtr device);
+
+ //[DllImportAttribute("libmtp.dll")]
+ //private static extern int LIBMTP_Reset_Device (MtpDeviceHandle handle);
+
+ [DllImport("libmtp.dll")]
+ private static extern int LIBMTP_Get_Batterylevel (MtpDeviceHandle handle, out ushort maxLevel, out ushort currentLevel);
+
+ //[DllImportAttribute("libmtp.dll")]
+ //private static extern IntPtr LIBMTP_Get_Modelname (MtpDeviceHandle handle); // char *
+
+ [DllImportAttribute("libmtp.dll")]
+ private static extern IntPtr LIBMTP_Get_Serialnumber (MtpDeviceHandle handle); // char *
+
+ [DllImportAttribute("libmtp.dll")]
+ private static extern IntPtr LIBMTP_Get_Deviceversion (MtpDeviceHandle handle); // char *
+
+ [DllImportAttribute("libmtp.dll")]
+ private static extern IntPtr LIBMTP_Get_Friendlyname (MtpDeviceHandle handle); // char *
+
+ [DllImport("libmtp.dll")]
+ private static extern int LIBMTP_Set_Friendlyname (MtpDeviceHandle handle, string name);
+
+ [DllImportAttribute("libmtp.dll")]
+ private static extern IntPtr LIBMTP_Get_Errorstack (MtpDeviceHandle handle); // LIBMTP_error_t *
+
+ [DllImportAttribute("libmtp.dll")]
+ private static extern int LIBMTP_Get_Supported_Filetypes (MtpDeviceHandle handle, ref IntPtr types, ref ushort count); // uint16_t **const
+
+
+ // void LIBMTP_Release_Device_List (LIBMTP_mtpdevice_t *)
+
+
+ // int LIBMTP_Detect_Descriptor (uint16_t *, uint16_t *);
+ /*
+ void LIBMTP_Dump_Device_Info (LIBMTP_mtpdevice_t *)
+
+ char * LIBMTP_Get_Syncpartner (LIBMTP_mtpdevice_t *)
+ int LIBMTP_Set_Syncpartner (LIBMTP_mtpdevice_t *, char const *const)
+ int LIBMTP_Get_Secure_Time (LIBMTP_mtpdevice_t *, char **const)
+ int LIBMTP_Get_Device_Certificate (LIBMTP_mtpdevice_t *, char **const)
+ */
+
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct DeviceEntry
+ {
+ [MarshalAs(UnmanagedType.LPStr)] public string vendor;
+ public short vendor_id;
+ [MarshalAs(UnmanagedType.LPStr)] public string product;
+ public short product_id;
+ public int device_flags;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ public struct DeviceStorage
+ {
+ public uint Id;
+ public ushort StorageType;
+ public ushort FileSystemType;
+ public ushort AccessCapability;
+ public ulong MaxCapacity;
+ public ulong FreeSpaceInBytes;
+ public ulong FreeSpaceInObjects;
+ [MarshalAs(UnmanagedType.LPStr)] public string StorageDescription;
+ [MarshalAs(UnmanagedType.LPStr)] public string VolumeIdentifier;
+ public IntPtr Next; // LIBMTP_devicestorage_t*
+ public IntPtr Prev; // LIBMTP_devicestorage_t*
+ }
+
+ internal class MtpDeviceHandle : SafeHandle
+ {
+ private MtpDeviceHandle()
+ : base(IntPtr.Zero, true)
+ {
+
+ }
+
+ internal MtpDeviceHandle(IntPtr ptr, bool ownsHandle)
+ : base (IntPtr.Zero, ownsHandle)
+ {
+ SetHandle (ptr);
+ }
+
+ public override bool IsInvalid
+ {
+ get { return handle == IntPtr.Zero; }
+ }
+
+ protected override bool ReleaseHandle ()
+ {
+ MtpDevice.ReleaseDevice(handle);
+ return true;
+ }
+ }
+
+ internal struct MtpDeviceStruct
+ {
+ public byte object_bitsize;
+ public IntPtr parameters; // void*
+ public IntPtr usbinfo; // void*
+ public IntPtr storage; // LIBMTP_devicestorage_t*
+ public IntPtr errorstack; // LIBMTP_error_t*
+ public byte maximum_battery_level;
+ public uint default_music_folder;
+ public uint default_playlist_folder;
+ public uint default_picture_folder;
+ public uint default_video_folder;
+ public uint default_organizer_folder;
+ public uint default_zencast_folder;
+ public uint default_album_folder;
+ public uint default_text_folder;
+ public IntPtr cd; // void*
+ public IntPtr next; // LIBMTP_mtpdevice_t*
}
}
Copied: trunk/banshee/src/Libraries/Mtp/Mtp/Playlist.cs (from r3709, /branches/banshee/stable/ext/libmtp-sharp/Base/Playlist.cs)
==============================================================================
--- /branches/banshee/stable/ext/libmtp-sharp/Base/Playlist.cs (original)
+++ trunk/banshee/src/Libraries/Mtp/Mtp/Playlist.cs Tue Apr 8 03:18:44 2008
@@ -32,6 +32,25 @@
namespace Mtp
{
+ // Playlist Management
+ [DllImport("libmtp.dll")]
+ private static extern IntPtr LIBMTP_new_playlist_t (); // LIBMTP_playlist_t*
+
+ [DllImport("libmtp.dll")]
+ private static extern void LIBMTP_destroy_playlist_t (ref Playlist playlist);
+
+ [DllImport("libmtp.dll")]
+ private static extern IntPtr LIBMTP_Get_Playlist_List (MtpDeviceHandle handle); // LIBMTP_playlist_t*
+
+ [DllImport("libmtp.dll")]
+ private static extern IntPtr LIBMTP_Get_Playlist (MtpDeviceHandle handle, uint playlistId); // LIBMTP_playlist_t*
+
+ [DllImport("libmtp.dll")]
+ private static extern int LIBMTP_Create_New_Playlist (MtpDeviceHandle handle, ref Playlist metadata, uint parentHandle);
+
+ [DllImport("libmtp.dll")]
+ private static extern int LIBMTP_Update_Playlist (MtpDeviceHandle handle, ref Playlist playlist);
+
[StructLayout(LayoutKind.Sequential)]
internal struct Playlist
{
Copied: trunk/banshee/src/Libraries/Mtp/Mtp/Track.cs (from r3709, /branches/banshee/stable/ext/libmtp-sharp/Track.cs)
==============================================================================
--- /branches/banshee/stable/ext/libmtp-sharp/Track.cs (original)
+++ trunk/banshee/src/Libraries/Mtp/Mtp/Track.cs Tue Apr 8 03:18:44 2008
@@ -28,6 +28,7 @@
*/
using System;
+using System.Runtime.InteropServices;
namespace Mtp
{
@@ -154,12 +155,12 @@
if (string.IsNullOrEmpty(path))
throw new ArgumentException ("Cannot be null or empty", "path");
- TrackManagement.GetTrack (device.Handle, trackStruct.item_id, path, callback, IntPtr.Zero);
+ GetTrack (device.Handle, trackStruct.item_id, path, callback, IntPtr.Zero);
}
public void UpdateMetadata()
{
- TrackManagement.UpdateTrackMetadata(device.Handle, ref trackStruct);
+ UpdateTrackMetadata(device.Handle, ref trackStruct);
}
private static FileType DetectFiletype(Track track)
@@ -199,5 +200,106 @@
return FileType.UNKNOWN;
}
+
+ internal static void DestroyTrack (IntPtr track)
+ {
+ LIBMTP_destroy_track_t (track);
+ }
+
+ internal static void GetTrack (MtpDeviceHandle handle, uint trackId, string destPath, ProgressFunction callback, IntPtr data)
+ {
+ if (LIBMTP_Get_Track_To_File (handle, trackId, destPath, callback, data) != 0)
+ {
+ LibMtpException.CheckErrorStack(handle);
+ throw new LibMtpException (ErrorCode.General, "Could not download track from the device");
+ }
+ }
+
+ internal static IntPtr GetTrackListing (MtpDeviceHandle handle, ProgressFunction function, IntPtr data)
+ {
+ return LIBMTP_Get_Tracklisting_With_Callback(handle, function, data);
+ }
+
+ internal static void SendTrack (MtpDeviceHandle handle, string path, ref TrackStruct metadata, ProgressFunction callback, IntPtr data, uint parent)
+ {
+ if (LIBMTP_Send_Track_From_File (handle, path, ref metadata, callback, data, parent) != 0)
+ {
+ LibMtpException.CheckErrorStack(handle);
+ throw new LibMtpException (ErrorCode.General, "Could not upload the track");
+ }
+ }
+
+ internal static void UpdateTrackMetadata(MtpDeviceHandle handle, ref TrackStruct metadata)
+ {
+ if (LIBMTP_Update_Track_Metadata (handle, ref metadata) != 0)
+ throw new LibMtpException(ErrorCode.General);
+ }
+
+ //[DllImport("libmtp.dll")]
+ //private static extern IntPtr LIBMTP_new_track_t (); // LIBMTP_track_t *
+
+ [DllImport("libmtp.dll")]
+ private static extern void LIBMTP_destroy_track_t (IntPtr track); // LIBMTP_track_t *
+
+ //[DllImport("libmtp.dll")]
+ //private static extern IntPtr LIBMTP_Get_Tracklisting (MtpDeviceHandle handle); //LIBMTP_track_t *
+
+ [DllImport("libmtp.dll")]
+ private static extern IntPtr LIBMTP_Get_Tracklisting_With_Callback (MtpDeviceHandle handle, ProgressFunction callback, IntPtr data); // LIBMTP_track_t *
+
+ //[DllImport("libmtp.dll")]
+ //private static extern IntPtr LIBMTP_Get_Trackmetadata (MtpDeviceHandle handle, uint trackId); // LIBMTP_track_t *
+
+ [DllImport("libmtp.dll")]
+ private static extern int LIBMTP_Get_Track_To_File (MtpDeviceHandle handle, uint trackId, string path, ProgressFunction callback, IntPtr data);
+
+ [DllImport("libmtp.dll")]
+ private static extern int LIBMTP_Send_Track_From_File (MtpDeviceHandle handle, string path, ref TrackStruct track, ProgressFunction callback, IntPtr data, uint parentHandle);
+
+ [DllImport("libmtp.dll")]
+ private static extern int LIBMTP_Update_Track_Metadata (MtpDeviceHandle handle, ref TrackStruct metadata);
+
+ //[DllImport("libmtp.dll")]
+ //private static extern int LIBMTP_Track_Exists (MtpDeviceHandle handle, uint trackId);
+
+ //int LIBMTP_Get_Track_To_File_Descriptor (MtpDeviceHandle handle, uint trackId, int const, LIBMTP_progressfunc_t const, void const *const)
+ //int LIBMTP_Send_Track_From_File_Descriptor (MtpDeviceHandle handle, int const, LIBMTP_track_t *const, LIBMTP_progressfunc_t const, void const *const, uint32_t const)
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct TrackStruct
+ {
+ public uint item_id;
+ public uint parent_id;
+
+ [MarshalAs(UnmanagedType.LPStr)] public string title;
+ [MarshalAs(UnmanagedType.LPStr)] public string artist;
+ [MarshalAs(UnmanagedType.LPStr)] public string genre;
+ [MarshalAs(UnmanagedType.LPStr)] public string album;
+ [MarshalAs(UnmanagedType.LPStr)] public string date;
+ [MarshalAs(UnmanagedType.LPStr)] public string filename;
+
+ public ushort tracknumber;
+ public uint duration;
+ public uint samplerate;
+ public ushort nochannels;
+ public uint wavecodec;
+ public uint bitrate;
+ public ushort bitratetype;
+ public ushort rating; // 0 -> 100
+ public uint usecount;
+ public ulong filesize;
+ public FileType filetype;
+ public IntPtr next; // Track Null if last
+ /*
+ public Track? Next
+ {
+ get
+ {
+ if (next == IntPtr.Zero)
+ return null;
+ return (Track)Marshal.PtrToStructure(next, typeof(Track));
+ }
+ }*/
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]