#!/bin/sh # # midp - midp application launcher # version 0.1 # # Copyright (C) 2006 hdluc@yahoo.com # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # ###################################################################### # variables TITLE="MIDP Launcher" BASE=/opt/QtPalmtop/midp # specify the game file locations GAME_LOC=/home/zaurus/Documents/games/java GAME=$1 # specify the qshdlg prefix and control files export QSHDLG_APP=`basename $0` INPUT=/var/spool/qshdlg/input_$QSHDLG_APP OUTPUT=/var/spool/qshdlg/output_$QSHDLG_APP CONTROL=/var/spool/qshdlg/control_$QSHDLG_APP # specify the library locations ME4SE=$BASE/me4se.jar MIDPX=$BASE/midp-full.jar EXTRA=$BASE/png.jar:$BASE/mmapi.jar:$BASE/nokiaui.jar:$BASE/siemensapi.jar # check that a JVM is available, otherwise show error message if [ "`which evm`" = "" ] && [ ! -f /home/QtPalmtop/j2me/bin/cvm ]; then qshdlg message -h 100 -t "$TITLE: Error" -d "Error: No j2me runtime found" -n -v OK exit 1 fi # show selection dialog if no jar file was passed in as argument if [ "$GAME" = "" ] && [ -d $GAME_LOC ]; then # display a selection box # qshdlg select -t "$TITLE: Game Selector" & # display a custom selection box with message window qshdlg custom -A -C message -f lcfont -t "$TITLE: Game Selector" -c eucJP & # wait until control initialisation is completed while [ ! -p $CONTROL ] do echo >/dev/null done # display status message echo "$TITLE initialised. loading items ..." |tee $OUTPUT # populate selection list for FILE in `ls -1 $GAME_LOC/*.jar` do if [ -f $FILE ]; then echo 'item(QString)' "`basename $FILE`" > $CONTROL fi done echo 'showSelect()' > $CONTROL # display status message echo "item list loaded." |tee $OUTPUT # wait for user input/selection while [ ! -p $INPUT ] do echo >/dev/null done read RET < $INPUT echo "$RET was selected." |tee $OUTPUT # terminate qshdlg echo 'reject()' > $CONTROL # check return value if [ "$RET" = "" ]; then echo "[`basename $0`] no game selected!" exit 0 fi GAME=${GAME_LOC}/${RET} echo "$GAME was selected." fi # load the specified/selected game if [ "$GAME" = "" ]; then exit 0; fi echo "[`basename $0`] launching `basename ${GAME}`" # ensure required library exists if [ ! -f $ME4SE ]; then echo "error! `basename $ME4SE` not found!" exit 1 fi if [ ! -f $MIDPX ]; then echo "error! `basename $MIDPX` not found!" exit 1 fi if [ "`which unzip`" = "" ]; then echo "error! unzip not found!" exit 1 fi if [ "`which awk`" = "" ]; then echo "error! awk not found!" exit 1 fi # determine main class name echo "[`basename $0`] loading `basename ${GAME}`" unzip -oq ${GAME} META-INF/MANIFEST.MF -d /tmp/ if [ -f /tmp/META-INF/MANIFEST.MF ]; then APPLET=`grep MIDlet-1 /tmp/META-INF/MANIFEST.MF|cut -d, -f3|awk '{print $1}'` rm -rf /tmp/META-INF else echo "error! cannot find main class!" exit 1 fi # launch applet echo "[`basename $0`] launching ${APPLET}" if [ "`which evm`" != "" ]; then evm -XappName=MIDP -cp $ME4SE:$MIDPX:$GAME org.me4se.MIDletRunner $APPLET else /home/QtPalmtop/j2me/bin/cvm -XappName=MIDP -Djava.class.path=$ME4SE:$MIDPX:$EXTRA:$GAME org.me4se.MIDletRunner $APPLET fi