Exemple #1
0
 internal static void UpdateTrackMetadata(MtpDeviceHandle handle, ref TrackStruct metadata)
 {
     if (LIBMTP_Update_Track_Metadata(handle, ref metadata) != 0)
     {
         throw new LibMtpException(ErrorCode.General);
     }
 }
Exemple #2
0
 internal MtpDevice(MtpDeviceHandle handle, MtpDeviceStruct device)
 {
     this.device = device;
     this.Handle = handle;
     this.name   = GetFriendlyName(Handle);
     SetDefaultFolders();
 }
Exemple #3
0
 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");
     }
 }
Exemple #4
0
 internal static void SendTrack(MtpDeviceHandle handle, string path, ref TrackStruct metadata, ProgressFunction callback, IntPtr data)
 {
     if (LIBMTP_Send_Track_From_File(handle, path, ref metadata, callback, data) != 0)
     {
         LibMtpException.CheckErrorStack(handle);
         throw new LibMtpException(ErrorCode.General, "Could not upload the track");
     }
 }
Exemple #5
0
 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");
     }
 }
Exemple #6
0
        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");
            }
        }
Exemple #7
0
        internal static string GetDeviceversion(MtpDeviceHandle handle)
        {
            IntPtr ptr = LIBMTP_Get_Deviceversion(handle);

            if (ptr == IntPtr.Zero)
            {
                return(null);
            }

            return(StringFromIntPtr(ptr));
        }
Exemple #8
0
        internal static string GetFriendlyName(MtpDeviceHandle handle)
        {
            IntPtr ptr = LIBMTP_Get_Friendlyname(handle);

            if (ptr == IntPtr.Zero)
            {
                return(null);
            }

            return(StringFromIntPtr(ptr));
        }
Exemple #9
0
        internal static string GetSerialnumber(MtpDeviceHandle handle)
        {
            IntPtr ptr = LIBMTP_Get_Serialnumber(handle);

            if (ptr == IntPtr.Zero)
            {
                return(null);
            }

            return(StringFromIntPtr(ptr));
        }
Exemple #10
0
        internal static uint CreateFolder(MtpDeviceHandle handle, string name, uint parentId)
        {
            uint result = LIBMTP_Create_Folder(handle, name, parentId, 0);

            if (result == 0)
            {
                LibMtpException.CheckErrorStack(handle);
                throw new LibMtpException(ErrorCode.General, "Could not create folder on the device");
            }

            return(result);
        }
Exemple #11
0
        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]);
        }
Exemple #12
0
        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;
        }
Exemple #13
0
        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;
        }
Exemple #14
0
 static extern IntPtr LIBMTP_Get_Album_List (MtpDeviceHandle handle); // LIBMTP_album_t*
Exemple #15
0
 internal static extern IntPtr LIBMTP_Get_Playlist_List(MtpDeviceHandle handle);  // LIBMTP_playlist_t*
Exemple #16
0
 private static extern uint LIBMTP_Create_Folder(MtpDeviceHandle handle, string name, uint parentId);
Exemple #17
0
 internal static IntPtr GetFolderList(MtpDeviceHandle handle)
 {
     return(LIBMTP_Get_Folder_List(handle));
 }
 private static extern int LIBMTP_Get_Representative_Sample_Format(MtpDeviceHandle handle, FileType type, IntPtr data_array);
Exemple #19
0
 static extern IntPtr LIBMTP_Get_Album_List(MtpDeviceHandle handle);  // LIBMTP_album_t*
Exemple #20
0
 private static extern IntPtr LIBMTP_Get_Filemetadata (MtpDeviceHandle handle, uint fileid); // LIBMTP_file_t *
Exemple #21
0
 internal static void UpdateTrackMetadata(MtpDeviceHandle handle, ref TrackStruct metadata)
 {
     if (LIBMTP_Update_Track_Metadata (handle, ref metadata) != 0)
         throw new LibMtpException (ErrorCode.General);
 }
Exemple #22
0
 internal static void SendTrack(MtpDeviceHandle handle, string path, ref TrackStruct metadata, ProgressFunction callback, IntPtr data)
 {
     if (LIBMTP_Send_Track_From_File (handle, path, ref metadata, callback, data) != 0)
     {
         LibMtpException.CheckErrorStack (handle);
         throw new LibMtpException (ErrorCode.General, "Could not upload the track");
     }
 }
Exemple #23
0
 internal static IntPtr GetTrackListing(MtpDeviceHandle handle, ProgressFunction function, IntPtr data)
 {
     return LIBMTP_Get_Tracklisting_With_Callback (handle, function, data);
 }
Exemple #24
0
 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");
     }
 }
Exemple #25
0
 private static extern int LIBMTP_Get_Supported_Filetypes (MtpDeviceHandle handle, ref IntPtr types, ref ushort count); // uint16_t **const
Exemple #26
0
 private static extern int LIBMTP_Create_New_Playlist(MtpDeviceHandle handle, ref PlaylistStruct metadata);
Exemple #27
0
 private static extern IntPtr LIBMTP_Get_Playlist_List(MtpDeviceHandle handle);
Exemple #28
0
 internal static extern int LIBMTP_Create_New_Album (MtpDeviceHandle handle, ref AlbumStruct album, uint parentId);
Exemple #29
0
 private static extern IntPtr LIBMTP_Get_Filelisting (MtpDeviceHandle handle); // LIBMTP_file_t *
Exemple #30
0
 private static extern IntPtr LIBMTP_Get_Tracklisting_With_Callback(MtpDeviceHandle handle, ProgressFunction callback, IntPtr data);
Exemple #31
0
 private static extern int LIBMTP_Get_Representative_Sample_Format (MtpDeviceHandle handle, FileType type, IntPtr data_array);
Exemple #32
0
 private static extern int LIBMTP_Get_Track_To_File(MtpDeviceHandle handle, uint trackId, string path, ProgressFunction callback, IntPtr data);
Exemple #33
0
 private static extern int LIBMTP_Update_Playlist(MtpDeviceHandle handle, ref PlaylistStruct playlist);
Exemple #34
0
 private static extern int LIBMTP_Send_Track_From_File(MtpDeviceHandle handle, string path, ref TrackStruct track, ProgressFunction callback, IntPtr data);
 private static extern int LIBMTP_Send_Representative_Sample(MtpDeviceHandle handle, uint id, ref FileSampleData sample);
Exemple #36
0
 private static extern int LIBMTP_Update_Track_Metadata(MtpDeviceHandle handle, ref TrackStruct metadata);
Exemple #37
0
 private static extern IntPtr LIBMTP_Get_Folder_List(MtpDeviceHandle handle);  // LIBMTP_folder_t*
Exemple #38
0
 private static extern IntPtr LIBMTP_Get_Errorstack (MtpDeviceHandle handle); // LIBMTP_error_t *
Exemple #39
0
 private static extern int LIBMTP_Update_Playlist(MtpDeviceHandle handle, ref PlaylistStruct playlist);
Exemple #40
0
 private static extern int LIBMTP_Set_Friendlyname (MtpDeviceHandle handle, string name);
Exemple #41
0
 private static extern int LIBMTP_Create_New_Playlist(MtpDeviceHandle handle, ref PlaylistStruct metadata, uint parentHandle);
Exemple #42
0
 internal static extern int LIBMTP_Create_New_Album(MtpDeviceHandle handle, ref AlbumStruct album);
Exemple #43
0
 static extern IntPtr LIBMTP_Get_Album (MtpDeviceHandle handle, uint albumId); // LIBMTP_album_t*
Exemple #44
0
 internal static uint CreateFolder (MtpDeviceHandle handle, string name, uint parentId)
 {
     uint result = LIBMTP_Create_Folder (handle, name, parentId, 0);
     if (result == 0)
     {
         LibMtpException.CheckErrorStack(handle);
         throw new LibMtpException(ErrorCode.General, "Could not create folder on the device");
     }
     
     return result;
 }
Exemple #45
0
 static extern int LIBMTP_Update_Album (MtpDeviceHandle handle, ref AlbumStruct album);
Exemple #46
0
 private static extern IntPtr LIBMTP_Get_Folder_List (MtpDeviceHandle handle); // LIBMTP_folder_t*
Exemple #47
0
 private static extern IntPtr LIBMTP_Get_Filelisting_With_Callback (MtpDeviceHandle handle, ProgressFunction function, IntPtr data); // LIBMTP_file_t *
Exemple #48
0
 private static extern IntPtr LIBMTP_Get_Friendlyname (MtpDeviceHandle handle); // char *
Exemple #49
0
 private static extern int LIBMTP_Get_File_To_File (MtpDeviceHandle handle, uint fileId, string path, ProgressFunction function, IntPtr data);
 private static extern IntPtr LIBMTP_Get_Filelisting_With_Callback(MtpDeviceHandle handle, ProgressFunction function, IntPtr data);  // LIBMTP_file_t *
Exemple #51
0
 private static extern int LIBMTP_Send_Representative_Sample (MtpDeviceHandle handle, uint id, ref FileSampleData sample);
 private static extern IntPtr LIBMTP_Get_Filemetadata(MtpDeviceHandle handle, uint fileid);  // LIBMTP_file_t *
Exemple #53
0
 static extern IntPtr LIBMTP_Get_Album(MtpDeviceHandle handle, uint albumId);  // LIBMTP_album_t*
 private static extern int LIBMTP_Get_File_To_File(MtpDeviceHandle handle, uint fileId, string path, ProgressFunction function, IntPtr data);
Exemple #55
0
 static extern int LIBMTP_Update_Album(MtpDeviceHandle handle, ref AlbumStruct album);
Exemple #56
0
 private static extern int LIBMTP_Send_Track_From_File(MtpDeviceHandle handle, string path, ref TrackStruct track, ProgressFunction callback, IntPtr data);
Exemple #57
0
 internal static IntPtr GetFolderList (MtpDeviceHandle handle)
 {
     return LIBMTP_Get_Folder_List (handle);
 }
Exemple #58
0
 private static extern int LIBMTP_Update_Track_Metadata(MtpDeviceHandle handle, ref TrackStruct metadata);
Exemple #59
0
 private static extern uint LIBMTP_Create_Folder (MtpDeviceHandle handle, string name, uint parentId, uint storageId);
 private static extern IntPtr LIBMTP_Get_Filelisting(MtpDeviceHandle handle);  // LIBMTP_file_t *