banshee r4987 - in trunk/banshee: . src/Libraries/Mtp/Mtp



Author: gburt
Date: Fri Jan 30 02:25:46 2009
New Revision: 4987
URL: http://svn.gnome.org/viewvc/banshee?rev=4987&view=rev

Log:
2009-01-29  Gabriel Burt  <gabriel burt gmail com>

	* src/Libraries/Mtp/Mtp/File.cs:
	* src/Libraries/Mtp/Mtp/Playlist.cs:
	* src/Libraries/Mtp/Mtp/Track.cs: Fix up the libmtp8 support which was
	crashing on loading MTP devices due to playlists (BGO #542117, BNC #470722)



Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Libraries/Mtp/Mtp/File.cs
   trunk/banshee/src/Libraries/Mtp/Mtp/Playlist.cs
   trunk/banshee/src/Libraries/Mtp/Mtp/Track.cs

Modified: trunk/banshee/src/Libraries/Mtp/Mtp/File.cs
==============================================================================
--- trunk/banshee/src/Libraries/Mtp/Mtp/File.cs	(original)
+++ trunk/banshee/src/Libraries/Mtp/Mtp/File.cs	Fri Jan 30 02:25:46 2009
@@ -32,30 +32,26 @@
 
 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 *
+		private static extern int LIBMTP_Get_File_To_File (MtpDeviceHandle handle, uint fileId, string path, ProgressFunction function, IntPtr data);
 
 		[DllImport("libmtp.dll")]
 		public static extern void LIBMTP_destroy_filesampledata_t (ref FileSampleData data); // LIBMTP_filesampledata_t *
@@ -71,6 +67,9 @@
 	{
 		public int item_id;
 		public int parent_id;
+#ifdef LIBMTP8
+		public int storage_id;
+#endif
 		[MarshalAs(UnmanagedType.LPStr)]public string filename;
 		public long filesize;
 		public FileType filetype;

Modified: trunk/banshee/src/Libraries/Mtp/Mtp/Playlist.cs
==============================================================================
--- trunk/banshee/src/Libraries/Mtp/Mtp/Playlist.cs	(original)
+++ trunk/banshee/src/Libraries/Mtp/Mtp/Playlist.cs	Fri Jan 30 02:25:46 2009
@@ -67,7 +67,12 @@
         protected override int Create ()
         {
             // TODO replace 0 w/ the folder id of the playlists folder?
+#if LIBMTP8
+            playlist.parent_id = Device.PlaylistFolder.FolderId;
+            return LIBMTP_Create_New_Playlist (Device.Handle, ref playlist);
+#else
             return LIBMTP_Create_New_Playlist (Device.Handle, ref playlist, Device.PlaylistFolder.FolderId);
+#endif
         }
 
         protected override int Update ()
@@ -81,29 +86,32 @@
         }
 
         // Playlist Management
-        [DllImport("libmtp.dll")]
-        internal static extern IntPtr LIBMTP_new_playlist_t (); // LIBMTP_playlist_t*
 
-        [DllImport("libmtp.dll")]
-        internal static extern void LIBMTP_destroy_playlist_t (ref PlaylistStruct playlist);
+        //[DllImport("libmtp.dll")]
+        //private static extern void LIBMTP_destroy_playlist_t (ref PlaylistStruct playlist);
 
         [DllImport("libmtp.dll")]
         internal static extern IntPtr LIBMTP_Get_Playlist_List (MtpDeviceHandle handle); // LIBMTP_playlist_t*
 
         [DllImport("libmtp.dll")]
-        internal static extern IntPtr LIBMTP_Get_Playlist (MtpDeviceHandle handle, uint playlistId); // LIBMTP_playlist_t*
-
-        [DllImport("libmtp.dll")]
-        internal static extern int LIBMTP_Create_New_Playlist (MtpDeviceHandle handle, ref PlaylistStruct metadata, uint parentHandle);
+#if LIBMTP8
+        private static extern int LIBMTP_Create_New_Playlist (MtpDeviceHandle handle, ref PlaylistStruct metadata);
+#else
+        private static extern int LIBMTP_Create_New_Playlist (MtpDeviceHandle handle, ref PlaylistStruct metadata, uint parentHandle);
+#endif
 
         [DllImport("libmtp.dll")]
-        internal static extern int LIBMTP_Update_Playlist (MtpDeviceHandle handle, ref PlaylistStruct playlist);
+        private static extern int LIBMTP_Update_Playlist (MtpDeviceHandle handle, ref PlaylistStruct playlist);
     }
 
 	[StructLayout(LayoutKind.Sequential)]
 	internal struct PlaylistStruct
 	{
 		public uint playlist_id;
+#if LIBMTP8
+		public uint parent_id;
+		public uint storage_id;
+#endif
 
 		[MarshalAs(UnmanagedType.LPStr)]
         public string Name;

Modified: trunk/banshee/src/Libraries/Mtp/Mtp/Track.cs
==============================================================================
--- trunk/banshee/src/Libraries/Mtp/Mtp/Track.cs	(original)
+++ trunk/banshee/src/Libraries/Mtp/Mtp/Track.cs	Fri Jan 30 02:25:46 2009
@@ -217,6 +217,7 @@
 		internal static void SendTrack (MtpDeviceHandle handle, string path, ref TrackStruct metadata, ProgressFunction callback, IntPtr data, uint parent)
 		{
 #if LIBMTP8
+            metadata.parent_id = parent;
 			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, parent) != 0)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]