Search in sources :

Example 1 with PlistRefOut

use of org.robovm.libimobiledevice.binding.PlistRefOut in project robovm by robovm.

the class LockdowndClient method getValue.

/**
     * Retrieves a preferences plist using an optional domain and/or key name.
     * 
     * @param domain the domain to query on or <code>null</code> for the global 
     *        domain.
     * @param key the key name to request or <code>null</code> to query for all 
     *        keys.
     * @return a plist node representing the result value node.
     */
public NSObject getValue(String domain, String key) throws IOException {
    PlistRefOut plistOut = new PlistRefOut();
    try {
        checkResult(LibIMobileDevice.lockdownd_get_value(getRef(), domain, key, plistOut));
        PlistRef plist = plistOut.getValue();
        return PlistUtil.toJavaPlist(plist);
    } finally {
        plistOut.delete();
    }
}
Also used : PlistRefOut(org.robovm.libimobiledevice.binding.PlistRefOut) PlistRef(org.robovm.libimobiledevice.binding.PlistRef)

Example 2 with PlistRefOut

use of org.robovm.libimobiledevice.binding.PlistRefOut in project robovm by robovm.

the class PlistUtil method toJavaPlist.

public static NSObject toJavaPlist(PlistRef plist) throws IOException {
    PlistRefOut plistOut = new PlistRefOut();
    ByteArrayOut plistBinOut = new ByteArrayOut();
    IntOut lengthOut = new IntOut();
    try {
        LibIMobileDevice.plist_to_bin(plist, plistBinOut, lengthOut);
        LibIMobileDevice.plist_free(plist);
        int length = lengthOut.getValue();
        ByteArray plistBin = plistBinOut.getValue();
        if (length == 0 || plistBin == null) {
            return null;
        }
        byte[] data = new byte[length];
        for (int i = 0; i < length; i++) {
            data[i] = plistBin.get(i);
        }
        return PropertyListParser.parse(data);
    } catch (IOException e) {
        throw e;
    } catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        throw new RuntimeException(e);
    } finally {
        plistOut.delete();
        LibIMobileDevice.delete_ByteArrayOut_value(plistBinOut);
        plistBinOut.delete();
        lengthOut.delete();
    }
}
Also used : PlistRefOut(org.robovm.libimobiledevice.binding.PlistRefOut) ByteArray(org.robovm.libimobiledevice.binding.ByteArray) IntOut(org.robovm.libimobiledevice.binding.IntOut) ByteArrayOut(org.robovm.libimobiledevice.binding.ByteArrayOut) IOException(java.io.IOException) IOException(java.io.IOException)

Example 3 with PlistRefOut

use of org.robovm.libimobiledevice.binding.PlistRefOut in project robovm by robovm.

the class MobileImageMounterClient method lookupImage.

/**
     * Checks if an image of the specified type has already been mounted. This
     * method returns a plist similar to this when an image has been mounted:
     * <pre>
     * &lt;plist version="1.0"&gt;
     *   &lt;dict&gt;
     *     &lt;key&gt;ImageDigest&lt;/key&gt;
     *     &lt;data&gt;rBSGlwMv4yovqGM7sOk44vrE6xI=&lt;/data&gt;
     *     &lt;key&gt;ImagePresent&lt;/key&gt;
     *     &lt;true/&gt;
     *     &lt;key&gt;Status&lt;/key&gt;
     *     &lt;string&gt;Complete&lt;/string&gt;
     *   &lt;/dict&gt;
     * &lt;/plist&gt;
     * </pre>
     * The {@code ImageDigest} value is the SHA-1 digest if the image file.
     * <p>
     * If no image has been mounted {@code ImagePresent=false} and there will be
     * no {@code ImageDigest} in the response.
     * <p>
     * NOTE! It seems like this only returns {@code ImagePresent=true} the first
     * time it is called after an image has been mounted. On subsequent calls
     * it returns {@code ImagePresent=false} even if the image is still mounted.
     * 
     * @param imageType type of the image to look for. If <code>null</code> is 
     *        passed {@code Developer} will be used.
     * @return the result of the lookup.
     */
public NSDictionary lookupImage(String imageType) throws IOException {
    if (imageType == null) {
        imageType = "Developer";
    }
    PlistRefOut plistOut = new PlistRefOut();
    try {
        checkResult(LibIMobileDevice.mobile_image_mounter_lookup_image(getRef(), imageType, plistOut));
        PlistRef plist = plistOut.getValue();
        return (NSDictionary) PlistUtil.toJavaPlist(plist);
    } finally {
        plistOut.delete();
    }
}
Also used : PlistRefOut(org.robovm.libimobiledevice.binding.PlistRefOut) PlistRef(org.robovm.libimobiledevice.binding.PlistRef) NSDictionary(com.dd.plist.NSDictionary)

Example 4 with PlistRefOut

use of org.robovm.libimobiledevice.binding.PlistRefOut in project robovm by robovm.

the class MobileImageMounterClient method mountImage.

/**
     * Mounts an image on the device. After an image has been mounted it will
     * remain mounted until the device is rebooted. Returns an 
     * {@link NSDictionary} with {@code Status=Complete} on success. On error
     * the {@link NSDictionary} will contain {@code Error=ImageMountFailed}.
     * 
     * @param imagePath the path of the image to be mounted. Should be an 
     *        absolute path inside the AFC jail on the device.
     * @param imageSignature the image's signature data.
     * @param imageType type of the image. If <code>null</code> is passed
     *        {@code Developer} will be used.
     * @return the result of the mount.
     */
public NSDictionary mountImage(String imagePath, byte[] imageSignature, String imageType) throws IOException {
    if (imagePath == null) {
        throw new NullPointerException("imagePath");
    }
    if (imageSignature == null) {
        throw new NullPointerException("imageSignature");
    }
    if (imageType == null) {
        imageType = "Developer";
    }
    if (!imagePath.startsWith("/")) {
        imagePath = "/" + imagePath;
    }
    imagePath = PRIVATE_MOUNT_PREFIX + imagePath;
    PlistRefOut plistOut = new PlistRefOut();
    try {
        checkResult(LibIMobileDevice.mobile_image_mounter_mount_image(getRef(), imagePath, imageSignature, (short) imageSignature.length, imageType, plistOut));
        PlistRef plist = plistOut.getValue();
        return (NSDictionary) PlistUtil.toJavaPlist(plist);
    } finally {
        plistOut.delete();
    }
}
Also used : PlistRefOut(org.robovm.libimobiledevice.binding.PlistRefOut) PlistRef(org.robovm.libimobiledevice.binding.PlistRef) NSDictionary(com.dd.plist.NSDictionary)

Example 5 with PlistRefOut

use of org.robovm.libimobiledevice.binding.PlistRefOut in project robovm by robovm.

the class InstallationProxyClient method browse.

/**
     * Lists installed applications of the specified type.
     *
     * @param type the type of applications to list. Either 
     *        {@link ApplicationType#User} or {@link ApplicationType#System}
     *        applications. Pass <code>null</code> to list all.
     * @return an {@link NSArray} of {@link NSDictionary}s holding information
     *         about the installed applications.
     */
public NSArray browse(Options.ApplicationType type) throws IOException {
    PlistRefOut plistOut = new PlistRefOut();
    PlistRef clientOpts = new Options().applicationType(type).toPlistRef();
    try {
        checkResult(LibIMobileDevice.instproxy_browse(getRef(), clientOpts, plistOut));
        PlistRef plist = plistOut.getValue();
        return (NSArray) PlistUtil.toJavaPlist(plist);
    } finally {
        plistOut.delete();
        LibIMobileDevice.plist_free(clientOpts);
    }
}
Also used : PlistRefOut(org.robovm.libimobiledevice.binding.PlistRefOut) PlistRef(org.robovm.libimobiledevice.binding.PlistRef) NSArray(com.dd.plist.NSArray)

Aggregations

PlistRefOut (org.robovm.libimobiledevice.binding.PlistRefOut)5 PlistRef (org.robovm.libimobiledevice.binding.PlistRef)4 NSDictionary (com.dd.plist.NSDictionary)2 NSArray (com.dd.plist.NSArray)1 IOException (java.io.IOException)1 ByteArray (org.robovm.libimobiledevice.binding.ByteArray)1 ByteArrayOut (org.robovm.libimobiledevice.binding.ByteArrayOut)1 IntOut (org.robovm.libimobiledevice.binding.IntOut)1