Beispiel #1
0
        public bool HasAncestor(Folder ancestor)
        {
            if (ancestor == null) {
                throw new ArgumentNullException ("ancestor");
            }

            if (device != ancestor.device) {
                throw new ArgumentException ("Folders are on different devices");
            }

            bool hasAncestor = false;
            if (parentId != 0) {
                if (parentId == ancestor.FolderId) {
                    hasAncestor = true;
                } else {
                    Folder parent = CreateParentFolder ();

                    hasAncestor = parent.HasAncestor (ancestor);
                }
            }
            return hasAncestor;
        }
Beispiel #2
0
        internal static Folder Find(MtpDevice device, uint folderId)
        {
            if (device == null) {
                throw new ArgumentNullException ("device");
            }

            Folder folder = null;
            IntPtr root = GetFolderList (device.Handle);
            try {
                IntPtr ptr = Find (root, folderId);
                if (ptr != IntPtr.Zero) {
                    FolderStruct folderStruct = (FolderStruct)Marshal.PtrToStructure (ptr, typeof (FolderStruct));
                    folder = new Folder (folderStruct, device);
                }
            } finally {
                DestroyFolder (root);
            }
            return folder;
        }
Beispiel #3
0
 public bool InFolder(Folder folder)
 {
     return InFolder (folder, false);
 }
Beispiel #4
0
        public bool InFolder(Folder folder, bool recursive)
        {
            if (folder == null) {
                return false;
            }

            bool is_parent = trackStruct.parent_id == folder.FolderId;
            if (is_parent || !recursive) {
                return is_parent;
            }

            return Folder.Find (device, trackStruct.parent_id).HasAncestor (folder);
        }
Beispiel #5
0
        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);
        }
Beispiel #6
0
 public bool InFolder (Folder folder)
 {
     return folder != null && trackStruct.parent_id == folder.FolderId;
 }
Beispiel #7
0
 public void UploadTrack (string path, Track track, Folder folder)
 {
     UploadTrack (path, track, folder, null);
 }
Beispiel #8
0
 /// <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;
     }
 }
Beispiel #9
0
 public void UploadTrack(string path, Track track, Folder folder)
 {
     UploadTrack(path, track, folder, null);
 }
Beispiel #10
0
 public List <Folder> GetRootFolders()
 {
     return(Folder.GetRootFolders(this));
 }
Beispiel #11
0
 public bool InFolder(Folder folder)
 {
     return(folder != null && trackStruct.parent_id == folder.FolderId);
 }