Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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()}");
            }
        }
Ejemplo n.º 3
0
 private void CommandsAfterLaunch(ReadOnlyCollection <string> args)
 {
     if (args.Count > 0)
     {
         string filename = args[0];
         Logger.debug("applicationOpenFile:" + filename);
         Local f = LocalFactory.createLocal(filename);
         if (f.exists())
         {
             if ("cyberducklicense".Equals(f.getExtension()))
             {
                 License license = LicenseFactory.create(f);
                 if (license.verify())
                 {
                     f.copy(
                         LocalFactory.createLocal(
                             Preferences.instance().getProperty("application.support.path"), f.getName()));
                     if (DialogResult.OK == _bc.InfoBox(
                             license.ToString(),
                             Locale.localizedString(
                                 "Thanks for your support! Your contribution helps to further advance development to make Cyberduck even better.",
                                 "License"),
                             Locale.localizedString(
                                 "Your donation key has been copied to the Application Support folder.", "License"),
                             String.Format("{0}", Locale.localizedString("Continue", "License")),
                             null, false))
                     {
                         ;
                     }
                 }
                 else
                 {
                     if (DialogResult.OK == _bc.WarningBox(
                             Locale.localizedString("Not a valid donation key", "License"),
                             Locale.localizedString("Not a valid donation key", "License"),
                             Locale.localizedString("This donation key does not appear to be valid.", "License"),
                             null,
                             String.Format("{0}", Locale.localizedString("Continue", "License")),
                             false, Preferences.instance().getProperty("website.help") + "/faq"))
                     {
                         ;
                     }
                 }
             }
             else if ("cyberduckprofile".Equals(f.getExtension()))
             {
                 Protocol profile = (Protocol)ProtocolReaderFactory.instance().read(f);
                 profile.register();
                 Host host = new Host(profile, profile.getDefaultHostname(), profile.getDefaultPort());
                 NewBrowser().AddBookmark(host);
                 // Register in application support
                 Local profiles =
                     LocalFactory.createLocal(Preferences.instance().getProperty("application.support.path"),
                                              "Profiles");
                 profiles.mkdir(true);
                 f.copy(LocalFactory.createLocal(profiles, f.getName()));
             }
             else if ("duck".Equals(f.getExtension()))
             {
                 Host host = (Host)HostReaderFactory.instance().read(f);
                 NewBrowser().Mount(host);
             }
         }
     }
 }
Ejemplo n.º 4
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);
                 }
             }
         }
     }
 }
Ejemplo n.º 5
0
 public static void Register()
 {
     HostReaderFactory.addFactory(ch.cyberduck.core.Factory.NATIVE_PLATFORM, new Factory());
 }