Пример #1
0
        public void RefreshDatabase()
        {
            IntPtr afcClient;

            AFC.AFCError returnCode = AFC.afc_client_start_service(device.handle, out afcClient, "iOSLib");
            if (returnCode != AFC.AFCError.AFC_E_SUCCESS || afcClient == IntPtr.Zero)
            {
                return;
            }

            string photoDataPath = @"/PhotoData/Photos.sqlite";

            if (AFC.copyToDisk(afcClient, photoDataPath, tempFolder + @"\Photos.sqlite") != AFC.AFCError.AFC_E_SUCCESS)
            {
                AFC.afc_client_free(afcClient);
                return;
            }

            AFC.copyToDisk(afcClient, photoDataPath + "-wal", tempFolder + @"\Photos.sqlite-wal");
            AFC.copyToDisk(afcClient, photoDataPath + "-shm", tempFolder + @"\Photos.sqlite-shm");

            AFC.afc_client_free(afcClient);

            Count = SQLite.countPhotos(tempFolder + @"\Photos.sqlite");
        }
Пример #2
0
        public void SavePhotos(List <Photo> photoList, string savePath)
        {
            if (!Directory.Exists(savePath))
            {
                Directory.CreateDirectory(savePath);
            }

            IEnumerable photoLists = photoList.GroupBy(x => x.Device.Udid).Select(x => x.ToList());

            foreach (List <Photo> currPhotoList in photoLists)
            {
                iDevice currDevice = currPhotoList[0].Device;
                IntPtr  afcClient;
                if (AFC.afc_client_start_service(device.handle, out afcClient, "iOSLib") != AFC.AFCError.AFC_E_SUCCESS ||
                    afcClient == IntPtr.Zero)
                {
                    return;
                }

                foreach (Photo currPhoto in currPhotoList)
                {
                    AFC.copyToDisk(afcClient, currPhoto.getNameWithPath(), savePath + @"\" + currPhoto.getName());
                    Photo.serializeXml(currPhoto, savePath);
                }
            }
        }
Пример #3
0
        public void Remove()
        {
            parent.RefreshDatabase();
            SQLite.deleteFromDatabase(this);

            IntPtr afcClient;

            AFC.AFCError returnCode = AFC.afc_client_start_service(Device.handle, out afcClient, "iOSLib");
            if (returnCode != AFC.AFCError.AFC_E_SUCCESS || afcClient == IntPtr.Zero)
            {
                return;
            }
            returnCode = AFC.afc_remove_path(afcClient, getNameWithPath());

            if (AFC.afc_remove_path(afcClient, @"/PhotoData/Photos.sqlite-shm") != AFC.AFCError.AFC_E_SUCCESS ||
                AFC.afc_remove_path(afcClient, @"/PhotoData/Photos.sqlite-wal") != AFC.AFCError.AFC_E_SUCCESS)
            {
                AFC.afc_client_free(afcClient);
                return;
            }

            if (AFC.afc_remove_path(afcClient, @"/PhotoData/Photos.sqlite") != AFC.AFCError.AFC_E_SUCCESS)
            {
                AFC.afc_client_free(afcClient);
                return;
            }

            AFC.copyToDevice(afcClient, parent.tempFolder + @"\Photos.sqlite", @"/PhotoData/Photos.sqlite");
            AFC.afc_client_free(afcClient);
        }
Пример #4
0
        public void SaveSettings()
        {
            foreach (AutoFilterCollection AFC in MainBigList.Where(x => x is AutoFilterCollection))
            {
                AFC.SaveSettings();
            }

            RecentFileList.Save();
            Properties.Settings.Default.Save();
        }
Пример #5
0
        public static int AFCDirectoryRead(TypedPtr <AFCCommConnection> conn, IntPtr dir, ref string buffer)
        {
            int ret;

            IntPtr ptr = IntPtr.Zero;

            ret = AFC.DirectoryRead((IntPtr)conn, dir, ref ptr);
            if ((ret == 0) && (ptr != null))
            {
                buffer = Marshal.PtrToStringAnsi(ptr);
            }
            else
            {
                buffer = null;
            }
            return(ret);
        }
Пример #6
0
        public void Save(string savePath)
        {
            IntPtr afcClient;

            AFC.AFCError returnCode = AFC.afc_client_start_service(Device.handle, out afcClient, "iOSLib");
            if (returnCode != AFC.AFCError.AFC_E_SUCCESS || afcClient == IntPtr.Zero)
            {
                return;
            }

            if (AFC.copyToDisk(afcClient, getNameWithPath(), savePath + @"\" + getName()) != AFC.AFCError.AFC_E_SUCCESS)
            {
                AFC.afc_client_free(afcClient);
                return;
            }
            AFC.afc_client_free(afcClient);

            serializeXml(this, savePath);
        }
Пример #7
0
        public void Restore(string path)
        {
            Photo photo = new Photo(path);

            IntPtr afcClient;
            ulong  fileHandle;

            if (AFC.openPhoto(photo, device.Photos.PhotoList[device.Photos.PhotoList.Count - 1].Path + photo.getName(),
                              device, AFC.FileOpenMode.AFC_FOPEN_WRONLY, out afcClient, out fileHandle) != AFC.AFCError.AFC_E_SUCCESS ||
                afcClient == IntPtr.Zero || fileHandle == 0)
            {
                return;
            }

            byte[] fileContent = File.ReadAllBytes(photo.getNameWithPath());
            uint   bytesWritten;

            AFC.afc_file_write(afcClient, fileHandle, fileContent, Convert.ToUInt32(photo.Size), out bytesWritten);

            AFC.closePhoto(afcClient, fileHandle);
        }
Пример #8
0
        public void RemovePhotos(List <Photo> photoList)
        {
            IEnumerable photoLists = photoList.GroupBy(x => x.Device.Udid).Select(x => x.ToList());

            foreach (List <Photo> currPhotoList in photoLists)
            {
                iDevice currDevice = currPhotoList[0].Device;

                IntPtr       afcClient;
                AFC.AFCError returnCode = AFC.afc_client_start_service(currDevice.handle, out afcClient, "iOSLib");
                if (returnCode != AFC.AFCError.AFC_E_SUCCESS || afcClient == IntPtr.Zero)
                {
                    continue;
                }
                currPhotoList[0].parent.RefreshDatabase();

                if (AFC.afc_remove_path(afcClient, @"/PhotoData/Photos.sqlite-shm") != AFC.AFCError.AFC_E_SUCCESS ||
                    AFC.afc_remove_path(afcClient, @"/PhotoData/Photos.sqlite-wal") != AFC.AFCError.AFC_E_SUCCESS)
                {
                    AFC.afc_client_free(afcClient);
                    continue;
                }

                if (AFC.afc_remove_path(afcClient, @"/PhotoData/Photos.sqlite") != AFC.AFCError.AFC_E_SUCCESS)
                {
                    AFC.afc_client_free(afcClient);
                    continue;
                }

                foreach (Photo currPhoto in currPhotoList)
                {
                    SQLite.deleteFromDatabase(currPhoto);
                    returnCode = AFC.afc_remove_path(afcClient, currPhoto.getNameWithPath());
                }

                AFC.copyToDevice(afcClient, currPhotoList[0].parent.tempFolder + @"\Photos.sqlite", @"/PhotoData/Photos.sqlite");
                AFC.afc_client_free(afcClient);
            }
        }
Пример #9
0
 public static int AFCDirectoryOpen(TypedPtr <AFCCommConnection> conn, string path, ref IntPtr dir)
 {
     return(AFC.DirectoryOpen((IntPtr)conn, Encoding.UTF8.GetBytes(path), ref dir));
 }