Ejemplo n.º 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);
     }
 }
Ejemplo n.º 2
0
 internal MtpDevice(MtpDeviceHandle handle, MtpDeviceStruct device)
 {
     this.device = device;
     this.Handle = handle;
     this.name   = GetFriendlyName(Handle);
     SetDefaultFolders();
 }
Ejemplo n.º 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");
     }
 }
Ejemplo n.º 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");
     }
 }
Ejemplo n.º 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");
     }
 }
Ejemplo n.º 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");
            }
        }
Ejemplo n.º 7
0
        internal static string GetDeviceversion(MtpDeviceHandle handle)
        {
            IntPtr ptr = LIBMTP_Get_Deviceversion(handle);

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

            return(StringFromIntPtr(ptr));
        }
Ejemplo n.º 8
0
        internal static string GetFriendlyName(MtpDeviceHandle handle)
        {
            IntPtr ptr = LIBMTP_Get_Friendlyname(handle);

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

            return(StringFromIntPtr(ptr));
        }
Ejemplo n.º 9
0
        internal static string GetSerialnumber(MtpDeviceHandle handle)
        {
            IntPtr ptr = LIBMTP_Get_Serialnumber(handle);

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

            return(StringFromIntPtr(ptr));
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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]);
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 14
0
 static extern IntPtr LIBMTP_Get_Album_List (MtpDeviceHandle handle); // LIBMTP_album_t*
Ejemplo n.º 15
0
 internal static extern IntPtr LIBMTP_Get_Playlist_List(MtpDeviceHandle handle);  // LIBMTP_playlist_t*
Ejemplo n.º 16
0
 private static extern uint LIBMTP_Create_Folder(MtpDeviceHandle handle, string name, uint parentId);
Ejemplo n.º 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);
Ejemplo n.º 19
0
 static extern IntPtr LIBMTP_Get_Album_List(MtpDeviceHandle handle);  // LIBMTP_album_t*
Ejemplo n.º 20
0
 private static extern IntPtr LIBMTP_Get_Filemetadata (MtpDeviceHandle handle, uint fileid); // LIBMTP_file_t *
Ejemplo n.º 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);
 }
Ejemplo n.º 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");
     }
 }
Ejemplo n.º 23
0
 internal static IntPtr GetTrackListing(MtpDeviceHandle handle, ProgressFunction function, IntPtr data)
 {
     return LIBMTP_Get_Tracklisting_With_Callback (handle, function, data);
 }
Ejemplo n.º 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");
     }
 }
Ejemplo n.º 25
0
 private static extern int LIBMTP_Get_Supported_Filetypes (MtpDeviceHandle handle, ref IntPtr types, ref ushort count); // uint16_t **const
Ejemplo n.º 26
0
 private static extern int LIBMTP_Create_New_Playlist(MtpDeviceHandle handle, ref PlaylistStruct metadata);
Ejemplo n.º 27
0
 private static extern IntPtr LIBMTP_Get_Playlist_List(MtpDeviceHandle handle);
Ejemplo n.º 28
0
 internal static extern int LIBMTP_Create_New_Album (MtpDeviceHandle handle, ref AlbumStruct album, uint parentId);
Ejemplo n.º 29
0
 private static extern IntPtr LIBMTP_Get_Filelisting (MtpDeviceHandle handle); // LIBMTP_file_t *
Ejemplo n.º 30
0
 private static extern IntPtr LIBMTP_Get_Tracklisting_With_Callback(MtpDeviceHandle handle, ProgressFunction callback, IntPtr data);
Ejemplo n.º 31
0
 private static extern int LIBMTP_Get_Representative_Sample_Format (MtpDeviceHandle handle, FileType type, IntPtr data_array);
Ejemplo n.º 32
0
 private static extern int LIBMTP_Get_Track_To_File(MtpDeviceHandle handle, uint trackId, string path, ProgressFunction callback, IntPtr data);
Ejemplo n.º 33
0
 private static extern int LIBMTP_Update_Playlist(MtpDeviceHandle handle, ref PlaylistStruct playlist);
Ejemplo n.º 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);
Ejemplo n.º 36
0
 private static extern int LIBMTP_Update_Track_Metadata(MtpDeviceHandle handle, ref TrackStruct metadata);
Ejemplo n.º 37
0
 private static extern IntPtr LIBMTP_Get_Folder_List(MtpDeviceHandle handle);  // LIBMTP_folder_t*
Ejemplo n.º 38
0
 private static extern IntPtr LIBMTP_Get_Errorstack (MtpDeviceHandle handle); // LIBMTP_error_t *
Ejemplo n.º 39
0
 private static extern int LIBMTP_Update_Playlist(MtpDeviceHandle handle, ref PlaylistStruct playlist);
Ejemplo n.º 40
0
 private static extern int LIBMTP_Set_Friendlyname (MtpDeviceHandle handle, string name);
Ejemplo n.º 41
0
 private static extern int LIBMTP_Create_New_Playlist(MtpDeviceHandle handle, ref PlaylistStruct metadata, uint parentHandle);
Ejemplo n.º 42
0
 internal static extern int LIBMTP_Create_New_Album(MtpDeviceHandle handle, ref AlbumStruct album);
Ejemplo n.º 43
0
 static extern IntPtr LIBMTP_Get_Album (MtpDeviceHandle handle, uint albumId); // LIBMTP_album_t*
Ejemplo n.º 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;
 }
Ejemplo n.º 45
0
 static extern int LIBMTP_Update_Album (MtpDeviceHandle handle, ref AlbumStruct album);
Ejemplo n.º 46
0
 private static extern IntPtr LIBMTP_Get_Folder_List (MtpDeviceHandle handle); // LIBMTP_folder_t*
Ejemplo n.º 47
0
 private static extern IntPtr LIBMTP_Get_Filelisting_With_Callback (MtpDeviceHandle handle, ProgressFunction function, IntPtr data); // LIBMTP_file_t *
Ejemplo n.º 48
0
 private static extern IntPtr LIBMTP_Get_Friendlyname (MtpDeviceHandle handle); // char *
Ejemplo n.º 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 *
Ejemplo n.º 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 *
Ejemplo n.º 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);
Ejemplo n.º 55
0
 static extern int LIBMTP_Update_Album(MtpDeviceHandle handle, ref AlbumStruct album);
Ejemplo n.º 56
0
 private static extern int LIBMTP_Send_Track_From_File(MtpDeviceHandle handle, string path, ref TrackStruct track, ProgressFunction callback, IntPtr data);
Ejemplo n.º 57
0
 internal static IntPtr GetFolderList (MtpDeviceHandle handle)
 {
     return LIBMTP_Get_Folder_List (handle);
 }
Ejemplo n.º 58
0
 private static extern int LIBMTP_Update_Track_Metadata(MtpDeviceHandle handle, ref TrackStruct metadata);
Ejemplo n.º 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 *