Search in sources :

Example 1 with DisabledLicenseVerifierCallback

use of ch.cyberduck.core.aquaticprime.DisabledLicenseVerifierCallback in project cyberduck by iterate-ch.

the class MainController method applicationShouldTerminateAfterDonationPrompt.

public NSUInteger applicationShouldTerminateAfterDonationPrompt(final NSApplication app) {
    if (log.isDebugEnabled()) {
        log.debug("applicationShouldTerminateAfterDonationPrompt");
    }
    if (!displayDonationPrompt) {
        // Already displayed
        return NSApplication.NSTerminateNow;
    }
    final License key = LicenseFactory.find();
    if (!key.verify(new DisabledLicenseVerifierCallback())) {
        final String lastversion = preferences.getProperty("donate.reminder");
        if (NSBundle.mainBundle().infoDictionary().objectForKey("CFBundleShortVersionString").toString().equals(lastversion)) {
            // Do not display if same version is installed
            return NSApplication.NSTerminateNow;
        }
        // Display after upgrade
        final Calendar nextreminder = Calendar.getInstance();
        nextreminder.setTimeInMillis(preferences.getLong("donate.reminder.date"));
        // Display prompt every n days
        nextreminder.add(Calendar.DAY_OF_YEAR, preferences.getInteger("donate.reminder.interval"));
        if (log.isDebugEnabled()) {
            log.debug(String.format("Next reminder %s", nextreminder.getTime().toString()));
        }
        if (nextreminder.getTime().after(new Date(System.currentTimeMillis()))) {
            // Do not display if shown in the reminder interval
            return NSApplication.NSTerminateNow;
        }
        // Make sure prompt is not loaded twice upon next quit event
        displayDonationPrompt = false;
        donationController = new DonateAlertController(app);
        donationController.setCallback(donationController);
        donationController.loadBundle();
        donationController.window().center();
        donationController.window().makeKeyAndOrderFront(null);
        // Delay application termination. Dismissing the donation dialog will reply to quit.
        return NSApplication.NSTerminateLater;
    }
    return NSApplication.NSTerminateNow;
}
Also used : Calendar(java.util.Calendar) License(ch.cyberduck.core.aquaticprime.License) DisabledLicenseVerifierCallback(ch.cyberduck.core.aquaticprime.DisabledLicenseVerifierCallback) NSAttributedString(ch.cyberduck.binding.foundation.NSAttributedString) Date(java.util.Date)

Example 2 with DisabledLicenseVerifierCallback

use of ch.cyberduck.core.aquaticprime.DisabledLicenseVerifierCallback in project cyberduck by iterate-ch.

the class TerminalHelpPrinter method print.

public static void print(final Options options, final HelpFormatter formatter) {
    formatter.setSyntaxPrefix("Usage:");
    final Preferences preferences = PreferencesFactory.get();
    final StringBuilder builder = new StringBuilder().append("Default protocols").append(StringUtils.LF);
    final ProtocolFactory protocols = ProtocolFactory.get();
    for (Protocol p : protocols.find(new DefaultProtocolPredicate(EnumSet.of(Protocol.Type.ftp, Protocol.Type.sftp, Protocol.Type.dav)))) {
        append(p, builder);
    }
    builder.append(StringUtils.LF);
    for (Protocol p : protocols.find(new DefaultProtocolPredicate(EnumSet.of(Protocol.Type.s3, Protocol.Type.swift, Protocol.Type.azure, Protocol.Type.b2, Protocol.Type.googlestorage)))) {
        append(p, builder);
    }
    builder.append(StringUtils.LF);
    for (Protocol p : protocols.find(new DefaultProtocolPredicate(EnumSet.of(Protocol.Type.dropbox, Protocol.Type.onedrive, Protocol.Type.googledrive, Protocol.Type.nextcloud, Protocol.Type.owncloud, Protocol.Type.dracoon, Protocol.Type.brick)))) {
        append(p, builder);
    }
    builder.append("Local Disk");
    builder.append(StringUtils.LF);
    for (Protocol p : protocols.find(new DefaultProtocolPredicate(EnumSet.of(Protocol.Type.file)))) {
        append(p, builder);
    }
    builder.append(StringUtils.LF);
    builder.append(String.format("Third party connection profiles. Install additional connection profiles in %s", LocalFactory.get(SupportDirectoryFinderFactory.get().find(), PreferencesFactory.get().getProperty("profiles.folder.name")).getAbbreviatedPath()));
    builder.append(StringUtils.LF);
    for (Protocol p : protocols.find(new ProfileProtocolPredicate())) {
        append(p, builder);
    }
    final StringBuilder header = new StringBuilder(StringUtils.LF).append("\t").append("URLs must be fully qualified. Paths can either denote " + "a remote file (ftps://user@example.net/resource) or folder (ftps://user@example.net/directory/) " + "with a trailing slash. You can reference files relative to your home directory with /~ (ftps://user@example.net/~/).").append(StringUtils.LF).append(builder).append(StringUtils.LF).append(StringUtils.LF);
    final StringBuilder footer = new StringBuilder(StringUtils.LF);
    footer.append(String.format("Cyberduck is libre software licenced under the GPL. For general help about using Cyberduck, please refer to %s and the wiki at %s. For bug reports or feature requests open a ticket at %s.", preferences.getProperty("website.cli"), preferences.getProperty("website.help"), MessageFormat.format(preferences.getProperty("website.bug"), preferences.getProperty("application.version"))));
    final License l = LicenseFactory.find();
    footer.append(StringUtils.LF);
    if (l.verify(new DisabledLicenseVerifierCallback())) {
        footer.append(l.toString());
    } else {
        footer.append("Not registered. Purchase a donation key to support the development of this software.");
    }
    formatter.printHelp("duck [options...]", header.toString(), options, footer.toString());
}
Also used : ProtocolFactory(ch.cyberduck.core.ProtocolFactory) DefaultProtocolPredicate(ch.cyberduck.core.DefaultProtocolPredicate) ProfileProtocolPredicate(ch.cyberduck.core.ProfileProtocolPredicate) License(ch.cyberduck.core.aquaticprime.License) DisabledLicenseVerifierCallback(ch.cyberduck.core.aquaticprime.DisabledLicenseVerifierCallback) Preferences(ch.cyberduck.core.preferences.Preferences) Protocol(ch.cyberduck.core.Protocol)

Example 3 with DisabledLicenseVerifierCallback

use of ch.cyberduck.core.aquaticprime.DisabledLicenseVerifierCallback in project cyberduck by iterate-ch.

the class TerminalVersionPrinter method print.

public static void print(final Preferences preferences) {
    final Console console = new Console();
    final License l = LicenseFactory.find();
    console.printf("%s %s (%s). %s%n", preferences.getProperty("application.name"), preferences.getProperty("application.version"), preferences.getProperty("application.revision"), l.verify(new DisabledLicenseVerifierCallback()) ? l.toString() : "Not registered. Purchase a donation key to support the development of this software.");
}
Also used : License(ch.cyberduck.core.aquaticprime.License) DisabledLicenseVerifierCallback(ch.cyberduck.core.aquaticprime.DisabledLicenseVerifierCallback)

Example 4 with DisabledLicenseVerifierCallback

use of ch.cyberduck.core.aquaticprime.DisabledLicenseVerifierCallback in project cyberduck by iterate-ch.

the class MainController method application_openFile.

@Override
public boolean application_openFile(final NSApplication app, final String filename) {
    if (log.isDebugEnabled()) {
        log.debug(String.format("Open file %s", filename));
    }
    final Local f = LocalFactory.get(filename);
    if (f.exists()) {
        if ("duck".equals(f.getExtension())) {
            final Host bookmark;
            try {
                newDocument().mount(HostReaderFactory.get().read(f));
                return true;
            } catch (AccessDeniedException e) {
                log.error(String.format("Failure reading bookmark from %s. %s", f, e.getMessage()));
                return false;
            }
        } else if ("cyberducklicense".equals(f.getExtension())) {
            final License l = LicenseFactory.get(f);
            if (l.verify(new DisabledLicenseVerifierCallback())) {
                try {
                    f.copy(LocalFactory.get(SupportDirectoryFinderFactory.get().find(), f.getName()));
                    final NSAlert alert = NSAlert.alert(l.toString(), LocaleFactory.localizedString("Thanks for your support! Your contribution helps to further advance development to make Cyberduck even better.", "License") + "\n\n" + LocaleFactory.localizedString("Your donation key has been copied to the Application Support folder.", "License"), // default
                    LocaleFactory.localizedString("Continue", "License"), // other
                    null, null);
                    alert.setAlertStyle(NSAlert.NSInformationalAlertStyle);
                    if (new AlertSheetReturnCodeMapper().getOption(alert.runModal()) == SheetCallback.DEFAULT_OPTION) {
                        for (BrowserController c : MainController.getBrowsers()) {
                            c.removeDonateWindowTitle();
                        }
                        this.updateLicenseMenu();
                    }
                } catch (AccessDeniedException e) {
                    log.error(e.getMessage());
                    return false;
                }
            } else {
                final NSAlert alert = NSAlert.alert(LocaleFactory.localizedString("Not a valid registration key", "License"), LocaleFactory.localizedString("This donation key does not appear to be valid.", "License"), // default
                LocaleFactory.localizedString("Continue", "License"), // other
                null, null);
                alert.setAlertStyle(NSAlert.NSWarningAlertStyle);
                alert.setShowsHelp(true);
                alert.setDelegate(new ProxyController() {

                    @Action
                    public boolean alertShowHelp(NSAlert alert) {
                        BrowserLauncherFactory.get().open(ProviderHelpServiceFactory.get().help());
                        return true;
                    }
                }.id());
                alert.runModal();
            }
            return true;
        } else if ("cyberduckprofile".equals(f.getExtension())) {
            try {
                final Profile profile = ProfileReaderFactory.get().read(f);
                if (profile.isEnabled()) {
                    if (log.isDebugEnabled()) {
                        log.debug(String.format("Register profile %s", profile));
                    }
                    final ProtocolFactory protocols = ProtocolFactory.get();
                    protocols.register(profile);
                    final Host host = new Host(profile, profile.getDefaultHostname(), profile.getDefaultPort());
                    newDocument().addBookmark(host);
                    // Register in application support
                    final Local profiles = LocalFactory.get(SupportDirectoryFinderFactory.get().find(), preferences.getProperty("profiles.folder.name"));
                    if (!profiles.exists()) {
                        new DefaultLocalDirectoryFeature().mkdir(profiles);
                    }
                    f.copy(LocalFactory.get(profiles, f.getName()));
                }
            } catch (AccessDeniedException e) {
                log.error(String.format("Failure reading profile from %s. %s", f, e));
                return false;
            }
        } else {
            // Upload file
            this.background(new AbstractBackgroundAction<Void>() {

                @Override
                public Void run() {
                    // Wait until bookmarks are loaded
                    Uninterruptibles.awaitUninterruptibly(bookmarksSemaphore);
                    return null;
                }

                @Override
                public void cleanup() {
                    upload(f);
                }

                @Override
                public String getActivity() {
                    return "Open File";
                }
            });
            return true;
        }
    }
    return false;
}
Also used : AccessDeniedException(ch.cyberduck.core.exception.AccessDeniedException) AbstractBackgroundAction(ch.cyberduck.core.threading.AbstractBackgroundAction) Action(ch.cyberduck.binding.Action) License(ch.cyberduck.core.aquaticprime.License) DisabledLicenseVerifierCallback(ch.cyberduck.core.aquaticprime.DisabledLicenseVerifierCallback) NSAttributedString(ch.cyberduck.binding.foundation.NSAttributedString) DefaultLocalDirectoryFeature(ch.cyberduck.core.local.DefaultLocalDirectoryFeature) NSAlert(ch.cyberduck.binding.application.NSAlert) ProxyController(ch.cyberduck.binding.ProxyController) AlertSheetReturnCodeMapper(ch.cyberduck.binding.application.AlertSheetReturnCodeMapper)

Example 5 with DisabledLicenseVerifierCallback

use of ch.cyberduck.core.aquaticprime.DisabledLicenseVerifierCallback in project cyberduck by iterate-ch.

the class QloudsonicProxyProvider method headers.

@Override
public List<Header> headers() throws AccessDeniedException, MissingReceiptException, InvalidReceiptException {
    final List<License> receipts = factory.open();
    if (receipts.isEmpty()) {
        throw new MissingReceiptException();
    }
    final List<Header> headers = new ArrayList<Header>();
    for (License receipt : receipts) {
        if (log.isInfoEnabled()) {
            log.info(String.format("Using voucher %s", receipt));
        }
        if (!receipt.verify(new DisabledLicenseVerifierCallback())) {
            throw new InvalidReceiptException();
        }
        headers.add(new Header(Headers.HEADER_VOUCHER, receipt.getValue("Voucher")));
    }
    return headers;
}
Also used : Header(ch.cyberduck.core.Header) License(ch.cyberduck.core.aquaticprime.License) ArrayList(java.util.ArrayList) DisabledLicenseVerifierCallback(ch.cyberduck.core.aquaticprime.DisabledLicenseVerifierCallback)

Aggregations

DisabledLicenseVerifierCallback (ch.cyberduck.core.aquaticprime.DisabledLicenseVerifierCallback)5 License (ch.cyberduck.core.aquaticprime.License)5 NSAttributedString (ch.cyberduck.binding.foundation.NSAttributedString)2 Action (ch.cyberduck.binding.Action)1 ProxyController (ch.cyberduck.binding.ProxyController)1 AlertSheetReturnCodeMapper (ch.cyberduck.binding.application.AlertSheetReturnCodeMapper)1 NSAlert (ch.cyberduck.binding.application.NSAlert)1 DefaultProtocolPredicate (ch.cyberduck.core.DefaultProtocolPredicate)1 Header (ch.cyberduck.core.Header)1 ProfileProtocolPredicate (ch.cyberduck.core.ProfileProtocolPredicate)1 Protocol (ch.cyberduck.core.Protocol)1 ProtocolFactory (ch.cyberduck.core.ProtocolFactory)1 AccessDeniedException (ch.cyberduck.core.exception.AccessDeniedException)1 DefaultLocalDirectoryFeature (ch.cyberduck.core.local.DefaultLocalDirectoryFeature)1 Preferences (ch.cyberduck.core.preferences.Preferences)1 AbstractBackgroundAction (ch.cyberduck.core.threading.AbstractBackgroundAction)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1