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;
}
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());
}
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.");
}
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;
}
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;
}
Aggregations