You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2012/06/13 19:09:08 UTC
[18/19] [CB-606] Added create script for unix and windows
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/template/project/blackberry.xml
----------------------------------------------------------------------
diff --git a/template/project/blackberry.xml b/template/project/blackberry.xml
deleted file mode 100644
index 59c0278..0000000
--- a/template/project/blackberry.xml
+++ /dev/null
@@ -1,333 +0,0 @@
-<project default="help">
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
- <!-- LOAD PROPERTIES -->
-
- <property prefix="properties" file="project.properties" />
- <property name="build.dir" location="build" />
- <property name="widget.dir" location="${build.dir}/widget" />
- <property name="code.sign" value="false" />
- <property name="generate.ext" value="cod" />
-
- <!-- BlackBerry WebWorks Packager directory is required. -->
- <fail unless="properties.blackberry.bbwp.dir" message="Please specify BlackBerry WebWorks Packager directory using 'blackberry.bbwp.dir' in your 'project.properties' file." />
-
- <!-- OS identification -->
- <condition property="isMacOSX" else="false">
- <and>
- <os family="mac" />
- <os family="unix" />
- </and>
- </condition>
-
- <condition property="javaloader" value="${properties.blackberry.bbwp.dir}/bin/javaloader" else="${properties.blackberry.bbwp.dir}/bin/JavaLoader.exe">
- <equals arg1="${isMacOSX}" arg2="true" />
- </condition>
-
- <condition property="bbwp" value="${properties.blackberry.bbwp.dir}/bbwp" else="${properties.blackberry.bbwp.dir}/bbwp.exe">
- <equals arg1="${isMacOSX}" arg2="true" />
- </condition>
-
-
- <!-- LOAD DEVICE -->
-
- <target name="load-device" depends="package-app">
- <bbwp code-sign="true" />
- <exec executable="${javaloader}" dir="." failonerror="true">
- <arg value="-u" />
- <arg value="-w${properties.blackberry.sim.password}" />
- <arg value="load" />
- <arg file="${build.dir}/StandardInstall/${cod.name}.cod" />
- </exec>
- </target>
-
- <!-- LOAD SIMULATOR -->
-
- <target name="load-simulator" depends="build">
-
- <!-- Find the simulator directory -->
- <set-simulator-dir />
-
- <!-- Locate BBWP simulator directory. There may be multiple, so choose the first. -->
- <path id="bbwp.sim.path">
- <first>
- <fileset dir="${properties.blackberry.bbwp.dir}/simpack">
- <include name="**/handhelds.manifest.txt" />
- </fileset>
- </first>
- </path>
- <dirname property="bbwp.sim.dir" file="${toString:bbwp.sim.path}" />
-
- <!-- Simulator directory: Use sim.dir property if set in project.properties file.
- Otherwise, use bbwp simulator directory. -->
- <condition
- property="simulator.dir"
- value="${properties.blackberry.sim.dir}"
- else="${bbwp.sim.dir}">
- <available file="${properties.blackberry.sim.dir}" type="dir" />
- </condition>
- <echo message="Simulator directory=${simulator.dir}" />
-
- <!-- Simulator binary: Use sim.bin property if set in project.properties file
- or try setting to 'defaultSimulator.bat' in simulator directory. -->
- <condition
- property="sim.bin"
- value="${properties.blackberry.sim.bin}"
- else="defaultSimulator.bat">
- <available file="${simulator.dir}/${properties.blackberry.sim.bin}"/>
- </condition>
-
- <!-- If simulator executable does not exist, use the first device listed
- in the 'handhelds.manifest.txt' file in the simulator directory. -->
- <loadfile
- property="device.list"
- srcFile="${simulator.dir}/handhelds.manifest.txt">
- <filterchain>
- <tokenFilter>
- <stringtokenizer/>
- </tokenFilter>
- </filterchain>
- </loadfile>
-
- <propertyregex property="device"
- input="${device.list}"
- regexp="^\d{4}"
- select="\0"
- override="true" />
- <property name="device.bin" value="${device}.bat" />
-
- <condition
- property="simulator.bin"
- value="${sim.bin}"
- else="${device.bin}">
- <available file="${simulator.dir}/${sim.bin}" />
- </condition>
-
- <echo message="Simulator executable=${simulator.dir}/${simulator.bin}" />
-
- <!-- Close running simulators -->
- <echo message="Closing all running simulators..." />
- <exec executable="${simulator.dir}/fledgecontroller.exe" dir="${simulator.dir}" spawn="false">
- <arg value="/execute=kill" />
- </exec>
-
- <!-- MDS directory: Use mds.dir property if set in project.properties file.
- Otherwise, use bbwp MDS directory. -->
- <condition
- property="mds.dir"
- value="${properties.blackberry.mds.dir}"
- else="${properties.blackberry.bbwp.dir}/mds">
- <available file="${properties.blackberry.mds.dir}" type="dir" />
- </condition>
- <echo message="MDS directory=${mds.dir}" />
-
- <copy todir="${simulator.dir}">
- <fileset dir="${build.dir}/StandardInstall" includes="*.cod, *.cso, *.csl, *.alx" />
- </copy>
- <exec executable="${mds.dir}/run.bat" dir="${mds.dir}" spawn="true" />
- <exec executable="${simulator.dir}/${simulator.bin}" dir="${simulator.dir}" spawn="true" />
-
- <!-- Only invoke FledgeHook.exe if it is found. Newer versions of the
- WebWorks SDK do not include it. -->
- <if>
- <available file="${properties.blackberry.bbwp.dir}/FledgeHook.exe" />
- <then>
- <exec executable="${properties.blackberry.bbwp.dir}/FledgeHook.exe" dir="${properties.blackberry.bbwp.dir}" spawn="true" />
- </then>
- </if>
- </target>
-
- <!-- PACKAGE-APP -->
-
- <target name="package-app" depends="generate-cod-name, clean">
- <!-- Copy the WebWorks application -->
- <mkdir dir="${widget.dir}" />
- <copy todir="${widget.dir}" overwrite="true">
- <fileset dir="www" excludes="ext-air/**,playbook/**"/>
- </copy>
-
- <!-- Package the WebWorks app by zipping the widget dir. -->
- <mkdir dir="${build.dir}" />
- <zip compress="false" destfile="${build.dir}/${cod.name}.zip" basedir="${widget.dir}" excludes="**/build/**,**/.settings/**,**/.project" />
- </target>
-
- <!-- BUILD -->
-
- <target name="build" depends="package-app">
- <bbwp code-sign="${code.sign}" />
- </target>
-
- <!-- BBWP MACRO -->
-
- <macrodef name="bbwp">
- <attribute name="code-sign" default="false" />
- <sequential>
-
- <!-- Ensure bbwp executable exists. -->
- <property name="properties.blackberry.bbwp.bin" location="${bbwp}" />
- <available file="${properties.blackberry.bbwp.bin}" property="properties.blackberry.bbwp.exists" />
- <fail unless="properties.blackberry.bbwp.exists" message="Cannot find ${properties.blackberry.bbwp.bin}. Please edit 'blackberry.bbwp.dir' in your 'project.properties' file." />
-
- <if>
- <equals arg1="@{code-sign}" arg2="true" />
- <then>
- <exec executable="${properties.blackberry.bbwp.bin}">
- <arg file="${build.dir}/${cod.name}.zip" />
- <arg value="/g" />
- <arg value="${properties.blackberry.sigtool.password}" />
- <arg value="/o" />
- <arg file="${build.dir}" />
- </exec>
- </then>
- <else>
- <exec executable="${properties.blackberry.bbwp.bin}">
- <arg file="${build.dir}/${cod.name}.zip" />
- <arg value="/o" />
- <arg file="${build.dir}" />
- </exec>
- </else>
- </if>
- </sequential>
- </macrodef>
-
- <!-- CLEAN -->
-
- <target name="clean">
- <delete dir="${build.dir}" />
- <delete dir="${widget.dir}" />
- </target>
-
- <!-- CLEAN DEVICE -->
-
- <target name="clean-device" depends="generate-cod-name">
- <exec executable="${javaloader}">
- <arg value="-usb" />
- <arg value="erase" />
- <arg value="-f" />
- <arg value="${cod.name}.cod" />
- </exec>
- </target>
-
- <!-- CLEAN SIMULATOR -->
-
- <target name="clean-simulator">
- <!-- Find the simulator directory -->
- <set-simulator-dir />
-
- <exec executable="${simulator.dir}/clean.bat" dir="${simulator.dir}" />
-
- <delete>
- <fileset dir="${simulator.dir}" includes="*.cod,*.csl,*.cso,*.debug,*.jar" />
- </delete>
- </target>
-
- <!-- HELPER TASKS -->
-
- <target name="generate-cod-name">
- <xmlproperty file="www/config.xml" prefix="config.xml" />
- <propertyregex property="cod.name"
- input="${config.xml.widget.name}"
- regexp="(\W+)"
- replace=""
- casesensitive="false"
- global="true"
- defaultValue="${config.xml.widget.name}" />
- <echo message="Generated name: ${cod.name}.cod" />
- </target>
-
- <!-- MACRO: SET SIMULATOR DIRECTORY -->
-
- <macrodef name="set-simulator-dir">
- <sequential>
- <!-- Locate BBWP simulator directory. There may be multiple, so choose the first. -->
- <path id="bbwp.sim.path">
- <first>
- <fileset dir="${properties.blackberry.bbwp.dir}/simpack">
- <include name="**/handhelds.manifest.txt" />
- </fileset>
- </first>
- </path>
- <dirname property="bbwp.sim.dir" file="${toString:bbwp.sim.path}" />
-
- <!-- Simulator directory: Use sim.dir property if set in project.properties file.
- Otherwise, use bbwp simulator directory. -->
- <condition
- property="simulator.dir"
- value="${properties.blackberry.sim.dir}"
- else="${bbwp.sim.dir}">
- <available file="${properties.blackberry.sim.dir}" type="dir" />
- </condition>
- <echo message="Simulator directory=${simulator.dir}" />
- </sequential>
- </macrodef>
-
- <!-- HELP -->
-
- <target name="help">
- <echo>
-NAME
- ${ant.project.name}
-
-SYNOPSIS
- ant TARGET COMMAND [-D<argument>=<value>]...
-
-DESCRIPTION
- You can build and deploy your project to a device or simulator.
-
-TARGETS
- blackberry ........ Builds a cod file and deploys to a device or simulator
-
- playbook .......... Builds a bar file and deploys to a device or simulator
-
-COMMANDS
- help .............. Show this help menu.
- ant, ant help
-
- load-device ....... Builds and deploys project to a connected USB device.
- ant load-device
-
- load-simulator .... Builds and deploys project to default simulator.
- ant load-simulator
-
- build ............. Compiles and packages the project for deployment.
- ant build
-
- clean ............. Remove all files from the build/ directory.
- ant clean
-
- clean-device ...... Remove this project from the connected USB device.
- ant clean-device
-
- clean-simulator ... Remove this project from the simulator (takes a while).
- ant clean-simulator
-
-GETTING STARTED
- 1. Edit project.properties
-
- 2. <ant load-simulator> to run the project on the simulator
-
- 3. Customize your project by editing www/config.xml
-
- 4. To run the project on a BlackBerry device, you will need to obtain
- code signing keys from RIM. Once you have the key, a project is
- installed by connecting a BlackBerry via USB and running
- <ant load-device>.
- </echo>
- </target>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/template/project/build.xml
----------------------------------------------------------------------
diff --git a/template/project/build.xml b/template/project/build.xml
deleted file mode 100644
index 9cf3e37..0000000
--- a/template/project/build.xml
+++ /dev/null
@@ -1,132 +0,0 @@
-<project name="Build and Deploy a Cordova BlackBerry WebWorks Project" default="help">
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
- <!-- LOAD ANT-CONTRIB LIBRARY -->
-
- <taskdef resource="net/sf/antcontrib/antcontrib.properties">
- <classpath>
- <pathelement location="./lib/ant-contrib/ant-contrib-1.0b3.jar" />
- </classpath>
- </taskdef>
-
- <!-- LOAD PROPERTIES -->
-
- <property prefix="properties" file="project.properties" />
- <property name="build.dir" location="build" />
- <property name="widget.dir" location="${build.dir}/widget" />
- <property name="code.sign" value="false" />
-
- <target name="blackberry" >
- <property name="subant.file" value="blackberry.xml" />
- </target>
-
- <target name="playbook" >
- <property name="subant.file" value="playbook.xml" />
- </target>
-
- <target name="load-device">
- <subant target="load-device">
- <fileset dir="." includes="${subant.file}"/>
- </subant>
- </target>
-
- <target name="load-simulator">
- <subant target="load-simulator">
- <fileset dir="." includes="${subant.file}"/>
- </subant>
- </target>
-
- <target name="build">
- <subant target="build">
- <fileset dir="." includes="${subant.file}"/>
- </subant>
- </target>
-
- <target name="clean">
- <subant target="clean">
- <fileset dir="." includes="${subant.file}"/>
- </subant>
- </target>
-
- <target name="clean-device">
- <subant target="clean-device">
- <fileset dir="." includes="${subant.file}"/>
- </subant>
- </target>
-
- <target name="clean-simulator">
- <subant target="clean-simulator">
- <fileset dir="." includes="${subant.file}"/>
- </subant>
- </target>
-
- <!-- HELP -->
-
- <target name="help">
- <echo>
-NAME
- ${ant.project.name}
-
-SYNOPSIS
- ant TARGET COMMAND [-D<argument>=<value>]...
-
-DESCRIPTION
- You can build and deploy your project to a device or simulator.
-
-TARGETS
- blackberry ........ Builds a cod file and deploys to a device or simulator
-
- playbook .......... Builds a bar file and deploys to a device or simulator
-
-COMMANDS
- help .............. Show this help menu.
- ant, ant help
-
- load-device ....... Builds and deploys project to a connected USB device.
- ant load-device
-
- load-simulator .... Builds and deploys project to default simulator.
- ant load-simulator
-
- build ............. Compiles and packages the project for deployment.
- ant build
-
- clean ............. Remove all files from the build/ directory.
- ant clean
-
- clean-device ...... Remove this project from the connected USB device.
- ant clean-device
-
- clean-simulator ... Remove this project from the simulator (takes a while).
- ant clean-simulator
-
-GETTING STARTED
- 1. Edit project.properties
-
- 2. <ant load-simulator> to run the project on the simulator
-
- 3. Customize your project by editing www/config.xml
-
- 4. To run the project on a BlackBerry device, you will need to obtain
- code signing keys from RIM. Once you have the key, a project is
- installed by connecting a BlackBerry via USB and running
- <ant load-device>.
- </echo>
- </target>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/template/project/lib/ant-contrib/LICENSE.txt
----------------------------------------------------------------------
diff --git a/template/project/lib/ant-contrib/LICENSE.txt b/template/project/lib/ant-contrib/LICENSE.txt
deleted file mode 100644
index 4d8c2fb..0000000
--- a/template/project/lib/ant-contrib/LICENSE.txt
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * The Apache Software License, Version 1.1
- *
- * Copyright (c) 2001-2003 Ant-Contrib project. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
- * Ant-Contrib project (http://sourceforge.net/projects/ant-contrib)."
- * Alternately, this acknowlegement may appear in the software itself,
- * if and wherever such third-party acknowlegements normally appear.
- *
- * 4. The name Ant-Contrib must not be used to endorse or promote products
- * derived from this software without prior written permission. For
- * written permission, please contact
- * ant-contrib-developers@lists.sourceforge.net.
- *
- * 5. Products derived from this software may not be called "Ant-Contrib"
- * nor may "Ant-Contrib" appear in their names without prior written
- * permission of the Ant-Contrib project.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE ANT-CONTRIB PROJECT OR ITS
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- */
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/template/project/lib/ant-contrib/ant-contrib-1.0b3.jar
----------------------------------------------------------------------
diff --git a/template/project/lib/ant-contrib/ant-contrib-1.0b3.jar b/template/project/lib/ant-contrib/ant-contrib-1.0b3.jar
deleted file mode 100644
index 0625376..0000000
Binary files a/template/project/lib/ant-contrib/ant-contrib-1.0b3.jar and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/template/project/playbook.xml
----------------------------------------------------------------------
diff --git a/template/project/playbook.xml b/template/project/playbook.xml
deleted file mode 100644
index 2584f9c..0000000
--- a/template/project/playbook.xml
+++ /dev/null
@@ -1,255 +0,0 @@
-<project default="help">
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
- <!-- LOAD PROPERTIES -->
-
- <property prefix="properties" file="project.properties" />
- <property name="build.dir" location="build" />
- <property name="widget.dir" location="${build.dir}/widget" />
- <property name="code.sign" value="false" />
- <property name="generate.ext" value="cod" />
- <property name="build.num.file" value="buildId.txt" />
-
- <!-- BlackBerry WebWorks Packager for Tablets directory is required. -->
- <fail unless="properties.playbook.bbwp.dir" message="Please specify BlackBerry WebWorks Packager directory using 'playbook.bbwp.dir' in your 'project.properties' file." />
-
- <!-- OS identification -->
- <condition property="isMacOSX" else="false">
- <and>
- <os family="mac" />
- <os family="unix" />
- </and>
- </condition>
-
- <condition property="bbwp" value="${properties.playbook.bbwp.dir}/bbwp" else="${properties.playbook.bbwp.dir}/bbwp.exe">
- <equals arg1="${isMacOSX}" arg2="true" />
- </condition>
-
- <condition property="blackberry-deploy" value="${properties.playbook.bbwp.dir}/blackberry-tablet-sdk/bin/blackberry-deploy" else="${properties.playbook.bbwp.dir}/blackberry-tablet-sdk/bin/blackberry-deploy.bat">
- <equals arg1="${isMacOSX}" arg2="true" />
- </condition>
-
- <!-- LOAD DEVICE -->
-
- <target name="load-device" depends="package-app">
- <bbwp code-sign="true" />
-
- <exec executable="${blackberry-deploy}" dir="." failonerror="true">
- <arg value="-installApp" />
- <arg value="-launchApp" />
- <arg value="-device" />
- <arg value="${properties.playbook.device.ip}" />
- <arg value="-password" />
- <arg value="${properties.playbook.device.password}" />
- <arg value="-package" />
- <arg file="${build.dir}/${cod.name}.bar" />
- </exec>
- </target>
-
- <!-- LOAD SIMULATOR -->
-
- <target name="load-simulator" depends="build">
-
- <echo>This tool will not open the simulator for you </echo>
-
- <exec executable="${blackberry-deploy}" dir="." failonerror="true">
- <arg value="-installApp" />
- <arg value="-launchApp" />
- <arg value="-device" />
- <arg value="${properties.playbook.sim.ip}" />
- <arg value="-password" />
- <arg value="${properties.playbook.sim.password}" />
- <arg value="-package" />
- <arg file="${build.dir}/${cod.name}.bar" />
- </exec>
- </target>
-
- <!-- PACKAGE-APP -->
-
- <target name="package-app" depends="generate-cod-name, clean">
- <!-- Copy the WebWorks application -->
- <mkdir dir="${widget.dir}" />
- <copy todir="${widget.dir}" overwrite="true">
- <fileset dir="www" >
- <exclude name="ext/**"/>
- <exclude name="ext-air/**"/>
- <exclude name="playbook/**"/>
- </fileset>
- </copy>
-
- <!-- Overwrite the cordova js with the playbook specific cordova js -->
- <copy todir="${widget.dir}" overwrite="true">
- <fileset dir="www/playbook">
- <include name="*.js" />
- </fileset>
- </copy>
-
- <!-- Update WebWorks Packager with the AIR APIs -->
- <copy todir="${properties.playbook.bbwp.dir}\ext" overwrite="true">
- <fileset dir="www/ext-air" excludes="README.md" />
- </copy>
-
- <!-- Package the WebWorks app by zipping the widget dir. -->
- <mkdir dir="${build.dir}" />
- <zip compress="false" destfile="${build.dir}/${cod.name}.zip" basedir="${widget.dir}" excludes="**/build/**,**/.settings/**,**/.project" />
- </target>
-
- <!-- BUILD -->
-
- <target name="build" depends="package-app">
- <bbwp code-sign="${code.sign}" />
- </target>
-
- <!-- BBWP MACRO -->
-
- <macrodef name="bbwp">
- <attribute name="code-sign" default="false" />
- <sequential>
- <buildnumber file="${build.num.file}" />
- <if>
- <equals arg1="@{code-sign}" arg2="true" />
- <then>
- <exec executable="${bbwp}">
- <arg file="${build.dir}/${cod.name}.zip" />
- <arg value="-gcsk" />
- <arg value="${properties.playbook.sigtool.csk.password}" />
- <arg value="-gp12" />
- <arg value="${properties.playbook.sigtool.p12.password}" />
- <arg value="-o" />
- <arg file="${build.dir}" />
- <arg value="-buildId" />
- <arg value="${build.number}" />
- </exec>
- </then>
- <else>
- <exec executable="${bbwp}">
- <arg file="${build.dir}/${cod.name}.zip" />
- <arg value="-o" />
- <arg file="${build.dir}" />
- <arg value="-buildId" />
- <arg value="${build.number}" />
- </exec>
- </else>
- </if>
- </sequential>
- </macrodef>
-
- <!-- CLEAN -->
-
- <target name="clean">
- <delete dir="${build.dir}" />
- <delete dir="${widget.dir}" />
- </target>
-
- <!-- CLEAN DEVICE -->
-
- <target name="clean-device" depends="generate-cod-name">
- <exec executable="${blackberry-deploy}" dir="." failonerror="true">
- <arg value="-uninstallApp" />
- <arg value="-device" />
- <arg value="${properties.playbook.device.ip}" />
- <arg value="-password" />
- <arg value="${properties.playbook.device.password}" />
- <arg value="-package" />
- <arg file="${build.dir}/${cod.name}.bar" />
- </exec>
- </target>
-
- <!-- CLEAN SIMULATOR -->
-
- <target name="clean-simulator">
- <exec executable="${blackberry-deploy}" dir="." failonerror="true">
- <arg value="-uninstallApp" />
- <arg value="-device" />
- <arg value="${properties.playbook.sim.ip}" />
- <arg value="-password" />
- <arg value="${properties.playbook.sim.password}" />
- <arg value="-package" />
- <arg file="${build.dir}/${cod.name}.bar" />
- </exec>
- </target>
-
- <!-- HELPER TASKS -->
-
- <target name="generate-cod-name">
- <xmlproperty file="www/config.xml" prefix="config.xml" />
- <propertyregex property="cod.name"
- input="${config.xml.widget.name}"
- regexp="(\W+)"
- replace=""
- casesensitive="false"
- global="true"
- defaultValue="${config.xml.widget.name}" />
- <echo message="Generated name: ${cod.name}.bar" />
- </target>
-
- <!-- HELP -->
-
- <target name="help">
- <echo>
-NAME
- ${ant.project.name}
-
-SYNOPSIS
- ant TARGET COMMAND [-D<argument>=<value>]...
-
-DESCRIPTION
- You can build and deploy your project to a device or simulator.
-
-TARGETS
- blackberry ........ Builds a cod file and deploys to a device or simulator
-
- playbook .......... Builds a bar file and deploys to a device or simulator
-
-COMMANDS
- help .............. Show this help menu.
- ant, ant help
-
- load-device ....... Builds and deploys project to a connected USB device.
- ant load-device
-
- load-simulator .... Builds and deploys project to default simulator.
- ant load-simulator
-
- build ............. Compiles and packages the project for deployment.
- ant build
-
- clean ............. Remove all files from the build/ directory.
- ant clean
-
- clean-device ...... Remove this project from the connected USB device.
- ant clean-device
-
- clean-simulator ... Remove this project from the simulator (takes a while).
- ant clean-simulator
-
-GETTING STARTED
- 1. Edit project.properties
-
- 2. <ant <TARGET> load-simulator> to run the project on the simulator
-
- 3. Customize your project by editing www/config.xml
-
- 4. To run the project on a BlackBerry device, you will need to obtain
- code signing keys from RIM. Once you have the key, a project is
- installed by connecting a BlackBerry via USB and running
- <ant <TARGET> load-device>.
- </echo>
- </target>
-</project>
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/template/project/project.properties
----------------------------------------------------------------------
diff --git a/template/project/project.properties b/template/project/project.properties
deleted file mode 100644
index ee05983..0000000
--- a/template/project/project.properties
+++ /dev/null
@@ -1,97 +0,0 @@
-# BlackBerry WebWorks Packager Directory
-#
-# The BlackBerry WebWorks Packager (bbwp) is required for compiling and packaging
-# BlackBerry WebWorks applications for deployment to a BlackBerry device
-# or simulator. The bbwp utility is installed with the standalone BlackBerry
-# WebWorks SDK, and as part of the BlackBerry Web Plugin for Eclipse.
-#
-# Please specify the location of the BlackBerry WebWorks Packager in your
-# environment.
-#
-# Typical location of bbwp for standalone BlackBerry WebWorks SDK installation:
-# C:\Program Files (x86)\Research In Motion\BlackBerry Widget Packager
-#
-# Typical location of bbwp for BlackBerry Web Plugin for Eclipse installation:
-# C:\Eclipse-3.5.2\plugins\net.rim.browser.tools.wcpc_1.0.0.201003191451-126\wcpc
-#
-# The ANT script is brittle and requires you to escape the backslashes.
-# e.g. C:\some\path must be C:\\some\\path
-#
-# Please remember to:
-# - Double escape your backslahses (i.e. \ must be \\)
-# - Do not add a trailing slash (e.g. C:\some\path)
-#
-blackberry.bbwp.dir=C:\\Program Files\\Research In Motion\\BlackBerry WebWorks Packager
-
-playbook.bbwp.dir=C:\\Program Files\\Research In Motion\\BlackBerry WebWorks SDK for TabletOS 2.1.0.6\\bbwp
-
-# (Optional) Simulator Directory
-#
-# If sim.dir is not specified, the build script will use the simulator directory
-# within the Blackberry WebWorks Packager.
-#
-blackberry.sim.dir=C:\\Program Files\\Research In Motion\BlackBerry WebWorks Packager\\simpack\\6.0.0.227
-
-# (Optional) Simulator Binary
-#
-# If sim.bin is not specified, the build script will attempt to use the default
-# simulator in the simulator directory.
-#
-#blackberry.sim.bin=9700.bat
-
-# (Optional) MDS Directory
-#
-# If mds.dir is not specified, the build script will attempt to use the MDS that
-# is installed with the Blackberry WebWorks Packager.
-#
-blackberry.mds.dir=C:\\Program Files\\Research In Motion\\BlackBerry WebWorks Packager\\mds
-
-# BlackBerry Code Signing Password
-#
-# If you leave this field blank, then
-# the signing tool will prompt you each time
-#
-blackberry.sigtool.password=
-
-# Playbook Code Signing Password
-#
-# If you leave these fields blank, then
-# signing will fail
-#
-playbook.sigtool.csk.password=
-playbook.sigtool.p12.password=
-
-# BlackBerry Simulator Password
-#
-# If you leave this field blank, then
-# you cannot deploy to simulator
-#
-blackberry.sim.password=
-
-# Playbook Simulator IP
-#
-# If you leave this field blank, then
-# you cannot deploy to simulator
-#
-playbook.sim.ip=
-
-# Playbook Simulator Password
-#
-# If you leave this field blank, then
-# you cannot deploy to simulator
-#
-playbook.sim.password=
-
-# Playbook Device IP
-#
-# If you leave this field blank, then
-# you cannot deploy to device
-#
-playbook.device.ip=
-
-# Playbook Device Password
-#
-# If you leave this field blank, then
-# you cannot deploy to device
-#
-playbook.device.password=
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/template/project/www/config.xml
----------------------------------------------------------------------
diff --git a/template/project/www/config.xml b/template/project/www/config.xml
deleted file mode 100644
index 28a7fc1..0000000
--- a/template/project/www/config.xml
+++ /dev/null
@@ -1,80 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<!--
- Widget Configuration Reference:
- http://docs.blackberry.com/en/developers/deliverables/15274/
--->
-
-<widget xmlns="http://www.w3.org/ns/widgets"
- xmlns:rim="http://www.blackberry.com/ns/widgets"
- version="1.0.0.0">
-
- <name>Cordova Sample</name>
-
- <description>
- A sample application written with Cordova.
- </description>
-
- <license href="http://opensource.org/licenses/alphabetical">
- </license>
-
- <!-- Cordova API -->
- <feature id="blackberry.system" required="true" version="1.0.0.0" />
- <feature id="org.apache.cordova" required="true" version="1.0.0" />
- <feature id="blackberry.find" required="true" version="1.0.0.0" />
- <feature id="blackberry.identity" required="true" version="1.0.0.0" />
- <feature id="blackberry.pim.Address" required="true" version="1.0.0.0" />
- <feature id="blackberry.pim.Contact" required="true" version="1.0.0.0" />
- <feature id="blackberry.io.file" required="true" version="1.0.0.0" />
- <feature id="blackberry.utils" required="true" version="1.0.0.0" />
- <feature id="blackberry.io.dir" required="true" version="1.0.0.0" />
- <feature id="blackberry.app" required="true" version="1.0.0.0" />
- <feature id="blackberry.app.event" required="true" version="1.0.0.0" />
- <feature id="blackberry.system.event" required="true" version="1.0.0.0"/>
- <feature id="blackberry.widgetcache" required="true" version="1.0.0.0"/>
- <feature id="blackberry.media.camera" />
- <feature id="blackberry.ui.dialog" />
-
- <!-- Cordova API -->
- <access subdomains="true" uri="file:///store/home" />
- <access subdomains="true" uri="file:///SDCard" />
-
- <!-- Expose access to all URIs, including the file and http protocols -->
- <access subdomains="true" uri="*" />
-
- <icon rim:hover="false" src="resources/icon.png" />
- <icon rim:hover="true" src="resources/icon.png" />
-
- <rim:loadingScreen backgroundColor="#CFCFCF"
- foregroundImage="resources/loading_foreground.png"
- onFirstLaunch="true">
- <rim:transitionEffect type="fadeOut" />
- </rim:loadingScreen>
-
- <content src="index.html" />
-
- <rim:permissions>
- <rim:permit>use_camera</rim:permit>
- <rim:permit>read_device_identifying_information</rim:permit>
- <rim:permit>access_shared</rim:permit>
- <rim:permit>read_geolocation</rim:permit>
- </rim:permissions>
-
-</widget>
http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/5f3fbff2/template/project/www/index.html
----------------------------------------------------------------------
diff --git a/template/project/www/index.html b/template/project/www/index.html
deleted file mode 100644
index 92537b1..0000000
--- a/template/project/www/index.html
+++ /dev/null
@@ -1,976 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<!DOCTYPE html>
-<html>
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" id="viewport" content="width=device-width,height=device-height,initial-scale=1.0,user-scalable=no">
- <script src="json2.js" type="text/javascript"></script>
- <script src="cordova.js" type="text/javascript"></script>
- <script type="text/javascript">
-
- //---------------------------------------------------------------------
- // Cordova event listeners
- //---------------------------------------------------------------------
-
- // invoked when device is ready
- function deviceInfo() {
- document.getElementById('window.device.platform').innerHTML = 'window.device.platform = ' + window.device.platform;
- document.getElementById('window.device.version').innerHTML = 'window.device.version = ' + window.device.version;
- document.getElementById('window.device.uuid').innerHTML = 'window.device.uuid = ' + window.device.uuid;
- document.getElementById('window.device.cordova').innerHTML = 'window.device.cordova = ' + window.device.cordova;
-
- setNetworkType();
- }
-
- // invoked when application is resumed (brought to foregroud)
- function doResume() {
- console.log('doResume()');
- }
-
- // invoked when application is paused (sent to background)
- function doPause() {
- console.log('doPause()');
- }
-
- // invoked when application is online
- function doOnline() {
- console.log('Event: online\n' + 'Network Type: ' + navigator.network.connection.type + '\n');
- setNetworkType();
- }
-
- // invoked when application is offline
- function doOffline() {
- console.log('Event: offline\n' + 'Network Type: ' + navigator.network.connection.type + '\n');
- setNetworkType();
- }
-
- // register Cordova event listeners when DOM content loaded
- function init() {
- console.log('init()');
- document.addEventListener("deviceready", deviceInfo, true);
- document.addEventListener("resume", doResume, false);
- document.addEventListener("pause", doPause, false);
- document.addEventListener("online", doOnline, false);
- document.addEventListener("offline", doOffline, false);
- }
-
- function unload() {
- console.log('unload()');
- }
-
- function fail(error) {
- navigator.notification.alert(error, null, "Error");
- }
-
- //---------------------------------------------------------------------
- // Notification
- //---------------------------------------------------------------------
-
- function callBeep() {
- navigator.notification.beep(2);
- }
-
- function callVibrate() {
- navigator.notification.vibrate(1000);
- }
-
- function alertDismissed() {
- alert('Alert dialog dismissed.');
- }
-
- function callAlert() {
- navigator.notification.alert(
- "You rock!",
- alertDismissed,
- "Woohoo!",
- "Thanks");
- }
-
- function confirmResult(button) {
- console.log('Confirm: you pressed button ' + button);
- }
-
- function callConfirm() {
- navigator.notification.confirm(
- "Please confirm",
- confirmResult,
- "Are you sure?",
- "Yes,No,Maybe");
- }
-
- //---------------------------------------------------------------------
- // Network
- //---------------------------------------------------------------------
- function setNetworkType() {
- var states = {};
- states[Connection.UNKNOWN] = 'Unknown connection';
- states[Connection.ETHERNET] = 'Ethernet connection';
- states[Connection.WIFI] = 'WiFi connection';
- states[Connection.CELL_2G] = 'Cell 2G connection';
- states[Connection.CELL_3G] = 'Cell 3G connection';
- states[Connection.CELL_4G] = 'Cell 4G connection';
- states[Connection.NONE] = 'No network connection';
- document.getElementById('networkStatus').innerHTML = 'Connection type = ' + states[navigator.network.connection.type];
- }
-
- //---------------------------------------------------------------------
- // Accelerometer
- //---------------------------------------------------------------------
- function showAcceleration(acceleration) {
- alert('Acceleration X: ' + acceleration.x + '\n' +
- 'Acceleration Y: ' + acceleration.y + '\n' +
- 'Acceleration Z: ' + acceleration.z + '\n');
- }
-
- var accelWatchId = null;
- var watchAcceleration = function() {
- var success = function(a) {
- document.getElementById('x').innerHTML = a.x;
- document.getElementById('y').innerHTML = a.y;
- document.getElementById('z').innerHTML = a.z;
- };
- var options = {};
- options.frequency = 200;
- accelWatchId = navigator.accelerometer.watchAcceleration(success, fail, options);
- }
-
- function clearAccelWatch() {
- if (accelWatchId != null) {
- navigator.accelerometer.clearWatch(accelWatchId);
- accelWatchId = null;
- }
- }
-
- function getAcceleration() {
- navigator.accelerometer.getCurrentAcceleration(showAcceleration, fail);
- }
-
- //---------------------------------------------------------------------
- // Geolocation
- //---------------------------------------------------------------------
- function getLocation() {
- var success = function(p) {
- alert('Latitude: ' + p.coords.latitude + '\n' +
- 'Longitude: ' + p.coords.longitude);
- };
- var options = {};
- options.enableHighAccuracy = true;
- var timeout = new Number(document.getElementById('geo_timeout').value);
- if (isNaN(timeout) === false) {
- options.timeout = timeout*1000;
- }
- var maxage = new Number(document.getElementById('geo_maxage').value);
- if (isNaN(maxage) === false) {
- options.maximumAge = maxage*1000;
- }
- navigator.geolocation.getCurrentPosition(success, onLocationFail, options);
- }
-
- var locationWatchId = null;
- var watchLocation = function() {
- var success = function(p) {
- document.getElementById('lat').innerHTML = p.coords.latitude;
- document.getElementById('long').innerHTML = p.coords.longitude;
- };
- var options = {};
- options.enableHighAccuracy = true;
- var timeout = new Number(document.getElementById('geo_timeout').value);
- if (isNaN(timeout) === false) {
- options.timeout = timeout*1000;
- }
- var maxage = new Number(document.getElementById('geo_maxage').value);
- if (isNaN(maxage) === false) {
- options.maximumAge = maxage*1000;
- }
- locationWatchId = navigator.geolocation.watchPosition(success, onLocationFail, options);
- }
-
- function clearLocationWatch() {
- if (locationWatchId != null) {
- navigator.geolocation.clearWatch(locationWatchId);
- locationWatchId = null;
- }
- document.getElementById('lat').innerHTML = "";
- document.getElementById('long').innerHTML = "";
- }
-
- function onLocationFail(error) {
- alert('code: ' + error.code + '\n' +
- 'message: ' + error.message + '\n');
- }
-
- //---------------------------------------------------------------------
- // Camera
- //---------------------------------------------------------------------
- function onCapturePhotoSuccess(imageData) {
- if (imageData != null) {
- var smallImage = document.getElementById('cameraImage');
-
- // hide upload button
- var uploadButton = document.getElementById('uploadButton');
- uploadButton.style.display = 'none';
-
- // Unhide image element
- smallImage.style.display = 'block';
-
- // Show the captured photo
- // The inline CSS rules are used to resize the image
- smallImage.src = "data:image/jpeg;base64," + imageData;
- }
- }
-
- function onCapturePhotoURISuccess(imageURI) {
- if (imageURI != null) {
- var smallImage = document.getElementById('cameraImage');
- var uploadButton = document.getElementById('uploadButton');
-
- // Unhide image elements
- smallImage.style.display = 'block';
- uploadButton.style.display = 'block';
-
- // Show the captured photo
- // The inline CSS rules are used to resize the image
- smallImage.src = imageURI;
- }
- }
-
- function capturePhoto() {
- navigator.camera.getPicture(onCapturePhotoSuccess, fail,
- { destinationType: Camera.DestinationType.DATA_URL, quality: 50 });
- }
-
- function capturePhotoURI() {
- navigator.camera.getPicture(onCapturePhotoURISuccess, fail,
- { destinationType: Camera.DestinationType.FILE_URI, quality: 50 });
- }
-
- function uploadImage() {
- var smallImage = document.getElementById('cameraImage');
- if (smallImage.src && smallImage.src !== "") {
- var f = new FileTransfer();
- f.upload(
- // file path
- smallImage.src,
- // server URL - update to your own, and don't forget to
- // include your domain in an access element in config.xml
- "http://192.168.1.1/upload.php",
- // success callback
- function(result) {
- document.getElementById('uploadProgress').innerHTML =
- result.bytesSent + ' bytes sent';
- alert(result.responseCode + ": " + result.response);
- },
- // error callback
- function(error) {
- alert('error uploading file: ' + error.code);
- },
- // options
- { fileName: 'myImage.jpg',
- params: { 'username':'jtyberg' }
- });
- }
- }
-
- //---------------------------------------------------------------------
- // Contacts
- //---------------------------------------------------------------------
- function onContactSaved(contact) {
- var msg = "Contact " + contact.id + " saved.";
- navigator.notification.alert(msg, null, "Success");
- }
-
- function onContactUpdated(contact) {
- var msg = 'Contact ' + contact.id + ' updated.';
- navigator.notification.alert(msg, null, "Success");
- }
-
- function onContactRemoved(contact) {
- var msg = "Contact " + contact.id + " removed.";
- navigator.notification.alert(msg, null, "Success");
- }
-
- function createContact() {
- var myContact = navigator.contacts.create({"displayName": "fitness instructor"});
- myContact.note = "Workout queen.";
- myContact.birthday = new Date("May 11, 1979 05:32:00");
-
- // add name
- var myName = new ContactName();
- myName.givenName = "Shoshana";
- myName.familyName = "Lowenstein";
- myName.honorificPrefix = "Miss";
- myContact.name = myName;
-
- // add email
- var emails = [];
- emails[0] = new ContactField("work","im@work.com");
- emails[1] = new ContactField("home","im@home.com",true);
- emails[2] = new ContactField(null,"im@other.com");
- emails[3] = new ContactField(null,"im@aloss.com"); // 4th will be ignored
- myContact.emails = emails;
-
- // add phone numbers
- var phoneNumbers = [];
- phoneNumbers[0] = new ContactField("work","555-111-1111");
- phoneNumbers[1] = new ContactField("home","555-222-1111");
- phoneNumbers[2] = new ContactField("home","555-222-2222");
- phoneNumbers[3] = new ContactField(null,"555-333-1234");
- phoneNumbers[4] = new ContactField("fax","555-444-1234");
- phoneNumbers[5] = new ContactField("work","555-111-2222");
- phoneNumbers[6] = new ContactField("mobile","555-555-5555",true);
- phoneNumbers[7] = new ContactField("work","555-111-3333"); // 3rd 'work' phone will be ignored
- phoneNumbers[8] = new ContactField("pager","555-666-1111");
- myContact.phoneNumbers = phoneNumbers;
-
- // add address
- var addresses = [];
- addresses[0] = new ContactAddress(null, "home", null, "123 Astor Place", "Phoenix", "AZ", "58392", "United States");
- addresses[1] = new ContactAddress(null, "work", null, "290 Farmers Mills Rd", "Riverdale", "AZ", "58399", "United States");
- myContact.addresses = addresses;
-
- // add urls
- var urls = [];
- urls[0] = new ContactField(null,"http://my.domain.com");
- myContact.urls = urls;
-
- // add company info
- var orgs = [];
- orgs[0] = new ContactOrganization(null, null, "Beach Fitness", null, "Instructor", null);
- myContact.organizations = orgs;
-
- // add categories
- var categories = [];
- categories[0] = "Business";
- categories[1] = "Family"; // DOH! BlackBerry only supports 'Personal' and 'Business'
- myContact.categories = categories;
-
- // add photo
- var smallImage = document.getElementById('cameraImage');
- if (smallImage.src && smallImage.src !== "") {
- var photos = [];
- photos[0] = new ContactField(null, smallImage.src);
- myContact.photos = photos;
- }
-
- // saves the contact to device
- myContact.save(onContactSaved);
- }
-
- function updateContact() {
- // find a contact to update
- navigator.contacts.find(
- ['name','emails'],
- function(contacts) {
- var now = new Date();
-
- // we did not specify any filter, so all contacts will be returned
- // update first contact and save
- if (contacts[0]) {
- var c = contacts[0];
-
- // update attributes
- c.categories = [ 'Personal' ];
- c.emails[0].value = "sl@bf.com";
- c.note = 'updated: ' + now;
- console.log('contact: ' + c.id + ' ' + c.note);
-
- // remove phone numbers
- c.phoneNumbers = [];
-
- // set field to non-null value to remove from database
- c.birthday = "";
-
- // save changes
- c.save(onContactUpdated);
- }
- },
- fail
- );
- }
-
- function findContacts() {
- var filterText = document.getElementById('filterText').value;
- navigator.contacts.find(
- ['name', 'emails', 'addresses', 'organizations'],
- function(contacts) {
- var msg = 'Found ' + contacts.length + ' contacts.';
- navigator.notification.alert(msg, null, 'Success');
- },
- fail,
- {
- multiple: true, filter: filterText
- }
- );
- }
-
- function removeContact() {
- // find a contact to remove
- navigator.contacts.find(
- ["*"],
- // remove first contact
- function(contacts) {
- if (contacts[0]) {
- contacts[0].remove(onContactRemoved);
- }
- },
- fail);
- }
-
- //---------------------------------------------------------------------
- // File
- //---------------------------------------------------------------------
-
- // retrieves root file system entry
- var getFileSystemRoot = (function() {
-
- // private
- var root;
-
- // one-time retrieval of the root file system entry
- var init = function() {
- window.requestFileSystem(LocalFileSystem.PERSISTENT, 0,
- function(fileSystem) {
- root = fileSystem.root;
- },
- onFileSystemError);
- };
- document.addEventListener("deviceready", init, true);
-
- // public function returns private root entry
- return function() {
- return root;
- };
- }()); // execute immediately
-
- // file system error handler
- function onFileSystemError(error) {
- var msg = 'file system error: ' + error.code;
- navigator.notification.alert(msg, null, 'File System Error');
- }
-
- // logs file events
- function onFileEvent(event) {
- console.log('file event: ' + event.target.fileName + ' ' + event.type);
- }
-
- // called when error reading file
- function onFileError(event) {
- console.log('file error: ' + event.target.error.code);
- }
-
- // called when file is loaded
- function onFileLoaded(event) {
- onFileEvent(event);
- console.log(event.target.result);
- alert('FileReader.result: ' + event.target.fileName + ': ' + event.target.result);
- }
-
- // reads a text file
- function readFileAsText()
- {
- var fileReader = new FileReader(),
- root = getFileSystemRoot(),
- file;
-
- // set the callbacks
- fileReader.onloadstart = onFileEvent;
- fileReader.onprogress = onFileEvent;
- fileReader.onload = onFileLoaded;
- fileReader.onloadend = onFileEvent;
- fileReader.onabort = onFileEvent;
- fileReader.onerror = onFileError;
-
- // read the file
- file = new File();
- file.fullPath = root.toURI() + '/cordova.txt';
- fileReader.readAsText(file);
- }
-
- // reads a text file and encodes to Base64
- function readFileAsDataURL()
- {
- var fileReader = new FileReader(),
- root = getFileSystemRoot(),
- file;
- // set the callbacks
- fileReader.onloadstart = onFileEvent;
- fileReader.onload = onFileLoaded;
- fileReader.onprogress = onFileEvent;
- fileReader.onloadend = onFileEvent;
- fileReader.onabort = onFileEvent;
- fileReader.onerror = onFileError;
-
- // read the file
- file = new File();
- file.fullPath = root.toURI() + '/cordova.txt';
- fileReader.readAsDataURL(file);
- }
-
- // called when file is written
- function onFileWrite(event) {
- onFileEvent(event);
- console.log('FileWriter position=' +
- event.target.position + ", length=" + event.target.length);
- }
-
- // writes a text file to the device
- function writeFile()
- {
- // root file system entry
- var root = getFileSystemRoot(),
-
- // writes a file
- write_file = function(writer) {
- var lineCount = 1;
-
- // set the callbacks
- writer.onwritestart = onFileEvent;
- writer.onprogress = onFileEvent;
- writer.onwrite = onFileWrite;
- writer.onabort = onFileEvent;
- writer.onerror = onFileError;
- writer.onwriteend = function(event) {
- onFileEvent(event);
- lineCount += 1;
- if (lineCount <= 3) {
- // append a new line
- writer.write('Line ' + lineCount + '.\r\n');
- }
- else {
- alert(writer.fileName +
- ' length=' + writer.length +
- ', position=' + writer.position);
- }
- }
-
- // append
- writer.seek(writer.length);
-
- // write to file
- writer.write('Line ' + lineCount + '.\r\n');
- },
-
- // creates a FileWriter object
- create_writer = function(fileEntry) {
- fileEntry.createWriter(write_file, onFileSystemError);
- };
-
- // create a file and write to it
- root.getFile('cordova.txt', {create: true}, create_writer, onFileSystemError);
- }
-
- // truncates a file
- function truncateFile() {
- // root file system entry
- var root = getFileSystemRoot(),
-
- // truncates a file
- truncate_file = function(writer) {
- // set the callbacks
- writer.onwritestart = onFileEvent;
- writer.onprogress = onFileEvent;
- writer.onwrite = onFileWrite;
- writer.onabort = onFileEvent;
- writer.onerror = onFileError;
- writer.onwriteend = function(event) {
- onFileEvent(event);
- alert(writer.fileName +
- ' length=' + writer.length +
- ', position=' + writer.position);
- }
-
- // strip off the last 3 bytes of the file
- writer.truncate(writer.length-3);
- },
-
- // creates a FileWriter object
- create_writer = function(fileEntry) {
- fileEntry.createWriter(truncate_file, onFileSystemError);
- };
-
- // retrieve a file and truncate it
- root.getFile('cordova.txt', {create: false}, create_writer, onFileSystemError);
- }
-
- // retrieve root file system
- function getFileSystem(type, success, error)
- {
- var type = type || parseInt(document.getElementById('fsType').value),
- success = success || function(fileSystem) {
- // get the root file system entry
- var root = fileSystem.root;
-
- // display file system path
- document.getElementById('fsURI').value = root.toURI();
-
- // display root file system entry
- displayEntry(root);
- },
- fail = error || onFileSystemError;
-
- // get file system
- window.requestFileSystem(type, 0, success, fail);
- }
-
- // get file system path from input
- function getFileSystemURI()
- {
- return document.getElementById('fsURI').value;
- }
-
- // retrieve file system entry from URI
- function resolveFileSystemURI()
- {
- window.resolveLocalFileSystemURI(getFileSystemURI(), displayEntry, onFileSystemError);
- }
-
- // display file system entry
- function displayEntry(entry) {
- navigator.notification.alert(entry, null, 'File System Entry');
- }
-
- // retrieve file system entry metadata
- function getMetadata()
- {
- var displayMetadata = function(metadata) {
- navigator.notification.alert(metadata, null, 'Metadata');
- },
- callback = function(entry) {
- entry.getMetadata(displayMetadata, onFileSystemError);
- };
-
- // look up file system entry and display its metadata
- window.resolveLocalFileSystemURI(getFileSystemURI(), callback, onFileSystemError);
- }
-
- // retrieve parent directory
- function getParent()
- {
- var callback = function(entry) {
- entry.getParent(displayEntry, onFileSystemError);
- };
-
- // look up file system entry and display its parent
- window.resolveLocalFileSystemURI(getFileSystemURI(), callback, onFileSystemError);
- }
-
- // remove file system entry
- function removeFileEntry()
- {
- var callback = function(entry) {
- entry.remove(function() {
- navigator.notification.alert(entry.toURI(), null, 'Entry deleted');
- }, onFileSystemError);
- };
-
- // look up file system entry and attempt to delete it
- window.resolveLocalFileSystemURI(getFileSystemURI(), callback, onFileSystemError);
- }
-
- // remove directory recursively
- function removeDirectory(entry)
- {
- var callback = function(entry) {
- if (entry.constructor === DirectoryEntry) {
- entry.removeRecursively(function() {
- navigator.notification.alert(entry.toURI(), null, 'Entry deleted');
- }, onFileSystemError);
- }
- else {
- navigator.notification.alert(entry.toURI(), null, 'Not a directory');
- }
- };
-
- // look up directory entry and recursively remove it
- window.resolveLocalFileSystemURI(getFileSystemURI(), callback, onFileSystemError);
- }
-
- // retrieve or create a file on the file system
- function getFile()
- {
- // file path to append to file system root
- var filePath = document.getElementById('filePath').value,
- // get file entry
- callback = function(entry) {
- entry.getFile(
- // file path
- filePath,
- // options
- { create: true },
- // success callback
- displayEntry,
- // error callback
- onFileSystemError);
- };
-
- // look up file system entry
- window.resolveLocalFileSystemURI(getFileSystemURI(), callback, onFileSystemError);
- }
-
- // retrieve or create a directory on the file system
- function getDirectory()
- {
- // file path
- var filePath = document.getElementById('filePath').value,
- // get directory entry
- callback = function(entry) {
- entry.getDirectory(
- // file path
- filePath,
- // options
- { create: true },
- // success callback
- displayEntry,
- // error callback
- onFileSystemError);
- };
-
- // look up file system entry
- window.resolveLocalFileSystemURI(getFileSystemURI(), callback, onFileSystemError);
- }
-
- // list the contents of a directory
- function readEntries()
- {
- // file path
- var filePath = document.getElementById('filePath').value,
- // list directory entries
- callback = function(entry) {
- var reader = entry.createReader();
- reader.readEntries(
- function(entries) {
- entries[0].getParent(displayEntry, onFileSystemError);
- },
- onFileSystemError);
- };
-
- // look up file system entry
- window.resolveLocalFileSystemURI(getFileSystemURI(), callback, onFileSystemError);
- }
-
- // copy file system entry
- function copyTo()
- {
- // copy file system entry
- var callback = function(srcEntry) {
- var parent = document.getElementById('parent').value,
- newName = document.getElementById('newName').value,
- parentEntry = new Entry({fullPath: parent});
- srcEntry.copyTo(parentEntry, newName, displayEntry, onFileSystemError);
- };
-
- // look up file system entry and copy it to destination path
- window.resolveLocalFileSystemURI(getFileSystemURI(), callback, onFileSystemError);
- }
-
- // move file system entry
- function moveTo()
- {
- // move file system entry
- var callback = function(srcEntry) {
- var parent = document.getElementById('parent').value,
- newName = document.getElementById('newName').value,
- parentEntry = new Entry({fullPath: parent});
- srcEntry.moveTo(parentEntry, newName, displayEntry, onFileSystemError);
- };
-
- // look up file system entry and move it to destination path
- window.resolveLocalFileSystemURI(getFileSystemURI(), callback, onFileSystemError);
- }
-
- //---------------------------------------------------------------------
- // Media Capture
- //---------------------------------------------------------------------
-
- (function() {
- // display capture modes
- var displayCaptureModes = function() {
- var i, len, mode, modes = "Audio:\n";
- for (i = 0; len = navigator.device.capture.supportedAudioModes.length, i < len; i += 1) {
- mode = navigator.device.capture.supportedAudioModes[i];
- modes += mode.type + ';\n';
- }
- document.getElementById('supportedAudioModes').innerHTML = modes;
- modes = "Image:\n";
- for (i = 0; len = navigator.device.capture.supportedImageModes.length, i < len; i += 1) {
- mode = navigator.device.capture.supportedImageModes[i];
- modes += mode.type + ',' + mode.width + 'x' + mode.height + ';\n';
- }
- document.getElementById('supportedImageModes').innerHTML = modes;
- modes = "Video:\n";
- for (i = 0; len = navigator.device.capture.supportedVideoModes.length, i < len; i += 1) {
- mode = navigator.device.capture.supportedVideoModes[i];
- modes += mode.type + ',' + mode.width + 'x' + mode.height + ';\n';
- }
- document.getElementById('supportedVideoModes').innerHTML = modes;
- };
- document.addEventListener("deviceready", displayCaptureModes, true);
- }());
-
- function startAudioCapture()
- {
- navigator.device.capture.captureAudio(function(mediaFiles) {
- var i, file, len, msg = '';
- for (i = 0, len = mediaFiles.length; i < len; i += 1) {
- msg += mediaFiles[i].fullPath + '\n';
- }
- navigator.notification.alert(msg, null, 'Captured audio clips');
- }, function(error) {
- navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error');
- }, {limit:2});
- }
-
- function stopCaptures()
- {
- navigator.device.capture.stopCaptures();
- }
-
- function startImageCapture()
- {
- navigator.device.capture.captureImage(function(mediaFiles) {
- var i, file, len, msg = '';
- for (i = 0, len = mediaFiles.length; i < len; i += 1) {
- msg += mediaFiles[i].fullPath + '\n';
- }
- navigator.notification.alert(msg, null, 'Captured images');
- }, function(error) {
- navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error');
- }, {limit:2});
- }
-
- function startVideoCapture()
- {
- navigator.device.capture.captureVideo(function(mediaFiles) {
- var i, file, len, msg = '';
- for (i = 0, len = mediaFiles.length; i < len; i += 1) {
- msg += mediaFiles[i].fullPath + '\n';
- }
- navigator.notification.alert(msg, null, 'Captured video clips');
- }, function(error) {
- navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error');
- }, {limit:2});
- }
-
- </script>
- <title>Cordova API Sample</title>
- </head>
- <body onload="init()" onunload="unload()">
-
- <h3>window.device</h3>
- <p id="window.device.platform">[window.device.platform]</p>
- <p id="window.device.version">[window.device.version]</p>
- <p id="window.device.uuid">[window.device.uuid]</p>
- <p id="window.device.cordova">[window.device.cordova]</p>
-
- <h3>window.notification</h3>
- <input type="button" value="Beep" onclick="callBeep();return false;" />
- <input type="button" value="Vibrate" onclick="callVibrate();return false;" />
- <input type="button" value="Alert" onclick="callAlert();return false;" />
- <input type="button" value="Confirm" onclick="callConfirm();return false;" />
-
- <h3>navigator.network</h3>
- <p id="networkStatus">[navigator.network.connection.type]</p>
-
- <h3>navigator.geolocation</h3>
- <dl id="location-data">
- <dt>Latitude:</dt><dd id="lat"> </dd>
- <dt>Longitude:</dt><dd id="long"> </dd>
- </dl>
- <p>Timeout:<input type="text" id="geo_timeout" /></p>
- <p>Max age:<input type="text" id="geo_maxage" /></p>
- <input type="button" value="Get Location" onclick="getLocation();return false;" />
- <input type="button" value="Watch Location" onclick="watchLocation();return false;" />
- <input type="button" value="Clear Geo" onclick="clearLocationWatch();return false;" />
-
- <h3>navigator.accelerometer</h3>
- <dl id="accel-data">
- <dt>X:</dt><dd id="x"> </dd>
- <dt>Y:</dt><dd id="y"> </dd>
- <dt>Z:</dt><dd id="z"> </dd>
- </dl>
- <input type="button" value="Get Acceleration" onclick="getAcceleration();return false;" />
- <input type="button" value="Watch Acceleration" onclick="watchAcceleration();return false;" />
- <input type="button" value="Clear Watch" onclick="clearAccelWatch();return false;" />
-
- <h3>navigator.camera</h3>
- <input type="button" value="Get Photo (Data)" onclick="capturePhoto();return false;" />
- <input type="button" value="Get Photo (URI)" onclick="capturePhotoURI();return false;" />
- <img style="display:none;width:120px;height:120px;" id="cameraImage" src="" />
- <p id="uploadProgress"></p>
- <input style="display:none;" id="uploadButton" type="button" value="Upload" onclick="uploadImage();return false;" />
-
- <h3>navigator.contacts</h3>
- <input type="button" value="Create Contact" onclick="createContact();return false;" />
- <input type="button" value="Update Contact" onclick="updateContact();return false;" />
- <input type="button" value="Remove Contact" onclick="removeContact();return false;" />
- <p>
- <input type="text" id="filterText" />
- <input type="button" value="Find Contacts" onclick="findContacts();return false;" />
- </p>
-
- <h3>FileReader</h3>
- <input type="button" value="Read File (Text)" onclick="readFileAsText();return false;" />
- <input type="button" value="Read File (Base64)" onclick="readFileAsDataURL();return false;" />
- <h3>FileWriter</h3>
- <input type="button" value="Write File" onclick="writeFile();return false;" />
- <input type="button" value="Truncate File" onclick="truncateFile();return false;" />
- <h3>File and Directory</h3>
- <p>
- <select id="fsType">
- <option value="0">Temporary</option>
- <option value="1">Persistent</option>
- <option value="-1">Test</option>
- </select>
- <input type="button" value="Get File System" onclick="getFileSystem();return false;" />
- </p>
- <p>
- <label>URI:</label><input type="text" id="fsURI"/>
- <input type="button" value="Resolve URI" onclick="resolveFileSystemURI();return false;" />
- <input type="button" value="Get MetaData" onclick="getMetadata();return false;" />
- <input type="button" value="Get Parent" onclick="getParent();return false;" />
- <input type="button" value="Remove" onclick="removeFileEntry();return false;" />
- <input type="button" value="Remove Dir" onclick="removeDirectory();return false;" />
- </p>
- <p>
- <label id="uriLabel"><URI>/</label>
- <input type="text" id="filePath" />
- <input type="button" value="Get File" onclick="getFile();return false;" />
- <input type="button" value="Get Dir" onclick="getDirectory();return false;" />
- <input type="button" value="List" onclick="readEntries();return false;" />
- </p>
- <p>
- <label>parent:</label>
- <input type="text" id="parent" />
- <label>newName:</label>
- <input type="text" id="newName" />
- <input type="button" value="Copy To" onclick="copyTo();return false;" />
- <input type="button" value="Move To" onclick="moveTo();return false;" />
- </p>
-
- <h3>Media Capture</h3>
- <p id="supportedAudioModes">[supportedAudioModes]</p>
- <p id="supportedImageModes">[supportedImageModes]</p>
- <p id="supportedVideoModes">[supportedVideoModes]</p>
- <input type="button" value="Audio" onclick="startAudioCapture();return false;" />
- <input type="button" value="Image" onclick="startImageCapture();return false;" />
- <input type="button" value="Video" onclick="startVideoCapture();return false;" />
-
- </body>
-</html>