示例#1
0
        private void listView2_ItemDrag(object sender, ItemDragEventArgs e)
        {
            string[] filenames;
            //string[] filenames_real;

            string ext = "";

            if (files92 == null)
            {
                ext = ".mddata";
            }

            iPhoneBackup backup = currentBackup;

            int k = 0;

            filenames = new string[listView2.SelectedItems.Count];
            //filenames_real = new string[listView2.SelectedItems.Count];

            foreach (ListViewItem i in listView2.SelectedItems)
            {
                filenames[k] = Path.Combine(backup.path, ((iPhoneFile)i.Tag).Key + ext);
                //filenames_real[k] = "";

                ++k;
            }

            listView2.DoDragDrop(new DataObject(DataFormats.FileDrop, filenames), DragDropEffects.Copy);
        }
示例#2
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox1.SelectedIndex == -1)
            {
                return;
            }

            if (comboBox1.SelectedItem.GetType() == typeof(iPhoneBackup))
            {
                if (currentBackup == null || currentBackup.index != comboBox1.SelectedIndex)
                {
                    currentBackup = (iPhoneBackup)comboBox1.SelectedItem;
                    loadCurrentBackup();
                }
                return;
            }


            // choose a backup from a non standard directory

            OpenFileDialog fd = new OpenFileDialog();

            //fd.InitialDirectory = "C:\\" ;
            fd.Filter           = "iPhone Backup|Info.plist|All files (*.*)|*.*";
            fd.FilterIndex      = 1;
            fd.RestoreDirectory = true;

            if (fd.ShowDialog() == DialogResult.OK)
            {
                //backups.Clear();
                //comboBox1.Items.Clear();
                //listView1.Items.Clear();
                //listView2.Items.Clear();

                iPhoneBackup b = LoadManifest(Path.GetDirectoryName(fd.FileName));

                if (b != null)
                {
                    b.custom = true;

                    comboBox1.Items.Insert(comboBox1.Items.Count - 1, b);

                    b.index = comboBox1.Items.Count - 2;

                    comboBox1.SelectedIndex = b.index;
                }
            }

            if (comboBox1.SelectedIndex == comboBox1.Items.Count - 1)
            {
                if (currentBackup != null)
                {
                    comboBox1.SelectedIndex = currentBackup.index;
                }
                else
                {
                    comboBox1.SelectedIndex = -1;
                }
            }
        }
示例#3
0
        private iPhoneBackup LoadManifest(string path)
        {
            iPhoneBackup backup = null;

            string filename = Path.Combine(path, "Info.plist");

            try
            {
                xdict dd = xdict.open(filename);

                if (dd != null)
                {
                    backup = new iPhoneBackup();

                    backup.path = path;

                    foreach (xdictpair p in dd)
                    {
                        if (p.item.GetType() == typeof(string))
                        {
                            switch (p.key)
                            {
                            case "Device Name": backup.DeviceName = (string)p.item; break;

                            case "Display Name": backup.DisplayName = (string)p.item; break;

                            case "Last Backup Date":
                                DateTime.TryParse((string)p.item, out backup.LastBackupDate);
                                break;
                            }
                        }
                    }

                    backups.Add(backup);
                    backups.Sort(iPhoneBackup.SortByDate);
                }
            }
            catch (InvalidOperationException ex)
            {
                MessageBox.Show(ex.InnerException.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            return(backup);
        }
示例#4
0
        private void listView2_DoubleClick(object sender, EventArgs e)
        {
            iPhoneBackup backup = currentBackup;
            iPhoneFile   file   = (iPhoneFile)listView2.FocusedItem.Tag;

            string ext = "";

            if (files92 == null)
            {
                ext = ".mddata";
            }

            string argument = @"/select, """ + Path.Combine(backup.path, file.Key + ext) + @"""";

            System.Diagnostics.Process.Start("explorer.exe", argument);
        }
示例#5
0
        private void loadCurrentBackup()
        {
            if (currentBackup == null)
            {
                return;
            }

            button1.ToolTipText = currentBackup.path;

            listView1.Items.Clear();
            listView2.Items.Clear();
            buttonCSVExport.Enabled = false;
            files92 = null;

            try
            {
                iPhoneBackup backup = currentBackup;

                // backup iTunes 9.2+
                if (File.Exists(Path.Combine(backup.path, "Manifest.mbdb")))
                {
                    files92 = mbdbdump.mbdb.ReadMBDB(backup.path);

                    BinaryPlistReader az = new BinaryPlistReader();
                    IDictionary       er = az.ReadObject(Path.Combine(backup.path, "Manifest.plist"));

                    parseAll92(er);
                }
            }
            catch (InvalidOperationException ex)
            {
                MessageBox.Show(ex.InnerException.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.StackTrace);
            }
        }
示例#6
0
        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            string filename;
            string dest_root;
            string dest;

            string ext = (files92 == null) ? ".mddata" : "";

            iPhoneBackup backup = currentBackup;
            iPhoneApp    app    = listView1.FocusedItem.Tag as iPhoneApp;

            if (backup == null || app == null)
            {
                return;
            }

            dest_root = dest = Path.Combine(@"C:\temp", backup.DeviceName, app.Key);

            foreach (ListViewItem i in listView2.SelectedItems)
            {
                iPhoneFile f = i.Tag as iPhoneFile;
                if (f != null)
                {
                    filename = Path.Combine(backup.path, f.Key + ext);

                    dest = Path.Combine(dest_root, f.Path);

                    dest = dest.Normalize(NormalizationForm.FormC);

                    StringBuilder sb = new StringBuilder(dest.Length);
                    char[]        ss = Path.GetInvalidPathChars();

                    Array.Sort(ss);

                    foreach (char c in dest)
                    {
                        //System.IO.Path.GetInvalidFileNameChars()
                        if (c == Path.DirectorySeparatorChar || c == Path.AltDirectorySeparatorChar)
                        {
                            sb.Append(Path.DirectorySeparatorChar);
                        }
                        else if (c == Path.VolumeSeparatorChar)
                        {
                            sb.Append(c);
                        }
                        else if (Array.BinarySearch(ss, c) >= 0)
                        {
                            sb.Append('_');
                        }
                        else
                        {
                            sb.Append(c);
                        }
                    }

                    dest = sb.ToString();
                    dest = dest.Replace(':', '_');
                    dest = dest.Replace(@"C_\temp", @"C:\temp");
                    Directory.CreateDirectory(Path.GetDirectoryName(dest));
                    File.Copy(filename, dest, true);
                }
            }
        }
示例#7
0
        public int index;                   // index in the combobox control

        // delegate to sort backups (newer first)
        public static int SortByDate(iPhoneBackup a, iPhoneBackup b)
        {
            return(b.LastBackupDate.CompareTo(a.LastBackupDate));
        }
示例#8
0
        public int index;                   // index in the combobox control

        // delegate to sort backups (newer first)
        public static int SortByDate(iPhoneBackup a, iPhoneBackup b)
        {
            return b.LastBackupDate.CompareTo(a.LastBackupDate);
        }
示例#9
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox1.SelectedIndex == -1)
                return;

            if (comboBox1.SelectedItem.GetType() == typeof(iPhoneBackup))
            {
                if (currentBackup == null || currentBackup.index != comboBox1.SelectedIndex)
                {
                    currentBackup = (iPhoneBackup)comboBox1.SelectedItem;
                    loadCurrentBackup();
                }
                return;
            }


            // choose a backup from a non standard directory

            OpenFileDialog fd = new OpenFileDialog();

            //fd.InitialDirectory = "C:\\" ;
            fd.Filter = "iPhone Backup|Info.plist|All files (*.*)|*.*";
            fd.FilterIndex = 1;
            fd.RestoreDirectory = true;
            
            if (fd.ShowDialog() == DialogResult.OK)
            {
                //backups.Clear();
                //comboBox1.Items.Clear();
                //listView1.Items.Clear();
                //listView2.Items.Clear();

                iPhoneBackup b = LoadManifest(Path.GetDirectoryName(fd.FileName));

                if (b != null)
                {
                    b.custom = true;

                    comboBox1.Items.Insert(comboBox1.Items.Count - 1, b);

                    b.index = comboBox1.Items.Count - 2;

                    comboBox1.SelectedIndex = b.index;
                }
            }

            if (comboBox1.SelectedIndex == comboBox1.Items.Count - 1)
            {
                if (currentBackup != null) 
                    comboBox1.SelectedIndex = currentBackup.index;                
                else
                    comboBox1.SelectedIndex = -1;                
            }
        }
示例#10
0
        private iPhoneBackup LoadManifest(string path)
        {
            iPhoneBackup backup = null;

            string filename = Path.Combine(path, "Info.plist");

            try
            {
                xdict dd = xdict.open(filename);

                if (dd != null)
                {
                    backup = new iPhoneBackup();

                    backup.path = path;

                    foreach (xdictpair p in dd)
                    {
                        if (p.item.GetType() == typeof(string))
                        {
                            switch (p.key)
                            {
                                case "Device Name": backup.DeviceName = (string)p.item; break;
                                case "Display Name": backup.DisplayName = (string)p.item; break;
                                case "Last Backup Date":                                    
                                    DateTime.TryParse((string)p.item, out backup.LastBackupDate);
                                    break;
                            }
                        }
                    }

                    backups.Add(backup);
                    backups.Sort(iPhoneBackup.SortByDate);
                }
            }
            catch (InvalidOperationException ex)
            {
                MessageBox.Show(ex.InnerException.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            return backup;
        }