Search in sources :

Example 1 with NSUInteger

use of org.rococoa.cocoa.foundation.NSUInteger in project cyberduck by iterate-ch.

the class HyperlinkAttributedStringFactory method create.

/**
 * @param value     Existing attributes
 * @param hyperlink URL
 * @return Clickable and underlined string to put into text field.
 */
private static NSAttributedString create(final NSMutableAttributedString value, final String hyperlink) {
    final NSRange range = NSRange.NSMakeRange(new NSUInteger(0), value.length());
    value.beginEditing();
    value.addAttributeInRange(NSMutableAttributedString.LinkAttributeName, hyperlink, range);
    // make the text appear in blue
    value.addAttributeInRange(NSMutableAttributedString.ForegroundColorAttributeName, NSColor.blueColor(), range);
    // system font
    value.addAttributeInRange(NSMutableAttributedString.FontAttributeName, NSFont.systemFontOfSize(NSFont.smallSystemFontSize()), range);
    // next make the text appear with an underline
    value.addAttributeInRange(NSMutableAttributedString.UnderlineStyleAttributeName, NSNumber.numberWithInt(NSMutableAttributedString.SingleUnderlineStyle), range);
    value.endEditing();
    return value;
}
Also used : NSRange(ch.cyberduck.binding.foundation.NSRange) NSUInteger(org.rococoa.cocoa.foundation.NSUInteger)

Example 2 with NSUInteger

use of org.rococoa.cocoa.foundation.NSUInteger in project cyberduck by iterate-ch.

the class ApplicationSupportDirectoryFinder method find.

@Override
public Local find() {
    final NSArray directories = FoundationKitFunctions.library.NSSearchPathForDirectoriesInDomains(FoundationKitFunctions.NSSearchPathDirectory.NSApplicationSupportDirectory, FoundationKitFunctions.NSSearchPathDomainMask.NSUserDomainMask, true);
    final String application = preferences.getProperty("application.name");
    if (directories.count().intValue() == 0) {
        log.error("Failed searching for application support directory");
        return new FinderLocal("~/Library/Application Support", application);
    } else {
        final String directory = directories.objectAtIndex(new NSUInteger(0)).toString();
        if (log.isInfoEnabled()) {
            log.info(String.format("Found application support directory in %s", directory));
        }
        final Local folder = new FinderLocal(directory, application);
        if (log.isDebugEnabled()) {
            log.debug(String.format("Use folder %s for application support directory", folder));
        }
        return folder;
    }
}
Also used : FinderLocal(ch.cyberduck.core.local.FinderLocal) NSArray(ch.cyberduck.binding.foundation.NSArray) FinderLocal(ch.cyberduck.core.local.FinderLocal) Local(ch.cyberduck.core.Local) NSUInteger(org.rococoa.cocoa.foundation.NSUInteger)

Example 3 with NSUInteger

use of org.rococoa.cocoa.foundation.NSUInteger in project cyberduck by iterate-ch.

the class LibraryLogDirectoryFinder method find.

@Override
public Local find() {
    final NSArray directories = FoundationKitFunctions.library.NSSearchPathForDirectoriesInDomains(FoundationKitFunctions.NSSearchPathDirectory.NSLibraryDirectory, FoundationKitFunctions.NSSearchPathDomainMask.NSUserDomainMask, true);
    final String application = preferences.getProperty("application.name");
    if (directories.count().intValue() == 0) {
        log.error("Failed searching for library directory");
        return new FinderLocal("~/Library/Logs", application);
    } else {
        final String directory = directories.objectAtIndex(new NSUInteger(0)).toString();
        if (log.isInfoEnabled()) {
            log.info(String.format("Found library directory in %s", directory));
        }
        final Local folder = new FinderLocal(new FinderLocal(directory, "Logs"), application);
        if (log.isDebugEnabled()) {
            log.debug(String.format("Use folder %s for log directory", folder));
        }
        return folder;
    }
}
Also used : FinderLocal(ch.cyberduck.core.local.FinderLocal) NSArray(ch.cyberduck.binding.foundation.NSArray) FinderLocal(ch.cyberduck.core.local.FinderLocal) Local(ch.cyberduck.core.Local) NSUInteger(org.rococoa.cocoa.foundation.NSUInteger)

Example 4 with NSUInteger

use of org.rococoa.cocoa.foundation.NSUInteger in project cyberduck by iterate-ch.

the class KeychainCertificateStore method toDEREncodedCertificates.

public static NSArray toDEREncodedCertificates(final List<X509Certificate> certificates) {
    // Prepare the certificate chain
    try {
        final Object[] encoded = new DEREncoder().encode(certificates);
    } catch (CertificateException e) {
        log.error(String.format("Failure %s DER encoding certificates %s", e, certificates));
        return NSArray.array();
    }
    final NSMutableArray certs = NSMutableArray.arrayWithCapacity(new NSUInteger(certificates.size()));
    for (X509Certificate certificate : certificates) {
        try {
            final SecCertificateRef certificateRef = SecurityFunctions.library.SecCertificateCreateWithData(null, NSData.dataWithBase64EncodedString(Base64.encodeBase64String(certificate.getEncoded())));
            if (null == certificateRef) {
                log.error(String.format("Error creating converting from ASN.1 DER encoded certificate %s", certificate));
                continue;
            }
            certs.addObject(certificateRef);
        } catch (CertificateEncodingException e) {
            log.error(String.format("Failure %s retrieving encoded  certificate", e));
        }
    }
    return certs;
}
Also used : DEREncoder(ch.cyberduck.core.ssl.DEREncoder) NSMutableArray(ch.cyberduck.binding.foundation.NSMutableArray) CertificateException(java.security.cert.CertificateException) CertificateEncodingException(java.security.cert.CertificateEncodingException) NSUInteger(org.rococoa.cocoa.foundation.NSUInteger) X509Certificate(java.security.cert.X509Certificate) SecCertificateRef(ch.cyberduck.core.keychain.SecCertificateRef)

Example 5 with NSUInteger

use of org.rococoa.cocoa.foundation.NSUInteger in project cyberduck by iterate-ch.

the class MainController method serviceUploadFileUrl_.

/**
 * NSService implementation
 */
@Action
public void serviceUploadFileUrl_(final NSPasteboard pboard, final String userData) {
    if (log.isDebugEnabled()) {
        log.debug(String.format("serviceUploadFileUrl_: with user data %s", userData));
    }
    if (pboard.availableTypeFromArray(NSArray.arrayWithObject(NSPasteboard.FilenamesPboardType)) != null) {
        NSObject o = pboard.propertyListForType(NSPasteboard.FilenamesPboardType);
        if (o != null) {
            if (o.isKindOfClass(NSArray.CLASS)) {
                final NSArray elements = Rococoa.cast(o, NSArray.class);
                List<Local> files = new ArrayList<Local>();
                for (int i = 0; i < elements.count().intValue(); i++) {
                    files.add(LocalFactory.get(elements.objectAtIndex(new NSUInteger(i)).toString()));
                }
                this.upload(files);
            }
        }
    }
}
Also used : NSObject(ch.cyberduck.binding.foundation.NSObject) NSArray(ch.cyberduck.binding.foundation.NSArray) ArrayList(java.util.ArrayList) NSUInteger(org.rococoa.cocoa.foundation.NSUInteger) AbstractBackgroundAction(ch.cyberduck.core.threading.AbstractBackgroundAction) Action(ch.cyberduck.binding.Action)

Aggregations

NSUInteger (org.rococoa.cocoa.foundation.NSUInteger)33 Action (ch.cyberduck.binding.Action)12 NSIndexSet (ch.cyberduck.binding.foundation.NSIndexSet)12 WindowMainAction (ch.cyberduck.core.threading.WindowMainAction)11 ArrayList (java.util.ArrayList)10 NSArray (ch.cyberduck.binding.foundation.NSArray)9 BackgroundAction (ch.cyberduck.core.threading.BackgroundAction)9 DefaultMainAction (ch.cyberduck.core.threading.DefaultMainAction)9 Transfer (ch.cyberduck.core.transfer.Transfer)9 NSPoint (org.rococoa.cocoa.foundation.NSPoint)9 NSObject (ch.cyberduck.binding.foundation.NSObject)8 DownloadTransfer (ch.cyberduck.core.transfer.DownloadTransfer)7 ControllerMainAction (ch.cyberduck.core.threading.ControllerMainAction)6 TransferBackgroundAction (ch.cyberduck.core.threading.TransferBackgroundAction)5 TransferCollectionBackgroundAction (ch.cyberduck.core.threading.TransferCollectionBackgroundAction)5 WorkerBackgroundAction (ch.cyberduck.core.threading.WorkerBackgroundAction)5 TransferItem (ch.cyberduck.core.transfer.TransferItem)5 Local (ch.cyberduck.core.Local)3 Path (ch.cyberduck.core.Path)3 BrowserTransferBackgroundAction (ch.cyberduck.core.threading.BrowserTransferBackgroundAction)3