internal static void UpdateTrackMetadata(MtpDeviceHandle handle, ref TrackStruct metadata) { if (LIBMTP_Update_Track_Metadata(handle, ref metadata) != 0) { throw new LibMtpException(ErrorCode.General); } }
internal MtpDevice(MtpDeviceHandle handle, MtpDeviceStruct device) { this.device = device; this.Handle = handle; this.name = GetFriendlyName(Handle); SetDefaultFolders(); }
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 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"); } }
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 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 string GetSerialnumber(MtpDeviceHandle handle) { IntPtr ptr = LIBMTP_Get_Serialnumber(handle); if (ptr == IntPtr.Zero) { return(null); } return(StringFromIntPtr(ptr)); }
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); }
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 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; }
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; }
static extern IntPtr LIBMTP_Get_Album_List (MtpDeviceHandle handle); // LIBMTP_album_t*
internal static extern IntPtr LIBMTP_Get_Playlist_List(MtpDeviceHandle handle); // LIBMTP_playlist_t*
private static extern uint LIBMTP_Create_Folder(MtpDeviceHandle handle, string name, uint parentId);
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);
static extern IntPtr LIBMTP_Get_Album_List(MtpDeviceHandle handle); // LIBMTP_album_t*
private static extern IntPtr LIBMTP_Get_Filemetadata (MtpDeviceHandle handle, uint fileid); // LIBMTP_file_t *
internal static void UpdateTrackMetadata(MtpDeviceHandle handle, ref TrackStruct metadata) { if (LIBMTP_Update_Track_Metadata (handle, ref metadata) != 0) throw new LibMtpException (ErrorCode.General); }
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"); } }
internal static IntPtr GetTrackListing(MtpDeviceHandle handle, ProgressFunction function, IntPtr data) { return LIBMTP_Get_Tracklisting_With_Callback (handle, function, data); }
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"); } }
private static extern int LIBMTP_Get_Supported_Filetypes (MtpDeviceHandle handle, ref IntPtr types, ref ushort count); // uint16_t **const
private static extern int LIBMTP_Create_New_Playlist(MtpDeviceHandle handle, ref PlaylistStruct metadata);
private static extern IntPtr LIBMTP_Get_Playlist_List(MtpDeviceHandle handle);
internal static extern int LIBMTP_Create_New_Album (MtpDeviceHandle handle, ref AlbumStruct album, uint parentId);
private static extern IntPtr LIBMTP_Get_Filelisting (MtpDeviceHandle handle); // LIBMTP_file_t *
private static extern IntPtr LIBMTP_Get_Tracklisting_With_Callback(MtpDeviceHandle handle, ProgressFunction callback, IntPtr data);
private static extern int LIBMTP_Get_Representative_Sample_Format (MtpDeviceHandle handle, FileType type, IntPtr data_array);
private static extern int LIBMTP_Get_Track_To_File(MtpDeviceHandle handle, uint trackId, string path, ProgressFunction callback, IntPtr data);
private static extern int LIBMTP_Update_Playlist(MtpDeviceHandle handle, ref PlaylistStruct playlist);
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);
private static extern int LIBMTP_Update_Track_Metadata(MtpDeviceHandle handle, ref TrackStruct metadata);
private static extern IntPtr LIBMTP_Get_Folder_List(MtpDeviceHandle handle); // LIBMTP_folder_t*
private static extern IntPtr LIBMTP_Get_Errorstack (MtpDeviceHandle handle); // LIBMTP_error_t *
private static extern int LIBMTP_Set_Friendlyname (MtpDeviceHandle handle, string name);
private static extern int LIBMTP_Create_New_Playlist(MtpDeviceHandle handle, ref PlaylistStruct metadata, uint parentHandle);
internal static extern int LIBMTP_Create_New_Album(MtpDeviceHandle handle, ref AlbumStruct album);
static extern IntPtr LIBMTP_Get_Album (MtpDeviceHandle handle, uint albumId); // LIBMTP_album_t*
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; }
static extern int LIBMTP_Update_Album (MtpDeviceHandle handle, ref AlbumStruct album);
private static extern IntPtr LIBMTP_Get_Folder_List (MtpDeviceHandle handle); // LIBMTP_folder_t*
private static extern IntPtr LIBMTP_Get_Filelisting_With_Callback (MtpDeviceHandle handle, ProgressFunction function, IntPtr data); // LIBMTP_file_t *
private static extern IntPtr LIBMTP_Get_Friendlyname (MtpDeviceHandle handle); // char *
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 *
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 *
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);
static extern int LIBMTP_Update_Album(MtpDeviceHandle handle, ref AlbumStruct album);
internal static IntPtr GetFolderList (MtpDeviceHandle handle) { return LIBMTP_Get_Folder_List (handle); }
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 *