<ant dir="javame" target="build"/>
<ant dir="javase" target="build"/>
<ant dir="android" target="package"/>
+ <ant dir="rim" target="build"/>
</target>
<target name="buildwithoutj2me">
<ant dir="javame" target="clean"/>
<ant dir="javase" target="clean"/>
<ant dir="android" target="clean"/>
+ <ant dir="rim" target="clean"/>
</target>
<target name="test">
<include name="core/**"/>
<include name="javame/**"/>
<include name="javase/**"/>
- <!-- Only include the build script for now -->
<include name="rim/build.xml"/>
+ <include name="rim/src/**"/>
+ <include name="rim/res/**"/>
+ <include name="rim/BarcodeReader.rapc"/>
<include name="docs/**"/>
</zipfileset>
</zip>
<pathelement location="core/src"/>
<pathelement location="javame/src"/>
<pathelement location="javase/src"/>
+ <pathelement location="rim/src"/>
</sourcepath>
<classpath>
<pathelement location="${WTK-home}/lib/cldcapi11.jar"/>
<pathelement location="${WTK-home}/lib/mmapi.jar"/>
<pathelement location="${WTK-home}/lib/jsr234.jar"/>
<pathelement location="${android-home}/android.jar"/>
+ <pathelement location="${BB-JDK-home}/lib/net_rim_api.jar"/>
</classpath>
</javadoc>
</target>
fork="true">
<classpath refid="wtk-build-path"/>
</javac>
+ <jar jarfile="javame.jar" basedir="build" level="9"/>
</target>
<target name="compile-basic" depends="init">
<classpath refid="wtk-build-path"/>
<exclude name="com/google/zxing/client/j2me/AdvancedMultimediaManager.java"/>
</javac>
+ <jar jarfile="javame-basic.jar" basedir="build" level="9"/>
</target>
<target name="package">
<unzip src="../core/core.jar" dest="build"/>
<mkdir dir="build-j2me"/>
- <exec executable="${WTK-home}/bin/preverify1.1">
+ <exec executable="${WTK-home}/bin/preverify1.1" failonerror="true">
<arg line="-classpath ${preverify-classpath} -d build-j2me build"/>
</exec>
--- /dev/null
+Manifest-Version: 1.0
+RIM-COD-Module-Name: BarcodeReader
+RIM-COD-Module-Dependencies: net_rim_cldc,net_rim_bbapi_invoke
+MIDlet-Jar-Size: 31621
+MIDlet-1: BarcodeReader,,com.google.zxing.client.rim.ZXingUIApp
+RIM-COD-Creation-Time: 1203088206
+MIDlet-Jar-URL: BarcodeReader.jar
+RIM-COD-URL: BarcodeReader.cod
+RIM-COD-SHA1: 82 7e 06 9b 39 6e 8c 49 33 54 37 1d 6d 3d 7b 07 d1 86 c8 d3
+RIM-COD-Size: 56372
+MicroEdition-Configuration: CLDC-1.1
+MIDlet-Version: 0.5
+MIDlet-Name: BarcodeReader
+MIDlet-Vendor: ZXing Project
+MicroEdition-Profile: MIDP-2.0
+RIM-MIDlet-Flags-1: 0
<project name="rim" default="build">
<property file="../build.properties"/>
+ <property name="rim-api-jar" value="${BB-JDK-home}/lib/net_rim_api.jar"/>
<target name="init">
<tstamp/>
</not>
</condition>
</fail>
- <fail message="Please build target 'build-basic' in 'javame' first">
+ <fail message="Please set 'WTK-home' in build.properties">
<condition>
<not>
- <available file="../javame/BarcodeReaderBasic.jar" type="file"/>
+ <available file="${WTK-home}" type="dir"/>
+ </not>
+ </condition>
+ </fail>
+ <fail message="Please build 'core' first">
+ <condition>
+ <not>
+ <available file="../core/core.jar" type="file"/>
+ </not>
+ </condition>
+ </fail>
+ <fail message="Please build 'build-basic' in 'javame' first">
+ <condition>
+ <not>
+ <available file="../javame/javame-basic.jar" type="file"/>
</not>
</condition>
</fail>
</target>
- <target name="build" depends="init,clean">
- <copy file="../javame/BarcodeReaderBasic.jad" todir="."/>
+ <target name="build" depends="init">
+
+ <mkdir dir="build"/>
+ <javac srcdir="src"
+ destdir="build"
+ source="1.2"
+ target="1.2"
+ bootclasspath="${rim-api-jar}"
+ optimize="true"
+ debug="true"
+ deprecation="true"
+ fork="true">
+ <classpath>
+ <pathelement location="../core/core.jar"/>
+ <pathelement location="../javame/javame-basic.jar"/>
+ </classpath>
+ </javac>
+
+ <unzip src="../core/core.jar" dest="build"/>
+ <unzip src="../javame/javame-basic.jar" dest="build"/>
+
+ <mkdir dir="build-j2me"/>
+ <exec executable="${WTK-home}/bin/preverify1.1" failonerror="true">
+ <arg line="-classpath ${rim-api-jar} -d build-j2me build"/>
+ </exec>
+
+ <jar jarfile="temp.jar" basedir="build-j2me"/>
<java jar="${BB-JDK-home}/bin/rapc.jar" fork="true">
- <arg value="import=${BB-JDK-home}/lib/net_rim_api.jar"/>
- <arg value="codename=BarcodeReaderBasic"/>
- <arg value="-midlet"/>
- <arg value="jad=BarcodeReaderBasic.jad"/>
- <arg value="../javame/BarcodeReaderBasic.jar"/>
+ <arg value="-quiet"/>
+ <arg value="import=${rim-api-jar}"/>
+ <arg value="jad=BarcodeReader.rapc"/>
+ <arg value="codename=BarcodeReader"/>
+ <arg value="temp.jar"/>
</java>
</target>
<target name="clean">
- <delete dir="." includes="BarcodeReader*"/>
+ <delete dir="build"/>
+ <delete dir="build-j2me"/>
+ <delete file="temp.jar"/>
+ <delete file="BarcodeReader.cod"/>
+ <delete file="BarcodeReader.csl"/>
+ <delete file="BarcodeReader.cso"/>
+ <delete file="BarcodeReader.debug"/>
+ <delete file="BarcodeReader.jar"/>
</target>
</project>
--- /dev/null
+/*\r
+ * Copyright 2008 Google Inc.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package com.google.zxing.client.rim;\r
+\r
+import net.rim.device.api.io.file.FileSystemJournal;\r
+import net.rim.device.api.io.file.FileSystemJournalEntry;\r
+import net.rim.device.api.io.file.FileSystemJournalListener;\r
+\r
+/**\r
+ * @author Sean Owen (srowen@google.com)\r
+ */\r
+final class ImageCapturedJournalListener implements FileSystemJournalListener {\r
+\r
+ private final ZXingMainScreen screen;\r
+ private long lastUSN;\r
+\r
+ ImageCapturedJournalListener(ZXingMainScreen screen) {\r
+ this.screen = screen;\r
+ }\r
+\r
+ public void fileJournalChanged() {\r
+ long nextUSN = FileSystemJournal.getNextUSN();\r
+ for (long lookUSN = nextUSN - 1; lookUSN >= lastUSN; --lookUSN) {\r
+ FileSystemJournalEntry entry = FileSystemJournal.getEntry(lookUSN);\r
+ if (entry == null) {\r
+ break;\r
+ }\r
+ if (entry.getEvent() == FileSystemJournalEntry.FILE_ADDED) {\r
+ screen.handleFile(entry.getPath());\r
+ }\r
+ }\r
+ lastUSN = nextUSN;\r
+ }\r
+\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright 2008 Google Inc.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package com.google.zxing.client.rim;\r
+\r
+import com.google.zxing.MonochromeBitmapSource;\r
+import com.google.zxing.MultiFormatReader;\r
+import com.google.zxing.Reader;\r
+import com.google.zxing.ReaderException;\r
+import com.google.zxing.Result;\r
+import com.google.zxing.client.j2me.LCDUIImageMonochromeBitmapSource;\r
+import net.rim.blackberry.api.invoke.CameraArguments;\r
+import net.rim.blackberry.api.invoke.Invoke;\r
+import net.rim.device.api.system.Characters;\r
+import net.rim.device.api.ui.UiApplication;\r
+import net.rim.device.api.ui.component.Dialog;\r
+import net.rim.device.api.ui.component.LabelField;\r
+import net.rim.device.api.ui.container.MainScreen;\r
+\r
+import javax.microedition.io.Connector;\r
+import javax.microedition.io.file.FileConnection;\r
+import javax.microedition.lcdui.Image;\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+\r
+/**\r
+ * @author Sean Owen (srowen@google.com)\r
+ */\r
+final class ZXingMainScreen extends MainScreen {\r
+\r
+ private final ZXingUIApp app;\r
+ private final ImageCapturedJournalListener captureListener;\r
+\r
+ ZXingMainScreen() {\r
+ setTitle("Barcode Reader");\r
+ add(new LabelField("ZXing"));\r
+ app = (ZXingUIApp) UiApplication.getUiApplication();\r
+ captureListener = new ImageCapturedJournalListener(this);\r
+ app.addFileSystemJournalListener(captureListener);\r
+ }\r
+\r
+ public boolean keyChar(char c, int status, int time) {\r
+ if (c == Characters.ENTER) {\r
+ Invoke.invokeApplication(Invoke.APP_TYPE_CAMERA, new CameraArguments());\r
+ return true;\r
+ } else {\r
+ return super.keyChar(c, status, time);\r
+ }\r
+ }\r
+\r
+ public void close() {\r
+ app.removeFileSystemJournalListener(captureListener);\r
+ super.close();\r
+ }\r
+\r
+ private void showMessage(String msg) {\r
+ synchronized (app.getAppEventLock()) {\r
+ Dialog.alert(msg);\r
+ }\r
+ }\r
+\r
+ void handleFile(String path) {\r
+ if (path.endsWith(".jpg") && path.indexOf("IMG") >= 0) {\r
+ app.requestForeground();\r
+ try {\r
+ FileConnection file = null;\r
+ InputStream is = null;\r
+ Image capturedImage;\r
+ try {\r
+ file = (FileConnection) Connector.open("file://" + path);\r
+ is = file.openInputStream();\r
+ capturedImage = Image.createImage(is);\r
+ } finally {\r
+ if (is != null) {\r
+ try {\r
+ is.close();\r
+ } catch (IOException ioe ) {\r
+ // continue\r
+ }\r
+ }\r
+ if (file != null) {\r
+ try {\r
+ file.close();\r
+ } catch (IOException ioe ) {\r
+ // continue\r
+ }\r
+ }\r
+ }\r
+ MonochromeBitmapSource source = new LCDUIImageMonochromeBitmapSource(capturedImage);\r
+ Reader reader = new MultiFormatReader();\r
+ Result result = reader.decode(source);\r
+ try {\r
+ file.delete();\r
+ } catch (IOException ioe) {\r
+ // continue\r
+ }\r
+ showMessage(result.getText());\r
+ } catch (IOException ioe) {\r
+ showMessage(ioe.getMessage());\r
+ } catch (ReaderException re) {\r
+ showMessage("Sorry, no barcode was found.");\r
+ }\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright 2008 Google Inc.\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+package com.google.zxing.client.rim;\r
+\r
+import net.rim.device.api.ui.UiApplication;\r
+\r
+/**\r
+ * @author Sean Owen (srowen@google.com)\r
+ */\r
+public final class ZXingUIApp extends UiApplication {\r
+\r
+ public static void main(String[] args) {\r
+ new ZXingUIApp().enterEventDispatcher();\r
+ }\r
+\r
+ ZXingUIApp() {\r
+ pushScreen(new ZXingMainScreen());\r
+ }\r
+\r
+}\r