Inheritance: System.Windows.Forms.Form
 public void Push( List<System.IO.FileInfo> files, string destPath )
 {
     var transfer = new TransferDialog ( );
     transfer.PushDialog ( files, destPath );
 }
 public void Push( System.IO.FileInfo file, string remote )
 {
     var transfer = new TransferDialog ( );
     transfer.PushDialog ( file, remote);
 }
 public void Pull( Core.IO.FileInfo remoteFile, System.IO.FileInfo destFile )
 {
     var transfer = new TransferDialog ( );
     transfer.PullDialog ( remoteFile, destFile );
 }
 public void Pull( List<Core.IO.FileInfo> files, System.IO.DirectoryInfo destPath )
 {
     var transfer = new TransferDialog ( );
     transfer.PullDialog ( files, destPath );
 }
Exemple #5
0
        private void copyToLocalToolStripButton_Click( object sender, EventArgs e )
        {
            if ( itemsList.SelectedItems.Count > 0 ) {
                FolderBrowserDialog fbd = new FolderBrowserDialog ( );
                fbd.RootFolder = Environment.SpecialFolder.Desktop;
                fbd.Description = "Select destination for selected files";
                fbd.ShowNewFolderButton = true;
                if ( fbd.ShowDialog ( this ) == DialogResult.OK ) {
                    string selPath = fbd.SelectedPath;
                    List<DroidExplorer.Core.IO.FileInfo> files = new List<DroidExplorer.Core.IO.FileInfo> ( );
                    foreach ( FileSystemInfoListViewItem item in itemsList.SelectedItems ) {
                        if ( item.FileSystemInfo.IsDirectory ) {

                        } else if ( item.FileSystemInfo.IsLink ) {

                        } else if ( item.FileSystemInfo.IsPipe ) {

                        } else if ( item.FileSystemInfo.IsSocket ) {

                        } else { // file
                            files.Add ( item.FileSystemInfo as DroidExplorer.Core.IO.FileInfo );
                        }
                    }

                    var transfer = new TransferDialog ( );
                    transfer.TransferComplete += delegate ( object s, EventArgs ea ) {

                    };
                    transfer.TransferError += delegate ( object s, EventArgs ea ) {
                        if ( transfer.TransferException != null ) { // was there an error while transfering?
                            TaskDialog.MessageBox ( "Transfer Error", transfer.TransferException.Message, string.Empty, TaskDialogButtons.OK, SysIcons.Error );
                        }
                    };
                    transfer.Pull ( files, new System.IO.DirectoryInfo ( selPath ) );
                }
            }
        }
Exemple #6
0
        private void copyToolStripMenuItem_Click( object sender, EventArgs e )
        {
            List<string> lfiles = new List<string> ( );
            List<DroidExplorer.Core.IO.FileInfo> rfiles = new List<DroidExplorer.Core.IO.FileInfo> ( );
            foreach ( FileSystemInfoListViewItem item in itemsList.SelectedItems ) {
                if ( item.FileSystemInfo.IsLink ) {
                    // links CAN NOT use ADB Pull/Push, the link needs to be resolved and then
                    // ADB Pull/Push can be used
                    if ( !item.FileSystemInfo.IsDirectory ) {
                        DroidExplorer.Core.IO.SymbolicLinkInfo lnk = item.FileSystemInfo as DroidExplorer.Core.IO.SymbolicLinkInfo;

                        string linkFullPath = System.IO.Path.Combine ( CurrentDirectory.FullName, lnk.Link );
                        this.LogDebug ( "Copying {0} link from {1}", lnk.Name, linkFullPath );
                        rfiles.Add ( DroidExplorer.Core.IO.FileInfo.Create ( item.FileSystemInfo.Name,
                            item.FileSystemInfo.Size, item.FileSystemInfo.UserPermissions,
                            item.FileSystemInfo.GroupPermissions, item.FileSystemInfo.OtherPermissions,
                            item.FileSystemInfo.LastModificationDateTime,/* item.FileSystemInfo.IsExecutable */ false,
                            linkFullPath ) );
                        lfiles.Add ( System.IO.Path.Combine ( FolderManagement.TempFolder, item.FileSystemInfo.Name ) );
                    }
                } else if ( item.FileSystemInfo.IsDirectory ) {
                    TaskDialog.MessageBox ( "Not Yet Implemented", "Can not copy directory to clipboard", "This feature will be added soon.", TaskDialogButtons.OK, SysIcons.Information );
                } else if ( item.FileSystemInfo.IsPipe ) {
                    // do nothing as they are not yet visible
                } else if ( item.FileSystemInfo.IsSocket ) {
                    // do nothing as they are not yet visible
                } else { // file
                    rfiles.Add ( item.FileSystemInfo as DroidExplorer.Core.IO.FileInfo );
                    lfiles.Add ( System.IO.Path.Combine ( FolderManagement.TempFolder, item.FileSystemInfo.Name ) );
                }
            }
            if ( rfiles.Count > 0 ) {
                var transfer = new TransferDialog ( );
                if ( transfer.PullDialog ( rfiles, new System.IO.DirectoryInfo ( FolderManagement.TempFolder ) ) == DialogResult.OK ) {
                    this.Cursor = Cursors.WaitCursor;
                    Clipboard.SetData ( DataFormats.FileDrop, lfiles.ToArray ( ) );
                    this.Cursor = Cursors.Default;
                } else {
                    if ( transfer.TransferException != null ) {
                        TaskDialog.MessageBox ( "Copy error", transfer.TransferException.Message, string.Empty, TaskDialogButtons.OK, SysIcons.Error );
                    }
                }
            }
        }
Exemple #7
0
 private void copyToDeviceToolStripButton_Click( object sender, EventArgs e )
 {
     System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog ( );
     ofd.Title = "Select files to copy";
     ofd.Filter = "All Files (*.*)|*.*";
     ofd.FilterIndex = 0;
     ofd.CheckFileExists = true;
     ofd.Multiselect = true;
     //ofd.InitialDirectory = Environment.GetFolderPath ( Environment.SpecialFolder.Desktop );
     if ( ofd.ShowDialog ( this ) == DialogResult.OK ) {
         if ( ofd.FileNames != null && ofd.FileNames.Length > 0 ) {
             List<System.IO.FileInfo> files = new List<System.IO.FileInfo> ( );
             foreach ( var item in ofd.FileNames ) {
                 files.Add ( new System.IO.FileInfo ( item ) );
             }
             var tf = new TransferDialog ( );
             if ( tf.PushDialog ( files, this.CurrentDirectory.FullName ) != DialogResult.OK ) {
                 if ( tf.TransferException != null ) { // was there an error while transfering?
                     TaskDialog.MessageBox ( "Transfer Error", tf.TransferException.Message, string.Empty, TaskDialogButtons.OK, SysIcons.Error );
                 }
             } else {
                 NavigateToPath ( this.CurrentDirectory );
             }
         }
     }
 }
Exemple #8
0
 private void applyROMUpdateToolStripMenuItem_Click( object sender, EventArgs e )
 {
     System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog ( );
     ofd.Title = "Select ROM Update .zip";
     //ofd.RestoreDirectory = true;
     ofd.Multiselect = false;
     //ofd.InitialDirectory = Environment.GetFolderPath ( Environment.SpecialFolder.Desktop );
     ofd.Filter = "Zip Files|*.zip";
     ofd.FilterIndex = 0;
     if ( ofd.ShowDialog ( this ) == DialogResult.OK ) {
         var transfer = new TransferDialog ( );
         if ( transfer.PushDialog ( new System.IO.FileInfo ( ofd.FileName ), "/sdcard/update.zip" ) == DialogResult.OK ) {
             TaskDialog.ShowTaskDialogBox ( "Apply Update?", "Do you want to apply the uploaded update now?", string.Empty, string.Empty,
                 string.Empty, string.Empty, string.Empty, "Reboot device to apply update now|Reboot in recovery but do not apply|Do not apply update now", TaskDialogButtons.None,
                 SysIcons.Question, SysIcons.Information );
             if ( TaskDialog.CommandButtonResult == 0 ) {
                 // apply now
                 CommandRunner.Instance.ApplyUpdate ( );
             } else if ( TaskDialog.CommandButtonResult == 1 ) {
                 CommandRunner.Instance.RebootRecovery ( );
             }
         } else {
             if ( transfer.TransferException != null ) { // was there an error while transfering?
                 TaskDialog.MessageBox ( "Transfer Error", transfer.TransferException.Message, string.Empty, TaskDialogButtons.OK, SysIcons.Error );
             }
         }
     }
 }
Exemple #9
0
 private void pasteToolStripMenuItem_Click( object sender, EventArgs e )
 {
     if ( Clipboard.ContainsFileDropList ( ) ) {
         StringCollection files = Clipboard.GetFileDropList ( );
         List<System.IO.FileInfo> lfiles = new List<System.IO.FileInfo> ( );
         foreach ( var item in files ) {
             System.IO.FileInfo file = new System.IO.FileInfo ( item );
             if ( file.Exists ) {
                 lfiles.Add ( file );
             }
         }
         var transfer = new TransferDialog ( );
         transfer.TransferComplete += delegate ( object s, EventArgs ea ) {
             if ( this.InvokeRequired ) {
                 this.Invoke ( new NavigateToPathDelegate ( this.NavigateToPath ), new object[] { this.CurrentDirectory } );
             } else {
                 this.NavigateToPath ( this.CurrentDirectory );
             }
         };
         transfer.TransferError += delegate ( object s, EventArgs ea ) {
             if ( transfer.TransferException != null ) {
                 if ( this.InvokeRequired ) {
                     this.Invoke ( new MessageBoxDelegate ( TaskDialog.MessageBox ), new object[] { "Paste error", transfer.TransferException.Message, string.Empty, TaskDialogButtons.OK, SysIcons.Error } );
                 } else {
                     TaskDialog.MessageBox ( "Paste error", transfer.TransferException.Message, string.Empty, TaskDialogButtons.OK, SysIcons.Error );
                 }
             }
         };
         transfer.Push ( lfiles, this.CurrentDirectory.FullName );
     }
 }
Exemple #10
0
        void itemsList_DragDrop( object sender, DragEventArgs e )
        {
            if ( e.Data.GetDataPresent ( DataFormats.FileDrop ) ) {
                string[] fsiItems = (string[])e.Data.GetData ( DataFormats.FileDrop );
                List<System.IO.FileInfo> files = new List<System.IO.FileInfo> ( );
                foreach ( var item in fsiItems ) {
                    if ( System.IO.File.Exists ( item ) ) {
                        files.Add ( new System.IO.FileInfo ( item ) );
                    } else if ( System.IO.Directory.Exists ( item ) ) {
                        // TODO: Handle copying entire directory over.
                    }
                }

                var transfer = new TransferDialog ( );
                transfer.TransferComplete += delegate ( object s, EventArgs ea ) {
                    if ( this.InvokeRequired ) {
                        this.Invoke ( new NavigateToPathDelegate ( NavigateToPath ), new object[] { this.CurrentDirectory } );
                    } else {
                        NavigateToPath ( this.CurrentDirectory );
                    }
                };
                transfer.TransferError += delegate ( object s, EventArgs ea ) {
                    if ( transfer.TransferException != null ) { // was there an error while transfering?
                        if ( this.InvokeRequired ) {
                            this.Invoke ( new MessageBoxDelegate ( TaskDialog.MessageBox ), new object[] { "Transfer Error", transfer.TransferException.Message, string.Empty, TaskDialogButtons.OK, SysIcons.Error } );
                        } else {
                            TaskDialog.MessageBox ( "Transfer Error", transfer.TransferException.Message, string.Empty, TaskDialogButtons.OK, SysIcons.Error );
                        }
                    }
                };
                transfer.Push ( files, this.CurrentDirectory.FullName );
            }
        }
Exemple #11
0
 private void flashRecoveryImageToolStripMenuItem_Click( object sender, EventArgs e )
 {
     System.Windows.Forms.OpenFileDialog ofd = new System.Windows.Forms.OpenFileDialog ( );
     ofd.Title = "Select Recovery Image";
     ofd.Filter = "Recovery Images|*.img|All Files (*.*)|*.*";
     ofd.FilterIndex = 0;
     //ofd.InitialDirectory = Environment.GetFolderPath ( Environment.SpecialFolder.Desktop );
     //ofd.RestoreDirectory = true;
     ofd.Multiselect = false;
     if ( ofd.ShowDialog ( this ) == DialogResult.OK ) {
         string recoveryImage = string.Format ( "/sdcard/{0}", System.IO.Path.GetFileName ( ofd.FileName ) );
         var tf = new TransferDialog ( );
         if ( tf.PushDialog ( new System.IO.FileInfo ( ofd.FileName ), recoveryImage ) != DialogResult.OK ) {
             TaskDialog.ShowTaskDialogBox ( "Flash Recovery Image?", "Recovery image has been transfered to device.", string.Empty, string.Empty,
                 string.Empty, string.Empty, string.Empty, "Flash image now|Do not do not flash image now", TaskDialogButtons.None,
                 SysIcons.Question, SysIcons.Information );
             if ( TaskDialog.CommandButtonResult == 0 ) {
                 // apply now
                 try {
                     CommandRunner.Instance.FlashImage ( recoveryImage );
                     TaskDialog.MessageBox ( "Flash Complete", "The recovery image was successfully flashed to the device.", string.Empty, TaskDialogButtons.OK, SysIcons.Information );
                 } catch ( Exception ex ) {
                     TaskDialog.MessageBox ( "Flash Error", ex.Message, string.Empty, TaskDialogButtons.OK, SysIcons.Error );
                 }
             }
         } else {
             if ( tf.TransferException != null ) { // was there an error while transfering?
                 TaskDialog.MessageBox ( "Transfer Error", tf.TransferException.Message, string.Empty, TaskDialogButtons.OK, SysIcons.Error );
             }
         }
     }
 }