Search in sources :

Example 1 with IOs

use of com.twinsoft.convertigo.beans.mobileplatforms.IOs in project convertigo by convertigo.

the class LaunchBuild method perform.

public static String perform(MobileResourceHelper mobileResourceHelper, HttpServletRequest request) throws Exception {
    MobilePlatform mobilePlatform = mobileResourceHelper.mobilePlatform;
    MobileApplication mobileApplication = mobileResourceHelper.mobileApplication;
    String finalApplicationName = mobileApplication.getComputedApplicationName();
    File mobileArchiveFile = mobileResourceHelper.makeZipPackage();
    // Login to the mobile builder platform
    String mobileBuilderPlatformURL = EnginePropertiesManager.getProperty(PropertyName.MOBILE_BUILDER_PLATFORM_URL);
    Map<String, String[]> params = new HashMap<String, String[]>();
    params.put("application", new String[] { finalApplicationName });
    params.put("platformName", new String[] { mobilePlatform.getName() });
    params.put("platformType", new String[] { mobilePlatform.getType() });
    params.put("auth_token", new String[] { mobileApplication.getComputedAuthenticationToken() });
    // revision and endpoint params
    params.put("revision", new String[] { mobileResourceHelper.getRevision() });
    params.put("endpoint", new String[] { mobileApplication.getComputedEndpoint(request) });
    params.put("appid", new String[] { mobileApplication.getComputedApplicationId() });
    // iOS
    if (mobilePlatform instanceof IOs) {
        IOs ios = (IOs) mobilePlatform;
        String pw, title = ios.getiOSCertificateTitle();
        if (!title.equals("")) {
            pw = ios.getiOSCertificatePw();
        } else {
            title = EnginePropertiesManager.getProperty(PropertyName.MOBILE_BUILDER_IOS_CERTIFICATE_TITLE);
            pw = EnginePropertiesManager.getProperty(PropertyName.MOBILE_BUILDER_IOS_CERTIFICATE_PW);
        }
        params.put("iOSCertificateTitle", new String[] { title });
        params.put("iOSCertificatePw", new String[] { pw });
    }
    // Android
    if (mobilePlatform instanceof Android) {
        Android android = (Android) mobilePlatform;
        String certificatePw, keystorePw, title = android.getAndroidCertificateTitle();
        if (!title.equals("")) {
            certificatePw = android.getAndroidCertificatePw();
            keystorePw = android.getAndroidKeystorePw();
        } else {
            title = EnginePropertiesManager.getProperty(PropertyName.MOBILE_BUILDER_ANDROID_CERTIFICATE_TITLE);
            certificatePw = EnginePropertiesManager.getProperty(PropertyName.MOBILE_BUILDER_ANDROID_CERTIFICATE_PW);
            keystorePw = EnginePropertiesManager.getProperty(PropertyName.MOBILE_BUILDER_ANDROID_KEYSTORE_PW);
        }
        params.put("androidCertificateTitle", new String[] { title });
        params.put("androidCertificatePw", new String[] { certificatePw });
        params.put("androidKeystorePw", new String[] { keystorePw });
    }
    // Windows Phone
    if (mobilePlatform instanceof WindowsPhoneKeyProvider) {
        WindowsPhoneKeyProvider windowsPhone = (WindowsPhoneKeyProvider) mobilePlatform;
        String title = windowsPhone.getWinphonePublisherIdTitle();
        if (title.equals("")) {
            title = EnginePropertiesManager.getProperty(PropertyName.MOBILE_BUILDER_WINDOWSPHONE_PUBLISHER_ID_TITLE);
        }
        params.put("winphonePublisherIdTitle", new String[] { title });
    }
    // Launch the mobile build
    URL url = new URL(mobileBuilderPlatformURL + "/build?" + URLUtils.mapToQuery(params));
    HostConfiguration hostConfiguration = new HostConfiguration();
    hostConfiguration.setHost(url.getHost());
    HttpState httpState = new HttpState();
    Engine.theApp.proxyManager.setProxy(hostConfiguration, httpState, url);
    PostMethod method = new PostMethod(url.toString());
    FileRequestEntity entity = new FileRequestEntity(mobileArchiveFile, null);
    method.setRequestEntity(entity);
    int methodStatusCode = Engine.theApp.httpClient.executeMethod(hostConfiguration, method, httpState);
    String sResult = IOUtils.toString(method.getResponseBodyAsStream(), "UTF-8");
    if (methodStatusCode != HttpStatus.SC_OK) {
        throw new ServiceException("Unable to build application '" + finalApplicationName + "'.\n" + sResult);
    }
    return sResult;
}
Also used : HashMap(java.util.HashMap) PostMethod(org.apache.commons.httpclient.methods.PostMethod) HostConfiguration(org.apache.commons.httpclient.HostConfiguration) HttpState(org.apache.commons.httpclient.HttpState) IOs(com.twinsoft.convertigo.beans.mobileplatforms.IOs) URL(java.net.URL) Android(com.twinsoft.convertigo.beans.mobileplatforms.Android) FileRequestEntity(org.apache.commons.httpclient.methods.FileRequestEntity) MobilePlatform(com.twinsoft.convertigo.beans.core.MobilePlatform) ServiceException(com.twinsoft.convertigo.engine.admin.services.ServiceException) MobileApplication(com.twinsoft.convertigo.beans.core.MobileApplication) File(java.io.File) WindowsPhoneKeyProvider(com.twinsoft.convertigo.beans.mobileplatforms.WindowsPhoneKeyProvider)

Example 2 with IOs

use of com.twinsoft.convertigo.beans.mobileplatforms.IOs in project convertigo by convertigo.

the class BuildLocallyEndingDialog method createButtonsForButtonBar.

/**
 * Create contents of the button bar.
 * @param parent
 */
@Override
protected void createButtonsForButtonBar(Composite parent) {
    Button button = createButton(parent, IDialogConstants.OK_ID, "OK", true);
    button.setEnabled(true);
    if (mobilePlatform instanceof IOs && exitValue == 0) {
        Button openXcode = createButton(parent, IDialogConstants.OPEN_ID, "Open Xcode", true);
        openXcode.setEnabled(true);
        openXcode.addSelectionListener(new SelectionListener() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                try {
                    if (applicationBuilt.exists()) {
                        new ProcessBuilder("open", applicationBuilt.getCanonicalPath()).start();
                    }
                } catch (IOException e1) {
                    Engine.logEngine.error("Error when trying to open the xcode project:\n" + e1.getMessage(), e1);
                } finally {
                    close();
                }
            }

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
            }
        });
    }
}
Also used : Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IOException(java.io.IOException) IOs(com.twinsoft.convertigo.beans.mobileplatforms.IOs) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 3 with IOs

use of com.twinsoft.convertigo.beans.mobileplatforms.IOs in project convertigo by convertigo.

the class Migration7_0_0 method migrate.

public static Element migrate(Document document, Element projectNode) throws EngineException {
    try {
        NodeList mobileDevicesNodeList = XMLUtils.findElements(projectNode, "/mobiledevice");
        if (mobileDevicesNodeList != null) {
            MobileApplication mobileApplication = new MobileApplication();
            Element mobileApplicationElement = mobileApplication.toXml(document);
            projectNode.appendChild(mobileApplicationElement);
            Node[] mobileDeviceNodes = XMLUtils.toNodeArray(mobileDevicesNodeList);
            boolean hasAndroid = false;
            boolean hasIOs = false;
            for (Node mobileDeviceNode : mobileDeviceNodes) {
                Element mobileDevice = (Element) mobileDeviceNode;
                String classname = mobileDevice.getAttribute("classname");
                if (classname == null) {
                // may never arrived
                } else if (classname.equals("com.twinsoft.convertigo.beans.mobiledevices.Android")) {
                    hasAndroid = true;
                } else if (classname.startsWith("com.twinsoft.convertigo.beans.mobiledevices.IP")) {
                    hasIOs = true;
                }
                projectNode.removeChild(mobileDevice);
            }
            if (hasAndroid) {
                mobileApplicationElement.appendChild(new Android().toXml(document));
            }
            if (hasIOs) {
                mobileApplicationElement.appendChild(new IOs().toXml(document));
            }
            if (hasAndroid && hasIOs) {
                mobileApplicationElement.appendChild(new WindowsPhone8().toXml(document));
                mobileApplicationElement.appendChild(new Windows().toXml(document));
            }
            String projectName = "" + XMLUtils.findPropertyValue(projectNode, "name");
            File mobileFolder = new File(Engine.projectDir(projectName) + "/DisplayObjects/mobile");
            if (mobileFolder.exists()) {
                FileUtils.write(new File(mobileFolder, "mobile_project_migrated.txt"), "Your mobile project has been migrated.\n" + "Now, we make per platform configuration and resources.\n" + "You may customize your config.xml (the existing one will never used) and dispatch your existing specific resources per platform (see the 'platforms' folder).\n" + "You can delete this file after reading it.", "UTF-8");
            }
        }
    } catch (Exception e) {
        throw new EngineException("[Migration 7.0.0] Unable to migrate project", e);
    }
    return projectNode;
}
Also used : WindowsPhone8(com.twinsoft.convertigo.beans.mobileplatforms.WindowsPhone8) NodeList(org.w3c.dom.NodeList) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) EngineException(com.twinsoft.convertigo.engine.EngineException) Windows(com.twinsoft.convertigo.beans.mobileplatforms.Windows) IOs(com.twinsoft.convertigo.beans.mobileplatforms.IOs) EngineException(com.twinsoft.convertigo.engine.EngineException) IOException(java.io.IOException) Android(com.twinsoft.convertigo.beans.mobileplatforms.Android) MobileApplication(com.twinsoft.convertigo.beans.core.MobileApplication) File(java.io.File)

Example 4 with IOs

use of com.twinsoft.convertigo.beans.mobileplatforms.IOs in project convertigo by convertigo.

the class BuildLocally method getAbsolutePathOfBuiltFile.

/**
 * Return the absolute path of built application file
 * @param mobilePlatform
 * @param buildMode
 * @return
 */
protected File getAbsolutePathOfBuiltFile(MobilePlatform mobilePlatform, String buildMode) {
    String cordovaPlatform = mobilePlatform.getCordovaPlatform();
    String builtPath = File.separator + "platforms" + File.separator + cordovaPlatform + File.separator;
    String buildMd = buildMode.equals("debug") ? "Debug" : "Release";
    String extension = "";
    File f = new File(getCordovaDir(), builtPath);
    if (f.exists()) {
        // Android
        if (mobilePlatform instanceof Android) {
            builtPath = builtPath + "ant-build" + File.separator;
            File f2 = new File(getCordovaDir(), builtPath);
            if (!f2.exists()) {
                builtPath = File.separator + "platforms" + File.separator + cordovaPlatform + File.separator + "build" + File.separator + "outputs" + File.separator + "apk" + File.separator;
            }
            extension = "apk";
        // iOS
        } else if (mobilePlatform instanceof IOs) {
            extension = "xcodeproj";
        // Windows Phone 8
        } else if (mobilePlatform instanceof WindowsPhone8) {
            builtPath = builtPath + "Bin" + File.separator + buildMd + File.separator;
            extension = "xap";
        // Windows 8
        } else if (mobilePlatform instanceof Windows) {
        // TODO : Handle Windows 8
        } else {
            return null;
        }
    }
    f = new File(getCordovaDir(), builtPath);
    if (f.exists()) {
        String[] filesNames = f.list();
        int i = filesNames.length - 1;
        boolean find = false;
        while (i > 0 && !find && !extension.isEmpty()) {
            String fileName = filesNames[i];
            if (fileName.endsWith(extension)) {
                builtPath += fileName;
                find = true;
            }
            i--;
        }
    } else {
        builtPath = File.separator + "platforms" + File.separator + cordovaPlatform + File.separator;
    }
    return new File(getCordovaDir(), builtPath);
}
Also used : WindowsPhone8(com.twinsoft.convertigo.beans.mobileplatforms.WindowsPhone8) Windows(com.twinsoft.convertigo.beans.mobileplatforms.Windows) IOs(com.twinsoft.convertigo.beans.mobileplatforms.IOs) File(java.io.File) Android(com.twinsoft.convertigo.beans.mobileplatforms.Android)

Example 5 with IOs

use of com.twinsoft.convertigo.beans.mobileplatforms.IOs in project convertigo by convertigo.

the class BuildLocally method configureSignIOS.

public void configureSignIOS(File provisioningProfile, String signId) throws Exception {
    if (mobilePlatform instanceof IOs || !Engine.isMac()) {
        return;
    }
    String line;
    String uuid = null;
    try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(provisioningProfile)))) {
        while ((line = br.readLine()) != null) {
            if (line.contains("UUID")) {
                line = br.readLine();
                Matcher m = Pattern.compile("[-A-F0-9]{36}", Pattern.CASE_INSENSITIVE).matcher(line);
                if (m.find()) {
                    uuid = m.group();
                    break;
                } else {
                    throw new EngineException("Cannot match UUID from " + provisioningProfile);
                }
            }
        }
    }
    if (uuid == null) {
        throw new EngineException("No UUID found in " + provisioningProfile);
    }
    File dir = new File(System.getProperty("user.home"), "Library/MobileDevice/Provisioning Profiles");
    dir.mkdirs();
    FileUtils.copyFile(provisioningProfile, new File(dir, uuid + ".mobileprovision"));
    iosProvisioningProfileUUID = uuid;
    iosSignIdentity = signId;
}
Also used : InputStreamReader(java.io.InputStreamReader) Matcher(java.util.regex.Matcher) BufferedReader(java.io.BufferedReader) EngineException(com.twinsoft.convertigo.engine.EngineException) IOs(com.twinsoft.convertigo.beans.mobileplatforms.IOs) File(java.io.File) FileInputStream(java.io.FileInputStream)

Aggregations

IOs (com.twinsoft.convertigo.beans.mobileplatforms.IOs)10 Android (com.twinsoft.convertigo.beans.mobileplatforms.Android)6 File (java.io.File)6 MobileApplication (com.twinsoft.convertigo.beans.core.MobileApplication)5 MobilePlatform (com.twinsoft.convertigo.beans.core.MobilePlatform)4 WindowsPhone8 (com.twinsoft.convertigo.beans.mobileplatforms.WindowsPhone8)4 IOException (java.io.IOException)4 Windows (com.twinsoft.convertigo.beans.mobileplatforms.Windows)3 EngineException (com.twinsoft.convertigo.engine.EngineException)3 Matcher (java.util.regex.Matcher)3 Element (org.w3c.dom.Element)3 Node (org.w3c.dom.Node)3 TwsCachedXPathAPI (com.twinsoft.convertigo.engine.util.TwsCachedXPathAPI)2 BufferedReader (java.io.BufferedReader)2 FileInputStream (java.io.FileInputStream)2 InputStreamReader (java.io.InputStreamReader)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 Pattern (java.util.regex.Pattern)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2