[banshee] [Mtp] Fix indentation in src/Libraries/Mtp/Mtp
- From: Bertrand Lorentz <blorentz src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [banshee] [Mtp] Fix indentation in src/Libraries/Mtp/Mtp
- Date: Tue, 29 Dec 2009 11:02:00 +0000 (UTC)
commit 6b2a61a21b9f5c24c15e09f4136d8de005cf733c
Author: Bertrand Lorentz <bertrand lorentz gmail com>
Date: Mon Dec 28 18:10:37 2009 +0100
[Mtp] Fix indentation in src/Libraries/Mtp/Mtp
Change all indentation to use 4 spaces instead of tabs. Remove a few
trailing whitespaces while at it. No code change.
src/Libraries/Mtp/Mtp/AbstractTrackList.cs | 2 +-
src/Libraries/Mtp/Mtp/Album.cs | 38 +-
src/Libraries/Mtp/Mtp/Error.cs | 94 ++--
src/Libraries/Mtp/Mtp/ErrorCode.cs | 42 +-
src/Libraries/Mtp/Mtp/FileSampleData.cs | 32 +-
src/Libraries/Mtp/Mtp/FileType.cs | 90 ++--
src/Libraries/Mtp/Mtp/Folder.cs | 462 ++++++++--------
src/Libraries/Mtp/Mtp/MtpDevice.cs | 848 ++++++++++++++--------------
src/Libraries/Mtp/Mtp/Playlist.cs | 44 +-
src/Libraries/Mtp/Mtp/Track.cs | 468 ++++++++--------
10 files changed, 1060 insertions(+), 1060 deletions(-)
---
diff --git a/src/Libraries/Mtp/Mtp/AbstractTrackList.cs b/src/Libraries/Mtp/Mtp/AbstractTrackList.cs
index 984bf4c..976470f 100644
--- a/src/Libraries/Mtp/Mtp/AbstractTrackList.cs
+++ b/src/Libraries/Mtp/Mtp/AbstractTrackList.cs
@@ -8,7 +8,7 @@ namespace Mtp
{
private bool saved;
private List<int> track_ids;
- private MtpDevice device;
+ private MtpDevice device;
public abstract uint Count { get; protected set; }
public abstract string Name { get; set; }
diff --git a/src/Libraries/Mtp/Mtp/Album.cs b/src/Libraries/Mtp/Mtp/Album.cs
index db74437..a381c08 100644
--- a/src/Libraries/Mtp/Mtp/Album.cs
+++ b/src/Libraries/Mtp/Mtp/Album.cs
@@ -33,9 +33,9 @@ using System.Runtime.InteropServices;
namespace Mtp
{
- public class Album : AbstractTrackList
- {
- private AlbumStruct album;
+ public class Album : AbstractTrackList
+ {
+ private AlbumStruct album;
public uint AlbumId {
get { return Saved ? album.album_id : 0; }
@@ -140,7 +140,7 @@ namespace Mtp
public void Remove ()
{
- MtpDevice.LIBMTP_Delete_Object(Device.Handle, AlbumId);
+ MtpDevice.LIBMTP_Delete_Object(Device.Handle, AlbumId);
}
public override string ToString ()
@@ -158,29 +158,29 @@ namespace Mtp
}
}
- [DllImport("libmtp.dll")]
- internal static extern IntPtr LIBMTP_new_album_t (); // LIBMTP_album_t*
+ [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 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_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 IntPtr LIBMTP_Get_Album (MtpDeviceHandle handle, uint albumId); // LIBMTP_album_t*
#if LIBMTP8
- [DllImport("libmtp.dll")]
- internal static extern int LIBMTP_Create_New_Album (MtpDeviceHandle handle, ref AlbumStruct album);
+ [DllImport("libmtp.dll")]
+ internal static extern int LIBMTP_Create_New_Album (MtpDeviceHandle handle, ref AlbumStruct album);
#else
- [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_Create_New_Album (MtpDeviceHandle handle, ref AlbumStruct album, uint parentId);
#endif
- [DllImport("libmtp.dll")]
- internal static extern int LIBMTP_Update_Album (MtpDeviceHandle handle, ref AlbumStruct album);
- }
+ [DllImport("libmtp.dll")]
+ internal static extern int LIBMTP_Update_Album (MtpDeviceHandle handle, ref AlbumStruct album);
+ }
[StructLayout(LayoutKind.Sequential)]
internal struct AlbumStruct
diff --git a/src/Libraries/Mtp/Mtp/Error.cs b/src/Libraries/Mtp/Mtp/Error.cs
index ed79bd8..d54b8ac 100644
--- a/src/Libraries/Mtp/Mtp/Error.cs
+++ b/src/Libraries/Mtp/Mtp/Error.cs
@@ -32,52 +32,52 @@ using System.Runtime.InteropServices;
namespace Mtp
{
- public class LibMtpException : Exception
- {
- public LibMtpException (ErrorCode error) : this (error, error.ToString (), null)
- {
- }
-
- public LibMtpException (ErrorCode error, string message) : this (error, message, null)
- {
-
- }
-
- public LibMtpException (ErrorCode error, string message, Exception innerException)
- : base (message, innerException)
- {
- }
-
- internal static void CheckErrorStack (MtpDeviceHandle 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);
- ptr = e.next;
- }
-
- // Once we throw the exception, clear the error stack
- MtpDevice.ClearErrorStack (handle);
- throw ex;
- }
- }
-
- public struct Error
- {
- public ErrorCode errornumber;
- [MarshalAs(UnmanagedType.LPStr)] public string error_text;
- public IntPtr next; // LIBMTP_error_t*
-
- public static void CheckError (ErrorCode errorCode)
- {
- if (errorCode != ErrorCode.None) {
- throw new LibMtpException (errorCode, errorCode.ToString ());
+ public class LibMtpException : Exception
+ {
+ public LibMtpException (ErrorCode error) : this (error, error.ToString (), null)
+ {
+ }
+
+ public LibMtpException (ErrorCode error, string message) : this (error, message, null)
+ {
+
+ }
+
+ public LibMtpException (ErrorCode error, string message, Exception innerException)
+ : base (message, innerException)
+ {
+ }
+
+ internal static void CheckErrorStack (MtpDeviceHandle 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);
+ ptr = e.next;
}
- }
- }
+
+ // Once we throw the exception, clear the error stack
+ MtpDevice.ClearErrorStack (handle);
+ throw ex;
+ }
+ }
+
+ public struct Error
+ {
+ public ErrorCode errornumber;
+ [MarshalAs(UnmanagedType.LPStr)] public string error_text;
+ public IntPtr next; // LIBMTP_error_t*
+
+ public static void CheckError (ErrorCode errorCode)
+ {
+ if (errorCode != ErrorCode.None) {
+ throw new LibMtpException (errorCode, errorCode.ToString ());
+ }
+ }
+ }
}
diff --git a/src/Libraries/Mtp/Mtp/ErrorCode.cs b/src/Libraries/Mtp/Mtp/ErrorCode.cs
index 59a1732..7e9803b 100644
--- a/src/Libraries/Mtp/Mtp/ErrorCode.cs
+++ b/src/Libraries/Mtp/Mtp/ErrorCode.cs
@@ -33,25 +33,25 @@ 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
- }
+ 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
+ }
}
diff --git a/src/Libraries/Mtp/Mtp/FileSampleData.cs b/src/Libraries/Mtp/Mtp/FileSampleData.cs
index fcab905..4d437a7 100644
--- a/src/Libraries/Mtp/Mtp/FileSampleData.cs
+++ b/src/Libraries/Mtp/Mtp/FileSampleData.cs
@@ -34,24 +34,24 @@ 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 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_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);
+ [DllImport("libmtp.dll")]
+ public static extern int LIBMTP_Send_Representative_Sample (MtpDeviceHandle handle, uint id, ref FileSampleData sample);
}
- [StructLayout(LayoutKind.Sequential)]
- internal struct FileSampleData
- {
- public uint width;
- public uint height;
- public uint duration;
- public FileType filetype;
- public ulong size;
- public IntPtr data;
- }
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct FileSampleData
+ {
+ public uint width;
+ public uint height;
+ public uint duration;
+ public FileType filetype;
+ public ulong size;
+ public IntPtr data;
+ }
}
diff --git a/src/Libraries/Mtp/Mtp/FileType.cs b/src/Libraries/Mtp/Mtp/FileType.cs
index 02b5f00..bfb2dcf 100644
--- a/src/Libraries/Mtp/Mtp/FileType.cs
+++ b/src/Libraries/Mtp/Mtp/FileType.cs
@@ -31,49 +31,49 @@ 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
- }
+ 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
+ }
}
diff --git a/src/Libraries/Mtp/Mtp/Folder.cs b/src/Libraries/Mtp/Mtp/Folder.cs
index b0d8a12..febd0cc 100644
--- a/src/Libraries/Mtp/Mtp/Folder.cs
+++ b/src/Libraries/Mtp/Mtp/Folder.cs
@@ -33,262 +33,262 @@ using System.Runtime.InteropServices;
namespace Mtp
{
- public class Folder
- {
- private MtpDevice device;
- private uint folderId;
- private uint parentId;
- private string name;
+ public class Folder
+ {
+ private MtpDevice device;
+ private uint folderId;
+ private uint parentId;
+ private string name;
- internal uint FolderId
- {
- get { return folderId; }
- }
-
- public string Name
- {
- get { return name; }
- }
-
- internal uint ParentId
- {
- get { return parentId; }
- }
-
- internal Folder (uint folderId, uint parentId, string name, MtpDevice device)
- {
- this.device = device;
- this.folderId = folderId;
- this.parentId = parentId;
- this.name = name;
- }
-
- internal Folder (FolderStruct folder, MtpDevice device)
- : this (folder.folder_id, folder.parent_id, folder.name, device)
- {
+ internal uint FolderId
+ {
+ get { return folderId; }
+ }
+
+ public string Name
+ {
+ get { return name; }
+ }
+
+ internal uint ParentId
+ {
+ get { return parentId; }
+ }
+
+ internal Folder (uint folderId, uint parentId, string name, MtpDevice device)
+ {
+ this.device = device;
+ this.folderId = folderId;
+ this.parentId = parentId;
+ this.name = name;
+ }
+
+ internal Folder (FolderStruct folder, MtpDevice device)
+ : this (folder.folder_id, folder.parent_id, folder.name, device)
+ {
- }
-
- public Folder AddChild(string name)
- {
- if (string.IsNullOrEmpty(name))
- throw new ArgumentNullException("name");
-
- // First create the folder on the device and check for error
- uint id = CreateFolder (device.Handle, name, FolderId);
-
- FolderStruct f = new FolderStruct();
- f.folder_id = id;
- f.parent_id = FolderId;
- f.name = name;
-
- return new Folder(f, device);
- }
-
- public List<Folder> GetChildren ()
- {
- using (FolderHandle handle = GetFolderList(device.Handle))
- {
- // Find the pointer to the folderstruct representing this folder
- IntPtr ptr = handle.DangerousGetHandle();
- ptr = Find (ptr, folderId);
-
- FolderStruct f = (FolderStruct)Marshal.PtrToStructure(ptr, typeof(FolderStruct));
-
- ptr = f.child;
- List<Folder> folders = new List<Folder>();
- while (ptr != IntPtr.Zero)
- {
- FolderStruct folder = (FolderStruct)Marshal.PtrToStructure(ptr, typeof(FolderStruct));
- folders.Add(new Folder(folder, device));
- ptr = folder.sibling;
- }
-
- return folders;
- }
- }
-
- public void Remove()
- {
- MtpDevice.DeleteObject(device.Handle, FolderId);
- }
+ }
+
+ public Folder AddChild(string name)
+ {
+ if (string.IsNullOrEmpty(name))
+ throw new ArgumentNullException("name");
+
+ // First create the folder on the device and check for error
+ uint id = CreateFolder (device.Handle, name, FolderId);
+
+ FolderStruct f = new FolderStruct();
+ f.folder_id = id;
+ f.parent_id = FolderId;
+ f.name = name;
+
+ return new Folder(f, device);
+ }
+
+ public List<Folder> GetChildren ()
+ {
+ using (FolderHandle handle = GetFolderList(device.Handle))
+ {
+ // Find the pointer to the folderstruct representing this folder
+ IntPtr ptr = handle.DangerousGetHandle();
+ ptr = Find (ptr, folderId);
+
+ FolderStruct f = (FolderStruct)Marshal.PtrToStructure(ptr, typeof(FolderStruct));
+
+ ptr = f.child;
+ List<Folder> folders = new List<Folder>();
+ while (ptr != IntPtr.Zero)
+ {
+ FolderStruct folder = (FolderStruct)Marshal.PtrToStructure(ptr, typeof(FolderStruct));
+ folders.Add(new Folder(folder, device));
+ ptr = folder.sibling;
+ }
+
+ return folders;
+ }
+ }
+
+ public void Remove()
+ {
+ MtpDevice.DeleteObject(device.Handle, FolderId);
+ }
public override string ToString ()
{
return String.Format ("{0} (id {1}, parent id {2})", Name, FolderId, ParentId);
}
-
- internal static List<Folder> GetRootFolders (MtpDevice device)
- {
- List<Folder> folders = new List<Folder>();
- using (FolderHandle handle = GetFolderList (device.Handle))
- {
- for (IntPtr ptr = handle.DangerousGetHandle(); ptr != IntPtr.Zero;)
- {
- FolderStruct folder = (FolderStruct)Marshal.PtrToStructure(ptr, typeof(FolderStruct));
- folders.Add(new Folder (folder, device));
- ptr = folder.sibling;
- }
- return folders;
- }
- }
+
+ internal static List<Folder> GetRootFolders (MtpDevice device)
+ {
+ List<Folder> folders = new List<Folder>();
+ using (FolderHandle handle = GetFolderList (device.Handle))
+ {
+ for (IntPtr ptr = handle.DangerousGetHandle(); ptr != IntPtr.Zero;)
+ {
+ FolderStruct folder = (FolderStruct)Marshal.PtrToStructure(ptr, typeof(FolderStruct));
+ folders.Add(new Folder (folder, device));
+ ptr = folder.sibling;
+ }
+ return folders;
+ }
+ }
- internal static uint CreateFolder (MtpDeviceHandle handle, string name, uint parentId)
- {
+ internal static uint CreateFolder (MtpDeviceHandle handle, string name, uint parentId)
+ {
#if LIBMTP8
- uint result = LIBMTP_Create_Folder (handle, name, parentId, 0);
+ uint result = LIBMTP_Create_Folder (handle, name, parentId, 0);
#else
- uint result = LIBMTP_Create_Folder (handle, name, parentId);
+ uint result = LIBMTP_Create_Folder (handle, name, parentId);
#endif
- if (result == 0)
- {
- LibMtpException.CheckErrorStack(handle);
- throw new LibMtpException(ErrorCode.General, "Could not create folder on the device");
- }
-
- return result;
- }
+ 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 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);
- }
+ 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 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 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_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 IntPtr LIBMTP_Find_Folder (IntPtr folderList, uint folderId); // LIBMTP_folder_t*
#if LIBMTP8
- [DllImport("libmtp.dll")]
- private static extern uint LIBMTP_Create_Folder (MtpDeviceHandle handle, string name, uint parentId, uint storageId);
+ [DllImport("libmtp.dll")]
+ private static extern uint LIBMTP_Create_Folder (MtpDeviceHandle handle, string name, uint parentId, uint storageId);
#else
- [DllImport("libmtp.dll")]
- private static extern uint LIBMTP_Create_Folder (MtpDeviceHandle handle, string name, uint parentId);
+ [DllImport("libmtp.dll")]
+ private static extern uint LIBMTP_Create_Folder (MtpDeviceHandle handle, string name, uint parentId);
#endif
- }
+ }
- 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; }
- }
+ 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;
+ protected override bool ReleaseHandle ()
+ {
+ Folder.DestroyFolder (handle);
+ return true;
+ }
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct FolderStruct
+ {
+ public uint folder_id;
+ public uint parent_id;
#if LIBMTP8
- public uint storage_id;
+ public uint storage_id;
#endif
- [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));
- }
- }*/
+ [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;
- }
- }*/
- }
+ /*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;
+ }
+ }*/
+ }
}
diff --git a/src/Libraries/Mtp/Mtp/MtpDevice.cs b/src/Libraries/Mtp/Mtp/MtpDevice.cs
index 66e6386..a16d314 100644
--- a/src/Libraries/Mtp/Mtp/MtpDevice.cs
+++ b/src/Libraries/Mtp/Mtp/MtpDevice.cs
@@ -33,33 +33,33 @@ using System.Runtime.InteropServices;
namespace Mtp
{
- public delegate int ProgressFunction(ulong sent, ulong total, IntPtr data);
-
- public class MtpDevice : IDisposable
- {
- internal MtpDeviceHandle Handle;
- private MtpDeviceStruct device;
- private string name;
- private Folder albumFolder;
- private Folder musicFolder;
- private Folder organizerFolder;
- private Folder pictureFolder;
- private Folder playlistFolder;
- private Folder podcastFolder;
- private Folder textFolder;
- private Folder videoFolder;
-
- static MtpDevice() {
- LIBMTP_Init ();
- }
-
- public int BatteryLevel {
- get {
- ushort level, maxLevel;
- GetBatteryLevel (Handle, out maxLevel, out level);
- return (int)((level * 100.0) / maxLevel);
- }
- }
+ public delegate int ProgressFunction(ulong sent, ulong total, IntPtr data);
+
+ public class MtpDevice : IDisposable
+ {
+ internal MtpDeviceHandle Handle;
+ private MtpDeviceStruct device;
+ private string name;
+ private Folder albumFolder;
+ private Folder musicFolder;
+ private Folder organizerFolder;
+ private Folder pictureFolder;
+ private Folder playlistFolder;
+ private Folder podcastFolder;
+ private Folder textFolder;
+ private Folder videoFolder;
+
+ static MtpDevice() {
+ LIBMTP_Init ();
+ }
+
+ public int BatteryLevel {
+ get {
+ ushort level, maxLevel;
+ GetBatteryLevel (Handle, out maxLevel, out level);
+ return (int)((level * 100.0) / maxLevel);
+ }
+ }
public string SerialNumber {
get { return GetSerialnumber (Handle); }
@@ -69,138 +69,138 @@ namespace Mtp
get { return GetDeviceversion (Handle); }
}
- public string Name {
- get { return name; }
+ public string Name {
+ get { return name; }
set {
if (SetFriendlyName (Handle, value)) {
name = value;
}
}
- }
-
- public Folder AlbumFolder {
- get { return albumFolder; }
- }
-
- public Folder MusicFolder {
- get { return musicFolder; }
- }
-
- public Folder OrganizerFolder {
- get { return organizerFolder; }
- }
-
- public Folder PictureFolder {
- get { return pictureFolder; }
- }
-
- public Folder PlaylistFolder {
- get { return playlistFolder; }
- }
-
- public Folder PodcastFolder {
- get { return podcastFolder; }
- }
-
- public Folder TextFolder {
- get { return textFolder; }
- }
-
- public Folder VideoFolder {
- get { return videoFolder; }
- }
-
- internal MtpDevice (MtpDeviceHandle handle, MtpDeviceStruct device)
- {
- this.device = device;
- this.Handle = handle;
- this.name = GetFriendlyName(Handle);
- SetDefaultFolders ();
- }
-
- internal MtpDevice(IntPtr handle, bool ownsHandle, MtpDeviceStruct device)
- : this(new MtpDeviceHandle(handle, ownsHandle), device)
- {
-
- }
-
- /// <summary>
- /// This function scans the top level directories and stores the relevant ones so they are readily
- /// accessible
- /// </summary>
- private void SetDefaultFolders ()
- {
- List<Folder> folders = GetRootFolders();
-
- foreach (Folder f in folders)
- {
- if (f.FolderId == this.device.default_album_folder)
- albumFolder = f;
- else if (f.FolderId == device.default_music_folder) {
- musicFolder = f;
- // Fix for devices that don't have an explicit playlist folder (BGO #590342)
- if (device.default_playlist_folder == 0) {
- playlistFolder = f;
- }
- }
- else if (f.FolderId == device.default_organizer_folder)
- organizerFolder = f;
- else if (f.FolderId == device.default_picture_folder)
- pictureFolder = f;
- else if (f.FolderId == device.default_playlist_folder)
- playlistFolder = f;
- else if (f.FolderId == device.default_text_folder)
- textFolder = f;
- else if (f.FolderId == device.default_video_folder)
- videoFolder = f;
- else if (f.FolderId == device.default_zencast_folder)
- podcastFolder = f;
- }
- }
-
- public void Dispose ()
- {
- if (!Handle.IsClosed)
- Handle.Close();
- }
-
- public List<Folder> GetRootFolders()
- {
- return Folder.GetRootFolders(this);
- }
-
- public List<Track> GetAllTracks()
- {
- return GetAllTracks(null);
- }
-
- public List<Track> GetAllTracks(ProgressFunction callback)
- {
- 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));
- Track.DestroyTrack (ptr);
- tracks.Add (new Track (track, this));
- ptr = track.next;
- }
-
- return tracks;
- }
+ }
+
+ public Folder AlbumFolder {
+ get { return albumFolder; }
+ }
+
+ public Folder MusicFolder {
+ get { return musicFolder; }
+ }
+
+ public Folder OrganizerFolder {
+ get { return organizerFolder; }
+ }
+
+ public Folder PictureFolder {
+ get { return pictureFolder; }
+ }
+
+ public Folder PlaylistFolder {
+ get { return playlistFolder; }
+ }
+
+ public Folder PodcastFolder {
+ get { return podcastFolder; }
+ }
+
+ public Folder TextFolder {
+ get { return textFolder; }
+ }
+
+ public Folder VideoFolder {
+ get { return videoFolder; }
+ }
+
+ internal MtpDevice (MtpDeviceHandle handle, MtpDeviceStruct device)
+ {
+ this.device = device;
+ this.Handle = handle;
+ this.name = GetFriendlyName(Handle);
+ SetDefaultFolders ();
+ }
+
+ internal MtpDevice(IntPtr handle, bool ownsHandle, MtpDeviceStruct device)
+ : this(new MtpDeviceHandle(handle, ownsHandle), device)
+ {
+
+ }
+
+ /// <summary>
+ /// This function scans the top level directories and stores the relevant ones so they are readily
+ /// accessible
+ /// </summary>
+ private void SetDefaultFolders ()
+ {
+ List<Folder> folders = GetRootFolders();
+
+ foreach (Folder f in folders)
+ {
+ if (f.FolderId == this.device.default_album_folder)
+ albumFolder = f;
+ else if (f.FolderId == device.default_music_folder) {
+ musicFolder = f;
+ // Fix for devices that don't have an explicit playlist folder (BGO #590342)
+ if (device.default_playlist_folder == 0) {
+ playlistFolder = f;
+ }
+ }
+ else if (f.FolderId == device.default_organizer_folder)
+ organizerFolder = f;
+ else if (f.FolderId == device.default_picture_folder)
+ pictureFolder = f;
+ else if (f.FolderId == device.default_playlist_folder)
+ playlistFolder = f;
+ else if (f.FolderId == device.default_text_folder)
+ textFolder = f;
+ else if (f.FolderId == device.default_video_folder)
+ videoFolder = f;
+ else if (f.FolderId == device.default_zencast_folder)
+ podcastFolder = f;
+ }
+ }
+
+ public void Dispose ()
+ {
+ if (!Handle.IsClosed)
+ Handle.Close();
+ }
+
+ public List<Folder> GetRootFolders()
+ {
+ return Folder.GetRootFolders(this);
+ }
+
+ public List<Track> GetAllTracks()
+ {
+ return GetAllTracks(null);
+ }
+
+ public List<Track> GetAllTracks(ProgressFunction callback)
+ {
+ 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));
+ Track.DestroyTrack (ptr);
+ tracks.Add (new Track (track, this));
+ ptr = track.next;
+ }
+
+ return tracks;
+ }
public List<Playlist> GetPlaylists ()
{
List<Playlist> playlists = new List<Playlist> ();
- IntPtr ptr = Playlist.LIBMTP_Get_Playlist_List (Handle);
- while (ptr != IntPtr.Zero) {
- PlaylistStruct d = (PlaylistStruct)Marshal.PtrToStructure(ptr, typeof(PlaylistStruct));
- playlists.Add (new Playlist (this, d));
- ptr = d.next;
- }
-
+ IntPtr ptr = Playlist.LIBMTP_Get_Playlist_List (Handle);
+ while (ptr != IntPtr.Zero) {
+ PlaylistStruct d = (PlaylistStruct)Marshal.PtrToStructure(ptr, typeof(PlaylistStruct));
+ playlists.Add (new Playlist (this, d));
+ ptr = d.next;
+ }
+
return playlists;
}
@@ -208,54 +208,54 @@ namespace Mtp
{
List<Album> albums = new List<Album> ();
- IntPtr ptr = Album.LIBMTP_Get_Album_List (Handle);
- while (ptr != IntPtr.Zero) {
- AlbumStruct d = (AlbumStruct)Marshal.PtrToStructure(ptr, typeof(AlbumStruct));
- albums.Add (new Album (this, d));
- ptr = d.next;
- }
-
+ IntPtr ptr = Album.LIBMTP_Get_Album_List (Handle);
+ while (ptr != IntPtr.Zero) {
+ AlbumStruct d = (AlbumStruct)Marshal.PtrToStructure(ptr, typeof(AlbumStruct));
+ albums.Add (new Album (this, d));
+ ptr = d.next;
+ }
+
return albums;
}
-
- public List<DeviceStorage> GetStorage ()
- {
- List<DeviceStorage> storages = new List<DeviceStorage>();
- IntPtr ptr = device.storage;
- while (ptr != IntPtr.Zero) {
- DeviceStorage storage = (DeviceStorage)Marshal.PtrToStructure(ptr, typeof(DeviceStorage));
- storages.Add (storage);
- ptr = storage.Next;
- }
- return storages;
- }
-
- public void Remove (Track track)
- {
- DeleteObject(Handle, track.FileId);
- }
-
- public void UploadTrack (string path, Track track, Folder folder)
- {
- UploadTrack (path, track, folder, null);
- }
-
- public void UploadTrack (string path, Track track, Folder folder, ProgressFunction callback)
- {
- if (string.IsNullOrEmpty(path))
- throw new ArgumentNullException("path");
- if (track == null)
- throw new ArgumentNullException("track");
+
+ public List<DeviceStorage> GetStorage ()
+ {
+ List<DeviceStorage> storages = new List<DeviceStorage>();
+ IntPtr ptr = device.storage;
+ while (ptr != IntPtr.Zero) {
+ DeviceStorage storage = (DeviceStorage)Marshal.PtrToStructure(ptr, typeof(DeviceStorage));
+ storages.Add (storage);
+ ptr = storage.Next;
+ }
+ return storages;
+ }
+
+ public void Remove (Track track)
+ {
+ DeleteObject(Handle, track.FileId);
+ }
+
+ public void UploadTrack (string path, Track track, Folder folder)
+ {
+ UploadTrack (path, track, folder, null);
+ }
+
+ public void UploadTrack (string path, Track track, Folder folder, ProgressFunction callback)
+ {
+ if (string.IsNullOrEmpty(path))
+ throw new ArgumentNullException("path");
+ if (track == null)
+ throw new ArgumentNullException("track");
folder = folder ?? MusicFolder;
if (folder != null) {
track.trackStruct.parent_id = folder.FolderId;
}
-
- // We send the trackstruct by ref so that when the file_id gets filled in, our copy is updated
- Track.SendTrack (Handle, path, ref track.trackStruct, callback, IntPtr.Zero);
- // LibMtp.GetStorage (Handle, 0);
- }
+
+ // We send the trackstruct by ref so that when the file_id gets filled in, our copy is updated
+ Track.SendTrack (Handle, path, ref track.trackStruct, callback, IntPtr.Zero);
+ // LibMtp.GetStorage (Handle, 0);
+ }
public FileType [] GetFileTypes ()
{
@@ -267,92 +267,92 @@ namespace Mtp
return file_types;
}
-
- public static List<MtpDevice> Detect ()
- {
- IntPtr ptr;
- GetConnectedDevices(out ptr);
-
- List<MtpDevice> devices = new List<MtpDevice>();
- while (ptr != IntPtr.Zero)
- {
- MtpDeviceStruct d = (MtpDeviceStruct)Marshal.PtrToStructure(ptr, typeof(MtpDeviceStruct));
- devices.Add(new MtpDevice(ptr, true, d));
- ptr = d.next;
- }
-
- 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;
-
+
+ public static List<MtpDevice> Detect ()
+ {
+ IntPtr ptr;
+ GetConnectedDevices(out ptr);
+
+ List<MtpDevice> devices = new List<MtpDevice>();
+ while (ptr != IntPtr.Zero)
+ {
+ MtpDeviceStruct d = (MtpDeviceStruct)Marshal.PtrToStructure(ptr, typeof(MtpDeviceStruct));
+ devices.Add(new MtpDevice(ptr, true, d));
+ ptr = d.next;
+ }
+
+ 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;
-
+ }
+
+
+ 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)
+ 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;
+ 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 void GetStorage (MtpDeviceHandle handle, int sortMode)
+ {
+ LIBMTP_Get_Storage (handle, sortMode);
+ }
internal static Int16 [] GetFileTypes (MtpDeviceHandle handle)
{
@@ -367,98 +367,98 @@ namespace Mtp
return new Int16[0];
}
-
- internal static void ReleaseDevice (IntPtr handle)
- {
- LIBMTP_Release_Device(handle);
- }
+
+ 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;
+ 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)
- */
-
+ [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)
+ */
+
public static string GetMimeTypeFor (FileType type)
{
switch (type) {
@@ -478,77 +478,77 @@ namespace Mtp
}
return null;
}
- }
-
- [StructLayout(LayoutKind.Sequential)]
- internal struct DeviceEntry
- {
- [MarshalAs(UnmanagedType.LPStr)] public string vendor;
- public ushort vendor_id;
- [MarshalAs(UnmanagedType.LPStr)] public string product;
- public ushort product_id;
- public uint 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*
- }
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct DeviceEntry
+ {
+ [MarshalAs(UnmanagedType.LPStr)] public string vendor;
+ public ushort vendor_id;
+ [MarshalAs(UnmanagedType.LPStr)] public string product;
+ public ushort product_id;
+ public uint 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*
+ }
}
diff --git a/src/Libraries/Mtp/Mtp/Playlist.cs b/src/Libraries/Mtp/Mtp/Playlist.cs
index 0a91f68..cad92cc 100644
--- a/src/Libraries/Mtp/Mtp/Playlist.cs
+++ b/src/Libraries/Mtp/Mtp/Playlist.cs
@@ -104,31 +104,31 @@ namespace Mtp
private static extern int LIBMTP_Update_Playlist (MtpDeviceHandle handle, ref PlaylistStruct playlist);
}
- [StructLayout(LayoutKind.Sequential)]
- internal struct PlaylistStruct
- {
- public uint playlist_id;
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct PlaylistStruct
+ {
+ public uint playlist_id;
#if LIBMTP8
- public uint parent_id;
- public uint storage_id;
+ public uint parent_id;
+ public uint storage_id;
#endif
- [MarshalAs(UnmanagedType.LPStr)]
+ [MarshalAs(UnmanagedType.LPStr)]
public string Name;
- public IntPtr tracks; // int*
- public uint no_tracks;
- public IntPtr next; // LIBMTP_playlist_t*
-
-
- /*public Playlist? Next
- {
- get
- {
- if (next == IntPtr.Zero)
- return null;
- return (Playlist)Marshal.PtrToStructure(next, typeof(Playlist));
- }
- }*/
- }
+ public IntPtr tracks; // int*
+ public uint no_tracks;
+ public IntPtr next; // LIBMTP_playlist_t*
+
+
+ /*public Playlist? Next
+ {
+ get
+ {
+ if (next == IntPtr.Zero)
+ return null;
+ return (Playlist)Marshal.PtrToStructure(next, typeof(Playlist));
+ }
+ }*/
+ }
}
diff --git a/src/Libraries/Mtp/Mtp/Track.cs b/src/Libraries/Mtp/Mtp/Track.cs
index a2f9986..452ecf8 100644
--- a/src/Libraries/Mtp/Mtp/Track.cs
+++ b/src/Libraries/Mtp/Mtp/Track.cs
@@ -32,153 +32,153 @@ using System.Runtime.InteropServices;
namespace Mtp
{
- public class Track
- {
- internal TrackStruct trackStruct;
- private MtpDevice device;
-
- public uint FileId {
- get { return trackStruct.item_id; }
- }
-
- public string Album {
- get { return trackStruct.album; }
- set { trackStruct.album = value;}
- }
-
- public string Artist {
- get { return trackStruct.artist; }
- set { trackStruct.artist = value; }
- }
-
- public uint Bitrate {
- get { return trackStruct.bitrate; }
- }
-
- public ushort BitrateType {
- get { return trackStruct.bitratetype; }
- }
-
- public string ReleaseDate {
- get { return trackStruct.date; }
- set { trackStruct.date = value; }
- }
-
- public int Year {
- get { return ReleaseDate == null || ReleaseDate.Length < 4 ? 0 : Int32.Parse (ReleaseDate.Substring(0, 4)); }
- set { ReleaseDate = String.Format ("{0:0000}0101T0000.00", value); }
- }
-
- public uint Duration {
- get { return trackStruct.duration; }
- set { trackStruct.duration = value; }
- }
-
- public string FileName {
- get { return trackStruct.filename; }
- set { trackStruct.filename = value; }
- }
-
- public ulong FileSize {
- get { return trackStruct.filesize; }
- set { trackStruct.filesize = value; }
- }
-
- public FileType FileType {
- get { return trackStruct.filetype; }
- set { trackStruct.filetype = value; }
- }
-
- public string Genre {
- get { return trackStruct.genre; }
- set { trackStruct.genre = value; }
- }
-
- public ushort NoChannels {
- get { return trackStruct.nochannels; }
- set { trackStruct.nochannels = value; }
- }
+ public class Track
+ {
+ internal TrackStruct trackStruct;
+ private MtpDevice device;
+
+ public uint FileId {
+ get { return trackStruct.item_id; }
+ }
+
+ public string Album {
+ get { return trackStruct.album; }
+ set { trackStruct.album = value;}
+ }
+
+ public string Artist {
+ get { return trackStruct.artist; }
+ set { trackStruct.artist = value; }
+ }
+
+ public uint Bitrate {
+ get { return trackStruct.bitrate; }
+ }
+
+ public ushort BitrateType {
+ get { return trackStruct.bitratetype; }
+ }
+
+ public string ReleaseDate {
+ get { return trackStruct.date; }
+ set { trackStruct.date = value; }
+ }
+
+ public int Year {
+ get { return ReleaseDate == null || ReleaseDate.Length < 4 ? 0 : Int32.Parse (ReleaseDate.Substring(0, 4)); }
+ set { ReleaseDate = String.Format ("{0:0000}0101T0000.00", value); }
+ }
+
+ public uint Duration {
+ get { return trackStruct.duration; }
+ set { trackStruct.duration = value; }
+ }
+
+ public string FileName {
+ get { return trackStruct.filename; }
+ set { trackStruct.filename = value; }
+ }
+
+ public ulong FileSize {
+ get { return trackStruct.filesize; }
+ set { trackStruct.filesize = value; }
+ }
+
+ public FileType FileType {
+ get { return trackStruct.filetype; }
+ set { trackStruct.filetype = value; }
+ }
+
+ public string Genre {
+ get { return trackStruct.genre; }
+ set { trackStruct.genre = value; }
+ }
+
+ public ushort NoChannels {
+ get { return trackStruct.nochannels; }
+ set { trackStruct.nochannels = value; }
+ }
// 0 to 100
- public ushort Rating {
- get { return trackStruct.rating; }
- set {
- if (value < 0 || value > 100)
- throw new ArgumentOutOfRangeException ("Rating", "Rating must be between zero and 100");
- trackStruct.rating = value;
- }
- }
-
- public uint SampleRate {
- get { return trackStruct.samplerate; }
- set { trackStruct.samplerate = value; }
- }
-
- public string Title {
- get { return trackStruct.title; }
- set { trackStruct.title = value; }
- }
-
- public ushort TrackNumber
- {
- get { return trackStruct.tracknumber; }
- set { trackStruct.tracknumber = value; }
- }
-
- public uint WaveCodec {
- get { return trackStruct.wavecodec; }
- }
-
- public uint UseCount {
- get { return trackStruct.usecount; }
- set { trackStruct.usecount = value; }
- }
+ public ushort Rating {
+ get { return trackStruct.rating; }
+ set {
+ if (value < 0 || value > 100)
+ throw new ArgumentOutOfRangeException ("Rating", "Rating must be between zero and 100");
+ trackStruct.rating = value;
+ }
+ }
+
+ public uint SampleRate {
+ get { return trackStruct.samplerate; }
+ set { trackStruct.samplerate = value; }
+ }
+
+ public string Title {
+ get { return trackStruct.title; }
+ set { trackStruct.title = value; }
+ }
+
+ public ushort TrackNumber
+ {
+ get { return trackStruct.tracknumber; }
+ set { trackStruct.tracknumber = value; }
+ }
+
+ public uint WaveCodec {
+ get { return trackStruct.wavecodec; }
+ }
+
+ public uint UseCount {
+ get { return trackStruct.usecount; }
+ set { trackStruct.usecount = value; }
+ }
#if LIBMTP8
- public string Composer {
- get { return trackStruct.composer; }
- set { trackStruct.composer = value; }
- }
+ public string Composer {
+ get { return trackStruct.composer; }
+ set { trackStruct.composer = value; }
+ }
#endif
- public Track (string filename, ulong filesize) : this (new TrackStruct (), null)
- {
- this.trackStruct.filename = filename;
- this.trackStruct.filesize = filesize;
- this.trackStruct.filetype = DetectFileType (this);
- }
-
- internal Track (TrackStruct track, MtpDevice device)
- {
- this.device = device;
- this.trackStruct = track;
- }
+ public Track (string filename, ulong filesize) : this (new TrackStruct (), null)
+ {
+ this.trackStruct.filename = filename;
+ this.trackStruct.filesize = filesize;
+ this.trackStruct.filetype = DetectFileType (this);
+ }
+
+ internal Track (TrackStruct track, MtpDevice device)
+ {
+ this.device = device;
+ this.trackStruct = track;
+ }
public bool InFolder (Folder folder)
{
return folder != null && trackStruct.parent_id == folder.FolderId;
}
-
- public void Download (string path)
- {
- Download (path, null);
- }
-
- public void Download (string path, ProgressFunction callback)
- {
- if (String.IsNullOrEmpty (path))
- throw new ArgumentException ("Cannot be null or empty", "path");
-
- GetTrack (device.Handle, trackStruct.item_id, path, callback, IntPtr.Zero);
- }
-
- public void UpdateMetadata ()
- {
- UpdateTrackMetadata (device.Handle, ref trackStruct);
- }
-
- private static FileType DetectFileType (Track track)
- {
+
+ public void Download (string path)
+ {
+ Download (path, null);
+ }
+
+ public void Download (string path, ProgressFunction callback)
+ {
+ if (String.IsNullOrEmpty (path))
+ throw new ArgumentException ("Cannot be null or empty", "path");
+
+ GetTrack (device.Handle, trackStruct.item_id, path, callback, IntPtr.Zero);
+ }
+
+ public void UpdateMetadata ()
+ {
+ UpdateTrackMetadata (device.Handle, ref trackStruct);
+ }
+
+ private static FileType DetectFileType (Track track)
+ {
string ext = System.IO.Path.GetExtension (track.FileName);
// Strip leading .
@@ -193,129 +193,129 @@ namespace Mtp
//if (type == null)
// return FileType.UNKNOWN;
return type;
- }
-
- 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)
- {
+ }
+
+ 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)
+ {
#if LIBMTP8
- if (LIBMTP_Send_Track_From_File (handle, path, ref metadata, callback, data) != 0)
+ if (LIBMTP_Send_Track_From_File (handle, path, ref metadata, callback, data) != 0)
#else
- if (LIBMTP_Send_Track_From_File (handle, path, ref metadata, callback, data, metadata.parent_id) != 0)
+ if (LIBMTP_Send_Track_From_File (handle, path, ref metadata, callback, data, metadata.parent_id) != 0)
#endif
- {
- LibMtpException.CheckErrorStack (handle);
- throw new LibMtpException (ErrorCode.General, "Could not upload the track");
- }
- }
+ {
+ 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 *
+ 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 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 (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_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 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_Get_Track_To_File (MtpDeviceHandle handle, uint trackId, string path, ProgressFunction callback, IntPtr data);
#if LIBMTP8
- [DllImport("libmtp.dll")]
- private static extern int LIBMTP_Send_Track_From_File (MtpDeviceHandle handle, string path, ref TrackStruct track, 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);
#else
- [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_Send_Track_From_File (MtpDeviceHandle handle, string path, ref TrackStruct track, ProgressFunction callback, IntPtr data, uint parentHandle);
#endif
- [DllImport("libmtp.dll")]
- private static extern int LIBMTP_Update_Track_Metadata (MtpDeviceHandle handle, ref TrackStruct metadata);
+ [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);
+ //[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)
- }
+ //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;
+ [StructLayout(LayoutKind.Sequential)]
+ internal struct TrackStruct
+ {
+ public uint item_id;
+ public uint parent_id;
#if LIBMTP8
- public uint storage_id;
+ public uint storage_id;
#endif
- [MarshalAs(UnmanagedType.LPStr)] public string title;
- [MarshalAs(UnmanagedType.LPStr)] public string artist;
+ [MarshalAs(UnmanagedType.LPStr)] public string title;
+ [MarshalAs(UnmanagedType.LPStr)] public string artist;
#if LIBMTP8
- [MarshalAs(UnmanagedType.LPStr)] public string composer;
+ [MarshalAs(UnmanagedType.LPStr)] public string composer;
#endif
- [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;
+ [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;
#if LIBMTP_TRACK_HAS_MODDATE
#if LIBMTP_SIZEOF_TIME_T_64
- public ulong modificationdate;
+ public ulong modificationdate;
#else
- public uint modificationdate;
+ public uint modificationdate;
#endif
#endif
- 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));
- }
- }*/
- }
+ 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]