public static bool ApplicationShouldTerminateAfterDonationPrompt() { Logger.debug("ApplicationShouldTerminateAfterDonationPrompt"); License l = LicenseFactory.find(); if (!l.verify(new DisabledLicenseVerifierCallback())) { string appVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(); String lastversion = PreferencesFactory.get().getProperty("donate.reminder"); if (appVersion.Equals(lastversion)) { // Do not display if same version is installed return(true); } DateTime nextReminder = new DateTime(PreferencesFactory.get().getLong("donate.reminder.date")); // Display prompt every n days nextReminder.AddDays(PreferencesFactory.get().getLong("donate.reminder.interval")); Logger.debug("Next reminder: " + nextReminder); // Display after upgrade if (nextReminder.CompareTo(DateTime.Now) == 1) { // Do not display if shown in the reminder interval return(true); } ObjectFactory.GetInstance <IDonationController>().Show(); } return(true); }
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 { }); } }
public void CanReadValidLicense() { IsValidIfLocalLicenseDoesNotAlreadyExist(); // Assuming test environment can write in one of folders license file may be. using (var path = new TemporaryFile(LicenseManager.GetLicenseFilePath())) { // In test environment there isn't license file/storage then this test must fail. // After this we must discard cached (and empty) license to load the newly created one. Assert.IsNull(LicenseManager.License); Assert.IsFalse(LicenseManager.IsLicenseValid); LicenseManager.Renew(); // Now we prepare a fake license file to check few basics in // LicenseManager class. var contact = ContactFactory.Create <Contact>(); var license = LicenseFactory.Create <License>(contact); license.Features.Add((int)Feature.Example1, 1); LicenseWriter.ToFile(path, license); Assert.IsTrue(LicenseManager.IsLicenseValid); Assert.IsNotNull(LicenseManager.License); Assert.AreEqual(LicenseManager.License.Id, license.Id); Assert.IsTrue(LicenseManager.IsFeatureAvailable(Feature.Example1)); } }
private static License CreateLicenseFromNewContact(Action <Contact> customizeContact = null) { var contact = ContactFactory.Create <Contact>(); if (customizeContact != null) { customizeContact(contact); } return(LicenseFactory.Create <License>(contact)); }
public void ThenTheCorrectNoLicenseIsCreated() { string[] file = { "using BuildAddons.Tasks.License.Licenses;" }; var subject = new LicenseFactory(new Mock <IFileReader>().Object); var result = subject.For(file); Assert.That(result, Is.TypeOf <NoLicense>()); }
public void setup() { ContextMenuStrip rightMenu = new ContextMenuStrip(); ToolStripMenuItem itemUpdate = new ToolStripMenuItem { Text = LocaleFactory.get().localize("Check for Update…", "Main") }; PeriodicUpdateChecker updater = PeriodicUpdateCheckerFactory.get(); itemUpdate.Enabled = updater.hasUpdatePrivileges(); itemUpdate.Click += delegate { updater.check(false); }; ToolStripMenuItem itemDonate = new ToolStripMenuItem { Text = LocaleFactory.get().localize("Donate…", "Main") }; itemDonate.Click += delegate { BrowserLauncherFactory.get().open(PreferencesFactory.get().getProperty("website.donate")); }; ToolStripMenuItem itemKey = new ToolStripMenuItem { Text = LicenseFactory.find().ToString(), Enabled = false }; ToolStripMenuItem itemExit = new ToolStripMenuItem { Text = LocaleFactory.get().localize("Exit", "Localizable") }; itemExit.Click += delegate { MainController.Exit(false); }; rightMenu.Items.AddRange(new ToolStripItem[] { itemUpdate, new ToolStripSeparator(), itemDonate, itemKey, new ToolStripSeparator(), itemExit }); try { _icon.Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath); } catch (ArgumentException) { } _icon.Visible = true; _icon.ContextMenuStrip = rightMenu; _icon.MouseClick += delegate(object sender, MouseEventArgs args) { if (args.Button == MouseButtons.Left) { foreach (BrowserController browser in MainController.Browsers) { browser.View.Activate(); browser.View.BringToFront(); } } }; }
public void ValidForMinorHardwareChanges() { using (var temp = new TemporaryFile()) { var contact = ContactFactory.Create <ContactForSlightlyChangedHardware>(); var license = LicenseFactory.Create <License>(contact); LicenseWriter.ToFile(temp, license); license = LicenseReader.FromFile <LicenseWithSlightlyChangedHardware, IniLicenseTextConverter <LicenseWithSlightlyChangedHardware> >(temp); Assert.IsTrue(license.IsValid()); } }
public void InvalidIfHardwareConfigurationChanged() { using (var temp = new TemporaryFile()) { var contact = ContactFactory.Create <Contact>(); var license = LicenseFactory.Create <License>(contact); LicenseWriter.ToFile(temp, license); license = LicenseReader.FromFile <LicenseWithChangedHardware, IniLicenseTextConverter <LicenseWithChangedHardware> >(temp); Assert.IsFalse(license.IsValid()); } }
public void SelfIssuedLicense() { using (var temp = new TemporaryFile()) { var contact = ContactFactory.Create <Contact>(); var license = LicenseFactory.Create <License>(contact); LicenseWriter.ToFile(temp, license); license = LicenseReader.FromFile(temp); Assert.IsTrue(license.IsValid()); } }
public static void Register() { LicenseFactory.addFactory(core.Factory.NATIVE_PLATFORM, new Factory()); }
public virtual string RegisteredText() { return(LicenseFactory.find().ToString()); }
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); } } } } }
public LicenseTask() { _licenseFactory = new LicenseFactory(new FileReader()); _sourceFileFactory = new SourceFileFactory(new FileReader(), new FileWriter(), _licenseFactory); }
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); } } } }
public SourceFileFactory(IFileReader fileReader, IFileWriter fileWriter, LicenseFactory licenseFactory) { _fileReader = fileReader; _fileWriter = fileWriter; _licenseFactory = licenseFactory; }