Exemple #1
0
        void ICyberduck.QuickConnect(string arg)
        {
            Host h = HostParser.parse(arg);

            if (AbstractPath.Type.file == _detector.detect(h.getDefaultPath()))
            {
                Path file = new Path(h.getDefaultPath(), EnumSet.of(AbstractPath.Type.file));
                // wait until transferCollection is loaded
                transfersSemaphore.Wait();
                TransferController.Instance.StartTransfer(new DownloadTransfer(h, file,
                                                                               LocalFactory.get(PreferencesFactory.get().getProperty("queue.download.folder"),
                                                                                                file.getName())));
            }
            else
            {
                foreach (BrowserController b in Browsers)
                {
                    if (b.IsMounted())
                    {
                        if (
                            new HostUrlProvider().get(b.Session.getHost())
                            .Equals(new HostUrlProvider().get(h)))
                        {
                            b.View.BringToFront();
                            return;
                        }
                    }
                }
                NewBrowser().Mount(h);
            }
        }
Exemple #2
0
        public static string ExtractExeFromCommand(string command)
        {
            if (!String.IsNullOrEmpty(command))
            {
                String cmd = null;
                if (command.StartsWith("\""))
                {
                    int i = command.IndexOf("\"", 1);
                    if (i > 2)
                    {
                        cmd = command.Substring(1, i - 1);
                    }
                }
                else
                {
                    int i = command.IndexOf(" ");
                    if (i > 0)
                    {
                        cmd = command.Substring(0, i);
                    }
                }

                if (null != cmd && LocalFactory.get(cmd).exists())
                {
                    return(cmd);
                }
            }
            return(null);
        }
Exemple #3
0
        public AboutBox()
        {
            InitializeComponent();

            Text = String.Format("About {0}", AssemblyTitle);
            logoPictureBox.Image  = ApplicationIcon();
            labelProductName.Text = AssemblyProduct;
            labelVersion.Text     = String.Format("Version {0} ({1})",
                                                  PreferencesFactory.get().getProperty("application.version"),
                                                  PreferencesFactory.get().getProperty("application.revision"));
            labelCopyright.Text = Copyright();

            Font bigBoldFont = new Font(Font.FontFamily, Font.Size + 4, FontStyle.Bold);

            labelProductName.Font = bigBoldFont;

            labelRegistered.Text = RegisteredText();

            creditsRichTextBox.Rtf = Credits();
            creditsRichTextBox.SelectAll();
            creditsRichTextBox.SelectionFont = new Font(Font.FontFamily, 9);
            creditsRichTextBox.DeselectAll();
            creditsRichTextBox.LinkClicked += (sender, e) => BrowserLauncherFactory.get().open(e.LinkText);

            ackButton.Click +=
                delegate { ApplicationLauncherFactory.get().open(LocalFactory.get("Acknowledgments.rtf")); };
            PeriodicUpdateChecker updater = PeriodicUpdateCheckerFactory.get();

            updateButton.Enabled = updater.hasUpdatePrivileges();
            updateButton.Click  += delegate { updater.check(false); };
        }
Exemple #4
0
        void ICyberduck.RegisterRegistration(string registrationPath)
        {
            Local   f       = LocalFactory.get(registrationPath);
            License license = LicenseFactory.get(f);

            if (license.verify(new DisabledLicenseVerifierCallback()))
            {
                f.copy(LocalFactory.get(SupportDirectoryFinderFactory.get().find(),
                                        f.getName()));
                _bc.InfoBox(license.ToString(),
                            LocaleFactory.localizedString(
                                "Thanks for your support! Your contribution helps to further advance development to make Cyberduck even better.",
                                "License"),
                            LocaleFactory.localizedString(
                                "Your registration key has been copied to the Application Support folder.",
                                "License"),
                            String.Format("{0}", LocaleFactory.localizedString("Continue", "License")), null, false);
                foreach (BrowserController controller in new List <BrowserController>(Browsers))
                {
                    controller.RemoveDonateButton();
                }
            }
            else
            {
                _bc.WarningBox(LocaleFactory.localizedString("Not a valid registration key", "License"),
                               LocaleFactory.localizedString("Not a valid registration key", "License"),
                               LocaleFactory.localizedString("This registration key does not appear to be valid.",
                                                             "License"), null,
                               String.Format("{0}", LocaleFactory.localizedString("Continue", "License")), false,
                               ProviderHelpServiceFactory.get().help(), delegate { });
            }
        }
Exemple #5
0
 private void View_ChangedPrivateKeyEvent(object sender, PrivateKeyArgs e)
 {
     _host.getCredentials()
     .setIdentity(null == e.KeyFile || e.KeyFile.Equals(LocaleFactory.localizedString("None"))
             ? null
             : LocalFactory.get(e.KeyFile));
     Update();
     ItemChanged();
 }
Exemple #6
0
 private void View_ChangedPrivateKey(object sender, PrivateKeyArgs e)
 {
     _credentials.setIdentity(null == e.KeyFile ? null : LocalFactory.get(e.KeyFile));
     if (!_keys.Contains(e.KeyFile))
     {
         _keys.Add(e.KeyFile);
         View.PopulatePrivateKeys(_keys);
     }
     Update();
 }
Exemple #7
0
        public static IList <KeyValuePair <string, string> > OpenWithListForExtension(String ext)
        {
            IList <String> progs = new List <string>();
            List <KeyValuePair <string, string> > map = new List <KeyValuePair <string, string> >();

            if (IsBlank(ext))
            {
                return(map);
            }

            if (!ext.StartsWith("."))
            {
                ext = "." + ext;
            }
            using (RegistryKey clsExt = Registry.ClassesRoot.OpenSubKey(ext))
            {
                IList <string> rootList = OpenWithListForExtension(ext, clsExt);
                foreach (string s in rootList)
                {
                    progs.Add(s);
                }
            }
            using (
                RegistryKey clsExt =
                    Registry.CurrentUser.OpenSubKey(
                        "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\" + ext))
            {
                IList <string> explorerList = OpenWithListForExtension(ext, clsExt);
                foreach (string s in explorerList)
                {
                    progs.Add(s);
                }
            }

            foreach (string exe in progs.Distinct())
            {
                ApplicationFinder finder      = ApplicationFinderFactory.get();
                Application       application = finder.getDescription(exe);
                if (finder.isInstalled(application))
                {
                    map.Add(new KeyValuePair <string, string>(application.getName(), exe));
                }
                else
                {
                    map.Add(new KeyValuePair <string, string>(LocalFactory.get(exe).getName(), exe));
                }
            }
            map.Sort(
                delegate(KeyValuePair <string, string> pair1, KeyValuePair <string, string> pair2)
            {
                return(pair1.Key.CompareTo(pair2.Key));
            });

            return(map);
        }
Exemple #8
0
        void ICyberduck.RegisterBookmark(string bookmarkPath)
        {
            Local f        = LocalFactory.get(bookmarkPath);
            Host  bookmark = (Host)HostReaderFactory.get().read(f);

            if (null == bookmark)
            {
                return;
            }
            NewBrowser().Mount(bookmark);
        }
Exemple #9
0
 private void InitPrivateKeys()
 {
     foreach (
         Local key in
         Utils.ConvertFromJavaList <Local>(
             new OpenSSHPrivateKeyConfigurator(
                 LocalFactory.get(PreferencesFactory.get().getProperty("local.user.home"), ".ssh")).list()))
     {
         _keys.Add(key.getAbsolute());
     }
     View.PopulatePrivateKeys(_keys);
 }
Exemple #10
0
        void ICyberduck.RegisterBookmark(string bookmarkPath)
        {
            Local f = LocalFactory.get(bookmarkPath);

            try
            {
                Host bookmark = (Host)HostReaderFactory.get().read(f);
                NewBrowser().Mount(bookmark);
            }
            catch (AccessDeniedException ex)
            {
                Logger.error($"Failure reading bookmark from {f}. {ex.getMessage()}");
            }
        }
Exemple #11
0
 void ICyberduck.QuickConnect(string arg)
 {
     try
     {
         Host h = HostParser.parse(arg);
         h.setCredentials(CredentialsConfiguratorFactory.get(h.getProtocol()).configure(h));
         if (AbstractPath.Type.file == _detector.detect(h.getDefaultPath()))
         {
             Path file = new Path(PathNormalizer.normalize(h.getDefaultPath()), EnumSet.of(AbstractPath.Type.file));
             // wait until transferCollection is loaded
             transfersSemaphore.Wait();
             TransferController.Instance.StartTransfer(new DownloadTransfer(h, file,
                                                                            LocalFactory.get(PreferencesFactory.get().getProperty("queue.download.folder"),
                                                                                             file.getName())));
         }
         else
         {
             foreach (BrowserController b in Browsers)
             {
                 if (b.IsMounted())
                 {
                     if (
                         new HostUrlProvider().get(b.Session.getHost())
                         .Equals(new HostUrlProvider().get(h)))
                     {
                         b.View.BringToFront();
                         if (Path.Type.directory == _detector.detect(h.getDefaultPath()))
                         {
                             b.SetWorkdir(new Path(PathNormalizer.normalize(h.getDefaultPath()), EnumSet.of(AbstractPath.Type.directory)));
                         }
                         return;
                     }
                 }
             }
             NewBrowser().Mount(h);
         }
     }
     catch (HostParserException e)
     {
         Logger.warn(e.getDetail());
     }
 }
Exemple #12
0
        void ICyberduck.RegisterProfile(string profilePath)
        {
            Local    f       = LocalFactory.get(profilePath);
            Protocol profile = (Protocol)ProfileReaderFactory.get().read(f);

            if (null == profile)
            {
                return;
            }
            if (profile.isEnabled())
            {
                ProtocolFactory.get().register(profile);
                Host host = new Host(profile, profile.getDefaultHostname(), profile.getDefaultPort());
                NewBrowser().AddBookmark(host);
                // Register in application support
                Local profiles =
                    LocalFactory.get(SupportDirectoryFinderFactory.get().find(),
                                     PreferencesFactory.get().getProperty("profiles.folder.name"));
                profiles.mkdir();
                f.copy(LocalFactory.get(profiles, f.getName()));
            }
        }
Exemple #13
0
 private void View_ChangedBrowserDownloadPathEvent()
 {
     _host.setDownloadFolder(LocalFactory.get(View.SelectedDownloadFolder));
     ItemChanged();
     Update();
 }
Exemple #14
0
        private void View_OpenDownloadFolderEvent()
        {
            Local folder = new DownloadDirectoryFinder().find(_host);

            ApplicationLauncherFactory.get().open(LocalFactory.get(folder.getAbsolute()));
        }
Exemple #15
0
 private void CommandsAfterLaunch(IList <string> args)
 {
     if (args.Count > 0)
     {
         string arg = args[0];
         Logger.debug("applicationOpenFile:" + arg);
         Local f = LocalFactory.get(arg);
         if (f.exists())
         {
             if ("cyberducklicense".Equals(f.getExtension()))
             {
                 License license = LicenseFactory.get(f);
                 if (license.verify())
                 {
                     f.copy(LocalFactory.get(PreferencesFactory.get().getProperty("application.support.path"),
                                             f.getName()));
                     _bc.InfoBox(license.ToString(),
                                 LocaleFactory.localizedString(
                                     "Thanks for your support! Your contribution helps to further advance development to make Cyberduck even better.",
                                     "License"),
                                 LocaleFactory.localizedString(
                                     "Your registration key has been copied to the Application Support folder.",
                                     "License"),
                                 String.Format("{0}", LocaleFactory.localizedString("Continue", "License")), null, false);
                     foreach (BrowserController controller in new List <BrowserController>(Browsers))
                     {
                         controller.RemoveDonateButton();
                     }
                 }
                 else
                 {
                     _bc.WarningBox(LocaleFactory.localizedString("Not a valid registration key", "License"),
                                    LocaleFactory.localizedString("Not a valid registration key", "License"),
                                    LocaleFactory.localizedString("This registration key does not appear to be valid.",
                                                                  "License"), null,
                                    String.Format("{0}", LocaleFactory.localizedString("Continue", "License")), false,
                                    PreferencesFactory.get().getProperty("website.help") + "/faq", delegate { });
                 }
             }
             else if ("cyberduckprofile".Equals(f.getExtension()))
             {
                 Protocol profile = (Protocol)ProfileReaderFactory.get().read(f);
                 if (null == profile)
                 {
                     return;
                 }
                 if (profile.isEnabled())
                 {
                     ProtocolFactory.register(profile);
                     Host host = new Host(profile, profile.getDefaultHostname(), profile.getDefaultPort());
                     NewBrowser().AddBookmark(host);
                     // Register in application support
                     Local profiles =
                         LocalFactory.get(PreferencesFactory.get().getProperty("application.support.path"),
                                          PreferencesFactory.get().getProperty("profiles.folder.name"));
                     profiles.mkdir();
                     f.copy(LocalFactory.get(profiles, f.getName()));
                 }
             }
             else if ("duck".Equals(f.getExtension()))
             {
                 Host bookmark = (Host)HostReaderFactory.get().read(f);
                 if (null == bookmark)
                 {
                     return;
                 }
                 NewBrowser().Mount(bookmark);
             }
         }
         else
         {
             // it might be an URL
             if (Uri.IsWellFormedUriString(arg, UriKind.Absolute))
             {
                 Host h = HostParser.parse(arg);
                 if (AbstractPath.Type.file == _detector.detect(h.getDefaultPath()))
                 {
                     Path file = new Path(h.getDefaultPath(), EnumSet.of(AbstractPath.Type.file));
                     // wait until transferCollection is loaded
                     transfersSemaphore.Wait();
                     TransferController.Instance.StartTransfer(new DownloadTransfer(h, file,
                                                                                    LocalFactory.get(PreferencesFactory.get().getProperty("queue.download.folder"),
                                                                                                     file.getName())));
                 }
                 else
                 {
                     foreach (BrowserController b in Browsers)
                     {
                         if (b.IsMounted())
                         {
                             if (
                                 new HostUrlProvider().get(b.Session.getHost())
                                 .Equals(new HostUrlProvider().get(h)))
                             {
                                 b.View.BringToFront();
                                 return;
                             }
                         }
                     }
                     NewBrowser().Mount(h);
                 }
             }
         }
     }
 }
Exemple #16
0
 public ch.cyberduck.core.Local find()
 {
     return
         (LocalFactory.get(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                                        PreferencesFactory.get().getProperty("application.datafolder.name"))));
 }
 public ch.cyberduck.core.Local find()
 {
     return(LocalFactory.get(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)));
 }