# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1276252424 -10800 # Node ID 85266cc22c7fa891a0ebb12cb776a4fef3affc9d # Parent dc7c549001d500b60d746e14abd9a0336ad28d91 Revision: v2.2.1 Kit: 2010123 diff -r dc7c549001d5 -r 85266cc22c7f build/Makefile.comp --- a/build/Makefile.comp Thu May 27 12:49:31 2010 +0300 +++ b/build/Makefile.comp Fri Jun 11 13:33:44 2010 +0300 @@ -179,11 +179,11 @@ build_native: $(PHASEINFO) - $(SBS) -c $(PLATFORM)_$(CFG) BUILD + $(SBS) -c $(PLATFORM)_$(CFG) -fastbuild: export java +fastbuild: java $(PHASEINFO) - $(SBS) -c $(PLATFORM)_$(CFG) TARGET + $(SBS) -c $(PLATFORM)_$(CFG) build_clean_native: $(PHASEINFO) diff -r dc7c549001d5 -r 85266cc22c7f build/Makefile.project --- a/build/Makefile.project Thu May 27 12:49:31 2010 +0300 +++ b/build/Makefile.project Fri Jun 11 13:33:44 2010 +0300 @@ -180,7 +180,7 @@ # Following flag enables application notifications to AppArc. PROJECT_DEFINES += RD_JAVA_USIF_NOTIFY_APP_ARC # Following flag enables installation progress notifications through USIF. - #PROJECT_DEFINES += RD_JAVA_USIF_NOTIFY_PROGRESS + PROJECT_DEFINES += RD_JAVA_USIF_NOTIFY_PROGRESS endif # Java proximity Listener support exsist in 9.2 only(can not be used if 5.0 untill IAD dependecy mentioned) diff -r dc7c549001d5 -r 85266cc22c7f build/Makefile.subsystem --- a/build/Makefile.subsystem Thu May 27 12:49:31 2010 +0300 +++ b/build/Makefile.subsystem Fri Jun 11 13:33:44 2010 +0300 @@ -206,7 +206,7 @@ $(SBS) -c $(PLATFORM)_$(CFG) fastbuild: export java - $(SBS) -c $(PLATFORM)_$(CFG) TARGET + $(SBS) -c $(PLATFORM)_$(CFG) clean_native: $(PHASEINFO) diff -r dc7c549001d5 -r 85266cc22c7f build/bld.inf --- a/build/bld.inf Thu May 27 12:49:31 2010 +0300 +++ b/build/bld.inf Fri Jun 11 13:33:44 2010 +0300 @@ -42,6 +42,10 @@ ../rom/tckrunnerodclist30 /epoc32/release/winscw/urel/z/resource/java/tckrunnerodclist ../rom/tckrunnerodclist30 /epoc32/data/z/resource/java/tckrunnerodclist +../rom/javacontrolpanelodclist30 /epoc32/release/winscw/udeb/z/resource/java/javacontrolpanelodclist +../rom/javacontrolpanelodclist30 /epoc32/release/winscw/urel/z/resource/java/javacontrolpanelodclist +../rom/javacontrolpanelodclist30 /epoc32/data/z/resource/java/javacontrolpanelodclist + ../rom/javalocalization_3_1.iby LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(javalocalization.iby) #else // RD_JAVA_UI_QT @@ -61,6 +65,10 @@ ../rom/tckrunnerodclist /epoc32/release/winscw/urel/z/resource/java/tckrunnerodclist ../rom/tckrunnerodclist /epoc32/data/z/resource/java/tckrunnerodclist +../rom/javacontrolpanelodclist /epoc32/release/winscw/udeb/z/resource/java/javacontrolpanelodclist +../rom/javacontrolpanelodclist /epoc32/release/winscw/urel/z/resource/java/javacontrolpanelodclist +../rom/javacontrolpanelodclist /epoc32/data/z/resource/java/javacontrolpanelodclist + ../rom/javalocalization_2_1.iby LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(javalocalization.iby) #endif // RD_JAVA_UI_QT diff -r dc7c549001d5 -r 85266cc22c7f build/buildutils/checkcopyrights.py --- a/build/buildutils/checkcopyrights.py Thu May 27 12:49:31 2010 +0300 +++ b/build/buildutils/checkcopyrights.py Fri Jun 11 13:33:44 2010 +0300 @@ -13,48 +13,54 @@ # Contributors: # # Description: -# Checks that all the source files have a proper copyright header. +# Checks that all the source files have a proper EPL copyright header. # Ignores number of known 3rd party source files and directories. # -# Run this script on a clean workarea in order to avoid warnings -# about exported files and qmake generated files. +# Run this script on a clean workarea in order to avoid warnings +# about exported files and qmake generated files. # -# The excluded directories should be checked every now and then -# so that there won't be other problems (like files without any -# header). +# The excluded directories should be checked every now and then +# so that there won't be other problems (like files without any header). import sys, os, re # Specify here the file types to be checked checkedFileTypes = [".cpp", ".h", ".java", ".py", ".mk"] -# Include here the directories to be ignored -ignoredDirectories = [ - "javaextensions\\bluetooth\\bluecove", # Bluecove - "javacommons\\jvms\\j9\\s60\\inc", # IBM J9 - "javauis\\eswt_akn", # eSWT checked separately - "javauis\\eswt_qt", # eSWT checked separately - "javauis\\tsrc\\fute\\eswt\\", # eSWT checked separately - "javaextensions\\webservices", # Webservices not delivered - "jrt\\tools", # Tools not delivered - "\\internal" # Internal directories not delivered - ] -# Include here any individual files to be ignored -ignoredFiles = [ - "javacommons\\jvms\\cldc_1.1.1\\javasrc\\java\\util\\Timer.java", # Apache license - "javacommons\\jvms\\cldc_1.1.1\\javasrc\\java\\util\\TimerTask.java", # Apache license - "javacommons\\jvms\\cldc_1.1.1\\tsrc\\javasrc\\com\\nokia\\mj\\test\\java\\util\\TimerTaskTest.java", # Apache license - "javacommons\\jvms\\cldc_1.1.1\\tsrc\\javasrc\\com\\nokia\\mj\\test\\java\\util\\TimerTest.java", # Apache license - "javacommons\\utils\\inc\\convertutf.h", # Unicode Inc. - "javacommons\\utils\\src\\convertutf.cpp" # Unicode Inc. -] - -# The copyright text to be checked -copyrightText = "Nokia Corporation and/or its subsidiary(-ies)" +# The copyright texts to be searched for +copyrightText1 = "Nokia Corporation and/or its subsidiary(-ies)" +copyrightText2 = "Eclipse Public License v1.0" def main(): + + root = sys.argv[1] + if root[-1] != '\\': + root = root + '\\' + + # Include here the directories to be ignored + ignoredDirectories = [ + root + "javaextensions\\bluetooth\\bluecove", # Bluecove + root + "javacommons\\jvms\\j9\\s60\\inc", # IBM J9 + root + "javauis\\eswt_akn", # eSWT checked separately + root + "javauis\\eswt_qt", # eSWT checked separately + root + "javauis\\tsrc\\fute\\eswt\\", # eSWT checked separately + root + "javaextensions\\webservices", # Webservices not delivered + root + "tools", # Tools not delivered + "\\internal" # Internal directories not delivered + ] + + # Include here any individual files to be ignored + ignoredFiles = [ + root + "javacommons\\jvms\\cldc_1.1.1\\javasrc\\java\\util\\Timer.java", # Apache license + root + "javacommons\\jvms\\cldc_1.1.1\\javasrc\\java\\util\\TimerTask.java", # Apache license + root + "javacommons\\jvms\\cldc_1.1.1\\tsrc\\javasrc\\com\\nokia\\mj\\test\\java\\util\\TimerTaskTest.java", # Apache license + root + "javacommons\\jvms\\cldc_1.1.1\\tsrc\\javasrc\\com\\nokia\\mj\\test\\java\\util\\TimerTest.java", # Apache license + root + "javacommons\\utils\\inc\\convertutf.h", # Unicode Inc. + root + "javacommons\\utils\\src\\convertutf.cpp" # Unicode Inc. + ] + def visitFun(arg, dirname, names): @@ -94,16 +100,29 @@ # print "Ignoring file", f continue - # Check if the file contains the copyright text + # Check if the file contains the copyright texts try: file = open(fname) + + # Search for the first text found = False line = file.readline() while line != "": - if copyrightText in line: + if copyrightText1 in line: found = True break; - line = file.readline() + line = file.readline() + + # Search the second copyright text as well + if found: + found = False + line = file.readline() + while line != "": + if copyrightText2 in line: + found = True + break; + line = file.readline() + file.close() except IOError: @@ -112,8 +131,8 @@ if not found: print fname continue - - os.path.walk(sys.argv[1], visitFun, None) + + os.path.walk(root, visitFun, None) if __name__ == "__main__": diff -r dc7c549001d5 -r 85266cc22c7f build/buildutils/checkfilenames.py --- a/build/buildutils/checkfilenames.py Thu May 27 12:49:31 2010 +0300 +++ b/build/buildutils/checkfilenames.py Fri Jun 11 13:33:44 2010 +0300 @@ -42,7 +42,7 @@ ".cvsignore", ".dat", ".dcf", ".def", ".defs", ".dll", ".der", ".doc", ".dr", ".dso", ".dsp", ".dsw", ".dtd", ".emx", ".exe", ".flm", ".gcfml", ".gif", - ".h", ".hrh", ".html", ".iby", ".inf", ".ini", ".inl", + ".h", ".hrh", ".htm", ".html", ".iby", ".inf", ".ini", ".inl", ".jad", ".jar", ".java", ".javaversion", ".jpeg", ".jpg", ".js", ".jsp", ".jupiter", ".key", ".ks", ".launch", ".lib", ".loc", ".log", ".mak", ".make", "makefile", "makefile_akn", "makefile_qt", "manifest", ".mbm", ".mdl", @@ -64,6 +64,7 @@ # Other peculiar filenames: "installerodclist", "installerodclist30", "midpodclist", "midpodclist30", "notice", "package-list", "tckrunnerodclist", "tckrunnerodclist30", "unknowncert","midprootslist", + "javacontrolpanelodclist", "javacontrolpanelodclist30", ] # Command line options. diff -r dc7c549001d5 -r 85266cc22c7f build/buildutils/checkjavapackages.py --- a/build/buildutils/checkjavapackages.py Thu May 27 12:49:31 2010 +0300 +++ b/build/buildutils/checkjavapackages.py Fri Jun 11 13:33:44 2010 +0300 @@ -16,13 +16,17 @@ # Checks that all the java source files declare a package and that # the directory within a java source file is located corresponds # properly to the package. +# +# Ignores tsrc directories unless the option -all is given. import sys, os, re def main(): - files = [] + root = sys.argv[1] + all = len(sys.argv) > 2 and sys.argv[2] == '-all' + # Create a reg exp matching to "package x.y.z;" with whitespace ignored regex = re.compile("\\s*package\\s*([\\w.]*);.*", re.IGNORECASE) @@ -31,8 +35,12 @@ # Skip SVN directories if dirname.find("\\.svn") != -1: - return names + return + # Skip tsrc + if not all and dirname.find("\\tsrc") != -1: + return + for f in names: if not f.endswith(".java"): continue @@ -63,7 +71,7 @@ except IOError: print "Error reading the file " + fname - os.path.walk(sys.argv[1], visitFun, files) + os.path.walk(sys.argv[1], visitFun, None) if __name__ == "__main__": diff -r dc7c549001d5 -r 85266cc22c7f build/exports.inf --- a/build/exports.inf Thu May 27 12:49:31 2010 +0300 +++ b/build/exports.inf Fri Jun 11 13:33:44 2010 +0300 @@ -40,6 +40,10 @@ ../rom/tckrunnerodclist30 /epoc32/release/winscw/urel/z/resource/java/tckrunnerodclist ../rom/tckrunnerodclist30 /epoc32/data/z/resource/java/tckrunnerodclist +../rom/javacontrolpanelodclist30 /epoc32/release/winscw/udeb/z/resource/java/javacontrolpanelodclist +../rom/javacontrolpanelodclist30 /epoc32/release/winscw/urel/z/resource/java/javacontrolpanelodclist +../rom/javacontrolpanelodclist30 /epoc32/data/z/resource/java/javacontrolpanelodclist + ../rom/javalocalization_3_1.iby LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(javalocalization.iby) #else // RD_JAVA_UI_QT @@ -59,6 +63,10 @@ ../rom/tckrunnerodclist /epoc32/release/winscw/urel/z/resource/java/tckrunnerodclist ../rom/tckrunnerodclist /epoc32/data/z/resource/java/tckrunnerodclist +../rom/javacontrolpanelodclist /epoc32/release/winscw/udeb/z/resource/java/javacontrolpanelodclist +../rom/javacontrolpanelodclist /epoc32/release/winscw/urel/z/resource/java/javacontrolpanelodclist +../rom/javacontrolpanelodclist /epoc32/data/z/resource/java/javacontrolpanelodclist + ../rom/javalocalization_2_1.iby LANGUAGE_APP_LAYER_IBY_EXPORT_PATH(javalocalization.iby) #endif // RD_JAVA_UI_QT diff -r dc7c549001d5 -r 85266cc22c7f build/makefile.javaversion --- a/build/makefile.javaversion Thu May 27 12:49:31 2010 +0300 +++ b/build/makefile.javaversion Fri Jun 11 13:33:44 2010 +0300 @@ -1,6 +1,2 @@ # Set Java version (must be dot separated, without spaces) -ifdef RD_JAVA_S60_RELEASE_5_0_IAD - JAVA_VERSION = 2.1.26 -else - JAVA_VERSION = 2.1.26 -endif +JAVA_VERSION = 2.2.1 diff -r dc7c549001d5 -r 85266cc22c7f build/sis/java_2_0.pkg --- a/build/sis/java_2_0.pkg Thu May 27 12:49:31 2010 +0300 +++ b/build/sis/java_2_0.pkg Fri Jun 11 13:33:44 2010 +0300 @@ -102,6 +102,7 @@ "\epoc32\data\z\resource\java\midpodclist"-"c:\resource\java\midpodclist" "\epoc32\data\z\resource\java\tckrunnerodclist"-"c:\resource\java\tckrunnerodclist" "\epoc32\data\z\resource\java\installerodclist"-"c:\resource\java\installerodclist" +"\epoc32\data\z\resource\java\javacontrolpanelodclist"-"c:\resource\java\javacontrolpanelodclist" @@ -378,7 +379,7 @@ "\epoc32\release\armv5\urel\z\resource\java\jvm\lib\jrt\javawmamms.odc"-"c:\resource\java\jvm\lib\jrt\javawmamms.odc" "\epoc32\release\armv5\urel\z\resource\java\jvm\lib\jrt\tckrunner.odc"-"c:\resource\java\jvm\lib\jrt\tckrunner.odc" - +"\epoc32\release\armv5\urel\z\resource\java\jvm\lib\jrt\javacontrolpanel.odc"-"c:\resource\java\jvm\lib\jrt\javacontrolpanel.odc" ; Misc dlls @@ -491,6 +492,7 @@ "\epoc32\release\armv5\urel\javacaptain_ext_pushregistryplugin.dll" -"c:\sys\bin\javacaptain_ext_pushregistryplugin.dll" "\epoc32\release\armv5\urel\javacaptain_ext_storageserverplugin.dll" -"c:\sys\bin\javacaptain_ext_storageserverplugin.dll" "\epoc32\release\armv5\urel\javacaptain_ext_btdeviceclassmanager.dll" -"c:\sys\bin\javacaptain_ext_btdeviceclassmanager.dll" +"\epoc32\release\armv5\urel\javacaptain_ext_autostarter.dll" -"c:\sys\bin\javacaptain_ext_autostarter.dll" ; PLUGIN_ID_JAVA_CERT_STORE_EXTENSION_C = 7 "\epoc32\release\armv5\urel\javacaptain_ext_ondemand_7.dll" -"c:\sys\bin\javacaptain_ext_ondemand_7.dll" #ifdef RD_JAVA_MIDPRMS_DB @@ -663,6 +665,7 @@ "\epoc32\data\z\resource\plugins\LCDC64K.rsc"-"c:\resource\plugins\LCDC64K.rsc" "\epoc32\release\armv5\urel\lcdgdrv.dll"-"c:\sys\bin\lcdgdrv.dll" "\epoc32\release\armv5\urel\lcdgdrvi.dll"-"c:\sys\bin\lcdgdrvi.dll" +"\epoc32\release\armv5\urel\lcduiphysicswrap.dll"-"c:\sys\bin\lcduiphysicswrap.dll" #ifdef RD_JAVA_S60_RELEASE_5_0_IAD "\epoc32\release\armv5\urel\midp2permissiondb.dll"-"c:\sys\bin\midp2permissiondb.dll" "\epoc32\release\armv5\urel\midp2userpreferences.dll"-"c:\sys\bin\midp2userpreferences.dll" diff -r dc7c549001d5 -r 85266cc22c7f build/sis/java_3_1.pkg --- a/build/sis/java_3_1.pkg Thu May 27 12:49:31 2010 +0300 +++ b/build/sis/java_3_1.pkg Fri Jun 11 13:33:44 2010 +0300 @@ -55,7 +55,7 @@ "\epoc32\data\z\resource\java\midpodclist"-"c:\resource\java\midpodclist" "\epoc32\data\z\resource\java\tckrunnerodclist"-"c:\resource\java\tckrunnerodclist" "\epoc32\data\z\resource\java\installerodclist"-"c:\resource\java\installerodclist" - +"\epoc32\data\z\resource\java\javacontrolpanelodclist"-"c:\resource\java\javacontrolpanelodclist" ; Dlls containing java byte code and their odc files "\epoc32\release\armv5\urel\javabluecove.dll"-"c:\sys\bin\javabluecove.dll" @@ -158,12 +158,12 @@ "\epoc32\release\armv5\urel\z\resource\java\jvm\lib\jrt\javawmamms.odc"-"c:\resource\java\jvm\lib\jrt\javawmamms.odc" "\epoc32\release\armv5\urel\z\resource\java\jvm\lib\jrt\tckrunner.odc"-"c:\resource\java\jvm\lib\jrt\tckrunner.odc" +"\epoc32\release\armv5\urel\z\resource\java\jvm\lib\jrt\javacontrolpanel.odc"-"c:\resource\java\jvm\lib\jrt\javacontrolpanel.odc" ; Misc dlls -"\epoc32\release\armv5\urel\ifeui.dll"-"c:\sys\bin\ifeui.dll" "\epoc32\release\armv5\urel\javaappschemeplugin.dll"-"c:\sys\bin\javaappschemeplugin.dll" "\epoc32\release\armv5\urel\javabtl2capscplugin.dll"-"c:\sys\bin\javabtl2capscplugin.dll" "\epoc32\release\armv5\urel\javabtsppscplugin.dll"-"c:\sys\bin\javabtsppscplugin.dll" @@ -203,6 +203,7 @@ "\epoc32\release\armv5\urel\javacaptain_ext_pushregistryplugin.dll" -"c:\sys\bin\javacaptain_ext_pushregistryplugin.dll" "\epoc32\release\armv5\urel\javacaptain_ext_storageserverplugin.dll" -"c:\sys\bin\javacaptain_ext_storageserverplugin.dll" "\epoc32\release\armv5\urel\javacaptain_ext_btdeviceclassmanager.dll" -"c:\sys\bin\javacaptain_ext_btdeviceclassmanager.dll" +"\epoc32\release\armv5\urel\javacaptain_ext_autostarter.dll" -"c:\sys\bin\javacaptain_ext_autostarter.dll" ; PLUGIN_ID_JAVA_CERT_STORE_EXTENSION_C = 7 "\epoc32\release\armv5\urel\javacaptain_ext_ondemand_7.dll" -"c:\sys\bin\javacaptain_ext_ondemand_7.dll" #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK @@ -213,7 +214,6 @@ #endif ; resources -"\epoc32\data\z\resource\plugins\ifeui.rsc" -"c:\resource\plugins\ifeui.rsc" "\epoc32\data\z\resource\plugins\javaappschemeplugin.rsc" -"c:\resource\plugins\javaappschemeplugin.rsc" "\epoc32\winscw\c\private\102033E6\installer\inst_plugins.cfg"-"c:\private\102033E6\installer\inst_plugins.cfg" "\epoc32\data\Z\Resource\versions\java.txt"-"c:\resource\versions\java.txt" @@ -332,8 +332,8 @@ ;"\epoc32\release\armv5\urel\javam3g.dll"-"c:\sys\bin\javam3g.dll" ;"\epoc32\release\armv5\urel\z\resource\java\jvm\lib\jrt\javam3g.odc"-"c:\resource\java\jvm\lib\jrt\javam3g.odc" -;"\epoc32\release\armv5\urel\javanokiasound.dll"-"c:\sys\bin\javanokiasound.dll" -;"\epoc32\release\armv5\urel\z\resource\java\jvm\lib\jrt\javanokiasound.odc"-"c:\resource\java\jvm\lib\jrt\javanokiasound.odc" +"\epoc32\release\armv5\urel\javanokiasound.dll"-"c:\sys\bin\javanokiasound.dll" +"\epoc32\release\armv5\urel\z\resource\java\jvm\lib\jrt\javanokiasound.odc"-"c:\resource\java\jvm\lib\jrt\javanokiasound.odc" ;"\epoc32\release\armv5\urel\javasoftnotification.dll"-"c:\sys\bin\javasoftnotification.dll" ;"\epoc32\release\armv5\urel\z\resource\java\jvm\lib\jrt\javasoftnotification.odc"-"c:\resource\java\jvm\lib\jrt\javasoftnotification.odc" diff -r dc7c549001d5 -r 85266cc22c7f build/sis/java_rnd_tools.pkg --- a/build/sis/java_rnd_tools.pkg Thu May 27 12:49:31 2010 +0300 +++ b/build/sis/java_rnd_tools.pkg Fri Jun 11 13:33:44 2010 +0300 @@ -31,10 +31,6 @@ ;to be installed on Series 60 v5.0 platforms [0x1028315F], 0, 0, 0, {"Series60ProductID"} -"\epoc32\release\armv5\urel\JavaCap.exe"-"c:\sys\bin\JavaCap.exe" -"\epoc32\data\z\private\10003a3f\apps\JavaCap_reg.rsc"-"c:\private\10003a3f\import\apps\JavaCap_reg.rsc" -"\epoc32\data\z\resource\apps\JavaCap.rsc" -"c:\resource\apps\JavaCap.rsc" - ;j9dmp23.dll is a J9 VM plugin that provides the thread dump utility. "\epoc32\release\armv5\urel\j9dmp23.dll"-"c:\sys\bin\j9dmp23.dll" ;javathreaddumper.dll provides the thread dump agent. @@ -46,3 +42,8 @@ ; javainstaller.exe is a command line tool for starting javainstaller for RnD purposes only "\epoc32\release\armv5\urel\javainstaller.exe"-"c:\sys\bin\javainst.exe" + + +"\epoc32\release\armv5\urel\javacontrolpanel.dll"-"c:\sys\bin\javacontrolpanel.dll" +"\epoc32\release\armv5\urel\javacontrolpanel.exe"-"c:\sys\bin\javacontrolpanel.exe" +"\epoc32\data\z\private\10003a3f\apps\javacontrolpanel_reg.rsc" -"c:\private\10003a3f\import\apps\javacontrolpanel_reg.rsc" diff -r dc7c549001d5 -r 85266cc22c7f build/symbian_uids.pri --- a/build/symbian_uids.pri Thu May 27 12:49:31 2010 +0300 +++ b/build/symbian_uids.pri Fri Jun 11 13:33:44 2010 +0300 @@ -119,6 +119,9 @@ contains(TARGET, javacaptain_ext_scrupdater): TARGET.UID3 = 0x2002DD10 contains(TARGET, javacaptain_ext_ondemand_2): TARGET.UID3 = 0x2002DD01 contains(TARGET, javanokiaui): TARGET.UID3 = 0x2002E697 +contains(TARGET, javacaptain_ext_autostarter): TARGET.UID3 = 0x2002EA7E +contains(TARGET, javacontrolpanel): TARGET.UID3 = 0x2002FF62 +contains(TARGET, eswtqtwebkit): TARGET.UID3 = 0x2002FFA9 isEmpty(TARGET.UID3): error($${TEMPLATE} $${TARGET} : UID3 not defined. Please allocate UID3 and configure it either on $${TARGET}.pro file or in command symbian_uids.pri) diff -r dc7c549001d5 -r 85266cc22c7f inc/build_defines.hrh --- a/inc/build_defines.hrh Thu May 27 12:49:31 2010 +0300 +++ b/inc/build_defines.hrh Fri Jun 11 13:33:44 2010 +0300 @@ -15,7 +15,7 @@ * */ -#define RD_JAVA_VERSION 2,1,26 +#define RD_JAVA_VERSION 2,2,1 #define RD_JAVA_SYMBIAN_TARGET #define RD_JAVA_S60_RELEASE_10_1 #define RD_JAVA_S60_RELEASE_10_1_ONWARDS @@ -29,6 +29,7 @@ #define SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK #define RD_JAVA_USIF_APP_REG #define RD_JAVA_USIF_NOTIFY_APP_ARC +#define RD_JAVA_USIF_NOTIFY_PROGRESS #define RD_JAVA_PROXIMITY_LISTENER_ENABLED #define RD_JAVA_OPENC_BETA_PATCH #define OPENLCDUI_ENABLED diff -r dc7c549001d5 -r 85266cc22c7f inc/build_defines.pri --- a/inc/build_defines.pri Thu May 27 12:49:31 2010 +0300 +++ b/inc/build_defines.pri Fri Jun 11 13:33:44 2010 +0300 @@ -13,4 +13,4 @@ # # Description: Generated file - do not edit manually # -PROJECT_DEFINES *= RD_JAVA_SYMBIAN_TARGET RD_JAVA_S60_RELEASE_10_1 RD_JAVA_S60_RELEASE_10_1_ONWARDS RD_JAVA_S60_RELEASE_9_2_ONWARDS RD_JAVA_S60_RELEASE_5_0_ONWARDS RD_JAVA_UI_QT RD_JAVA_STDCPPV5 RD_JAVA_EPOCALLOWDLLDATA_FIX RD_JAVA_HTTP_EMC_ENABLED RD_JAVA_NGA_ENABLED SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK RD_JAVA_USIF_APP_REG RD_JAVA_USIF_NOTIFY_APP_ARC RD_JAVA_PROXIMITY_LISTENER_ENABLED RD_JAVA_OPENC_BETA_PATCH OPENLCDUI_ENABLED RD_JAVA_OPENLCDUI_ENABLED RD_JAVA_INSTALLERUI_ENABLED RD_JAVA_PREWARM RD_JAVA_ADVANCED_TACTILE_FEEDBACK RD_JAVA_APPLICATION_SETTINGS_QT RD_JAVA_MIDPRMS_DB +PROJECT_DEFINES *= RD_JAVA_SYMBIAN_TARGET RD_JAVA_S60_RELEASE_10_1 RD_JAVA_S60_RELEASE_10_1_ONWARDS RD_JAVA_S60_RELEASE_9_2_ONWARDS RD_JAVA_S60_RELEASE_5_0_ONWARDS RD_JAVA_UI_QT RD_JAVA_STDCPPV5 RD_JAVA_EPOCALLOWDLLDATA_FIX RD_JAVA_HTTP_EMC_ENABLED RD_JAVA_NGA_ENABLED SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK RD_JAVA_USIF_APP_REG RD_JAVA_USIF_NOTIFY_APP_ARC RD_JAVA_USIF_NOTIFY_PROGRESS RD_JAVA_PROXIMITY_LISTENER_ENABLED RD_JAVA_OPENC_BETA_PATCH OPENLCDUI_ENABLED RD_JAVA_OPENLCDUI_ENABLED RD_JAVA_INSTALLERUI_ENABLED RD_JAVA_PREWARM RD_JAVA_ADVANCED_TACTILE_FEEDBACK RD_JAVA_APPLICATION_SETTINGS_QT RD_JAVA_MIDPRMS_DB diff -r dc7c549001d5 -r 85266cc22c7f inc/java.txt --- a/inc/java.txt Thu May 27 12:49:31 2010 +0300 +++ b/inc/java.txt Fri Jun 11 13:33:44 2010 +0300 @@ -1,1 +1,1 @@ -2.1.26 +2.2.1 diff -r dc7c549001d5 -r 85266cc22c7f inc/java_s60_release.hrh --- a/inc/java_s60_release.hrh Thu May 27 12:49:31 2010 +0300 +++ b/inc/java_s60_release.hrh Fri Jun 11 13:33:44 2010 +0300 @@ -1,18 +1,1 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - RD_JAVA_S60_RELEASE=10.1 diff -r dc7c549001d5 -r 85266cc22c7f inc/project_defines.hrh --- a/inc/project_defines.hrh Thu May 27 12:49:31 2010 +0300 +++ b/inc/project_defines.hrh Fri Jun 11 13:33:44 2010 +0300 @@ -28,6 +28,7 @@ MACRO SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK MACRO RD_JAVA_USIF_APP_REG MACRO RD_JAVA_USIF_NOTIFY_APP_ARC +MACRO RD_JAVA_USIF_NOTIFY_PROGRESS MACRO RD_JAVA_PROXIMITY_LISTENER_ENABLED MACRO RD_JAVA_OPENC_BETA_PATCH MACRO OPENLCDUI_ENABLED diff -r dc7c549001d5 -r 85266cc22c7f javacommons/comms/ipclib/clientserver/src.s60/commssession.cpp --- a/javacommons/comms/ipclib/clientserver/src.s60/commssession.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/comms/ipclib/clientserver/src.s60/commssession.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -87,7 +87,10 @@ } else { - WLOG2(EJavaComms, "%s failed, err = %d", __PRETTY_FUNCTION__, rc); + if (rc != KErrOverflow) + { + WLOG2(EJavaComms, "%s failed, err = %d", __PRETTY_FUNCTION__, rc); + } } } return 0; @@ -151,7 +154,10 @@ } else { - WLOG2(EJavaComms, "%s failed, err = %d", __PRETTY_FUNCTION__, rc); + if (rc != KErrOverflow) + { + WLOG2(EJavaComms, "%s failed, err = %d", __PRETTY_FUNCTION__, rc); + } } } } @@ -193,7 +199,7 @@ else { rc = KErrOverflow; - WLOG3(EJavaComms, "%s: allocated length for message is too small (required size=%d, allocated size=%d)", + LOG3(EJavaComms, EInfo, "%s: allocated length for message is too small (required size=%d, allocated size=%d)", __PRETTY_FUNCTION__, neededLength, allocatedLength); } diff -r dc7c549001d5 -r 85266cc22c7f javacommons/comms/ipclib/clientserver/src.s60/creceiver.cpp --- a/javacommons/comms/ipclib/clientserver/src.s60/creceiver.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/comms/ipclib/clientserver/src.s60/creceiver.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -66,7 +66,7 @@ // buffer was not big enough for the message so reallocate buffer with correct size mBuffer.Close(); mBuffer.ReAllocL(mRequiredLength()); - WLOG2(EJavaComms, "%s: increasing buffer size to %d", __PRETTY_FUNCTION__, mRequiredLength()); + LOG2(EJavaComms, EInfo, "%s: increasing buffer size to %d", __PRETTY_FUNCTION__, mRequiredLength()); Receive(); } break; diff -r dc7c549001d5 -r 85266cc22c7f javacommons/gcfprotocols/http/javasrc.s60/com/nokia/mj/impl/gcf/protocol/http/Protocol.java --- a/javacommons/gcfprotocols/http/javasrc.s60/com/nokia/mj/impl/gcf/protocol/http/Protocol.java Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/gcfprotocols/http/javasrc.s60/com/nokia/mj/impl/gcf/protocol/http/Protocol.java Fri Jun 11 13:33:44 2010 +0300 @@ -45,7 +45,7 @@ String urls = null; int apnid = -1; int index = -1; - int responsetimeout = -1; + int responsetimeout = 180; // default timeout of 3 minutes ConnectionManager cminstance = null; AccessPoint apn = null; iFullUrl = "http:" + aUri; diff -r dc7c549001d5 -r 85266cc22c7f javacommons/gcfprotocols/http/src.s60/chttptransactionclient.cpp --- a/javacommons/gcfprotocols/http/src.s60/chttptransactionclient.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/gcfprotocols/http/src.s60/chttptransactionclient.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -626,6 +626,14 @@ iStatus = CHttpTransactionClient::ERequestNextBodayData; break; } + + case THTTPEvent::EReceiveTimeOut: + { + ELOG(ESOCKET,"MHFRunL EReceiveTimeOut"); + NotifyErrorL(KErrTimedOut); // send timeout error to java + break; + + } /* * -j2me expects the http stack to be able to post body data with no content type * the native stack default validation filter does not allow this. @@ -694,7 +702,6 @@ iTransaction.Cancel(); iHttpSession.RestartConnection(); - } if (iJavaWaitingOnCallBack) { @@ -707,7 +714,7 @@ LOG(ESOCKET,EInfo,"Notifiy Read EOF / Cancel"); iJavaWaitingOnCallBack=EFalse; //Notify Java of error if it is waiting for a read - iObserver->DataReadyForRead(-1); + iObserver->DataReadyForRead(aErrorCode); } } diff -r dc7c549001d5 -r 85266cc22c7f javacommons/gcfprotocols/socket/socket/inc/apnsettings.h --- a/javacommons/gcfprotocols/socket/socket/inc/apnsettings.h Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/gcfprotocols/socket/socket/inc/apnsettings.h Fri Jun 11 13:33:44 2010 +0300 @@ -27,7 +27,7 @@ public : static int setDefaultApn(int aType, int aApn); - static void removeDefaultApn(); + }; diff -r dc7c549001d5 -r 85266cc22c7f javacommons/gcfprotocols/socket/socket/src.s60/apnsettings.cpp --- a/javacommons/gcfprotocols/socket/socket/src.s60/apnsettings.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/gcfprotocols/socket/socket/src.s60/apnsettings.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -66,11 +66,4 @@ return def; } -void ApnSettings::removeDefaultApn() -{ - #ifdef RD_JAVA_OPENC_BETA_PATCH - setdefaultif(NULL); - ILOG(ESOCKET, "sedefaultif called"); - ILOG1(ESOCKET, "remove default apn returned %d",setdefaultif(NULL)); - #endif -} + diff -r dc7c549001d5 -r 85266cc22c7f javacommons/jvms/cldc_1.1.1/javasrc/java/util/Timer.java --- a/javacommons/jvms/cldc_1.1.1/javasrc/java/util/Timer.java Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/jvms/cldc_1.1.1/javasrc/java/util/Timer.java Fri Jun 11 13:33:44 2010 +0300 @@ -1,19 +1,3 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff -r dc7c549001d5 -r 85266cc22c7f javacommons/jvms/cldc_1.1.1/javasrc/java/util/TimerTask.java --- a/javacommons/jvms/cldc_1.1.1/javasrc/java/util/TimerTask.java Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/jvms/cldc_1.1.1/javasrc/java/util/TimerTask.java Fri Jun 11 13:33:44 2010 +0300 @@ -1,19 +1,3 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff -r dc7c549001d5 -r 85266cc22c7f javacommons/jvms/cldc_1.1.1/tsrc/javasrc/com/nokia/mj/test/java/util/TimerTaskTest.java --- a/javacommons/jvms/cldc_1.1.1/tsrc/javasrc/com/nokia/mj/test/java/util/TimerTaskTest.java Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/jvms/cldc_1.1.1/tsrc/javasrc/com/nokia/mj/test/java/util/TimerTaskTest.java Fri Jun 11 13:33:44 2010 +0300 @@ -1,19 +1,3 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff -r dc7c549001d5 -r 85266cc22c7f javacommons/jvms/cldc_1.1.1/tsrc/javasrc/com/nokia/mj/test/java/util/TimerTest.java --- a/javacommons/jvms/cldc_1.1.1/tsrc/javasrc/com/nokia/mj/test/java/util/TimerTest.java Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/jvms/cldc_1.1.1/tsrc/javasrc/com/nokia/mj/test/java/util/TimerTest.java Fri Jun 11 13:33:44 2010 +0300 @@ -1,19 +1,3 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff -r dc7c549001d5 -r 85266cc22c7f javacommons/jvms/j9/exports.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javacommons/jvms/j9/exports.inf Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,23 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +PRJ_PLATFORMS +default + +#ifndef RD_JAVA_SF_BUILD +#include "s60/exports.inf" +#endif diff -r dc7c549001d5 -r 85266cc22c7f javacommons/jvms/j9/j9.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javacommons/jvms/j9/j9.pro Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,23 @@ +# +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +TEMPLATE = subdirs + +# Export J9 only when available here (not available here in SF builds) +# (use indirection through ./exports.inf for pregenerated bld.inf variation) +exists($${_PRO_FILE_PWD_}/s60/exports.inf): { + BLD_INF_RULES.prj_extensions += "$${LITERAL_HASH}include \"exports.inf\"" \ +} diff -r dc7c549001d5 -r 85266cc22c7f javacommons/security/build/exports.inf --- a/javacommons/security/build/exports.inf Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/security/build/exports.inf Fri Jun 11 13:33:44 2010 +0300 @@ -27,9 +27,12 @@ #include +// Configuration interface for javasecurity #ifdef RD_JAVA_S60_RELEASE_10_1_ONWARDS +// Public configuration interface is named as CI_javasecurity.confml +// and it is located outside of jrt package. The name of private +// configuration interface is javasecurity2.confml. ../conf/javasecurity2.confml APP_LAYER_CONFML(javasecurity.confml) -../conf/CI_javasecurity.confml APP_LAYER_CONFML(CI_javasecurity.confml) #else ../conf/javasecurity.confml APP_LAYER_CONFML(javasecurity.confml) #endif /* RD_JAVA_S60_RELEASE_10_1_ONWARDS */ diff -r dc7c549001d5 -r 85266cc22c7f javacommons/security/conf/CI_javasecurity.confml Binary file javacommons/security/conf/CI_javasecurity.confml has changed diff -r dc7c549001d5 -r 85266cc22c7f javacommons/security/data/att_manufacturer.txt --- a/javacommons/security/data/att_manufacturer.txt Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/security/data/att_manufacturer.txt Fri Jun 11 13:33:44 2010 +0300 @@ -30,6 +30,7 @@ permission javax.microedition.media.control.VideoControl.getSnapshot "*" "snapshot"; permission javax.microedition.io.Connector.rtsp "*"; permission javax.microedition.PropertyPermission "mobinfo.imsi" "read"; + permission javax.microedition.midlet.CmdLineArgsPermission; } grant assigned { diff -r dc7c549001d5 -r 85266cc22c7f javacommons/security/data/att_operator.txt --- a/javacommons/security/data/att_operator.txt Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/security/data/att_operator.txt Fri Jun 11 13:33:44 2010 +0300 @@ -48,8 +48,16 @@ permission javax.microedition.io.PushRegistryPermission "*" "staticregistration,dynamicregistration,autoinvocation"; } +grant user "Url start" blanket,session,oneshot,no { + permission javax.microedition.midlet.CmdLineArgsPermission; +} + grant allowed { permission javax.microedition.io.Connector.sms "sms://*" "open,receive"; permission javax.microedition.io.Connector.mms "mms://*" "open,receive"; permission javax.microedition.io.Connector.cbs "cbs://*" "open,receive"; } + +grant assigned { + permission javax.microedition.midlet.AutoStartPermission; +} diff -r dc7c549001d5 -r 85266cc22c7f javacommons/security/data/att_operatorextra.txt --- a/javacommons/security/data/att_operatorextra.txt Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/security/data/att_operatorextra.txt Fri Jun 11 13:33:44 2010 +0300 @@ -30,6 +30,7 @@ permission javax.microedition.media.control.VideoControl.getSnapshot "*" "snapshot"; permission javax.microedition.io.Connector.rtsp "*"; permission javax.microedition.PropertyPermission "mobinfo.imsi" "read"; + permission javax.microedition.midlet.CmdLineArgsPermission; } grant assigned { diff -r dc7c549001d5 -r 85266cc22c7f javacommons/security/data/msa_manufacturer.txt --- a/javacommons/security/data/msa_manufacturer.txt Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/security/data/msa_manufacturer.txt Fri Jun 11 13:33:44 2010 +0300 @@ -30,6 +30,7 @@ permission javax.microedition.media.control.VideoControl.getSnapshot "*" "snapshot"; permission javax.microedition.io.Connector.rtsp "*"; permission javax.microedition.PropertyPermission "mobinfo.imsi" "read"; + permission javax.microedition.midlet.CmdLineArgsPermission; } grant assigned { diff -r dc7c549001d5 -r 85266cc22c7f javacommons/security/data/msa_operator.txt --- a/javacommons/security/data/msa_operator.txt Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/security/data/msa_operator.txt Fri Jun 11 13:33:44 2010 +0300 @@ -30,6 +30,7 @@ permission javax.microedition.media.control.VideoControl.getSnapshot "*" "snapshot"; permission javax.microedition.io.Connector.rtsp "*"; permission javax.microedition.PropertyPermission "mobinfo.imsi" "read"; + permission javax.microedition.midlet.CmdLineArgsPermission; } grant assigned { diff -r dc7c549001d5 -r 85266cc22c7f javacommons/security/data/msa_trustedthirdparty.txt --- a/javacommons/security/data/msa_trustedthirdparty.txt Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/security/data/msa_trustedthirdparty.txt Fri Jun 11 13:33:44 2010 +0300 @@ -62,6 +62,10 @@ permission javax.microedition.apdu.aid "apdu://*" "aid"; } +grant user "Url start" session,oneshot,no { + permission javax.microedition.midlet.CmdLineArgsPermission; +} + grant allowed { permission javax.microedition.io.Connector.sms "sms://*" "open,receive"; permission javax.microedition.io.Connector.mms "mms://*" "open,receive"; diff -r dc7c549001d5 -r 85266cc22c7f javacommons/security/data/s60_manufacturer.txt --- a/javacommons/security/data/s60_manufacturer.txt Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/security/data/s60_manufacturer.txt Fri Jun 11 13:33:44 2010 +0300 @@ -30,6 +30,7 @@ permission javax.microedition.media.control.VideoControl.getSnapshot "*" "snapshot"; permission javax.microedition.io.Connector.rtsp "*"; permission javax.microedition.PropertyPermission "mobinfo.imsi" "read"; + permission javax.microedition.midlet.CmdLineArgsPermission; } grant assigned { diff -r dc7c549001d5 -r 85266cc22c7f javacommons/security/data/s60_operator.txt --- a/javacommons/security/data/s60_operator.txt Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/security/data/s60_operator.txt Fri Jun 11 13:33:44 2010 +0300 @@ -30,6 +30,7 @@ permission javax.microedition.media.control.VideoControl.getSnapshot "*" "snapshot"; permission javax.microedition.io.Connector.rtsp "*"; permission javax.microedition.PropertyPermission "mobinfo.imsi" "read"; + permission javax.microedition.midlet.CmdLineArgsPermission; } grant assigned { diff -r dc7c549001d5 -r 85266cc22c7f javacommons/security/data/s60_trustedthirdparty.txt --- a/javacommons/security/data/s60_trustedthirdparty.txt Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/security/data/s60_trustedthirdparty.txt Fri Jun 11 13:33:44 2010 +0300 @@ -63,6 +63,10 @@ permission javax.microedition.securityservice.CMSMessageSignatureService "pki://*" "authenticate"; } +grant user "Url start" session,oneshot,no { + permission javax.microedition.midlet.CmdLineArgsPermission; +} + grant allowed { permission javax.microedition.io.Connector.sms "sms://*" "open,receive"; permission javax.microedition.io.Connector.mms "mms://*" "open,receive"; diff -r dc7c549001d5 -r 85266cc22c7f javacommons/security/inc/securitystoragedatadefs.h --- a/javacommons/security/inc/securitystoragedatadefs.h Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/security/inc/securitystoragedatadefs.h Fri Jun 11 13:33:44 2010 +0300 @@ -42,6 +42,7 @@ const wchar_t* const AUTHENTICATION_SETTINGS = L"Authentication"; const wchar_t* const BROADCAST_SETTINGS = L"Broadcast"; const wchar_t* const NFC_WRITE_ACCESS_SETTINGS = L"NFC Write Access"; +const wchar_t* const URL_START_SETTINGS = L"Url start"; // interaction modes values const wchar_t* const ONESHOT_INTERACTION_MODE = L"1"; diff -r dc7c549001d5 -r 85266cc22c7f javacommons/security/javasrc/com/nokia/mj/impl/security/common/Certificate.java --- a/javacommons/security/javasrc/com/nokia/mj/impl/security/common/Certificate.java Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/security/javasrc/com/nokia/mj/impl/security/common/Certificate.java Fri Jun 11 13:33:44 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -318,8 +318,9 @@ { Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, Integer.parseInt(str.substring(0,4))); - cal.set(Calendar.MONTH, Integer.parseInt(str.substring(4,6))); - cal.set(Calendar.DAY_OF_WEEK, Integer.parseInt(str.substring(6,8))); + // Calendar.MONTH begins from 0 (0=January, 1=Februrary, ...) + cal.set(Calendar.MONTH, Integer.parseInt(str.substring(4,6)) - 1); + cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(str.substring(6,8))); cal.set(Calendar.HOUR, Integer.parseInt(str.substring(8,10))); cal.set(Calendar.MINUTE, Integer.parseInt(str.substring(10,12))); cal.set(Calendar.SECOND, Integer.parseInt(str.substring(12,14))); diff -r dc7c549001d5 -r 85266cc22c7f javacommons/security/javasrc/com/nokia/mj/impl/security/midp/authorization/AccessControllerFactoryImpl.java --- a/javacommons/security/javasrc/com/nokia/mj/impl/security/midp/authorization/AccessControllerFactoryImpl.java Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/security/javasrc/com/nokia/mj/impl/security/midp/authorization/AccessControllerFactoryImpl.java Fri Jun 11 13:33:44 2010 +0300 @@ -61,7 +61,7 @@ * which the AccessControllerImpl instance * is retrieved */ - public static AccessControllerImpl getAccessController(StorageSession aStorageSession, + public synchronized static AccessControllerImpl getAccessController(StorageSession aStorageSession, Uid aAppSuiteUid, String aAppName) { @@ -69,7 +69,6 @@ { return null; } - // Synchronization missing AccessControllerImpl instance = (AccessControllerImpl)instances.get( aAppSuiteUid); @@ -82,14 +81,13 @@ return instance; } - public static void destroyAccessController(Uid appUID) + public synchronized static void destroyAccessController(Uid appUID) { if (appUID == null) { return; } // This is to be called when a MIDlet suite is stoped - // Synchronization missing // Remove the instance or mark it as inactive? AccessControllerImpl ac = (AccessControllerImpl)instances .remove(appUID); diff -r dc7c549001d5 -r 85266cc22c7f javacommons/security/javasrc/com/nokia/mj/impl/security/midp/authorization/SecurityPromptHandler.java --- a/javacommons/security/javasrc/com/nokia/mj/impl/security/midp/authorization/SecurityPromptHandler.java Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/security/javasrc/com/nokia/mj/impl/security/midp/authorization/SecurityPromptHandler.java Fri Jun 11 13:33:44 2010 +0300 @@ -81,7 +81,7 @@ } } - public UserSecuritySettings handleUserPermission( + public synchronized UserSecuritySettings handleUserPermission( UserPermission userPermission, boolean blanketPromptShown) { UserSecuritySettings settings = userPermission @@ -219,7 +219,7 @@ } else { - RuntimeUi ui = getUiInstance(); + getUiInstance(); boolean responseAvailable = ui.confirm( appName, cData); @@ -329,13 +329,12 @@ } } - private RuntimeUi getUiInstance() + private void getUiInstance() { if (ui == null) { ui = RuntimeUiFactory.getRuntimeUi(); } - return ui; } private UserSecuritySettings handleDenyAnswer(UserSecuritySettings settings) diff -r dc7c549001d5 -r 85266cc22c7f javacommons/security/javasrc/com/nokia/mj/impl/security/midp/common/PermissionMappingTable.java --- a/javacommons/security/javasrc/com/nokia/mj/impl/security/midp/common/PermissionMappingTable.java Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/security/javasrc/com/nokia/mj/impl/security/midp/common/PermissionMappingTable.java Fri Jun 11 13:33:44 2010 +0300 @@ -228,6 +228,12 @@ PERMISSION_MAPPING_TABLE.put( "javax.microedition.midlet.AutoStartPermission", new MIDPPermission( "com.nokia.mj.impl.installer.utils.AutoStartPermission", null)); + PERMISSION_MAPPING_TABLE.put( + "javax.microedition.midlet.CmdLineArgsPermission", new MIDPPermission( + "com.nokia.mj.impl.rt.utils.CmdLineArgsPermission", null)); + PERMISSION_MAPPING_TABLE.put( + "com.nokia.webstart", new MIDPPermission( + "com.nokia.mj.impl.rt.utils.CmdLineArgsPermission", null)); } /** diff -r dc7c549001d5 -r 85266cc22c7f javacommons/security/javasrc/com/nokia/mj/impl/security/midp/common/UserSecuritySettings.java --- a/javacommons/security/javasrc/com/nokia/mj/impl/security/midp/common/UserSecuritySettings.java Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/security/javasrc/com/nokia/mj/impl/security/midp/common/UserSecuritySettings.java Fri Jun 11 13:33:44 2010 +0300 @@ -48,6 +48,7 @@ public static final String AUTHENTICATION_SETTINGS = "Authentication"; public static final String BROADCAST_SETTINGS = "Broadcast"; public static final String NFC_WRITE_ACCESS_SETTINGS = "NFC Write Access"; + public static final String URL_START_SETTINGS = "Url start"; // security warnings modes public static final String SECURITY_WARNINGS_USER_DEFINED_MODE = "1"; diff -r dc7c549001d5 -r 85266cc22c7f javacommons/security/javasrc/com/nokia/mj/impl/security/midp/common/UserSecuritySettingsImpl.java --- a/javacommons/security/javasrc/com/nokia/mj/impl/security/midp/common/UserSecuritySettingsImpl.java Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/security/javasrc/com/nokia/mj/impl/security/midp/common/UserSecuritySettingsImpl.java Fri Jun 11 13:33:44 2010 +0300 @@ -51,6 +51,7 @@ private static final String AUTHENTICATION_ID = "setting_auth"; private static final String BROADCAST_ID = "setting_broadcast"; private static final String NFC_WRITE_ACCESS_ID = "setting_nfc_write_access"; + private static final String URL_START_ID = "setting_url_start"; public UserSecuritySettingsImpl( String name, @@ -159,6 +160,10 @@ { id = BROADCAST_ID; } + else if (URL_START_SETTINGS.equalsIgnoreCase(aSettingName)) + { + id = URL_START_ID; + } return resLoader.format(id, null /*aTextParameters*/); } diff -r dc7c549001d5 -r 85266cc22c7f javacommons/security/javasrc/com/nokia/mj/impl/security/utils/SecurityPromptMessage.java --- a/javacommons/security/javasrc/com/nokia/mj/impl/security/utils/SecurityPromptMessage.java Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/security/javasrc/com/nokia/mj/impl/security/utils/SecurityPromptMessage.java Fri Jun 11 13:33:44 2010 +0300 @@ -79,6 +79,7 @@ public static final String QUESTION_ID_PUSH_DYNAMIC_REGISTRATION = "push_registration_dynamic"; public static final String QUESTION_ID_AUTO_INVOCATION = "auto_invocation"; public static final String QUESTION_ID_NDEF_TAG_WRITE = "nfc_ndef_tag_write"; + public static final String QUESTION_ID_APP_AUTO_LAUNCH = "url_start"; // identifiers for the security prompt answer options public static final String ANSWER_ID_ALLOW = "prompt_allow"; diff -r dc7c549001d5 -r 85266cc22c7f javacommons/security/javaunicertstoreplugin/src.s60/javacertstoreimpl.cpp --- a/javacommons/security/javaunicertstoreplugin/src.s60/javacertstoreimpl.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/security/javaunicertstoreplugin/src.s60/javacertstoreimpl.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -75,7 +75,6 @@ Cancel(); } - mComms.unregisterListener(PLUGIN_ID_JAVA_CERT_STORE_ECOM_C,this); mComms.unregisterDefaultListener(this); mComms.disconnect(); mCertsData.ResetAndDestroy(); @@ -388,7 +387,7 @@ TBool validRequest = validateCertAttrFilter(aFilter); if (!validRequest) { - ELOG(EJavaSecurity,"No certificates matching the filter supplied"); + LOG(EJavaSecurity, EInfo, "No certificates matching the filter supplied"); User::RequestComplete(pRequestStatus,KErrNone); return; } diff -r dc7c549001d5 -r 85266cc22c7f javacommons/security/javaunicertstoreplugin/src.s60/javacertstoreimpl.h --- a/javacommons/security/javaunicertstoreplugin/src.s60/javacertstoreimpl.h Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/security/javaunicertstoreplugin/src.s60/javacertstoreimpl.h Fri Jun 11 13:33:44 2010 +0300 @@ -68,8 +68,7 @@ }; class CJavaCertStoreImpl: public CActive, public MCTWritableCertStore, - public java::comms::CommsListener, - public java::comms::CommsClientEndpoint + public java::comms::CommsListener { public: diff -r dc7c549001d5 -r 85266cc22c7f javacommons/security/tsrc/data/policies/test_manufacturer.txt --- a/javacommons/security/tsrc/data/policies/test_manufacturer.txt Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/security/tsrc/data/policies/test_manufacturer.txt Fri Jun 11 13:33:44 2010 +0300 @@ -30,6 +30,7 @@ permission javax.microedition.media.control.VideoControl.getSnapshot "*" "snapshot"; permission javax.microedition.io.Connector.rtsp "*"; permission javax.microedition.PropertyPermission "mobinfo.imsi" "read"; + permission javax.microedition.midlet.CmdLineArgsPermission; } grant assigned { permission javax.microedition.PropertyPermission "mobinfo.msisdn" "read"; diff -r dc7c549001d5 -r 85266cc22c7f javacommons/security/tsrc/data/policies/test_operator.txt --- a/javacommons/security/tsrc/data/policies/test_operator.txt Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/security/tsrc/data/policies/test_operator.txt Fri Jun 11 13:33:44 2010 +0300 @@ -30,6 +30,7 @@ permission javax.microedition.media.control.VideoControl.getSnapshot "*" "snapshot"; permission javax.microedition.io.Connector.rtsp "*"; permission javax.microedition.PropertyPermission "mobinfo.imsi" "read"; + permission javax.microedition.midlet.CmdLineArgsPermission; } grant assigned { permission javax.microedition.PropertyPermission "mobinfo.msisdn" "read"; diff -r dc7c549001d5 -r 85266cc22c7f javacommons/security/tsrc/data/policies/test_operatorextra.txt --- a/javacommons/security/tsrc/data/policies/test_operatorextra.txt Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/security/tsrc/data/policies/test_operatorextra.txt Fri Jun 11 13:33:44 2010 +0300 @@ -29,4 +29,5 @@ permission javax.microedition.media.control.RecordControl "*" "record"; permission javax.microedition.media.control.VideoControl.getSnapshot "*" "snapshot"; permission javax.microedition.io.Connector.rtsp "*"; + permission javax.microedition.midlet.CmdLineArgsPermission; } diff -r dc7c549001d5 -r 85266cc22c7f javacommons/security/tsrc/data/policies/test_trustedthirdparty.txt --- a/javacommons/security/tsrc/data/policies/test_trustedthirdparty.txt Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/security/tsrc/data/policies/test_trustedthirdparty.txt Fri Jun 11 13:33:44 2010 +0300 @@ -63,6 +63,10 @@ permission javax.microedition.securityservice.CMSMessageSignatureService "pki://*" "authenticate"; } +grant user "Url start" session,oneshot,no { + permission javax.microedition.midlet.CmdLineArgsPermission; +} + grant allowed { permission javax.microedition.io.Connector.sms "sms://*" "open,receive"; permission javax.microedition.io.Connector.mms "mms://*" "open,receive"; diff -r dc7c549001d5 -r 85266cc22c7f javacommons/security/tsrc/javasrc/com/nokia/mj/impl/security/midp/authorization/SecurityPolicyModuleTests.java --- a/javacommons/security/tsrc/javasrc/com/nokia/mj/impl/security/midp/authorization/SecurityPolicyModuleTests.java Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/security/tsrc/javasrc/com/nokia/mj/impl/security/midp/authorization/SecurityPolicyModuleTests.java Fri Jun 11 13:33:44 2010 +0300 @@ -89,6 +89,7 @@ new SecurityPolicyPermission(getPermissionName("javax.microedition.PropertyPermission"),"mobinfo.publicinfo","read",null), new SecurityPolicyPermission(getPermissionName("javax.microedition.PropertyPermission"),"mobinfo.cellid","read",null), new SecurityPolicyPermission(getPermissionName("javax.microedition.midlet.AutoStartPermission"),null,null,null), + new SecurityPolicyPermission(getPermissionName("javax.microedition.midlet.CmdLineArgsPermission"),null,null,null), }; static final SecurityPolicyPermission[] OPERATOR_PERMS = { @@ -142,6 +143,7 @@ new SecurityPolicyPermission(getPermissionName("javax.microedition.PropertyPermission"),"mobinfo.publicinfo","read",null), new SecurityPolicyPermission(getPermissionName("javax.microedition.PropertyPermission"),"mobinfo.cellid","read",null), new SecurityPolicyPermission(getPermissionName("javax.microedition.midlet.AutoStartPermission"),null,null,null), + new SecurityPolicyPermission(getPermissionName("javax.microedition.midlet.CmdLineArgsPermission"),null,null,null), }; static final SecurityPolicyPermission[] IDENTIFIED_THIRD_PARTY_PERMS = { @@ -265,6 +267,9 @@ new int[]{UserSecuritySettings.BLANKET_INTERACTION_MODE,UserSecuritySettings.ONESHOT_INTERACTION_MODE,UserSecuritySettings.NO_INTERACTION_MODE,UserSecuritySettings.SESSION_INTERACTION_MODE})), new SecurityPolicyPermission(getPermissionName("javax.microedition.PropertyPermission"),"mobinfo.publicinfo","read",null), new SecurityPolicyPermission(getPermissionName("javax.microedition.PropertyPermission"),"mobinfo.cellid","read",null), + new SecurityPolicyPermission(getPermissionName("javax.microedition.midlet.CmdLineArgsPermission"),null, null, + new SecurityPolicyPermissionSettings("Url start",UserSecuritySettings.SESSION_INTERACTION_MODE, + new int[]{UserSecuritySettings.ONESHOT_INTERACTION_MODE,UserSecuritySettings.NO_INTERACTION_MODE,UserSecuritySettings.SESSION_INTERACTION_MODE})), }; static final SecurityPolicyPermission[] UNIDENTIFIED_THIRD_PARTY_PERMS = { diff -r dc7c549001d5 -r 85266cc22c7f javacommons/utils/inc/javaoslayer.h --- a/javacommons/utils/inc/javaoslayer.h Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/utils/inc/javaoslayer.h Fri Jun 11 13:33:44 2010 +0300 @@ -33,6 +33,7 @@ const int BOOT_CLASSPATH_MIDP = 1; const int BOOT_CLASSPATH_INSTALLER = 2; const int BOOT_CLASSPATH_TCKRUNNER = 3; +const int BOOT_CLASSPATH_JAVACONTROLPANEL = 4; class DriveId; diff -r dc7c549001d5 -r 85266cc22c7f javacommons/utils/src.s60/javaoslayer.cpp --- a/javacommons/utils/src.s60/javaoslayer.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/utils/src.s60/javaoslayer.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -39,6 +39,7 @@ const char * const BOOT_CLASSPATH_MIDP_FILE = "midpodclist"; const char * const BOOT_CLASSPATH_INSTALLER_FILE = "installerodclist"; const char * const BOOT_CLASSPATH_TCKRUNNER_FILE = "tckrunnerodclist"; +const char * const BOOT_CLASSPATH_JAVACONTROLPANEL_FILE = "javacontrolpanelodclist"; _LIT(KStartUpTraceDir, "java\\full"); _LIT(KStartUpTraceFile, "startup.txt"); @@ -303,6 +304,10 @@ { path.append(BOOT_CLASSPATH_TCKRUNNER_FILE); } + else if (BOOT_CLASSPATH_JAVACONTROLPANEL == pathType) + { + path.append(BOOT_CLASSPATH_JAVACONTROLPANEL_FILE); + } else { path.append(BOOT_CLASSPATH_MIDP_FILE); diff -r dc7c549001d5 -r 85266cc22c7f javacommons/utils/src.s60/s60commonutils.cpp --- a/javacommons/utils/src.s60/s60commonutils.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javacommons/utils/src.s60/s60commonutils.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -118,6 +118,12 @@ for (int i = 0; i< count; i++) { + if( !aNativeArray[ i ] ) + { + // Skip null elements since already initialized + continue; + } + //TPtr16 temp = aNativeArray[i]->Des(); jstring javaString = S60CommonUtils::NativeToJavaString(aJni, *aNativeArray[i]); if (javaString == NULL) diff -r dc7c549001d5 -r 85266cc22c7f javaextensions/sensor/src.s60/cacceleratorsensor.cpp --- a/javaextensions/sensor/src.s60/cacceleratorsensor.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javaextensions/sensor/src.s60/cacceleratorsensor.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -297,7 +297,6 @@ void CAcceleratorSensor::OpenChannelL() { - TInt err; JELOG2(ESensor); LOG(ESensor,EInfo,"Creating Open Channel"); iChannel->OpenChannelL(); @@ -306,9 +305,9 @@ iScaleFactor = 1; TInt format(ESensrvChannelDataFormatAbsolute); TSensrvProperty property; - TRAP(err,iChannel->GetPropertyL(KSensrvPropIdChannelDataFormat, KSensrvItemIndexNone, - property);); - LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::GetPropertyL() One = %d",err); + iChannel->GetPropertyL(KSensrvPropIdChannelDataFormat, KSensrvItemIndexNone, + property); + if (property.PropertyType() == ESensrvIntProperty) { @@ -328,19 +327,17 @@ // Scaled value maximum TSensrvProperty property_scaled; TInt maxScaled(0); - TRAP(err,iChannel->GetPropertyL(KSensrvPropIdScaledRange, KSensrvItemIndexNone, - property_scaled);); - LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::GetPropertyL() Two = %d",err); + iChannel->GetPropertyL(KSensrvPropIdScaledRange, KSensrvItemIndexNone, + property_scaled); + if (property_scaled.GetArrayIndex() == ESensrvArrayPropertyInfo) { LOG(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::If"); //for 2G Accelerometer Sensor index value is 0. TInt rangeIndex(0); - TRAP(err,iChannel->GetPropertyL(KSensrvPropIdScaledRange, KSensrvItemIndexNone, - rangeIndex, property_scaled);); - LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::GetPropertyL() Three = %d",err); - + iChannel->GetPropertyL(KSensrvPropIdScaledRange, KSensrvItemIndexNone, + rangeIndex, property_scaled); property_scaled.GetMaxValue(maxScaled); LOG1(ESensor,EInfo,"property_scaled::maxValue = %d",maxScaled); @@ -353,36 +350,32 @@ } // MeasureRange can be an array property TReal maxMeasure; - TInt err1; + TSensrvProperty property_Measured; - TRAP(err1,iChannel->GetPropertyL(KSensrvPropIdMeasureRange, KSensrvItemIndexNone, - property_Measured);); - LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::GetPropertyL() Four = %d",err1); + iChannel->GetPropertyL(KSensrvPropIdMeasureRange, KSensrvItemIndexNone, + property_Measured); + + TInt arrayIndex = property_Measured.GetArrayIndex(); + LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::KSensrvPropIdMeasureRange::arrayIndex = %d",arrayIndex); - if (err1 == KErrNone) + if (property_Measured.GetArrayIndex() == ESensrvArrayPropertyInfo) { - TInt arrayIndex = property_Measured.GetArrayIndex(); - LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::KSensrvPropIdMeasureRange::arrayIndex = %d",arrayIndex); - - if (property_Measured.GetArrayIndex() == ESensrvArrayPropertyInfo) - { - LOG(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::If"); + LOG(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::If"); - TInt index2g = 0; - LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::Getting RangeIndex = %f",index2g); - //We need to TypeCast variable rangeIndex to TInt for - TRAP(err,iChannel->GetPropertyL(KSensrvPropIdMeasureRange, KSensrvItemIndexNone, - index2g, property_Measured);); - LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::GetPropertyL() Five = %d",err); - property_Measured.GetMaxValue(maxMeasure); - } - else - { - LOG(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::else"); - property_Measured.GetMaxValue(maxMeasure); - } + TInt index2g = 0; + LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::Getting RangeIndex = %f",index2g); + //We need to TypeCast variable rangeIndex to TInt for + iChannel->GetPropertyL(KSensrvPropIdMeasureRange, KSensrvItemIndexNone, + index2g, property_Measured); + property_Measured.GetMaxValue(maxMeasure); + } + else + { + LOG(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::else"); + property_Measured.GetMaxValue(maxMeasure); + } - } + iScaleFactor = maxMeasure / maxScaled ; LOG1(ESensor,EInfo,"CAcceleratorSensor::OpenChannelL()::iScaleFactor = %f",iScaleFactor); } diff -r dc7c549001d5 -r 85266cc22c7f javaextensions/wma/mms/pushplugin/build/eabi/javammsscpluginu.def --- a/javaextensions/wma/mms/pushplugin/build/eabi/javammsscpluginu.def Thu May 27 12:49:31 2010 +0300 +++ b/javaextensions/wma/mms/pushplugin/build/eabi/javammsscpluginu.def Fri Jun 11 13:33:44 2010 +0300 @@ -24,4 +24,6 @@ _ZThn28_N4java3wma22S60MmsServerConnection9setFilterERKSbIwSt11char_traitsIwESaIwEE @ 23 NONAME ; ## _ZThn28_NK4java3wma22S60MmsServerConnection6getUriEv @ 24 NONAME ; ## _ZThn28_NK4java3wma22S60MmsServerConnection9getFilterEv @ 25 NONAME ; ## + _ZN4java3wma22S60MmsServerConnection5closeEv @ 26 NONAME + _ZThn28_N4java3wma22S60MmsServerConnection5closeEv @ 27 NONAME diff -r dc7c549001d5 -r 85266cc22c7f javaextensions/wma/mms/pushplugin/src.s60/s60mmsserverconnection.cpp --- a/javaextensions/wma/mms/pushplugin/src.s60/s60mmsserverconnection.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javaextensions/wma/mms/pushplugin/src.s60/s60mmsserverconnection.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -270,7 +270,7 @@ return mFilter; } -void S60MmsServerConnection::close() +OS_EXPORT void S60MmsServerConnection::close() { JELOG2(EWMA); // the close and RunL are synchronized to make it SMP safe. diff -r dc7c549001d5 -r 85266cc22c7f javaextensions/wma/sms_cbs/pushplugin/cbs/build/eabi/javacbsscpluginu.def --- a/javaextensions/wma/sms_cbs/pushplugin/cbs/build/eabi/javacbsscpluginu.def Thu May 27 12:49:31 2010 +0300 +++ b/javaextensions/wma/sms_cbs/pushplugin/cbs/build/eabi/javacbsscpluginu.def Fri Jun 11 13:33:44 2010 +0300 @@ -24,4 +24,16 @@ _ZTVN4java3wma19CbsServerConnectionE @ 23 NONAME ; ## _ZTVN4java3wma20ServerConnectionBaseE @ 24 NONAME ; ## _ZThn28_N4java3wma19CbsServerConnection4openEPNS_4push18ConnectionListenerE @ 25 NONAME ; ## + _ZN4java3wma19CbsServerConnection15retrieveMessageER8TPckgBufI22TJavaMessageParametersE @ 26 NONAME + _ZN4java3wma19CbsServerConnection4openEPNS_4push18ConnectionListenerEb @ 27 NONAME + _ZN4java3wma19CbsServerConnection5closeEv @ 28 NONAME + _ZN4java3wma19CbsServerConnectionD0Ev @ 29 NONAME + _ZN4java3wma19CbsServerConnectionD1Ev @ 30 NONAME + _ZN4java3wma19CbsServerConnectionD2Ev @ 31 NONAME + _ZThn28_N4java3wma19CbsServerConnection15retrieveMessageER8TPckgBufI22TJavaMessageParametersE @ 32 NONAME + _ZThn28_N4java3wma19CbsServerConnection4openEPNS_4push18ConnectionListenerEb @ 33 NONAME + _ZThn28_N4java3wma19CbsServerConnection5closeEv @ 34 NONAME + _ZThn28_N4java3wma19CbsServerConnectionD0Ev @ 35 NONAME + _ZThn28_N4java3wma19CbsServerConnectionD1Ev @ 36 NONAME + diff -r dc7c549001d5 -r 85266cc22c7f javaextensions/wma/sms_cbs/pushplugin/cbs/src.s60/cbsserverconnection.cpp --- a/javaextensions/wma/sms_cbs/pushplugin/cbs/src.s60/cbsserverconnection.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javaextensions/wma/sms_cbs/pushplugin/cbs/src.s60/cbsserverconnection.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -58,7 +58,7 @@ return cbsConn; } -CbsServerConnection::~CbsServerConnection() +OS_EXPORT CbsServerConnection::~CbsServerConnection() { JELOG2(EWMA); removeDir(mMessageStoreDirName); @@ -128,7 +128,7 @@ } } -void CbsServerConnection::open(ConnectionListener* aListener, +OS_EXPORT void CbsServerConnection::open(ConnectionListener* aListener, bool aIsAppLaunched) { JELOG2(EWMA); @@ -282,7 +282,7 @@ } } -int CbsServerConnection::retrieveMessage(TJavaMessageParametersBuf& aCbsBuf) +OS_EXPORT int CbsServerConnection::retrieveMessage(TJavaMessageParametersBuf& aCbsBuf) { JELOG2(EWMA); TCBSParametersBuf cbsParametersBuf; @@ -328,7 +328,7 @@ } -void CbsServerConnection::close() +OS_EXPORT void CbsServerConnection::close() { JELOG2(EWMA); // the close and RunL are synchronized to make it SMP safe. diff -r dc7c549001d5 -r 85266cc22c7f javaextensions/wma/sms_cbs/pushplugin/sms/build/eabi/javasmsscpluginu.def --- a/javaextensions/wma/sms_cbs/pushplugin/sms/build/eabi/javasmsscpluginu.def Thu May 27 12:49:31 2010 +0300 +++ b/javaextensions/wma/sms_cbs/pushplugin/sms/build/eabi/javasmsscpluginu.def Fri Jun 11 13:33:44 2010 +0300 @@ -10,23 +10,28 @@ _ZN26SmsServerConnectionFactoryD2Ev @ 9 NONAME _ZN4java3wma19SmsServerConnection15retrieveMessageER8TPckgBufI22TJavaMessageParametersE @ 10 NONAME _ZN4java3wma19SmsServerConnection4openEPNS_4push18ConnectionListenerE @ 11 NONAME - _ZN4java3wma19SmsServerConnectionC1ERKSbIwSt11char_traitsIwESaIwEES7_ @ 12 NONAME - _ZN4java3wma19SmsServerConnectionC2ERKSbIwSt11char_traitsIwESaIwEES7_ @ 13 NONAME - _ZN4java3wma19SmsServerConnectionD0Ev @ 14 NONAME - _ZN4java3wma19SmsServerConnectionD1Ev @ 15 NONAME - _ZN4java3wma19SmsServerConnectionD2Ev @ 16 NONAME - _ZN4java3wma20ServerConnectionBase9setFilterERKSbIwSt11char_traitsIwESaIwEE @ 17 NONAME - _ZNK4java3wma20ServerConnectionBase18getMessagesOnStoreEv @ 18 NONAME - _ZNK4java3wma20ServerConnectionBase6getUriEv @ 19 NONAME - _ZNK4java3wma20ServerConnectionBase9getFilterEv @ 20 NONAME - _ZTI26SmsServerConnectionFactory @ 21 NONAME ; ## - _ZTIN4java3wma19SmsServerConnectionE @ 22 NONAME ; ## - _ZTIN4java3wma20ServerConnectionBaseE @ 23 NONAME ; ## - _ZTV26SmsServerConnectionFactory @ 24 NONAME ; ## - _ZTVN4java3wma19SmsServerConnectionE @ 25 NONAME ; ## - _ZTVN4java3wma20ServerConnectionBaseE @ 26 NONAME ; ## - _ZThn28_N4java3wma19SmsServerConnection15retrieveMessageER8TPckgBufI22TJavaMessageParametersE @ 27 NONAME ; ## - _ZThn28_N4java3wma19SmsServerConnection4openEPNS_4push18ConnectionListenerE @ 28 NONAME ; ## - _ZThn28_N4java3wma19SmsServerConnectionD0Ev @ 29 NONAME ; ## - _ZThn28_N4java3wma19SmsServerConnectionD1Ev @ 30 NONAME ; ## + _ZN4java3wma19SmsServerConnection4openEPNS_4push18ConnectionListenerEb @ 12 NONAME + _ZN4java3wma19SmsServerConnection5closeEv @ 13 NONAME + _ZN4java3wma19SmsServerConnectionC1ERKSbIwSt11char_traitsIwESaIwEES7_ @ 14 NONAME + _ZN4java3wma19SmsServerConnectionC2ERKSbIwSt11char_traitsIwESaIwEES7_ @ 15 NONAME + _ZN4java3wma19SmsServerConnectionD0Ev @ 16 NONAME + _ZN4java3wma19SmsServerConnectionD1Ev @ 17 NONAME + _ZN4java3wma19SmsServerConnectionD2Ev @ 18 NONAME + _ZN4java3wma20ServerConnectionBase9setFilterERKSbIwSt11char_traitsIwESaIwEE @ 19 NONAME + _ZNK4java3wma20ServerConnectionBase18getMessagesOnStoreEv @ 20 NONAME + _ZNK4java3wma20ServerConnectionBase6getUriEv @ 21 NONAME + _ZNK4java3wma20ServerConnectionBase9getFilterEv @ 22 NONAME + _ZTI26SmsServerConnectionFactory @ 23 NONAME + _ZTIN4java3wma19SmsServerConnectionE @ 24 NONAME + _ZTIN4java3wma20ServerConnectionBaseE @ 25 NONAME + _ZTV26SmsServerConnectionFactory @ 26 NONAME + _ZTVN4java3wma19SmsServerConnectionE @ 27 NONAME + _ZTVN4java3wma20ServerConnectionBaseE @ 28 NONAME + _ZThn28_N4java3wma19SmsServerConnection15retrieveMessageER8TPckgBufI22TJavaMessageParametersE @ 29 NONAME + _ZThn28_N4java3wma19SmsServerConnection4openEPNS_4push18ConnectionListenerE @ 30 NONAME + _ZThn28_N4java3wma19SmsServerConnection4openEPNS_4push18ConnectionListenerEb @ 31 NONAME + _ZThn28_N4java3wma19SmsServerConnection5closeEv @ 32 NONAME + _ZThn28_N4java3wma19SmsServerConnectionD0Ev @ 33 NONAME + _ZThn28_N4java3wma19SmsServerConnectionD1Ev @ 34 NONAME + diff -r dc7c549001d5 -r 85266cc22c7f javaextensions/wma/sms_cbs/pushplugin/sms/src.s60/smsserverconnection.cpp --- a/javaextensions/wma/sms_cbs/pushplugin/sms/src.s60/smsserverconnection.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javaextensions/wma/sms_cbs/pushplugin/sms/src.s60/smsserverconnection.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -72,7 +72,7 @@ delete mOpenMonitor; } -void SmsServerConnection::open(ConnectionListener* aListener, +OS_EXPORT void SmsServerConnection::open(ConnectionListener* aListener, bool aIsAppLaunched) { JELOG2(EWMA); @@ -299,7 +299,7 @@ } -void SmsServerConnection::close() +OS_EXPORT void SmsServerConnection::close() { JELOG2(EWMA); // the close and RunL are synchronized to make it SMP safe. diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javacaptain/extensionplugins/autostarter/build/bwins/javacaptain_ext_autostarteru.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javamanager/javacaptain/extensionplugins/autostarter/build/bwins/javacaptain_ext_autostarteru.def Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,3 @@ +EXPORTS + ?findDllMethod@@YAP6APAXXZPBD@Z @ 1 NONAME ; void * (*)(void) findDllMethod(char const *) + diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javacaptain/extensionplugins/autostarter/build/eabi/javacaptain_ext_autostarteru.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javamanager/javacaptain/extensionplugins/autostarter/build/eabi/javacaptain_ext_autostarteru.def Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,3 @@ +EXPORTS + _Z13findDllMethodPKc @ 1 NONAME + diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javacaptain/extensionplugins/autostarter/build/javacaptain_ext_autostarter.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javamanager/javacaptain/extensionplugins/autostarter/build/javacaptain_ext_autostarter.pro Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,26 @@ +# +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: autostarter is plugin for Java Captain that starts auto start +# MIDlets +# + +TEMPLATE=lib +TARGET=javacaptain_ext_autostarter +CONFIG += omj stl +CONFIG -= qt + + +LIBS += -ljavacomms -ljavastorage + +include(../../../../../build/omj.pri) diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javacaptain/extensionplugins/autostarter/inc/autostarter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javamanager/javacaptain/extensionplugins/autostarter/inc/autostarter.h Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: autostarter is Java Captain Symbian plugin that starts +* auto start Java applications after they have been installed +* and when the device boots. +* +*/ + +#ifndef AUTOSTARTER_H +#define AUTOSTARTER_H + +#include "javaosheaders.h" + +#include "eventconsumerinterface.h" +#include "extensionplugininterface.h" + +namespace java +{ + +namespace captain +{ + +class CoreInterface; + +OS_NONSHARABLE_CLASS(AutoStarter) : public EventConsumerInterface, + public ExtensionPluginInterface +{ +public: + AutoStarter(); + virtual ~AutoStarter(); + + // PluginInterface + virtual void startPlugin(CoreInterface* aCore); + virtual void stopPlugin(); + + // EventConsumerInterface + virtual void event(const std::string& eventProvider, + java::comms::CommsMessage& aMsg); + + // ExtensionPluginInterface methods + virtual EventConsumerInterface* getEventConsumer(); + +private: + bool startMIDletL(const std::wstring& aUid); + void checkMIDletsToBeStartedL(); + + CoreInterface* mCore; +}; + +} // namespace captain +} // namespace java + +#endif // AUTOSTARTER_H diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javacaptain/extensionplugins/autostarter/src.s60/autostarter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javamanager/javacaptain/extensionplugins/autostarter/src.s60/autostarter.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,263 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: autostarter is Java Captain Symbian plugin that starts +* auto start Java applications after they have been installed +* and when the device boots. +* +*/ + +#include +#include +#include +#include +#include +#include + +#include "commsendpoint.h" +#include "coreinterface.h" +#include "javaprocessconstants.h" +#include "javasymbianoslayer.h" +#include "javauids.h" +#include "logger.h" +#include "preinstallerstartermessages.h" +#include "rtcinterface.h" +#include "rtcmessages.h" + +#include "autostarter.h" + + +using namespace java::storage; +using namespace java::util; + + +/** + * Return pointer to ExtensionPluginInterface implementation for this + * extension dll + */ +java::captain::ExtensionPluginInterface* getExtensionPlugin() +{ + return new java::captain::AutoStarter(); +} + +namespace java +{ +namespace captain +{ + +/** + * Empty contructor + */ +AutoStarter::AutoStarter() : mCore(0) +{ +} + +/** + * Empty destructor + */ +AutoStarter::~AutoStarter() +{ +} + +/** + * Implement PluginInterface method + */ +void AutoStarter::startPlugin(CoreInterface* core) +{ + LOG(EJavaCaptain, EInfo, "AutoStarter plugin started"); + + mCore = core; +} + +/** + * Implement PluginInterface method + */ +void AutoStarter::stopPlugin() +{ + mCore = 0; +} + +/** + * Implement ExtensionPluginInterface method + */ +EventConsumerInterface* AutoStarter::getEventConsumer() +{ + return this; +} + +/** + * Handle Java Captain events sent by Boot event provider or + * preinstaller starter + * + * Implement EventConsumerInterface method + */ +void AutoStarter::event(const std::string& eventProvider, + java::comms::CommsMessage& aMsg) +{ + LOG1(EJavaCaptain, EInfo, "AutoStarter::event received, id %d", aMsg.getMessageId()); + + if (eventProvider == PREINSTALLER_EVENT_PROVIDER) + { + int exitStatus = 0; + getPreinstallerExitedMessageParams(aMsg, exitStatus); + LOG1( + EJavaCaptain, + EInfo, + "AutoStarter::event() preinstaller exited event received (status=%d)", + exitStatus); + + // Start auto-start MIDlets + TRAPD(err, checkMIDletsToBeStartedL()) + if (KErrNone != err) + { + ELOG1(EJavaCaptain, "AutoStarter::checkMIDletsToBeStartedL: leaved (%d)", err); + } + } +/* + else if ( MESSAGE TELLS THAT NEW MIDLET HAS BEEN INSTALLED ) + { + // Auto-start the new MIDlet if it is auto-start MIDlet + } +*/ + +} + +/** + * + * + */ +void AutoStarter::checkMIDletsToBeStartedL() +{ + + + // Find all MIDlets with Nokia-MIDlet-auto-start + // APPLICATION_TABLE, if (AUTORUN == AUTOSTART_TRUE) || (AUTORUN == AUTOSTART_ONCE), + // call startMIDletL(ID) + + LOG(EJavaCaptain, EInfo, "AutoStarter::checkMIDletsToBeStartedL called"); + + std::auto_ptr js(JavaStorage::createInstance()); + try + { + js->open(JAVA_DATABASE_NAME); + + // In Java Storage there is 'APPLICATION_TABLE' table that contains + // the Uid of the application in ID column. The value in column AUTORUN is + // one of the following AUTOSTART_FALSE (0), AUTOSTART_TRUE (1) or + // AUTOSTART_ONCE (2) + + JavaStorageEntry attribute; + JavaStorageApplicationEntry_t findPattern; + JavaStorageApplicationList_t foundEntries; + + // Get all IDs from APPLICATION_TABLE where AUTORUN is AUTOSTART_TRUE + attribute.setEntry(AUTORUN, L"1"); + findPattern.insert(attribute); + attribute.setEntry(ID, L""); + findPattern.insert(attribute); + + js->search(APPLICATION_TABLE, findPattern, foundEntries); + findPattern.clear(); + + // Iterate through all found applications + JavaStorageApplicationList_t::const_iterator appIterator; + for (appIterator = foundEntries.begin(); appIterator != foundEntries.end(); ++appIterator) + { + std::wstring applicationId = appIterator->begin()->entryValue(); + + LOG1WSTR(EJavaCaptain, EInfo, + "AutoStarter::checkMIDletsToBeStartedL : going to start MIDlet, uid is %s", + applicationId); + + startMIDletL(applicationId); + } + foundEntries.clear(); + + + // Get all IDs from APPLICATION_TABLE where AUTORUN is AUTOSTART_ONCE + attribute.setEntry(AUTORUN, L"2"); + findPattern.insert(attribute); + attribute.setEntry(ID, L""); + findPattern.insert(attribute); + + js->search(APPLICATION_TABLE, findPattern, foundEntries); + findPattern.clear(); + + // Iterate through all found applications + for (appIterator = foundEntries.begin(); appIterator != foundEntries.end(); ++appIterator) + { + std::wstring applicationId = appIterator->begin()->entryValue(); + + LOG1WSTR(EJavaCaptain, EInfo, + "AutoStarter::checkMIDletsToBeStartedL : going to start MIDlet (once), uid is %s", + applicationId); + + if (startMIDletL(applicationId)) + { + // after starting MIDlet must set AUTORUN value to AUTOSTART_FALSE + JavaStorageApplicationEntry_t matchEntries; + + JavaStorageApplicationEntry_t updateEntries; + JavaStorageEntry attribute; + + attribute.setEntry(ID, applicationId); + matchEntries.insert(attribute); + + attribute.setEntry(AUTORUN, L"0"); + updateEntries.insert(attribute); + + js->update(APPLICATION_TABLE, updateEntries, matchEntries); + } + } + foundEntries.clear(); + } + catch (JavaStorageException& e) + { + ELOG1(EJavaCaptain, + "AutoStarter::checkMIDletsToBeStartedL: Java Storage exception %s", e.what()); + } + + try + { + js->close(); + } + catch (JavaStorageException& e2) + { + WLOG1(EJavaCaptain, + "AutoStarter::checkMIDletsToBeStartedL: Java Storage exception " + "when closing storage %s", e2.what()); + } +} + + +/** + * + * @return true if launch succeeded, false is starting failed + */ +bool AutoStarter::startMIDletL(const std::wstring& aUid) +{ + // start MIDlet + rtcLaunchInfo launchInfo(aUid); + + bool launchSuccess = mCore->getRtc()->launch(launchInfo); + if (!launchSuccess) + { + ELOG(EJavaCaptain, "AutoStarter::startMIDletL: launching MIDlet failed"); + } + + return launchSuccess; +} + + +} // namespace captain +} // namespace java diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javacaptain/extensionplugins/autostarter/src.s60/lookup.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javamanager/javacaptain/extensionplugins/autostarter/src.s60/lookup.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: lookup +* +*/ + +#include //For strcmp + +#include "javasymbianoslayer.h" +#include "logger.h" + +#include "extensionplugininterface.h" + +using namespace java::captain; + +ExtensionPluginInterface* getExtensionPlugin(); + +EXPORT_C FuncPtr findDllMethod(const char* funcName) +{ + FuncPtr ptr = 0; + if (funcName) + { + if (strcmp(funcName, "getExtensionPlugin") == 0) + { + ptr = (FuncPtr)getExtensionPlugin; + } + } + else + { + ELOG(EJavaCaptain, + "scrupdater extensionplugin findDllMethod() funcName == null"); + } + return ptr; +} diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javacaptain/extensionplugins/config/src/configextensionplugin.cpp --- a/javamanager/javacaptain/extensionplugins/config/src/configextensionplugin.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javacaptain/extensionplugins/config/src/configextensionplugin.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -74,6 +74,9 @@ #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK mCore->loadExtensionPlugin("scrupdater"); #endif // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK + // This plugin implements support for auto-starting + // Java applications + mCore->loadExtensionPlugin("autostarter"); #endif // __SYMBIAN32__ mCore->loadExtensionPlugin("boot"); mCore->loadExtensionPlugin("mmc"); diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javacaptain/extensionplugins/preinstallerstarter/build/exports.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javamanager/javacaptain/extensionplugins/preinstallerstarter/build/exports.inf Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,19 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +PRJ_EXPORTS +../inc/preinstallerstartermessages.h |../../../../../inc/preinstallerstartermessages.h diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javacaptain/extensionplugins/preinstallerstarter/inc/preinstallerstarter.h --- a/javamanager/javacaptain/extensionplugins/preinstallerstarter/inc/preinstallerstarter.h Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javacaptain/extensionplugins/preinstallerstarter/inc/preinstallerstarter.h Fri Jun 11 13:33:44 2010 +0300 @@ -33,7 +33,8 @@ class CoreInterface; -OS_NONSHARABLE_CLASS(PreinstallerStarter) : public EventConsumerInterface, +OS_NONSHARABLE_CLASS(PreinstallerStarter) : public CActive, + public EventConsumerInterface, public ExtensionPluginInterface { public: @@ -51,11 +52,17 @@ // ExtensionPluginInterface methods virtual EventConsumerInterface* getEventConsumer(); +protected: + // CActive + virtual void RunL(); + virtual void DoCancel(); + private: void startPreinstaller(TBool aIadBoot); void registerMidletApplicationTypeHandler(); CoreInterface* mCore; + RProcess* mPreinstaller; }; } // namespace captain diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javacaptain/extensionplugins/preinstallerstarter/inc/preinstallerstartermessages.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javamanager/javacaptain/extensionplugins/preinstallerstarter/inc/preinstallerstartermessages.h Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: PreinstallerStarterMessages +* +*/ + +#ifndef PREINSTALLERSTARTERMESSAGES_H +#define PREINSTALLERSTARTERMESSAGES_H + +#include "logger.h" +#include "commsmessage.h" + +namespace java +{ +namespace captain +{ + +using namespace java::util; +using namespace java::comms; + +// This event is sent when preinstaller process has exited +const int PREINSTALLER_EVENT_MESSAGE_ID_EXITED_C = 30; + +const char PREINSTALLER_EVENT_PROVIDER[] = "preinstaller"; + + +inline void setPreinstallerExitedMessageParams(CommsMessage& aMessage, const int& aExitStatus) +{ + aMessage.setMessageId(PREINSTALLER_EVENT_MESSAGE_ID_EXITED_C); + aMessage << aExitStatus; +} + +inline void getPreinstallerExitedMessageParams(CommsMessage& aMessage, int& aExitStatus) +{ + if (aMessage.getMessageId() == PREINSTALLER_EVENT_MESSAGE_ID_EXITED_C) + { + aMessage >> aExitStatus; + } + else + { + ELOG2(EJavaCaptain, "wrong MessageId!: %d should be %d", + aMessage.getMessageId(), PREINSTALLER_EVENT_MESSAGE_ID_EXITED_C); + aExitStatus = 0; + } +} + + +} // namespace captain +} // namespace java + +#endif // PREINSTALLERSTARTERMESSAGES_H diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javacaptain/extensionplugins/preinstallerstarter/src.s60/preinstallerstarter.cpp --- a/javamanager/javacaptain/extensionplugins/preinstallerstarter/src.s60/preinstallerstarter.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javacaptain/extensionplugins/preinstallerstarter/src.s60/preinstallerstarter.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2008 - 2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -31,6 +31,7 @@ #include "coreinterface.h" #include "booteventprovidermessages.h" #include "mmceventprovidermessages.h" +#include "preinstallerstartermessages.h" #include "preinstallerstarter.h" @@ -52,19 +53,19 @@ using java::fileutils::DriveListenerInterface; /** - * Empty contructor + * Initialize member varaibles in constructor */ -PreinstallerStarter::PreinstallerStarter() : mCore(0) +PreinstallerStarter::PreinstallerStarter() : + CActive(EPriorityStandard), mCore(0), mPreinstaller(0) { - JELOG2(EJavaCaptain); } /** - * Empty destructor + * Destructor */ PreinstallerStarter::~PreinstallerStarter() { - JELOG2(EJavaCaptain); + DoCancel(); } /** @@ -72,8 +73,8 @@ */ void PreinstallerStarter::startPlugin(CoreInterface* core) { - JELOG2(EJavaCaptain); mCore = core; + CActiveScheduler::Add(this); } /** @@ -81,7 +82,6 @@ */ void PreinstallerStarter::stopPlugin() { - JELOG2(EJavaCaptain); mCore = 0; } @@ -90,7 +90,6 @@ */ EventConsumerInterface* PreinstallerStarter::getEventConsumer() { - JELOG2(EJavaCaptain); return this; } @@ -106,7 +105,6 @@ void PreinstallerStarter::event(const std::string& eventProvider, java::comms::CommsMessage& aMsg) { - JELOG2(EJavaCaptain); if (eventProvider == BOOT_EVENT_PROVIDER) { int bootType = NORMAL_BOOT_C; @@ -133,7 +131,9 @@ case FIRST_DEVICE_BOOT_C: case NORMAL_BOOT_C: { +#ifndef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK registerMidletApplicationTypeHandler(); +#endif // Start preinstaller normally (without 'iad' option). startPreinstaller(EFalse); @@ -183,8 +183,6 @@ */ void PreinstallerStarter::startPreinstaller(TBool aIadBoot) { - JELOG2(EJavaCaptain); - // Check that the device has enough free memory (800kB) to start preinstaller process // and (if needed) also java installer TInt freeMemory = 0; @@ -276,17 +274,21 @@ } // start preinstaller - RProcess preinstaller; + mPreinstaller = new RProcess(); TBuf<64> preinstallerProcess; // Actual len of the process name is 9 len = strlen(java::runtime::JAVA_PROCESS); TPtr8 ptr8Process((TUint8 *)java::runtime::JAVA_PROCESS, len, len); preinstallerProcess.Copy(ptr8Process); - TInt err = preinstaller.Create(preinstallerProcess, commandLine); + TInt err = mPreinstaller->Create(preinstallerProcess, commandLine); if (KErrNone == err) { - // process has been created, allow it to run - preinstaller.Resume(); - preinstaller.Close(); + // Process has been created. + + // This active object will be activated when preinstaller process exits + mPreinstaller->Logon(iStatus); + + // Allow the process to run + mPreinstaller->Resume(); if (aIadBoot) { LOG( @@ -298,9 +300,14 @@ { LOG(EJavaCaptain, EInfo, "PreinstallerStarter: started preinstaller"); } + + SetActive(); } else { + delete mPreinstaller; + mPreinstaller = 0; + ELOG1( EJavaCaptain, "PreinstallerStarter: starting preinstaller failed, err %d", @@ -375,5 +382,35 @@ } } +void PreinstallerStarter::RunL() +{ + LOG(EJavaCaptain, EInfo, "PreinstallerStarter::RunL started"); + + // Send event to AutoStarter plugin, done only once + CommsMessage eventMsg; + setPreinstallerExitedMessageParams(eventMsg, iStatus.Int()); + mCore->getEventDispatcher()->event(PREINSTALLER_EVENT_PROVIDER, eventMsg); + + // process handle is no longer needed + mPreinstaller->Close(); + delete mPreinstaller; + mPreinstaller = 0; +} + + +void PreinstallerStarter::DoCancel() +{ + if (mPreinstaller) + { + mPreinstaller->LogonCancel(iStatus); + // Because exit notification request has been canceled, + // there is no reason to keep the process handle open. + mPreinstaller->Close(); + delete mPreinstaller; + mPreinstaller = 0; + } +} + + } // namespace captain } // namespace java diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javacaptain/javacaptain.pro --- a/javamanager/javacaptain/javacaptain.pro Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javacaptain/javacaptain.pro Fri Jun 11 13:33:44 2010 +0300 @@ -19,5 +19,6 @@ SUBDIRS += extensionplugins/javacertstore/build/javacaptain_ext_javacertstore.pro SUBDIRS += extensionplugins/storageserver/build/javacaptain_ext_storageserverplugin.pro SUBDIRS += extensionplugins/preinstallerstarter/build/javacaptain_ext_preinstallerstarter.pro +SUBDIRS += extensionplugins/autostarter/build/javacaptain_ext_autostarter.pro SUBDIRS += extensionplugins/scrupdater/build/javacaptain_ext_scrupdater.pro BLD_INF_RULES.prj_extensions += "prj_extensions" diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javacaptain/subsystem.mk --- a/javamanager/javacaptain/subsystem.mk Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javacaptain/subsystem.mk Fri Jun 11 13:33:44 2010 +0300 @@ -35,6 +35,7 @@ endif COMPONENTS += extensionplugins/preinstallerstarter/build +COMPONENTS += extensionplugins/autostarter/build ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK COMPONENTS += extensionplugins/scrupdater/build endif diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/appinstuiplugin/src/javainstalllauncher.cpp --- a/javamanager/javainstaller/appinstuiplugin/src/javainstalllauncher.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/appinstuiplugin/src/javainstalllauncher.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -619,7 +619,7 @@ // Open UI env and resource file. if (!iEik) { - iEik = CEikonEnv::Static(); + iEik = CEikonEnv::Static(); // codescanner::eikonenvstatic } if (!iEik) { diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installer/build/exports.inf --- a/javamanager/javainstaller/installer/build/exports.inf Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installer/build/exports.inf Fri Jun 11 13:33:44 2010 +0300 @@ -27,11 +27,12 @@ ../data/inst_plugins.cfg /epoc32/data/z/private/102033E6/installer/inst_plugins.cfg -// Generic configuration interface for javainstaller cenrep settings -// javainstaller_102824CE implementation specifics for cenrep data +// Configuration interface for javainstaller #ifdef RD_JAVA_S60_RELEASE_10_1_ONWARDS +// Public configuration interface is named as CI_javainstaller.confml +// and it is located outside of jrt package. The name of private +// configuration interface is javainstaller2.confml. ../conf/javainstaller2.confml APP_LAYER_CONFML(javainstaller.confml) -../conf/CI_javainstaller.confml APP_LAYER_CONFML(CI_javainstaller.confml) #else ../conf/javainstaller.confml APP_LAYER_CONFML(javainstaller.confml) #endif /* RD_JAVA_S60_RELEASE_10_1_ONWARDS */ diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installer/build/javainstaller.pro --- a/javamanager/javainstaller/installer/build/javainstaller.pro Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installer/build/javainstaller.pro Fri Jun 11 13:33:44 2010 +0300 @@ -60,7 +60,8 @@ } contains(PROJECT_DEFINES,RD_JAVA_S60_RELEASE_10_1_ONWARDS) { - LIBS += -lQtServiceFramework + CONFIG += hb + LIBS += -lxqservice } contains(PROJECT_DEFINES,RD_JAVA_USIF_NOTIFY_PROGRESS) { diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installer/conf/CI_javainstaller.confml Binary file javamanager/javainstaller/installer/conf/CI_javainstaller.confml has changed diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installer/javasrc.s60/com/nokia/mj/impl/installer/applicationregistrator/SifNotifier.java --- a/javamanager/javainstaller/installer/javasrc.s60/com/nokia/mj/impl/installer/applicationregistrator/SifNotifier.java Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installer/javasrc.s60/com/nokia/mj/impl/installer/applicationregistrator/SifNotifier.java Fri Jun 11 13:33:44 2010 +0300 @@ -41,6 +41,8 @@ public static final int SUB_OP_OCSP = 2; /** Download phase during installation. */ public static final int SUB_OP_DOWNLOAD = 3; + /** Maximum progress notification value. */ + private static final int MAX_PROGRESS = 100; /** Operation being notified. */ private int iOperation = 0; @@ -62,6 +64,8 @@ /** Sending progress notifications is only allowed between start * and end notifications. */ private boolean iNotifyProgressAllowed = false; + /** Value of the last progress notification that has been sent. */ + private int iLastProgressSent = 0; /** Native object handle. */ private int iHandle = 0; @@ -119,6 +123,10 @@ InstallerException.internalError( "Notifying SIF start failed with code " + ret); } + else + { + Log.log("SifNotifier.notifyStart: " + getInfoString()); + } iNotifyProgressAllowed = true; } @@ -135,21 +143,34 @@ InstallerException.internalError( "SifNotifier.notifyEnd: notifier has not been initialized"); } + if (aErrCategory == 0 && iLastProgressSent < MAX_PROGRESS) + { + // Before sending end notification, update progress to max if + // operation was successful and max progress notification has + // not yet been sent. + notifyProgress(SUB_OP_NO, MAX_PROGRESS, MAX_PROGRESS); + } + // No more progress notifications allowed. iNotifyProgressAllowed = false; int ret = _notifyEnd( iHandle, iGlobalComponentId, aErrCategory, aErrCode, aErrMsg, aErrMsgDetails); + String logMsg = + "ErrCategory: " + aErrCategory + + ", ErrCode: " + aErrCode + + ", ErrMsg: " + aErrMsg + + ", ErrMsgDetails: " + aErrMsgDetails; if (ret < 0) { Log.logError("Notifying SIF end failed with code " + ret + - ", " + getInfoString() + - ", ErrCategory: " + aErrCategory + - ", ErrCode: " + aErrCode + - ", ErrMsg: " + aErrMsg + - ", ErrMsgDetails: " + aErrMsgDetails); + ", " + getInfoString() + ", " + logMsg); InstallerException.internalError( "Notifying SIF end failed with code " + ret); } + else + { + Log.log("SifNotifier.notifyEnd: " + logMsg); + } } /** @@ -168,19 +189,28 @@ InstallerException.internalError( "SifNotifier.notifyProgress: notifier has not been initialized"); } + if (aSubOperation == SUB_OP_NO) + { + iLastProgressSent = aCurrent; + } int ret = _notifyProgress( iHandle, iGlobalComponentId, iOperation, aSubOperation, aCurrent, aTotal); + String logMsg = + "SubOp: " + aSubOperation + + ", Current: " + aCurrent + + ", Total: " + aTotal; if (ret < 0) { Log.logError("Notifying SIF progress failed with code " + ret + - ", " + getInfoString() + - ", SubOp: " + aSubOperation + - ", Current: " + aCurrent + - ", Total: " + aTotal); + ", " + getInfoString() + ", " + logMsg); InstallerException.internalError( "Notifying SIF progress failed with code " + ret); } + else + { + Log.log("SifNotifier.notifyProgress: " + logMsg); + } } /** @@ -202,6 +232,10 @@ InstallerException.internalError( "Destroying SIF notifier failed with code " + ret); } + else + { + Log.log("SifNotifier destroyed"); + } iHandle = 0; } @@ -221,6 +255,10 @@ InstallerException.internalError( "Initializing SifNotifier failed with code " + ret); } + else + { + Log.log("SifNotifier created"); + } iHandle = ret; } @@ -235,11 +273,31 @@ buf.append("Operation: ").append(iOperation); buf.append(", GlobalComponentId: ").append(iGlobalComponentId); buf.append(", ComponentName: ").append(iComponentName); - for (int i = 0; i < iApplicationNames.length; i++) + if (iApplicationNames != null) { - buf.append(", ApplicationName: ").append(iApplicationNames[i]); + for (int i = 0; i < iApplicationNames.length; i++) + { + buf.append(", ApplicationName[").append(i).append("]: ") + .append(iApplicationNames[i]); + } + } + if (iApplicationIcons != null) + { + for (int i = 0; i < iApplicationIcons.length; i++) + { + buf.append(", ApplicationIcon[").append(i).append("]: ") + .append(iApplicationIcons[i]); + } } buf.append(", ComponentSize: ").append(iComponentSize); + if (iIconDir != null) + { + buf.append(", IconDir: ").append(iIconDir); + } + if (iComponentIcon != null) + { + buf.append(", ComponentIcon: ").append(iComponentIcon); + } return buf.toString(); } diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installer/javasrc.s60/com/nokia/mj/impl/installer/applicationregistrator/SifRegistrator.java --- a/javamanager/javainstaller/installer/javasrc.s60/com/nokia/mj/impl/installer/applicationregistrator/SifRegistrator.java Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installer/javasrc.s60/com/nokia/mj/impl/installer/applicationregistrator/SifRegistrator.java Fri Jun 11 13:33:44 2010 +0300 @@ -25,7 +25,6 @@ import com.nokia.mj.impl.installer.utils.FileUtils; import com.nokia.mj.impl.installer.utils.Log; import com.nokia.mj.impl.installer.utils.PlatformUid; -import com.nokia.mj.impl.rt.installer.ApplicationInfoImpl; import com.nokia.mj.impl.utils.Attribute; import com.nokia.mj.impl.utils.Uid; @@ -129,27 +128,6 @@ } /** - * Registers or unregisters Java software type to software - * installation framework. - * - * @param aRegister true for registration, false for unregistration - */ - public static void registerJavaSoftwareType(boolean aRegister) - { - String op = (aRegister? "Register": "Unregister"); - int err = _registerJavaSoftwareType(aRegister); - if (err < 0) - { - InstallerException.internalError( - op + " Java software type failed with code " + err); - } - else - { - Log.log("SifRegistrator " + op + "ed Java software type"); - } - } - - /** * Starts application registration session. * The registrations and unregistrations are done only * when commitSession is called. @@ -690,15 +668,20 @@ private static String[] getComponentFiles(SuiteInfo aSuite) { Vector componentFiles = new Vector(); - String path = aSuite.getJadPath(); - if (path != null) + if (!aSuite.isPreinstalled()) { - componentFiles.addElement(getScrString(path)); - } - path = aSuite.getJarPath(); - if (path != null) - { - componentFiles.addElement(getScrString(path)); + // Add component jad and jar files only when the + // application is not preinstalled. + String path = aSuite.getJadPath(); + if (path != null) + { + componentFiles.addElement(getScrString(path)); + } + path = aSuite.getJarPath(); + if (path != null) + { + componentFiles.addElement(getScrString(path)); + } } boolean addRootPath = true; int rootDrive = FileUtils.getDrive(aSuite.getRootDir()); @@ -716,10 +699,15 @@ } if (addRootPath) { - componentFiles.addElement(getScrString(aSuite.getRootDir())); + componentFiles.addElement( + getScrString(aSuite.getRootDir() + "nofile.txt")); } String[] result = new String[componentFiles.size()]; componentFiles.copyInto(result); + for (int i = 0; i < result.length; i++) + { + Log.log("SifRegistrator componentFiles[" + i + "]: " + result[i]); + } return result; } @@ -826,21 +814,58 @@ } // Register Domain-Category property. - ApplicationInfoImpl appInfoImpl = (ApplicationInfoImpl) - com.nokia.mj.impl.rt.support.ApplicationInfo.getInstance(); - String domainCategory = appInfoImpl.getProtectionDomain(); - err = _setLocalizedComponentProperty( - iSessionHandle, cid, "Domain-Category", - domainCategory, UNSPECIFIED_LOCALE); - if (err < 0) + String protectionDomainProperty = "Domain-Category"; + String protectionDomainName = aSuite.getProtectionDomainName(); + if (protectionDomainName != null) + { + err = _setLocalizedComponentProperty( + iSessionHandle, cid, protectionDomainProperty, + getProtectionDomainPropertyValue(protectionDomainName), + UNSPECIFIED_LOCALE); + if (err < 0) + { + InstallerException.internalError( + "Adding property " + protectionDomainProperty + + " value " + protectionDomainName + " for component " + + cid + " failed with code " + err); + } + } + else { - InstallerException.internalError( - "Adding property Domain-Category value " + domainCategory + - " for component " + cid + " failed with code " + err); + Log.logWarning( + "SifRegistrator.registerLocalizedProperties: " + + protectionDomainProperty + " not set"); } } /** + * Returns the "Domain-Category" property value which contains + * the text id and text file name for the localized domain category + * text. + */ + private String getProtectionDomainPropertyValue(String aProtectionDomain) + { + String textId = null; + if (aProtectionDomain.equals("Manufacturer")) + { + textId = "txt_java_inst_setlabel_cert_domain_val_manufacturer"; + } + else if (aProtectionDomain.equals("Operator")) + { + textId = "txt_java_inst_setlabel_cert_domain_val_operator"; + } + else if (aProtectionDomain.equals("IdentifiedThirdParty")) + { + textId = "txt_java_inst_setlabel_cert_domain_val_trusted_third_party"; + } + else if (aProtectionDomain.equals("UnidentifiedThirdParty")) + { + textId = "txt_java_inst_setlabel_cert_domain_val_untrusted_third_party"; + } + return textId + ",javaapplicationinstaller"; + } + + /** * Returns array of localized names from the specified * attributes of given suite. Assumes that aAttrPrefix * is an attribute name prefix that is followed by locale. @@ -949,14 +974,6 @@ private static native int _launchAppView(); /** - * Registers Java software type to software installation framework. - * - * @param aRegister true for registration, false for unregistration - * @return 0 or Symbian error code (negative number) - */ - private static native int _registerJavaSoftwareType(boolean aRegister); - - /** * Starts native application registration session. * * @param aTransaction true if also transaction for this session should diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installer/javasrc.s60/com/nokia/mj/impl/installer/utils/SysUtil.java --- a/javamanager/javainstaller/installer/javasrc.s60/com/nokia/mj/impl/installer/utils/SysUtil.java Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installer/javasrc.s60/com/nokia/mj/impl/installer/utils/SysUtil.java Fri Jun 11 13:33:44 2010 +0300 @@ -441,6 +441,44 @@ return ret; } + /** + * Maps given ISO language/country code to Symbian TLanguage. + * + * @param aLocale ISO language/country code + * @return Symbian TLanguage value, or -1 if no matching language is found. + */ + public static int isoToLang(String aLocale) + { + // Replace possible dash with underscore. + aLocale = aLocale.replace('-', '_'); + // Get language and country parts. + String lang = aLocale.toLowerCase(); + String country = null; + int sepIndex = aLocale.indexOf("_"); + if (sepIndex >= 0) + { + lang = aLocale.substring(0, sepIndex).toLowerCase(); + country = aLocale.substring(sepIndex + 1).toUpperCase(); + } + // Map locale to Symbian TLanguage using native service. + int result = -1; + if (country == null) + { + result = _isoToLang(lang); + } + else + { + result = _isoToLang(lang + "_" + country); + if (result == -1) + { + // No result for language and country, try using language only. + result = _isoToLang(lang); + } + } + //Log.log("SysUtil.isoToLang: " + aLocale + " ==> " + result); + return result; + } + /*** ---------------------------- PROTECTED --------------------------- */ /*** ----------------------------- PACKAGE ---------------------------- */ /*** ----------------------------- PRIVATE ---------------------------- */ @@ -648,6 +686,14 @@ private static native int _getScreenHeight(); /** + * Maps given ISO language/country code to Symbian TLanguage. + * + * @param aLocale ISO language/country code + * @return Symbian TLanguage value, or -1 if no matching language is found. + */ + private static native int _isoToLang(String aLocale); + + /** * Class for holding return value from native side. */ private static class IntValue diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/InstallationNotifier.java --- a/javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/InstallationNotifier.java Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/InstallationNotifier.java Fri Jun 11 13:33:44 2010 +0300 @@ -278,8 +278,6 @@ } if (iSifNotifier != null) { - Log.log("InstallationNotifier.set: update SifNotifier to " + - currentPercentage); try { iSifNotifier.notifyProgress( diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/Installer.java --- a/javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/Installer.java Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/Installer.java Fri Jun 11 13:33:44 2010 +0300 @@ -336,7 +336,7 @@ if (iThreadDumper != null) { - iThreadDumper.startTimer(10*60*1000); // 10 mins + iThreadDumper.startTimer(5*60*1000); // 5 mins } try @@ -538,9 +538,9 @@ table.add(new com.nokia.mj.impl.installer.midp2.install.steps. GetFromStorage()); table.add(new com.nokia.mj.impl.installer.midp2.install.steps. - StartProgressNotifications()); + SelectUids()); // Select suite uid and application uids. table.add(new com.nokia.mj.impl.installer.midp2.install.steps. - SelectUids()); // Select suite uid and application uids. + StartProgressNotifications()); table.add(new com.nokia.mj.impl.installer.midp2.install.steps. AuthenticateJad()); // This must be the first security // related step. diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/midp2/install/steps/DlListener.java --- a/javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/midp2/install/steps/DlListener.java Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/midp2/install/steps/DlListener.java Fri Jun 11 13:33:44 2010 +0300 @@ -81,8 +81,6 @@ } if (iBall.iSifNotifier != null) { - Log.log("DlListener.set: update SifNotifier to " + - aDlInfo.getCurrentSize() + " / " + aDlInfo.getTotalSize()); try { iBall.iSifNotifier.notifyProgress( diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/midp2/install/steps/FinalizeInstallation.java --- a/javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/midp2/install/steps/FinalizeInstallation.java Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/midp2/install/steps/FinalizeInstallation.java Fri Jun 11 13:33:44 2010 +0300 @@ -302,11 +302,11 @@ } } - //if (ball.iSifRegistrator.getSifMode() > 0 && launchApp) - //{ - // ball.iSifRegistrator.launchAppView(); - //} - //else + if (ball.iSifRegistrator.getSifMode() > 0 && launchApp) + { + ball.iSifRegistrator.launchAppView(); + } + else if (ball.iCaptainMsgs && launchApp && launchAppInfo.getApplications() != null && launchAppInfo.getApplications().length > 0) diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/midp2/install/steps/HandleCustomAttributes.java --- a/javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/midp2/install/steps/HandleCustomAttributes.java Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/midp2/install/steps/HandleCustomAttributes.java Fri Jun 11 13:33:44 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -23,10 +23,13 @@ import com.nokia.mj.impl.installer.storagehandler.ApplicationInfo; import com.nokia.mj.impl.installer.storagehandler.SuiteInfo; import com.nokia.mj.impl.installer.utils.Log; +import com.nokia.mj.impl.installer.utils.AutoStartPermission; import com.nokia.mj.impl.utils.InstallerDetailedErrorMessage; import com.nokia.mj.impl.utils.InstallerErrorMessage; import com.nokia.mj.impl.utils.OtaStatusCode; import com.nokia.mj.impl.utils.exception.InvalidAttributeException; +import com.nokia.mj.impl.security.midp.authorization.AccessControllerFactoryImpl; +import com.nokia.mj.impl.security.midp.authorization.AccessControllerImpl; import java.util.Vector; @@ -98,18 +101,52 @@ { String attrName = "Nokia-MIDlet-Auto-Start-" + i; String attrValue = aBall.getAttributeValue(attrName); + + if (attrValue == null) + { + // Allow also this form of the name to be compatible with + // an existing implementation + attrName = "Nokia-MIDlet-auto-start-" + i; + attrValue = aBall.getAttributeValue(attrName); + + if ((attrValue == null) && (i == 1)) + { + // Allow even this S40 format + attrName = "Nokia-MIDlet-auto-start"; + attrValue = aBall.getAttributeValue(attrName); + } + } + if (attrValue != null) { if (apps.size() < i) { break; } - if (attrValue.equalsIgnoreCase("false")) + + // Check if MIDlet has permission for Auto-start + AccessControllerImpl accessControllerImpl = + AccessControllerFactoryImpl. + getAccessController(aBall.iStorageHandler.getSession(), + aBall.iSuite.getUid(), + aBall.iSuite.getName()); + AutoStartPermission autoStartPermission = new AutoStartPermission(); + if (!accessControllerImpl.isPermissionAllowed( + autoStartPermission.toString())) + { + Log.logWarning("Attribute " + attrName + + " ignored due to insufficient permissions"); + break; + } + + if (attrValue.equalsIgnoreCase("false") || + attrValue.equalsIgnoreCase("no")) { ((ApplicationInfo)apps.elementAt(i-1)). setAutoStart(ApplicationInfo.AUTOSTART_FALSE); } - else if (attrValue.equalsIgnoreCase("true")) + else if (attrValue.equalsIgnoreCase("true") || + attrValue.equalsIgnoreCase("yes")) { ((ApplicationInfo)apps.elementAt(i-1)). setAutoStart(ApplicationInfo.AUTOSTART_TRUE); diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/midp2/install/steps/OcspListener.java --- a/javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/midp2/install/steps/OcspListener.java Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/midp2/install/steps/OcspListener.java Fri Jun 11 13:33:44 2010 +0300 @@ -78,7 +78,6 @@ } if (iBall.iSifNotifier != null) { - Log.log("OcspListener.ocspEvent: update SifNotifier to 0 / 0"); try { iBall.iSifNotifier.notifyProgress( @@ -109,7 +108,6 @@ } if (iBall.iSifNotifier != null) { - Log.log("OcspListener.ocspEvent: update SifNotifier to 100 / 100"); try { iBall.iSifNotifier.notifyProgress( diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/midp2/install/steps/RegisterApplicationToSif.java --- a/javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/midp2/install/steps/RegisterApplicationToSif.java Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/midp2/install/steps/RegisterApplicationToSif.java Fri Jun 11 13:33:44 2010 +0300 @@ -40,11 +40,11 @@ Log.log("Old suite unregistered from SIF"); } - if (ball.iSourceUrl != null) + if (ball.iAuthenticationCredentials != null) { - // Save source URL to suite as jad URL which is - // registered to SIF as download URL. - ball.iSuite.setJadUrl(ball.iSourceUrl); + // Set protection domain name. + ball.iSuite.setProtectionDomainName( + ball.iAuthenticationCredentials[0].getProtectionDomainName()); } // Initialize application installation group to SuiteInfo. diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/midp2/install/steps/StartProgressNotifications.java --- a/javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/midp2/install/steps/StartProgressNotifications.java Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/midp2/install/steps/StartProgressNotifications.java Fri Jun 11 13:33:44 2010 +0300 @@ -100,8 +100,16 @@ catch (Throwable t) { Log.logError("StartProgressNotifications: SifNotifier.notifyStart failed", t); + try + { + ball.iSifNotifier.destroy(); + } + catch (Throwable t2) + { + Log.logError("StartProgressNotifications: SifNotifier.destroy failed", t2); + } + ball.iSifNotifier = null; } - // Set SifNotifier for the listeners that should use it. ball.iInstallationNotifier.setSifNotifier(ball.iSifNotifier); } diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/midp2/uninstall/steps/StartProgressNotifications.java --- a/javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/midp2/uninstall/steps/StartProgressNotifications.java Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/midp2/uninstall/steps/StartProgressNotifications.java Fri Jun 11 13:33:44 2010 +0300 @@ -91,8 +91,16 @@ catch (Throwable t) { Log.logError("StartProgressNotifications: SifNotifier.notifyStart failed", t); + try + { + ball.iSifNotifier.destroy(); + } + catch (Throwable t2) + { + Log.logError("StartProgressNotifications: SifNotifier.destroy failed", t2); + } + ball.iSifNotifier = null; } - // Set SifNotifier for the listeners that should use it. ball.iInstallationNotifier.setSifNotifier(ball.iSifNotifier); } diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/storagehandler/SuiteInfo.java --- a/javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/storagehandler/SuiteInfo.java Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installer/javasrc/com/nokia/mj/impl/installer/storagehandler/SuiteInfo.java Fri Jun 11 13:33:44 2010 +0300 @@ -80,6 +80,8 @@ private String iConvertedIconPath = null; /** Application installation group. This member is not saved into storage. */ private String iInstallationGroup = null; + /** Protection domain name. This member is not saved into storage. */ + private String iProtectionDomainName = null; /** * Combined Jad and Manifest attributes. Key is attribute name, @@ -521,6 +523,22 @@ } /** + * Get protection domain name. + */ + public String getProtectionDomainName() + { + return iProtectionDomainName; + } + + /** + * Set protection domain name. + */ + public void setProtectionDomainName(String aProtectionDomainName) + { + iProtectionDomainName = aProtectionDomainName; + } + + /** * Set suite uid. * * @param aUid suite uid @@ -740,6 +758,14 @@ } /** + * Returns true if this application suite is preinstalled, false otherwise. + */ + public boolean isPreinstalled() + { + return (iPreinstallState == STATE_PREINSTALLED); + } + + /** * Set flag telling if application suite is preinstalled. * * @param aTrusted true if suite is preinstalled, false otherwise @@ -842,6 +868,7 @@ buf.append(" OnScreenKeypad: ").append(getOnScreenKeypad()).append("\n"); buf.append(" ConvertedIcon: ").append(getConvertedIconPath()).append("\n"); buf.append(" Group: ").append(getInstallationGroup()).append("\n"); + buf.append(" Protection domain: ").append(getProtectionDomainName()).append("\n"); if (iApplications != null) { buf.append("Applications:\n"); diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installer/src.s60/applicationregistrator/applicationregistrator.cpp --- a/javamanager/javainstaller/installer/src.s60/applicationregistrator/applicationregistrator.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installer/src.s60/applicationregistrator/applicationregistrator.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -129,7 +129,6 @@ return err; } -//#if 1 #ifndef RD_JAVA_USIF_APP_REG // Delete any pending (un)registrations (possible if // e.g. device rebooted before commit). @@ -169,7 +168,6 @@ * @param[in] aBackground * @return 0 if registration succeeded or Symbian error code */ -//#if 0 #ifdef RD_JAVA_USIF_APP_REG JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_ApplicationRegistrator__1registerApplication (JNIEnv */*aEnv*/, jclass /*aClass*/, jint /*aSessionHandle*/, jint /*aUid*/, jstring /*aGroupName*/, @@ -486,7 +484,6 @@ * @param[in] aUid The Uid of the application to be unregistered.. * @return 0 if unregistration succeeded or Symbian error code */ -//#if 0 #ifdef RD_JAVA_USIF_APP_REG JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_ApplicationRegistrator__1unregisterApplication (JNIEnv *, jclass, jint /*aSessionHandle*/, jint /*aUid*/) @@ -527,7 +524,6 @@ TInt err = KErrNone; -//#if 1 #ifndef RD_JAVA_USIF_APP_REG if (aSynchronous) { @@ -586,7 +582,6 @@ reinterpret_cast(aSessionHandle<<2); TInt err = KErrNone; -//#if 1 #ifndef RD_JAVA_USIF_APP_REG err = pApaSession->RollbackNonNativeApplicationsUpdates(); #endif // RD_JAVA_USIF_APP_REG diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installer/src.s60/applicationregistrator/sifnotifier.cpp --- a/javamanager/javainstaller/installer/src.s60/applicationregistrator/sifnotifier.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installer/src.s60/applicationregistrator/sifnotifier.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -161,7 +161,7 @@ jstring aGlobalComponentId, jint aErrCategory, jint aErrCode, jstring aErrMsg, jstring aErrMsgDetails) { - __UHEAP_MARK; + //__UHEAP_MARK; HBufC *globalComponentId = CreateHBufCFromJavaStringLC(aEnv, aGlobalComponentId); HBufC *errMsg = NULL; if (NULL != aErrMsg) @@ -174,24 +174,29 @@ errMsgDetails = CreateHBufCFromJavaStringLC(aEnv, aErrMsgDetails); } - CSifOperationEndData *endData = CSifOperationEndData::NewLC( - *globalComponentId, (TErrorCategory)aErrCategory, aErrCode, - *errMsg, *errMsgDetails); + CSifOperationEndData *endData = + CSifOperationEndData::NewLC( + *globalComponentId, (TErrorCategory)aErrCategory, aErrCode, + (NULL != errMsg? *errMsg: KNullDesC()), + (NULL != errMsgDetails? *errMsgDetails: KNullDesC())); + // Do not use UHEAP macros around PublishCompletionL() because it + // creates a timer object which gets deleted only when the notifier + // object is deleted. aNotifier->PublishCompletionL(*endData); CleanupStack::PopAndDestroy(endData); - if (NULL != aErrMsg) + if (NULL != errMsgDetails) + { + CleanupStack::PopAndDestroy(errMsgDetails); + } + if (NULL != errMsg) { CleanupStack::PopAndDestroy(errMsg); } - if (NULL != aErrMsgDetails) - { - CleanupStack::PopAndDestroy(errMsgDetails); - } CleanupStack::PopAndDestroy(globalComponentId); - __UHEAP_MARKEND; + //__UHEAP_MARKEND; } /* @@ -203,10 +208,25 @@ (JNIEnv *aEnv, jclass, jint aHandle, jstring aGlobalComponentId, jint aErrCategory, jint aErrCode, jstring aErrMsg, jstring aErrMsgDetails) { + CActiveScheduler* newScheduler = 0; + if (0 == CActiveScheduler::Current()) + { + // Create ActiveScheduler as it does not yet exist. + newScheduler = new CActiveScheduler; + CActiveScheduler::Install(newScheduler); + } + CPublishSifOperationInfo *pNotifier = reinterpret_cast(aHandle<<2); TRAPD(err, NotifyEndL(aEnv, pNotifier, aGlobalComponentId, aErrCategory, aErrCode, aErrMsg, aErrMsgDetails)); + + if (newScheduler) + { + delete newScheduler; + newScheduler = 0; + } + return err; } diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installer/src.s60/applicationregistrator/sifregistrator.cpp --- a/javamanager/javainstaller/installer/src.s60/applicationregistrator/sifregistrator.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installer/src.s60/applicationregistrator/sifregistrator.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -31,13 +31,12 @@ // SCR usage is enabled if this macro has been defined. #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK -#include -#include #include #include #ifdef RD_JAVA_USIF_APP_REG #include #endif // RD_JAVA_USIF_APP_REG +#include // Helper macro for logging a TDesC. #define LOG_TDESC_L(compIdParam, logLevelParam, msgParam, tdescParam) \ @@ -50,18 +49,11 @@ } // NAMESPACE DECLARATION -QTM_USE_NAMESPACE using namespace java; using namespace Usif; IMPORT_C HBufC* CreateHBufCFromJavaStringLC(JNIEnv* aEnv, jstring aString); -// Java MIME types. -_LIT(KMimeTypeAppDescriptor, "text/vnd.sun.j2me.app-descriptor"); -_LIT(KMimeTypeJava, "application/java"); -_LIT(KMimeTypeJavaArchive, "application/java-archive"); -_LIT(KMimeTypeXJavaArchive, "application/x-java-archive"); - // Properties registered to SCR. _LIT(KMIDletName, "MIDlet-Name"); _LIT(KUid, "Uid"); @@ -254,86 +246,40 @@ { TInt err = KErrNone; - QServiceManager serviceManager; - QObject* activityManager = - serviceManager.loadInterface("com.nokia.qt.activities.ActivityManager"); - if (!activityManager) + CActiveScheduler* newScheduler = 0; + if (0 == CActiveScheduler::Current()) { - err = serviceManager.error(); - ELOG1(EJavaInstaller, - "launchAppView: loading ActivityManager failed, error %d", err); - return KErrCouldNotConnect; - } - // URL for launching AppLib. - QUrl url(QString("appto://20022F35?activityname=AppLibRecentView")); - QMetaObject::invokeMethod(activityManager, "launchActivity", - Q_ARG(QString, url.toString())); - err = serviceManager.error(); - delete activityManager; - if (QServiceManager::NoError != err) - { - ELOG1(EJavaInstaller, - "launchAppView: launching AppLib activity failed, error %d", - err); - return KErrCouldNotConnect; + // Create ActiveScheduler as it does not yet exist. + newScheduler = new CActiveScheduler; + CActiveScheduler::Install(newScheduler); } - // Start AppLib and bring it to foreground. - const TUid KAppLibUid = { 0x20022F35 }; - TRAP(err, StartAppL(KAppLibUid)); - return err; -} + QUrl openRecentView("appto://20022F35?activityname=AppLibRecentView"); + XQApplicationManager applicationManager; + XQAiwRequest *request = applicationManager.create(openRecentView); + if (request) { + bool result = request->send(); + if (!result) { + int error = request->lastError(); + ELOG1(EJavaInstaller, + "launchAppView: launching AppLib failed, error %d", error); + err = KErrGeneral; + } + delete request; + } -/** - * See JNI method __1registerJavaSoftwareType. - * This method makes calls that may leave (the actual registering). - */ -void RegisterJavaSoftwareTypeL(RSoftwareComponentRegistry *aScr, TBool aRegister = ETrue) -{ - RPointerArray javaMimeTypes; - CleanupResetAndDestroyPushL(javaMimeTypes); - javaMimeTypes.AppendL(KMimeTypeAppDescriptor().AllocL()); - javaMimeTypes.AppendL(KMimeTypeJava().AllocL()); - javaMimeTypes.AppendL(KMimeTypeJavaArchive().AllocL()); - javaMimeTypes.AppendL(KMimeTypeXJavaArchive().AllocL()); - if (aRegister) - { - TUid javaSifPluginUid = TUid::Uid(0x2002bc70); - _LIT_SECURE_ID(KJavaInstallerSid, 0x102033E6); - aScr->AddSoftwareTypeL( - Usif::KSoftwareTypeJava, javaSifPluginUid, - KJavaInstallerSid, KJavaInstallerSid, javaMimeTypes); - } - else + if (newScheduler) { - aScr->DeleteSoftwareTypeL(Usif::KSoftwareTypeJava, javaMimeTypes); + delete newScheduler; + newScheduler = 0; } - CleanupStack::PopAndDestroy(&javaMimeTypes); -} -/* - * Class: com_nokia_mj_impl_installer_applicationregistrator_SifRegistrator - * Method: _registerJavaSoftwareType - * Signature: (Z)I - */ -JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_SifRegistrator__1registerJavaSoftwareType -(JNIEnv *, jclass, jboolean aRegister) -{ - RSoftwareComponentRegistry *pScr = NULL; - TRAPD(err, pScr = CreateScrL()); - if (KErrNone != err) + if (KErrNone == err) { - return err; + // Start AppLib and bring it to foreground. + const TUid KAppLibUid = { 0x20022F35 }; + TRAP(err, StartAppL(KAppLibUid)); } - TRAP(err, RegisterJavaSoftwareTypeL(pScr, aRegister)); - if (KErrNone != err) - { - ELOG1(EJavaInstaller, - "registerJavaSoftwareType: registration failed, error %d", - err); - } - pScr->Close(); - delete pScr; return err; } @@ -538,7 +484,7 @@ jint aMediaId, jstring aMidletInfoUrl, jstring aMidletDescription, jstring aDownloadUrl, jobject aComponentId) { - //__UHEAP_MARK; + __UHEAP_MARK; RSoftwareComponentRegistry *pScr = reinterpret_cast(aSessionHandle<<2); TComponentId componentId = -1; @@ -547,7 +493,7 @@ aComponentFiles, aComponentSize, aIsRemovable, aIsDrmProtected, aIsOriginVerified, aIsUpdate, aMediaId, aMidletInfoUrl, aMidletDescription, aDownloadUrl)); - //__UHEAP_MARKEND; + __UHEAP_MARKEND; if (KErrNone == err) { jclass clazz = aEnv->GetObjectClass(aComponentId); @@ -565,7 +511,7 @@ JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_SifRegistrator__1unregisterComponent (JNIEnv *, jclass, jint aSessionHandle, jint aComponentId) { - //__UHEAP_MARK; + __UHEAP_MARK; RSoftwareComponentRegistry *pScr = reinterpret_cast(aSessionHandle<<2); TInt err = KErrNone; @@ -576,7 +522,7 @@ { TRAP(err, pScr->DeleteComponentL(aComponentId)); } - //__UHEAP_MARKEND; + __UHEAP_MARKEND; return err; } @@ -1085,11 +1031,11 @@ JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_SifRegistrator__1logComponent (JNIEnv *aEnv, jclass, jint aSessionHandle, jstring aGlobalId) { - __UHEAP_MARK; + //__UHEAP_MARK; RSoftwareComponentRegistry *pScr = reinterpret_cast(aSessionHandle<<2); TRAPD(err, LogComponentL(aEnv, pScr, aGlobalId)); - __UHEAP_MARKEND; + //__UHEAP_MARKEND; return err; } @@ -1134,17 +1080,6 @@ /* * Class: com_nokia_mj_impl_installer_applicationregistrator_SifRegistrator - * Method: _registerJavaSoftwareType - * Signature: (Z)I - */ -JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_applicationregistrator_SifRegistrator__1registerJavaSoftwareType -(JNIEnv *, jclass, jboolean) -{ - return KErrNone; -} - -/* - * Class: com_nokia_mj_impl_installer_applicationregistrator_SifRegistrator * Method: _startSession * Signature: ()I */ diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installer/src.s60/utils/filewriter.cpp --- a/javamanager/javainstaller/installer/src.s60/utils/filewriter.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installer/src.s60/utils/filewriter.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -26,6 +26,7 @@ #ifdef RD_JAVA_S60_RELEASE_5_0 #include #else +#include #include #endif // RD_JAVA_S60_RELEASE_5_0 diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installer/src.s60/utils/sysutil.cpp --- a/javamanager/javainstaller/installer/src.s60/utils/sysutil.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installer/src.s60/utils/sysutil.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -25,13 +25,20 @@ #include #include +#ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK +#include "hbextendedlocale.h" +#endif // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK + #include "com_nokia_mj_impl_installer_utils_SysUtil.h" +#include "javajniutils.h" #include "logger.h" #ifndef KPSUidJavaLatestInstallation #define KPSUidJavaLatestInstallation 0x10282567 #endif +using namespace java::util; + /** * Helper method for creating HBufC from jstring. */ @@ -720,3 +727,21 @@ } return value; } + +/* + * Class: com_nokia_mj_impl_installer_utils_SysUtil + * Method: _isoToLang + * Signature: ()[Ljava/lang/String; + */ +JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_utils_SysUtil__1isoToLang +(JNIEnv *aEnv, jclass, jstring aLocale) +{ +#ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK + return HbExtendedLocale::ISOToSymbianLang( + QString::fromStdWString(JniUtils::jstringToWstring(aEnv, aLocale))); +#else // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK + (void)aEnv; // suppress compilation warning about unused argument + (void)aLocale; // suppress compilation warning about unused argument + return -1; +#endif // SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK +} diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installer/tsrc/build/jiut.bat --- a/javamanager/javainstaller/installer/tsrc/build/jiut.bat Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installer/tsrc/build/jiut.bat Fri Jun 11 13:33:44 2010 +0300 @@ -14,6 +14,8 @@ @rem Description: @rem rem Script for running JavaInstaller unit tests from S60 eshell +rem Start SifServer before running any tests +sifserver rem javainstaller test -mainclass=com.nokia.mj.impl.installer.downloader.NotificationPosterTest rem javainstaller test -mainclass=com.nokia.mj.impl.installer.downloader.DownloaderTest javainstaller test -mainclass=com.nokia.mj.impl.installer.storagehandler.OtaStatusHandlerTest diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installer/tsrc/javasrc/com/nokia/mj/impl/installer/InstallerEngineTest.java --- a/javamanager/javainstaller/installer/tsrc/javasrc/com/nokia/mj/impl/installer/InstallerEngineTest.java Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installer/tsrc/javasrc/com/nokia/mj/impl/installer/InstallerEngineTest.java Fri Jun 11 13:33:44 2010 +0300 @@ -64,6 +64,7 @@ })); } + // Run 1 suite.addTest(new InstallerEngineTest("testMidletMessageOk", new TestMethod() { public void run(TestCase tc) @@ -112,6 +113,7 @@ } })); + // Run 2 suite.addTest(new InstallerEngineTest("testDownloadJarOk", new TestMethod() { public void run(TestCase tc) @@ -240,6 +242,7 @@ } })); + // Run 3 suite.addTest(new InstallerEngineTest("testInstallOptions", new TestMethod() { public void run(TestCase tc) @@ -985,7 +988,7 @@ callInstallerOk(new String[] { "list", "-systemproperties" }); callInstallerOk(new String[] { "launch", "-nouid" }); callInstallerOk(new String[] { "launch", "-uid=invaliduid" }); - callInstallerOk(new String[] { "uninstallall" }); + callInstallerOk(new String[] { "uninstallall", "-silent" }); callInstallerOk(new String[] { "unregister" }); callInstallerOk(new String[] { "test", "-nomainclass" }); } diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installer/tsrc/javasrc/com/nokia/mj/impl/installer/applicationregistrator/ApplicationRegistratorTest.java --- a/javamanager/javainstaller/installer/tsrc/javasrc/com/nokia/mj/impl/installer/applicationregistrator/ApplicationRegistratorTest.java Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installer/tsrc/javasrc/com/nokia/mj/impl/installer/applicationregistrator/ApplicationRegistratorTest.java Fri Jun 11 13:33:44 2010 +0300 @@ -374,12 +374,32 @@ appReg.startSession(); groupName = appReg.getGroupName(uid); - assertTrue( - "The group name was not VeryVeryLongGrou, it was " + groupName, - "VeryVeryLongGrou".equals(groupName)); + if (SifRegistrator.getSifMode() > 0) + { + // When USIF is in use ApplicationRegistrator should not + // have registered anything. + assertTrue( + "The group name was not empty, it was " + groupName, + "".equals(groupName)); + } + else + { + assertTrue( + "The group name was not VeryVeryLongGrou, it was " + groupName, + "VeryVeryLongGrou".equals(groupName)); + } uidInUse = appReg.uidInUse(uid); - assertTrue("uidInUse returned false value", true == uidInUse); + if (SifRegistrator.getSifMode() > 0) + { + // When USIF is in use ApplicationRegistrator should not + // have registered anything. + assertTrue("uidInUse returned true value", false == uidInUse); + } + else + { + assertTrue("uidInUse returned false value", true == uidInUse); + } appReg.closeSession(); } @@ -582,7 +602,16 @@ "".equals(groupName)); uidInUse = appReg.uidInUse(uid); - assertTrue("uidInUse returned false value", true == uidInUse); + if (SifRegistrator.getSifMode() > 0) + { + // When USIF is in use ApplicationRegistrator should not + // have registered anything. + assertTrue("uidInUse returned true value", false == uidInUse); + } + else + { + assertTrue("uidInUse returned false value", true == uidInUse); + } appReg.closeSession(); } @@ -703,12 +732,32 @@ appReg.startSession(); groupName = appReg.getGroupName(uid); - assertTrue( - "The group name was not Suite, it was " + groupName, - "Suite".equals(groupName)); + if (SifRegistrator.getSifMode() > 0) + { + // When USIF is in use ApplicationRegistrator should not + // have registered anything. + assertTrue( + "The group name was not empty, it was " + groupName, + "".equals(groupName)); + } + else + { + assertTrue( + "The group name was not Suite, it was " + groupName, + "Suite".equals(groupName)); + } uidInUse = appReg.uidInUse(uid); - assertTrue("uidInUse returned false value", true == uidInUse); + if (SifRegistrator.getSifMode() > 0) + { + // When USIF is in use ApplicationRegistrator should not + // have registered anything. + assertTrue("uidInUse returned true value", false == uidInUse); + } + else + { + assertTrue("uidInUse returned false value", true == uidInUse); + } appReg.closeSession(); } diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installer/tsrc/javasrc/com/nokia/mj/impl/installer/applicationregistrator/SifRegistratorTest.java --- a/javamanager/javainstaller/installer/tsrc/javasrc/com/nokia/mj/impl/installer/applicationregistrator/SifRegistratorTest.java Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installer/tsrc/javasrc/com/nokia/mj/impl/installer/applicationregistrator/SifRegistratorTest.java Fri Jun 11 13:33:44 2010 +0300 @@ -203,21 +203,22 @@ { SuiteInfo si = getTestSuite(); ComponentId cid = getComponentId(si.getGlobalId()); - Uid uid = null; - //Uid uid = sifReg.getUid(cid.getId()); - //assertTrue("Suite uid " + si.getUid() + " does not match" + - // " to uid " + uid + " from SCR", - // si.getUid().equals(uid)); - Vector apps = si.getApplications(); - for (int i = 0; i < apps.size(); i++) - { - cid = getComponentId(si.getGlobalId(i)); - uid = sifReg.getUid(cid.getId()); - assertTrue("Application uid " + - ((ApplicationInfo)apps.elementAt(i)).getUid() + - " does not match to uid " + uid + " from SCR", - ((ApplicationInfo)apps.elementAt(i)).getUid().equals(uid)); - } + // Check for USIF Phase 2 registration. + Uid uid = sifReg.getUid(cid.getId()); + assertTrue("Suite uid " + si.getUid() + " does not match" + + " to uid " + uid + " from SCR", + si.getUid().equals(uid)); + // Check for USIF Phase 1 registration. + //Vector apps = si.getApplications(); + //for (int i = 0; i < apps.size(); i++) + //{ + // cid = getComponentId(si.getGlobalId(i)); + // uid = sifReg.getUid(cid.getId()); + // assertTrue("Application uid " + + // ((ApplicationInfo)apps.elementAt(i)).getUid() + + // " does not match to uid " + uid + " from SCR", + // ((ApplicationInfo)apps.elementAt(i)).getUid().equals(uid)); + //} sifReg.closeSession(); } catch (InstallerException ie) @@ -324,16 +325,18 @@ private void assertSuiteExists(SuiteInfo aSuite, boolean aExists) { String not = (aExists? " not": ""); + // Check for USIF Phase 2 registration. ComponentId cid = getComponentId(aSuite.getGlobalId()); - //assertTrue("Suite " + aSuite.getGlobalId() + not + - // " found from SCR", (aExists? cid != null: cid == null)); - Vector apps = aSuite.getApplications(); - for (int i = 0; i < apps.size(); i++) - { - cid = getComponentId(aSuite.getGlobalId(i)); - assertTrue("Application " + aSuite.getGlobalId(i) + not + - " found from SCR", (aExists? cid != null: cid == null)); - } + assertTrue("Suite " + aSuite.getGlobalId() + not + + " found from SCR", (aExists? cid != null: cid == null)); + // Check for USIF Phase 1 registration. + //Vector apps = aSuite.getApplications(); + //for (int i = 0; i < apps.size(); i++) + //{ + // cid = getComponentId(aSuite.getGlobalId(i)); + // assertTrue("Application " + aSuite.getGlobalId(i) + not + + // " found from SCR", (aExists? cid != null: cid == null)); + //} } private void logSuite(SuiteInfo aSuite) diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installer/tsrc/javasrc/com/nokia/mj/impl/installer/utils/SysUtilTest.java --- a/javamanager/javainstaller/installer/tsrc/javasrc/com/nokia/mj/impl/installer/utils/SysUtilTest.java Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installer/tsrc/javasrc/com/nokia/mj/impl/installer/utils/SysUtilTest.java Fri Jun 11 13:33:44 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -375,8 +375,8 @@ Uid uid = SysUtil.REPO_ID_JAVA_INST_VARIATION; long key = SysUtil.REPO_KEY_JAVA_INST_SHELL_FOLDER_VALUE; String value = SysUtil.getRepositoryStringValue(uid, key); - //assertTrue("Unexpected value: " + value, "Games,Applications".equals(value)); - assertTrue("Unexpected value: " + value, "".equals(value)); + assertTrue("Unexpected value: " + value, "Games,Applications".equals(value)); + //assertTrue("Unexpected value: " + value, "".equals(value)); } catch (InstallerException ie) { diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/InstallConfirmationView.java --- a/javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/InstallConfirmationView.java Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/InstallConfirmationView.java Fri Jun 11 13:33:44 2010 +0300 @@ -33,7 +33,6 @@ import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Link; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/InstallerUiEswt.java --- a/javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/InstallerUiEswt.java Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/InstallerUiEswt.java Fri Jun 11 13:33:44 2010 +0300 @@ -463,6 +463,7 @@ public void updateProgress(int aProgress) { super.updateProgress(aProgress); + if (true) return; // Disable UI temporarily. if (!isUiReady()) { return; @@ -509,6 +510,7 @@ public void ended() { super.ended(); + if (true) return; // Disable UI temporarily. if (!isUiReady()) { return; @@ -553,6 +555,7 @@ public void started(DownloadInfo aDownloadInfo) { super.started(aDownloadInfo); + if (true) return; // Disable UI temporarily. if (!isUiReady()) { return; @@ -579,6 +582,7 @@ public void updateProgress(DownloadInfo aDownloadInfo) { super.updateProgress(aDownloadInfo); + if (true) return; // Disable UI temporarily. if (!isUiReady()) { return; @@ -628,6 +632,7 @@ public void ended(DownloadInfo aDownloadInfo) { super.ended(aDownloadInfo); + if (true) return; // Disable UI temporarily. if (!isUiReady()) { return; @@ -654,6 +659,7 @@ public void setOcspIndicator(boolean aOn) { super.setOcspIndicator(aOn); + if (true) return; // Disable UI temporarily. waitForUi(); if (!isUiReady()) { @@ -754,6 +760,7 @@ public void error(InstallerExceptionBase aInstallerException) { super.error(aInstallerException); + if (true) return; // Disable UI temporarily. waitForUi(); if (!isUiReady()) { @@ -850,6 +857,7 @@ */ public boolean confirm(String aAppName, ConfirmData aConfirmData) { + if (true) return true; // Disable UI temporarily. waitForUi(); if (!isUiReady()) { return true; @@ -888,6 +896,7 @@ */ public String[] getUsernamePassword(String aUrl) { + if (true) return new String[] { "", "" }; // Disable UI temporarily. waitForUi(); if (!isUiReady()) { @@ -943,6 +952,7 @@ */ public boolean launchAppQuery(LaunchAppInfo aLaunchAppInfo) { + if (true) return false; // Disable UI temporarily. waitForUi(); if (!isUiReady() || iConfirmationsCanceled || getInstallInfo() == null) { diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/InstallerUiTexts.java --- a/javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/InstallerUiTexts.java Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/InstallerUiTexts.java Fri Jun 11 13:33:44 2010 +0300 @@ -88,7 +88,7 @@ public static final String DRIVE_TYPE_INTERNAL_MASS_STORAGE_MB = "%U: Internal Mass Storage (%N MB)"; public static final String DRIVE_TYPE_INTERNAL_MASS_STORAGE_GB = "%U: Internal Mass Storage (%N GB)"; // Texts for permission confirmation view. - public static final String PERM_QUERY = "Application %U asks permissions to access protected device functionality."; + public static final String PERM_QUERY = "Access for protected functionality needed."; public static final String PERM_VIEW_DETAILS = "Details"; public static final String PERM_ALLOW_ALWAYS = "Allow always"; public static final String PERM_ASK_ME_LATER = "Ask me later"; diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/LaunchAppQueryView.java --- a/javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/LaunchAppQueryView.java Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/LaunchAppQueryView.java Fri Jun 11 13:33:44 2010 +0300 @@ -46,7 +46,7 @@ { super(aInstallerUi, aParent, 8); setTitle(InstallerUiTexts.get(InstallerUiTexts.INSTALLATION_COMPLETE)); - setCommands("Show", //InstallerUiTexts.get(InstallerUiTexts.SHOW), + setCommands(InstallerUiTexts.get(InstallerUiTexts.SHOW), InstallerUiTexts.get(InstallerUiTexts.CLOSE)); } @@ -68,8 +68,8 @@ protected void createView() { // Add header. - String title = "Installed"; - addHeader(title, iInstallerUi.getInstallInfo(), null); + addHeader(InstallerUiTexts.get(InstallerUiTexts.INSTALLATION_COMPLETE), + iInstallerUi.getInstallInfo(), null); // Add content to the application info Composite. addAppInfo(iInstallerUi.getInstallInfo(), true); } diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/PermissionConfirmationView.java --- a/javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/PermissionConfirmationView.java Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/PermissionConfirmationView.java Fri Jun 11 13:33:44 2010 +0300 @@ -35,7 +35,6 @@ import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Link; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; @@ -106,10 +105,11 @@ addHeader(title, iInstallInfo, null); GridData gridData = null; - int horizontalSpan = getColumns(); int labelStyle = SWT.WRAP; // Add permission query label. + int detailsColumns = 2; + int horizontalSpan = getColumns() - detailsColumns; Label domainLabel = createLabel( InstallerUiTexts.get(InstallerUiTexts.PERM_QUERY, new String[] { appName }), @@ -120,12 +120,11 @@ iPermissionInfo.getPermissionNames() != null && iPermissionInfo.getPermissionNames().length > 0) { - Link detailsLink = new Link(getComposite(), SWT.NONE); - detailsLink.setText( - "" + - InstallerUiTexts.get(InstallerUiTexts.PERM_VIEW_DETAILS) + - ""); - detailsLink.addListener(SWT.Selection, new Listener() + horizontalSpan = detailsColumns; + Button detailsButton = new Button(getComposite(), SWT.NONE); + detailsButton.setText( + InstallerUiTexts.get(InstallerUiTexts.PERM_VIEW_DETAILS)); + detailsButton.addListener(SWT.Selection, new Listener() { public void handleEvent(Event aEvent) { @@ -134,10 +133,12 @@ }); gridData = new GridData(GridData.FILL_HORIZONTAL); gridData.horizontalSpan = horizontalSpan; - detailsLink.setLayoutData(gridData); - addSoftKeyListenerFor(detailsLink); + detailsButton.setLayoutData(gridData); + addSoftKeyListenerFor(detailsButton); } + horizontalSpan = getColumns(); + // Number of pixels on top of the buttons. int verticalIndent = 5; @@ -235,6 +236,10 @@ gridData.verticalIndent = verticalIndent; iCancelButton.setLayoutData(gridData); addSoftKeyListenerFor(iCancelButton); + + // After other widgets have been added, add content to + // application info Composite. + addAppInfo(iInstallInfo, false); } /** diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/ViewBase.java --- a/javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/ViewBase.java Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/installerui/javasrc/com/nokia/mj/impl/installer/ui/eswt2/ViewBase.java Fri Jun 11 13:33:44 2010 +0300 @@ -50,6 +50,8 @@ { /** Maximum view height in percentage from display client area height. */ protected static final int MAX_VIEW_HEIGHT = 80; + /** Maximum view width in percentage from display client area width. */ + protected static final int MAX_VIEW_WIDTH = 90; /** Parent shell for this view. */ protected Shell iParent = null; /** Container for the contents of the view */ @@ -341,12 +343,12 @@ SWT.DEFAULT, SWT.DEFAULT)); } - int contentWidth = iDefaultContentSize.x; + int contentWidth = iDefaultContentSize.x * MAX_VIEW_WIDTH / 100; if (aVerticalScrollBarVisible) { int verticalScrollBarWidth = getScrolledComposite().getVerticalBar().getSize().x; - contentWidth = iDefaultContentSize.x - verticalScrollBarWidth; + contentWidth -= verticalScrollBarWidth; } // Recalculate the size of the content. @@ -355,7 +357,7 @@ Point cmdContentSize = cmdComp.computeSize(iDefaultContentSize.x, SWT.DEFAULT); cmdComp.setSize(cmdContentSize); - // Adjust Shell height. The Shell never changes the x position, nor the width. + // Adjust Shell height and width. Rectangle dispRect = shell.getDisplay().getClientArea(); int offset = iDefaultContentSize.y - contentSize.y - cmdContentSize.y; @@ -368,18 +370,20 @@ offset -= maxHeight - newHeight; newHeight = maxHeight; } + int newWidth = defShellBounds.width; + int maxWidth = dispRect.width * MAX_VIEW_WIDTH / 100; + if (newWidth > maxWidth) + { + newWidth = maxWidth; + } + // Always center horizontally and vertically. Rectangle dispBounds = shell.getDisplay().getBounds(); + int x = dispBounds.width - newWidth; int y = dispBounds.height - newHeight; - // Always center vertically. + x /= 2; y /= 2; - // For landscape orientation center vertically - //if (dispRect.width > dispRect.height) - //{ - // y /= 2; - //} - // Set bounds when command Buttons are in use. - shell.setBounds(defShellBounds.x, y, defShellBounds.width, newHeight); + shell.setBounds(x, y, newWidth, newHeight); Rectangle clientArea = shell.getClientArea(); iContainer.setSize(clientArea.width, clientArea.height); iContainer.layout(true); @@ -558,10 +562,20 @@ } if (size > 0) { - createAppInfoLabel( - InstallerUiTexts.get( - InstallerUiTexts.SIZE_KB, - new String[] { Long.toString(1 + size/1024) })); + if (size > 1024*1024) + { + createAppInfoLabel( + InstallerUiTexts.get( + InstallerUiTexts.SIZE_MB, + new String[] { Long.toString(1 + size/(1024*1024)) })); + } + else + { + createAppInfoLabel( + InstallerUiTexts.get( + InstallerUiTexts.SIZE_KB, + new String[] { Long.toString(1 + size/1024) })); + } } if (aFull) { diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/javainstaller.pro --- a/javamanager/javainstaller/javainstaller.pro Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/javainstaller.pro Fri Jun 11 13:33:44 2010 +0300 @@ -16,6 +16,5 @@ TEMPLATE = subdirs SUBDIRS += installerui/build/javainstallerui.pro SUBDIRS += installer/build/javainstaller.pro -BLD_INF_RULES.prj_extensions += "$${LITERAL_HASH}include \"appinstuiplugin/build/bld.inf\"" BLD_INF_RULES.prj_extensions += "$${LITERAL_HASH}include \"javasifplugin/build/bld.inf\"" BLD_INF_RULES.prj_extensions += "prj_extensions" diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/javasifplugin/build/javasifplugin.mmp --- a/javamanager/javainstaller/javasifplugin/build/javasifplugin.mmp Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/javasifplugin/build/javasifplugin.mmp Fri Jun 11 13:33:44 2010 +0300 @@ -53,6 +53,7 @@ USERINCLUDE ../../../../inc SYSTEMINCLUDE ../../../../inc +SYSTEMINCLUDE /epoc32/include/mw/usif // Libraries LIBRARY apgrfx.lib diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/javasifplugin/inc/javasifplugin.h --- a/javamanager/javainstaller/javasifplugin/inc/javasifplugin.h Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/javasifplugin/inc/javasifplugin.h Fri Jun 11 13:33:44 2010 +0300 @@ -221,6 +221,24 @@ */ void CopyFilesIfNeededL(TFileName &aFileName); + /** + * If Java Installer is already running, set error category EInstallerBusy etc + * to aResults, set aStatus to KErrAlreadyExists and return ETrue + * @param[in][out] aResults + * @param[in][out] aStatus + * @return ETrue if Java Installer is running + */ + TBool ExitIfJavaInstallerRunning( + COpaqueNamedParams& aResults, + TRequestStatus& aStatus); + + /** + * If Java Installer is already running, + * set aStatus to KErrAlreadyExists and return ETrue + * @param[in][out] aStatus + * @return ETrue if Java Installer is running + */ + TBool ExitIfJavaInstallerRunning(TRequestStatus& aStatus); private: // Data diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/javasifplugin/src/javasifplugin.cpp --- a/javamanager/javainstaller/javasifplugin/src/javasifplugin.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/javasifplugin/src/javasifplugin.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009 - 2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -24,6 +24,7 @@ #include #include #include +#include #include "comms.h" #include "commsmessage.h" @@ -43,10 +44,15 @@ _LIT(KPrivateDataCage, "\\private\\"); _LIT(KInboxDataCage, "\\private\\1000484b\\"); +_LIT(KJavaInstallerProcess, "Installer"); _LIT(KJavaInstallerDataCage, "\\private\\102033e6\\"); _LIT(KJavaInstallerTmp, "\\private\\102033E6\\installer\\tmp\\"); _LIT(KAnyExtension, ".*"); +// Java Installer is executed with same Uid as Java Runtime +_LIT_SECURE_ID(KJavaInstallerSecureID, KJavaMidpSecureId); + + // ============================ MEMBER FUNCTIONS =============================== @@ -122,6 +128,11 @@ CComponentInfo& aComponentInfo, TRequestStatus& aStatus) { + if (ExitIfJavaInstallerRunning(aStatus)) + { + return; + } + RProcess rJavaInstaller; TFileName fileName; TBuf<1536> commandLine; @@ -273,6 +284,11 @@ COpaqueNamedParams& aResults, TRequestStatus& aStatus) { + if (ExitIfJavaInstallerRunning(aResults, aStatus)) + { + return; + } + RProcess rJavaInstaller; TFileName fileName; // Max two path names and some options -> 1536 is enough @@ -371,6 +387,26 @@ // AskUser is not supported } + + // TODO: activate this code block when KSifInParam_UpgradeData has been + // defined in sifcommon.h +/* + // KSifInParam_UpgradeData Yes/No/AskUser -> -upgrade_data=yes|no + TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_UpgradeData, intValue)); + if (paramFound) + { + if (intValue == 0) // Yes + { + commandLine.Append(_L(" -upgrade_data=yes")); + } + else if (intValue == 1) // No + { + commandLine.Append(_L(" -upgrade_data=no")); + } + // AskUser is not supported + } +*/ + // KSifInParam_AllowUntrusted Yes/No/AskUser -> -untrusted=yes|no TRAP_IGNORE(paramFound = aArguments.GetIntByNameL(KSifInParam_AllowUntrusted, intValue)); if (paramFound) @@ -571,9 +607,14 @@ TComponentId aComponentId, const TSecurityContext& aSecurityContext, const COpaqueNamedParams& aArguments, - COpaqueNamedParams& /* aResults */, + COpaqueNamedParams& aResults, TRequestStatus& aStatus) { + if (ExitIfJavaInstallerRunning(aResults, aStatus)) + { + return; + } + RProcess rJavaInstaller; TFileName fileName; // Max one uid and some options -> 256 is enough @@ -795,4 +836,105 @@ return; } +TBool CJavaSifPlugin::ExitIfJavaInstallerRunning( + COpaqueNamedParams& aResults, + TRequestStatus& aStatus) +{ + // If Java Installer is already running, set error category EInstallerBusy etc + // to aResults and return + + TInt err(KErrNone); + RProcess proc; + TFindProcess finder(KJavaInstallerProcess); + TFullName procName; + + // Java Installer process SID is 0x102033E6 and name is "Installer" + while (finder.Next(procName) == KErrNone) + { + if (proc.Open(finder) != KErrNone) + { + continue; + } + if (proc.SecureId() == KJavaInstallerSecureID) + { + if (proc.ExitType() == EExitPending) + { + // Java Installer process is already running + proc.Close(); + + // return error information + TRAP(err, aResults.AddIntL(KSifOutParam_ErrCategory, EInstallerBusy)); + if (KErrNone != err) + { + ELOG1(EJavaInstaller, + "CJavaSifPlugin::ExitIfJavaInstallerRunning aResults.AddIntL " + "ErrCategory err %d", err); + } + + TRAP(err, aResults.AddIntL(KSifOutParam_ErrCode, KErrInUse)); + if (KErrNone != err) + { + ELOG1(EJavaInstaller, + "CJavaSifPlugin::ExitIfJavaInstallerRunning aResults.AddIntL " + "ErrCode err %d", err); + } + + TRAP(err, aResults.AddIntL(KSifOutParam_ExtendedErrCode, 0)); + if (KErrNone != err) + { + ELOG1(EJavaInstaller, + "CJavaSifPlugin::ExitIfJavaInstallerRunning aResults.AddIntL " + "ExtendedErrCode err %d", err); + } + + // TODO: return also localized error message from usif + // common localization file after the localized strings are available + + TRequestStatus *statusPtr(&aStatus); + User::RequestComplete(statusPtr, KErrInUse); + return ETrue; + } + } + proc.Close(); + } + + return EFalse; +} + + +TBool CJavaSifPlugin::ExitIfJavaInstallerRunning(TRequestStatus& aStatus) +{ + // If Java Installer is already running, set aStatus to KErrInUse + // and return ETrue + + RProcess proc; + TFindProcess finder(KJavaInstallerProcess); + TFullName procName; + + // Java Installer process SID is 0x102033E6 and name is "Installer" + while (finder.Next(procName) == KErrNone) + { + if (proc.Open(finder) != KErrNone) + { + continue; + } + if (proc.SecureId() == KJavaInstallerSecureID) + { + if (proc.ExitType() == EExitPending) + { + // Java Installer process is already running + proc.Close(); + + // return error information + TRequestStatus *statusPtr(&aStatus); + User::RequestComplete(statusPtr, KErrInUse); + return ETrue; + } + } + proc.Close(); + } + + return EFalse; +} + // End of File diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/javasifplugin/src/proxy.cpp --- a/javamanager/javainstaller/javasifplugin/src/proxy.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/javasifplugin/src/proxy.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009 - 2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/javasifplugin/src/resultsserver.cpp --- a/javamanager/javainstaller/javasifplugin/src/resultsserver.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/javasifplugin/src/resultsserver.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -19,6 +19,7 @@ #include #include +#include #include "comms.h" #include "javasymbianoslayer.h" @@ -44,6 +45,33 @@ int ResultsServer::start() { + // Write reasonable error codes to iResults that can be used if + // Java Installer never returns InstallerResultMessage. + // If InstallerResultMessage is received the values will be overwritten. + TRAPD(err, iResults.AddIntL(KSifOutParam_ErrCategory, EUnexpectedError)); + if (KErrNone != err) + { + ELOG1(EJavaInstaller, + "ResultsServer::start iResults.AddIntL ErrCategory err %d", err); + } + + TRAP(err, iResults.AddIntL(KSifOutParam_ErrCode, KErrUnknown)); + if (KErrNone != err) + { + ELOG1(EJavaInstaller, + "ResultsServer::start iResults.AddIntL ErrCode err %d", err); + } + + TRAP(err, iResults.AddIntL(KSifOutParam_ExtendedErrCode, 0)); + if (KErrNone != err) + { + ELOG1(EJavaInstaller, + "ResultsServer::start iResults.AddIntL ExtendedErrCode err %d", err); + } + + // TODO: return also localized error message from usif + // common localization file after the localized strings are available + iRunning = 1; iComms.registerDefaultListener(this); return iComms.start(IPC_ADDRESS_JAVA_SIF_PLUGIN_C); @@ -118,14 +146,6 @@ if (KErrNone != result) { // return common error information - TRAP(err, iResults.AddIntL(KSifOutParam_ExtendedErrCode, result)); - if (KErrNone != err) - { - ELOG1(EJavaInstaller, - "ResultsServer::processMessage iResults.AddIntL ExtendedErrCode err %d", - err); - } - TRAP(err, iResults.AddIntL(KSifOutParam_ErrCode, result)); if (KErrNone != err) { @@ -197,7 +217,24 @@ } else { - // operation succeeded + // Operation succeeded + + // Overwrite (reset) the default error values set for the case where no + // InstallerResultMessage is never received + TRAPD(err, iResults.AddIntL(KSifOutParam_ErrCategory, 0)); + if (KErrNone != err) + { + ELOG1(EJavaInstaller, + "ResultsServer::processMessage iResults.AddIntL ErrCategory err %d", err); + } + + TRAP(err, iResults.AddIntL(KSifOutParam_ErrCode, 0)); + if (KErrNone != err) + { + ELOG1(EJavaInstaller, + "ResultsServer::processMessage iResults.AddIntL ErrCode err %d", err); + } + if (INSTALL_OPERATION == operation) { diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javainstaller/subsystem.mk --- a/javamanager/javainstaller/subsystem.mk Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javainstaller/subsystem.mk Fri Jun 11 13:33:44 2010 +0300 @@ -20,17 +20,14 @@ installerui/build \ installer/build \ -NONQTSUBSYSTEMS = \ - appinstuiplugin/build - -SYMBIAN_ONLY = \ - appinstuiplugin/build +ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK + NONQTSUBSYSTEMS = javasifplugin/build + SYMBIAN_ONLY = javasifplugin/build +else + NONQTSUBSYSTEMS = appinstuiplugin/build + SYMBIAN_ONLY = appinstuiplugin/build +endif -ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK - NONQTSUBSYSTEMS += javasifplugin/build - SYMBIAN_ONLY += javasifplugin/build -endif - LINUX_ONLY = include ${JAVA_SRC_ROOT}/build/Makefile.subsystem diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javalauncher/src.s60/javalauncher.cpp --- a/javamanager/javalauncher/src.s60/javalauncher.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javalauncher/src.s60/javalauncher.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -672,8 +672,8 @@ LOG(EJavaCaptain, EInfo, "javalauncher: startJavaCaptain javacaptain.exe was started ok"); #endif - // Wait 3 seconds so that Java Captain has time to start - User::After(3000000); + // Wait 3 seconds so that Java Captain has time to start and get read to answer Comms + User::After(3000000); // codescanner::userafter } else { diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javalauncher/tsrc/testmidletstart/build/testmidletstart.pkg --- a/javamanager/javalauncher/tsrc/testmidletstart/build/testmidletstart.pkg Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javalauncher/tsrc/testmidletstart/build/testmidletstart.pkg Fri Jun 11 13:33:44 2010 +0300 @@ -1,18 +1,3 @@ -; -; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -; All rights reserved. -; This component and the accompanying materials are made available -; under the terms of "Eclipse Public License v1.0" -; which accompanies this distribution, and is available -; at the URL "http://www.eclipse.org/legal/epl-v10.html". -; -; Initial Contributors: -; Nokia Corporation - initial contribution. -; -; Contributors: -; -; Description: -; ; Language &EN diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javasettings/appsettingsview_qt/src/javaapplicationsettings.cpp --- a/javamanager/javasettings/appsettingsview_qt/src/javaapplicationsettings.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javasettings/appsettingsview_qt/src/javaapplicationsettings.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -16,61 +16,65 @@ */ #include "javaapplicationsettings.h" -JavaApplicationSettings::JavaApplicationSettings() +JavaApplicationSettings::JavaApplicationSettings(): + iName(QString("")), + iValues(QStringList()), + iId(0), iCurrentValue(0), + iColumnName(L""), + iTableName(""), + iStorageValuesFilter(L""), + iValuesColumnName(L""), + iFilterColumnName(L""), + iFilterColumnValue(L""), + connectedToUi(false) { - iId = 0; - iName = ""; - iCurrentValue = 0; - iColumnName = L""; - iTableName = ""; - iFilterColumnName = L""; - iFilterColumnValue = L""; - iStorageValuesFilter = L""; - iValuesColumnName = L""; } JavaApplicationSettings::JavaApplicationSettings(const QString& aName, const QStringList& aValues): - iValues(aValues) + iName(aName), + iValues(aValues), + iId(0), + iCurrentValue(0), + iColumnName(L""), + iTableName(""), + iStorageValuesFilter(L""), + iValuesColumnName(L""), + iFilterColumnName(L""), + iFilterColumnValue(L""), + connectedToUi(false) { - iName = aName; - iId = 0; - iCurrentValue = 0; - iColumnName = L""; - iTableName = ""; - iFilterColumnName = L""; - iFilterColumnValue = L""; - iStorageValuesFilter = L""; - iValuesColumnName = L""; } JavaApplicationSettings::JavaApplicationSettings(const QString& aName, const QStringList& aValues, const std::wstring& aColumnName, const std::string& aTableName, const std::vector& aStorageValues): - iValues(aValues) + iName(aName), + iValues(aValues), + iId(0), + iCurrentValue(0), + iColumnName(aColumnName), + iTableName(aTableName), + iStorageValues(aStorageValues), + iStorageValuesFilter(L""), + iValuesColumnName(L""), + iFilterColumnName(L""), + iFilterColumnValue(L""), + connectedToUi(false) { - iName = aName; - iId = 0; - iCurrentValue = 0; - iColumnName = aColumnName; - iTableName = aTableName; - iStorageValues = aStorageValues; - iFilterColumnName = L""; - iFilterColumnValue = L""; - iStorageValuesFilter = L""; - iValuesColumnName = L""; } JavaApplicationSettings::JavaApplicationSettings(const QString& aName, const QStringList& aValues, const std::wstring& aColumnName, const std::string& aTableName, const std::vector& aStorageValues, const std::wstring& aFilterColumnName, const std::wstring& aFilterColumnValue, const std::wstring& aValuesColumnName): - iValues(aValues) + iName(aName), + iValues(aValues), + iId(0), + iCurrentValue(0), + iColumnName(aColumnName), + iTableName(aTableName), + iStorageValues(aStorageValues), + iStorageValuesFilter(L""), + iValuesColumnName(aValuesColumnName), + iFilterColumnName(aFilterColumnName), + iFilterColumnValue(aFilterColumnValue), + connectedToUi(false) { - iName = aName; - iId = 0; - iCurrentValue = 0; - iColumnName = aColumnName; - iTableName = aTableName; - iStorageValues = aStorageValues; - iFilterColumnName = aFilterColumnName; - iFilterColumnValue = aFilterColumnValue; - iStorageValuesFilter = L""; - iValuesColumnName = aValuesColumnName; } void JavaApplicationSettings::setCurrentValue(int aCurrentValue) @@ -78,6 +82,21 @@ iCurrentValue = aCurrentValue; } +void JavaApplicationSettings::connectToUi() +{ + connectedToUi = true; +} + +void JavaApplicationSettings::disconnectFromUi() +{ + connectedToUi = false; +} + +bool JavaApplicationSettings::isConnectedToUi() +{ + return connectedToUi; +} + int JavaApplicationSettings::getCurrentValue() { return iCurrentValue; diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javasettings/appsettingsview_qt/src/javaapplicationsettings.h --- a/javamanager/javasettings/appsettingsview_qt/src/javaapplicationsettings.h Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javasettings/appsettingsview_qt/src/javaapplicationsettings.h Fri Jun 11 13:33:44 2010 +0300 @@ -22,6 +22,7 @@ #include #include #include +#include class JavaApplicationSettings { @@ -31,6 +32,7 @@ { QString name; uint id; + CmApplSettingsUi::SelectionType type; }; JavaApplicationSettings(const QString&, @@ -71,6 +73,10 @@ const std::vector& getStorageValues(); void setStorageValuesFilter(const std::wstring&); const std::wstring& getStorageValuesFilter(); + void connectToUi(); + void disconnectFromUi(); + bool isConnectedToUi(); + private: QString iName; QStringList iValues; @@ -85,6 +91,7 @@ std::wstring iValuesColumnName; std::wstring iFilterColumnName; std::wstring iFilterColumnValue; + bool connectedToUi; }; #endif // JAVAAPPLICATIONSETTINGS_H diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javasettings/appsettingsview_qt/src/javaapplicationsettingsview_p.cpp --- a/javamanager/javasettings/appsettingsview_qt/src/javaapplicationsettingsview_p.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javasettings/appsettingsview_qt/src/javaapplicationsettingsview_p.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -27,6 +27,7 @@ #include #include #include +#include #include "javaapplicationsettings.h" #include "javaapplicationsettingsview.h" @@ -48,11 +49,8 @@ const wchar_t ON_SCREEN_KEYPAD_VALUE_NAVIGATION[] = L"2"; JavaApplicationSettingsViewPrivate::JavaApplicationSettingsViewPrivate(const QString& aJavaAppUid): - mainForm(0), model(0), generalSettingsGroup(0), securitySettingsGroup(0) + mainForm(0), model(0), generalSettingsGroup(0), securitySettingsGroup(0), netConnSettingsUi(0), asyncToSyncCallEventLoop(0), secWarningAccepted(false), defaultConnId(0) { - // init access point settings ui - netConnSettingsUi = new CmApplSettingsUi(this); - // init storage iStorage.reset(JavaStorage::createInstance()); try @@ -61,91 +59,104 @@ } catch (JavaStorageException& aJse) {} - // init the suite UID from the application UID - readSuiteUid(aJavaAppUid); - if (iSuiteUid.size() <= 0) - { - // TODO: display a no settings available message - return; - } QTranslator translator; // load the correct translation of the localized strings for the cmmanager. // Load this one first since it contains the smallest amount of strings // (so it's ok to be searched last) - if (translator.load("z:/resource/qt/translations/cmapplsettingsui_" + QLocale::system().name())) - { - qApp->installTranslator(&translator); - } - if (translator.load("z:/resource/qt/translations/cmmanager_" + QLocale::system().name())) - { - qApp->installTranslator(&translator); - } + installTranslator("cmapplsettingsui"); + installTranslator("cmmanager"); // load the correct translation of the localized strings for the java settings // Current solution reads it from Z only (this does not work with IAD) // -> check if translator can handle path without drive letter (e.g. the resource // is loaded from the same drive where the DLL is loaded) - if (translator.load("z:/resource/qt/translations/javaruntimeapplicationsettings_" + QLocale::system().name())) - { - qApp->installTranslator(&translator); - } + installTranslator("javaruntimeapplicationsettings"); // init strings - BLANKET = hbTrId("txt_java_sett_setlabel_permission_val_blanket"); - SESSION = hbTrId("txt_java_sett_setlabel_permission_val_session"); - ONESHOT = hbTrId("txt_java_sett_setlabel_permission_val_oneshot"); - DENIED = hbTrId("txt_java_sett_setlabel_permission_val_no"); - SECURITY_LEVEL = hbTrId("txt_java_sett_setlabel_security_level"); - USER_DEFINED = hbTrId("txt_java_sett_setlabel_security_level_val_user_defined"); - SENSITIVE_SETTINGS = hbTrId("txt_java_sett_info_query_perm_sec"); - SENSITIVE_SETTINGS_NET_USAGE = hbTrId("txt_java_sett_info_query_perm_net"); - MUTUALLY_EXCLUSIVE_SETTINGS = hbTrId("txt_java_sett_info_query_perm_warn"); - OK = hbTrId("txt_java_sett_button_settings_ok"); - CANCEL = hbTrId("txt_java_sett_button_settings_cancel"); - SECURITY_WARNING_TITLE = hbTrId("txt_java_sett_title_note_security_warn"); - NET_ACCESS = hbTrId("txt_java_sett_setlabel_net_access"); - LOW_LEVEL_NET_ACCESS = hbTrId("txt_java_sett_setlabel_low_level_net_access"); - NETWORK_CONNECTION = hbTrId("txt_occ_title_network_connection"); + BLANKET = QString(hbTrId("txt_java_sett_setlabel_permission_val_blanket")); + SESSION = QString(hbTrId("txt_java_sett_setlabel_permission_val_session")); + ONESHOT = QString(hbTrId("txt_java_sett_setlabel_permission_val_oneshot")); + DENIED = QString(hbTrId("txt_java_sett_setlabel_permission_val_no")); + SECURITY_LEVEL = QString(hbTrId("txt_java_sett_setlabel_security_level")); + USER_DEFINED = QString(hbTrId("txt_java_sett_setlabel_security_level_val_user_defined")); + SENSITIVE_SETTINGS = QString(hbTrId("txt_java_sett_info_query_perm_sec")); + SENSITIVE_SETTINGS_NET_USAGE = QString(hbTrId("txt_java_sett_info_query_perm_net")); + MUTUALLY_EXCLUSIVE_SETTINGS = QString(hbTrId("txt_java_sett_info_query_perm_warn")); + OK = QString(hbTrId("txt_java_sett_button_settings_ok")); + CANCEL = QString(hbTrId("txt_java_sett_button_settings_cancel")); + SECURITY_WARNING_TITLE = QString(hbTrId("txt_java_sett_title_note_security_warn")); + NET_ACCESS = QString(hbTrId("txt_java_sett_setlabel_net_access")); + LOW_LEVEL_NET_ACCESS = QString(hbTrId("txt_java_sett_setlabel_low_level_net_access")); + NETWORK_CONNECTION = QString(hbTrId("txt_occ_title_network_connection")); + SETTINGS_TITLE = QString(hbTrId("txt_java_sett_title_settings")); + SETTINGS_NOT_AVAILABLE = QString(hbTrId("txt_java_sett_info_settings_not_available")); + // init the suite UID from the application UID + readSuiteUid(aJavaAppUid); + if (iSuiteUid.size() <= 0) + { + return; + } + + // init access point settings ui + netConnSettingsUi = new CmApplSettingsUi(this); + asyncToSyncCallEventLoop = new QEventLoop(); + // read all settings readAllSettings(); // init form mainForm = new HbDataForm(); - mainForm->setHeading(hbTrId("txt_java_sett_title_settings")); + mainForm->setHeading(QString::fromStdWString(readFromStorage(PACKAGE_NAME, L"", L"", APPLICATION_PACKAGE_TABLE))); model = new HbDataFormModel(); // init settings generalSettingsGroup = model->appendDataFormGroup( - hbTrId("txt_java_sett_subtitle_general"), model->invisibleRootItem()); + QString(hbTrId("txt_java_sett_subtitle_general")), model->invisibleRootItem()); initSettings(generalSettings, generalSettingsGroup); - securitySettingsGroup = model->appendDataFormGroup( - hbTrId("txt_java_sett_subtitle_security"), model->invisibleRootItem()); - initSettings(securitySettings, securitySettingsGroup); + // append the security settings only if there are any user settings + if (extraSettings.size() > 0) + { + securitySettingsGroup = model->appendDataFormGroup( + QString(hbTrId("txt_java_sett_subtitle_security")), model->invisibleRootItem()); + initSettings(securitySettings, securitySettingsGroup); - // if security warnings is user defined -> add the extra settings, expand - if (securitySettings[0].getCurrentValue() == 1) - { - securityWarningsChanged(USER_DEFINED); + // if security warnings is user defined -> add the extra settings, expand + if (securitySettings[0].getCurrentValue() == 1) + { + securityWarningsChanged(USER_DEFINED); + } } // link form and model mainForm->setModel(model); mainForm->setExpanded(model->indexFromItem(generalSettingsGroup), true); - mainForm->setExpanded(model->indexFromItem(securitySettingsGroup), (securitySettings[0].getCurrentValue() == 1)); + if (extraSettings.size() > 0) + { + mainForm->setExpanded(model->indexFromItem(securitySettingsGroup), (securitySettings[0].getCurrentValue() == 1)); + } } void JavaApplicationSettingsViewPrivate::init(JavaApplicationSettingsView* aPublicView) { iPublicView = aPublicView; - // do the connect for the main form - iPublicView->connect(mainForm, SIGNAL(activated(const QModelIndex)), - iPublicView, SLOT(_q_dataItemDisplayed(const QModelIndex))); - - // set the form as view's widget - iPublicView->setWidget(mainForm); + if (mainForm) + { + // do the connect for the main form + iPublicView->connect(mainForm, SIGNAL(activated(const QModelIndex)), + iPublicView, SLOT(_q_dataItemDisplayed(const QModelIndex))); + + // set the form as view's widget + iPublicView->setWidget(mainForm); + } + else + { + // no settings available + HbLabel* label = new HbLabel(SETTINGS_NOT_AVAILABLE, iPublicView); + label->setAlignment(Qt::AlignVCenter); + } // set title - iPublicView->setTitle(QString::fromStdWString(readFromStorage(PACKAGE_NAME, L"", L"", APPLICATION_PACKAGE_TABLE))); + iPublicView->setTitle(SETTINGS_TITLE); } JavaApplicationSettingsViewPrivate::~JavaApplicationSettingsViewPrivate() @@ -153,6 +164,12 @@ delete mainForm; delete model; delete netConnSettingsUi; + delete asyncToSyncCallEventLoop; + foreach (QTranslator *translator, translators) { + qApp->removeTranslator(translator); + } + qDeleteAll(translators); + translators.clear(); } void JavaApplicationSettingsViewPrivate::readAllSettings() @@ -165,16 +182,15 @@ // if the on screen keypad is predefined, it should not be changable by user // -> right now it is not added to settings list. It should be changed so that // the setting should not be editable by user - settingsValues< localizedSettingsNames; + localizedSettingsNames[QString::fromStdWString(NET_ACCESS_SETTINGS)] = NET_ACCESS; + localizedSettingsNames[QString::fromStdWString(LOW_LEVEL_NET_ACCESS_SETTINGS)] = LOW_LEVEL_NET_ACCESS; + localizedSettingsNames[QString::fromStdWString(MESSAGING_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_messaging")); + localizedSettingsNames[QString::fromStdWString(RESTRICTED_MESSAGING_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_restricted_messaging")); + localizedSettingsNames[QString::fromStdWString(CALL_CONTROL_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_call_control")); + localizedSettingsNames[QString::fromStdWString(LOCAL_CONNECTIVITY_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_local_conn")); + localizedSettingsNames[QString::fromStdWString(MULTIMEDIA_RECORDING_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_mm_record")); + localizedSettingsNames[QString::fromStdWString(WRITE_USER_DATA_ACCESS_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_write_data")); + localizedSettingsNames[QString::fromStdWString(READ_USER_DATA_ACCESS_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_read_data")); + localizedSettingsNames[QString::fromStdWString(LOCATION_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_location")); + localizedSettingsNames[QString::fromStdWString(LANDMARK_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_landmarks")); + localizedSettingsNames[QString::fromStdWString(AUTHENTICATION_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_auth")); + localizedSettingsNames[QString::fromStdWString(SMART_CARD_COMMUNICATION_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_smartcard")); + localizedSettingsNames[QString::fromStdWString(APPLICATION_AUTO_INVOCATION_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_app_auto_invoc")); + localizedSettingsNames[QString::fromStdWString(BROADCAST_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_broadcast")); + localizedSettingsNames[QString::fromStdWString(NFC_WRITE_ACCESS_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_nfc_write_access")); + localizedSettingsNames[QString::fromStdWString(URL_START_SETTINGS)] = QString(hbTrId("txt_java_sett_setlabel_url_start")); + vector allSecuritySettings = readFromStorage(FUNCTION_GROUP, MIDP_FUNC_GRP_SETTINGS_TABLE); + // sort the security settings according to how they should be displayed + std::sort(allSecuritySettings.begin(), allSecuritySettings.end(), AscendingSort()); + QHash settingsIndexes; + for(int i=0; i highRiskList; + QStringList highRiskSettingsNames; + highRiskSettingsNames + < mutuallyExclusiveList; + QStringList mutuallyExclusiveSettingsNames; + mutuallyExclusiveSettingsNames + <& settings, HbDataFormModelItem * parent) @@ -290,8 +311,7 @@ for (int i=0; iappendDataFormItem( HbDataFormModelItem::ToggleValueItem, settings[i].getName(), parent); - storageValue = readFromStorage(settings[i]); - if (storageValue >= 0) + currentValue = settings[i].getCurrentValue(); + if (currentValue < 0) { - currentValue = storageValue; + currentValue = 0; } // make it a toogle button (-> get rid of the "pressed" ui effect) - appSettings->setContentWidgetData(QString("text"), settings[i].getValues()[settings[i].getCurrentValue()]); + appSettings->setContentWidgetData(QString("text"), settings[i].getValues()[currentValue]); appSettings->setContentWidgetData(QString("additionalText"),settings[i].getValues()[1 - currentValue]); break; default: @@ -516,6 +536,7 @@ iPublicView->disconnect(extraSettingsId, 0, 0, 0); model->removeItem(model->indexFromItem(extraSettings[i].getId())); extraSettings[i].setId(0); + extraSettings[i].disconnectFromUi(); } } } @@ -532,7 +553,7 @@ // empty filter -> all bearer types included QSet filter; // reset the result - netConnSelection.result = CmApplSettingsUi::SelectionTypeDestination; + netConnSelection.result = netConn.type; netConnSelection.id = netConn.id; // init settings ui with destinations, filter and initial selection netConnSettingsUi->setOptions(listItems, filter); @@ -549,22 +570,26 @@ mainForm->model())->itemFromIndex(dataItemIndex); int itemType = item->data(HbDataFormModelItem::ItemTypeRole).toInt(); HbComboBox * comboBox = NULL; - HbPushButton * pushButton = NULL; + HbPushButton * pushButton = NULL; + HbWidget * widget = (qobject_cast + (mainForm->itemByIndex(dataItemIndex)))->dataItemContentWidget(); + JavaApplicationSettings* settings = findSettings(widget); + if (settings == NULL || settings->isConnectedToUi()) + { + return; + } + settings->connectToUi(); switch(HbDataFormModelItem::DataItemType(itemType)) { case HbDataFormModelItem::ComboBoxItem: - comboBox = static_cast( - (qobject_cast - (mainForm->itemByIndex(dataItemIndex)))->dataItemContentWidget()); + comboBox = static_cast(widget); iPublicView->connect(comboBox, SIGNAL(currentIndexChanged(const QString &)), iPublicView, SLOT(_q_settingsChanged(const QString &)), Qt::UniqueConnection); break; case HbDataFormModelItem::ToggleValueItem: - pushButton = static_cast< HbPushButton*>( - (qobject_cast - (mainForm->itemByIndex(dataItemIndex)))->dataItemContentWidget()); + pushButton = static_cast< HbPushButton*>(widget); iPublicView->connect(pushButton, SIGNAL(clicked(bool)), iPublicView, SLOT(_q_settingsChanged(bool)), @@ -579,34 +604,70 @@ { netConnSelection = netConnSettingsUi->selection(); // store the selection - if (netConnSelection.id != netConn.id) + if (netConnSelection.id != netConn.id + && netConnSelection.id != defaultConnId) { - ConnectionManager::setDestinationNetworkIdL(iSuiteUid, netConnSelection.id); - netConn.id = netConnSelection.id; - readNetworkConnectionName(); - generalSettings[netSettIndex].getId()->setContentWidgetData(QString("text"), netConn.name); - generalSettings[netSettIndex].getId()->setContentWidgetData(QString("additionalText"), netConn.name); + TRAPD(err, + switch(netConnSelection.result) + { + case CmApplSettingsUi::SelectionTypeDestination: + ConnectionManager::setDestinationNetworkIdL(iSuiteUid, netConnSelection.id); + break; + case CmApplSettingsUi::SelectionTypeConnectionMethod: + ConnectionManager::setApnIdL(iSuiteUid, netConnSelection.id); + break; + } + ); + if (err == KErrNone) + { + netConn.id = netConnSelection.id; + netConn.type = netConnSelection.result; + readNetworkConnectionName(); + generalSettings[netSettIndex].getId()->setContentWidgetData(QString("text"), netConn.name); + generalSettings[netSettIndex].getId()->setContentWidgetData(QString("additionalText"), netConn.name); + } } } } +void JavaApplicationSettingsViewPrivate::securityWarningDismissed(HbAction* action) +{ + HbMessageBox *dlg = static_cast(sender()); + secWarningAccepted = (action == dlg->actions().at(0)); + asyncToSyncCallEventLoop->exit(); +} + +void JavaApplicationSettingsViewPrivate::initNetworkConnection() +{ + TRAP_IGNORE( + netConn.id = ConnectionManager::getDestinationNetworkIdL(iSuiteUid); + if (netConn.id == (uint)KJavaNetworkAccessNotSpecified) + { + netConn.id = ConnectionManager::getApnIdL(iSuiteUid); + } + ); + QNetworkConfigurationManager manager; + QNetworkConfiguration defaultCfg = manager.defaultConfiguration(); + defaultConnId = defaultCfg.identifier().toInt(); + QNetworkConfiguration cfg = manager.configurationFromIdentifier( + QString::number(netConn.id)); + if (!cfg.isValid()) + { + cfg = defaultCfg; + } + netConn.name = QString(hbTrId(cfg.name().toUtf8())); +} + void JavaApplicationSettingsViewPrivate::readNetworkConnectionName() { QNetworkConfigurationManager manager; - QNetworkConfiguration cfg; - if (netConn.id == 0) + QNetworkConfiguration cfg = manager.configurationFromIdentifier( + QString::number(netConn.id)); + if (!cfg.isValid()) { - // figure out the default configuration cfg = manager.defaultConfiguration(); } - else - { - cfg = manager.configurationFromIdentifier(QString::number(netConn.id)); - } - if (cfg.isValid()) - { - netConn.name = hbTrId(cfg.name().toUtf8()); - } + netConn.name = QString(hbTrId(cfg.name().toUtf8())); } JavaApplicationSettings* JavaApplicationSettingsViewPrivate::findSettings(HbWidget* id) @@ -648,8 +709,7 @@ bool JavaApplicationSettingsViewPrivate::securityWarningAccepted(const QString& text, const QString& acceptActionLabel, const QString& rejectActionLabel, const QString& headingText) { - return true; -/* HbMessageBox securityWarning(HbMessageBox::MessageTypeQuestion); + HbMessageBox securityWarning(HbMessageBox::MessageTypeQuestion); securityWarning.setDismissPolicy(HbDialog::NoDismiss); securityWarning.setTimeout(HbDialog::NoTimeout); securityWarning.setIconVisible(false); @@ -657,15 +717,62 @@ securityWarning.addAction(new HbAction( acceptActionLabel, &securityWarning)); securityWarning.addAction(new HbAction( - rejectActionLabel, &securityWarning)); - securityWarning.setHeadingWidget(new HbLabel(headingText)); - HbAction *selected = securityWarning.exec(); - return (selected == securityWarning.primaryAction());*/ + rejectActionLabel, &securityWarning)); + securityWarning.setHeadingWidget(new HbLabel(headingText)); + securityWarning.open(this, SLOT(securityWarningDismissed(HbAction*))); + asyncToSyncCallEventLoop->exec(); + return secWarningAccepted; +} + +void JavaApplicationSettingsViewPrivate::configureList(QList& list, const QStringList& settingsNames, const QHash& settingsIndexes) +{ + for(int i=0; i& list, const QHash& settingsIndexes, bool isHighRiskList) +{ + if (settingsIndexes.contains(settingsName)) + { + if (isHighRiskList) + { + extraSettings[settingsIndexes.value(settingsName)].setHighRiskList(list); + } + else + { + extraSettings[settingsIndexes.value(settingsName)].setMutuallyExclusiveList(list); + } + } +} + +void JavaApplicationSettingsViewPrivate::installTranslator(const QString& translationFileName) { - int currentValue = -1; + QTranslator* translator = new QTranslator; + + // load the correct translation of the localized strings for the java settings + // Current solution reads it from Z only (this does not work with IAD) + // -> check if translator can handle path without drive letter (e.g. the resource + // is loaded from the same drive where the DLL is loaded) + if (translator->load("z:/resource/qt/translations/" + + translationFileName + "_" + QLocale::system().name())) + { + translators.append(translator); + qApp->installTranslator(translator); + } + else + { + delete translator; + translator = NULL; + } +} + +void JavaApplicationSettingsViewPrivate::readFromStorage(JavaApplicationSettings& settings) +{ if (settings.getColumnName().size() > 0 && settings.getTableName().size() > 0) { @@ -718,15 +825,12 @@ { if (storageValues[i] == value) { - currentValue = i; + settings.setCurrentValue(i); break; } } } } - - settings.setCurrentValue(currentValue); - return currentValue; } void JavaApplicationSettingsViewPrivate::filterSecuritySettings(JavaApplicationSettings& settings) @@ -861,6 +965,79 @@ return value; } +vector JavaApplicationSettingsViewPrivate::readFromStorage(const std::wstring& aColumnName, const std::string& aTableName) +{ + vector values; + + // hash for associating settings names with display indexes: + // a settings with lower index is shown before a settings + // with a higher index + QHash settingsNamesIndexes; + settingsNamesIndexes[QString::fromStdWString(NET_ACCESS_SETTINGS)] = 0; + settingsNamesIndexes[QString::fromStdWString(LOW_LEVEL_NET_ACCESS_SETTINGS)] = 1; + settingsNamesIndexes[QString::fromStdWString(MESSAGING_SETTINGS)] = 2; + settingsNamesIndexes[QString::fromStdWString(RESTRICTED_MESSAGING_SETTINGS)] = 3; + settingsNamesIndexes[QString::fromStdWString(CALL_CONTROL_SETTINGS)] = 4; + settingsNamesIndexes[QString::fromStdWString(LOCAL_CONNECTIVITY_SETTINGS)] = 5; + settingsNamesIndexes[QString::fromStdWString(MULTIMEDIA_RECORDING_SETTINGS)] = 6; + settingsNamesIndexes[QString::fromStdWString(WRITE_USER_DATA_ACCESS_SETTINGS)] = 7; + settingsNamesIndexes[QString::fromStdWString(READ_USER_DATA_ACCESS_SETTINGS)] = 8; + settingsNamesIndexes[QString::fromStdWString(LOCATION_SETTINGS)] = 9; + settingsNamesIndexes[QString::fromStdWString(LANDMARK_SETTINGS)] = 10; + settingsNamesIndexes[QString::fromStdWString(AUTHENTICATION_SETTINGS)] = 11; + settingsNamesIndexes[QString::fromStdWString(SMART_CARD_COMMUNICATION_SETTINGS)] = 12; + settingsNamesIndexes[QString::fromStdWString(APPLICATION_AUTO_INVOCATION_SETTINGS)] = 13; + settingsNamesIndexes[QString::fromStdWString(BROADCAST_SETTINGS)] = 14; + settingsNamesIndexes[QString::fromStdWString(NFC_WRITE_ACCESS_SETTINGS)] = 15; + settingsNamesIndexes[QString::fromStdWString(URL_START_SETTINGS)] = 16; + int last_index = 16; + + JavaStorageApplicationEntry_t query; + JavaStorageApplicationList_t queryResult; + JavaStorageEntry attr; + attr.setEntry(ID, iSuiteUid); + query.insert(attr); + attr.setEntry(aColumnName, L""); + query.insert(attr); + + try + { + iStorage->search(aTableName, query, queryResult); + JavaStorageApplicationList_t::const_iterator iterator; + for (iterator = queryResult.begin(); iterator != queryResult.end(); iterator++) + { + std::wstring name = L""; + JavaStorageApplicationEntry_t entry = (*iterator); + JavaStorageEntry findPattern; + findPattern.setEntry(aColumnName, L""); + JavaStorageApplicationEntry_t::const_iterator findIterator = + entry.find(findPattern); + if (findIterator != entry.end()) + { + name = findIterator->entryValue(); + } + + if (name.size() > 0) + { + IndexedSettingsName value; + value.name = name; + value.index = last_index + 1; + if (settingsNamesIndexes.contains(QString::fromStdWString(name))) + { + value.index = settingsNamesIndexes.value(QString::fromStdWString(name)); + } + values.push_back(value); + } + } + } + catch (JavaStorageException& aJse) + { + // Don't leave. Set defaults. + } + + return values; +} + void JavaApplicationSettingsViewPrivate::readSuiteUid(const QString& aAppUid) { iSuiteUid = L""; diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javasettings/appsettingsview_qt/src/javaapplicationsettingsview_p.h --- a/javamanager/javasettings/appsettingsview_qt/src/javaapplicationsettingsview_p.h Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javasettings/appsettingsview_qt/src/javaapplicationsettingsview_p.h Fri Jun 11 13:33:44 2010 +0300 @@ -18,7 +18,10 @@ #define JAVAAPPLICATIONSETTINGSVIEW_P_H #include +#include +#include #include +#include #include #include #include "javaapplicationsettings.h" @@ -30,6 +33,21 @@ class HbDataFormModel; class HbDataFormModelItem; class JavaApplicationSettingsView; +class HbAction; + +struct IndexedSettingsName +{ + std::wstring name; + int index; +}; + +struct AscendingSort +{ + bool operator()(const IndexedSettingsName& i1, const IndexedSettingsName& i2) + { + return i1.index < i2.index; + } +}; class JavaApplicationSettingsViewPrivate: public QObject { @@ -47,6 +65,7 @@ private slots: void netConnSelected(uint netConnSelectionStatus); + void securityWarningDismissed(HbAction*); private: void readAllSettings(); @@ -57,16 +76,22 @@ HbWidget * itemToWidget(const HbDataFormModelItem *); JavaApplicationSettings* findSettings(HbWidget* id); JavaApplicationSettings* findSettings(HbWidget* id, QVector& settings); - int readFromStorage(JavaApplicationSettings& settings); + void readFromStorage(JavaApplicationSettings& settings); void writeToStorage(JavaApplicationSettings& settings); bool findFromStorage(const std::wstring&, const std::wstring&, const std::wstring&, const std::string&); std::wstring readFromStorage(const std::wstring&, const std::wstring&, const std::wstring&, const std::string&); + std::vector readFromStorage(const std::wstring& aColumnName, const std::string& aTableName); void filterSecuritySettings(JavaApplicationSettings& settings); void findEntry(const java::storage::JavaStorageApplicationList_t&, const std::wstring&, std::wstring& eValue); void readSuiteUid(const QString& aAppUid); bool securityWarningAccepted(const QString& text, const QString& acceptActionLabel, const QString& rejectActionLabel, const QString& headingText); void handleNetworkSettings(); void readNetworkConnectionName(); + void initNetworkConnection(); + void configureList(QList&, const QStringList&, const QHash&); + void attachList(const QString& settingsName, const QList&, const QHash&, bool isHighRiskList = true); + void installTranslator(const QString& translationFileName); + private: HbDataForm * mainForm; HbDataFormModel *model; @@ -78,11 +103,15 @@ JavaApplicationSettingsView* iPublicView; std::auto_ptr iStorage; std::wstring iSuiteUid; - QString BLANKET,SESSION,ONESHOT,DENIED,SECURITY_LEVEL,USER_DEFINED,SENSITIVE_SETTINGS,SENSITIVE_SETTINGS_NET_USAGE,MUTUALLY_EXCLUSIVE_SETTINGS,OK,CANCEL,SECURITY_WARNING_TITLE,NET_ACCESS,LOW_LEVEL_NET_ACCESS,NETWORK_CONNECTION,NETWORK_CONNECTION_CHANGE; + QString BLANKET,SESSION,ONESHOT,DENIED,SECURITY_LEVEL,USER_DEFINED,SENSITIVE_SETTINGS,SENSITIVE_SETTINGS_NET_USAGE,MUTUALLY_EXCLUSIVE_SETTINGS,OK,CANCEL,SECURITY_WARNING_TITLE,NET_ACCESS,LOW_LEVEL_NET_ACCESS,NETWORK_CONNECTION,NETWORK_CONNECTION_CHANGE,SETTINGS_TITLE,SETTINGS_NOT_AVAILABLE; CmApplSettingsUi* netConnSettingsUi; CmApplSettingsUi::SettingSelection netConnSelection; JavaApplicationSettings::NetworkConnection netConn; int netSettIndex; + QEventLoop* asyncToSyncCallEventLoop; + bool secWarningAccepted; + int defaultConnId; + QList translators; }; diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javasidchecker/build/javasidchecker.mmp --- a/javamanager/javasidchecker/build/javasidchecker.mmp Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javasidchecker/build/javasidchecker.mmp Fri Jun 11 13:33:44 2010 +0300 @@ -39,8 +39,7 @@ // Includes USERINCLUDE . USERINCLUDE ../inc - -SYSTEMINCLUDE ../../../inc /epoc32/include/ecom /epoc32/include/swi +USERINCLUDE ../../../inc // Sources SOURCEPATH ../src diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javasidchecker/src/javasidchecker.cpp --- a/javamanager/javasidchecker/src/javasidchecker.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/javasidchecker/src/javasidchecker.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -21,7 +21,7 @@ #include -#include +#include #include #include "javauids.h" diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javaupgradeapp/build/javaupgradeapp.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javamanager/javaupgradeapp/build/javaupgradeapp.pro Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,31 @@ +# +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: Helper application for uninstalling a java application and +# then installing new application (java or native) +# +# + +TEMPLATE=app +TARGET=javaupgradeapp +CONFIG += omj no_icon stl +CONFIG -= qt + +symbian { + TARGET.UID2 = 0x2000CFEC + TARGET.UID3 = 0x2002FF64 + TARGET.CAPABILITY = TrustedUI + LIBS += -lestor -lapparc -lapgrfx +} + +include(../../../build/omj.pri) diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javaupgradeapp/sis/java_upgradeapp.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javamanager/javaupgradeapp/sis/java_upgradeapp.pkg Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,37 @@ +; +; Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: Helper application for uninstalling a java application and +; then installing new application (any installation package file) +; +;Languages +&EN + + +#{"javaupgradeapp"},(0x2002FF64),1,1,0, TYPE=SA,RU + +;Localised Vendor name +%{"Nokia"} + +;Unique Vendor name +:"Nokia" + +;Supports Series 60 v 5.0 +;This line indicates that this installation is for the Series 60 platform v3.0 +;This line must appear _exactly_ as shown below in the sis file +;If this line is missing or incorrect, the sis file will not be able +;to be installed on Series 60 v5.0 platforms +[0x1028315F], 0, 0, 0, {"Series60ProductID"} + +; +"\epoc32\release\armv5\urel\javaupgradeapp.exe"-"c:\sys\bin\javaupgradeapp.exe" diff -r dc7c549001d5 -r 85266cc22c7f javamanager/javaupgradeapp/src.s60/javaupgradeapp.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javamanager/javaupgradeapp/src.s60/javaupgradeapp.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,407 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Helper application for uninstalling a java application and +* then installing new application (java or native) +* +*/ + +#include +#include +#include +#include +#include +#include +#include + +#include "exceptionbase.h" +#include "javaoslayer.h" +#include "javaprocessconstants.h" +#include "javasymbianoslayer.h" +#include "javauids.h" +#include "logger.h" + + +using namespace java::util; + + +_LIT(KHexValueStart, "0x"); +_LIT(KSemiColon, ";"); +_LIT(KUidArg, "uid="); +_LIT(KFileArg, "file="); + +const TInt KExtraLenForLogging = 2; +const TInt KArgumentValueMaxLen = 1568; +// Wait for 0.5 sec if ArcApp has not yet initialized +const TInt KDelayWhenWaitingAppArc = 500000; + + +/** + * Set the value of the argument specified by aArgName to aArgValue + * + * @param aCmdLine command line to be parsed + * @param aArgName the name of the argument + * @param aArgValue the value parsed from command line will be returned here + */ +static void getArgValueL(const TPtrC &aCmdLine, const TDesC &aArgName, HBufC **aArgValue) +{ + TBuf valueBuf; + TInt argPos = aCmdLine.FindF(aArgName); + if (argPos >= 0) + { + TInt semicolonPos = aCmdLine.Mid(argPos).Find(KSemiColon); + if (KErrNotFound == semicolonPos) + { + semicolonPos = aCmdLine.Mid(argPos).Length(); + } + TInt argLen = semicolonPos - aArgName.Length(); + if (argLen >= KArgumentValueMaxLen) + { + // Protect from buffer overflow. + WLOG2(EUtils, + "javaupgradeapp: argument value len too long (%d), cutting it to %d", + argLen, (KArgumentValueMaxLen - 1)); + argLen = KArgumentValueMaxLen - 1; + } + else if (argLen == 0) + { + User::Leave(KErrArgument); + } + + valueBuf = aCmdLine.Mid(argPos + aArgName.Length(), argLen); + } + + // Allocate new HBufC and return it + HBufC *pBufValue = HBufC::NewL(valueBuf.Length() + 2); + *pBufValue = valueBuf; + *aArgValue = pBufValue; +} + + +/** + * Parse the name from the value of 'file' parameter in + * command line given in aCmdLine + * + * @param aCmdLine command line to be parsed, the format is + * ;file=YYY; + * @param aFileName will contain the name parsed from command line + */ +static void getNameFromCommandLineL(const TPtrC &aCmdLine, HBufC **aFileName) +{ + TInt err = aCmdLine.FindF(KFileArg); + User::LeaveIfError(err); + + getArgValueL(aCmdLine, KFileArg, aFileName); +} + + +/** + * Parse the Uid from the value of 'uid' parameter in + * command line given in aCmdLine + * + * @param aCmdLine command line to be parsed, the format is + * uid=YYY; + * @param aUid will contain the Uid parsed from command line + */ +static void getUidFromCommandLineL(const TPtrC &aCmdLine, TInt32 &aUid) +{ + TInt err(KErrNone); + TInt argPos = aCmdLine.FindF(KUidArg); + if (KErrNotFound != argPos) + { + TPtrC uidToParse = aCmdLine.Mid(argPos + KUidArg.iTypeLength); + TLex parseUid(uidToParse); + if (uidToParse.FindF(KHexValueStart) == 0) + { + parseUid.Inc(2); // skip hex prefix + TUint32 tmpValue; + err = parseUid.Val(tmpValue, EHex); + aUid = tmpValue; + } + else + { + err = parseUid.Val(aUid); + } + + if (KErrNone != err) + { + ELOG1(EUtils, + "javaupgradeapp failed parsing app Uid from cmdline uid param. Error %d", + err); + } + } + else + { + ELOG(EUtils, + "javaupgradeapp cannot uninstall app because uid parameter is not given"); + } + + User::LeaveIfError(err); +} + + +/** + * Parse the process command line. + * Determine the uid of the Java application to be uninstalled and + * the name of the application package to be installed. + * Leaves if argument 'file' exist but file name cannot be found, + * leaves if argument 'uid' exist but uid cannot be parsed from command line, + * does NOT leave if only one of the arguments is present + * + * @param aFileName returns value of argument 'file' + * @param aUid returns Uid of the Java application to be uninstalled + */ +void getFileAndUidL(HBufC **aFileName, TInt32 *aUid) +{ + HBufC *pBufCmdLine = + HBufC::NewLC(User::CommandLineLength() + KExtraLenForLogging); + TPtr cmdLineBuf = pBufCmdLine->Des(); + User::CommandLine(cmdLineBuf); + + if (cmdLineBuf.Length() > 0) + { + LOG1WSTR(EUtils, EInfo, + "javaupgradeapp: full java application cmd line is : %s", + (wchar_t *)(cmdLineBuf.PtrZ())); + + // Get the midlet uid from the commandline + TRAPD(err, getUidFromCommandLineL(cmdLineBuf, *aUid)); + // It is enough that either midlet uid OR installation package name + // have been given in commandline + if ((err != KErrNone) && (err != KErrNotFound)) + { + User::Leave(err); + } + + // Get the name of the installation package from the commandline + TRAPD(err2, getNameFromCommandLineL(cmdLineBuf, aFileName)) + if (err2 != KErrNone) + { + if (err2 == KErrNotFound) + { + if (err == KErrNotFound) + { + // Both arguments missing + User::Leave(KErrArgument); + } + } + else + { + User::Leave(err2); + } + } + } + else + { + ELOG(EUtils, "javaupgradeapp: empty command line"); + User::Leave(KErrArgument); + } + + CleanupStack::PopAndDestroy(pBufCmdLine); +} + + +/** + * Uninstall the java application specified by aUid parameter. + * + * @param aUid the Uid of the java application to be uninstalled + */ +void uninstallJavaAppL(TInt32 aUid) +{ + RProcess rJavaInstaller; + TFileName fileName; + // Max one path name and some options -> 1536 is enough + TBuf<1536> commandLine; + + // Build command line used to pass all necessary info to Java Installer + TInt len = strlen(java::runtime::JAVA_INSTALLER_STARTER_DLL); + TPtr8 ptr8InstallerDll((TUint8 *)java::runtime::JAVA_INSTALLER_STARTER_DLL, len, len); + commandLine.Copy(ptr8InstallerDll); + + // Use command line options that make sure that uninstallation is done + // always, silently and so that the uninstalled java application will + // be preinstalled again if the user uninstalls it + commandLine.Append(_L(" uninstall -uid=")); + commandLine.AppendNum(aUid); + commandLine.Append(_L(" -forceuninstall -silent -preinstall_always")); + + LOG1WSTR(EUtils, EInfo, + "javaupgradeapp:uninstallJavaAppL Java Installer command line is %s", + (wchar_t *)(commandLine.PtrZ())); + + // start JavaInstaller + TBuf<64> installerProcess; // Actual len of the process name is 9 + len = strlen(java::runtime::JAVA_PROCESS); + TPtr8 ptr8Process((TUint8 *)java::runtime::JAVA_PROCESS, len, len); + installerProcess.Copy(ptr8Process); + + TRequestStatus status; + TInt err = rJavaInstaller.Create(installerProcess, commandLine); + if (KErrNone == err) + { + LOG(EUtils, EInfo, "javaupgradeapp:uninstallJavaAppL calling Logon"); + // Get notification when Java Installer exits (or panics) + rJavaInstaller.Logon(status); + + LOG(EUtils, EInfo, "javaupgradeapp:uninstallJavaAppL calling Resume"); + rJavaInstaller.Resume(); + } + else + { + ELOG1(EUtils, + "javaupgradeapp:uninstallJavaAppL Cannot start Java Installer, error %d", + err); + User::Leave(err); + } + + // now wait until Java Installer exits + User::WaitForRequest(status); + + LOG(EUtils, EInfo, "javaupgradeapp:uninstallJavaAppL calling RProcess::Close"); + // free resources before returning + rJavaInstaller.Close(); +} + + +/** + * + * + * + */ +void installAppPackageL(HBufC *aBufFileName) +{ + // Open file using default handler, + // if the file is an installation package, it will be installed + RApaLsSession apaSession; + TInt err = apaSession.Connect(); + if (KErrNone != err) + { + ELOG(EUtils, + "javaupgradeapp:installAppPackageL: Cannot connect to AppArc server"); + User::Leave(err); + } + CleanupClosePushL(apaSession); + + TInt retryCounter(10); + TThreadId handlerTreadId; + do + { + err = apaSession.StartDocument(*aBufFileName, handlerTreadId); + if (RApaLsSession::EAppListInvalid == err) + { + // Application list has not yet been populated, + // try again after a short delay + retryCounter--; + if (retryCounter > 0) + { + User::After(KDelayWhenWaitingAppArc); + continue; + } + else + { + ELOG(EUtils, + "javaupgradeapp:installAppPackageL: RApaLsSession " + "StartDocument returned EAppListInvalid for 10 times, exiting"); + User::Leave(err); + } + } + else if (KErrNone != err) + { + ELOG1(EUtils, + "javaupgradeapp:installAppPackageL: RApaLsSession " + "StartDocument returned error %d", err); + User::Leave(err); + } + + } while (RApaLsSession::EAppListInvalid == err); + + CleanupStack::PopAndDestroy(); // apaSession +} + + +/** + * Get the uid of the Java application to be uninstaller and + * start Java Installer to uninstall the application. + * Then install the new application package given in cmdline + * + */ +void handleUpgradeL(void) +{ + HBufC *pBufFileName = NULL; + TInt32 uid(0); + + getFileAndUidL(&pBufFileName, &uid); + + if (uid != 0) + { + LOG1( + EUtils, + EInfo, + "javaupgradeapp uninstalling app uid %d", uid); + uninstallJavaAppL(uid); + } + + if (pBufFileName != NULL) + { + LOG1WSTR(EUtils, EInfo, + "javaupgradeapp: installing new app package %s", + (wchar_t *)(pBufFileName->Des().PtrZ())); + installAppPackageL(pBufFileName); + + delete pBufFileName; + } +} + + +/** + * Main function of executable javaupgradeapp.exe. + * "installer app" created by Services team starts this executable when + * the "installer app" must be replaced with the real application (java/native or wrt) + * + * The command line format is + * uid=;file= + * for example + * uid=0x10137c4d;file=D:\\temp\\upgrade\\package.sis + * + * Sample code for starting this application from the "installer app" MIDlet + * @code + + MIDlet.platformRequest( + “nativeapp://application-exe=javaupgradeapp.exe;application-args=uid=0x10137c4d;file=D:\\temp\\upgrade\\package.sis”); + + * @endcode + * + */ +TInt E32Main(void) +{ + // TODO: check that only MIDP runtime process can start this in final version + // that goes to ROM + + + CTrapCleanup *pCleanupStack = CTrapCleanup::New(); + if (NULL == pCleanupStack) + { + ELOG(EUtils, "Cannot create CleanupStack in javaupgradeapp.exe main()"); + return KErrNoMemory; + } + + TRAPD(err, handleUpgradeL()); + if (KErrNone != err) + { + ELOG1(EUtils, "javaupgradeapp.exe: handleUpgradeL leaved with err %d", err); + } + + delete pCleanupStack; + return err; +} + diff -r dc7c549001d5 -r 85266cc22c7f javamanager/preinstaller/src.s60/main.cpp --- a/javamanager/preinstaller/src.s60/main.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javamanager/preinstaller/src.s60/main.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -119,7 +119,7 @@ // Start active scheduler. Preinstallation starts. LOG(EJavaPreinstaller, EInfo, "startPreinstallationL: Starting CActiveScheduler"); - CActiveScheduler::Start(); + CActiveScheduler::Start(); // codescanner::activestart // Now preinstallation has been done LOG(EJavaPreinstaller, EInfo, "startPreinstallationL: Cleaning up"); diff -r dc7c549001d5 -r 85266cc22c7f javaruntimes/installer/starterdll/src/main.cpp --- a/javaruntimes/installer/starterdll/src/main.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javaruntimes/installer/starterdll/src/main.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -212,7 +212,7 @@ #endif // Wait 3 seconds so that Java Captain has time to start - User::After(3000000); + User::After(3000000); // codescanner::userafter } else { diff -r dc7c549001d5 -r 85266cc22c7f javaruntimes/midp/runtime/javasrc/com/nokia/mj/impl/rt/midp/MidletLifeCycle.java --- a/javaruntimes/midp/runtime/javasrc/com/nokia/mj/impl/rt/midp/MidletLifeCycle.java Thu May 27 12:49:31 2010 +0300 +++ b/javaruntimes/midp/runtime/javasrc/com/nokia/mj/impl/rt/midp/MidletLifeCycle.java Fri Jun 11 13:33:44 2010 +0300 @@ -25,16 +25,18 @@ import java.util.Timer; import java.util.TimerTask; +import java.security.AccessControlException; + import com.nokia.mj.impl.rt.utils.ExtensionUtil; +import com.nokia.mj.impl.rt.utils.CmdLineArgsPermission; import com.nokia.mj.impl.rt.support.Jvm; import com.nokia.mj.impl.rt.support.JvmInternal; import com.nokia.mj.impl.rt.support.ThreadEventListener; +import com.nokia.mj.impl.rt.support.ApplicationUtils; import com.nokia.mj.impl.rt.legacy.LegacySupport; -import com.nokia.mj.impl.gcf.PushSecurityUtils; - import com.nokia.mj.impl.security.packageprotection.PackageProtector; import com.nokia.mj.impl.security.common.RuntimeSecurityException; import com.nokia.mj.impl.security.midp.authentication.AuthenticationModule; @@ -620,7 +622,7 @@ { if (Log.mOn) Log.logI("MidletLifeCycle.handleStartRequest(), subTask: " + subTask); - if ((mState == POST_INIT_DONE && subTask != LifeCycleTask.PRE_WARM_START) || + if ((mState == POST_INIT_DONE && subTask != LifeCycleTask.PRE_WARM_START) || (mState == PRE_INIT_DONE && subTask == LifeCycleTask.PRE_WARM_START)) { if (subTask == LifeCycleTask.NORMAL_START) @@ -879,7 +881,7 @@ t = encodedArgs.charAt(idx); if (t < 'a') { - if (idx + 4 >= len) + if (idx + 3 >= len) break; // decode one 16-bit char char a = (char)(t - 'A'); @@ -892,7 +894,7 @@ } else { - if (idx + 2 >= len) + if (idx + 1 >= len) break; // decode one 8-bit char char a = (char)(t - 'a'); @@ -960,7 +962,7 @@ // If system property com.nokia.mid.cmdline has value, it contains // the arguments for the current MIDlet. setMidletArguments(); - + if (mPrewarmStart) { // Get the recorded heap size from previous run. @@ -995,23 +997,23 @@ if ((mMainArgs.findArgument("-autoinvocation") != null) || mAutoinvocationFromUrl) { + if (Log.mOn) Log.logI("Ensuring autoinvocation."); + String pushAdditionalInfo = + mMainArgs.findArgument("-autoInvocationAdditional"); + if (Log.mOn) Log.logI(" addInfo: '" + pushAdditionalInfo + "'"); + + // ensure security try { - if (Log.mOn) Log.logI("Ensuring autoinvocation."); - String pushAdditionalInfo = - mMainArgs.findArgument("-autoInvocationAdditional"); - if (Log.mOn) Log.logI(" addInfo: '" + pushAdditionalInfo + "'"); - PushSecurityUtils.ensurePermission("autoinvocation", - pushAdditionalInfo); - + ApplicationUtils appUtils = ApplicationUtils.getInstance(); + CmdLineArgsPermission cmdLineArgsPermission = + new CmdLineArgsPermission(); + appUtils.checkPermission(cmdLineArgsPermission); if (Log.mOn) Log.logI("Autoinvocation allowed."); - } - catch (SecurityException se) + }catch(AccessControlException e) { - // The user didn't allow starting. Throw StartupException and - // mark it as non fatal. - if (Log.mOn) Log.logI("Autoinvocation NOT allowed."); - throw new StartupException("Auto invocation not allowed.", + if (Log.mOn) Log.logI("Autoinvocation NOT allowed."); + throw new StartupException(e.toString(), false); } } @@ -1169,7 +1171,7 @@ if (mAcceptedUserProperties == null) { // Doing intialization only once. - String launchParams = + String launchParams = ApplicationInfoImpl.getMidletInfo().getAttribute("Nokia-MIDlet-Launch-Params"); mAcceptedUserProperties = split(launchParams, ","); } diff -r dc7c549001d5 -r 85266cc22c7f javaruntimes/midp/runtime/javasrc/com/nokia/mj/impl/rt/utils/CmdLineArgsPermission.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javaruntimes/midp/runtime/javasrc/com/nokia/mj/impl/rt/utils/CmdLineArgsPermission.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,106 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Permission object for managing access to command line API feature +* +*/ + + + +package com.nokia.mj.impl.rt.utils; + +import java.security.Permission; +import java.security.PermissionCollection; +import com.nokia.mj.impl.security.common.PermissionBase; +import com.nokia.mj.impl.security.utils.SecurityPromptMessage; + +/** + * Permission class representing the token access to command line API feature. + * + */ +public class CmdLineArgsPermission extends PermissionBase +{ + /** + * Constructor + * + */ + public CmdLineArgsPermission() + { + super(null); + } + + /** + * Returns the question (as localized text) associated with the security + * prompt + * + * @return the localized text associated with the security prompt + */ + public String getSecurityPromptQuestion(int aInteractionMode) + { + return (SecurityPromptMessage.getInstance()).getText( + SecurityPromptMessage.QUESTION_ID_APP_AUTO_LAUNCH, + null); + } + + /** + * Only implies permission objects of same instance + */ + public boolean implies(Permission p) + { + if (p instanceof CmdLineArgsPermission) + { + return true; + } + return false; + } + + /** + * String representation of the permission + */ + public String toString() + { + return "com.nokia.webstart"; + } + + /** + * Don't allow cloning + */ + public boolean equals(Object obj) + { + return (obj.hashCode() == hashCode()); + } + + /** + * Not supported + */ + public int hashCode() + { + return 0; + } + + /** + * Actions are not supported + */ + public String getActions() + { + return null; + } + + /** + * Permission collections not supported + */ + public PermissionCollection newPermissionCollection() + { + return null; + } +} \ No newline at end of file diff -r dc7c549001d5 -r 85266cc22c7f javaruntimes/midp/runtime/javasrc/javax/microedition/midlet/MIDlet.java --- a/javaruntimes/midp/runtime/javasrc/javax/microedition/midlet/MIDlet.java Thu May 27 12:49:31 2010 +0300 +++ b/javaruntimes/midp/runtime/javasrc/javax/microedition/midlet/MIDlet.java Fri Jun 11 13:33:44 2010 +0300 @@ -312,6 +312,8 @@ mNetworkPromptSchemes = new Hashtable(); mNetworkPromptSchemes.put("http:","javax.microedition.io.Connector.http"); mNetworkPromptSchemes.put("https:","javax.microedition.io.Connector.https"); + mNetworkPromptSchemes.put("rtsp:","javax.microedition.io.Connector.rtsp"); + mNetworkPromptSchemes.put("mms:","javax.microedition.io.Connector.rtsp"); } if (mNoPromptSchemes == null) { @@ -320,9 +322,7 @@ mNoPromptSchemes = new Hashtable(); mNoPromptSchemes.put("cti:",""); mNoPromptSchemes.put("mailto:",""); - mNoPromptSchemes.put("mms:",""); mNoPromptSchemes.put("mmsto:",""); - mNoPromptSchemes.put("rtsp:",""); mNoPromptSchemes.put("sms:",""); mNoPromptSchemes.put("tel:",""); } diff -r dc7c549001d5 -r 85266cc22c7f javaruntimes/midp/runtimestarter/src/midpruntimestarter.cpp --- a/javaruntimes/midp/runtimestarter/src/midpruntimestarter.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javaruntimes/midp/runtimestarter/src/midpruntimestarter.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -165,6 +165,14 @@ // Starting with lower old space in pre warm case. jvm->overrideOldHeapSize(36); + + // In the pre-warm start we need to add something into class path. + // Otherwise the VM puts class path to point MIDP private data cage. +#ifdef RD_JAVA_SYMBIAN_TARGET + jvm->appendClassPath(L"z:/private/ignore.jar"); +#else // RD_JAVA_SYMBIAN_TARGET + jvm->appendClassPath(L"./ignore.jar"); +#endif // RD_JAVA_SYMBIAN_TARGET } // If the requested to go to back ground, pass the info to Java peer. diff -r dc7c549001d5 -r 85266cc22c7f javaruntimes/starterutils/src.s60/j9starters60.cpp --- a/javaruntimes/starterutils/src.s60/j9starters60.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javaruntimes/starterutils/src.s60/j9starters60.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -205,6 +205,10 @@ { pathType = BOOT_CLASSPATH_TCKRUNNER; } + else if (mIdentifier == L"JavaControlPanel") + { + pathType = BOOT_CLASSPATH_JAVACONTROLPANEL; + } std::list odcFiles; std::list bcpEntities; diff -r dc7c549001d5 -r 85266cc22c7f javatools/javacaptain_app/build/bld.inf --- a/javatools/javacaptain_app/build/bld.inf Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,22 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -PRJ_PLATFORMS -default - -PRJ_MMPFILES -javacaptainapp.mmp \ No newline at end of file diff -r dc7c549001d5 -r 85266cc22c7f javatools/javacaptain_app/build/javacaptainapp.mmp --- a/javatools/javacaptain_app/build/javacaptainapp.mmp Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -#include -#include -#include -#include <../../../inc/java_stdcpp_support_for_exe.hrh> -#include <../../../inc/project_defines.hrh> - -TARGET JavaCap.exe -TARGETTYPE exe -UID 0x100039CE 0x20022D3C -CAPABILITY AllFiles WriteDeviceData PowerMgmt NetworkControl - -SOURCEPATH ../src.s60 -SOURCE javacap.cpp - -PAGED - -USERINCLUDE ../../../inc - -START RESOURCE javacap.rss -HEADER -TARGETPATH APP_RESOURCE_DIR -LANG SC -END // RESOURCE - -START RESOURCE javacap_reg.rss -// Do not change the UID below. -TARGETPATH /private/10003a3f/apps -END - -LIBRARY apparc.lib -LIBRARY cone.lib -LIBRARY eikcore.lib -LIBRARY eikcoctl.lib -LIBRARY avkon.lib -LIBRARY bafl.lib -LIBRARY egul.lib -LIBRARY ws32.lib -LIBRARY flogger.lib -LIBRARY efsrv.lib -LIBRARY centralrepository.lib - -LIBRARY javacomms.lib -LIBRARY javaipc.lib -LIBRARY javastorage.lib -LIBRARY javadebugapi.lib - -// End of file diff -r dc7c549001d5 -r 85266cc22c7f javatools/javacaptain_app/src.s60/javacap.cpp --- a/javatools/javacaptain_app/src.s60/javacap.cpp Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,685 +0,0 @@ -/* -* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: JavaCap -* -*/ - - -#include "comms.h" -#include "rtcmessages.h" -#include "coremessages.h" - -#include "logger.h" - -#include "javacap.h" -#include "javacap.hrh" - -#include "javainifileutils.h" - -#include -#include - -#include "javastoragenames.h" // Storage constants. -#include "securitystoragedatadefs.h" - -#include - -_LIT(KJavaCapYes, "Yes"); -_LIT(KJavaCapNo, "No"); -_LIT(KUserSecurityMode, "User"); -_LIT(KNormalSecurityMode, "Default"); -_LIT(KS60SecurityPolicyName, "S60"); -_LIT(KMSASecurityPolicyName, "MSA"); -_LIT(KATTSecurityPolicyName, "AT&T"); -_LIT(KS60SecurityPolicy, "s60"); -_LIT(KMSASecurityPolicy, "msa"); -_LIT(KATTSecurityPolicy, "att"); -// Java Security Policy Central Repository UID -static const TUid KCRUidJavaSecurity = { 0x2001B289 }; -// IDs for security folder and file keys -static const TUint32 KPolicy = 0x03; -static const TUint32 KSecurityWarnings = 0x04; -const int KS60SecurityPolicyId = 1; -const int KMSASecurityPolicyId = 2; -const int KATTSecurityPolicyId = 3; - -using namespace java::storage; -using namespace std; -using namespace java::util; -using namespace java::comms; -using namespace java::captain; - -void CJavaCaptainContainer::ConstructL(const TRect& aRect) -{ - JELOG2(EJavaCaptain); - mCaptainRunning = true; - mPrewarmEnabled = false; -#if defined(RD_JAVA_PREWARM) && !defined (__WINS__) - mPrewarmEnabled = true; -#endif // RD_JAVA_PREWARM - mPrewarmUiEnabled = false; - mDebugEnabled = false; - mRedirectEnabled = false; - iStorage.reset(JavaStorage::createInstance()); - try - { - iStorage->open(); - } - catch (JavaStorageException& aJse) - { - User::Leave(aJse.mStatus); - } - mUserSecurityModeEnabled = (GetSecurityWarningsMode() == SECURITY_WARNINGS_USER_DEFINED_MODE); - mSecurityPolicyId = GetSecurityPolicy(); - mHeader = _L("Java states:"); - updateStates(); - CreateWindowL(); - SetRect(aRect); - ActivateL(); - mRedirector.reset(new LogRedirector()); -} - -CJavaCaptainContainer::~CJavaCaptainContainer() -{ - JELOG2(EJavaCaptain); -} - -void CJavaCaptainContainer::Draw(const TRect& /*aRect*/) const -{ - JELOG2(EJavaCaptain); - CWindowGc& gc = SystemGc(); - gc.Clear(); - - const CFont* usedFont = CEikonEnv::Static()->NormalFont(); - gc.UseFont(usedFont); - - gc.DrawText(mHeader,TPoint(10,20)); - int pos = 50; - gc.DrawText(mCaptainState,TPoint(20,pos)); - int gap = 25; - pos += gap; - gc.DrawText(mPrewarmState,TPoint(20,pos)); - pos += gap; - gc.DrawText(mPrewarmUiState,TPoint(20,pos)); - pos += gap; - gc.DrawText(mDebugState,TPoint(20,pos)); - pos += gap; - gc.DrawText(mSecurityMode,TPoint(20,pos)); - pos += gap; - gc.DrawText(mSecurityPolicy,TPoint(20,pos)); - pos += gap; - gc.DrawText(mRedirectState,TPoint(20,pos)); - - gc.DiscardFont(); -} - -void CJavaCaptainContainer::updateStates() -{ - - int propertyVal = java::util::JavaIniFileUtils::getProperty(java::util::UI_PREWARM); - if (propertyVal != -1) - { - mPrewarmUiEnabled = propertyVal; - } - - mCaptainState = _L("Captain running: "); - if (mCaptainRunning) - { - mCaptainState.Append(KJavaCapYes); - } - else - { - mCaptainState.Append(KJavaCapNo); - } - - mPrewarmState = _L("Prewarm enabled: "); - if (mPrewarmEnabled) - { - mPrewarmState.Append(KJavaCapYes); - } - else - { - mPrewarmState.Append(KJavaCapNo); - } - - mPrewarmUiState = _L("Prewarm UI enabled: "); - if (mPrewarmUiEnabled) - { - mPrewarmUiState.Append(KJavaCapYes); - } - else - { - mPrewarmUiState.Append(KJavaCapNo); - } - - mDebugState = _L("Java Debug enabled: "); - if (mDebugEnabled) - { - mDebugState.Append(KJavaCapYes); - } - else - { - mDebugState.Append(KJavaCapNo); - } - - mSecurityMode = _L("Security warnings: "); - if (mUserSecurityModeEnabled) - { - mSecurityMode.Append(KUserSecurityMode); - } - else - { - mSecurityMode.Append(KNormalSecurityMode); - } - - mSecurityPolicy = _L("Security policy: "); - switch (mSecurityPolicyId) - { - case KS60SecurityPolicyId: - mSecurityPolicy.Append(KS60SecurityPolicyName); - break; - case KMSASecurityPolicyId: - mSecurityPolicy.Append(KMSASecurityPolicyName); - break; - case KATTSecurityPolicyId: - mSecurityPolicy.Append(KATTSecurityPolicyName); - break; - default: - mSecurityPolicy.Append(KS60SecurityPolicyName); - } - - mRedirectState = _L("Redirect logs: "); - if (mRedirectEnabled) - { - mRedirectState.Append(KJavaCapYes); - } - else - { - mRedirectState.Append(KJavaCapNo); - } - - DrawDeferred(); -} - -void CJavaCaptainContainer::setCaptainState(bool running) -{ - mCaptainRunning = running; - updateStates(); -} - - - -#include "commsmessage.h" -#include "commsclientendpoint.h" - -void CJavaCaptainContainer::handleStateChangeCmd(int cmd) -{ - switch (cmd) - { - - case ETogglePrewarmEnable: - { - mPrewarmEnabled = !mPrewarmEnabled; - CommsMessage message; - message.setModuleId(PLUGIN_ID_JAVACAPTAIN_CORE_C); - if (mPrewarmEnabled) - { - message.setMessageId(CORE_MSG_ID_START_PREWARM); - } - else - { - message.setMessageId(CORE_MSG_ID_STOP_PREWARM); - } - CommsClientEndpoint comms; - comms.connect(IPC_ADDRESS_JAVA_CAPTAIN_C); - comms.send(message); - comms.disconnect(); - break; - } - case ETogglePrewarmUiEnable: - mPrewarmUiEnabled = !mPrewarmUiEnabled; - java::util::JavaIniFileUtils::setProperty(java::util::UI_PREWARM, mPrewarmUiEnabled); - break; - - case EDebugMode: - { - mDebugEnabled = !mDebugEnabled; - - CommsMessage message; - std::wstring vmArgs = L""; - if (mDebugEnabled) - { - vmArgs = L"-Xrunjdwp:server=y,address=localhost:8000"; - } - setSetExtraArguments(message, vmArgs, L""); - - CommsClientEndpoint comms; - comms.connect(IPC_ADDRESS_JAVA_CAPTAIN_C); - comms.send(message); - comms.disconnect(); - } - break; - - case ESecurityMode: - { - mUserSecurityModeEnabled = !mUserSecurityModeEnabled; - - if (mUserSecurityModeEnabled) - { - SetSecurityWarningsMode(SECURITY_WARNINGS_USER_DEFINED_MODE); - } - else - { - SetSecurityWarningsMode(SECURITY_WARNINGS_DEFAULT_MODE); - } - } - break; - case ES60SecurityPolicy: - mSecurityPolicyId = KS60SecurityPolicyId; - SetSecurityPolicy(mSecurityPolicyId); - break; - case EMSASecurityPolicy: - mSecurityPolicyId = KMSASecurityPolicyId; - SetSecurityPolicy(mSecurityPolicyId); - break; - case EATTSecurityPolicy: - mSecurityPolicyId = KATTSecurityPolicyId; - SetSecurityPolicy(mSecurityPolicyId); - break; - - case ERedirectMode: - mRedirectEnabled = !mRedirectEnabled; - if (mRedirectEnabled) - { - mRedirector->start(); - } - else - { - mRedirector->stop(); - } - break; - - default: - break; - } - updateStates(); -} - -std::wstring CJavaCaptainContainer::GetSecurityWarningsMode() -{ - try - { - JavaStorageApplicationEntry_t query; - JavaStorageApplicationList_t queryResult; - JavaStorageEntry attr; - attr.setEntry(ID, L""); - query.insert(attr); - attr.setEntry(SECURITY_WARNINGS, L""); - query.insert(attr); - iStorage->search(MIDP_PACKAGE_TABLE, query, queryResult); - JavaStorageApplicationList_t::const_iterator iterator; - JavaStorageApplicationList_t domainQueryResult; - for (iterator = queryResult.begin(); iterator != queryResult.end(); iterator++) - { - std::wstring securityWarnings = L""; - JavaStorageApplicationEntry_t entry = (*iterator); - findColumn(entry, SECURITY_WARNINGS, securityWarnings); - if (securityWarnings == SECURITY_WARNINGS_USER_DEFINED_MODE) - { - // make them all USER - SetSecurityWarningsMode(SECURITY_WARNINGS_USER_DEFINED_MODE); - return SECURITY_WARNINGS_USER_DEFINED_MODE; - } - } - } - catch (JavaStorageException& aJse) - { - } - // one mroe check: central repository - std::wstring securityWarningsMode = SECURITY_WARNINGS_DEFAULT_MODE; - TRAP_IGNORE( - CRepository* repository = CRepository::NewLC(KCRUidJavaSecurity); - TInt warningsMode; - User::LeaveIfError(repository->Get(KSecurityWarnings, warningsMode)); - switch (warningsMode) -{ -case 1: - securityWarningsMode = SECURITY_WARNINGS_USER_DEFINED_MODE; - break; -case 2: - securityWarningsMode = SECURITY_WARNINGS_DEFAULT_MODE; - break; -} -CleanupStack::PopAndDestroy(repository);); - return securityWarningsMode; -} - -void CJavaCaptainContainer::SetSecurityWarningsMode(const std::wstring& aSecurityWarningsMode) -{ - try - { - JavaStorageApplicationEntry_t query; - JavaStorageApplicationList_t queryResult; - JavaStorageEntry attr; - attr.setEntry(ID, L""); - query.insert(attr); - iStorage->search(MIDP_PACKAGE_TABLE, query, queryResult); - JavaStorageApplicationList_t::const_iterator iterator; - JavaStorageApplicationList_t domainQueryResult; - for (iterator = queryResult.begin(); iterator != queryResult.end(); iterator++) - { - std::wstring uid = L""; - JavaStorageApplicationEntry_t entry = (*iterator); - findColumn(entry, ID, uid); - JavaStorageApplicationEntry_t oldEntry; - JavaStorageEntry oldAttr; - oldAttr.setEntry(ID, uid); - oldEntry.insert(oldAttr); - attr.setEntry(SECURITY_WARNINGS, aSecurityWarningsMode); - entry.clear(); - entry.insert(attr); - iStorage->update(MIDP_PACKAGE_TABLE, entry, oldEntry); - } - } - catch (JavaStorageException& aJse) - { - } - // set the cenRep key as well - TRAP_IGNORE( - CRepository* repository = CRepository::NewLC(KCRUidJavaSecurity); - if (aSecurityWarningsMode == SECURITY_WARNINGS_USER_DEFINED_MODE) -{ - repository->Set(KSecurityWarnings, 1); - } - else - { - repository->Set(KSecurityWarnings, 2); - } - CleanupStack::PopAndDestroy(repository); - ); -} - -void CJavaCaptainContainer::findColumn(const JavaStorageApplicationEntry_t& aEntry, - const wstring& aColName, wstring& aColValue) -{ - JavaStorageEntry findPattern; - findPattern.setEntry(aColName, L""); - JavaStorageApplicationEntry_t::const_iterator findIterator = - aEntry.find(findPattern); - if (findIterator != aEntry.end()) - { - aColValue = findIterator->entryValue(); - } -} - - -int CJavaCaptainContainer::GetSecurityPolicy() -{ - int securityPolicyId =KS60SecurityPolicyId; - TRAP_IGNORE( - CRepository* repository = CRepository::NewLC(KCRUidJavaSecurity); - HBufC* buf = HBufC::NewLC(NCentralRepositoryConstants::KMaxUnicodeStringLength); - TPtr policy(buf->Des()); - User::LeaveIfError(repository->Get(KPolicy, policy)); - if (policy.Compare(KS60SecurityPolicy) == 0) -{ - securityPolicyId = KS60SecurityPolicyId; -} -else if (policy.Compare(KMSASecurityPolicy) == 0) -{ - securityPolicyId = KMSASecurityPolicyId; -} -else if (policy.Compare(KATTSecurityPolicy) == 0) -{ - securityPolicyId = KATTSecurityPolicyId; -} -CleanupStack::PopAndDestroy(buf); -CleanupStack::PopAndDestroy(repository);); - return securityPolicyId; -} - -void CJavaCaptainContainer::SetSecurityPolicy(int aSecurityPolicyId) -{ - TRAP_IGNORE( - CRepository* repository = CRepository::NewLC(KCRUidJavaSecurity); - switch (aSecurityPolicyId) -{ -case KS60SecurityPolicyId: - User::LeaveIfError(repository->Set(KPolicy, KS60SecurityPolicy)); - break; - case KMSASecurityPolicyId: - User::LeaveIfError(repository->Set(KPolicy, KMSASecurityPolicy)); - break; - case KATTSecurityPolicyId: - User::LeaveIfError(repository->Set(KPolicy, KATTSecurityPolicy)); - break; - } - CleanupStack::PopAndDestroy(repository);); -} - -// -// CJavaCaptainAppUi -// -CJavaCaptainAppUi::~CJavaCaptainAppUi() -{ - JELOG2(EJavaCaptain); - RemoveFromStack(iAppView); - delete iAppView; - delete mPeriodic; -} - -void CJavaCaptainAppUi::ConstructL() -{ - JELOG2(EJavaCaptain); - BaseConstructL(); - iAppView=new(ELeave) CJavaCaptainContainer; - iAppView->SetMopParent(this); - iAppView->ConstructL(ClientRect()); - - iCoeEnv->RootWin().EnableFocusChangeEvents(); - mPeriodic=CPeriodic::NewL(CActive::EPriorityStandard); - - AddToStackL(iAppView); - -} - -_LIT(KExecutableName, "javacaptain.exe"); - -void senMsgToSplash(int id) -{ - CommsMessage message; - message.setModuleId(1); - message.setMessageId(id); - CommsClientEndpoint comms; - comms.connect(10900); - comms.send(message); - comms.disconnect(); -} - -TInt CJavaCaptainAppUi::tick(TAny* appUi) -{ - CJavaCaptainAppUi* app = static_cast(appUi); -// ELOG1(EJavaCaptain,"mActive: %d", app->mActive); - if (app->mActive) - { - senMsgToSplash(1); - } - else - { - senMsgToSplash(2); - } - app->mActive = !app->mActive; - return 0; -} - -void CJavaCaptainAppUi::HandleCommandL(TInt aCommand) -{ - JELOG2(EJavaCaptain); - - switch (aCommand) - { - case EAknSoftkeyExit: - case EEikCmdExit: - Exit(); - break; - case ECaptainStart: - { - RProcess proc; - int st = proc.Create(KExecutableName, KExecutableName); - if (st == KErrNone) - { - proc.Resume(); - iAppView->setCaptainState(true); - } - proc.Close(); - } - break; - - case ECaptainStop: - { - CommsMessage message; - message.setModuleId(PLUGIN_ID_JAVACAPTAIN_CORE_C); - message.setMessageId(CORE_MSG_ID_STOP_JAVACAPTAIN); - CommsClientEndpoint comms; - comms.connect(IPC_ADDRESS_JAVA_CAPTAIN_C); - comms.send(message); - comms.disconnect(); - iAppView->setCaptainState(false); - } - break; - - case EThreadDump: - { - CommsMessage message; - message.setModuleId(PLUGIN_ID_JAVACAPTAIN_CORE_C); - message.setMessageId(CORE_MSG_ID_DO_THREAD_DUMP); - CommsClientEndpoint comms; - comms.connect(IPC_ADDRESS_JAVA_CAPTAIN_C); - comms.send(message); - comms.disconnect(); - } - break; - - case ETogglePrewarmEnable: - case ETogglePrewarmUiEnable: - case EDebugMode: - case ESecurityMode: - case ES60SecurityPolicy: - case EMSASecurityPolicy: - case EATTSecurityPolicy: - case ERedirectMode: - iAppView->handleStateChangeCmd(aCommand); - break; - - default: - Exit(); - break; - } -} - -CEikAppUi* CJavaCaptainEikDocument::CreateAppUiL() -{ - JELOG2(EJavaCaptain); - return(new(ELeave) CJavaCaptainAppUi); -} - -void CJavaCaptainEikDocument::ConstructL() -{ - JELOG2(EJavaCaptain); -} - -TUid CJavaCaptainApplication::AppDllUid() const -{ - JELOG2(EJavaCaptain); - return KUidJavaCaptain; -} - -CApaDocument* CJavaCaptainApplication::CreateDocumentL() -{ - JELOG2(EJavaCaptain); - CJavaCaptainEikDocument* document=new(ELeave) CJavaCaptainEikDocument(*this); - CleanupStack::PushL(document); - document->ConstructL(); - CleanupStack::Pop(); - return(document); -} - -#include - -LOCAL_C CApaApplication* NewApplication() -{ - JELOG2(EJavaCaptain); - return new CJavaCaptainApplication; -} - - -GLDEF_C TInt E32Main() -{ - JELOG2(EJavaCaptain); - return EikStart::RunApplication(NewApplication); -} - - -#include -#include -#include - -LogRedirector::LogRedirector() : mFd(-1) -{ - iJavaDiagnostic.reset(JavaDiagnostic::createInstance()); -} - -LogRedirector::~LogRedirector() -{ -} - -void LogRedirector::start() -{ - iJavaDiagnostic->setDiagnosticListener(*this); - mFd = open("c:\\data\\javaredirect.log", O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR); -} - -void LogRedirector::stop() -{ - iJavaDiagnostic->removeDiagnosticListener(); - close(mFd); - mFd = -1; -} - -void LogRedirector::systemOut(const TDesC8& aData) -{ - write(aData); -} - -void LogRedirector::systemErr(const TDesC8& aData) -{ - write(aData); -} - -void LogRedirector::log(const TDesC8& aData) -{ - write(aData); -} - -void LogRedirector::write(const TDesC8& aData) -{ - if (mFd > 0) - { - ::write(mFd, (const char*)aData.Ptr(), aData.Size()); - } -}; - - - -// End of File diff -r dc7c549001d5 -r 85266cc22c7f javatools/javacaptain_app/src.s60/javacap.h --- a/javatools/javacaptain_app/src.s60/javacap.h Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,132 +0,0 @@ -/* -* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: JavaCap -* -*/ - -#ifndef JAVACAP_H -#define JAVACAP_H - -#include -#include -#include -#include -#include -#include "javastorage.h" -#include "javadiagnostic.h" -using namespace java::debug; - -const TUid KUidJavaCaptain={ 0x20022D3C }; -class LogRedirector; - -class CJavaCaptainContainer : public CCoeControl -{ -public: - void ConstructL(const TRect& aRect); - ~CJavaCaptainContainer(); - static void ThreadMain(CJavaCaptainContainer*); - void updateStates(); - void setCaptainState(bool running); - void handleStateChangeCmd(int cmd); - -private: - void StartCaptain(); - void Draw(const TRect& aRect) const; - std::wstring GetSecurityWarningsMode(); - void SetSecurityWarningsMode(const std::wstring& aSecurityWarningsMode); - int GetSecurityPolicy(); - void SetSecurityPolicy(int); - void findColumn(const java::storage::JavaStorageApplicationEntry_t& aEntry, const std::wstring& aColName, std::wstring& aColValue); - - -private: - TBuf<20> mHeader; - TBuf<40> mCaptainState; - TBuf<40> mPrewarmState; - TBuf<40> mPrewarmUiState; - TBuf<40> mDebugState; - TBuf<40> mSecurityMode; - TBuf<40> mSecurityPolicy; - TBuf<40> mRedirectState; - - bool mCaptainRunning; - bool mPrewarmEnabled; - bool mPrewarmUiEnabled; - bool mDebugEnabled; - bool mUserSecurityModeEnabled; - int mSecurityPolicyId; - bool mRedirectEnabled; - - std::auto_ptr iStorage; - std::auto_ptr mRedirector; -}; - -class CJavaCaptainEikDocument : public CAknDocument -{ -public: - void ConstructL(); - CJavaCaptainEikDocument(CEikApplication& aApp): CAknDocument(aApp) { } - ~CJavaCaptainEikDocument() {} -private: - // from CAknDocument - CEikAppUi* CreateAppUiL(); -}; - -class CJavaCaptainAppUi : public CAknAppUi -{ -public: - void ConstructL(); - ~CJavaCaptainAppUi(); - -public: - static TInt tick(TAny* splash); - -private: - void HandleCommandL(TInt aCommand); - CJavaCaptainContainer* iAppView; - bool mActive; - CPeriodic* mPeriodic; -}; - -class CJavaCaptainApplication : public CAknApplication -{ -private: - // from CApaApplication - CApaDocument* CreateDocumentL(); - TUid AppDllUid() const; -}; - -class LogRedirector : public DiagnosticListener -{ -public: - LogRedirector(); - ~LogRedirector(); - - void start(); - void stop(); - - // DiagnosticListener methods - virtual void systemOut(const TDesC8& aData); - virtual void systemErr(const TDesC8& aData); - virtual void log(const TDesC8& aData); - -private: - void write(const TDesC8& aData); - std::auto_ptr iJavaDiagnostic; - - int mFd; -}; - -#endif // JAVACAP_H - diff -r dc7c549001d5 -r 85266cc22c7f javatools/javacaptain_app/src.s60/javacap.hrh --- a/javatools/javacaptain_app/src.s60/javacap.hrh Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -#ifndef _JAVACAP_HRH -#define _JAVACAP_HRH - -enum JavaCapCommandIds -{ - ECaptainCtl = 1, - EPrewarmCtl, - ECaptainStart, - ECaptainStop, - ETogglePrewarmEnable, - ETogglePrewarmUiEnable, - EThreadDump, - EDebugMode, - ESecurityMode, - ESecurityPolicy, - ES60SecurityPolicy, - EMSASecurityPolicy, - EATTSecurityPolicy, - ERedirectMode -}; -#endif diff -r dc7c549001d5 -r 85266cc22c7f javatools/javacaptain_app/src.s60/javacap.rss --- a/javatools/javacaptain_app/src.s60/javacap.rss Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,114 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -NAME JACA - -#include -#include -#include -#include - -#ifdef RD_SCALABLE_UI -#include -#endif - -#include "javacap.hrh" - -#include - -RESOURCE RSS_SIGNATURE { } - -RESOURCE TBUF { buf="javacap"; } - -RESOURCE EIK_APP_INFO - { - menubar = r_javacap_menubar; - cba=R_AVKON_SOFTKEYS_OPTIONS_EXIT; - } - -#ifdef RD_SCALABLE_UI -RESOURCE LOCALISABLE_APP_INFO r_localisable_app_info -{ - short_caption = "JavaCap"; - caption_and_icon = CAPTION_AND_ICON_INFO - { - caption = "JavaCap"; - }; -} -#endif - -//---------------------------------------------------- -// -// r_javacap_menubar -// -//---------------------------------------------------- -// -RESOURCE MENU_BAR r_javacap_menubar - { - titles = - { - MENU_TITLE { menu_pane = r_javacap_menu; txt = "Menu"; } - }; - } - -//---------------------------------------------------- -// -// r_askello_menu -// -//---------------------------------------------------- -// -RESOURCE MENU_PANE r_javacap_menu -{ - items = - { - MENU_ITEM { command = ECaptainCtl; txt = "JavaCaptain"; cascade = r_javacap_sub_menu;}, - MENU_ITEM { command = EPrewarmCtl; txt = "Prewarm"; cascade = r_javacap_prewarm_menu; }, - MENU_ITEM { command = EThreadDump; txt = "Thread dump";}, - MENU_ITEM { command = EDebugMode; txt = "Change debug mode";}, - MENU_ITEM { command = ESecurityMode; txt = "Change security warnings";}, - MENU_ITEM { command = ESecurityPolicy; txt = "SecurityPolicy"; cascade = r_javacap_secpolicy_sub_menu;}, - MENU_ITEM { command = ERedirectMode; txt = "Change redirect mode";} - }; -} - -RESOURCE MENU_PANE r_javacap_sub_menu -{ - items = - { - MENU_ITEM { command = ECaptainStart; txt = "Start Captain"; }, - MENU_ITEM { command = ECaptainStop; txt = "Stop Captain"; } - }; -} - -RESOURCE MENU_PANE r_javacap_secpolicy_sub_menu -{ - items = - { - MENU_ITEM { command = ES60SecurityPolicy; txt = "S60"; }, - MENU_ITEM { command = EMSASecurityPolicy; txt = "MSA"; }, - MENU_ITEM { command = EATTSecurityPolicy; txt = "AT&T"; } - }; -} - -RESOURCE MENU_PANE r_javacap_prewarm_menu -{ - items = - { - MENU_ITEM { command = ETogglePrewarmEnable; txt = "Prewarm (on/off)"; }, - MENU_ITEM { command = ETogglePrewarmUiEnable; txt = "Prewarm UI (on/off)"; } - }; -} - diff -r dc7c549001d5 -r 85266cc22c7f javatools/javacaptain_app/src.s60/javacap_reg.rss --- a/javatools/javacaptain_app/src.s60/javacap_reg.rss Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -#include - -UID2 KUidAppRegistrationResourceFile -UID3 0x20022D3C - -RESOURCE APP_REGISTRATION_INFO -{ - app_file = "JavaCap"; - embeddability = KAppNotEmbeddable; - newfile=KAppDoesNotSupportNewFile; -} - -// End of File diff -r dc7c549001d5 -r 85266cc22c7f javatools/javacontrolpanel/controlpanel/build/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javatools/javacontrolpanel/controlpanel/build/build.xml Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,30 @@ + + + + + + + + + + + diff -r dc7c549001d5 -r 85266cc22c7f javatools/javacontrolpanel/controlpanel/build/bwins/javacontrolpanelu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javatools/javacontrolpanel/controlpanel/build/bwins/javacontrolpanelu.def Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,3 @@ +EXPORTS + ?jni_lookup@@YAP6AXXZPBD@Z @ 1 NONAME ; void (*)(void) jni_lookup(char const *) + diff -r dc7c549001d5 -r 85266cc22c7f javatools/javacontrolpanel/controlpanel/build/eabi/javacontrolpanelu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javatools/javacontrolpanel/controlpanel/build/eabi/javacontrolpanelu.def Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,3 @@ +EXPORTS + _Z10jni_lookupPKc @ 1 NONAME + diff -r dc7c549001d5 -r 85266cc22c7f javatools/javacontrolpanel/controlpanel/build/javacontrolpanel.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javatools/javacontrolpanel/controlpanel/build/javacontrolpanel.pro Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,29 @@ +# +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +TARGET=javacontrolpanel +TEMPLATE=lib + +CONFIG += omj java stl +CONFIG -= qt + +LIBS += -ljavastorage + +symbian { + LIBS += -ljavadebugapi -lcentralrepository +} + +include(../../../../build/omj.pri) diff -r dc7c549001d5 -r 85266cc22c7f javatools/javacontrolpanel/controlpanel/javasrc/com/nokia/mj/impl/javacontrolpanel/JavaCaptain.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javatools/javacontrolpanel/controlpanel/javasrc/com/nokia/mj/impl/javacontrolpanel/JavaCaptain.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,206 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.mj.impl.javacontrolpanel; + +import com.nokia.mj.impl.utils.Logger; +import com.nokia.mj.impl.comms.*; +import com.nokia.mj.impl.comms.exception.*; + + +class JavaCaptain +{ + private final static int PLUGIN_ID_JAVACAPTAIN_CORE_C = 13; + private final static int CORE_MSG_ID_STOP_JAVACAPTAIN = 130; + private final static int CORE_MSG_ID_DO_THREAD_DUMP = 131; + private final static int CORE_MSG_ID_START_PREWARM = 132; + private final static int CORE_MSG_ID_STOP_PREWARM = 133; + private final static int CORE_MSG_ID_GET_PREWARM = 134; + + private final static int PLUGIN_ID_RTC_C = 1; + private final static int RTC_MSG_ID_SET_EXTRA_ARGUMENTS = 150; + private final static int RTC_MSG_ID_GET_EXTRA_ARGUMENTS = 151; + + private final static String JVM_DEBUG_ARGS = "-Xrunjdwp:server=y,address=localhost:8000"; + + public JavaCaptain() + { + } + + public boolean isRunning() + { + CommsEndpoint comms = new CommsEndpoint(); + boolean isRunning = false; + try + { + comms.connect(CommsEndpoint.JAVA_CAPTAIN); + comms.disconnect(); + isRunning = true; + } + catch (CommsException e) + { + e.printStackTrace(); + } + finally + { + comms.destroy(); + } + return isRunning; + } + + public void start() + { + _start(); + // wait until JC message loop is up + for(int i = 0; i < 5; i++) + { + try + { + Thread.sleep(30); + } + catch(InterruptedException e) {} + if (isRunning()) + { + break; + } + } + } + + public void stop() + { + CommsMessage message = createMessage(); + message.setMessageId(CORE_MSG_ID_STOP_JAVACAPTAIN); + // waits until JC message loop is down + sendReceive(message); + } + + public boolean isPrewarmEnabled() + { + CommsMessage message = createMessage(); + message.setMessageId(CORE_MSG_ID_GET_PREWARM); + CommsMessage reply = sendReceive(message); + int enabled = reply.readInt(); + return enabled == 1 ? true : false; + } + + public void enablePrewarm(boolean aEnable) + { + CommsMessage message = createMessage(); + if (aEnable) + { + message.setMessageId(CORE_MSG_ID_START_PREWARM); + } + else + { + message.setMessageId(CORE_MSG_ID_STOP_PREWARM); + } + send(message); + } + + public void doThreadDump() + { + CommsMessage message = createMessage(); + message.setMessageId(CORE_MSG_ID_DO_THREAD_DUMP); + send(message); + } + + public boolean isDebugEnabled() + { + CommsMessage message = createDebugMessage(); + message.setMessageId(RTC_MSG_ID_GET_EXTRA_ARGUMENTS); + CommsMessage receivedMessage = sendReceive(message); + String vmArgs = receivedMessage.readString(); + boolean enabled = false; + if(vmArgs.compareTo(JVM_DEBUG_ARGS) == 0) + { + enabled = true; + } + return enabled; + } + + public void enableDebug(boolean aEnable) + { + String vmArgs = ""; + if (aEnable) + { + vmArgs = JVM_DEBUG_ARGS; + } + + CommsMessage message = createDebugMessage(); + message.setMessageId(RTC_MSG_ID_SET_EXTRA_ARGUMENTS); + message.write(vmArgs); + message.write(""); // appArgs + send(message); + } + + private void send(CommsMessage aMessage) + { + CommsEndpoint comms = new CommsEndpoint(); + try + { + comms.connect(CommsEndpoint.JAVA_CAPTAIN); + comms.send(aMessage); + comms.disconnect(); + } + catch (CommsException e) + { + e.printStackTrace(); + } + finally + { + comms.destroy(); + } + } + + private CommsMessage sendReceive(CommsMessage aMessage) + { + CommsEndpoint comms = new CommsEndpoint(); + CommsMessage receivedMessage = new CommsMessage(); + try + { + comms.connect(CommsEndpoint.JAVA_CAPTAIN); + receivedMessage = comms.sendReceive(aMessage, CommsEndpoint.WAIT_FOR_EVER); + comms.disconnect(); + } + catch (CommsException e) + { + e.printStackTrace(); + } + finally + { + comms.destroy(); + } + return receivedMessage; + } + + private CommsMessage createMessage() + { + CommsMessage message = new CommsMessage(); + message.setModuleId(PLUGIN_ID_JAVACAPTAIN_CORE_C); + return message; + } + + private CommsMessage createDebugMessage() + { + CommsMessage message = new CommsMessage(); + message.setModuleId(PLUGIN_ID_RTC_C); + return message; + } + + private native void _start(); + +} diff -r dc7c549001d5 -r 85266cc22c7f javatools/javacontrolpanel/controlpanel/javasrc/com/nokia/mj/impl/javacontrolpanel/JavaControlPanel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javatools/javacontrolpanel/controlpanel/javasrc/com/nokia/mj/impl/javacontrolpanel/JavaControlPanel.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,87 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.mj.impl.javacontrolpanel; + +import com.nokia.mj.impl.utils.Logger; +import com.nokia.mj.impl.rt.support.JvmInternal; +import com.nokia.mj.impl.rt.support.ThreadEventListener; + +class JavaControlPanel +{ + /** + * JavaControlPanel main program. + * + * @param aArgs command line arguments + */ + public static void main(String[] aArgs) + { + Logger.ILOG(Logger.EUtils, "JavaControlPanel.main starts"); + int exitCode = 0; + + try + { + JvmInternal.setThreadEventListener(new ThreadEventListener() + { + public void threadStarting(Thread newThread, Thread parentThread) {} + public void threadDied(Thread thread) {} + public void uncaughtException(Thread thread, Throwable throwable) + { + String threadName = null; + if (thread != null) + { + threadName = thread.getName(); + } + Logger.ELOG(Logger.EUtils, "Unhandled exception in " + + threadName, throwable); + } + }); + exitCode = mainWithResult(aArgs); + } + catch (Throwable t) + { + Logger.ELOG(Logger.EUtils, "Unhandled exception in main", t); + exitCode = -1; + } + + Logger.ILOG(Logger.EUtils, "JavaControlPanel.main exits with code " + exitCode); + System.exit(exitCode); + } + + /** + * JavaControlPanel main program which returns error code indicating + * operation result. + * + * @param aArgs command line arguments + * @return error code indicating operation result + */ + public static int mainWithResult(String[] aArgs) + { + if (aArgs.length == 0) + { + JavaControlPanelUi ui = new JavaControlPanelUi(); + ui.show(); + } + else + { + Logger.WLOG(Logger.EUtils, "JavaControlPanel making thread dump and exiting"); + new JavaCaptain().doThreadDump(); + } + return 0; + } + +} diff -r dc7c549001d5 -r 85266cc22c7f javatools/javacontrolpanel/controlpanel/javasrc/com/nokia/mj/impl/javacontrolpanel/JavaControlPanelUi.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javatools/javacontrolpanel/controlpanel/javasrc/com/nokia/mj/impl/javacontrolpanel/JavaControlPanelUi.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,434 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.mj.impl.javacontrolpanel; + +import com.nokia.mj.impl.rt.support.Jvm; +import org.eclipse.swt.layout.*; +import org.eclipse.ercp.swt.mobile.*; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.*; +import org.eclipse.swt.widgets.*; +import org.eclipse.swt.graphics.*; + +import com.nokia.mj.impl.utils.Logger; + +class JavaControlPanelUi +{ + private JavaCaptain iCaptain; + private Redirector iRedirector; + private SecurityConfig iSecurity; + + private Shell iShell; + private Button iJavaCaptain; + private Button iPrewarm; + private Button iThreadDump; + private Button iJavaDebug; + private Button iRedirect; + private Combo iSecurityWarnings; + private Combo iSecurityPolicy; + + static + { + Jvm.loadSystemLibrary("javacontrolpanel"); + } + + public JavaControlPanelUi() + { + iCaptain = new JavaCaptain(); + iRedirector = new Redirector(); + iSecurity = new SecurityConfig(); + } + + public void show() + { + Display display = new Display(); + iShell = new Shell(display); + + createUi(); + iShell.pack(); + iShell.open(); + handleOrientationChange(); + + while (!iShell.isDisposed()) + { + if (!display.readAndDispatch()) + { + display.sleep(); + } + } + display.dispose(); + } + + private void exitEventLoop() + { + iRedirector.stop(); + iShell.dispose(); + } + + private void createUi() + { + try + { + setLayout(); + createJavaCaptainUi(); + createPrewarmUi(); + createThreadDumpUi(); + createJavaDebugUi(); + createSecurityWarningsUi(); + createSecurityPolicyUi(); + createRedirectLogsUi(); + createCommands(); + platformAdaptation(); + } + catch (Throwable e) + { + Logger.ELOG(Logger.EUtils, "createUi failed", e); + exitEventLoop(); + } + } + + private void setLayout() + { + iShell.setText("Java Control Panel"); + iShell.setLayout(new GridLayout(2, false)); + } + + private void createJavaCaptainUi() + { + Label label = new Label(iShell, SWT.NONE); + label.setText("Java Captain"); + label.setLayoutData(new GridData(SWT.CENTER)); + + iJavaCaptain = new Button(iShell, SWT.TOGGLE); + iJavaCaptain.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + iJavaCaptain.addSelectionListener(new SelectionListener() + { + public void widgetDefaultSelected(SelectionEvent aEvent) + { + widgetSelected(aEvent); + } + public void widgetSelected(SelectionEvent event) + { + javaCaptainPressed(); + } + }); + toggleJavaCaptain(iCaptain.isRunning()); + } + + private void createPrewarmUi() + { + Label label = new Label(iShell, SWT.NONE); + label.setText("Prewarm"); + label.setLayoutData(new GridData(SWT.CENTER)); + + iPrewarm = new Button(iShell, SWT.TOGGLE); + iPrewarm.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + iPrewarm.addSelectionListener(new SelectionListener() + { + public void widgetDefaultSelected(SelectionEvent aEvent) + { + widgetSelected(aEvent); + } + public void widgetSelected(SelectionEvent event) + { + prewarmPressed(); + } + }); + togglePrewarm(iCaptain.isPrewarmEnabled()); + } + + private void createThreadDumpUi() + { + Label label = new Label(iShell, SWT.NONE); + label.setText("Thread Dump"); + label.setLayoutData(new GridData(SWT.CENTER)); + + iThreadDump = new Button(iShell, SWT.PUSH); + iThreadDump.setText("Dump"); + iThreadDump.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + iThreadDump.addSelectionListener(new SelectionListener() + { + public void widgetDefaultSelected(SelectionEvent aEvent) + { + widgetSelected(aEvent); + } + public void widgetSelected(SelectionEvent event) + { + threadDumpPressed(); + } + }); + } + + private void createJavaDebugUi() + { + Label label = new Label(iShell, SWT.NONE); + label.setText("Java Debug"); + label.setLayoutData(new GridData(SWT.CENTER)); + + iJavaDebug = new Button(iShell, SWT.TOGGLE); + iJavaDebug.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + iJavaDebug.addSelectionListener(new SelectionListener() + { + public void widgetDefaultSelected(SelectionEvent aEvent) + { + widgetSelected(aEvent); + } + public void widgetSelected(SelectionEvent event) + { + javaDebugPressed(); + } + }); + toggleJavaDebug(iCaptain.isDebugEnabled()); + } + + private void createSecurityWarningsUi() + { + Label label = new Label(iShell, SWT.NONE); + label.setText("Security Warnings"); + label.setLayoutData(new GridData(SWT.CENTER)); + + iSecurityWarnings = new Combo(iShell, SWT.DROP_DOWN | SWT.READ_ONLY); + for(int i = 0; i < SecurityConfig.MODES.length; i++) + { + iSecurityWarnings.add(SecurityConfig.MODES[i]); + } + iSecurityWarnings.select(iSecurity.getWarningsMode()); + iSecurityWarnings.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + iSecurityWarnings.addSelectionListener(new SelectionListener() + { + public void widgetDefaultSelected(SelectionEvent aEvent) + { + widgetSelected(aEvent); + } + public void widgetSelected(SelectionEvent event) + { + securityWarningsSelected(); + } + }); + } + + private void createSecurityPolicyUi() + { + Label label = new Label(iShell, SWT.NONE); + label.setText("Security Policy"); + label.setLayoutData(new GridData(SWT.CENTER)); + + iSecurityPolicy = new Combo(iShell, SWT.DROP_DOWN | SWT.READ_ONLY); + for(int i = 0; i < SecurityConfig.POLICIES.length; i++) + { + iSecurityPolicy.add(SecurityConfig.POLICIES[i]); + } + iSecurityPolicy.select(iSecurity.getSecurityPolicy()); + iSecurityPolicy.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + iSecurityPolicy.addSelectionListener(new SelectionListener() + { + public void widgetDefaultSelected(SelectionEvent aEvent) + { + widgetSelected(aEvent); + } + public void widgetSelected(SelectionEvent event) + { + securityPolicySelected(); + } + }); + } + + private void createRedirectLogsUi() + { + Label label = new Label(iShell, SWT.NONE); + label.setText("Redirect Logs"); + label.setLayoutData(new GridData(SWT.CENTER)); + + iRedirect = new Button(iShell, SWT.TOGGLE); + iRedirect.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); + iRedirect.addSelectionListener(new SelectionListener() + { + public void widgetDefaultSelected(SelectionEvent aEvent) + { + widgetSelected(aEvent); + } + public void widgetSelected(SelectionEvent event) + { + redirectPressed(); + } + }); + toggleRedirect(iRedirector.isRedirecting()); + } + + private void createCommands() + { + Command exit = new Command(iShell, Command.EXIT, 0); + exit.setText("Exit"); + exit.addSelectionListener(new SelectionListener() + { + public void widgetDefaultSelected(SelectionEvent aEvent) + { + widgetSelected(aEvent); + } + public void widgetSelected(SelectionEvent aEvent) + { + exitEventLoop(); + } + }); + } + + private void platformAdaptation() + { + if (isLinux()) + { + configureUi(); + } + } + + private void configureUi() + { + // add second dummy command so that menu bar is visible + new Command(iShell, Command.GENERAL, 0).setText(""); + + // disable not supported services + iRedirect.setEnabled(false); + iSecurityPolicy.setEnabled(false); + iSecurityWarnings.setEnabled(false); + } + + private void handleOrientationChange() + { + iShell.addControlListener(new ControlListener() + { + private boolean handleEvent = false; + public void controlMoved(ControlEvent e) + { + } + public void controlResized(ControlEvent e) + { + // ignore first event that comes during startup + if (handleEvent) + { + // avoid flickering during orientation change + iShell.setVisible(false); + iShell.layout(); + iShell.setVisible(true); + } + handleEvent = true; + } + }); + } + + + private void javaCaptainPressed() + { + if (iJavaCaptain.getSelection()) + { + iCaptain.start(); + javaCaptainStarted(); + } + else + { + iCaptain.stop(); + } + toggleJavaCaptain(iJavaCaptain.getSelection()); + } + + private void toggleJavaCaptain(boolean aSelected) + { + iJavaCaptain.setText( aSelected ? "Running" : "Stopped"); + iJavaCaptain.setSelection(aSelected); + } + + private void prewarmPressed() + { + iCaptain.enablePrewarm(iPrewarm.getSelection()); + togglePrewarm(iPrewarm.getSelection()); + } + + private void togglePrewarm(boolean aSelected) + { + iPrewarm.setText( aSelected ? "Enabled" : "Disabled"); + iPrewarm.setSelection(aSelected); + } + + private void threadDumpPressed() + { + iCaptain.doThreadDump(); + } + + private void javaDebugPressed() + { + iCaptain.enableDebug(iJavaDebug.getSelection()); + toggleJavaDebug(iJavaDebug.getSelection()); + } + + private void toggleJavaDebug(boolean aSelected) + { + iJavaDebug.setText( aSelected ? "Enabled" : "Disabled"); + iJavaDebug.setSelection(aSelected); + } + + private void securityWarningsSelected() + { + iSecurity.setWarningsMode(iSecurityWarnings.getSelectionIndex()); + } + + private void securityPolicySelected() + { + iSecurity.setSecurityPolicy(iSecurityPolicy.getSelectionIndex()); + } + + private void redirectPressed() + { + if (iRedirect.getSelection()) + { + iRedirector.start(); + } + else + { + iRedirector.stop(); + } + toggleRedirect(iRedirect.getSelection()); + } + + private void toggleRedirect(boolean aSelected) + { + iRedirect.setText( aSelected ? "Yes" : "No"); + iRedirect.setSelection(aSelected); + } + + private void javaCaptainStarted() + { + // some JavaCaptain services return to default settings + // when JC is restarted so refresh states + togglePrewarm(iCaptain.isPrewarmEnabled()); + toggleJavaDebug(iCaptain.isDebugEnabled()); + } + + private boolean isLinux() + { + String platform = System.getProperty("os.name"); + if (platform != null && platform.equalsIgnoreCase("linux")) + { + return true; + } + return false; + } + +} + + + + + diff -r dc7c549001d5 -r 85266cc22c7f javatools/javacontrolpanel/controlpanel/javasrc/com/nokia/mj/impl/javacontrolpanel/Redirector.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javatools/javacontrolpanel/controlpanel/javasrc/com/nokia/mj/impl/javacontrolpanel/Redirector.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.mj.impl.javacontrolpanel; + +class Redirector +{ + private int iHandle; + + public Redirector() + { + } + + public void start() + { + stop(); + iHandle = _start(); + } + + public void stop() + { + if (isRedirecting()) + { + _stop(iHandle); + iHandle = 0; + } + } + + public boolean isRedirecting() + { + if (iHandle != 0) + { + return true; + } + else + { + return false; + } + } + + private native int _start(); + private native void _stop(int aHandle); + +} diff -r dc7c549001d5 -r 85266cc22c7f javatools/javacontrolpanel/controlpanel/javasrc/com/nokia/mj/impl/javacontrolpanel/SecurityConfig.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javatools/javacontrolpanel/controlpanel/javasrc/com/nokia/mj/impl/javacontrolpanel/SecurityConfig.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,79 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.mj.impl.javacontrolpanel; + +import com.nokia.mj.impl.utils.Logger; + + +class SecurityConfig +{ + private static final String SECURITY_WARNINGS_USER_DEFINED_MODE = "1"; + private static final String SECURITY_WARNINGS_DEFAULT_MODE = "2"; + + private static final int S60_SECURITY_POLICY_ID = 1; + private static final int MSA_SECURITY_POLICY_ID = 2; + private static final int ATT_SECURITY_POLICY_ID = 3; + + public static final String MODES[] = { "Default", "User"}; + public static final String POLICIES[] = { "S60", "MSA", "AT&T"}; + + public SecurityConfig() + { + } + + public int getSecurityPolicy() + { + int index = _getSecurityPolicy() - 1; + return index; + } + + public void setSecurityPolicy(int aPolicyIndex) + { + int id = aPolicyIndex + 1; + _setSecurityPolicy(id); + } + + public int getWarningsMode() + { + String mode = _getSecurityWarningsMode(); + int index = 0; + if (mode.compareTo(SECURITY_WARNINGS_USER_DEFINED_MODE) == 0 ) + { + index = 1; + } + return index; + } + + public void setWarningsMode(int aModeIndex) + { + if (aModeIndex == 0) + { + _setSecurityWarningsMode(SECURITY_WARNINGS_DEFAULT_MODE); + } + else + { + _setSecurityWarningsMode(SECURITY_WARNINGS_USER_DEFINED_MODE); + } + } + + private native String _getSecurityWarningsMode(); + private native void _setSecurityWarningsMode(String aMode); + private native int _getSecurityPolicy(); + private native void _setSecurityPolicy(int aPolicyId); + +} diff -r dc7c549001d5 -r 85266cc22c7f javatools/javacontrolpanel/controlpanel/javasrc/com/nokia/mj/impl/rt/javacontrolpanel/ApplicationInfoImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javatools/javacontrolpanel/controlpanel/javasrc/com/nokia/mj/impl/rt/javacontrolpanel/ApplicationInfoImpl.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,112 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.mj.impl.rt.javacontrolpanel; + +import com.nokia.mj.impl.rt.support.ApplicationInfo; +import com.nokia.mj.impl.utils.Uid; + +/** + * @author Nokia Corporation + * @version 1.0 + */ + +public class ApplicationInfoImpl extends ApplicationInfo +{ + private String iProtectionDomain = null; + + /** + */ + public String getRuntimeType() + { + // See runtime types defined in ApplicationInfo class. + return "JavaControlPanel"; + } + + /** + */ + public String getProtectionDomain() + { + return MANUFACTURER_DOMAIN; + } + + /** + */ + public Uid getUid() + { + return Uid.createUid("[2002FF61]"); + } + + /** + */ + public Uid getSuiteUid() + { + throw new RuntimeException + ("Get suite uid is not applicable for JavaControlPanel"); + } + + /** + */ + public String getSuiteName() + { + return getName(); + } + + /** + */ + public String getName() + { + return "JavaControlPanel"; + } + + /** + */ + public String getVendor() + { + return "Nokia"; + } + + /** + */ + public String getVersion() + { + return "1.0.0"; + } + + /** + */ + public String getRootPath() + { + throw new RuntimeException + ("getRootPath is not applicable for JavaControlPanel"); + } + + /** + */ + public String getMainClass() + { + throw new RuntimeException + ("Get main class is not applicable for JavaControlPanel"); + } + + /** + */ + public String getAttribute(String key) + { + return null; + } +} diff -r dc7c549001d5 -r 85266cc22c7f javatools/javacontrolpanel/controlpanel/javasrc/com/nokia/mj/impl/rt/javacontrolpanel/ApplicationUtilsImpl.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javatools/javacontrolpanel/controlpanel/javasrc/com/nokia/mj/impl/rt/javacontrolpanel/ApplicationUtilsImpl.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package com.nokia.mj.impl.rt.javacontrolpanel; + +import com.nokia.mj.impl.rt.support.ApplicationInfo; +import com.nokia.mj.impl.rt.support.ApplicationUtils; +import com.nokia.mj.impl.utils.Uid; + +import java.security.Permission; +import java.security.AccessControlException; + +/** + * @author Nokia Corporation + * @version 1.0 + */ +public class ApplicationUtilsImpl extends ApplicationUtils +{ + public static void doShutdownImpl() + { + // Send shutdown notification to all registered listeners. + ((ApplicationUtilsImpl)sInstance).doShutdown(); + } + + + public void notifyExitCmd() + { + } + + public void checkPermission(Permission aPermission) + throws AccessControlException, NullPointerException + { + checkPermission(null, aPermission); + } + + public void checkPermission(Uid aAppUid, Permission aPermission) + throws AccessControlException, NullPointerException + { + return; + } +} diff -r dc7c549001d5 -r 85266cc22c7f javatools/javacontrolpanel/controlpanel/src.s60/logredirector.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javatools/javacontrolpanel/controlpanel/src.s60/logredirector.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include +#include +#include +#include "logredirector.h" + +LogRedirector::LogRedirector() : mFd(-1) +{ + iJavaDiagnostic.reset(JavaDiagnostic::createInstance()); +} + +LogRedirector::~LogRedirector() +{ +} + +void LogRedirector::start() +{ + iJavaDiagnostic->setDiagnosticListener(*this); + mFd = open("c:\\data\\javaredirect.log", O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR); +} + +void LogRedirector::stop() +{ + iJavaDiagnostic->removeDiagnosticListener(); + close(mFd); + mFd = -1; +} + +void LogRedirector::systemOut(const TDesC8& aData) +{ + write(aData); +} + +void LogRedirector::systemErr(const TDesC8& aData) +{ + write(aData); +} + +void LogRedirector::log(const TDesC8& aData) +{ + write(aData); +} + +void LogRedirector::write(const TDesC8& aData) +{ + if (mFd > 0) + { + ::write(mFd, (const char*)aData.Ptr(), aData.Size()); + } +}; + diff -r dc7c549001d5 -r 85266cc22c7f javatools/javacontrolpanel/controlpanel/src.s60/logredirector.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javatools/javacontrolpanel/controlpanel/src.s60/logredirector.h Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,46 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef LOGREDIRECTOR_H +#define LOGREDIRECTOR_H + +#include +#include "javadiagnostic.h" +using namespace java::debug; + +class LogRedirector : public DiagnosticListener +{ +public: + LogRedirector(); + ~LogRedirector(); + + void start(); + void stop(); + + // DiagnosticListener methods + virtual void systemOut(const TDesC8& aData); + virtual void systemErr(const TDesC8& aData); + virtual void log(const TDesC8& aData); + +private: + void write(const TDesC8& aData); + std::auto_ptr iJavaDiagnostic; + int mFd; +}; + +#endif // LOGREDIRECTOR_H + diff -r dc7c549001d5 -r 85266cc22c7f javatools/javacontrolpanel/controlpanel/src.s60/security.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javatools/javacontrolpanel/controlpanel/src.s60/security.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,220 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include +#include + +#include "security.h" +#include "logger.h" +#include "javastoragenames.h" +#include "securitystoragedatadefs.h" + +using namespace java::storage; +using namespace std; + +_LIT(KS60SecurityPolicy, "s60"); +_LIT(KMSASecurityPolicy, "msa"); +_LIT(KATTSecurityPolicy, "att"); +// Java Security Policy Central Repository UID +static const TUid KCRUidJavaSecurity = { 0x2001B289 }; +// IDs for security folder and file keys +static const TUint32 KPolicy = 0x03; +static const TUint32 KSecurityWarnings = 0x04; + +const int S60_SECURITY_POLICY_ID = 1; +const int MSA_SECURITY_POLICY_ID = 2; +const int ATT_SECURITY_POLICY_ID = 3; + + +Security::Security() +{ + try + { + iStorage.reset(JavaStorage::createInstance()); + iStorage->open(); + } + catch (JavaStorageException& e) + { + ELOG1(EUtils, "open storage connection failed, %s", e.toString().c_str()); + } +} + +Security::~Security() +{ +} + +std::wstring Security::getSecurityWarningsMode() +{ + try + { + JavaStorageApplicationEntry_t query; + JavaStorageApplicationList_t queryResult; + JavaStorageEntry attr; + attr.setEntry(ID, L""); + query.insert(attr); + attr.setEntry(SECURITY_WARNINGS, L""); + query.insert(attr); + iStorage->search(MIDP_PACKAGE_TABLE, query, queryResult); + JavaStorageApplicationList_t::const_iterator iterator; + JavaStorageApplicationList_t domainQueryResult; + for (iterator = queryResult.begin(); iterator != queryResult.end(); iterator++) + { + std::wstring securityWarnings = L""; + JavaStorageApplicationEntry_t entry = (*iterator); + findColumn(entry, SECURITY_WARNINGS, securityWarnings); + if (securityWarnings == SECURITY_WARNINGS_USER_DEFINED_MODE) + { + // make them all USER + setSecurityWarningsMode(SECURITY_WARNINGS_USER_DEFINED_MODE); + return SECURITY_WARNINGS_USER_DEFINED_MODE; + } + } + } + catch (JavaStorageException& aJse) + { + } + // one more check: central repository + std::wstring securityWarningsMode = SECURITY_WARNINGS_DEFAULT_MODE; + TRAP_IGNORE + ( + CRepository* repository = CRepository::NewLC(KCRUidJavaSecurity); + TInt warningsMode; + User::LeaveIfError(repository->Get(KSecurityWarnings, warningsMode)); + switch (warningsMode) + { + case 1: + securityWarningsMode = SECURITY_WARNINGS_USER_DEFINED_MODE; + break; + case 2: + securityWarningsMode = SECURITY_WARNINGS_DEFAULT_MODE; + break; + } + CleanupStack::PopAndDestroy(repository); + ); + return securityWarningsMode; +} + +void Security::setSecurityWarningsMode(const std::wstring& aSecurityWarningsMode) +{ + try + { + JavaStorageApplicationEntry_t query; + JavaStorageApplicationList_t queryResult; + JavaStorageEntry attr; + attr.setEntry(ID, L""); + query.insert(attr); + iStorage->search(MIDP_PACKAGE_TABLE, query, queryResult); + JavaStorageApplicationList_t::const_iterator iterator; + JavaStorageApplicationList_t domainQueryResult; + for (iterator = queryResult.begin(); iterator != queryResult.end(); iterator++) + { + std::wstring uid = L""; + JavaStorageApplicationEntry_t entry = (*iterator); + findColumn(entry, ID, uid); + JavaStorageApplicationEntry_t oldEntry; + JavaStorageEntry oldAttr; + oldAttr.setEntry(ID, uid); + oldEntry.insert(oldAttr); + attr.setEntry(SECURITY_WARNINGS, aSecurityWarningsMode); + entry.clear(); + entry.insert(attr); + iStorage->update(MIDP_PACKAGE_TABLE, entry, oldEntry); + } + } + catch (JavaStorageException& aJse) + { + } + // set the cenRep key as well + TRAP_IGNORE + ( + CRepository* repository = CRepository::NewLC(KCRUidJavaSecurity); + if (aSecurityWarningsMode == SECURITY_WARNINGS_USER_DEFINED_MODE) + { + repository->Set(KSecurityWarnings, 1); + } + else + { + repository->Set(KSecurityWarnings, 2); + } + CleanupStack::PopAndDestroy(repository); + ); +} + +void Security::findColumn(const JavaStorageApplicationEntry_t& aEntry, + const wstring& aColName, wstring& aColValue) +{ + JavaStorageEntry findPattern; + findPattern.setEntry(aColName, L""); + JavaStorageApplicationEntry_t::const_iterator findIterator = + aEntry.find(findPattern); + if (findIterator != aEntry.end()) + { + aColValue = findIterator->entryValue(); + } +} + +int Security::getSecurityPolicy() +{ + int securityPolicyId = S60_SECURITY_POLICY_ID; + TRAP_IGNORE + ( + CRepository* repository = CRepository::NewLC(KCRUidJavaSecurity); + HBufC* buf = HBufC::NewLC(NCentralRepositoryConstants::KMaxUnicodeStringLength); + TPtr policy(buf->Des()); + User::LeaveIfError(repository->Get(KPolicy, policy)); + if (policy.Compare(KS60SecurityPolicy) == 0) + { + securityPolicyId = S60_SECURITY_POLICY_ID; + } + else if (policy.Compare(KMSASecurityPolicy) == 0) + { + securityPolicyId = MSA_SECURITY_POLICY_ID; + } + else if (policy.Compare(KATTSecurityPolicy) == 0) + { + securityPolicyId = ATT_SECURITY_POLICY_ID; + } + CleanupStack::PopAndDestroy(buf); + CleanupStack::PopAndDestroy(repository); + ); + return securityPolicyId; + +} + +void Security::setSecurityPolicy(int aSecurityPolicyId) +{ + TRAP_IGNORE + ( + CRepository* repository = CRepository::NewLC(KCRUidJavaSecurity); + switch (aSecurityPolicyId) + { + case S60_SECURITY_POLICY_ID: + User::LeaveIfError(repository->Set(KPolicy, KS60SecurityPolicy)); + break; + case MSA_SECURITY_POLICY_ID: + User::LeaveIfError(repository->Set(KPolicy, KMSASecurityPolicy)); + break; + case ATT_SECURITY_POLICY_ID: + User::LeaveIfError(repository->Set(KPolicy, KATTSecurityPolicy)); + break; + } + CleanupStack::PopAndDestroy(repository); + ); +} + + diff -r dc7c549001d5 -r 85266cc22c7f javatools/javacontrolpanel/controlpanel/src.s60/security.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javatools/javacontrolpanel/controlpanel/src.s60/security.h Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef SECURITY_H +#define SECURITY_H + +#include +#include +#include "javastorage.h" + +class Security +{ +public: + Security(); + ~Security(); + + std::wstring getSecurityWarningsMode(); + void setSecurityWarningsMode(const std::wstring& aMode); + int getSecurityPolicy(); + void setSecurityPolicy(int aPolicyId); + +private: + void findColumn(const java::storage::JavaStorageApplicationEntry_t& aEntry, + const std::wstring& aColName, std::wstring& aColValue); + + std::auto_ptr iStorage; +}; + +#endif // SECURITY_H diff -r dc7c549001d5 -r 85266cc22c7f javatools/javacontrolpanel/controlpanel/src/javacaptain.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javatools/javacontrolpanel/controlpanel/src/javacaptain.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: JavaCaptain +* +*/ + + +#include "com_nokia_mj_impl_javacontrolpanel_JavaCaptain.h" + +#ifdef __SYMBIAN32__ +#include +#else +#include +#endif + +#include +#include "logger.h" + +/* + * Class: com_nokia_mj_impl_javacontrolpanel_JavaCaptain + * Method: _start + * Signature: ()V + */ +JNIEXPORT void JNICALL Java_com_nokia_mj_impl_javacontrolpanel_JavaCaptain__1start + (JNIEnv *, jobject) +{ + int rc = 0; + int pid = 0; + char* av[2]; + int index = 0; + av[index++] = "javacaptain"; + av[index] = NULL; + +#ifdef __SYMBIAN32__ + rc = posix_spawn(&pid, "javacaptain", NULL, NULL, av, NULL); +#else + if (!(pid = fork())) + { + rc = execvp("javacaptain", av); + if (rc == -1) + { + rc = errno; + } + } +#endif // __SYMBIAN32__ + + if (rc) + { + ELOG3(EUtils,"%s failed, %s - errno=%d", __PRETTY_FUNCTION__, strerror(rc), rc); + } + +} + diff -r dc7c549001d5 -r 85266cc22c7f javatools/javacontrolpanel/controlpanel/src/redirector.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javatools/javacontrolpanel/controlpanel/src/redirector.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,55 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#include "com_nokia_mj_impl_javacontrolpanel_Redirector.h" +#include "logger.h" +#ifdef __SYMBIAN32__ +#include "logredirector.h" +#endif + +/* + * Class: com_nokia_mj_impl_javacontrolpanel_Redirector + * Method: _start + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_javacontrolpanel_Redirector__1start + (JNIEnv *, jobject) +{ +#ifdef __SYMBIAN32__ + LogRedirector* redirector = new LogRedirector(); + redirector->start(); + return (jint)redirector; +#else + return 0; +#endif +} + +/* + * Class: com_nokia_mj_impl_javacontrolpanel_Redirector + * Method: _stop + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_com_nokia_mj_impl_javacontrolpanel_Redirector__1stop + (JNIEnv *, jobject, jint aHandle) +{ +#ifdef __SYMBIAN32__ + LogRedirector* redirector = reinterpret_cast(aHandle); + redirector->stop(); + delete redirector; +#endif +} diff -r dc7c549001d5 -r 85266cc22c7f javatools/javacontrolpanel/controlpanel/src/securityconfig.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javatools/javacontrolpanel/controlpanel/src/securityconfig.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,87 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include +#include "com_nokia_mj_impl_javacontrolpanel_SecurityConfig.h" +#include "javajniutils.h" + +#ifdef __SYMBIAN32__ +#include "security.h" +#endif + +/* + * Class: com_nokia_mj_impl_javacontrolpanel_SecurityConfig + * Method: _getSecurityWarningsMode + * Signature: ()Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_com_nokia_mj_impl_javacontrolpanel_SecurityConfig__1getSecurityWarningsMode + (JNIEnv* aEnv, jobject) +{ +#ifdef __SYMBIAN32__ + Security security; + std::wstring mode = security.getSecurityWarningsMode(); + return java::util::JniUtils::wstringToJstring(aEnv, mode); +#else + return java::util::JniUtils::wstringToJstring(aEnv, L"2");; +#endif +} + +/* + * Class: com_nokia_mj_impl_javacontrolpanel_SecurityConfig + * Method: _setSecurityWarningsMode + * Signature: (Ljava/lang/String;)V + */ +JNIEXPORT void JNICALL Java_com_nokia_mj_impl_javacontrolpanel_SecurityConfig__1setSecurityWarningsMode + (JNIEnv* aEnv, jobject, jstring aMode) +{ +#ifdef __SYMBIAN32__ + Security security; + std::wstring mode = java::util::JniUtils::jstringToWstring(aEnv, aMode); + security.setSecurityWarningsMode(mode); +#endif +} + +/* + * Class: com_nokia_mj_impl_javacontrolpanel_SecurityConfig + * Method: _getSecurityPolicy + * Signature: ()I + */ +JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_javacontrolpanel_SecurityConfig__1getSecurityPolicy + (JNIEnv *, jobject) +{ +#ifdef __SYMBIAN32__ + Security security; + return security.getSecurityPolicy(); +#else + return 1; +#endif +} + +/* + * Class: com_nokia_mj_impl_javacontrolpanel_SecurityConfig + * Method: _setSecurityPolicy + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_com_nokia_mj_impl_javacontrolpanel_SecurityConfig__1setSecurityPolicy + (JNIEnv *, jobject, jint aPolicyId) +{ +#ifdef __SYMBIAN32__ + Security security; + security.setSecurityPolicy(aPolicyId); +#endif +} + diff -r dc7c549001d5 -r 85266cc22c7f javatools/javacontrolpanel/starter/build/javacontrolpanel.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javatools/javacontrolpanel/starter/build/javacontrolpanel.pro Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,39 @@ +# +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +TEMPLATE=app +TARGET=javacontrolpanel +CONFIG += omj no_icon stl +CONFIG -= qt + +INCLUDEPATH += ../../../../javaruntimes/inc +LIBS += -ljavacomms -ljavaruntimestarterutils + +symbian { + TARGET.EPOCHEAPSIZE = 0x020000 0x800000 + TARGET.EPOCSTACKSIZE = 0x14000 + TARGET.UID2 = 0x20004c45 + TARGET.UID3 = 0x2002FF61 + TARGET.SID = 0x2002FF61 + + TARGET.CAPABILITY = AllFiles WriteDeviceData PowerMgmt NetworkControl + + MMP_RULES += "START RESOURCE ../data/javacontrolpanel_reg.rss" + MMP_RULES += "TARGETPATH /private/10003a3f/apps" + MMP_RULES += "END" +} + +include(../../../../build/omj.pri) diff -r dc7c549001d5 -r 85266cc22c7f javatools/javacontrolpanel/starter/data/javacontrolpanel_reg.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javatools/javacontrolpanel/starter/data/javacontrolpanel_reg.rss Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,31 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: javacontrolpanel_reg.rss +* +*/ + + +#include + +UID2 KUidAppRegistrationResourceFile +UID3 0x2002FF61 + +RESOURCE APP_REGISTRATION_INFO +{ + app_file = "JavaControlPanel"; + embeddability = KAppEmbeddable; + newfile = KAppDoesNotSupportNewFile; +} + +// End of File diff -r dc7c549001d5 -r 85266cc22c7f javatools/javacontrolpanel/starter/src/main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javatools/javacontrolpanel/starter/src/main.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Main program for the Java Manager process +* +*/ + +#include +#include + +#include "logger.h" +#include "exceptionbase.h" +#include "runtimeexception.h" +#include "javacommonutils.h" +#include "runtimestarterutils.h" +#include "jvmstarter.h" + +using namespace java::runtime; +using namespace java::util; + +int startJvm(int argc, char *argv[]); +const wchar_t* const JavaControlPanel_MAIN_CLASS = L"com.nokia.mj.impl.javacontrolpanel.JavaControlPanel"; + +int main(int argc, char *argv[]) +{ + LOG(EUtils, EInfo, "JavaControlPanel main()"); + int result = -1; + try + { + result = startJvm(argc, argv); + } + catch (RuntimeException& e) + { + ELOG1(EUtils, "JavaControlPanel main() RuntimeException caught: %s ", + e.toString().c_str()); + } + + catch (ExceptionBase& e) + { + ELOG1(EUtils, "JavaControlPanel main() ExceptionBase caught: %s ", + e.toString().c_str()); + } + + catch (std::exception& e) + { + ELOG1(EUtils, "JavaControlPanel main() Exception %s caught", e.what()); + } + + LOG1(EUtils, EInfo, "JavaControlPanel EXIT = %d", result); + return result; +} + +int startJvm(int argc, char *argv[]) +{ + JELOG2(EUtils); + + // Create instance of RuntimeStarterUtils for thread supervisioning. + std::auto_ptr starterUtils(new RuntimeStarterUtils()); + starterUtils->startThreadSupervisor(); + + // Create starter for starting the JVM + std::auto_ptr + jvm(JvmStarter::getJvmStarterInstance(JvmStarter::CLDC, + L"JavaControlPanel")); + + // Set the debugging features available provided by the captain. + // starterUtils->enableDevelopmentFeatures(*jvm.get()); + // jvm->enableThreadDumping(); + + jvm->appendSystemProperty(L"-Dcom.nokia.rt.port=javacontrolpanel"); + jvm->setMainClass(JavaControlPanel_MAIN_CLASS); + + for (int i = 1; i < argc; ++i) + { + jvm->appendApplicationArgument( + JavaCommonUtils::utf8ToWstring(argv[i])); + } + + // Start the JVM. + return jvm->startJvm(); +} diff -r dc7c549001d5 -r 85266cc22c7f javatools/javatools.pro --- a/javatools/javatools.pro Thu May 27 12:49:31 2010 +0300 +++ b/javatools/javatools.pro Fri Jun 11 13:33:44 2010 +0300 @@ -16,7 +16,8 @@ TEMPLATE = subdirs SUBDIRS += tckrunner/starter/build/tckrunner.pro SUBDIRS += tckrunner/runner/build/tckrunner.pro +SUBDIRS += javacontrolpanel/starter/build/javacontrolpanel.pro +SUBDIRS += javacontrolpanel/controlpanel/build/javacontrolpanel.pro SUBDIRS += javasecuritycustomization/build/javasecuritycustomization.pro -BLD_INF_RULES.prj_extensions += "$${LITERAL_HASH}include \"javacaptain_app/build/bld.inf\"" BLD_INF_RULES.prj_extensions += "$${LITERAL_HASH}include \"testcerts/bld.inf\"" BLD_INF_RULES.prj_extensions += "prj_extensions" diff -r dc7c549001d5 -r 85266cc22c7f javatools/subsystem.mk --- a/javatools/subsystem.mk Thu May 27 12:49:31 2010 +0300 +++ b/javatools/subsystem.mk Fri Jun 11 13:33:44 2010 +0300 @@ -19,7 +19,9 @@ # Common COMPONENTS = \ tckrunner/starter/build \ - tckrunner/runner/build + tckrunner/runner/build \ + javacontrolpanel/starter/build \ + javacontrolpanel/controlpanel/build \ # Platform specific ifeq ($(BUILDENV),symbian) @@ -43,7 +45,6 @@ endif NONQTSUBSYSTEMS += \ - javacaptain_app/build \ testcerts endif diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/build/build.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/build/build.pro Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,19 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: Generated file - do not edit manually +# +TEMPLATE = subdirs +SUBDIRS += eswtqt/eswtqt.pro +SUBDIRS += eswtqtwebkit/eswtqtwebkit.pro +BLD_INF_RULES.prj_extensions += "prj_extensions" diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/build/build.xml --- a/javauis/eswt_qt/build/build.xml Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ - - - - - - Builds eSWT on Qt - - - - - - - - - - - - - - - - - - org.eclipse.ercp.swt.defaultOrientation=system - - - - - - - - diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/build/bwins/eswtqtu.def --- a/javauis/eswt_qt/build/bwins/eswtqtu.def Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -EXPORTS - ?jni_lookup@@YAP6AXXZPBD@Z @ 1 NONAME ; void (*)(void) jni_lookup(char const *) - diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/build/eabi/eswtqtu.def --- a/javauis/eswt_qt/build/eabi/eswtqtu.def Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -EXPORTS - _Z10jni_lookupPKc @ 1 NONAME diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/build/eswtqt.pro --- a/javauis/eswt_qt/build/eswtqt.pro Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -# -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -# All rights reserved. -# This component and the accompanying materials are made available -# under the terms of the License "Eclipse Public License v1.0" -# which accompanies this distribution, and is available -# at the URL "http://www.eclipse.org/legal/epl-v10.html". -# -# Initial Contributors: -# Nokia Corporation - initial contribution. -# -# Contributors: -# -# Description: -# - -TEMPLATE=lib -TARGET=eswtqt -CONFIG += omj java - -QT += core \ - gui \ - webkit - -symbian: LIBS += -lhal -lws32 -lgdi - -include(../org.eclipse.swt/Eclipse_SWT_PI/qt/library/eswt_widgets.pri) -include(../org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/graphics.pri) - -include(../../../build/omj.pri) diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/build/eswtqt/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/build/eswtqt/build.xml Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,63 @@ + + + + + + Builds eSWT on Qt + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.eclipse.ercp.swt.defaultOrientation=system + + + + + + + + + + + + diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/build/eswtqt/bwins/eswtqtu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/build/eswtqt/bwins/eswtqtu.def Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,6 @@ +EXPORTS + ?jni_lookup@@YAP6AXXZPBD@Z @ 1 NONAME ; void (*)(void) jni_lookup(char const *) + ?Throw@JniUtils@eSWT@Java@@QAEXPAUJNIEnv_@@ABH@Z @ 2 NONAME ; void Java::eSWT::JniUtils::Throw(struct JNIEnv_ *, int const &) + ?JavaStringToQString@JniUtils@eSWT@Java@@QAE?AVQString@@PAUJNIEnv_@@PAV_jstring@@@Z @ 3 NONAME ; class QString Java::eSWT::JniUtils::JavaStringToQString(struct JNIEnv_ *, class _jstring *) + ?QStringToJavaString@JniUtils@eSWT@Java@@QAEPAV_jstring@@PAUJNIEnv_@@ABVQString@@@Z @ 4 NONAME ; class _jstring * Java::eSWT::JniUtils::QStringToJavaString(struct JNIEnv_ *, class QString const &) + diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/build/eswtqt/eabi/eswtqtu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/build/eswtqt/eabi/eswtqtu.def Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,6 @@ +EXPORTS + _Z10jni_lookupPKc @ 1 NONAME + _ZN4Java4eSWT8JniUtils19JavaStringToQStringEP7JNIEnv_P8_jstring @ 2 NONAME + _ZN4Java4eSWT8JniUtils19QStringToJavaStringEP7JNIEnv_RK7QString @ 3 NONAME + _ZN4Java4eSWT8JniUtils5ThrowEP7JNIEnv_RKi @ 4 NONAME + diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/build/eswtqt/eswtqt.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/build/eswtqt/eswtqt.pro Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,24 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +TEMPLATE=lib +TARGET=eswtqt +CONFIG += omj java + +include(../../org.eclipse.swt/Eclipse_SWT_PI/qt/library/eswt_widgets.pri) +include(../../org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/graphics.pri) + +include(../../../../build/omj.pri) diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/build/eswtqtwebkit/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/build/eswtqtwebkit/build.xml Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,38 @@ + + + + + + Builds the Webkit JNI library for eSWT on Qt + + + + + + + + + + + + + + + + diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/build/eswtqtwebkit/bwins/eswtqtwebkitu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/build/eswtqtwebkit/bwins/eswtqtwebkitu.def Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,3 @@ +EXPORTS + ?jni_lookup@@YAP6AXXZPBD@Z @ 1 NONAME ; void (*)(void) jni_lookup(char const *) + diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/build/eswtqtwebkit/eabi/eswtqtwebkitu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/build/eswtqtwebkit/eabi/eswtqtwebkitu.def Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,3 @@ +EXPORTS + _Z10jni_lookupPKc @ 1 NONAME + diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/build/eswtqtwebkit/eswtqtwebkit.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/build/eswtqtwebkit/eswtqtwebkit.pro Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,22 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +TEMPLATE=lib +TARGET=eswtqtwebkit +CONFIG += omj java + +include(../../org.eclipse.swt/Eclipse_SWT_PI/qt/library/webkit/eswt_webkit.pri) +include(../../../../build/omj.pri) diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/build/subsystem.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/build/subsystem.mk Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,26 @@ +# +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +include $(JAVA_SRC_ROOT)/build/Makefile.defs + +COMPONENTS = \ + eswtqt \ + eswtqtwebkit + +include ${JAVA_SRC_ROOT}/build/Makefile.subsystem + +# Build order dependency +eswtqtwebkit: eswtqt diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/com.nokia.swt.extensions/extensions/org/eclipse/swt/internal/extension/ApplicationUI.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/com.nokia.swt.extensions/extensions/org/eclipse/swt/internal/extension/ApplicationUI.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia Corporation - initial implementation + *******************************************************************************/ + +package org.eclipse.swt.internal.extension; + +import org.eclipse.swt.internal.qt.UIThreadManager; + +/** + * A class that provides services for transferring the control over the + * execution of the UI thread to the application, and services for obtaining + * notifications of the state of the UI until the UI thread will return back to the + * caller. + * + * @see InternalUI + * @see ApplicationUIListener + */ +public final class ApplicationUI { + + /** + * Hand over the execution of the UI thread to the application. If the + * application has not yet requested the UI thread then it will be waiting + * until that happens. The waiting can be aborted by calling + * abortWait(). + * + * The control of the thread will be passed to the application. If the + * application allows the UI thread to return then this method will also + * return. + * + * After calling this method and before the method has returned the state of + * the UI thread can be tracked by setting an + * ApplicationUIListener. + */ + public static void run() { + UIThreadManager.runApplicationUI(); + } + + /** + * Aborts waiting the application to request the UI thread. This waiting can + * occur after run() has been called if the application has not + * yet at that point requested the UI thread and thus has not provided the + * Runnable to call back. Aborting the waiting will cause the UI thread to + * return from run(). If the application already obtained the + * control of the UI thread then this method does nothing. + */ + public static void abortWait() { + UIThreadManager.abortWait(); + } + + /** + * Sets the listener that will be notified of the state of the UI during its + * life-cycle under the application's control. + * + * @param listener The listener, or null to disable the notifications + */ + public static void setListener(ApplicationUIListener listener) { + final ApplicationUIListener applicationUIListener = listener; + org.eclipse.swt.internal.qt.ApplicationUIListener internalListener; + if(listener != null) { + internalListener = new org.eclipse.swt.internal.qt.ApplicationUIListener() { + public void applicationUIThreadRequest() { + applicationUIListener.applicationUIThreadRequest(); + } + }; + } else { + internalListener = null; + } + UIThreadManager.setApplicationUIListener(internalListener); + } +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/com.nokia.swt.extensions/extensions/org/eclipse/swt/internal/extension/ApplicationUIListener.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/com.nokia.swt.extensions/extensions/org/eclipse/swt/internal/extension/ApplicationUIListener.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia Corporation - initial implementation + *******************************************************************************/ +package org.eclipse.swt.internal.extension; + +/** + * An interface for providing notifications about the state of the UI during the + * life-time of the application. + */ +public interface ApplicationUIListener { + /** + * Called when the application requests the UI thread to call back a + * Runnable that the application provided. + */ + public void applicationUIThreadRequest(); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/com.nokia.swt.extensions/extensions/org/eclipse/swt/internal/extension/InternalUI.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/com.nokia.swt.extensions/extensions/org/eclipse/swt/internal/extension/InternalUI.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia Corporation - initial implementation + *******************************************************************************/ + +package org.eclipse.swt.internal.extension; + +import org.eclipse.swt.internal.qt.midp.UIThreadLauncher; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Internal_PackageSupport; + +/** + * A class that encapsulates services that enable the use of eSWT UI before the + * application has initialized its UI. This is achieved by utilizing an + * 'internal' instance of the Display class. I.e. an instance that is not + * revealed to the application but is only used internally within the API + * implementation. + * + * The same rules apply to the internal Display instance that apply to the + * Display normally. When the Display is created then the creating thread + * becomes the UI thread of the process. The application needs to be able to + * obtain control of the UI thread. The services for interfacing with the + * application are provided by the class ApplicationUI. + * + * @see ApplicationUI + */ +public final class InternalUI { + /** + * Obtains the platform specific UI thread where SWT UI APIs can be accessed + * in and calls the provided Runnable in it. This method instantly returns + * leaving two threads running concurrently: the calling thread and the UI + * thread. Only one UI thread can exist per process and this method can be + * called only once to obtain it. Subsequent calls will result in an + * exception being thrown. This method can be called by any thread. + * + * @param runnable + * A Runnable to call back in the UI thread. + * @exception RuntimeException + * If starting the UI thread fails + */ + public static void startInUIThread(Runnable runnable) { + if(!UIThreadLauncher.startInUIThread(runnable)) { + throw new RuntimeException("Failed to start the UI thread"); + } + } + + /** + * Creates the internal instance of Display. Must be called only once. + * + * This means that the native resources required by the eSWT UI will be + * initialized and a Display instance is returned that can be used to access + * them normally via the public eSWT APIs. + * + * @return The internal Display instance + * @see getInternalDisplayInstance + */ + public synchronized static Display createInternalDisplay() { + if(getInternalDisplayInstance() != null) { + throw new RuntimeException("Display already exists"); + } + return Internal_PackageSupport.internalInstance(); + } + + /** + * Returns the internal Display instance or null if it doesn't exist. + * @return The internal Display instance or null + */ + public synchronized static Display getInternalDisplayInstance() { + return Internal_PackageSupport.getInternalDisplayInstance(); + } +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/com.nokia.swt.extensions/extensions/org/eclipse/swt/internal/extension/NetworkStatus.java --- a/javauis/eswt_qt/com.nokia.swt.extensions/extensions/org/eclipse/swt/internal/extension/NetworkStatus.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/com.nokia.swt.extensions/extensions/org/eclipse/swt/internal/extension/NetworkStatus.java Fri Jun 11 13:33:44 2010 +0300 @@ -109,19 +109,27 @@ handleCallInformationChanged(); } + private static Display getDisplay() { + Display display; + display = Internal_PackageSupport.getInternalDisplayInstance(); + if(display == null) { + display = Internal_PackageSupport.getDisplayInstance(); + } + return display; + } + private static void addDisposeListener() { - Display display = Internal_PackageSupport.getDisplayInstance(); disposeListener = new Listener() { public void handleEvent(Event event) { destroy(); } }; - display.addListener(SWT.Dispose, disposeListener); + getDisplay().addListener(SWT.Dispose, disposeListener); } private static void removeDisposeListener() { if(disposeListener != null) { - Display display = Internal_PackageSupport.getDisplayInstance(); + Display display = getDisplay(); if(display != null && !display.isDisposed()) { display.removeListener(SWT.Dispose, disposeListener); disposeListener = null; @@ -130,7 +138,7 @@ } private static void checkThread() { - Display display = Internal_PackageSupport.getDisplayInstance(); + Display display = getDisplay(); if(display == null) { throw new RuntimeException("Display doesn't exist"); } @@ -207,7 +215,7 @@ if(notifiedStates != 0) { final NetworkStatusListener asyncNofityListener = listener; final int asyncNotifyStates = notifiedStates; - Internal_PackageSupport.getDisplayInstance().asyncExec(new Runnable() { + getDisplay().asyncExec(new Runnable() { public void run() { asyncNofityListener.stateChanged(asyncNotifyStates); } @@ -255,7 +263,7 @@ private void hookEvents() { // Packet data connections if(qNetworkConfigurationManagerHandle != 0) { - int signalProxy = org.eclipse.swt.internal.qt.OS.SignalHandler_new( + int signalProxy = org.eclipse.swt.internal.qt.OS.SignalForwarder_new( qNetworkConfigurationManagerHandle, this, OS.QSIGNAL_NETWORKCONFIGURATIONCHANGED); org.eclipse.swt.internal.qt.OS.QObject_connectOrThrow( qNetworkConfigurationManagerHandle, @@ -276,7 +284,7 @@ // Voice calls if(xqCallInfoHandle != 0) { - int signalProxy = org.eclipse.swt.internal.qt.OS.SignalHandler_new( + int signalProxy = org.eclipse.swt.internal.qt.OS.SignalForwarder_new( xqCallInfoHandle, this, OS.QSIGNAL_CALLINFORMATIONCHANGED); org.eclipse.swt.internal.qt.OS.QObject_connectOrThrow( xqCallInfoHandle, diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/com.nokia.swt.extensions/midp/org/eclipse/ercp/swt/midp/UIThreadSupport.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/com.nokia.swt.extensions/midp/org/eclipse/ercp/swt/midp/UIThreadSupport.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,88 @@ +/******************************************************************************* + * Copyright (c) 2009, 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia Corporation - initial implementation + *******************************************************************************/ +package org.eclipse.ercp.swt.midp; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.internal.qt.UIThreadManager; + +/** + *

+ * To use eSWT API a MIDlet needs to dedicate a thread as the UI thread for + * running the event loop. This can't happen in the MIDlet.startApp() because + * it's required by the MIDP specification that the call to startApp() returns + * quickly. Additionally, many native UI toolkits have restrictions for the + * thread that can be used as the UI thread. Thus, a random Java thread can't be + * used either. + *

+ *

+ * This class provides means to obtain a thread that can be used as the UI + * thread on the platform. All MIDlets must use this class to obtain the UI + * thread. If a MIDlet uses some other thread as the UI thread then the behavior + * is undefined. + *

+ * + * @see MIDlet + * @see MIDlet#startApp + */ +public class UIThreadSupport { + +private static boolean started; + +/** + *

+ * Calls back the given Runnable in a thread that can be used as the UI thread. + * The method must not be called more than once as there might be only one + * thread in the process capable of being used as the UI thread. + *

+ * + * An example:
+ * ...
+ * class MyMIDlet extends javax.microedition.midlet.MIDlet {
+ *     ...
+ *     public void startApp() {
+ *         UIThreadSupport.startInUIThread(new Runnable() {
+ *             public void run() {
+ *                 Display display = new Display();
+ *                 ...
+ *             }
+ *          });
+ *     }
+ *     ...
+ * }
+ * 
+ * + * @param runnable The Runnable object to call back + * @exception SWTError
    + *
  • ERROR_NULL_ARGUMENT if the runnable is null
  • + * @exception SWTError
      + *
    • ERROR_NO_HANDLES if a handle could not be obtained for + * thread creation
    • + * @exception SWTError
        + *
      • ERROR_FAILED_EXEC if called more than once
      • + * @see MIDlet + * @see MIDlet#startApp + */ +public static void startInUIThread(Runnable runnable) { + if(runnable == null) { + SWT.error(SWT.ERROR_NULL_ARGUMENT); + } + synchronized(UIThreadSupport.class) { + if(started) { + SWT.error(SWT.ERROR_FAILED_EXEC); + } + started = true; + } + if(!UIThreadManager.startInUIThread(runnable)) { + SWT.error(SWT.ERROR_NO_HANDLES); + } +} + +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/com.nokia.swt.extensions/midp_common/org/eclipse/ercp/swt/midp/UIThreadSupport.java --- a/javauis/eswt_qt/com.nokia.swt.extensions/midp_common/org/eclipse/ercp/swt/midp/UIThreadSupport.java Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Nokia Corporation - initial implementation - *******************************************************************************/ -package org.eclipse.ercp.swt.midp; - -import org.eclipse.swt.SWT; - -/** - *

        - * To use eSWT API a MIDlet needs to dedicate a thread as the UI thread for - * running the event loop. This can't happen in the MIDlet.startApp() because - * it's required by the MIDP specification that the call to startApp() returns - * quickly. Additionally, many native UI toolkits have restrictions for the - * thread that can be used as the UI thread. Thus, a random Java thread can't be - * used either. - *

        - *

        - * This class provides means to obtain a thread that can be used as the UI - * thread on the platform. All MIDlets must use this class to obtain the UI - * thread. If a MIDlet uses some other thread as the UI thread then the behavior - * is undefined. - *

        - * - * @see MIDlet - * @see MIDlet#startApp - */ -public class UIThreadSupport { - -private static boolean started; - -/** - *

        - * Calls back the given Runnable in a thread that can be used as the UI thread. - * The method must not be called more than once as there might be only one - * thread in the process capable of being used as the UI thread. - *

        - * - * An example:
        - * ...
        - * class MyMIDlet extends javax.microedition.midlet.MIDlet {
        - *     ...
        - *     public void startApp() {
        - *         UIThreadSupport.startInUIThread(new Runnable() {
        - *             public void run() {
        - *                 Display display = new Display();
        - *                 ...
        - *             }
        - *          });
        - *     }
        - *     ...
        - * }
        - * 
        - * - * @param runnable The Runnable object to call back - * @exception SWTError
          - *
        • ERROR_NO_HANDLES if a handle could not be obtained for - * thread creation
        • - * @exception SWTError
            - *
          • ERROR_FAILED_EXEC if called more than once
          • - * @see MIDlet - * @see MIDlet#startApp - */ -public static void startInUIThread(Runnable runnable) { - synchronized(UIThreadSupport.class) { - if(started) { - SWT.error(SWT.ERROR_FAILED_EXEC); - } - started = true; - } - try { - new Thread(runnable).start(); - } catch(Exception e) { - SWT.error(SWT.ERROR_NO_HANDLES); - } -} - -} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/com.nokia.swt.extensions/midp_symbian/org/eclipse/ercp/swt/midp/UIThreadSupport.java --- a/javauis/eswt_qt/com.nokia.swt.extensions/midp_symbian/org/eclipse/ercp/swt/midp/UIThreadSupport.java Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,84 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Nokia Corporation - initial implementation - *******************************************************************************/ -package org.eclipse.ercp.swt.midp; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.internal.qt.s60.OS; - -/** - *

            - * To use eSWT API a MIDlet needs to dedicate a thread as the UI thread for - * running the event loop. This can't happen in the MIDlet.startApp() because - * it's required by the MIDP specification that the call to startApp() returns - * quickly. Additionally, many native UI toolkits have restrictions for the - * thread that can be used as the UI thread. Thus, a random Java thread can't be - * used either. - *

            - *

            - * This class provides means to obtain a thread that can be used as the UI - * thread on the platform. All MIDlets must use this class to obtain the UI - * thread. If a MIDlet uses some other thread as the UI thread then the behavior - * is undefined. - *

            - * - * @see MIDlet - * @see MIDlet#startApp - */ -public class UIThreadSupport { - -private static boolean started; - -/** - *

            - * Calls back the given Runnable in a thread that can be used as the UI thread. - * The method must not be called more than once as there might be only one - * thread in the process capable of being used as the UI thread. - *

            - * - * An example:
            - * ...
            - * class MyMIDlet extends javax.microedition.midlet.MIDlet {
            - *     ...
            - *     public void startApp() {
            - *         UIThreadSupport.startInUIThread(new Runnable() {
            - *             public void run() {
            - *                 Display display = new Display();
            - *                 ...
            - *             }
            - *          });
            - *     }
            - *     ...
            - * }
            - * 
            - * - * @param runnable The Runnable object to call back - * @exception SWTError
              - *
            • ERROR_NO_HANDLES if a handle could not be obtained for - * thread creation
            • - * @exception SWTError
                - *
              • ERROR_FAILED_EXEC if called more than once
              • - * @see MIDlet - * @see MIDlet#startApp - */ -public static void startInUIThread(Runnable runnable) { - synchronized(UIThreadSupport.class) { - if(started) { - SWT.error(SWT.ERROR_FAILED_EXEC); - } - started = true; - } - int status = OS.startUI(runnable); - if(status != 0) { - SWT.error(SWT.ERROR_NO_HANDLES); - } -} - -} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/eswtuitestutils/.classpath --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/eswtuitestutils/.classpath Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,7 @@ + + + + + + + diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/eswtuitestutils/.project --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/eswtuitestutils/.project Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,19 @@ + + + eswtuitestutils + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.pde.PluginNature + + + diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/eswtuitestutils/build/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/eswtuitestutils/build/build.xml Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,62 @@ + + + + + + Builds eswtuitestutils on Qt + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${component.dir}.odc${line.separator} + ${component.dir}.jar${line.separator} + + + diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/eswtuitestutils/build/bwins/eswtuitestutilsu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/eswtuitestutils/build/bwins/eswtuitestutilsu.def Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,3 @@ +EXPORTS + ?jni_lookup@@YAP6AXXZPBD@Z @ 1 NONAME ; void (*)(void) jni_lookup(char const *) + diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/eswtuitestutils/build/eabi/eswtuitestutilsu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/eswtuitestutils/build/eabi/eswtuitestutilsu.def Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,3 @@ +EXPORTS + _Z10jni_lookupPKc @ 1 NONAME + diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/eswtuitestutils/build/eswtuitestutils.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/eswtuitestutils/build/eswtuitestutils.pro Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,35 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of the License "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +TEMPLATE=lib +TARGET=eswtuitestutils +CONFIG += omj java + + +symbian { + + TARGET.UID3 = 0x2002E699 + + include(../src/eswtuitestutils.pri) + + LIBS += -llibc + LIBS += -leuser + LIBS += -llibstdcpp + LIBS += -ljavautils + LIBS += -leikcore +} + +include(../../../../build/omj.pri) \ No newline at end of file diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/eswtuitestutils/javasrc/com/nokia/mj/impl/uitestutils/ImageTestUtils.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/eswtuitestutils/javasrc/com/nokia/mj/impl/uitestutils/ImageTestUtils.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,639 @@ +package com.nokia.mj.impl.uitestutils; + +import org.eclipse.swt.internal.qt.graphics.Image; +import java.util.Arrays; + +/** + * Image utils for verifying image pixels against mask + * plus some other helpers for verifying image properties. + * + * NOTE. Currently only CGFX images are supported however eSWT images + * can be verified by using org.eclipse.swt.internal.qt.graphics.Image internal_getImage() + * to obtain wrapped CGFX image. + * + * Usage example + * + * create a mask from mask data and then mask by giving data and scanlenght. + * + * int[] maskData = { + * 0,0,0,0,0,0,0,0,0, + * 0,0,0,0,1,0,0,0,0, + * 0,0,0,0,1,0,0,0,0, + * 0,0,0,0,1,0,0,0,0, + * 0,0,0,0,1,0,0,0,0, + * 0,0,0,0,1,0,0,0,0, + * 0,0,0,0,1,0,0,0,0, + * 0,0,0,0,0,0,0,0,0 + * }; + * + * Mask mask = new Mask(maskData, 9); + * + * + * Then image pixels can be validated with ImageTestUtils. That is where there is 1 in mask it is + * compared against maskArgb and all where there is 0 in mask it is compared against bgArgb. + * + * ImageTestUtils.validatePixels(imageToValidate, mask, maskArgb, bgArgb); + * + * + * @author sampkaar + * + */ +public class ImageTestUtils { + + /** + * This pixel is rendering target image background color. + */ + public static final int IMAGE_BACKGROUND_COLOR = 0; + + /** + * This pixel is foreground color set to GC. + */ + public static final int GC_FOREGROUND_COLOR = 1; + + /** + * This pixel is either foreground or image background color. + * Used for example in drawRoundRect and drawEllipse tests. + */ + public static final int FOREGROUND_OR_IMAGE_BACKGROUND_COLOR = 2; + + /** + * This pixel is background color set to GC. + * Used for example in fillGradientRect test. + */ + public static final int GC_BACKGROUND_COLOR = 3; + + /** + * This pixel is neither foreground nor gc background color. + * Used for example in fillGradientRect test. + */ + public static final int NEITHER_FOREGROUND_NOR_GC_BACKGROUND_COLOR = 4; + + /** + * This pixel can be ignored. + * Used for example in fillGradientRect test. + */ + public static final int IGNORE_COLOR = 5; + + /** + * Validates image dimensions against reference width and height. + * Prints possible problems to System.out. + * + * @param img - The image to check + * @param refWidth - The reference width + * @param refHeight - The reference height + */ + public static final boolean validateImageDimensions(Image img, int refWidth, int refHeight) { + if ((refWidth != img.getWidth()) || (refHeight != img.getHeight())) { + System.out.println("Image size should be ("+refWidth+","+refHeight+"), "+ + "but is ("+img.getWidth()+","+img.getHeight()+")"); + return false; + } + return true; + } + + /** + * Validates image pixels which are outside specified rectangle ingoreRect against given reference color. + * + * @param ignoreRect The area that is to be ingnored + * @param img Image to validate + * @param argb The reference color + * @return true if all pixels outside ingoreRect have reference color orherwise false + */ + public static final boolean validatePixels(Rect ignoreRect, Image img, int argb) { + final int width = img.getWidth(); + final int height = img.getHeight(); + final int pixels = width * height; + final int scanlength = img.getWidth(); + + // data array for image data + int[] imageData = new int[pixels]; + + // get data for whole image + img.getRGB(imageData, 0, width, 0, 0, width, height); + + // calculate start index + int start = scanlength*ignoreRect.y(); + for(int y = 0; y> 24) & 0xff; + final int refRed = (argb >> 16) & 0xff; + final int refGreen = (argb >> 8) & 0xff; + final int refBlue = (argb) & 0xff; + + // data array for image data + int[] imageData = new int[pixels]; + + // get data for whole image + img.getRGB(imageData, 0, width, 0, 0, width, height); + + // check each pixel in image, break if pixel does not match + for(int i=0; i < pixels; i++) { + if (refAlpha != ((imageData[i] >> 24) & 0xff)) return false; + if (refRed != ((imageData[i] >> 16) & 0xff)) return false; + if (refGreen != ((imageData[i] >> 8 ) & 0xff)) return false; + if (refBlue != ( imageData[i] & 0xff)) return false; + } + return true; + } + + /** + * Validates that given pixels are equal to + * reference pixel color (argb) and background color in given rgb data + * + * @param rgbdata - The image data to be checked + * @param mask - the reference mask + * @param maskArgb - The reference color for pixels with value 1 in mask + * @param bgArgb - The reference color for pixels with value 0 in mask + * + */ + public static final boolean validatePixels(int[] rgbdata, Mask mask, int maskArgb, int bgArgb) { + return doCheckPixels(rgbdata, mask, maskArgb, bgArgb, 0, false); + } + + /** + * Validates that given pixels are equal to + * reference pixel color (argb) and background color in given rgb data + * + * @param rgbdata - The image data to be checked + * @param dataOffset The offset from beginning of rgbdata where image data starts + * @param dataLength The lenght of image data after offset + * @param mask - the reference mask + * @param maskArgb - The reference color for pixels with value 1 in mask + * @param bgArgb - The reference color for pixels with value 0 in mask + * + */ + public static final boolean validatePixels(int[] rgbdata, int dataOffset, int dataLength, Mask mask, int maskArgb, int bgArgb) { + + // create array for data + int[] data = new int[dataLength]; + + // copy from rgbdata to data + for(int i=dataOffset; i < rgbdata.length; i++) { + data[i-dataOffset] = rgbdata[i]; + } + + //System.out.println("\n mask size: " + mask.getData().length+", dataSize: " + rgbdata.length); + return doCheckPixels(data, mask, maskArgb, bgArgb, 0, false); + } + + /** + * Validates that given pixels are equal to + * reference pixel color (argb) and background color in image + * + * @param img - The image to check + * @param mask - the reference mask + * @param maskArgb - The reference color for pixels with value 1 in mask + * @param bgArgb - The reference color for pixels with value 0 in mask + * + */ + public static final boolean validatePixels(Image img, Mask mask, int maskArgb, int bgArgb) { + + // data array for image data + int[] imageData = new int[img.getWidth()*img.getHeight()]; + + // get data for whole image + img.getRGB(imageData, 0, img.getWidth(), 0, 0, img.getWidth(), img.getHeight()); + + // check pixels + return doCheckPixels(imageData, mask, maskArgb, bgArgb, 0, false); + } + + /** + * Validates that given pixels are equal to + * reference pixel color (argb) and background color in image + * + * @param img - The image to check + * @param mask - the reference mask + * @param maskArgb - The reference color for pixels with value 1 in mask + * @param bgArgb - The reference color for pixels with value 0 in mask + * @param ingoreAlpha If true alpha value is not validated + * @return true if mask and image match otherwise false + */ + public static final boolean validatePixels(Image img, Mask mask, int maskArgb, int bgArgb, boolean ignoreAlpha) { + + // data array for image data + int[] imageData = new int[img.getWidth()*img.getHeight()]; + + // get data for whole image + img.getRGB(imageData, 0, img.getWidth(), 0, 0, img.getWidth(), img.getHeight()); + + // check pixels + return doCheckPixels(imageData, mask, maskArgb, bgArgb, 0, ignoreAlpha); + } + + /** + * Validates that given pixels are equal to + * foreground color (argb), image background color and gc background color in image + * + * @param img - The image to check + * @param mask - the reference mask + * @param fgArgb - The reference color for pixels with value 1 GC_FOREGROUND_COLOR in mask + * @param gcBgArgb - The reference color for pixels with value 3 GC_BACKGROUND_COLOR in mask + * @param imgBgArgb - The reference color for pixels with value 0 IMAGE_BACKGROUND_COLOR in mask + * @param ingoreAlpha If true alpha value is not validated + * @return true if mask and image match otherwise false + */ + public static final boolean validatePixels(Image img, Mask mask, int fgArgb, int gcBgArgb, int imgBgArgb, boolean ignoreAlpha) { + + // data array for image data + int[] imageData = new int[img.getWidth()*img.getHeight()]; + + // get data for whole image + img.getRGB(imageData, 0, img.getWidth(), 0, 0, img.getWidth(), img.getHeight()); + + // check pixels + return doCheckPixels(imageData, mask, fgArgb, imgBgArgb, gcBgArgb, ignoreAlpha); + } + + /* + * method for checking pixels against mask + * The imageData and the data in mask must be same size. + */ + private static final boolean doCheckPixels(int[] imageData, Mask mask, int fgColorArgb, int imgBgColorArgb, int gcBgColorArgb, boolean ignoreAlpha ) { + + // get color components for GC foreground color + final int fgAlpha = (fgColorArgb >> 24) & 0xff; + final int fgRed = (fgColorArgb >> 16) & 0xff; + final int fgGreen = (fgColorArgb >> 8) & 0xff; + final int fgBlue = (fgColorArgb) & 0xff; + + // get color components for image background color + final int imgBgAlpha = (imgBgColorArgb >> 24) & 0xff; + final int imgBgRed = (imgBgColorArgb >> 16) & 0xff; + final int imgBgGreen = (imgBgColorArgb >> 8) & 0xff; + final int imgBgBlue = (imgBgColorArgb) & 0xff; + + // get color components for GC background color + int gcBgAlpha = 0; + int gcBgRed = 0; + int gcBgGreen = 0; + int gcBgBlue = 0; + if (gcBgColorArgb != 0){ // GC Background color is defined + gcBgAlpha = (gcBgColorArgb >> 24) & 0xff; + gcBgRed = (gcBgColorArgb >> 16) & 0xff; + gcBgGreen = (gcBgColorArgb >> 8) & 0xff; + gcBgBlue = (gcBgColorArgb) & 0xff; + } + + // get mask data + int[] maskdata = mask.getData(); + + // verify background & pixels + for(int i=0; i < imageData.length; i++) { + + // if mask pixel is GC_FOREGROUND_COLOR (1), check against fgArgb + if(maskdata[i] == GC_FOREGROUND_COLOR) { + if (!ignoreAlpha) { + if (fgAlpha != ((imageData[i] >> 24) & 0xff)) return false; + } + if (fgRed != ((imageData[i] >> 16) & 0xff)) return false; + if (fgGreen != ((imageData[i] >> 8 ) & 0xff)) return false; + if (fgBlue != ( imageData[i] & 0xff)) return false; + } + // if mask pixel is FOREGROUND_OR_IMAGE_BACKGROUND_COLOR (2), this pixel is either + // foreground or image background color. + // Used for example in drawRoundRect and drawEllipse tests. + else if(maskdata[i] == FOREGROUND_OR_IMAGE_BACKGROUND_COLOR) { + if (!ignoreAlpha) { + if (fgAlpha != ((imageData[i] >> 24) & 0xff) && + imgBgAlpha != ((imageData[i] >> 24) & 0xff)) return false; + } + if (fgRed != ((imageData[i] >> 16) & 0xff) && + imgBgRed != ((imageData[i] >> 16) & 0xff)) return false; + + if (fgGreen != ((imageData[i] >> 8 ) & 0xff) && + imgBgGreen != ((imageData[i] >> 8 ) & 0xff)) return false; + + if (fgBlue != ( imageData[i] & 0xff) && + imgBgBlue != ( imageData[i] & 0xff)) return false; + } + // if mask pixel is GC_BACKGROUND_COLOR (3), this pixel is background color set to GC. + // Used for example in fillGradientRect test. + else if(maskdata[i] == GC_BACKGROUND_COLOR) { + if (!ignoreAlpha) { + if (gcBgAlpha != ((imageData[i] >> 24) & 0xff)) return false; + } + if (gcBgRed != ((imageData[i] >> 16) & 0xff)) return false; + if (gcBgGreen != ((imageData[i] >> 8 ) & 0xff)) return false; + if (gcBgBlue != ( imageData[i] & 0xff)) return false; + } + // if mask pixel is NEITHER_FOREGROUND_NOR_GC_BACKGROUND_COLOR (4), this pixel is neither + // foreground nor gc background color. + // Used for example in fillGradientRect test. + else if(maskdata[i] == NEITHER_FOREGROUND_NOR_GC_BACKGROUND_COLOR) { + if (!ignoreAlpha) { + if (fgAlpha != gcBgAlpha){ + if (fgAlpha == ((imageData[i] >> 24) & 0xff) || + gcBgAlpha == ((imageData[i] >> 24) & 0xff)) return false; + } + } + + if (fgRed != gcBgRed){ + if (fgRed == ((imageData[i] >> 16) & 0xff) || + gcBgRed == ((imageData[i] >> 16) & 0xff)) return false; + } + if (fgGreen != gcBgGreen){ + if (fgGreen == ((imageData[i] >> 8 ) & 0xff) || + gcBgGreen == ((imageData[i] >> 8 ) & 0xff)) return false; + } + if (fgBlue != gcBgBlue){ + if (fgBlue == ( imageData[i] & 0xff) || + gcBgBlue == ( imageData[i] & 0xff)) return false; + } + } + else if(maskdata[i] == IGNORE_COLOR) { + // skip the pixel + } + // if mask pixel is IMAGE_BACKGROUND_COLOR (1), check against imgBg + else if(maskdata[i] == IMAGE_BACKGROUND_COLOR) { + if (!ignoreAlpha) { + if (imgBgAlpha != ((imageData[i] >> 24) & 0xff)) return false; + } + if (imgBgRed != ((imageData[i] >> 16) & 0xff)) return false; + if (imgBgGreen != ((imageData[i] >> 8 ) & 0xff)) return false; + if (imgBgBlue != ( imageData[i] & 0xff)) return false; + } + // If mask pixel is something else that's error + else { + return false; + } + } + return true; + } + + /** + * prints black & white image to console. + * black is printed as 1 and white as 0. + */ + public static final void print(Image img) { + + final int width = img.getWidth(); + final int height = img.getHeight(); + final int pixels = img.getWidth() * img.getHeight(); + + // data array for image data + int[] imageData = new int[pixels]; + + // get data for whole image + img.getRGB(imageData, 0, width, 0, 0, width, height); + + String output = "Image("+img.getWidth()+","+img.getHeight()+"):\n"; + int y = 0; + for(int i = 0; i < imageData.length; i++) { + + int a = ((imageData[i] >> 24) & 0xff); + int r = ((imageData[i] >> 16) & 0xff); + int b = ((imageData[i] >> 8 ) & 0xff); + int g = ( imageData[i] & 0xff); + + if (a == 255 && r == 0 && g == 0 && b == 0) { + output += "1,"; + } else if (a == 255 && r == 255 && g == 255 && b == 255) { + output += "0,"; + } + else { + output += "("+a+","+r+","+b+","+g+")"; + } + + if(i==((y*width) + (width-1))) { + output += "\n"; + y++; + } + } + System.out.println(output); + } + + public static final void print(int[] array, int scanlength) { + final int width = scanlength; + String output = ""; + + int y = 0; + for(int i = 0; i < array.length; i++) { + + int a = ((array[i] >> 24) & 0xff); + int r = ((array[i] >> 16) & 0xff); + int b = ((array[i] >> 8 ) & 0xff); + int g = ( array[i] & 0xff); + + if (a == 255 && r == 0 && g == 0 && b == 0) { + output += "1,"; + } else if (a == 255 && r == 255 && g == 255 && b == 255) { + output += "0,"; + } + else { + output += "x,"; + } + + if(i==((y*width) + (width-1))) { + output += "\n"; + y++; + } + } + System.out.println(output); + } + + private int getIndexForPoint(int scanlength, int x, int y) { + return y*scanlength+x; + } + + +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/eswtuitestutils/javasrc/com/nokia/mj/impl/uitestutils/Key.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/eswtuitestutils/javasrc/com/nokia/mj/impl/uitestutils/Key.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,532 @@ +//Key.java +// +// +// + +package com.nokia.mj.impl.uitestutils; + +public class Key { + + // + // NON UNICODE LOGICAL KEY CODES + // pass them to class c.tor to generate symbian symbian scan and key codes + // (for unicode keys use unicode char) + // + + //non unicode MIDP key codes + public static final int UpArrow = -1; + public static final int DownArrow = -2; + public static final int LeftArrow = -3; + public static final int RightArrow = -4; + public static final int Clear = -5; // Clear key + public static final int Select = -6; // Selection key + public static final int Edit = -7; // Edit Key + public static final int Send = -8; // Send Key + public static final int CBA1 = -9; // Left CBA + public static final int CBA2 = -10; // Right CBA + public static final int End = -11; // End key + public static final int Applications = -12; // Applications key + public static final int Voice = -13; // Voice key + + //non unicode non MIDP key codes + public static final int Power = -14; + public static final int Backspace = -15; + public static final int GripOpen = -16; + public static final int GripClose = -17; + public static final int Camera = -18; + public static final int VolumeUp = -19; + public static final int VolumeDown = -20; + public static final int PlayPause = -21; //Media key + public static final int Stop = -22; //Media Key + public static final int NextFF = -23; //Media key + public static final int PreviousRew = -24; //Media key + + public static final int PageUp = -25; + public static final int PageDown = -26; + public static final int HomeKey = -27; + public static final int EndKey = -28; + // Activate key represents a key that will cause a "default selection" of an item. On Linux + // this is Enter, but on S60 it may be the same key as Select. + public static final int Activate = -29; + public static final int InsertKey = -30; + public static final int ReturnKey = -31; + public static final int DeleteKey = -32; + public static final int Escape = -33; + + + + // + // SYMBIAN SCAN CODES - copied from e32keys.h + // + + public static final int EStdKeyNull=0x00; /**< No key present. */ + public static final int EStdKeyBackspace=0x01; /**< Scan code for Backspace key.*/ + public static final int EStdKeyTab=0x02; /**< Scan code for Tab key. */ + public static final int EStdKeyEnter=0x03; /**< Scan code for Enter key.*/ + public static final int EStdKeyEscape=0x04; /**< Scan code for Escape (Esc) key.*/ + public static final int EStdKeySpace=0x05; /**< Scan code for Space key.*/ + public static final int EStdKeyPrintScreen=0x06; /**< Scan code for Print Screen key.*/ + public static final int EStdKeyPause=0x07; /**< Scan code for Pause key.*/ + public static final int EStdKeyHome=0x08; /**< Scan code for Home key.*/ + public static final int EStdKeyEnd=0x09; /**< Scan code for End key.*/ + public static final int EStdKeyPageUp=0x0a; /**< Scan code for Page Up key.*/ + public static final int EStdKeyPageDown=0x0b; /**< Scan code for Page Down key.*/ + public static final int EStdKeyInsert=0x0c; /**< Scan code for Insert key.*/ + public static final int EStdKeyDelete=0x0d; /**< Scan code for Delete (Del) key.*/ + public static final int EStdKeyLeftArrow=0x0e; /**< Scan code for Left arrow key.*/ + public static final int EStdKeyRightArrow=0x0f; /**< Scan code for Right arrow key.*/ + public static final int EStdKeyUpArrow=0x10; /**< Scan code for Up arrow key.*/ + public static final int EStdKeyDownArrow=0x11; /**< Scan code for Down arrow key.*/ + public static final int EStdKeyLeftShift=0x12; /**< Scan code for left Shift key.*/ + public static final int EStdKeyRightShift=0x13; /**< Scan code for right Shift key.*/ + public static final int EStdKeyLeftAlt=0x14; /**< Scan code for left Alt key.*/ + public static final int EStdKeyRightAlt=0x15; /**< Scan code for right Alt key.*/ + public static final int EStdKeyLeftCtrl=0x16; /**< Scan code for left Control (Ctrl) key.*/ + public static final int EStdKeyRightCtrl=0x17; /**< Scan code for right Control (Ctrl) key.*/ + public static final int EStdKeyLeftFunc=0x18; /**< Scan code for left Fn key.*/ + public static final int EStdKeyRightFunc=0x19; /**< Scan code for right Fn key.*/ + public static final int EStdKeyCapsLock=0x1a; /**< Scan code for Caps lock key.*/ + public static final int EStdKeyNumLock=0x1b; /**< Scan code for Num lock key.*/ + public static final int EStdKeyScrollLock=0x1c; /**< Scan code for Scroll lock key.*/ + public static final int EStdKeyF1=0x60; /**< Scan code for function key F1.*/ + public static final int EStdKeyF2=0x61; /**< Scan code for function key F2.*/ + public static final int EStdKeyF3=0x62; /**< Scan code for function key F3.*/ + public static final int EStdKeyF4=0x63; /**< Scan code for function key F4.*/ + public static final int EStdKeyF5=0x64; /**< Scan code for function key F5*/ + public static final int EStdKeyF6=0x65; /**< Scan code for function key F6*/ + public static final int EStdKeyF7=0x66; /**< Scan code for function key F7*/ + public static final int EStdKeyF8=0x67; /**< Scan code for function key F8*/ + public static final int EStdKeyF9=0x68; /**< Scan code for function key F9*/ + public static final int EStdKeyF10=0x69; /**< Scan code for function key F10*/ + public static final int EStdKeyF11=0x6a; /**< Scan code for function key F11*/ + public static final int EStdKeyF12=0x6b; /**< Scan code for function key F12*/ + public static final int EStdKeyF13=0x6c; /**< Scan code for function key F13*/ + public static final int EStdKeyF14=0x6d; /**< Scan code for function key F14*/ + public static final int EStdKeyF15=0x6e; /**< Scan code for function key F15*/ + public static final int EStdKeyF16=0x6f; /**< Scan code for function key F16*/ + public static final int EStdKeyF17=0x70; /**< Scan code for function key F17*/ + public static final int EStdKeyF18=0x71; /**< Scan code for function key F18*/ + public static final int EStdKeyF19=0x72; /**< Scan code for function key F19*/ + public static final int EStdKeyF20=0x73; /**< Scan code for function key F20*/ + public static final int EStdKeyF21=0x74; /**< Scan code for function key F21*/ + public static final int EStdKeyF22=0x75; /**< Scan code for function key F22.*/ + public static final int EStdKeyF23=0x76; /**< Scan code for function key F23.*/ + public static final int EStdKeyF24=0x77; /**< Scan code for function key F24.*/ + public static final int EStdKeyXXX=0x78; /**< Scan code for the key to the left of the 1 key on a standard keyboard.*/ + public static final int EStdKeyComma=0x79; /**< Scan code for Comma (,) key.*/ + public static final int EStdKeyFullStop=0x7a; /**< Scan code for Full stop (.) key.*/ + public static final int EStdKeyForwardSlash=0x7b; /**< Scan code for Forward slash (/) key.*/ + public static final int EStdKeyBackSlash=0x7c; /**< Scan code for Back slash (\) key.*/ + public static final int EStdKeySemiColon=0x7d; /**< Scan code for Semi colon (;) key.*/ + public static final int EStdKeySingleQuote=0x7e; /**< Scan code for Single quote (') key.*/ + public static final int EStdKeyHash=0x7f; /**< Scan code for Hash key (#) key.*/ + public static final int EStdKeySquareBracketLeft=0x80; /**< Scan code for left Square bracket ([) key.*/ + public static final int EStdKeySquareBracketRight=0x81; /**< Scan code for right Square bracket (]) key.*/ + public static final int EStdKeyMinus=0x82; /**< Scan code for Minus key (-) key.*/ + public static final int EStdKeyEquals=0x83; /**< Scan code for Equals key (=) key.*/ + public static final int EStdKeyNkpForwardSlash=0x84; /**< Scan code for forward slash (/) key on the Numeric keypad.*/ + public static final int EStdKeyNkpAsterisk=0x85; /**< Scan code for Asterisk (*) key on the Numeric keypad.*/ + public static final int EStdKeyNkpMinus=0x86; /**< Scan code for Minus (-) key on the Numeric keypad.*/ + public static final int EStdKeyNkpPlus=0x87; /**< Scan code for Plus (+) key on the Numeric keypad.*/ + public static final int EStdKeyNkpEnter=0x88; /**< Scan code for Enter key on the Numeric keypad.*/ + public static final int EStdKeyNkp1=0x89; /**< Scan code for the 1 key on the Numeric keypad.*/ + public static final int EStdKeyNkp2=0x8a; /**< Scan code for the 2 key on the Numeric keypad.*/ + public static final int EStdKeyNkp3=0x8b; /**< Scan code for the 3 key on the Numeric keypad.*/ + public static final int EStdKeyNkp4=0x8c; /**< Scan code for the 4 key on the Numeric keypad.*/ + public static final int EStdKeyNkp5=0x8d; /**< Scan code for the 5 key on the Numeric keypad.*/ + public static final int EStdKeyNkp6=0x8e; /**< Scan code for the 6 key on the Numeric keypad.*/ + public static final int EStdKeyNkp7=0x8f; /**< Scan code for the 7 key on the Numeric keypad.*/ + public static final int EStdKeyNkp8=0x90; /**< Scan code for the 8 key on the Numeric keypad.*/ + public static final int EStdKeyNkp9=0x91; /**< Scan code for the 9 key on the Numeric keypad.*/ + public static final int EStdKeyNkp0=0x92; /**< Scan code for the 0 key on the Numeric keypad.*/ + public static final int EStdKeyNkpFullStop=0x93; /**< Scan code for Full stop (.) key on the Numeric keypad.*/ + public static final int EStdKeyMenu=0x94; /**< Scan code for Menu key.*/ + public static final int EStdKeyBacklightOn=0x95; /**< Scan code for Backlight on key.*/ + public static final int EStdKeyBacklightOff=0x96; /**< Scan code for Backlight off key.*/ + public static final int EStdKeyBacklightToggle=0x97; /**< Scan code for Backlight toggle key.*/ + public static final int EStdKeyIncContrast=0x98; /**< Scan code for Increase contrast key.*/ + public static final int EStdKeyDecContrast=0x99; /**< Scan code for Decrease contrast key.*/ + public static final int EStdKeySliderDown=0x9a; /**< Scan code for Slider down key.*/ + public static final int EStdKeySliderUp=0x9b; /**< Scan code for Slider up key.*/ + public static final int EStdKeyDictaphonePlay=0x9c; /**< Scan code for Dictaphone play key.*/ + public static final int EStdKeyDictaphoneStop=0x9d; /**< Scan code for Dictaphone stop key.*/ + public static final int EStdKeyDictaphoneRecord=0x9e; /**< Scan code for Dictaphone record key.*/ + public static final int EStdKeyHelp=0x9f; /**< Scan code for Help key */ + public static final int EStdKeyOff=0xa0; /**< Scan code for Off key.*/ + public static final int EStdKeyDial=0xa1; /**< Scan code for Dial key.*/ + public static final int EStdKeyIncVolume=0xa2; /**< Scan code for Increase volume key.*/ + public static final int EStdKeyDecVolume=0xa3; /**< Scan code for Decrease volume key.*/ + public static final int EStdKeyDevice0=0xa4; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ + public static final int EStdKeyDevice1=0xa5; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ + public static final int EStdKeyDevice2=0xa6; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ + public static final int EStdKeyDevice3=0xa7; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ + public static final int EStdKeyDevice4=0xa8; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ + public static final int EStdKeyDevice5=0xa9; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ + public static final int EStdKeyDevice6=0xaa; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ + public static final int EStdKeyDevice7=0xab; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ + public static final int EStdKeyDevice8=0xac; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ + public static final int EStdKeyDevice9=0xad; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ + public static final int EStdKeyDeviceA=0xae; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ + public static final int EStdKeyDeviceB=0xaf; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ + public static final int EStdKeyDeviceC=0xb0; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ + public static final int EStdKeyDeviceD=0xb1; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ + public static final int EStdKeyDeviceE=0xb2; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ + public static final int EStdKeyDeviceF=0xb3; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ + public static final int EStdKeyApplication0=0xb4; /**< Scan code for device-specific application launcher key.*/ + public static final int EStdKeyApplication1=0xb5; /**< Scan code for device-specific application launcher key.*/ + public static final int EStdKeyApplication2=0xb6; /**< Scan code for device-specific application launcher key.*/ + public static final int EStdKeyApplication3=0xb7; /**< Scan code for device-specific application launcher key.*/ + public static final int EStdKeyApplication4=0xb8; /**< Scan code for device-specific application launcher key.*/ + public static final int EStdKeyApplication5=0xb9; /**< Scan code for device-specific application launcher key.*/ + public static final int EStdKeyApplication6=0xba; /**< Scan code for device-specific application launcher key.*/ + public static final int EStdKeyApplication7=0xbb; /**< Scan code for device-specific application launcher key.*/ + public static final int EStdKeyApplication8=0xbc; /**< Scan code for device-specific application launcher key.*/ + public static final int EStdKeyApplication9=0xbd; /**< Scan code for device-specific application launcher key.*/ + public static final int EStdKeyApplicationA=0xbe; /**< Scan code for device-specific application launcher key.*/ + public static final int EStdKeyApplicationB=0xbf; /**< Scan code for device-specific application launcher key.*/ + public static final int EStdKeyApplicationC=0xc0; /**< Scan code for device-specific application launcher key.*/ + public static final int EStdKeyApplicationD=0xc1; /**< Scan code for device-specific application launcher key.*/ + public static final int EStdKeyApplicationE=0xc2; /**< Scan code for device-specific application launcher key.*/ + public static final int EStdKeyApplicationF=0xc3; /**< Scan code for device-specific application launcher key.*/ + public static final int EStdKeyYes=0xc4; /**< Scan code for Yes key.*/ + public static final int EStdKeyNo=0xc5; /**< Scan code for No key.*/ + public static final int EStdKeyIncBrightness=0xc6; /**< Scan code for Increase brightness key.*/ + public static final int EStdKeyDecBrightness=0xc7; /**< Scan code for Decrease brightness key.*/ + public static final int EStdKeyKeyboardExtend=0xc8; /**< Scan code for flip actuated when keypad extends to full keyboard.*/ + public static final int EStdKeyDevice10 = 0xc9; /**< Diagonal LeftUpArrow.*/ + public static final int EStdKeyDevice11 = 0xca; /**< Diagonal RightUpArrow.*/ + public static final int EStdKeyDevice12 = 0xcb; /**< Diagonal RightDownArrow.*/ + public static final int EStdKeyDevice13 = 0xcc; /**< Diagonal LeftDownArrow.*/ + + // + // SYMBIAN KEY CODES + // + + public static final int ENonCharacterKeyBase = 0xf800; + + public static final int EKeyNull=0x0000; /**< Code for the Null key. */ + public static final int EKeyBell=0x0007; /**< Code for the Bell key*/ + public static final int EKeyBackspace=0x0008; /**< Code for the Backspace key */ + public static final int EKeyTab=0x0009; /**< Code for the Tab key*/ + public static final int EKeyLineFeed=0x000a; /**< Code for the Linefeed key*/ + public static final int EKeyVerticalTab=0x000b; /**< Code for the Vertical tab key*/ + public static final int EKeyFormFeed=0x000c; /**< Code for the Form feed key*/ + public static final int EKeyEnter=0x000d; /**< Code for the Enter key */ + public static final int EKeyEscape=0x001b; /**< Code for the Escape key */ + public static final int EKeySpace=0x0020; /**< Code for the Space key*/ + public static final int EKeyDelete=0x007f; /**< Code for the Delete (Del) key*/ + public static final int EKeyPrintScreen = ENonCharacterKeyBase;/**< Code for the Print screen key */ + public static final int EKeyPause = ENonCharacterKeyBase + 1; /**< Code for the Pause key*/ + public static final int EKeyHome = ENonCharacterKeyBase + 2; /**< Code for the Home key*/ + public static final int EKeyEnd = ENonCharacterKeyBase + 3; /**< Code for the End key*/ + public static final int EKeyPageUp = ENonCharacterKeyBase + 4; /**< Code for the Page up key*/ + public static final int EKeyPageDown = ENonCharacterKeyBase + 5; /**< Code for the Page down key*/ + public static final int EKeyInsert = ENonCharacterKeyBase + 6; /**< Code for the Insert key*/ + public static final int EKeyLeftArrow = ENonCharacterKeyBase + 7; /**< Code for the Left arrow key*/ + public static final int EKeyRightArrow = ENonCharacterKeyBase + 8; /**< Code for the Right arrow key*/ + public static final int EKeyUpArrow = ENonCharacterKeyBase + 9; /**< Code for the Up arrow key*/ + public static final int EKeyDownArrow = ENonCharacterKeyBase + 10; /**< Code for the Down arrow key*/ + public static final int EKeyLeftShift = ENonCharacterKeyBase + 11; /**< Code for the left Shift key*/ + public static final int EKeyRightShift = ENonCharacterKeyBase + 12; /**< Code for the right Shift key*/ + public static final int EKeyLeftAlt = ENonCharacterKeyBase + 13; /**< Code for the left Alt key*/ + public static final int EKeyRightAlt = ENonCharacterKeyBase + 14; /**< Code for the right Alt key*/ + public static final int EKeyLeftCtrl = ENonCharacterKeyBase + 15; /**< Code for the left Control (Ctrl) key*/ + public static final int EKeyRightCtrl = ENonCharacterKeyBase + 16; /**< Code for the right Control (Ctrl) key.*/ + public static final int EKeyLeftFunc = ENonCharacterKeyBase + 17; /**< Code for the left Fn key.*/ + public static final int EKeyRightFunc = ENonCharacterKeyBase + 18; /**< Code for the right Fn key.*/ + public static final int EKeyCapsLock = ENonCharacterKeyBase + 19; /**< Code for the Caps lock key.*/ + public static final int EKeyNumLock = ENonCharacterKeyBase + 20; /**< Code for the Num lock key.*/ + public static final int EKeyScrollLock = ENonCharacterKeyBase + 21; /**< Code for the Scroll lock key.*/ + public static final int EKeyF1 = ENonCharacterKeyBase + 22; /**< Code for the F1 function key.*/ + public static final int EKeyF2 = ENonCharacterKeyBase + 23; /**< Code for the F2 function key.*/ + public static final int EKeyF3 = ENonCharacterKeyBase + 24; /**< Code for the F3 function key.*/ + public static final int EKeyF4 = ENonCharacterKeyBase + 25; /**< Code for the F4 function key.*/ + public static final int EKeyF5 = ENonCharacterKeyBase + 26; /**< Code for the F5 function key.*/ + public static final int EKeyF6 = ENonCharacterKeyBase + 27; /**< Code for the F6 function key.*/ + public static final int EKeyF7 = ENonCharacterKeyBase + 28; /**< Code for the F7 function key.*/ + public static final int EKeyF8 = ENonCharacterKeyBase + 29; /**< Code for the F8 function key.*/ + public static final int EKeyF9 = ENonCharacterKeyBase + 30; /**< Code for the F9 function key.*/ + public static final int EKeyF10 = ENonCharacterKeyBase + 31; /**< Code for the F10 function key.*/ + public static final int EKeyF11 = ENonCharacterKeyBase + 21; /**< Code for the F11 function key.*/ + public static final int EKeyF12 = ENonCharacterKeyBase + 33; /**< Code for the F12 function key.*/ + public static final int EKeyF13 = ENonCharacterKeyBase + 34; /**< Code for the F13 function key.*/ + public static final int EKeyF14 = ENonCharacterKeyBase + 35; /**< Code for the F14 function key.*/ + public static final int EKeyF15 = ENonCharacterKeyBase + 36; /**< Code for the F15 function key.*/ + public static final int EKeyF16 = ENonCharacterKeyBase + 37; /**< Code for the F16 function key.*/ + public static final int EKeyF17 = ENonCharacterKeyBase + 38; /**< Code for the F17 function key.*/ + public static final int EKeyF18 = ENonCharacterKeyBase + 39; /**< Code for the F18 function key.*/ + public static final int EKeyF19 = ENonCharacterKeyBase + 40; /**< Code for the F19 function key.*/ + public static final int EKeyF20 = ENonCharacterKeyBase + 41; /**< Code for the F20 function key.*/ + public static final int EKeyF21 = ENonCharacterKeyBase + 42; /**< Code for the F21 function key.*/ + public static final int EKeyF22 = ENonCharacterKeyBase + 43; /**< Code for the F22 function key.*/ + public static final int EKeyF23 = ENonCharacterKeyBase + 44; /**< Code for the F23 function key.*/ + public static final int EKeyF24 = ENonCharacterKeyBase + 45; /**< Code for the F24 function key.*/ + public static final int EKeyOff = ENonCharacterKeyBase + 46; /**< Code for the Off key.*/ + public static final int EKeyIncContrast = ENonCharacterKeyBase + 47; /**< Code for the Increase contrast key.*/ + public static final int EKeyDecContrast = ENonCharacterKeyBase + 48; /**< Code for the Decrease contrast key.*/ + public static final int EKeyBacklightOn = ENonCharacterKeyBase + 49; /**< Code for the Backlight on key.*/ + public static final int EKeyBacklightOff = ENonCharacterKeyBase + 50; /**< Code for the Backlight off key.*/ + public static final int EKeyBacklightToggle = ENonCharacterKeyBase + 51; /**< Code for the Backlight toggle key.*/ + public static final int EKeySliderDown = ENonCharacterKeyBase + 52; /**< Code for the Slider down key.*/ + public static final int EKeySliderUp = ENonCharacterKeyBase + 53; /**< Code for the Slider up key.*/ + public static final int EKeyMenu = ENonCharacterKeyBase + 54; /**< Code for the Menu key.*/ + public static final int EKeyDictaphonePlay = ENonCharacterKeyBase + 55; /**< Code for the Dictaphone play key.*/ + public static final int EKeyDictaphoneStop = ENonCharacterKeyBase + 56; /**< Code for the Dictaphone stop key.*/ + public static final int EKeyDictaphoneRecord = ENonCharacterKeyBase + 57; /**< Code for the Dictaphone record key.*/ + public static final int EKeyHelp = ENonCharacterKeyBase + 58; /**< Code for the Help key.*/ + public static final int EKeyDial = ENonCharacterKeyBase + 59; /**< Code for the Dial key.*/ + public static final int EKeyScreenDimension0 = ENonCharacterKeyBase + 60; /**< Code for the first Screen dimension change key.*/ + public static final int EKeyScreenDimension1 = ENonCharacterKeyBase + 61; /**< Code for the second Screen dimension change key.*/ + public static final int EKeyScreenDimension2 = ENonCharacterKeyBase + 62; /**< Code for the third Screen dimension change key.*/ + public static final int EKeyScreenDimension3 = ENonCharacterKeyBase + 63; /**< Code for the fourth Screen dimension change key.*/ + public static final int EKeyIncVolume = ENonCharacterKeyBase + 64; /**< Code for the increase colume key.*/ + public static final int EKeyDecVolume = ENonCharacterKeyBase + 65; /**< Code for the decrease volume key.*/ + public static final int EKeyDevice0 = ENonCharacterKeyBase + 66; /**< Code for a device specific key.*/ + public static final int EKeyDevice1 = ENonCharacterKeyBase + 67; /**< Code for a device specific key.*/ + public static final int EKeyDevice2 = ENonCharacterKeyBase + 68; /**< Code for a device specific key. */ + public static final int EKeyDevice3 = ENonCharacterKeyBase + 69; /**< Code for a device specific key.*/ + public static final int EKeyDevice4 = ENonCharacterKeyBase + 70; /**< Code for a device specific key.*/ + public static final int EKeyDevice5 = ENonCharacterKeyBase + 71; /**< Code for a device specific key.*/ + public static final int EKeyDevice6 = ENonCharacterKeyBase + 72; /**< Code for a device specific key.*/ + public static final int EKeyDevice7 = ENonCharacterKeyBase + 73; /**< Code for a device specific key.*/ + public static final int EKeyDevice8 = ENonCharacterKeyBase + 74; /**< Code for a device specific key.*/ + public static final int EKeyDevice9 = ENonCharacterKeyBase + 75; /**< Code for a device specific key.*/ + public static final int EKeyDeviceA = ENonCharacterKeyBase + 76; /**< Code for a device specific key.*/ + public static final int EKeyDeviceB = ENonCharacterKeyBase + 77; /**< Code for a device specific key.*/ + public static final int EKeyDeviceC = ENonCharacterKeyBase + 78; /**< Code for a device specific key.*/ + public static final int EKeyDeviceD = ENonCharacterKeyBase + 79; /**< Code for a device specific key.*/ + public static final int EKeyDeviceE = ENonCharacterKeyBase + 80; /**< Code for a device specific key.*/ + public static final int EKeyDeviceF = ENonCharacterKeyBase + 81; /**< Code for a device specific key.*/ + public static final int EKeyApplication0 = ENonCharacterKeyBase + 82; /**< Code for an Application launcher key.*/ + public static final int EKeyApplication1 = ENonCharacterKeyBase + 83; /**< Code for an Application launcher key.*/ + public static final int EKeyApplication2 = ENonCharacterKeyBase + 84; /**< Code for an Application launcher key.*/ + public static final int EKeyApplication3 = ENonCharacterKeyBase + 85; /**< Code for an Application launcher key.*/ + public static final int EKeyApplication4 = ENonCharacterKeyBase + 86; /**< Code for an Application launcher key.*/ + public static final int EKeyApplication5 = ENonCharacterKeyBase + 87; /**< Code for an Application launcher key.*/ + public static final int EKeyApplication6 = ENonCharacterKeyBase + 88; /**< Code for an Application launcher key.*/ + public static final int EKeyApplication7 = ENonCharacterKeyBase + 89; /**< Code for an Application launcher key.*/ + public static final int EKeyApplication8 = ENonCharacterKeyBase + 90; /**< Code for an Application launcher key.*/ + public static final int EKeyApplication9 = ENonCharacterKeyBase + 91; /**< Code for an Application launcher key.*/ + public static final int EKeyApplicationA = ENonCharacterKeyBase + 92; /**< Code for an Application launcher key.*/ + public static final int EKeyApplicationB = ENonCharacterKeyBase + 93; /**< Code for an Application launcher key.*/ + public static final int EKeyApplicationC = ENonCharacterKeyBase + 94; /**< Code for an Application launcher key.*/ + public static final int EKeyApplicationD = ENonCharacterKeyBase + 95; /**< Code for an Application launcher key.*/ + public static final int EKeyApplicationE = ENonCharacterKeyBase + 96; /**< Code for an Application launcher key.*/ + public static final int EKeyApplicationF = ENonCharacterKeyBase + 97; /**< Code for an Application launcher key.*/ + public static final int EKeyYes = ENonCharacterKeyBase + 98; /**< Code for the Yes key.*/ + public static final int EKeyNo = ENonCharacterKeyBase + 99; /**< Code for the No key.*/ + public static final int EKeyIncBrightness = ENonCharacterKeyBase + 100; /**< Code for the increase brightness key.*/ + public static final int EKeyDecBrightness = ENonCharacterKeyBase + 101; /**< Code for the decrease brightness key. */ + public static final int EKeyKeyboardExtend = ENonCharacterKeyBase + 102; /**< Code for flip actuated when keypad extends to full keyboard.*/ + public static final int EKeyDevice10 = ENonCharacterKeyBase + 103; /**< Diagonal LeftUpArrow.*/ + public static final int EKeyDevice11 = ENonCharacterKeyBase + 104; /**< Diagonal RightUpArrow.*/ + public static final int EKeyDevice12 = ENonCharacterKeyBase + 105; /**< Diagonal RightDownArrow.*/ + public static final int EKeyDevice13 = ENonCharacterKeyBase + 106; /**< Diagonal LeftDownArrow.*/ + + /** map from logical key codes to symbian key codes + * (index is logical key codes above with opposite sign) + * */ + private int logicalKeyCodes[] = { + EKeyUpArrow, //UpArrow + EKeyDownArrow,//DownArrow + EKeyLeftArrow,//LeftArrow + EKeyRightArrow,//RightArrow + EStdKeyDelete, //Clear + EKeyDevice3, //Select + EKeyRightShift, //Edit + EKeyYes, //Send + EKeyDevice0, //CBA1 + EKeyDevice1, //CBA2 + EKeyNo, //End + EKeyApplication0, //Applications + EKeyDevice6, //Voice + EKeyDevice7, //Power + EKeyDelete, //Backspace + EKeySliderDown, //GripOpen + EKeySliderUp, //GripClose + EKeyDevice7, //Camera + EKeyIncVolume, //VolumeUp + EKeyDecVolume, //VolumeDown + EKeyApplication2, //PlayPause + EKeyApplication3, //Stop + EKeyApplication4, //NextFF + EKeyApplication5, //PreviousRew + EKeyPageUp, // PageUp + EKeyPageDown, // PageDown + EKeyHome, // HomeKey + EKeyEnd, // EndKey + EKeyDevice3, // Activate + EKeyInsert, // InsertKey + EKeyEnter, // ReturnKey + EKeyDelete, // DeleteKey + EKeyEscape, // Escape + EKeyDevice10, //Diagonal LeftUpArrow + EKeyDevice11, //Diagonal RightUpArrow + EKeyDevice12, //Diagonal RightDownArrow + EKeyDevice13 //Diagonal LeftDownArrow + }; + + /** map from logical key codes to symbian scan codes + * (index is logical key codes above with opposite sign) + * */ + private int logicalScanCodes[] = { + EStdKeyUpArrow, //UpArrow + EStdKeyDownArrow, //DownArrow + EStdKeyLeftArrow, //LeftArrow + EStdKeyRightArrow, //RightArrow + EStdKeyBackspace, //Clear + EStdKeyDevice3, //Select + EStdKeyRightShift, //Edit + EStdKeyYes, //Send + EStdKeyDevice0, //CBA1 + EStdKeyDevice1, //CBA2 + EStdKeyNo, //End + EStdKeyApplication0, //Applications + EStdKeyDevice6, //Voice + EStdKeyDevice2, //Power + EStdKeyBackspace, //Backspace + EStdKeyNull, //GripOpen //TODO + EStdKeyNull, //GripClose //TODO + EStdKeyDevice7, //Camera + EStdKeyIncVolume, //VolumeUp + EStdKeyDecVolume, //VolumeDown + EStdKeyApplication2, //PlayPause + EStdKeyApplication3, //Stop + EStdKeyApplication4, //NextFF + EStdKeyApplication5, //PreviousRew + EStdKeyPageUp,// PageUp + EStdKeyPageDown,// PageDown + EStdKeyHome,// HomeKey + EStdKeyEnd,// EndKey + EStdKeyDevice3,// Activate + EStdKeyInsert,// InsertKey + EStdKeyEnter,// ReturnKey + EStdKeyDelete,// DeleteKey + EStdKeyEscape,// Escape + EStdKeyDevice10, //Diagonal LeftUpArrow + EStdKeyDevice11, //Diagonal RightUpArrow + EStdKeyDevice12, //Diagonal RightDownArrow + EStdKeyDevice13 //Diagonal LeftDownArrow + + + }; + + /** Default constructor */ + public Key() { + this.keyCode = 0; + this.scanCode = 0; + } + + /** Constructor accepting symbian key and scan codes defined above */ + public Key(int keyCode, int scanCode) { + this.keyCode = keyCode; + this.scanCode = scanCode; + } + + /** Constructor accepting unicode or logical key codes defined above */ + public Key(int keyCode) { + //JDEBUG("Key: Converting logical code " + keyCode); + + if (keyCode < 0) { + this.keyCode = logicalKeyCodes[-keyCode -1]; + this.scanCode = logicalScanCodes[-keyCode -1]; + } else if (keyCode >= 'a' && keyCode <= 'z') { + this.keyCode = keyCode; + this.scanCode = keyCode - 'a' + 'A'; + } else if (keyCode == '*') { + this.keyCode = keyCode; + this.scanCode = EStdKeyNkpAsterisk; + + } else if (keyCode == '#') { + this.keyCode = keyCode; + this.scanCode = EStdKeyHash; + } else if (keyCode == '/' || keyCode == '?') { + this.keyCode = keyCode; + this.scanCode = EStdKeyForwardSlash; + } + else if (keyCode == EKeyBackspace) { + this.keyCode = keyCode; + this.scanCode = EStdKeyBackspace; + } + else if (keyCode == EKeyEnter) { + this.keyCode = keyCode; + this.scanCode = EStdKeyEnter; + } + else if (keyCode == EKeyEscape) { + this.keyCode = keyCode; + this.scanCode = EStdKeyEscape; + } + else if (keyCode == EKeyDelete) { + this.keyCode = keyCode; + this.scanCode = EStdKeyDelete; + } + else if (keyCode == EKeyTab) { + this.keyCode = keyCode; + this.scanCode = EStdKeyTab; + } + else if (keyCode == '-' || keyCode == '_') { + this.keyCode = keyCode; + this.scanCode = EStdKeyMinus; + } + else if (keyCode == '=') { + this.keyCode = keyCode; + this.scanCode = EStdKeyEquals; + } + else if (keyCode == '+') { + this.keyCode = keyCode; + this.scanCode = EStdKeyNkpPlus; + } + else if (keyCode == ';' || keyCode == ':') { + this.keyCode = keyCode; + this.scanCode = EStdKeySemiColon; + } + else if (keyCode == '\'' || keyCode == '\"' ) { + this.keyCode = keyCode; + this.scanCode = EStdKeySingleQuote; + } + else if (keyCode >= '0' && keyCode <= '9') { + this.keyCode = keyCode; + this.scanCode = keyCode; + } + else if (keyCode == EKeySpace) { + this.keyCode = keyCode; + this.scanCode = EStdKeySpace; + } + else if (keyCode == DownArrow) { + this.keyCode = keyCode; + this.scanCode = EStdKeyDownArrow; + } + else if (keyCode == UpArrow) { + this.keyCode = keyCode; + this.scanCode = EStdKeyUpArrow; + } + else if (keyCode == LeftArrow) { + this.keyCode = keyCode; + this.scanCode = EStdKeyLeftArrow; + } + else if (keyCode == RightArrow) { + this.keyCode = keyCode; + this.scanCode = EStdKeyRightArrow; + } + else if (keyCode == ',') { + this.keyCode = keyCode; + this.scanCode = EStdKeyComma; + } + else if (keyCode == '.') { + this.keyCode = keyCode; + this.scanCode = EStdKeyFullStop; + } else { + this.keyCode = keyCode; + this.scanCode = keyCode; + } + } + + /** The symbian key code */ + public int keyCode; + + /** The symbian scan code */ + public int scanCode; + + /** Modifiers, for compatibility with XlibUtils **/ + public int modifiers; +} \ No newline at end of file diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/eswtuitestutils/javasrc/com/nokia/mj/impl/uitestutils/KeyFactory.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/eswtuitestutils/javasrc/com/nokia/mj/impl/uitestutils/KeyFactory.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,75 @@ +package com.nokia.mj.impl.uitestutils; + +public class KeyFactory +{ + + public static Key RIGHT_ARROW = new Key(Key.RightArrow); + public static Key LEFT_ARROW = new Key(Key.LeftArrow); + public static Key UP_ARROW = new Key(Key.UpArrow); + public static Key DOWN_ARROW = new Key(Key.DownArrow); + public static Key LEFTUP_ARROW = new Key(Key.EStdKeyDevice10); + public static Key RIGHTUP_ARROW = new Key(Key.EStdKeyDevice11); + public static Key RIGHTDOWN_ARROW = new Key(Key.EStdKeyDevice12); + public static Key LEFTDOWN_ARROW = new Key(Key.EStdKeyDevice13); + + public static Key SELECT_KEY = new Key(Key.Select); + public static Key SK1 = new Key(Key.CBA1); + public static Key SK2 = new Key(Key.CBA2); + + public static Key KEYPAD_0 = new Key(Key.EStdKeyNkp0); + public static Key KEYPAD_1 = new Key(Key.EStdKeyNkp1); + public static Key KEYPAD_2 = new Key(Key.EStdKeyNkp2); + public static Key KEYPAD_3 = new Key(Key.EStdKeyNkp3); + public static Key KEYPAD_4 = new Key(Key.EStdKeyNkp4); + public static Key KEYPAD_5 = new Key(Key.EStdKeyNkp5); + public static Key KEYPAD_6 = new Key(Key.EStdKeyNkp6); + public static Key KEYPAD_7 = new Key(Key.EStdKeyNkp7); + public static Key KEYPAD_8 = new Key(Key.EStdKeyNkp8); + public static Key KEYPAD_9 = new Key(Key.EStdKeyNkp9); + + public static Key F1 = new Key(Key.EKeyF1); + public static Key F2 = new Key(Key.EKeyF2); + public static Key F3 = new Key(Key.EKeyF3); + public static Key F4 = new Key(Key.EKeyF4); + public static Key F5 = new Key(Key.EKeyF5); + public static Key F6 = new Key(Key.EKeyF6); + public static Key F7 = new Key(Key.EKeyF7); + public static Key F8 = new Key(Key.EKeyF8); + public static Key F9 = new Key(Key.EKeyF9); + public static Key F10 = new Key(Key.EKeyF10); + public static Key F11 = new Key(Key.EKeyF11); + public static Key F12 = new Key(Key.EKeyF12); + public static Key F13 = new Key(Key.EKeyF13); + public static Key F14 = new Key(Key.EKeyF14); + public static Key F15 = new Key(Key.EKeyF15); + + public static Key BACKSPACE = new Key(Key.Backspace); + public static Key ENTER = new Key(Key.EKeyEnter); + public static Key ESCAPE = new Key(Key.EKeyEscape); + public static Key TAB = new Key(Key.EKeyTab); + public static Key CTRL_RIGHT = new Key(Key.EStdKeyRightCtrl); + public static Key CTRL_LEFT = new Key(Key.EStdKeyLeftCtrl); + public static Key SHIFT_RIGHT = new Key(Key.EStdKeyRightShift); + public static Key SHIFT_LEFT = new Key(Key.EStdKeyLeftShift); + public static Key SPACE = new Key(Key.EStdKeySpace); + public static Key DEL = new Key(Key.EKeyDelete); + + public static Key STAR = new Key('*'); + public static Key DIVIDE = new Key(Key.EStdKeyNkpForwardSlash); + public static Key ADD = new Key(Key.EStdKeyNkpPlus); + public static Key SUBTRACT = new Key(Key.EStdKeyNkpMinus); + public static Key HASH = new Key('#'); + public static Key CLEAR = new Key(Key.EStdKeyBackspace); + public static Key EDIT = new Key(Key.EStdKeyRightShift); + public static Key SEND = new Key(Key.EStdKeyYes); + public static Key END = new Key(Key.EStdKeyNo); + public static Key APPLICATIONS = new Key(Key.EStdKeyApplication0); + public static Key VOICE = new Key(Key.EStdKeyDevice6); + public static Key SOFTKEY_1 = new Key(Key.EStdKeyDevice0); + public static Key SOFTKEY_2 = new Key(Key.EStdKeyDevice1); + + public static Key key(int keyCode) + { + return new Key(keyCode); + } +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/eswtuitestutils/javasrc/com/nokia/mj/impl/uitestutils/Mask.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/eswtuitestutils/javasrc/com/nokia/mj/impl/uitestutils/Mask.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,275 @@ +package com.nokia.mj.impl.uitestutils; + +/** + * Mask implementation for storing and manipulating reference mask + * for pixel checking. Mask can be mirrored, rotated, restored etc. + * + * A new mask can be created from int[] array which holds indexes for + * refrence colors, e.g. value 1 can stand for red and 0 for white. + * + * example: + * + * int[] maskData = { + * 0,0,0,0,0,0,0,0,0, + * 0,0,0,0,1,0,0,0,0, + * 0,0,0,0,1,0,0,0,0, + * 0,0,0,0,1,0,0,0,0, + * 0,0,0,0,1,0,0,0,0, + * 0,0,0,0,1,0,0,0,0, + * 0,0,0,0,1,0,0,0,0, + * 0,0,0,0,0,0,0,0,0 + * }; + * + * + * ImageUtils can validate image pixels against mask indexes and given index colors. + * + * @author sampkaar + */ + + +public class Mask { + + int[] iMask = null; + int[] iOrigMask = null; + int iScanlength = 0; + int iWidth = 0; + int iHeight = 0; + Point iCenter; + + /** + * Creates instance of Mask. + * + * @param mask - int array for mask to be created, values should be 0 or 1 + * @param scanlength - length of line in mask + * + * @throws IllegalArgumentException - if mask is null + * @throws IllegalArgumentException - if remainder or mask.length/scanlength is not zero + */ + public Mask(int[] mask, int scanlength) { + if(mask == null) { + throw new IllegalArgumentException("mask is null"); + } + if((mask.length % scanlength) != 0) { + throw new IllegalArgumentException("Illegal scanlength"); + } + iMask = mask; + iOrigMask = mask; + iScanlength = scanlength; + iCenter = new Point(scanlength/2, (iMask.length/scanlength)/2); + iWidth = scanlength; + iHeight = iMask.length/scanlength; + } + + /** + * Returns mask's data array. + */ + public int[] getData() { + return iMask; + } + + /** + * gets subarea (rect) of mask specified by given arguments. + * + * @param x The x-coordinate of ractangle + * @param y The y-coordinate of ractangle + * @param width The width of ractangle + * @param height The height of ractangle + */ + public int[] getData(int x, int y, int width, int height) { + // specified area cannot exceed mask bounds + if((x+width > iWidth) || (y+height > iHeight)) { + throw new IllegalArgumentException("Area to be retrieved exceeds mask bounds"); + } + + // create new array + int[] result = new int[width*height]; + final int h = y+height; + final int w = x+width; + + // populate array + int resultIndex = 0; + for(int i = y; i < h ; i++) { + for(int j=x; j= 0; srcIndex -= iScanlength) { + System.arraycopy(iMask, srcIndex, resultMask, dstIndex, iScanlength); + dstIndex += iScanlength; + } + } + // save result mask + iMask = resultMask; + } + + /** + * Prints mask contents to console + */ + public void print() { + String output = "\n Mask("+iScanlength+","+iMask.length/iScanlength+"):\n"; + int y = 0; + for(int i = 0; i < iMask.length; i++) { + output += iMask[i]+","; + if(i==((y*iScanlength) + (iScanlength-1))) { + output += "\n"; + y++; + } + } + System.out.println(output); + } + + /** + * prints given mask data + * + * @param maskData The data of mask to be printed + * @param scanlengt The scanlength of one line in maskData + */ + public void print(int[] maskData, int scanlength) { + + final int width = scanlength; + final int height = maskData.length / width; + + String output = "\n Mask("+width+","+height+"):\n"; + + int y = 0; + for(int i = 0; i < maskData.length; i++) { + output += maskData[i]+","; + if(i==((y*width) + (width-1))) { + output += "\n"; + y++; + } + } + System.out.println(output); + } + + /** + * Resets mask to original mask given in constructor. + */ + public void resetOriginal() { + iMask = iOrigMask; + } + + /** + * Rotates mask. + * Positive angle rotates clockwise + * Negative angle rotates counterclockwise + * + * NOTE output is 100% correct only if width/height of mask is not even, i.e. + * 21 is ok, but 20 not. This is because currently the rotation is done after + * translating origin to the center of the mask and if width is 20 there no clear + * center... + * + * @param angel - The rotation angel + * @throws IllegalArgumentException - if remainder of angle / 90 is not zero + */ + public void rotate(float angle) { + if((angle % 90) != 0) { + throw new IllegalArgumentException("do not use other than 90 degree rotations"); + } + Matrix m = new Matrix(); + m.translate(iCenter.x, iCenter.y); + m.rotate(angle); + m.translate(-iCenter.x, -iCenter.y); + transform(m); + } + + /** + * Transforms mask based on given transform matrix. + * Note e.g. 45 degree rotation will fail as it needs bigger + * buffer, which is not supported. + * + * @param m - The trasformation matrix + * @throws IllegalArgumentException - if matrix m is null + * + */ + private void transform(Matrix m) { + if(m == null) { + throw new IllegalArgumentException("Matrix m is null"); + } + + int[] resultMask = new int[iMask.length]; + int y = 0; // line in source mask + int targetIndex = 0; // result mask index + + // points for source and target + Point sourcePoint; + Point targetPoint; + + for(int i=0; i< iMask.length ; i++){ + sourcePoint = new Point((i-(y*iScanlength)), y); + targetPoint = m.transform(sourcePoint); + targetIndex = (round(targetPoint.y)*iScanlength)+round(targetPoint.x); + resultMask[targetIndex] = iMask[i]; + + if(i==((y*iScanlength) + (iScanlength-1))) { + y++; + } + } + iMask = resultMask; + } + + /** + * Rounds given float to closest int value, e.g. + * If value >= 0.5 result is 1 + * if value <= 0.49 result is 0 + * + * @param value - The value to be rounded + */ + private int round(float value) { + int result = 0; + float temp = (int)value; + + if((temp+0.5 <= value)) { + result = (int)value+1; + } else { + result = (int)value; + } + return result; + } +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/eswtuitestutils/javasrc/com/nokia/mj/impl/uitestutils/Matrix.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/eswtuitestutils/javasrc/com/nokia/mj/impl/uitestutils/Matrix.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,258 @@ +package com.nokia.mj.impl.uitestutils; + +/** + * Matrix calculation implementation. + * + */ +public class Matrix { + + static final int ARRAY_SIZE = 6; + // Array index + static private final int M00 = 0; + static private final int M10 = 1; + static private final int M01 = 2; + static private final int M11 = 3; + static private final int M02 = 4; + static private final int M12 = 5; + + private float iComponents[]; + + /** + * Construct a matrix with the following components: + *
                +     * [1 0 0]
                +     * [0 1 0]
                +     * 
                + */ + public Matrix() { + iComponents = new float[ARRAY_SIZE]; + identity(); + } + + /** + * Construct a matrix with the following components: + *
                +     * [aM00 aM01 aM02]
                +     * [aM10 aM11 aM12]
                +     * 
                + * @param aM00 the x scaling component + * @param aM10 the y shearing component + * @param aM01 the x shearing component + * @param aM11 the y scaling component + * @param aM02 the x translation component + * @param aM12 the y translation component + */ + public Matrix(float aM00, float aM10, float aM01, + float aM11, float aM02, float aM12) { + iComponents = new float[ARRAY_SIZE]; + iComponents[M00] = aM00; iComponents[M01] = aM01; iComponents[M02] = aM02; + iComponents[M10] = aM10; iComponents[M11] = aM11; iComponents[M12] = aM12; + } + + /** + * Constructor + * Create a new matrix by coping the given one. + * @param aMatrix the matrix to copy + */ + public Matrix(Matrix aMatrix) { + iComponents = new float[aMatrix.iComponents.length]; + for(int index = 0; index < iComponents.length; index++) { + iComponents[index] = aMatrix.iComponents[index]; + } + } + + /** + * + */ + public float getComponent(int index) { + return iComponents[index]; + } + + /** + * Set matrix components: + *
                +     * [1 0 0]
                +     * [0 1 0]
                +     * 
                + * + */ + public void identity() + { + iComponents[M00] = 1; iComponents[M01] = 0; iComponents[M02] = 0; + iComponents[M10] = 0; iComponents[M11] = 1; iComponents[M12] = 0; + } + + /** + * Return transformed Point instance + * + * The transformation can be represented using matrix math on a 3x3 array. + * Given (x,y), the transformation (x',y') can be found by: + * [ x'] [ m00 m01 m02 ] [ x ] [ m00*x + m01*y + m02 ] + * [ y'] = [ m10 m11 m12 ] [ y ] = [ m10*x + m11*y + m12 ] + * [ 1 ] [ 0 0 1 ] [ 1 ] [ 1 ] + * + * The bottom row of the matrix is constant, so a transform can be uniquely + * represented by "[[m00, m01, m02], [m10, m11, m12]]". + * @param p the source point + * @return new point instance + */ + public Point transform(final Point p) + { + return new Point( + iComponents[M00] * p.x + iComponents[M01] * p.y + iComponents[M02], + iComponents[M10] * p.x + iComponents[M11] * p.y + iComponents[M12]); + } + + /** + * Return the matrix of components used in this transform. The resulting + * values are: + *
                +     * [array[0] array[2] array[4]]
                +     * [array[1] array[3] array[5]]
                +     * 
                + * @return array that contains the matrix components. + */ + float[] getComponents() { + return iComponents; + } + + + /** + * Return the determinant of this transform matrix. If the determinant is + * non-zero, the transform is invertible. + * The determinant is calculated as: + *
                +     * [m00 m01 m02] 
                +     * [m10 m11 m12] = m00 * m11 - m01 * m10
                +     * [ 0   0   1 ]
                +     * 
                + * @return the determinant + */ + public float determinant() { + return ((iComponents[M00] * iComponents[M11]) - + (iComponents[M01] * iComponents[M10])); + } + + /** + * The inverse is calculated as: + *
                +     *     [m00 m01 m02]
                +     *  M= [m10 m11 m12]
                +     *     [ 0   0   1 ] 
                +     *
                +     *              1                 [ m11/det  -m01/det   (m01*m12-m02*m11)/det]     
                +     * inverse(M)= --- x adjoint(M) = [-m10/det   m00/det   (m10*m02-m00*m12)/det] 
                +     *             det                [    0         0               1           ]  
                +     * 
                + */ + public Matrix inverse() { + // The inversion is useful for undoing transformations. + float det = determinant(); + if (det == 0) + { + throw new RuntimeException("Invalid determinant"); + } + return new Matrix( + iComponents[M11] / det, // iMtx[M00] + (-iComponents[M10]) / det, // iMtx[M10] + (-iComponents[M01]) / det, // iMtx[M01] + iComponents[M00] / det, // iMtx[M11] + ((iComponents[M01] * iComponents[M12]) - (iComponents[M02] * iComponents[M11])) / det, + ((iComponents[M10] * iComponents[M02]) - (iComponents[M00] * iComponents[M12])) / det); + } + + /** + * The multiply is calculated as: + *
                +     *       [a00 a01 a02]   [b00 b01 b02]
                +     *  this=[a10 a11 a12] B=[b10 b11 b12] 
                +     *       [ 0   0   1 ]   [ 0   0   1 ]
                +     *
                +     *                       [(a00*b00+a01*b10) (a00*b01+a01*b11) (a00*b02+a01*b12+a02)]   
                +	 * [this] = [this]x[B] = [(a10*b00+a11*b10) (a10*b01+a11*b11) (a10*b02+a11*b12+a12)]
                +     *                       [       0                   0                     1       ]
                +     * 
                + */ + public Matrix multiply(Matrix b) { + if(b == null) + { + throw new NullPointerException(); + } + float a00 = iComponents[M00]; // a + float a10 = iComponents[M10]; // b + float a01 = iComponents[M01]; // c + float a11 = iComponents[M11]; // d + float a02 = iComponents[M02]; // e + float a12 = iComponents[M12]; // f + iComponents[M00] = (a00 * b.iComponents[M00]) + (a01 * b.iComponents[M10]); // a + iComponents[M10] = (a10 * b.iComponents[M00]) + (a11 * b.iComponents[M10]); // b + iComponents[M01] = (a00 * b.iComponents[M01]) + (a01 * b.iComponents[M11]); // c + iComponents[M11] = (a10 * b.iComponents[M01]) + (a11 * b.iComponents[M11]); // d + iComponents[M02] = (a00 * b.iComponents[M02]) + (a01 * b.iComponents[M12]) + a02; // e + iComponents[M12] = (a10 * b.iComponents[M02]) + (a11 * b.iComponents[M12]) + a12; // f + return this; + } + + /** + * The rotation is calculated as: + *
                +     *          [ cos(angle) -sin(angle) 0 ]
                +     * [this] x [ sin(angle)  cos(angle) 0 ]
                +     *          [     0           0      1 ]
                +     * 
                + */ + public Matrix rotate(float angle) { + if (angle % 360 == 0) { + return this; + } + // Must convert degrees to radians since java.lang.Math expects radians + angle = angle * (float)Math.PI / 180.0f; + float c = (float)Math.cos(angle); + float s = (float)Math.sin(angle); + float m00 = iComponents[M00]; + float m10 = iComponents[M10]; + float m01 = iComponents[M01]; + float m11 = iComponents[M11]; + iComponents[M00] = m00 * c + m01 * s; + iComponents[M10] = m10 * c + m11 * s; + iComponents[M01] = m01 * c - m00 * s; + iComponents[M11] = m11 * c - m10 * s; + return this; + } + + /** + * The multiply is calculated as: + *
                +     *       [m00 m01 m02]   [scaleFactor      0      0]
                +     *  this=[m10 m11 m12] B=[    0       scaleFactor 0] 
                +     *       [ 0   0   1 ]   [    0            0      1]
                +     *
                +     *                       [(a00*scaleFactor) (a01*scaleFactor) a02]   
                +     * [this] = [this]x[B] = [(a10*scaleFactor) (a11*scaleFactor) a12]
                +     *                       [       0                   0         1 ]
                +     * 
                + * @see org.w3c.dom.svg.SVGMatrix#mScale() + */ + public Matrix scale(float scaleFactor) { + if(scaleFactor == 1) { + return this; + } + iComponents[M00] *= scaleFactor; + iComponents[M01] *= scaleFactor; + iComponents[M10] *= scaleFactor; + iComponents[M11] *= scaleFactor; + return this; + } + + /** + * + */ + public Matrix translate(float x, float y) { + if(x == 0 && y == 0) { + return this; + } + iComponents[M02] += (iComponents[M00] * x) + (iComponents[M01] * y); + iComponents[M12] += (iComponents[M10] * x) + (iComponents[M11] * y); + return this; + } +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/eswtuitestutils/javasrc/com/nokia/mj/impl/uitestutils/Modifier.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/eswtuitestutils/javasrc/com/nokia/mj/impl/uitestutils/Modifier.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,14 @@ +package com.nokia.mj.impl.uitestutils; + +public final class Modifier { + + // Bitmask for sending modifiers + // Values taken from /usr/include/X11/X.h + public static final int Shift = (1<<0); + public static final int CapsLock = (1<<1); + public static final int Control = (1<<2); + public static final int Alt = (1<<3); + public static final int NumLock = (1<<4); + public static final int ScrllLock = (1<<4); + public static final int AltGr = (1<<7); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/eswtuitestutils/javasrc/com/nokia/mj/impl/uitestutils/Point.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/eswtuitestutils/javasrc/com/nokia/mj/impl/uitestutils/Point.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,32 @@ + +package com.nokia.mj.impl.uitestutils; + +/** + * Class for storing point, i.e. x and y values. + * This is used in matric calculations. + * + * @author ktuokkol + */ +public class Point { + public float x; + public float y; + + /** + * Ctor + */ + public Point() { + x = 0f; + y = 0f; + } + + /** + * Ctor + * @param x + * @param y + */ + public Point(float x, float y) { + this.x = x; + this.y = y; + } + +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/eswtuitestutils/javasrc/com/nokia/mj/impl/uitestutils/Rect.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/eswtuitestutils/javasrc/com/nokia/mj/impl/uitestutils/Rect.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,100 @@ +package com.nokia.mj.impl.uitestutils; + +/** + * Simple rect container + * @author sampkaar + * + */ +public class Rect { + + private int x; + private int y; + private int width; + private int height; + + public Rect(int x, int y, int width, int height) { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + } + + public int x() { + return this.x; + } + + public int y() { + return this.y; + } + + public int width() { + return this.width; + } + + public int height() { + return this.height; + } + + public Rect intersection(Rect aRect){ + + if( aRect.x < this.x && aRect.x+aRect.width < this.x || + aRect.x > this.x+this.width && aRect.x+aRect.width > this.x+this.width) + { // no intersection + return new Rect(0,0,0,0); + } + if( aRect.y < this.y && aRect.y+aRect.height < this.y || + aRect.y > this.y+this.height && aRect.y+aRect.height > this.y+this.height) + { // no intersection + return new Rect(0,0,0,0); + } + int x = 0; + int y = 0; + int w = 0; + int h = 0; + + if(aRect.x < this.x) + { + x = this.x; + if (this.x + this.width < aRect.x + aRect.width) + { + w = this.width; + }else + { + w = aRect.x + aRect.width - this.x; + } + } else + { // aRect.x >= this.x + x = aRect.x; + if (aRect.x + aRect.width < this.x + this.width) + { + w = aRect.width; + }else + { + w = this.x + this.width - aRect.x; + } + } + if(aRect.y < this.y) + { + y = this.y; + if (this.y + this.height < aRect.y + aRect.height) + { + h = this.height; + }else + { + h = aRect.y + aRect.height - this.y; + } + } else + { // aRect.y >= this.y + y = aRect.y; + if (aRect.y + aRect.height < this.y + this.height) + { + h = aRect.height; + }else + { + h = this.y + this.height - aRect.y; + } + } + return new Rect(x, y, w, h); + } + +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/eswtuitestutils/javasrc/com/nokia/mj/impl/uitestutils/RuntimeUtils.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/eswtuitestutils/javasrc/com/nokia/mj/impl/uitestutils/RuntimeUtils.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,23 @@ +package com.nokia.mj.impl.uitestutils; + +import org.eclipse.ercp.swt.midp.UIThreadSupport; + +public class RuntimeUtils { + + public static final int S60 = 1; + public static final int X11 = 2; + + public static int getPlatform() { + return S60; + } + + public synchronized static final int startUI( + final Runnable callback) { + UIThreadSupport.startInUIThread(new Runnable() { + public void run() { + callback.run(); + } + }); + return 0; + } +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/eswtuitestutils/javasrc/com/nokia/mj/impl/uitestutils/S60Utils.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/eswtuitestutils/javasrc/com/nokia/mj/impl/uitestutils/S60Utils.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,112 @@ +package com.nokia.mj.impl.uitestutils; + + +final class S60Utils { + + static { + // Should use vmport, this is CDC/J2SE API + //System.loadLibrary("s60uitestutils"); + org.eclipse.swt.internal.Library.loadLibrary("s60uitestutils"); + } + + /** + * Constant for key press event. + */ + static final int PRESS = 0; + + /** + * Constant for key release event. + */ + static final int RELEASE = 1; + + /** + * Button constants. + */ + static final int BUTTON1 = 1; + static final int BUTTON2 = 2; + static final int BUTTON3 = 3; + + + /** + * Sends a key event to the window which has the keyboard focus. Get the keycode of + * the desired symbol using XKeysymToKeycode and pass that here. Or if the desired + * keycode is known it can be passed directly. + * @param keycode The keycode of the key to send. + * @param modifiers The modifiers to send. + * @param pressOrRelease Either PRESS or RELEASE must be passed here. + * @return 0 if successful, otherwise a non-zero error code + * @see XlibKeys + */ + static final native int S60SendKeyToFocusWindow(int keycode, int modifiers, int pressOrRelease); + + /** + * Returns the keycode of the given symbol (keysym) in the currently active + * keyboard layout. Keysym constants are defined in XlibKeys. + * @param keysym + * @return The keycode or zero in case of an error + * @see XlibKeys + */ + static final native int S60KeysymToKeycode(int keysym); + + /** + * Sends a pointer press or release event. + * @param x X-coordinate to send, relative to X root window (i.e. screen). + * @param y Y-coordinate to send, relative to X root window (i.e. screen). + * @param modifiers The modifiers to send. + * @param button The button that's pressed or released. + * @param pressOrRelease Either PRESS or RELEASE must be passed here. + * @return 0 if successful, otherwise a non-zero error code + */ + static final native int S60SendPointerEvent(int x, int y, int button, int pressOrRelease); + + /** + * Sends a pointer move event. + * @param x X-coordinate to send, relative to X root window (i.e. screen). + * @param y Y-coordinate to send, relative to X root window (i.e. screen). + * @param button The button that's held pressed during the move. + * @return 0 if successful, otherwise a non-zero error code + */ + static final native int S60SendPointerMoveEvent(int x, int y, int button); + + /** + * Disables the screensaver. + */ + static final native void S60DisableScreensaver(); + + /** + * Sets the doubleclick interval. Set to 0 to disable doubleclicks. + * @param interval New doubleclick interval + */ + static final native void S60SetDoubleclickInterval(int interval); + + /*static final native int _create(int toolkitHandle, UITestUtils testUtils); + static final native void _dispose(int toolkitHandle, UITestUtils testUtils, int testUtilsHandle); + + static final native void _startTest(int toolkitHandle, int handle, String screenShotDir); + static final native void _endTest(int toolkitHandle, int handle, boolean passed, String msg); + + static final native void _log(int toolkitHandle, int handle, String msg); + static final native void _logResult(int toolkitHandle, int handle, boolean passed, String msgPassed, String msgFailed); + + static final native void _triggerKeyPressEvent(int toolkitHandle, int handle, int keyCode, int scanCode); + static final native int _triggerKeyRepeatEvents(int toolkitHandle, int handle, int keyCode, int scanCode, int count); + static final native int _triggerMediaKeyRepeatEvents(int toolkitHandle, int handle, int keyCode, int scanCode, int pressedTimeInMillis); + + static final native boolean _getScreenShot(int toolkitHandle, int handle, String screenShotName); + static final native boolean _getScreenShot(int toolkitHandle, int handle, String screenShotName, + int areaToCompare, int displayableType); + static final native boolean _getScreenShot(int toolkitHandle, int handle, String screenShotName, + int topLeftX, int topLeftY, int bottomRightX, int bottomRightY); + + static final native void _triggerPointerDownEvent(int toolkitHandle, int handle, int x, int y); + static final native void _triggerPointerUpEvent(int toolkitHandle, int handle, int x, int y); + static final native void _triggerPointerDragEvent(int toolkitHandle, int handle, int x, int y); + + static final native void _changeQwertyInput(int toolkitHandle, int handle, boolean aOn); + static final native int _switchResolution(int toolkitHandle, int handle, int numTimes, int delayMillis); + + static final native void _getBoundsOf(int toolkitHandle, int handle, int type, int[] coordinates); + + static final native void _allowScreenSaver(int toolkitHandle, int handle, int allow);*/ + +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/eswtuitestutils/javasrc/com/nokia/mj/impl/uitestutils/UITestUtils.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/eswtuitestutils/javasrc/com/nokia/mj/impl/uitestutils/UITestUtils.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,187 @@ +// UITestUtils.java // // // + +package com.nokia.mj.impl.uitestutils; + +import java.lang.String; +import org.eclipse.swt.internal.qt.OS; + +public class UITestUtils { + + private static final int RES_CHANGE_DEFAULT_DELAY = 5000; + + public UITestUtils() { + // Always disable screensaver when running tests. + S60Utils.S60DisableScreensaver(); + } + + /** Init test and s. shot directory, make sure you use slashes to start and + end it dir name */ + public void startTest(String screenShotDir) { + } + + /** Ends the test, prints a summary, etc */ + public void endTest(boolean passed, String msg) { + } + + /** Log a message */ + public void log(String msg) { + } + + /** Logs one of the two messages and either PASSED or FAILED according to + value of passed parameter */ + public void log(boolean passed, String msgPassed, String msgFailed) { + } + + /** Sends a key event to the midlet using the specified key and scan code */ + public void triggerKeyPressEvent(Key key) { + int keycode = key.scanCode; + int modifiers = key.modifiers; + if(S60Utils.S60SendKeyToFocusWindow(keycode, modifiers, S60Utils.PRESS) != 0) + throw new RuntimeException("Emulating key press failed"); + if(S60Utils.S60SendKeyToFocusWindow(keycode, modifiers, S60Utils.RELEASE) != 0) + throw new RuntimeException("Emulating key release failed"); + } + + /** Sends a key down event to the application using the specified key */ + public void triggerKeyDownEvent(Key key) { + int keycode = key.scanCode; + int modifiers = key.modifiers; + if(S60Utils.S60SendKeyToFocusWindow(keycode, modifiers, S60Utils.PRESS) != 0) + throw new RuntimeException("Emulating key press failed"); + } + + /** Sends a key up event to the application using the specified key */ + public void triggerKeyUpEvent(Key key) { + int keycode = key.scanCode; + int modifiers = key.modifiers; + if(S60Utils.S60SendKeyToFocusWindow(keycode, modifiers, S60Utils.RELEASE) != 0) + throw new RuntimeException("Emulating key release failed"); + } + + + /** Triggers key repeat events using the specified key and scan code. + Calling this method will trigger the following events to Canvas/CustomItem: + 1. keyPressed event + 2. keyRepeated events, the number of events is indicated by count parameter + 3. keyReleased events + + NOTE 1: This method returns right after triggering the keyPressed event. There should be enough delay + after calling this so that all repeat events can be handled before the test result is checked. + The delay before triggering first repeat event is 0.6 seconds and between sequential repeat + events 0.2 seconds. + + NOTE 2: For triggering media key repeat events triggerMediaKeyRepeatEvents() + must be used. + */ + public int triggerKeyRepeatEvents(Key key, int count) { + return 0; + } + + /** This method must be used when triggering repeat events for media keys. + pressedTimeInMillis defines how long a key is kept pressed down. + + NOTE 1: This method returns right after triggering the keyDown event. There should be enough delay + (> pressedTimeInMillis) after calling this so that all repeat events and key up can be handled before + the test result is checked. + */ + public int triggerMediaKeyRepeatEvents(Key key, int pressedTimeInMillis) { + return 0; + } + + /** Sends pointer down event to the midlet */ + public void triggerPointerDownEvent(int x, int y) { + // Setting double click interval to 0 disables double clicks, making it possible + // to click around in the test cases quickly without causing unwanted double click + // events + OS.QApplication_setDoubleClickInterval(0); + if(S60Utils.S60SendPointerEvent(x, y, S60Utils.BUTTON1, S60Utils.PRESS) != 0) + throw new RuntimeException("Emulating pointer down failed"); + } + + /** Sends pointer up event to the midlet */ + public void triggerPointerUpEvent(int x, int y) { + if(S60Utils.S60SendPointerEvent(x, y, S60Utils.BUTTON1, S60Utils.RELEASE) != 0) + throw new RuntimeException("Emulating pointer up failed"); + } + + /** Sends pointer drag event to the midlet */ + public void triggerPointerDragEvent(int x, int y) { + if(S60Utils.S60SendPointerMoveEvent(x, y, S60Utils.BUTTON1) != 0 ) { + throw new RuntimeException("Emulating pointer move failed"); + } + } + + /** + * Sends a pointer event to open up a context menu. E.g. long-press, right-click + * or such depending on the platform. + */ + public void triggerContextPointerEvent(int x, int y) { + if(S60Utils.S60SendPointerEvent(x, y, S60Utils.BUTTON3, S60Utils.PRESS) != 0) + throw new RuntimeException("Emulating pointer down failed"); + if(S60Utils.S60SendPointerEvent(x, y, S60Utils.BUTTON3, S60Utils.RELEASE) != 0) + throw new RuntimeException("Emulating pointer up failed"); + } + + /** Takes a screen shot and saves it into a .png file. Returns true if + reference screen shot exists and is identical to the new screen shot*/ + public boolean getScreenShot(String screenShotName) { + return true; + } + + /** Takes a screen shot and saves it into a .png file. Returns true if + reference screen shot exists and compared area is identical in the reference and new screen shot. + areaToCompare and displayableType define the area that is compared. See also SpedeRunner.java.*/ + public boolean getScreenShot(String screenShotName, int areaToCompare, int displayableType) { + return true; + } + + /** Takes a screen shot and saves it into a .png file. Returns true if + reference screen shot exists and compared area is identical in the reference and new screen shot. + Four integer parameters define the rectangle area for screen shot comparison. */ + public boolean getScreenShot(String screenShotName, int topLeftX, int topLeftY, + int bottomRightX, int bottomRightY) { + return true; + } + + public void dispose() { + } + + /** Enable or disable QWERTY input */ + public void changeQwertyInput(boolean aOn) { + } + + public int switchResolution() { + return switchResolution(1); + } + + /** Change the screen resolution - works only on the emulator */ + public int switchResolution(int numTimes) { + return 0; + } + + /** Change the screen resolution - works only on the emulator */ + public int switchResolutionWithDelay(int delayMillis) { + return 0; + } + + /** + * Get the top left and bottom right coordinates of main pane, form rect, etc. + * + * @param coordinates The coordinates are returned in this array + * @param type Defines for which area the coordinates are fetched + */ + public void getBoundsOf(int type, int[] coordinates) { + } + + /** + * Disable screen saver + */ + public void disableScreenSaver() { + } + + /** + * Enable screen saver + */ + public void enableScreenSaver() { + } +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/eswtuitestutils/src/eswtuitestutils.pri --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/eswtuitestutils/src/eswtuitestutils.pri Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,15 @@ +#******************************************************************************* +# Copyright (c) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Nokia Corporation - initial implementation +#******************************************************************************* + +INCLUDEPATH += $$PWD +DEPENDPATH += $$PWD + +SOURCES += s60utils.cpp \ No newline at end of file diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/eswtuitestutils/src/s60utils.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/eswtuitestutils/src/s60utils.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,146 @@ +#include +#include +#include +#include +#include +#include +//#include +#include + +//#include + +#include "com_nokia_mj_impl_uitestutils_S60Utils.h" +// Note following modifilers are from X11 instead of Symbian +static const TInt Shift = (1<<0); +static const TInt CapsLock = (1<<1); +static const TInt Control = (1<<2); +static const TInt Alt = (1<<3); +static const TInt NumLock = (1<<4); +static const TInt ScrllLock = (1<<4); +static const TInt AltGr = (1<<7); + + +static TInt symbianKeyCode(TInt aX11Modifier) + { + TInt keyCode(0); + if( (aX11Modifier & Shift) > 0 ) + { + keyCode = EStdKeyLeftShift; + } + else if( (aX11Modifier & CapsLock) > 0 ) + { + keyCode = EStdKeyCapsLock; + } + else if( (aX11Modifier & Control) > 0 ) + { + keyCode = EStdKeyLeftCtrl; + } + else if( (aX11Modifier & Alt) > 0 ) + { + keyCode = EStdKeyLeftAlt; + } + else if( (aX11Modifier & NumLock) > 0 ) + { + keyCode = EStdKeyNumLock; + } + else if( (aX11Modifier & ScrllLock) > 0 ) + { + keyCode = EStdKeyScrollLock; + } + else if( (aX11Modifier & AltGr) > 0 ) + { + keyCode = EStdKeyRightAlt; + } + return keyCode; + } + +JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_uitestutils_S60Utils_S60SendKeyToFocusWindow + (JNIEnv *, jclass, jint aKeyCode, jint aModifier, jint aPressOrRelease) + { + RDebug::Print(_L("S60UITestUtils : S60SendKeyToFocusWindow, keycode=%d"), aKeyCode); + + User::ResetInactivityTime();// Reset user inactivity timers + + if(aModifier > 0 && aPressOrRelease == com_nokia_mj_impl_uitestutils_S60Utils_PRESS) + { + TRawEvent mevent; + TInt keyCode = symbianKeyCode( aModifier); + mevent.Set(TRawEvent::EKeyDown, keyCode); + UserSvr::AddEvent(mevent); + User::After(100000); + } + + TRawEvent event; + + if (aPressOrRelease == com_nokia_mj_impl_uitestutils_S60Utils_PRESS) + { + event.Set(TRawEvent::EKeyDown, aKeyCode); + } + else + { + event.Set(TRawEvent::EKeyUp, aKeyCode); + } + + UserSvr::AddEvent(event); + User::After(100000); + if(aModifier > 0 && aPressOrRelease == com_nokia_mj_impl_uitestutils_S60Utils_RELEASE) + { + TRawEvent mevent; + TInt keyCode = symbianKeyCode(aModifier); + mevent.Set(TRawEvent::EKeyUp, keyCode); + UserSvr::AddEvent(mevent); + User::After(100000); + } + + return 0; + } + +JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_uitestutils_S60Utils_S60KeysymToKeycode + (JNIEnv *, jclass, jint) + { + return 0; + } + +JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_uitestutils_S60Utils_S60SendPointerEvent + (JNIEnv *, jclass, jint aX, jint aY, jint /*aButton*/, jint aPressOrRelease) + { + User::ResetInactivityTime();// Reset user inactivity timers + + TRawEvent event; + + if (aPressOrRelease == com_nokia_mj_impl_uitestutils_S60Utils_PRESS) { + event.Set(TRawEvent::EButton1Down, aX, aY); + } else { + event.Set(TRawEvent::EButton1Up, aX, aY); + } + UserSvr::AddEvent(event); + return 0; + } + +JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_uitestutils_S60Utils_S60SendPointerMoveEvent + (JNIEnv *, jclass, jint aX, jint aY, jint) + { + User::ResetInactivityTime();// Reset user inactivity timers + TRawEvent event; + event.Set(TRawEvent::EPointerMove, aX, aY); + UserSvr::AddEvent(event); + return 0; + } + +JNIEXPORT void JNICALL Java_com_nokia_mj_impl_uitestutils_S60Utils_S60DisableScreensaver + (JNIEnv *, jclass) + { + //RProperty::Set( KPSUidScreenSaver, KScreenSaverAllowScreenSaver, 1 ); + } + +JNIEXPORT void JNICALL Java_com_nokia_mj_impl_uitestutils_S60Utils_S60SetDoubleclickInterval + (JNIEnv *, jclass, jint aInterval) + { + // Commented out for now. This can be taken into use once Qt doesn't need WSD to be allowed + /*QApplication* app = static_cast(QCoreApplication::instance()); + if ( app ) + { + app->setDoubleClickInterval( aInterval ); + }*/ + } + \ No newline at end of file diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt.qt.linux.arm.se/.project --- a/javauis/eswt_qt/org.eclipse.swt.qt.linux.arm.se/.project Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ - - - org.eclipse.swt.qt.linux.arm.se - - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt.qt.linux.arm.se/Makefile --- a/javauis/eswt_qt/org.eclipse.swt.qt.linux.arm.se/Makefile Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -# Scratchbox paths. Not the same as Linux host paths! -LIB_PATH:=/home/pmotresc/org.eclipse.swt/Eclipse_SWT_PI/qt/library -LIB_PATH_GFX:=/home/pmotresc/org.eclipse.swt/Eclipse_SWT_PI/qt/graphics_library - -debug: - cd $(LIB_PATH) && qmake -spec linux-g++ -unix CONFIG+=debug DESTDIR=debug OBJECTS_DIR=debug/linux-g++/build -o Makefile.maemo.debug swt.pro - cd $(LIB_PATH) && make -f Makefile.maemo.debug - cd $(LIB_PATH_GFX) && qmake -spec linux-g++ -unix CONFIG+=debug DESTDIR=debug OBJECTS_DIR=debug/linux-g++/build -o Makefile.maemo.debug graphics.pro - cd $(LIB_PATH_GFX) && make -f Makefile.maemo.debug - echo Done building debug - -release: - cd $(LIB_PATH) && qmake -spec linux-g++ -unix CONFIG+=release DESTDIR=release OBJECTS_DIR=release/linux-g++/build -o Makefile.maemo.release swt.pro - cd $(LIB_PATH) && make -f Makefile.maemo.release - cd $(LIB_PATH_GFX) && qmake -spec linux-g++ -unix CONFIG+=release DESTDIR=release OBJECTS_DIR=release/linux-g++/build -o Makefile.maemo.release graphics.pro - cd $(LIB_PATH_GFX) && make -f Makefile.maemo.release - echo Done building release - -clean: - -cd $(LIB_PATH) - -make -f Makefile.maemo.debug clean - -rm -f $(LIB_PATH)/Makefile.maemo.debug - -rm -f -r $(LIB_PATH)/debug - -cd $(LIB_PATH_GFX) - -make -f Makefile.maemo.debug clean - -rm -f $(LIB_PATH_GFX)/Makefile.maemo.debug - -rm -f -r $(LIB_PATH_GFX)/debug - -@echo Done cleaning debug - -cd $(LIB_PATH) - -make -f Makefile.maemo.release clean - -rm -f $(LIB_PATH)/Makefile.maemo.release - -rm -f -r $(LIB_PATH)/release - -cd $(LIB_PATH_GFX) - -make -f Makefile.maemo.release clean - -rm -f $(LIB_PATH_GFX)/Makefile.maemo.release - -rm -f -r $(LIB_PATH_GFX)/release - -@echo Done cleaning release - -all: debug, release diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt.qt.linux.arm.se/build.properties --- a/javauis/eswt_qt/org.eclipse.swt.qt.linux.arm.se/build.properties Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2007 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -custom = true -ws = qt -os = linux -arch=arm -java.edition= se -fragment=org.eclipse.swt.qt.linux.arm.se -version.suffix=3.5.0 -plugin.dir=../org.eclipse.swt -tests.junit.dir=../eclipsetests -tests.mt.dir=../nokiatests -tests.utils.dir=../s60utils -javac.source=1.3 -javac.target=1.3 -javac.debug=false -lib.filename = libeswtqt.so -lib.makefile = Makefile.linux -lib.spec=linux-g++ -jar.filename=eswt-qt.jar -generated.native.dir = generated \ No newline at end of file diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt.qt.linux.arm.se/build.xml --- a/javauis/eswt_qt/org.eclipse.swt.qt.linux.arm.se/build.xml Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,333 +0,0 @@ - - - - - -Usage: ant [one of the following:] -build : Build debug + release -build.jar : Build all jars -build.debug : Build all debug binaries -build.release : Build all release binaries -build.lib : Build all native libraries -build.lib.debug : Build debug native libraries -build.lib.release : Build release native libraries -build.tests : Build JUnit and MT tests -clean : Clean everything -clean.jar : Clean all jars -clean.lib : Clean native libraries and object files -clean.lib.debug : Clean debug native libraries and object files -clean.lib.release : Clean release native libraries and object files -export : Export everything -export.jar : Export Java classes packed as jar -export.debug : Export all debug binaries -export.release : Export all release binaries -export.lib : Export native libraries -export.lib.debug : Export debug native libraries -export.lib.release : Export release native libraries -run.tests : Run JUnit and MT tests - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt.qt.linux.x86.me/build.properties --- a/javauis/eswt_qt/org.eclipse.swt.qt.linux.x86.me/build.properties Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt.qt.linux.x86.me/build.properties Fri Jun 11 13:33:44 2010 +0300 @@ -23,7 +23,9 @@ javac.target=1.3 javac.debug=false lib.filename = libeswtqt.so +lib.filename.webkit = libeswtqtwebkit.so lib.makefile = Makefile.linux lib.spec=linux-g++ jar.filename=eswtqt.jar -generated.native.dir = generated \ No newline at end of file +generated.native.dir = generated/eswtqt +generated.native.dir.webkit = generated/eswtqtwebkit diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt.qt.linux.x86.me/build.xml --- a/javauis/eswt_qt/org.eclipse.swt.qt.linux.x86.me/build.xml Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt.qt.linux.x86.me/build.xml Fri Jun 11 13:33:44 2010 +0300 @@ -24,7 +24,7 @@ export.lib : Export native libraries export.lib.debug : Export debug native libraries export.lib.release : Export release native libraries -run.tests : Run JUnit and MT tests +run.tests : Run JUnit and MT tests @@ -38,8 +38,8 @@ - - + + @@ -66,13 +66,13 @@ - + + update="true" includes="eswt*.dll,libeswt*.so"/> @@ -100,6 +100,8 @@ + + @@ -125,6 +127,8 @@ + + @@ -189,11 +193,11 @@ - - + + - + @@ -221,12 +225,18 @@ + + + + + + @@ -251,16 +261,36 @@ tofile="${build.result.dir}/${build.lib.common.config}/${lib.filename}" overwrite="true" verbose="true"/> + + + + + + + + + + + + + + + + + + + - + - + @@ -289,7 +319,8 @@ - + + @@ -364,20 +395,21 @@ - + - - - + + + + - - - - + debug="${javac.debug}" debuglevel="lines,vars,source" verbose="true" failonerror="true"> + + + + - + diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt.qt.linux.x86.se/build.properties --- a/javauis/eswt_qt/org.eclipse.swt.qt.linux.x86.se/build.properties Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt.qt.linux.x86.se/build.properties Fri Jun 11 13:33:44 2010 +0300 @@ -24,7 +24,9 @@ javac.target=1.3 javac.debug=false lib.filename = libeswtqt.so +lib.filename.webkit = libeswtqtwebkit.so lib.makefile = Makefile.linux lib.spec=linux-g++ -jar.filename=eswt-qt.jar -generated.native.dir = generated \ No newline at end of file +jar.filename=eswtqt.jar +generated.native.dir = generated/eswtqt +generated.native.dir.webkit = generated/eswtqtwebkit diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt.qt.linux.x86.se/build.xml --- a/javauis/eswt_qt/org.eclipse.swt.qt.linux.x86.se/build.xml Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt.qt.linux.x86.se/build.xml Fri Jun 11 13:33:44 2010 +0300 @@ -38,7 +38,7 @@ - + @@ -51,7 +51,7 @@ - + @@ -85,6 +85,8 @@ + + @@ -110,6 +112,8 @@ + + @@ -175,8 +179,10 @@ + + - + @@ -200,12 +206,18 @@ + + + + + + @@ -230,6 +242,26 @@ tofile="${build.result.dir}/${build.lib.common.config}/${lib.filename}" overwrite="true" verbose="true"/> + + + + + + + + + + + + + + + + + + + @@ -268,7 +300,8 @@ - + + @@ -353,6 +386,7 @@ + diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt.qt.s60.armv5/.project --- a/javauis/eswt_qt/org.eclipse.swt.qt.s60.armv5/.project Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ - - - org.eclipse.swt.qt.s60.armv5 - - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt.qt.s60.armv5/build.properties --- a/javauis/eswt_qt/org.eclipse.swt.qt.s60.armv5/build.properties Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2007 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -custom = true -ws = qt -os = symbian -arch=x86 -java.edition=me -fragment=org.eclipse.swt.qt.s60.armv5 -version.suffix=3.5.0 -plugin.dir=../org.eclipse.swt -tests.junit.dir=../eclipsetests -tests.mt.dir=../nokiatests -tests.utils.dir=../s60utils -javac.source=1.3 -javac.target=1.3 -javac.debug=false -lib.filename = eswtqt.dll -lib.makefile = bld.inf -lib.spec=symbian-abld -jar.filename=eswt.jar -generated.native.dir = generated -loc.jar=resources.jar -loc.qt.jar=resources_qt.jar \ No newline at end of file diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt.qt.s60.armv5/build.xml --- a/javauis/eswt_qt/org.eclipse.swt.qt.s60.armv5/build.xml Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,560 +0,0 @@ - - - - - -Usage: ant [one of the following:] -build : Build debug + release -build.jar : Build all jars -build.debug : Build all debug binaries -build.release : Build all release binaries -build.lib : Build all native libraries -build.lib.debug : Build debug native libraries -build.lib.release : Build release native libraries -build.tests : Build JUnit and MT tests -clean : Clean everything -clean.jar : Clean all jars -clean.lib : Clean native libraries and object files -clean.lib.debug : Clean debug native libraries and object files -clean.lib.release : Clean release native libraries and object files -export : Export everything -export.jar : Export Java classes packed as jar -export.debug : Export all debug binaries -export.release : Export all release binaries -export.lib : Export native libraries -export.lib.debug : Export debug native libraries -export.lib.release : Export release native libraries -run.tests : Run JUnit and MT tests -make.sis : Create OMJ SIS package - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt.qt.s60.winscw/.project --- a/javauis/eswt_qt/org.eclipse.swt.qt.s60.winscw/.project Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ - - - org.eclipse.swt.qt.s60.winscw - - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt.qt.s60.winscw/build.properties --- a/javauis/eswt_qt/org.eclipse.swt.qt.s60.winscw/build.properties Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2007 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -custom = true -ws = qt -os = symbian -arch=x86 -java.edition=me -fragment=org.eclipse.swt.qt.s60.winscw -version.suffix=3.5.0 -plugin.dir=../org.eclipse.swt -tests.junit.dir=../eclipsetests -tests.mt.dir=../nokiatests -tests.utils.dir=../s60utils -javac.source=1.3 -javac.target=1.3 -javac.debug=false -lib.filename = eswtqt.dll -lib.makefile = bld.inf -lib.spec=symbian-abld -jar.filename=eswt.jar -generated.native.dir = generated -loc.jar=resources.jar -loc.qt.jar=resources_qt.jar -qmake.dir=/epoc32/tools/qt -make.dir=/epoc32/tools \ No newline at end of file diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt.qt.s60.winscw/build.xml --- a/javauis/eswt_qt/org.eclipse.swt.qt.s60.winscw/build.xml Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,602 +0,0 @@ - - - - - -Usage: ant [one of the following:] -build : Build debug + release -build.jar : Build all jars -build.debug : Build all debug binaries -build.release : Build all release binaries -build.lib : Build all native libraries -build.lib.debug : Build debug native libraries -build.lib.release : Build release native libraries -build.tests : Build JUnit and MT tests -clean : Clean everything -clean.jar : Clean all jars -clean.lib : Clean native libraries and object files -clean.lib.debug : Clean debug native libraries and object files -clean.lib.release : Clean release native libraries and object files -export : Export everything -export.jar : Export Java classes packed as jar -export.debug : Export all debug binaries -export.release : Export all release binaries -export.lib : Export native libraries -export.lib.debug : Export debug native libraries -export.lib.release : Export release native libraries -run.tests : Run JUnit and MT tests -make.sis : Create OMJ SIS package - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt.qt.win32.x86.internal/.project --- a/javauis/eswt_qt/org.eclipse.swt.qt.win32.x86.internal/.project Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ - - - org.eclipse.swt.qt.win32.x86.internal - - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt.qt.win32.x86.internal/build.properties --- a/javauis/eswt_qt/org.eclipse.swt.qt.win32.x86.internal/build.properties Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,29 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2007 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -custom = true -ws = qt -os = win32 -arch=x86 -java.edition= se -fragment=org.eclipse.swt.qt.win32.x86.internal -version.suffix=3.5.0 -plugin.dir=../org.eclipse.swt -tests.junit.dir=../eclipsetests -tests.mt.dir=../nokiatests -tests.utils.dir=../s60utils -javac.source=1.3 -javac.target=1.3 -javac.debug=false -lib.filename = eswtqt.dll -lib.makefile = Makefile.win32 -lib.spec=win32-g++ -jar.filename=eswt-qt.jar -generated.native.dir = generated \ No newline at end of file diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt.qt.win32.x86.internal/build.xml --- a/javauis/eswt_qt/org.eclipse.swt.qt.win32.x86.internal/build.xml Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,347 +0,0 @@ - - - - - -Usage: ant [one of the following:] -build : Build debug + release -build.jar : Build all jars -build.debug : Build all debug binaries -build.release : Build all release binaries -build.lib : Build all native libraries -build.lib.debug : Build debug native libraries -build.lib.release : Build release native libraries -build.tests : Build JUnit and MT tests -clean : Clean everything -clean.jar : Clean all jars -clean.lib : Clean native libraries and object files -clean.lib.debug : Clean debug native libraries and object files -clean.lib.release : Clean release native libraries and object files -export : Export everything -export.jar : Export Java classes packed as jar -export.debug : Export all debug binaries -export.release : Export all release binaries -export.lib : Export native libraries -export.lib.debug : Export debug native libraries -export.lib.release : Export release native libraries -run.tests : Run JUnit and MT tests - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse SWT Browser/qt/org/eclipse/swt/browser/QtWebKit.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT Browser/qt/org/eclipse/swt/browser/QtWebKit.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT Browser/qt/org/eclipse/swt/browser/QtWebKit.java Fri Jun 11 13:33:44 2010 +0300 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). + * Copyright (c) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,6 +12,7 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.internal.qt.OS; +import org.eclipse.swt.internal.qt.webkit.OS_webkit; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; @@ -38,7 +39,7 @@ // At this point, browser.handle is the view port of QScrollArea, set by Composite int scrollAreaHandle = Internal_PackageSupport.topHandle(browser); int viewPortHandle = Internal_PackageSupport.handle(browser); - webViewHandle = OS.QWebView_new(); + webViewHandle = OS_webkit.QWebView_new(); OS.QWidget_setParent(webViewHandle, scrollAreaHandle); int layout = OS.QVBoxLayout_new(0); @@ -83,25 +84,25 @@ browser.setData(SET_NO_MOUSE_PROPAGATE_STATE_KEY, new Boolean(true)); browser.setData(SET_EMBEDDED_SCROLLBARS_STATE_KEY, new Boolean(true)); - int handler1 = OS.SignalHandler_new(webViewHandle, this, OS.QSIGNAL_WEBVIEW_LOADFINISHED); + int handler1 = OS.SignalForwarder_new(webViewHandle, this, OS.QSIGNAL_WEBVIEW_LOADFINISHED); OS.QObject_connectOrThrow(webViewHandle, "loadFinished(bool)", handler1, "widgetSignal(bool)", OS.QT_AUTOCONNECTION); - int handler2 = OS.SignalHandler_new(webViewHandle, this, OS.QSIGNAL_WEBVIEW_LOADPROGRESS); + int handler2 = OS.SignalForwarder_new(webViewHandle, this, OS.QSIGNAL_WEBVIEW_LOADPROGRESS); OS.QObject_connectOrThrow(webViewHandle, "loadProgress(int)", handler2, "widgetSignal(int)", OS.QT_AUTOCONNECTION); - int handler3 = OS.SignalHandler_new(webViewHandle, this, OS.QSIGNAL_WEBVIEW_LOADSTARTED); + int handler3 = OS.SignalForwarder_new(webViewHandle, this, OS.QSIGNAL_WEBVIEW_LOADSTARTED); OS.QObject_connectOrThrow(webViewHandle, "loadStarted()", handler3, "widgetSignal()", OS.QT_AUTOCONNECTION); - int handler4 = OS.SignalHandler_new(webViewHandle, this, OS.QSIGNAL_WEBVIEW_STATUSBARMESSAGE); + int handler4 = OS.SignalForwarder_new(webViewHandle, this, OS.QSIGNAL_WEBVIEW_STATUSBARMESSAGE); OS.QObject_connectOrThrow(webViewHandle, "statusBarMessage(const QString&)", handler4, "widgetSignal(const QString&)", OS.QT_AUTOCONNECTION); - int handler5 = OS.SignalHandler_new(webViewHandle, this, OS.QSIGNAL_WEBVIEW_TITLECHANGED); + int handler5 = OS.SignalForwarder_new(webViewHandle, this, OS.QSIGNAL_WEBVIEW_TITLECHANGED); OS.QObject_connectOrThrow(webViewHandle, "titleChanged(const QString&)", handler5, "widgetSignal(const QString&)", OS.QT_AUTOCONNECTION); - int handler6 = OS.SignalHandler_new(webViewHandle, this, OS.QSIGNAL_WEBVIEW_URLCHANGED); + int handler6 = OS.SignalForwarder_new(webViewHandle, this, OS.QSIGNAL_WEBVIEW_URLCHANGED); OS.QObject_connectOrThrow(webViewHandle, "urlChanged(const QUrl&)", handler6, "widgetSignal(const QUrl&)", OS.QT_AUTOCONNECTION); - int handler7 = OS.SignalHandler_new(webViewHandle, this, OS.QSIGNAL_WEBVIEW_LINKCLICKED); + int handler7 = OS.SignalForwarder_new(webViewHandle, this, OS.QSIGNAL_WEBVIEW_LINKCLICKED); OS.QObject_connectOrThrow(webViewHandle, "linkClicked(const QUrl&)", handler7, "widgetSignal(const QUrl&)", OS.QT_AUTOCONNECTION); } @@ -110,10 +111,10 @@ * @see WebBrowser */ public boolean back() { - if (OS.QWebView_swt_canGoBack(webViewHandle)) { + if (OS_webkit.QWebView_swt_canGoBack(webViewHandle)) { if (sendLocationEventChanging((int)System.currentTimeMillis(), - OS.QWebView_swt_backUrl(webViewHandle))) { - OS.QWebView_back(webViewHandle); + OS_webkit.QWebView_swt_backUrl(webViewHandle))) { + OS_webkit.QWebView_back(webViewHandle); return true; } } @@ -124,17 +125,17 @@ * @see WebBrowser */ public boolean execute(String script) { - return OS.QWebView_swt_evaluateJavaScript(webViewHandle, script); + return OS_webkit.QWebView_swt_evaluateJavaScript(webViewHandle, script); } /** * @see WebBrowser */ public boolean forward() { - if (OS.QWebView_swt_canGoForward(webViewHandle)) { + if (OS_webkit.QWebView_swt_canGoForward(webViewHandle)) { if (sendLocationEventChanging((int)System.currentTimeMillis(), - OS.QWebView_swt_forwardUrl(webViewHandle))) { - OS.QWebView_forward(webViewHandle); + OS_webkit.QWebView_swt_forwardUrl(webViewHandle))) { + OS_webkit.QWebView_forward(webViewHandle); return true; } } @@ -159,21 +160,21 @@ * @see WebBrowser */ public String getUrl() { - return OS.QWebView_url(webViewHandle); + return OS_webkit.QWebView_url(webViewHandle); } /** * @see WebBrowser */ public boolean isBackEnabled() { - return OS.QWebView_swt_canGoBack(webViewHandle); + return OS_webkit.QWebView_swt_canGoBack(webViewHandle); } /** * @see WebBrowser */ public boolean isForwardEnabled() { - return OS.QWebView_swt_canGoForward(webViewHandle); + return OS_webkit.QWebView_swt_canGoForward(webViewHandle); } /** @@ -181,8 +182,8 @@ */ public void refresh() { if (sendLocationEventChanging((int)System.currentTimeMillis(), - OS.QWebView_url(webViewHandle))) { - OS.QWebView_reload(webViewHandle); + OS_webkit.QWebView_url(webViewHandle))) { + OS_webkit.QWebView_reload(webViewHandle); } } @@ -191,7 +192,7 @@ */ public boolean setText(String html) { if (sendLocationEventChanging((int)System.currentTimeMillis(), "about:blank")) { - OS.QWebView_setHtml(webViewHandle, html); + OS_webkit.QWebView_setHtml(webViewHandle, html); return true; } else { @@ -204,7 +205,7 @@ */ public boolean setUrl(String url) { if (sendLocationEventChanging((int)System.currentTimeMillis(), url)) { - OS.QWebView_setUrl(webViewHandle, url); + OS_webkit.QWebView_setUrl(webViewHandle, url); return true; } else { @@ -216,7 +217,7 @@ * @see WebBrowser */ public void stop() { - OS.QWebView_stop(webViewHandle); + OS_webkit.QWebView_stop(webViewHandle); } final boolean eventProcess( int widgetHandle, int eventType, int time, diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Resource.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Resource.java Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,99 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.swt.graphics; - -import org.eclipse.swt.*; - -/** - * This class is the abstract superclass of all graphics resource objects. - * Resources created by the application must be disposed. - *

                - * IMPORTANT: This class is intended to be subclassed only - * within the SWT implementation. However, it has not been marked - * final to allow those outside of the SWT development team to implement - * patched versions of the class in order to get around specific - * limitations in advance of when those limitations can be addressed - * by the team. Any class built using subclassing to access the internals - * of this class will likely fail to compile or run between releases and - * may be strongly platform specific. Subclassing should not be attempted - * without an intimate and detailed understanding of the workings of the - * hierarchy. No support is provided for user-written classes which are - * implemented as subclasses of this class. - *

                - * - * @see #dispose - * @see #isDisposed - * - * @since 3.1 - */ -public abstract class Resource { - - /** - * the device where this resource was created - */ - Device device; - -Resource() { -} - -Resource(Device device) { - if (device == null) device = Device.getDevice(); - if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); - this.device = device; -} - -void destroy() { -} - -/** - * Disposes of the operating system resources associated with - * this resource. Applications must dispose of all resources - * which they allocate. - */ -public void dispose() { - if (device == null) return; - if (device.isDisposed()) return; - destroy(); - if (device.tracking) device.dispose_Object(this); - device = null; -} - -/** - * Returns the Device where this resource was - * created. - * - * @return Device the device of the receiver - * - * @since 3.2 - */ -public Device getDevice() { - Device device = this.device; - if (device == null || isDisposed ()) SWT.error (SWT.ERROR_GRAPHIC_DISPOSED); - return device; -} - -void init() { - if (device.tracking) device.new_Object(this); -} - -/** - * Returns true if the resource has been disposed, - * and false otherwise. - *

                - * This method gets the dispose state for the resource. - * When a resource has been disposed, it is an error to - * invoke any other method using the resource. - * - * @return true when the resource is disposed and false otherwise - */ -public abstract boolean isDisposed(); - -} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/CaptionedControl.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/CaptionedControl.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/CaptionedControl.java Fri Jun 11 13:33:44 2010 +0300 @@ -1,12 +1,12 @@ /******************************************************************************* * Copyright (c) 2004, 2008 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. This program and the accompanying materials + * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: - * Yu You (Nokia Corp.)- initial API specification + * Yu You (Nokia Corp.)- initial API specification * Nokia Corporation - S60 implementation * Nokia Corporation - QT implementation *******************************************************************************/ @@ -26,7 +26,7 @@ import java.lang.Math; /** - * + * * A CaptionedControl is used to display a label (caption) in front of a * control. An optional trailing text can be used after the control, for * example, to indicate units of measurement. @@ -37,7 +37,7 @@ * order for the captions is determined by the SWT.LEFT_TO_RIGHT * and SWT.RIGHT_TO_LEFT styles hints. *

                - * + * *

                * CaptionedControl does not support nested CaptionedControls. An exception will * be thrown when an instance of CaptionedControl is given as the constructor's @@ -59,7 +59,7 @@ * control.getTrailingText("cm"); * *

                - * + * *

                *

                *
                Styles:
                @@ -75,7 +75,7 @@ *

                * IMPORTANT: This class is not intended to be subclassed. *

                - * + * */ public final class CaptionedControl extends Composite { boolean initPhase; @@ -93,7 +93,7 @@ public void qt_signal_qapplication_focusChanged(int old, int now) { ((CaptionedControl)w).qt_signal_qapplication_focusChanged(old, now); } - + public void removeControl(Control control) { ((CaptionedControl)w).removeControl(control); } @@ -102,18 +102,18 @@ class CaptionedControlLayout extends Layout { int checkHint(int hint, int spacing) { - + // Adjust a hint by spacing, check that result is not negative if (hint == SWT.DEFAULT) { return hint; } - + hint -= spacing; - + if (hint < 0) { hint = 0; } - + return hint; } @@ -122,7 +122,7 @@ Point res = new Point(0, 0); int wHint = checkHint(hint, 2 * margin); int hHint = checkHint(hint2, 2 * margin); - + CaptionedControlLayoutData data = getData(wHint, hHint); if ((getStyle() & SWT.HORIZONTAL) != 0) { if (hint == SWT.DEFAULT) { @@ -152,7 +152,7 @@ res.y = data.row1.y + Math.max(hint2, data.trail.y); } } - + // Since the margins are big enough, adding the border is pointless. res.x += 2 * margin; res.y += 2 * margin; @@ -162,30 +162,30 @@ protected void layout(Composite composite, boolean flushCache) { - Point size = composite.getSize(); + Point size = composite.getSize(); if (size.x <= 0 || size.y <= 0) { return; } - + CaptionedControlLayoutData data = getData(size.x, size.y); - + int x = margin; int y = margin; int w = size.x - 2 * margin; int h = 0; - + if ((getStyle() & SWT.HORIZONTAL) != 0) { h = size.y - 2 * margin; } else { h = data.row1.y; } - + if (h < 0) h = 0; - + imageLabel.setBounds(x, y, data.img.x, h); x += data.img.x; - + titleLabel.setBounds(x, y, data.title.x, h); x += data.title.x; @@ -196,12 +196,12 @@ h = size.y - data.row1.y - 2 * margin; if (h < 0) h = 0; x = margin; - + if (child == null) { trailW = data.row1.x - 2 * margin; } } - + int childW = 0; if (child != null) { if ((getStyle() & SWT.HORIZONTAL) != 0) { @@ -216,8 +216,8 @@ child.setBounds(x, y, childW, h); x += childW; - } - + } + trailLabel.setBounds(x, y, trailW, h); } @@ -229,10 +229,10 @@ CaptionedControlLayoutData res = new CaptionedControlLayoutData(); int extra = spacing * 2; - + wHint = checkHint(wHint, extra); hHint = checkHint(hHint, extra); - + if ((getStyle() & SWT.HORIZONTAL) != 0) { if (imageLabel.getImage() != null) { res.img = imageLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT); @@ -245,14 +245,14 @@ if (trail != null && trail.length() > 0) { res.trail = trailLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT); } - + } else { if (imageLabel.getImage() != null) { res.img = imageLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT); } String caption = titleLabel.getText(); if (caption != null && caption.length() > 0) { - + if (wHint != SWT.DEFAULT) { int hint = wHint - res.img.x; if (hint < 0) { @@ -263,15 +263,15 @@ res.title = titleLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT); } } - + String trail = trailLabel.getText(); if (trail != null && trail.length() > 0) { res.trail = trailLabel.computeSize(SWT.DEFAULT, SWT.DEFAULT); } - - + + } - + if (res.img.x > 0 && res.img.y > 0) { res.img.x += extra; res.img.y += extra; @@ -284,11 +284,11 @@ res.trail.x += extra; res.trail.y += extra; } - + if ((getStyle() & SWT.HORIZONTAL) != 0) { if (child != null) { res.child = child.computeSize(SWT.DEFAULT, SWT.DEFAULT); - + if (wHint != SWT.DEFAULT) { res.child.x = wHint - res.img.x - res.title.x - res.trail.x; if (res.child.x < 0) { @@ -303,13 +303,13 @@ } else { res.child = child.computeSize(SWT.DEFAULT, SWT.DEFAULT); } - + if (hHint != SWT.DEFAULT) { res.child.y = hHint - res.row1.y; } } } - + if ((getStyle() & SWT.HORIZONTAL) != 0) { res.row1.x = res.img.x + res.title.x + res.child.x + res.trail.x; res.row1.y = Math.max(res.row1.y, res.img.y); @@ -318,24 +318,24 @@ res.row1.y = Math.max(res.row1.y, res.child.y); } else { - // If the first row would expand to be bigger than the contained + // If the first row would expand to be bigger than the contained // control, adjust title caption width. if ((child != null) && (res.img.x + res.title.x > res.child.x + res.trail.x)) { int width = res.child.x + res.trail.x - res.img.x; - + if (width < 0) { width = 0; } - + Point newTitle = titleLabel.computeSize(width, SWT.DEFAULT); - + // Adjust title size only if the adjustment causes line count to // change (i.e. title height increases) if (newTitle.y > res.title.y) { res.title = newTitle; } } - + res.row1.x = res.img.x + res.title.x; res.row1.y = Math.max(res.row1.y, res.img.y); res.row1.y = Math.max(res.row1.y, res.title.y); @@ -343,7 +343,7 @@ res.row2.y = Math.max(res.row2.y, res.trail.y); res.row2.y = Math.max(res.row2.y, res.child.y); } - + return res; } } @@ -376,13 +376,13 @@ * style constants. The class description lists the style constants that are * applicable to the class. Style bits are also inherited from superclasses. *

                - * + * * @param parent * a widget which will be the parent of the new instance (cannot * be null) * @param style * the style of widget to construct - * + * * @exception IllegalArgumentException *
                  *
                • ERROR_NULL_ARGUMENT - if the parent is null
                • @@ -394,12 +394,12 @@ *
                • ERROR_INVALID_SUBCLASS - if this class is not an * allowed subclass
                • *
                - * + * * @see SWT#LEFT_TO_RIGHT * @see SWT#RIGHT_TO_LEFT */ public CaptionedControl (Composite parent, int style) { - super(parent, Internal_PackageSupport.checkBits(style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0), 0, + super(parent, Internal_PackageSupport.checkBits(style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0), 0, new CaptionedControlPackageProxy(), false); if (parent instanceof CaptionedControl) { SWT.error(SWT.ERROR_INVALID_PARENT); @@ -414,8 +414,8 @@ } trailLabel = new Label(this, SWT.CENTER); initPhase = false; - - + + layout = new CaptionedControlLayout(); super.setLayout(layout); @@ -555,13 +555,13 @@ public Rectangle computeTrim(int x, int y, int width, int height) { checkWidget(); - + Rectangle res = new Rectangle(0, 0, 0, 0); - + if (layout != null) { CaptionedControlLayoutData data = layout.getData(); - - if ((getStyle() & SWT.HORIZONTAL) != 0) { + + if ((getStyle() & SWT.HORIZONTAL) != 0) { res.width = data.img.x + data.title.x + data.trail.x + width; res.height = height; res.x = x - data.img.x - data.title.x - margin; @@ -577,12 +577,12 @@ else { res.width = width; res.height = height; - res.x = x; + res.x = x; res.y = y; } res.width += 2 * margin; res.height += 2 * margin; - + return res; } @@ -687,7 +687,7 @@ Control[] children = super.getChildren(); Control[] res = new Control[children.length - 3]; for (int i = 0, j = 0; i < children.length; i++) { - if (children[i] != imageLabel + if (children[i] != imageLabel && children[i] != titleLabel && children[i] != trailLabel ) { res[j] = children[i]; @@ -699,15 +699,15 @@ public Rectangle getClientArea() { checkWidget(); - + Rectangle res = new Rectangle(0, 0, 0, 0); - + Point size = getSize(); size.x -= 2 * margin; - size.y -= 2 * margin; - + size.y -= 2 * margin; + if (layout != null) { - + CaptionedControlLayoutData data = layout.getData(size.x, size.y); if ((getStyle() & SWT.HORIZONTAL) != 0) { res.width = size.x - data.img.x - data.title.x - data.trail.x; @@ -716,7 +716,7 @@ res.y = margin; } else { - res.width = size.x - data.trail.x; + res.width = size.x - data.trail.x; res.height = size.y - data.row1.y; res.x = margin; res.y = data.row1.y + margin; @@ -726,19 +726,19 @@ res.width = size.x; res.height = size.y; } - + if (res.width < 0) res.width = 0; if (res.height < 0) res.height = 0; - + return res; } /** * Returns the CaptionedControl's icon image, or null if it has never been * set. - * + * * @return the icon image or null. - * + * * @exception SWTException *
                  *
                • ERROR_WIDGET_DISPOSED - if the receiver has been @@ -756,7 +756,7 @@ /** * Gets the caption text, which will be an empty string if it has never been * set. - * + * * @return The label text. * @exception SWTException *
                    @@ -765,7 +765,7 @@ *
                  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the parent
                  • *
                  - * + * * @see #setText(java.lang.String) */ public String getText () { @@ -776,9 +776,9 @@ /** * Gets the trailing text, which will be an empty string if it has never * been set. - * + * * @return The trailing text. - * + * * @exception SWTException *
                    *
                  • ERROR_WIDGET_DISPOSED - if the receiver has been @@ -786,7 +786,7 @@ *
                  • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the parent
                  • *
                  - * + * * @see #setTrailingText(java.lang.String) */ public String getTrailingText () { @@ -847,19 +847,18 @@ /** * Sets the image as an icon to the CaptionedControl. The icon can co-exist * with caption text. The icon position is platform-dependent. - * + * *

                  * The parameter can be null indicating that no image should be displayed. * The implementation will adjust the image size to make it best fit the * CaptionedControl. *

                  - * + * * @param image * the image to display on the receiver - * + * * @exception IllegalArgumentException *
                    - *
                  • ERROR_NULL_ARGUMENT - if the image is null
                  • *
                  • ERROR_INVALID_ARGUMENT - if the image has been * disposed
                  • *
                  @@ -870,13 +869,10 @@ *
                • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the receiver
                • *
                - * + * */ public void setImage (Image image) { checkWidget(); - if (image == null) { - SWT.error(SWT.ERROR_NULL_ARGUMENT); - } if (image != null && image.isDisposed()) { SWT.error(SWT.ERROR_INVALID_ARGUMENT); } @@ -892,10 +888,10 @@ /** * Sets the caption label - * + * * @param string * the new caption label - * + * * @throws java.lang.IllegalArgumentException * ERROR_NULL_ARGUMENT if the text is null * @exception SWTException @@ -918,10 +914,10 @@ /** * Sets the trailing label - * + * * @param string * the new trailing label - * + * * @exception IllegalArgumentException *
                  *
                • ERROR_NULL_ARGUMENT - if the string is null
                • @@ -933,7 +929,7 @@ *
                • ERROR_THREAD_INVALID_ACCESS - if not called from the * thread that created the parent
                • *
                - * + * * @see #getTrailingText */ public void setTrailingText (java.lang.String string) { @@ -946,13 +942,12 @@ } private final int handle() { - return Internal_PackageSupport.handle(this); + return Internal_PackageSupport.handle(this); } void hookFocusChangedEvent() { focusSignalProxy = OS.SignalHandler_new(topHandle(), - Internal_PackageSupport.display(this), OS.QSIGNAL_QAPPLICATION_FOCUSCHANGED_TO_WIDDGET); OS.QObject_connectOrThrow(OS.QCoreApplication_instance(), "focusChanged(QWidget*, QWidget*)", focusSignalProxy, diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/Command.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/Command.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/Command.java Fri Jun 11 13:33:44 2010 +0300 @@ -432,7 +432,7 @@ void hookEvents() { Internal_PackageSupport.hookEvents(this); if ( type == Command.COMMANDGROUP ) return; - int triggeredProxy = OS.SignalHandler_new(handle(), Internal_PackageSupport.display(this), OS.QSIGNAL_TRIGGERED); + int triggeredProxy = OS.SignalHandler_new(handle(), OS.QSIGNAL_TRIGGERED); OS.QObject_connectOrThrow(handle(), "triggered(bool)", triggeredProxy, "widgetSignal(bool)", OS.QT_AUTOCONNECTION); } @@ -450,7 +450,7 @@ parent.addCommand( this ); }else{ Internal_PackageSupport.addCommand( this.control, this ); - Internal_PackageSupport.display(this).commandArranger.commandAdded( this ); + Internal_PackageSupport.commandArranger().commandAdded( this ); } } @@ -571,7 +571,7 @@ */ public boolean isDefaultCommand() { checkWidget (); - return Internal_PackageSupport.display(this).commandArranger.getDefaultCommand() == this; + return Internal_PackageSupport.commandArranger().getDefaultCommand() == this; } /** @@ -659,7 +659,7 @@ if ((accelerator & SWT.SHIFT) != 0) mask |= OS.QT_SHIFTMODIFIER; if ((accelerator & SWT.CONTROL) != 0) mask |= OS.QT_CONTROLMODIFIER; int keysym = accelerator & SWT.KEY_MASK; - int newKey = Display.untranslateKey (keysym); + int newKey = Internal_PackageSupport.untranslateKey (keysym); if (newKey != 0) { keysym = newKey; } @@ -677,7 +677,7 @@ checkWidget (); //Commmands that are in a command group can not be default commands if(parent != null ) return; - Internal_PackageSupport.display(this).commandArranger.setDefaultCommand(this); + Internal_PackageSupport.commandArranger().setDefaultCommand(this); } /** @@ -809,7 +809,7 @@ void releaseWidget () { Internal_PackageSupport.releaseWidget(this); - if( parent == null ) Internal_PackageSupport.display(this).commandArranger.commandRemoved( this ); + if( parent == null ) Internal_PackageSupport.commandArranger().commandRemoved( this ); accelerator = 0; parent = null; children = null; diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/ConstrainedText.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/ConstrainedText.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/ConstrainedText.java Fri Jun 11 13:33:44 2010 +0300 @@ -853,18 +853,18 @@ void hookEvents () { Internal_PackageSupport.hookEvents(this); int handle = handle(); - int handler = OS.SignalHandler_new(handle, Internal_PackageSupport.display(this), OS.QSIGNAL_TEXT_CHANGED); + int handler = OS.SignalHandler_new(handle, OS.QSIGNAL_TEXT_CHANGED); OS.QObject_connectOrThrow(handle, "textChanged(const QString&)", handler, "widgetSignal(const QString&)", OS.QT_AUTOCONNECTION); - handler = OS.SignalHandler_new(handle, Internal_PackageSupport.display(this), OS.QSIGNAL_RETURN_PRESSED); + handler = OS.SignalHandler_new(handle, OS.QSIGNAL_RETURN_PRESSED); OS.QObject_connectOrThrow(handle, "returnPressed()", handler, "widgetSignal()", OS.QT_AUTOCONNECTION); if(isExtended()) { - handler = OS.SignalHandler_new(handle, Internal_PackageSupport.display(this), OS.QSIGNAL_TEXT_CURSORPOSITIONCHANGED); + handler = OS.SignalHandler_new(handle, OS.QSIGNAL_TEXT_CURSORPOSITIONCHANGED); OS.QObject_connectOrThrow(handle, "cursorPositionChanged(int, int)", handler, "widgetSignal(int, int)", OS.QT_AUTOCONNECTION); - handler = OS.SignalHandler_new(handle, Internal_PackageSupport.display(this), OS.QSIGNAL_TEXT_SELECTIONCHANGED); + handler = OS.SignalHandler_new(handle, OS.QSIGNAL_TEXT_SELECTIONCHANGED); OS.QObject_connectOrThrow(handle, "selectionChanged()", handler, "widgetSignal()", OS.QT_AUTOCONNECTION); } diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/DateEditor.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/DateEditor.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/DateEditor.java Fri Jun 11 13:33:44 2010 +0300 @@ -427,7 +427,7 @@ } void hookEvents() { - int signalProxy = OS.SignalHandler_new(handle(), Internal_PackageSupport.display(this), + int signalProxy = OS.SignalHandler_new(handle(), OS.QSIGNAL_DATETIMEEDIT_CHANGED); OS.QObject_connectOrThrow(handle(), "dateTimeChanged(const QDateTime&)", signalProxy, "widgetSignal(const QDateTime&)", diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/ListBox.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/ListBox.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/ListBox.java Fri Jun 11 13:33:44 2010 +0300 @@ -547,8 +547,7 @@ void hookEvents() { if (selectionModelHandle != 0) { - int signalProxy = OS.SignalHandler_new(topHandle(), - Internal_PackageSupport.display(this), OS.QSIGNAL_SELECTIONCHANGED); + int signalProxy = OS.SignalHandler_new(topHandle(), OS.QSIGNAL_SELECTIONCHANGED); OS.QObject_connectOrThrow( selectionModelHandle, "selectionChanged( const QItemSelection&, const QItemSelection& )", @@ -556,8 +555,7 @@ "widgetSignal( const QItemSelection&, const QItemSelection& )", OS.QT_AUTOCONNECTION); - int itemActivatedSignalProxy = OS.SignalHandler_new(topHandle(), - Internal_PackageSupport.display(this), OS.QSIGNAL_ABSTRACTITEMVIEW_ACTIVATED); + int itemActivatedSignalProxy = OS.SignalHandler_new(topHandle(), OS.QSIGNAL_ABSTRACTITEMVIEW_ACTIVATED); OS.QObject_connectOrThrow(topHandle(), "activated(const QModelIndex& )", itemActivatedSignalProxy, "widgetSignal(const QModelIndex&)", OS.QT_AUTOCONNECTION); diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/ListView.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/ListView.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/ListView.java Fri Jun 11 13:33:44 2010 +0300 @@ -1504,11 +1504,11 @@ void hookEvents () { Internal_PackageSupport.hookEvents(this); int handle = topHandle(); - int signalProxySel = OS.SignalHandler_new(handle, Internal_PackageSupport.display(this), + int signalProxySel = OS.SignalHandler_new(handle, OS.QSIGNAL_LIST_ITEMSELECTION_CHANGED); OS.QObject_connectOrThrow(handle, "itemSelectionChanged()", signalProxySel, "widgetSignal()", OS.QT_AUTOCONNECTION); - int signalProxyDefSel = OS.SignalHandler_new(handle, Internal_PackageSupport.display(this), + int signalProxyDefSel = OS.SignalHandler_new(handle, OS.QSIGNAL_LIST_ITEM_DOUBLECLICKED); OS.QObject_connectOrThrow(handle, "itemDoubleClicked(QListWidgetItem*)", signalProxyDefSel, "widgetSignal(QListWidgetItem*)", OS.QT_AUTOCONNECTION); diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/MobileDevice.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/MobileDevice.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/MobileDevice.java Fri Jun 11 13:33:44 2010 +0300 @@ -260,7 +260,7 @@ } private static void hookEvents() { - int screenSignalProxy = OS.SignalHandler_new(desktopWidgetHandle, getDisplay(), OS.QSIGNAL_QDESKTOPWIDGET_SCREENCOUNTCHANGED); + int screenSignalProxy = OS.SignalHandler_new(desktopWidgetHandle, OS.QSIGNAL_QDESKTOPWIDGET_SCREENCOUNTCHANGED); OS.QObject_connectOrThrow(desktopWidgetHandle, "screenCountChanged(int)", screenSignalProxy, "widgetSignal(int)", OS.QT_AUTOCONNECTION); } diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/MultiPageDialog.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/MultiPageDialog.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/MultiPageDialog.java Fri Jun 11 13:33:44 2010 +0300 @@ -177,7 +177,7 @@ void hookEvents() { Internal_PackageSupport.hookEvents(this); - int signalProxy = OS.SignalHandler_new(handle(), Internal_PackageSupport.display(this), + int signalProxy = OS.SignalHandler_new(handle(), OS.QSIGNAL_CURRENT_TAB_CHANGED); OS.QObject_connectOrThrow(handle(), "currentChanged(int)", signalProxy, "widgetSignal(int)", OS.QT_AUTOCONNECTION); diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/SortedList.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/SortedList.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/SortedList.java Fri Jun 11 13:33:44 2010 +0300 @@ -15,7 +15,6 @@ package org.eclipse.ercp.swt.mobile; import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Internal_PackageSupport; import org.eclipse.swt.widgets.Scrollable; import org.eclipse.swt.widgets.Composite; @@ -628,23 +627,22 @@ void hookEvents () { Internal_PackageSupport.hookEvents(this); - Display display = Internal_PackageSupport.display(this); int scrollAreaHandle = scrollAreaHandle(); - int signalProxy1 = OS.SignalHandler_new(scrollAreaHandle, display, + int signalProxy1 = OS.SignalHandler_new(scrollAreaHandle, OS.QSIGNAL_LIST_ITEMSELECTION_CHANGED); OS.QObject_connectOrThrow(scrollAreaHandle, "itemSelectionChanged()", signalProxy1, "widgetSignal()", OS.QT_AUTOCONNECTION); - int signalProxy2 = OS.SignalHandler_new(scrollAreaHandle, display, + int signalProxy2 = OS.SignalHandler_new(scrollAreaHandle, OS.QSIGNAL_LIST_ITEM_DOUBLECLICKED); OS.QObject_connectOrThrow(scrollAreaHandle, "itemDoubleClicked(QListWidgetItem*)", signalProxy2, "widgetSignal(QListWidgetItem*)", OS.QT_AUTOCONNECTION); int signalProxy3 = OS.SignalHandler_new(Internal_PackageSupport.topHandle(this), - display, OS.QSIGNAL_LIST_ITEM_ACTIVATED); + OS.QSIGNAL_LIST_ITEM_ACTIVATED); OS.QObject_connectOrThrow(scrollAreaHandle, "itemActivated(QListWidgetItem* )", signalProxy3, "widgetSignal(QListWidgetItem* )", OS.QT_AUTOCONNECTION); if (editorHandle != 0) { - int signalProxy4 = OS.SignalHandler_new(editorHandle, display, OS.QSIGNAL_TEXT_CHANGED); + int signalProxy4 = OS.SignalHandler_new(editorHandle, OS.QSIGNAL_TEXT_CHANGED); OS.QObject_connectOrThrow(editorHandle, "textChanged(const QString&)", signalProxy4, "widgetSignal(const QString&)", OS.QT_AUTOCONNECTION); } diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/TextExtension.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/TextExtension.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/TextExtension.java Fri Jun 11 13:33:44 2010 +0300 @@ -351,7 +351,7 @@ SWT.getMessage("fetch_email"), OS.CNT_ACTIONALL, OS.CNT_DISPLAYALL); Display display = Internal_PackageSupport.display(this); - int handler = OS.SignalHandler_new(topHandle(), display, + int handler = OS.SignalHandler_new(topHandle(), OS.QSIGNAL_REQUESTCOMPLETED); OS.QObject_connectOrThrow(serviceRequest, "requestCompleted(QVariant)", @@ -389,7 +389,7 @@ SWT.getMessage("fetch_phonenumber"), OS.CNT_ACTIONALL, OS.CNT_DISPLAYALL); Display display = Internal_PackageSupport.display(this); - int handler = OS.SignalHandler_new(topHandle(), display, + int handler = OS.SignalHandler_new(topHandle(), OS.QSIGNAL_REQUESTCOMPLETED); OS.QObject_connectOrThrow(serviceRequest, "requestCompleted(QVariant)", @@ -458,7 +458,7 @@ Internal_PackageSupport.hookEvents(this); if(isExtended()) { Display display = Internal_PackageSupport.display(this); - int handler1 = OS.SignalHandler_new(topHandle(), display, OS.QSIGNAL_TEXT_CURSORPOSITIONCHANGED); + int handler1 = OS.SignalHandler_new(topHandle(), OS.QSIGNAL_TEXT_CURSORPOSITIONCHANGED); String s; if(Internal_PackageSupport.variant(this) == TextUtils.LINE_EDIT) { s = "cursorPositionChanged(int, int)"; @@ -467,7 +467,7 @@ } OS.QObject_connectOrThrow(topHandle(), s, handler1, "widgetSignal()", OS.QT_AUTOCONNECTION); - int handler2 = OS.SignalHandler_new(topHandle(), display, OS.QSIGNAL_TEXT_SELECTIONCHANGED); + int handler2 = OS.SignalHandler_new(topHandle(), OS.QSIGNAL_TEXT_SELECTIONCHANGED); OS.QObject_connectOrThrow(topHandle(), "selectionChanged()", handler2, "widgetSignal()", OS.QT_AUTOCONNECTION); } diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/graphics/Color.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/graphics/Color.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/graphics/Color.java Fri Jun 11 13:33:44 2010 +0300 @@ -116,7 +116,7 @@ public void dispose() { if (device == null) return; if (device.isDisposed()) return; - if (device.tracking) device.dispose_Object(this); + if (Device.tracking) device.dispose_Object(this); device = null; handle = -1; } @@ -214,8 +214,6 @@ * Invokes platform specific functionality to allocate a new color. */ void init(Device device, int red, int green, int blue) { - - if (device == null) device = Device.getDevice(); if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); this.device = device; @@ -226,7 +224,7 @@ } handle = (red & 0xFF) | ((green & 0xFF) << 8) | ((blue & 0xFF) << 16); // Keep this after dealing with all exceptions! - if (device.tracking) device.new_Object(this); + if (Device.tracking) device.new_Object(this); } /** diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/graphics/Device.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/graphics/Device.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/graphics/Device.java Fri Jun 11 13:33:44 2010 +0300 @@ -29,77 +29,60 @@ public abstract class Device implements Drawable { // Native device handle - int paintDevice; + static int paintDevice; // Device instance tracking static Device[] Devices = new Device[4]; // Debugging public static boolean DEBUG; - boolean debug = DEBUG; - boolean tracking = DEBUG; - Error [] errors; - Object [] objects; - Object trackingLock; + static boolean debug = DEBUG; + static boolean tracking = DEBUG; + static Error [] errors; + static Object [] objects; + static Object trackingLock; // Themed system colors - Color COLOR_LIST_BACKGROUND; - Color COLOR_LIST_FOREGROUND; - Color COLOR_LIST_SELECTION; - Color COLOR_LIST_SELECTION_TEXT; - Color COLOR_TITLE_BACKGROUND; - Color COLOR_TITLE_BACKGROUND_GRADIENT; - Color COLOR_TITLE_FOREGROUND; - Color COLOR_TITLE_INACTIVE_BACKGROUND; - Color COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT; - Color COLOR_TITLE_INACTIVE_FOREGROUND; - Color COLOR_WIDGET_BACKGROUND; - Color COLOR_WIDGET_BORDER; - Color COLOR_WIDGET_DARK_SHADOW; - Color COLOR_WIDGET_FOREGROUND; - Color COLOR_WIDGET_HIGHLIGHT_SHADOW; - Color COLOR_WIDGET_LIGHT_SHADOW; - Color COLOR_WIDGET_NORMAL_SHADOW; + static Color COLOR_LIST_BACKGROUND; + static Color COLOR_LIST_FOREGROUND; + static Color COLOR_LIST_SELECTION; + static Color COLOR_LIST_SELECTION_TEXT; + static Color COLOR_TITLE_BACKGROUND; + static Color COLOR_TITLE_BACKGROUND_GRADIENT; + static Color COLOR_TITLE_FOREGROUND; + static Color COLOR_TITLE_INACTIVE_BACKGROUND; + static Color COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT; + static Color COLOR_TITLE_INACTIVE_FOREGROUND; + static Color COLOR_WIDGET_BACKGROUND; + static Color COLOR_WIDGET_BORDER; + static Color COLOR_WIDGET_DARK_SHADOW; + static Color COLOR_WIDGET_FOREGROUND; + static Color COLOR_WIDGET_HIGHLIGHT_SHADOW; + static Color COLOR_WIDGET_LIGHT_SHADOW; + static Color COLOR_WIDGET_NORMAL_SHADOW; - // Disposed state flag + // Disposed state flag, instance data protected boolean disposed; + // Initialized state flag + static boolean initialized; + + // Internal state flag telling if this is the application's instance + // or an internal one + boolean internal; + // Handle to the null Icon. Eventually set by Image.internal_getNullIconHandle static int nullIconHandle; // Default height for FontData static final int FONT_DEF_HEIGHT = 12; - - /* - * TEMPORARY CODE. When a graphics object is - * created and the device parameter is null, - * the current Display is used. This presents - * a problem because SWT graphics does not - * reference classes in SWT widgets. The correct - * fix is to remove this feature. Unfortunately, - * too many application programs rely on this - * feature. - * - * This code will be removed in the future. - */ - protected static Device CurrentDevice; - protected static Runnable DeviceFinder; + static { try { Class.forName ("org.eclipse.swt.widgets.Display"); } catch (Throwable e) {} } -/* -* TEMPORARY CODE. -*/ -static synchronized Device getDevice () { - if (DeviceFinder != null) DeviceFinder.run(); - Device device = CurrentDevice; - CurrentDevice = null; - return device; -} - /** * Constructs a new instance of this class. *

                @@ -128,7 +111,18 @@ * @see DeviceData */ public Device(DeviceData data) { + this(data, false); +} + +/** + *

                + * IMPORTANT: This constructor is not part of the SWT + * public API. It should never be referenced from application code. + *

                + */ +protected Device(DeviceData data, boolean internal) { synchronized (Device.class) { + this.internal = internal; if (data != null) { debug = data.debug; tracking = data.tracking; @@ -141,6 +135,7 @@ // In this order init(); register(this); + initialized = true; } } @@ -220,6 +215,7 @@ deregister(this); } finally { disposed = true; + initialized = false; } if (tracking) { synchronized (trackingLock) { @@ -567,51 +563,53 @@ * @see #create */ protected void init () { - int palette = OS.QApplication_swt_palette_new(); - try { - int[] rgb; - - // List like widgets - rgb = OS.QPalette_color(palette, OS.QPALETTE_COLORGROUP_NORMAL, OS.QPALETTE_COLORROLE_BASE); - COLOR_LIST_BACKGROUND = new Color(this, rgb[0], rgb[1], rgb[2]); - rgb = OS.QPalette_color(palette, OS.QPALETTE_COLORGROUP_NORMAL, OS.QPALETTE_COLORROLE_TEXT); - COLOR_LIST_FOREGROUND = new Color(this, rgb[0], rgb[1], rgb[2]); - - // Highlight - rgb = OS.QPalette_color(palette, OS.QPALETTE_COLORGROUP_NORMAL, OS.QPALETTE_COLORROLE_HIGHLIGHT); - COLOR_LIST_SELECTION = new Color(this, rgb[0], rgb[1], rgb[2]); - COLOR_TITLE_BACKGROUND = new Color(this, rgb[0], rgb[1], rgb[2]); - COLOR_TITLE_BACKGROUND_GRADIENT = new Color(this, rgb[0], rgb[1], rgb[2]); - COLOR_WIDGET_HIGHLIGHT_SHADOW = new Color(this, rgb[0], rgb[1], rgb[2]); - rgb = OS.QPalette_color(palette, OS.QPALETTE_COLORGROUP_NORMAL, OS.QPALETTE_COLORROLE_HIGHLIGHTTEXT); - COLOR_LIST_SELECTION_TEXT = new Color(this, rgb[0], rgb[1], rgb[2]); - COLOR_TITLE_FOREGROUND = new Color(this, rgb[0], rgb[1], rgb[2]); - - // Inactive highlight - rgb = OS.QPalette_color(palette, OS.QPALETTE_COLORGROUP_DISABLED, OS.QPALETTE_COLORROLE_HIGHLIGHT); - COLOR_TITLE_INACTIVE_BACKGROUND = new Color(this, rgb[0], rgb[1], rgb[2]); - COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT = new Color(this, rgb[0], rgb[1], rgb[2]); - rgb = OS.QPalette_color(palette, OS.QPALETTE_COLORGROUP_DISABLED, OS.QPALETTE_COLORROLE_TEXT); - COLOR_TITLE_INACTIVE_FOREGROUND = new Color(this, rgb[0], rgb[1], rgb[2]); - - // Window - rgb = OS.QPalette_color(palette, OS.QPALETTE_COLORGROUP_NORMAL, OS.QPALETTE_COLORROLE_WINDOW); - COLOR_WIDGET_BACKGROUND = new Color(this, rgb[0], rgb[1], rgb[2]); - rgb = OS.QPalette_color(palette, OS.QPALETTE_COLORGROUP_NORMAL, OS.QPALETTE_COLORROLE_WINDOWTEXT); - COLOR_WIDGET_FOREGROUND = new Color(this, rgb[0], rgb[1], rgb[2]); - - // Shadows: Black <= Shadow < [Dark] < [Mid] < [Button] < Midlight < Light <= White - rgb = OS.QPalette_color(palette, OS.QPALETTE_COLORGROUP_NORMAL, OS.QPALETTE_COLORROLE_DARK); - COLOR_WIDGET_DARK_SHADOW = new Color(this, rgb[0], rgb[1], rgb[2]); - rgb = OS.QPalette_color(palette, OS.QPALETTE_COLORGROUP_NORMAL, OS.QPALETTE_COLORROLE_MID); - COLOR_WIDGET_BORDER = new Color(this, rgb[0], rgb[1], rgb[2]); - COLOR_WIDGET_NORMAL_SHADOW = new Color(this, rgb[0], rgb[1], rgb[2]); - rgb = OS.QPalette_color(palette, OS.QPALETTE_COLORGROUP_NORMAL, OS.QPALETTE_COLORROLE_BUTTON); - COLOR_WIDGET_LIGHT_SHADOW = new Color(this, rgb[0], rgb[1], rgb[2]); - } finally { - OS.QPalette_delete(palette); - } - paintDevice = OS.QApplication_swt_desktopPaintDevice(); + if(!initialized) { + int palette = OS.QApplication_swt_palette_new(); + try { + int[] rgb; + + // List like widgets + rgb = OS.QPalette_color(palette, OS.QPALETTE_COLORGROUP_NORMAL, OS.QPALETTE_COLORROLE_BASE); + COLOR_LIST_BACKGROUND = new Color(this, rgb[0], rgb[1], rgb[2]); + rgb = OS.QPalette_color(palette, OS.QPALETTE_COLORGROUP_NORMAL, OS.QPALETTE_COLORROLE_TEXT); + COLOR_LIST_FOREGROUND = new Color(this, rgb[0], rgb[1], rgb[2]); + + // Highlight + rgb = OS.QPalette_color(palette, OS.QPALETTE_COLORGROUP_NORMAL, OS.QPALETTE_COLORROLE_HIGHLIGHT); + COLOR_LIST_SELECTION = new Color(this, rgb[0], rgb[1], rgb[2]); + COLOR_TITLE_BACKGROUND = new Color(this, rgb[0], rgb[1], rgb[2]); + COLOR_TITLE_BACKGROUND_GRADIENT = new Color(this, rgb[0], rgb[1], rgb[2]); + COLOR_WIDGET_HIGHLIGHT_SHADOW = new Color(this, rgb[0], rgb[1], rgb[2]); + rgb = OS.QPalette_color(palette, OS.QPALETTE_COLORGROUP_NORMAL, OS.QPALETTE_COLORROLE_HIGHLIGHTTEXT); + COLOR_LIST_SELECTION_TEXT = new Color(this, rgb[0], rgb[1], rgb[2]); + COLOR_TITLE_FOREGROUND = new Color(this, rgb[0], rgb[1], rgb[2]); + + // Inactive highlight + rgb = OS.QPalette_color(palette, OS.QPALETTE_COLORGROUP_DISABLED, OS.QPALETTE_COLORROLE_HIGHLIGHT); + COLOR_TITLE_INACTIVE_BACKGROUND = new Color(this, rgb[0], rgb[1], rgb[2]); + COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT = new Color(this, rgb[0], rgb[1], rgb[2]); + rgb = OS.QPalette_color(palette, OS.QPALETTE_COLORGROUP_DISABLED, OS.QPALETTE_COLORROLE_TEXT); + COLOR_TITLE_INACTIVE_FOREGROUND = new Color(this, rgb[0], rgb[1], rgb[2]); + + // Window + rgb = OS.QPalette_color(palette, OS.QPALETTE_COLORGROUP_NORMAL, OS.QPALETTE_COLORROLE_WINDOW); + COLOR_WIDGET_BACKGROUND = new Color(this, rgb[0], rgb[1], rgb[2]); + rgb = OS.QPalette_color(palette, OS.QPALETTE_COLORGROUP_NORMAL, OS.QPALETTE_COLORROLE_WINDOWTEXT); + COLOR_WIDGET_FOREGROUND = new Color(this, rgb[0], rgb[1], rgb[2]); + + // Shadows: Black <= Shadow < [Dark] < [Mid] < [Button] < Midlight < Light <= White + rgb = OS.QPalette_color(palette, OS.QPALETTE_COLORGROUP_NORMAL, OS.QPALETTE_COLORROLE_DARK); + COLOR_WIDGET_DARK_SHADOW = new Color(this, rgb[0], rgb[1], rgb[2]); + rgb = OS.QPalette_color(palette, OS.QPALETTE_COLORGROUP_NORMAL, OS.QPALETTE_COLORROLE_MID); + COLOR_WIDGET_BORDER = new Color(this, rgb[0], rgb[1], rgb[2]); + COLOR_WIDGET_NORMAL_SHADOW = new Color(this, rgb[0], rgb[1], rgb[2]); + rgb = OS.QPalette_color(palette, OS.QPALETTE_COLORGROUP_NORMAL, OS.QPALETTE_COLORROLE_BUTTON); + COLOR_WIDGET_LIGHT_SHADOW = new Color(this, rgb[0], rgb[1], rgb[2]); + } finally { + OS.QPalette_delete(palette); + } + paintDevice = OS.QApplication_swt_desktopPaintDevice(); + } } /** @@ -761,46 +759,47 @@ OS.QIcon_delete( nullIconHandle ); nullIconHandle = 0; } + COLOR_LIST_BACKGROUND.dispose(); + COLOR_LIST_FOREGROUND.dispose(); + COLOR_LIST_SELECTION.dispose(); + COLOR_LIST_SELECTION_TEXT.dispose(); + COLOR_TITLE_BACKGROUND.dispose(); + COLOR_TITLE_BACKGROUND_GRADIENT.dispose(); + COLOR_TITLE_FOREGROUND.dispose(); + COLOR_TITLE_INACTIVE_BACKGROUND.dispose(); + COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT.dispose(); + COLOR_TITLE_INACTIVE_FOREGROUND.dispose(); + COLOR_WIDGET_BACKGROUND.dispose(); + COLOR_WIDGET_BORDER.dispose(); + COLOR_WIDGET_DARK_SHADOW.dispose(); + COLOR_WIDGET_FOREGROUND.dispose(); + COLOR_WIDGET_HIGHLIGHT_SHADOW.dispose(); + COLOR_WIDGET_LIGHT_SHADOW.dispose(); + COLOR_WIDGET_NORMAL_SHADOW.dispose(); + + COLOR_LIST_BACKGROUND = null; + COLOR_LIST_FOREGROUND = null; + COLOR_LIST_SELECTION = null; + COLOR_LIST_SELECTION_TEXT = null; + COLOR_TITLE_BACKGROUND = null; + COLOR_TITLE_BACKGROUND_GRADIENT = null; + COLOR_TITLE_FOREGROUND = null; + COLOR_TITLE_INACTIVE_BACKGROUND = null; + COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT = null; + COLOR_TITLE_INACTIVE_FOREGROUND = null; + COLOR_WIDGET_BACKGROUND = null; + COLOR_WIDGET_BORDER = null; + COLOR_WIDGET_DARK_SHADOW = null; + COLOR_WIDGET_FOREGROUND = null; + COLOR_WIDGET_HIGHLIGHT_SHADOW = null; + COLOR_WIDGET_LIGHT_SHADOW = null; + COLOR_WIDGET_NORMAL_SHADOW = null; + + paintDevice = 0; } // Non static data follows - COLOR_LIST_BACKGROUND.dispose(); - COLOR_LIST_FOREGROUND.dispose(); - COLOR_LIST_SELECTION.dispose(); - COLOR_LIST_SELECTION_TEXT.dispose(); - COLOR_TITLE_BACKGROUND.dispose(); - COLOR_TITLE_BACKGROUND_GRADIENT.dispose(); - COLOR_TITLE_FOREGROUND.dispose(); - COLOR_TITLE_INACTIVE_BACKGROUND.dispose(); - COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT.dispose(); - COLOR_TITLE_INACTIVE_FOREGROUND.dispose(); - COLOR_WIDGET_BACKGROUND.dispose(); - COLOR_WIDGET_BORDER.dispose(); - COLOR_WIDGET_DARK_SHADOW.dispose(); - COLOR_WIDGET_FOREGROUND.dispose(); - COLOR_WIDGET_HIGHLIGHT_SHADOW.dispose(); - COLOR_WIDGET_LIGHT_SHADOW.dispose(); - COLOR_WIDGET_NORMAL_SHADOW.dispose(); - - COLOR_LIST_BACKGROUND = null; - COLOR_LIST_FOREGROUND = null; - COLOR_LIST_SELECTION = null; - COLOR_LIST_SELECTION_TEXT = null; - COLOR_TITLE_BACKGROUND = null; - COLOR_TITLE_BACKGROUND_GRADIENT = null; - COLOR_TITLE_FOREGROUND = null; - COLOR_TITLE_INACTIVE_BACKGROUND = null; - COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT = null; - COLOR_TITLE_INACTIVE_FOREGROUND = null; - COLOR_WIDGET_BACKGROUND = null; - COLOR_WIDGET_BORDER = null; - COLOR_WIDGET_DARK_SHADOW = null; - COLOR_WIDGET_FOREGROUND = null; - COLOR_WIDGET_HIGHLIGHT_SHADOW = null; - COLOR_WIDGET_LIGHT_SHADOW = null; - COLOR_WIDGET_NORMAL_SHADOW = null; - - paintDevice = 0; + // No non-static data to release } /** diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/graphics/Font.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/graphics/Font.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/graphics/Font.java Fri Jun 11 13:33:44 2010 +0300 @@ -173,7 +173,7 @@ OS.QFont_delete(handle); } handle = 0; - if (device.tracking) + if (Device.tracking) device.dispose_Object(this); device = null; } @@ -260,8 +260,6 @@ extraFontStyle = false; xlfd = null; if (device == null) - device = Device.getDevice(); - if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); this.device = device; if (name == null) @@ -270,7 +268,7 @@ SWT.error(SWT.ERROR_INVALID_ARGUMENT); // Keep this after dealing with all exceptions! - if (device.tracking) + if (Device.tracking) device.new_Object(this); boolean italic = (style & SWT.ITALIC) != 0; @@ -352,8 +350,6 @@ if (handle <= 0) return null; if (device == null) - device = Device.getDevice(); - if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); Font font = new Font(); font.handle = handle; diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/graphics/GC.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/graphics/GC.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/graphics/GC.java Fri Jun 11 13:33:44 2010 +0300 @@ -322,9 +322,12 @@ * that created the drawable */ public void dispose() { + final Display display = (Display)data.device; + if(display.getThread() != Thread.currentThread()) { + SWT.error(SWT.ERROR_THREAD_INVALID_ACCESS); + } if (drawable != null && handle != 0) { if (data.buffered && (drawable instanceof Control)) { - final Display display = Display.getDefault(); display.syncExec(new Runnable() { public void run() { ((Control) drawable).redraw(); diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/graphics/Image.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/graphics/Image.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/graphics/Image.java Fri Jun 11 13:33:44 2010 +0300 @@ -160,7 +160,6 @@ * @param device Device */ Image(Device device) { - if (device == null) device = Device.getDevice(); if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); this.device = device; } @@ -450,7 +449,7 @@ if (device == null) return; if (device.isDisposed()) return; - if (device.tracking) device.dispose_Object(this); + if (Device.tracking) device.dispose_Object(this); device = null; } @@ -820,6 +819,6 @@ * Call this only after dealing with all exceptions! */ private void track() { - if (device.tracking) device.new_Object(this); + if (Device.tracking) device.new_Object(this); } } diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/widgets/Button.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/widgets/Button.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/widgets/Button.java Fri Jun 11 13:33:44 2010 +0300 @@ -162,7 +162,7 @@ } void hookEvents_pp () { - int signalProxy = OS.SignalHandler_new(handle, display, OS.QSIGNAL_CLICKED); + int signalProxy = OS.SignalHandler_new(handle, OS.QSIGNAL_CLICKED); OS.QObject_connectOrThrow(handle, "clicked()", signalProxy, "widgetSignal()", OS.QT_AUTOCONNECTION); } diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/widgets/Combo.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/widgets/Combo.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/widgets/Combo.java Fri Jun 11 13:33:44 2010 +0300 @@ -127,12 +127,12 @@ void register_pp() { super.register_pp(); - display.addWidget(comboTextHandle, this); + Display.addWidget(comboTextHandle, this); } void deregister_pp() { super.deregister_pp(); - display.removeWidget(comboTextHandle); + Display.removeWidget(comboTextHandle); } void releaseHandle_pp() { @@ -307,18 +307,18 @@ super.hookEvents_pp(); int selectionSignalProxy = OS.SignalHandler_new(topHandle, - display, OS.QSIGNAL_SELECTIONCHANGED); + OS.QSIGNAL_SELECTIONCHANGED); OS.QObject_connectOrThrow(topHandle, "currentIndexChanged(const QString&)", selectionSignalProxy, "widgetSignal(const QString&)", OS.QT_AUTOCONNECTION); - int returnPressedProxy = OS.SignalHandler_new(comboTextHandle, display, + int returnPressedProxy = OS.SignalHandler_new(comboTextHandle, OS.QSIGNAL_RETURN_PRESSED); OS.QObject_connectOrThrow(comboTextHandle, "returnPressed()", returnPressedProxy, "widgetSignal()", OS.QT_AUTOCONNECTION); int modifySignalProxy = OS.SignalHandler_new(topHandle, - display, OS.QSIGNAL_TEXT_CHANGED); + OS.QSIGNAL_TEXT_CHANGED); OS.QObject_connectOrThrow(topHandle, "editTextChanged(const QString&)", modifySignalProxy, "widgetSignal(const QString&)", OS.QT_AUTOCONNECTION); diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/widgets/Composite.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/widgets/Composite.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/widgets/Composite.java Fri Jun 11 13:33:44 2010 +0300 @@ -326,7 +326,7 @@ for(int i = 0; i < count; ++i) { int handle = list[i]; if (handle != 0) { - Widget widget = display.getWidget (handle); + Widget widget = Display.getWidget (handle); if (widget != null && widget != this) { if (widget instanceof Control && !(widget instanceof Shell)) { children [childControls++] = (Control) widget; @@ -519,7 +519,7 @@ if(dx != 0) { Control[] children =_getChildren(); try { - display.blockedQtEventType = OS.QSWTEVENT_WIDGETMOVED; + Display.blockedQtEventType = OS.QSWTEVENT_WIDGETMOVED; for (int i = 0; i < children.length; ++i) { Control child = children[i]; if (!child.isDisposed()) { @@ -529,7 +529,7 @@ } } } finally { - display.blockedQtEventType = OS.QEVENT_NONE; + Display.blockedQtEventType = OS.QEVENT_NONE; } } } diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/widgets/Control.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/widgets/Control.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/widgets/Control.java Fri Jun 11 13:33:44 2010 +0300 @@ -847,7 +847,7 @@ } boolean forceFocus(int focusReason) { - if (display.focusEvent == SWT.FocusOut) return false; + if (Display.focusEvent == SWT.FocusOut) return false; Decorations shell = menuShell(); shell.setSavedFocus(this); if (!isEnabled() || !isVisible() || !isActive()) @@ -1424,7 +1424,7 @@ } boolean isActive() { - Dialog dialog = display.getModalDialog(); + Dialog dialog = Display.getModalDialog(); if (dialog != null) { Shell dialogShell = dialog.parent; if (dialogShell != null && !dialogShell.isDisposed()) { @@ -1433,7 +1433,7 @@ } } Shell shell = null; - Shell[] modalShells = display.modalShells; + Shell[] modalShells = Display.modalShells; if (modalShells != null) { int bits = SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL; int index = modalShells.length; @@ -1735,7 +1735,7 @@ continue; } if (next) { - Widget widget = display.getWidget(children[iChild]); + Widget widget = Display.getWidget(children[iChild]); if (widget != null && widget != this) { if (widget instanceof org.eclipse.swt.widgets.Control) { controlAbove = (Control) widget; @@ -1985,7 +1985,7 @@ } boolean qt_event_shortcut(int key, int modifier, int character) { - display.mnemonicControl = this; + Display.mnemonicControl = this; Control shortcutHandler = getShortcutHandler(); if (shortcutHandler == null) { // If there's no shortcut handler then just activate the shortcut. @@ -2001,24 +2001,24 @@ void qt_swt_event_focusWasGained() { try { - display.focusEvent = SWT.FocusIn; + Display.focusEvent = SWT.FocusIn; sendEvent(SWT.FocusIn); } finally { if(display != null && !display.isDisposed()) { - display.focusEvent = SWT.None; + Display.focusEvent = SWT.None; } } if(display != null && !display.isDisposed()) { - display.commandArranger.focusedControlChanged(); + Display.commandArranger.focusedControlChanged(); } } void qt_swt_event_focusWasLost() { try { - display.focusEvent = SWT.FocusOut; + Display.focusEvent = SWT.FocusOut; sendEvent(SWT.FocusOut); } finally { if(display != null && !display.isDisposed()) { - display.focusEvent = SWT.None; + Display.focusEvent = SWT.None; } } } @@ -2614,10 +2614,10 @@ if (oldSize.x != width || oldSize.y != height) { if(isParentMirrored()) { try { - display.blockedQtEventType = OS.QSWTEVENT_WIDGETMOVED; + Display.blockedQtEventType = OS.QSWTEVENT_WIDGETMOVED; OS.QWidget_move(topHandle, oldPos.x - (width - oldSize.x), oldPos.y); } finally { - display.blockedQtEventType = OS.QEVENT_NONE; + Display.blockedQtEventType = OS.QEVENT_NONE; } } // This will send a resize event @@ -2715,7 +2715,7 @@ Control control = null; boolean fixFocus = false; if (!enabled) { - if (display.focusEvent != SWT.FocusOut) { + if (Display.focusEvent != SWT.FocusOut) { control = display.getFocusControl (); fixFocus = isFocusAncestor (control); } @@ -3238,7 +3238,7 @@ Control control = null; boolean fixFocus = false; if (!visible) { - if (display.focusEvent != SWT.FocusOut) { + if (Display.focusEvent != SWT.FocusOut) { control = display.getFocusControl (); fixFocus = isFocusAncestor (control); } @@ -3396,7 +3396,7 @@ // but if it's done then traversal is attempted relative to this control. // Normally it would be done relative to the control that had the // shortcut event. - display.mnemonicControl = this; + Display.mnemonicControl = this; return doTraversal(event); } @@ -3479,9 +3479,9 @@ // SWT checks for mnemonic hit here - if (display.mnemonicControl == null) + if (Display.mnemonicControl == null) return false; - Control nextControl = display.mnemonicControl.findNextControl(false); + Control nextControl = Display.mnemonicControl.findNextControl(false); if (nextControl != null) { nextControl.setFocus(OS.QT_TABFOCUSREASON); return true; @@ -3576,9 +3576,9 @@ // one event we are waiting for. OS.QApplication_syncX(); // Make Qt process all XEvents. - display.noInterrupt = true; + Display.noInterrupt = true; OS.QCoreApplication_processEvents(Display.handle, OS.QEVENTLOOP_EXCLUDEUSERINPUTEVENTS); - display.noInterrupt = false; + Display.noInterrupt = false; } } diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/widgets/Decorations.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/widgets/Decorations.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/widgets/Decorations.java Fri Jun 11 13:33:44 2010 +0300 @@ -681,7 +681,7 @@ menuBar = menu; ownMenuBar = 0; //Inform CommandArranger - display.commandArranger.menuBarChanged( this ); + Display.commandArranger.menuBarChanged( this ); } } @@ -767,7 +767,7 @@ } void saveFocus () { - Control control = display._getFocusControl (); + Control control = Display._getFocusControl (); if (control != null && control != this && this == control.menuShell ()) { setSavedFocus (control); } diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/widgets/Display.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/widgets/Display.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/swt/widgets/Display.java Fri Jun 11 13:33:44 2010 +0300 @@ -113,7 +113,7 @@ static int handle; /* QApplication event filter */ -int eventFilterHandle; +static int eventFilterHandle; static final String SWT_OBJECT_INDEX = "swt_obj_idx"; static final String ADD_WIDGET_KEY = "org.eclipse.swt.internal.addWidget"; @@ -121,32 +121,30 @@ static final String IMAGE_LOAD_SIZE_KEY = "org.eclipse.swt.internal.image.loadSize"; static final String SWT_EVENT_FILTER = "swt_event_filter"; -public CommandArranger commandArranger; +static CommandArranger commandArranger; -Event[] eventQueue; -EventTable eventTable, filterTable; +static Event[] eventQueue; +static EventTable eventTable, filterTable; -// Note that this won't work with multiple displays in the same process. -// All the displays will have the same appname. static String APP_NAME; /* Widget Table */ -int[] indexTable; -int freeSlot; -int lastHandle; -Widget lastWidget; -Widget[] widgetTable; +static int[] indexTable; +static int freeSlot; +static int lastHandle; +static Widget lastWidget; +static Widget[] widgetTable; final static int GROW_SIZE = 64; -MobileDevice mobileDevice; -int mobileDeviceHandle; +static MobileDevice mobileDevice; +static int mobileDeviceHandle; /* Modality */ -Shell [] modalShells; -Dialog modalDialog; +static Shell [] modalShells; +static Dialog modalDialog; /* Sync/Async Widget Communication */ -Synchronizer synchronizer = new Synchronizer (this); +static Synchronizer synchronizer; Thread thread; static Thread fixedUiThread; @@ -155,29 +153,29 @@ Runnable [] disposeList; /* System Tray */ -Tray tray; +static Tray tray; /* Timers */ -int [] timerHandles; -Runnable [] timerRunnables; +static int [] timerHandles; +static Runnable [] timerRunnables; /* Timestamp of the Last Received Event */ -int lastEventTime; +static int lastEventTime; /* If not to interrupt event processing after every event */ -boolean noInterrupt; +static boolean noInterrupt; /* Used to block one type of events temporarily */ -int blockedQtEventType; +static int blockedQtEventType; /* Default orientation for Controls when style is not specified */ -int defaultOrientation; -boolean defaultOrientationIsSysLangDirection; +static int defaultOrientation; +static boolean defaultOrientationIsSysLangDirection; // The next Image loaded by Image class constructors will be scaled to // this size. Can be set using Display.setData([key], Point). Useful // for SVG images. -private Point imageLoadSize; +static private Point imageLoadSize; /* Key Mappings */ static final int [] [] KeyTable = { @@ -287,6 +285,7 @@ /* Multiple Displays. */ static Display Default; +static Display Internal; static Display [] Displays = new Display [4]; /* Package name */ @@ -299,48 +298,24 @@ static final String INTERNAL_EXTENSION_PACKAGE_PREFIX = "org.eclipse.swt.internal.extension."; /* Display Data */ -Object data; -String [] keys; -Object [] values; +static Object data; +static String [] keys; +static Object [] values; /* Last ShortcutOverride event parameters */ -int shortcutOverrideKey; -int shortcutOverrideModifier; -int shortcutOverrideCharacter; +static int shortcutOverrideKey; +static int shortcutOverrideModifier; +static int shortcutOverrideCharacter; /* Last control that had a mnemonic hit i.e. shortcut event*/ -Control mnemonicControl; +static Control mnemonicControl; /* It is stored here if we are currently in a focus event */ -int focusEvent; +static int focusEvent; /* Settings event specific variables */ static final int SETTINGS_DELAY = 2000; -Runnable settingsRunnable; - -/* -* TEMPORARY CODE. Install the runnable that -* gets the current display. This code will -* be removed in the future. -*/ -static { - DeviceFinder = new Runnable () { - public void run () { - Device device = getCurrent (); - if (device == null) { - device = getDefault (); - } - setDevice (device); - } - }; -} - -/* -* TEMPORARY CODE. -*/ -static void setDevice (Device device) { - CurrentDevice = device; -} +static Runnable settingsRunnable; /** * Constructs a new instance of this class. @@ -374,6 +349,17 @@ super(data); } +private Display(DeviceData data, boolean internal) { + super(data, internal); +} + +static Display internalInstance() { + if(Internal == null) { + Internal = new Display(null, true); + } + return Internal; +} + /** * Adds the listener to the collection of listeners who will * be notified when an event of the given type occurs anywhere @@ -448,7 +434,7 @@ eventTable.hook (eventType, listener); } -void addWidget (int handle, Widget widget) { +static void addWidget (int handle, Widget widget) { if (handle == 0) return; if (freeSlot == -1) { int length = (freeSlot = indexTable.length) + GROW_SIZE; @@ -514,7 +500,7 @@ OS.QApplication_beep(); } -private void checkDefaultOrientation(int sysLangDirection) { +private static void checkDefaultOrientation(int sysLangDirection) { defaultOrientation = SWT.LEFT_TO_RIGHT; String s = System.getProperty("org.eclipse.ercp.swt.defaultOrientation"); if (s != null) { @@ -533,12 +519,14 @@ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED); } -static void checkDisplay (Thread thread, boolean multiple) { +final void checkDisplay (Thread thread, boolean multiple) { synchronized (Device.class) { for (int i=0; itrue @@ -2091,10 +2115,10 @@ return asyncRetVal; } -Point readAndClearImageLoadSize() { - Point imageLoadSize = this.imageLoadSize; - this.imageLoadSize = null; - return imageLoadSize; +static Point readAndClearImageLoadSize() { + Point ilSize = Display.imageLoadSize; + Display.imageLoadSize = null; + return ilSize; } static void register (Display display) { @@ -2143,22 +2167,27 @@ Shell shell = shells [i]; if (!shell.isDisposed ()) shell.dispose (); } - commandArranger.dispose(); - if (tray != null) tray.dispose (); - tray = null; + final boolean lastDisplay = (displayCount() == 1); + if(lastDisplay) { + commandArranger.dispose(); + if (tray != null) tray.dispose (); + tray = null; + } while (readAndDispatch ()) {} if (disposeList != null) { for (int i=0; i0 ){ + Command[] add = commands.getCommands(null); + updateCommandPositions(add); + } + //Place them to their places + placePositiveCommands(); + placeNegativeCommand(); + + } + + private void updateCommandPositions(Command[] commands) { + positiveKeyCommands = new Command[commands.length]; + int positiveKeyIndex=0; + for (int i = 0; i < commands.length; i++) { + Command cmd = commands[i]; + if ( cmd.isDefaultCommand()){ + defaultCommand = cmd; + continue; + } + if( CommandUtils.isNegativeType(cmd.type) ){ + if (negativeKeyCommand == null || negativeKeyCommand.isDisposed()){ + negativeKeyCommand = cmd; + }else + if( negativeKeyCommand.getPriority() <= cmd.getPriority() ){ + positiveKeyCommands[positiveKeyIndex] = negativeKeyCommand; + positiveKeyIndex++; + negativeKeyCommand = cmd; + }else{ + positiveKeyCommands[positiveKeyIndex] = cmd; + positiveKeyIndex++; + } + continue; + } + positiveKeyCommands[positiveKeyIndex]=cmd; + positiveKeyIndex++; + } + if ((positiveKeyIndex) < positiveKeyCommands.length ){// needs to shrink + Command[] rightSized = new Command[positiveKeyIndex]; + System.arraycopy(positiveKeyCommands, 0, rightSized, 0, rightSized.length); + positiveKeyCommands = rightSized; + } + } + + + private void cleanPositiveCommands() { + boolean useBar = false; + if ( (positiveKeyCommands != null && positiveKeyCommands.length >1) || + (defaultCommand != null && positiveKeyCommands != null) ){ + useBar = true; + } + if (defaultCommand != null && !defaultCommand.isDisposed() + && !defaultCommand.control.isDisposed()) { + if (useBar) { + OS.QWidget_removeAction(defaultCommand.control.getShell() + .internal_getOwnMenuBar(), topHandle(defaultCommand)); + } + else{ + OS.QWidget_removeAction(topHandle(defaultCommand.control), topHandle(defaultCommand)); + } + } + if (positiveKeyCommands != null) { + for (int i = 0; i < positiveKeyCommands.length; i++) { + Command cmd = positiveKeyCommands[i]; + if (cmd == null || cmd.isDisposed() || cmd.control.isDisposed()){ + continue; + } + int handle = 0; + if (useBar) { + handle = cmd.control.getShell().internal_getOwnMenuBar(); + } else { + handle = topHandle(positiveKeyCommands[0].control); + } + OS.QWidget_removeAction(handle, topHandle(cmd)); + + } + } + } + + private void cleanNegativeCommand() { + if(negativeKeyCommand != null && !negativeKeyCommand.isDisposed() && !negativeKeyCommand.control.isDisposed() ){ + OS.QWidget_removeAction(topHandle(negativeKeyCommand.control), topHandle(negativeKeyCommand)); + } + } + + private void placeNegativeCommand() { + if(negativeKeyCommand != null ){ + OS.QWidget_addAction(Internal_PackageSupport.topHandle(negativeKeyCommand.control), + topHandle(negativeKeyCommand)); + } + } + + private void placePositiveCommands() { + if (defaultCommand != null ) { + int defaultCmdHandle = topHandle(defaultCommand); + if (positiveKeyCommands != null) { + OS.QMenuBar_addAction(defaultCommand.control.getShell() + .internal_getOwnMenuBar(), defaultCmdHandle); + } else { + OS.QWidget_addAction(Internal_PackageSupport + .topHandle(defaultCommand.control), defaultCmdHandle); + } + } + if (positiveKeyCommands != null) { + if (positiveKeyCommands.length == 1 && defaultCommand == null) { + OS.QWidget_addAction(Internal_PackageSupport + .topHandle(positiveKeyCommands[0].control), + topHandle(positiveKeyCommands[0])); + } else { + CommandUtils.sort(positiveKeyCommands); + for (int i = 0; i < positiveKeyCommands.length; i++) { + OS.QMenuBar_addAction(positiveKeyCommands[i].control + .getShell().internal_getOwnMenuBar(), + topHandle(positiveKeyCommands[i])); + } + } + } + } + + protected void handleMenuBarChanged(int newMenuBar, + CommandCollection commands) { + placePositiveCommands(); + } + + + private static final int topHandle(Widget w) { + return Internal_PackageSupport.topHandle(w); + } +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/eswt_widgets.pri --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/eswt_widgets.pri Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/eswt_widgets.pri Fri Jun 11 13:33:44 2010 +0300 @@ -9,14 +9,21 @@ # Nokia Corporation - initial implementation #******************************************************************************* +QT += core \ + gui + +DEFINES += SWTQT_LIBRARY + INCLUDEPATH += $$PWD DEPENDPATH += $$PWD -HEADERS += eventcallback.h \ +HEADERS += \ + eventcallback.h \ slotcallback.h \ swtlog.h \ jniutils.h \ swt.h \ + swterror.h \ autorelease.h \ listdatamodel.h \ qcaptionedwidget.h \ @@ -26,11 +33,11 @@ qswttabwidget.h \ execexceptionhandler.h \ swtfontcache.h \ - swtbufferflushevent.h - + swtbufferflushevent.h \ + swtexport.h - -SOURCES += eventcallback.cpp \ +SOURCES += \ + eventcallback.cpp \ slotcallback.cpp \ os.cpp \ swtlog.cpp \ @@ -45,29 +52,33 @@ ##### Symbian specific items ###### symbian { - -CONFIG += mobility -MOBILITY += bearer - -HEADERS += swts60.h \ - swtmobiledevice.h \ - swtflipwatch.h - -SOURCES += swts60.cpp \ - swtmobiledevice.cpp \ - swtflipwatch.cpp + CONFIG += mobility + MOBILITY += bearer + + HEADERS += \ + swts60.h \ + swtmobiledevice.h \ + swtflipwatch.h -LIBS += -leikcore -LIBS += -lapparc -LIBS += -lavkon -LIBS += -lefsrv -LIBS += -lcone -LIBS += -leikcoctl -LIBS += -lapgrfx -LIBS += -lHWRMVibraClient -LIBS += -lHWRMLightClient -LIBS += -lxqservice -LIBS += -lxqtelephonyservice -LIBS += -lQtContacts - + SOURCES += \ + swts60.cpp \ + swtmobiledevice.cpp \ + swtflipwatch.cpp + + LIBS += \ + -leikcore \ + -lapparc \ + -lavkon \ + -lefsrv \ + -lcone \ + -leikcoctl \ + -lapgrfx \ + -lHWRMVibraClient \ + -lHWRMLightClient \ + -lxqservice \ + -lxqtelephonyservice \ + -lQtContacts \ + -lhal \ + -lws32 \ + -lgdi } diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/eventcallback.cpp --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/eventcallback.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/eventcallback.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -17,7 +17,6 @@ #include "eventcallback.h" #include "swtlog.h" #include "jniutils.h" -#include "swt.h" #include "swtapplication.h" using namespace Java::eSWT; diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/gfxos.cpp --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/gfxos.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/gfxos.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -388,6 +388,19 @@ GFX_CATCH } +JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1drawWindowSurface + (JNIEnv* aJniEnv, jclass, jint aHandle, jint aSurfaceHandle, jint aX, jint aY, jint aWidth, jint aHeight) +{ + GFX_TRY + { + GFX_LOG_JNI_CALL(); + HANDLE_TO_POINTER(GraphicsContext*, gc, aHandle); + HANDLE_TO_POINTER(WindowSurface*, surface, aSurfaceHandle); + gc->drawWindowSurface(surface, aX, aY, aWidth, aHeight); + } + GFX_CATCH +} + void JNICALL Java_org_eclipse_swt_internal_qt_graphics_OS_graphicsContext_1fillArc (JNIEnv* aJniEnv , jclass, jint aHandle, jint aX, jint aY, jint aWidth, jint aHeight, jint aStartAngle, jint aArcAngle) { diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/graphics.h --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/graphics.h Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/graphics.h Fri Jun 11 13:33:44 2010 +0300 @@ -153,8 +153,9 @@ { WsTypeUnknown = 0x0000, // unknonwn or uninitialized type WsTypeQtImage = 0x0001, // QImage - WsTypeSymbianBitmap = 0x0002, // CFbsBitmap - WsTypeEglSurface = 0x0004 // EGL surface + WsTypeQtPixmap = 0x0002, // QPixmap + WsTypeSymbianBitmap = 0x0004, // CFbsBitmap + WsTypeEglSurface = 0x0016 // EGL surface }; @@ -629,6 +630,17 @@ int aLength, int aAlignments, int aFlags, bool aIsTransparent) = 0; /** + * Draws given window surface to current target. + * + * @param aSurface The WindowSurface to draw + * @param aX The x-coordinate of the area to draw + * @param aY The y-coordinate of the area to draw + * @param aWidth The width of the area to draw + * @param aHeigth The height of the area to draw + */ + virtual void drawWindowSurface(WindowSurface* aSurface, int aX, int aY, int aWidth, int aHeight) = 0; + + /** * Fill interior of circular or elliptical arc within specified rectangular area. * * @param aX The x coordinate of top left corner of arc rectangle diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/graphics.pri --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/graphics.pri Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/graphics.pri Fri Jun 11 13:33:44 2010 +0300 @@ -27,13 +27,20 @@ $$PWD/qt/graphicscontextimpl.h \ $$PWD/qt/bufferimpl.h \ $$PWD/qt/targetobserver.h \ - $$PWD/qt/windowsurfaceimpl.h \ $$PWD/gfxlog.h \ $$PWD/graphics.h \ - $$PWD/gfxutils.h + $$PWD/gfxutils.h \ + $$PWD/qt/windowsurfaceimpl_linux.h \ + $$PWD/qt/windowsurfaceimpl_symbian.h + +symbian { + HEADERS -= $$PWD/qt/windowsurfaceimpl_linux.h +} +!symbian { + HEADERS -= $$PWD/qt/windowsurfaceimpl_symbian.h +} SOURCES += $$PWD/qt/surfaceimpl.cpp \ - $$PWD/qt/windowsurfaceimpl.cpp \ $$PWD/qt/pixmap.cpp \ $$PWD/qt/imageloaderimpl.cpp \ $$PWD/qt/imagedataimpl.cpp \ @@ -43,8 +50,14 @@ $$PWD/qt/targetobserver.cpp \ $$PWD/graphicsfactory.cpp \ $$PWD/gfxos.cpp \ - $$PWD/gfxutils.cpp + $$PWD/gfxutils.cpp \ + $$PWD/qt/windowsurfaceimpl_linux.cpp \ + $$PWD/qt/windowsurfaceimpl_symbian.cpp symbian { -LIBS += -llibEGL + SOURCES -= $$PWD/qt/windowsurfaceimpl_linux.cpp + LIBS += -llibEGL } +!symbian { + SOURCES -= $$PWD/qt/windowsurfaceimpl_symbian.cpp +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/graphicsfactory.cpp --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/graphicsfactory.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/graphicsfactory.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -16,9 +16,14 @@ #include "imageloaderimpl.h" #include "imagedataimpl.h" #include "palettedataimpl.h" -#include "windowsurfaceimpl.h" #include "gfxlog.h" +#ifdef __SYMBIAN32__ +#include "windowsurfaceimpl_symbian.h" +#else +#include "windowsurfaceimpl_linux.h" +#endif + namespace Java { namespace GFX { /*static*/ WindowSurface* GraphicsFactory::createWindowSurface(QPaintDevice* aSurface, WindowSurfaceType aType) diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/qt/graphicscontextimpl.cpp --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/qt/graphicscontextimpl.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/qt/graphicscontextimpl.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -915,6 +915,22 @@ mPainter->restore(); } +void GraphicsContextImpl::drawWindowSurface(WindowSurface* aSurface, int aX, int aY, int aWidth, int aHeight) +{ + GFX_LOG_FUNC_CALL(); + QRect area(aX, aY, aWidth, aHeight); + switch(aSurface->getType()) + { + case WsTypeQtImage: + { + mPainter->drawImage(area, *aSurface->getQtImage(), area); + break; + } + default: + return; + } +} + void GraphicsContextImpl::fillArc(int aX, int aY, int aWidth, int aHeight, int aStartAngle, int aArcAngle) { GFX_LOG_FUNC_CALL(); diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/qt/graphicscontextimpl.h --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/qt/graphicscontextimpl.h Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/qt/graphicscontextimpl.h Fri Jun 11 13:33:44 2010 +0300 @@ -65,6 +65,7 @@ virtual void drawString( const unsigned short* aText, int aX, int aY, int aWidth, int aHeight, int aLength, int aAlignments, int aFlags, bool aIsTransparent); + virtual void drawWindowSurface(WindowSurface* aSurface, int aX, int aY, int aWidth, int aHeight); virtual void fillArc(int aX, int aY, int aWidth, int aHeight, int aStartAngle, int aArcAngle); virtual void fillEllipse(int aX, int aY, int aWidth, int aHeight); virtual void fillGradientRect(int aX, int aY, int aWidth, int aHeight, bool aVertical, bool aSwapColors); diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/qt/windowsurfaceimpl.cpp --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/qt/windowsurfaceimpl.cpp Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,387 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Nokia Corporation - initial API and implementation - *******************************************************************************/ - -//#include -#include -#include -#include -#include "windowsurfaceimpl.h" -#include "gfxlog.h" - -namespace Java { namespace GFX { - -WindowSurfaceImpl::WindowSurfaceImpl(QPaintDevice* aSurface, WindowSurfaceType aType) -: mIsBound(false), - mBufferedRendering(false), - mAutoRefresh(false), - mPaintingStarted(false) -{ - GFX_LOG_FUNC_CALL(); - mMainSurface.device = aSurface; - mMainSurface.type = aType; -} - -WindowSurfaceImpl::WindowSurfaceImpl(QWidget* aWidget, bool aAutoRefresh) -: mIsBound(false), - mBufferedRendering(false), - mAutoRefresh(false), - mPaintingStarted(false) -{ - GFX_LOG_FUNC_CALL(); - if(aWidget == NULL) - { - throw GfxException(EGfxErrorIllegalArgument, "Target widget is NULL"); - } - mMainSurface.widget = aWidget; - mAutoRefresh = aAutoRefresh; - updateSurfaceData(); -} - - -WindowSurfaceImpl::~WindowSurfaceImpl() -{ - GFX_LOG_FUNC_CALL(); - if(mMainSurface.localSurface != NULL) - { - delete mMainSurface.localSurface; - mMainSurface.localSurface = NULL; - } -} - -void WindowSurfaceImpl::beginPaint(int aX, int aY, int aWidth, int aHeight) -{ - if(mAutoRefresh && (mMainSurface.widget != NULL)) - { - updateSurfaceData(); - } -#ifdef __SYMBIAN32__ - if(!mMainSurface.localSurfaceInUse) - { - QRegion region(aX, aY, aWidth, aHeight); - mMainSurface.qSurface->beginPaint(region); - // In case local surface was used last round - // and we now have Qt's window surface again - // delete the local surface to save memory - if(mMainSurface.localSurface != NULL) - { - delete mMainSurface.localSurface; - mMainSurface.localSurface = NULL; - } - } -#endif - mPaintingStarted = true; -} - -void WindowSurfaceImpl::endPaint() -{ -#ifdef __SYMBIAN32__ - if(!mMainSurface.localSurfaceInUse) - { - mMainSurface.qSurface->endPaint(QRegion()); - } -#endif - mPaintingStarted = false; -} - -void WindowSurfaceImpl::flush() -{ -#ifdef __SYMBIAN32__ - if(!mMainSurface.localSurfaceInUse) - { - QRegion region(0,0,mMainSurface.device->width(), mMainSurface.device->height()); - mMainSurface.qSurface->flush(mMainSurface.widget, region, QPoint()); - } -#endif -} - -void WindowSurfaceImpl::bind(int aCapabilies) -{ - GFX_LOG_FUNC_CALL(); - // Bind is not allowed if beginPaint has not been called - if(!mPaintingStarted) - { - throw GfxException(EGfxErrorIllegalState, "beginPaint() not called before bind()"); - } - - switch (mMainSurface.type) - { - case WsTypeQtImage: - { - mBufferedRendering = true; - break; - } - - case WsTypeEglSurface: - { - // If caller does not support EGL surface - // create temp buffer to be used as target and - // copy pixels from window surface to temp buffer - if ((aCapabilies & WsTypeEglSurface) == 0) { - // TODO copy pixels from EGL surface to - // QImage created here - - } else { - // Caller supports EGL surface, so just - // save EGL state here - saveEglState(); - } - break; - } - case WsTypeSymbianBitmap: - { - break; - } - default: - { - // we should newer get here - } - } - mIsBound = true; -} - -int WindowSurfaceImpl::getType() -{ - GFX_LOG_FUNC_CALL(); - return mMainSurface.type; -} - -QPaintDevice* WindowSurfaceImpl::getDevice() -{ - return mMainSurface.device; -} - -#ifdef __SYMBIAN32__ -EGLSurface WindowSurfaceImpl::getEglSurface() -{ - return mEgl.drawSurface; -} - -EGLenum WindowSurfaceImpl::getEglApi() -{ - return mEgl.api; -} - -CFbsBitmap* WindowSurfaceImpl::getSymbianBitmap() -{ - return mMainSurface.symbianBitmap; -} -#endif - -QImage* WindowSurfaceImpl::getQtImage() -{ - return mMainSurface.localSurface; -} - -void WindowSurfaceImpl::refresh() -{ - updateSurfaceData(); -} - -void WindowSurfaceImpl::release() -{ - GFX_LOG_FUNC_CALL(); - if (!mIsBound) - { - return; - } - - if (mBufferedRendering) - { - // TODO draw QImage with painter to actual target - } - else - { - if(mMainSurface.type == WsTypeEglSurface) - { - restoreEglState(); - } - // pixels are already rendered to the target - // no post blitter hook needed - } - mIsBound = false; -} - -void WindowSurfaceImpl::dispose() -{ - GFX_LOG_FUNC_CALL(); - delete this; -} - -void WindowSurfaceImpl::saveEglState() -{ -#ifdef __SYMBIAN32__ - // Some painter needs to be active on the device - // in order to get correct data from EGL, so if - // there's no active painter, activate one here - if(!mMainSurface.device->paintingActive()) - { - mPainter.begin(mMainSurface.device); - } - mEgl.drawSurface = eglGetCurrentSurface(EGL_DRAW); - mEgl.readSurface = eglGetCurrentSurface(EGL_READ); - mEgl.context = eglGetCurrentContext(); - mEgl.api = eglQueryAPI(); -#endif -} - -void WindowSurfaceImpl::restoreEglState() -{ -#ifdef __SYMBIAN32__ - eglBindAPI(mEgl.api); - eglMakeCurrent(EGL_DEFAULT_DISPLAY, mEgl.drawSurface, mEgl.readSurface, mEgl.context); - mEgl.drawSurface = EGL_NO_SURFACE; - mEgl.readSurface = EGL_NO_SURFACE; - mEgl.context = EGL_NO_CONTEXT; - - // if owned painter was activate to the device - // release it - if(mPainter.isActive()) - { - mPainter.end(); - } -#endif -} - -// Private methods - -void WindowSurfaceImpl::createLocalSurface(int aWidth, int aHeight) -{ - mMainSurface.localSurface = new QImage(aWidth, aHeight, QImage::Format_ARGB32); - if(mMainSurface.localSurface->isNull()) - { - throw GfxException(EGfxErrorNoMemory, "Local Surface creation failed"); - } -} - -void WindowSurfaceImpl::deleteLocalSurface() -{ - if(mMainSurface.localSurface != NULL) - { - delete mMainSurface.localSurface; - mMainSurface.localSurface = NULL; - } - -} - -bool WindowSurfaceImpl::isLocalSurfaceValid() -{ - if(mMainSurface.localSurface == NULL) - { - return false; - } - - if((mMainSurface.localSurfaceInUse) && - (mMainSurface.localSurface->width() == mMainSurface.widget->width()) && - (mMainSurface.localSurface->height() == mMainSurface.widget->height())) - { - return true; - } - return false; -} - -void WindowSurfaceImpl::updateSurfaceData() -{ -#ifdef __SYMBIAN32__ - // If painting is active, i.e. beginPaint has been called - // surface data is not updated - if(mPaintingStarted) - { - return; - } - QWindowSurface* surface = mMainSurface.widget->windowSurface(); - - // If window surface is null it means that the widget has been - // sent to background and widget's window surface has been deleted, - // in such case create own QImage as local surface in order to support - // rendering in background - if(surface == NULL || surface == 0) - { - // check if we already have local surface with valid size - if(!isLocalSurfaceValid()) - { - // incase we have invalid surface delete the current one - // and create new - if(mMainSurface.localSurfaceInUse) - { - deleteLocalSurface(); - } - createLocalSurface(mMainSurface.widget->width(), mMainSurface.widget->height()); - // set info - mMainSurface.qSurface = NULL; - mMainSurface.device = mMainSurface.localSurface; - mMainSurface.type = WsTypeQtImage; - mMainSurface.localSurfaceInUse = true; - return; - } - else - { - // We have valid local surface so just return - return; - } - } - else - { - // We got Qt's window surface, so in case we had local surface in use - // delete it as it's not used anymore - if(mMainSurface.localSurfaceInUse) - { - deleteLocalSurface(); - } - } - - // We got window surface so extract information - QPaintDevice* device = surface->paintDevice(); - if(device->paintingActive()) - { - throw GfxException(EGfxErrorIllegalState, "Internal error: Device active when refreshing data"); - } - - // Attach painter to device in oder to see which type - // of device it is working on - mPainter.begin(device); - QPaintEngine* engine = mPainter.paintEngine(); - - // determine the surface type based on the engine used - // as Qt does not provide exact info of the surface type - switch (engine->type()) - { - case QPaintEngine::OpenVG: - // surface is EGL window surface - mMainSurface.type = WsTypeEglSurface; - break; - case QPaintEngine::Raster: - mMainSurface.type = WsTypeSymbianBitmap; - if(device->devType() == QInternal::Pixmap) - { - QPixmap* pixmap = static_cast(device); - mMainSurface.symbianBitmap = pixmap->toSymbianCFbsBitmap(); - } - else - { - throw GfxException(EGfxErrorIllegalArgument, "Unsupported device type"); - } - break; - default: - throw GfxException(EGfxErrorIllegalArgument, "Unsupported widget window surface type"); - break; - } - - // release painter - mPainter.end(); - mMainSurface.qSurface = surface; - mMainSurface.device = device; - mMainSurface.localSurfaceInUse = false; -#endif -} - - -} // namespace GFX -} // namespace Java diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/qt/windowsurfaceimpl.h --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/qt/windowsurfaceimpl.h Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,182 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies). - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Nokia Corporation - initial API and implementation - *******************************************************************************/ -#ifndef WINDOWSURFACEQT_H_ -#define WINDOWSURFACEQT_H_ - -#include "graphics.h" - -#ifdef __SYMBIAN32__ -#include "qwindowsurface_p.h" -#else -class QWindowSurface; -#endif - -namespace Java { namespace GFX { - -class WindowSurfaceImpl: public WindowSurface -{ -public: - /** - * Ctor for paint device - * @param surface The paindevice of Qt render surface - * @param type The type of the surface - */ - WindowSurfaceImpl(QPaintDevice* aSurface, WindowSurfaceType aType); - - /** - * Ctor for window owning widgets - * @param aWidget The target widget that this window surface is created on - * @param aAutoRefresh If true the Qt window surface pointer is updated each time - * the bind is called, otherwise not - */ - WindowSurfaceImpl(QWidget* aWidget, bool aAutoRefresh); - - /** - * Dtor - */ - virtual ~WindowSurfaceImpl(); - - /** - * From WindowSurface - * @see WindowSurface - */ - virtual void bind(int aCapabilies = WsTypeQtImage) ; - virtual void beginPaint(int aX, int aY, int aWidth, int aHeight); - virtual void endPaint(); - virtual void flush(); - virtual int getType(); - virtual QPaintDevice* getDevice(); -#ifdef __SYMBIAN32__ - virtual EGLSurface getEglSurface(); - virtual EGLenum getEglApi(); -#endif - virtual QImage* getQtImage(); - virtual void refresh(); - virtual void release(); - virtual void dispose(); - -#ifdef __SYMBIAN32__ - virtual CFbsBitmap* getSymbianBitmap(); -#endif - - -private: - - /** - * Creates and activates local off-screen buffer for rendering - * in background mode - */ - void createLocalSurface(int aWidth, int aHeight); - - /** - * Deletes local surface - */ - void deleteLocalSurface(); - - /** - * Checks that local surface size is correct - */ - bool isLocalSurfaceValid(); - - /** - * Updates window surface info, i.e. fetches info from Qt - */ - void updateSurfaceData(); - - /** - * Saves current EGL state - */ - void saveEglState(); - - /** - * Restores previously saved EGL state - */ - void restoreEglState(); - -#ifdef __SYMBIAN32__ - struct surfaceData - { - // The window surface that Qt has created - QWindowSurface* qSurface; - // The paint device QWindowSurface has - QPaintDevice* device; - // The Target widget which owns the QWindowSurface - QWidget* widget; - // Local surface used when widget is in background - // and QWindowSurface is not available - QImage* localSurface; - // The symbian bitmap used in a case where - // the widget is parially visible and Qt switches - // to software rendering - CFbsBitmap* symbianBitmap; - // The current type of the target surface - WindowSurfaceType type; - // Indicates if local surface is used - bool localSurfaceInUse; - surfaceData() : qSurface(NULL), - device(NULL), - widget(NULL), - localSurface(NULL), - symbianBitmap(NULL), - type(WsTypeUnknown), - localSurfaceInUse(false) - {} - }; -#else - struct surfaceData - { - QWindowSurface* qSurface; - QPaintDevice* device; - QWidget* widget; - QImage* localSurface; - WindowSurfaceType type; - bool localSurfaceInUse; - surfaceData() : qSurface(NULL), - device(NULL), - widget(NULL), - localSurface(NULL), - type(WsTypeUnknown), - localSurfaceInUse(false) - {} - }; -#endif - - /** - * Data collection for EGL surface - */ - struct eglData - { -#ifdef __SYMBIAN32__ - EGLSurface drawSurface; - EGLSurface readSurface; - EGLContext context; - EGLenum api; - eglData() : drawSurface(EGL_NO_SURFACE), - readSurface(EGL_NO_SURFACE), - context(EGL_NO_CONTEXT), - api(EGL_OPENGL_ES_API) - {} -#endif - }; - - surfaceData mMainSurface; - eglData mEgl; - QPainter mPainter; - bool mIsBound; - bool mBufferedRendering; - bool mAutoRefresh; - bool mPaintingStarted; -}; - -} // namespace GFX -} // namespace Java - -#endif /*WINDOWSURFACEQT_H_*/ diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/qt/windowsurfaceimpl_linux.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/qt/windowsurfaceimpl_linux.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,204 @@ +/******************************************************************************* + * Copyright (c) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia Corporation - initial API and implementation + *******************************************************************************/ + +#include +#include +#include +#include "windowsurfaceimpl_linux.h" +#include "gfxlog.h" + +namespace Java { namespace GFX { + +WindowSurfaceImpl::WindowSurfaceImpl(QPaintDevice* aSurface, WindowSurfaceType aType) +: mIsBound(false), + mBufferedRendering(false), + mAutoRefresh(false), + mPaintingStarted(false) +{ + GFX_LOG_FUNC_CALL(); + mMainSurface.device = aSurface; + mMainSurface.type = aType; +} + +WindowSurfaceImpl::WindowSurfaceImpl(QWidget* aWidget, bool aAutoRefresh) +: mIsBound(false), + mBufferedRendering(false), + mAutoRefresh(false), + mPaintingStarted(false) +{ + GFX_LOG_FUNC_CALL(); + if(aWidget == NULL) + { + throw GfxException(EGfxErrorIllegalArgument, "Target widget is NULL"); + } + mMainSurface.widget = aWidget; + mAutoRefresh = aAutoRefresh; + updateSurfaceData(); +} + + +WindowSurfaceImpl::~WindowSurfaceImpl() +{ + GFX_LOG_FUNC_CALL(); + if(mMainSurface.localSurface != NULL) + { + delete mMainSurface.localSurface; + mMainSurface.localSurface = NULL; + } +} + +void WindowSurfaceImpl::beginPaint(int aX, int aY, int aWidth, int aHeight) +{ + if(mAutoRefresh && (mMainSurface.widget != NULL)) + { + updateSurfaceData(); + } + mPaintingStarted = true; +} + +void WindowSurfaceImpl::endPaint() +{ + // nothing to do +} + +void WindowSurfaceImpl::flush() +{ + // nothing to do +} + +void WindowSurfaceImpl::bind(int aCapabilies) +{ + GFX_LOG_FUNC_CALL(); + // Bind is not allowed if beginPaint has not been called + if(!mPaintingStarted) + { + throw GfxException(EGfxErrorIllegalState, "beginPaint() not called before bind()"); + } + mIsBound = true; +} + +int WindowSurfaceImpl::getType() +{ + GFX_LOG_FUNC_CALL(); + return mMainSurface.type; +} + +QPaintDevice* WindowSurfaceImpl::getDevice() +{ + if(mMainSurface.localSurfaceInUse) + { + return mMainSurface.localSurface; + } + else + { + return mMainSurface.device; + } +} + +QImage* WindowSurfaceImpl::getQtImage() +{ + return mMainSurface.localSurface; +} + +void WindowSurfaceImpl::refresh() +{ + updateSurfaceData(); +} + +void WindowSurfaceImpl::release() +{ + GFX_LOG_FUNC_CALL(); + if (!mIsBound) + { + return; + } + // nothing to do + mIsBound = false; +} + +void WindowSurfaceImpl::dispose() +{ + GFX_LOG_FUNC_CALL(); + delete this; +} + + +// Private methods +void WindowSurfaceImpl::createLocalSurface(int aWidth, int aHeight) +{ + mMainSurface.localSurface = new QImage(aWidth, aHeight, QImage::Format_ARGB32); + if(mMainSurface.localSurface->isNull()) + { + throw GfxException(EGfxErrorNoMemory, "Local Surface creation failed"); + } +} + +void WindowSurfaceImpl::deleteLocalSurface() +{ + if(mMainSurface.localSurface != NULL) + { + delete mMainSurface.localSurface; + mMainSurface.localSurface = NULL; + } + +} + +bool WindowSurfaceImpl::isLocalSurfaceValid() +{ + if(mMainSurface.localSurface == NULL) + { + return false; + } + + if((mMainSurface.localSurfaceInUse) && + (mMainSurface.localSurface->width() == mMainSurface.widget->width()) && + (mMainSurface.localSurface->height() == mMainSurface.widget->height())) + { + return true; + } + return false; +} + +void WindowSurfaceImpl::updateSurfaceData() +{ + // If painting is active, i.e. beginPaint has been called + // surface data is not updated + if(mPaintingStarted) + { + return; + } + // check if we already have local surface with valid size + if(!isLocalSurfaceValid()) + { + // incase we have invalid surface delete the current one + // and create new + if(mMainSurface.localSurfaceInUse) + { + deleteLocalSurface(); + } + createLocalSurface(mMainSurface.widget->width(), mMainSurface.widget->height()); + // set info + mMainSurface.qSurface = NULL; + mMainSurface.device = mMainSurface.localSurface; + mMainSurface.type = WsTypeQtImage; + mMainSurface.localSurfaceInUse = true; + return; + } + else + { + // We have valid local surface so just return + return; + } +} + + +} // namespace GFX +} // namespace Java diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/qt/windowsurfaceimpl_linux.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/qt/windowsurfaceimpl_linux.h Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,108 @@ +/******************************************************************************* + * Copyright (c) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia Corporation - initial API and implementation + *******************************************************************************/ +#ifndef WINDOWSURFACEQT_H_ +#define WINDOWSURFACEQT_H_ + +#include "graphics.h" + +namespace Java { namespace GFX { + +class WindowSurfaceImpl: public WindowSurface +{ +public: + /** + * Ctor for paint device + * @param surface The paindevice of Qt render surface + * @param type The type of the surface + */ + WindowSurfaceImpl(QPaintDevice* aSurface, WindowSurfaceType aType); + + /** + * Ctor for window owning widgets + * @param aWidget The target widget that this window surface is created on + * @param aAutoRefresh If true the Qt window surface pointer is updated each time + * the bind is called, otherwise not + */ + WindowSurfaceImpl(QWidget* aWidget, bool aAutoRefresh); + + /** + * Dtor + */ + virtual ~WindowSurfaceImpl(); + + /** + * From WindowSurface + * @see WindowSurface + */ + virtual void bind(int aCapabilies = WsTypeQtImage) ; + virtual void beginPaint(int aX, int aY, int aWidth, int aHeight); + virtual void endPaint(); + virtual void flush(); + virtual int getType(); + virtual QPaintDevice* getDevice(); + virtual QImage* getQtImage(); + virtual void refresh(); + virtual void release(); + virtual void dispose(); + +private: + + /** + * Creates and activates local off-screen buffer for rendering + * in background mode + */ + void createLocalSurface(int aWidth, int aHeight); + + /** + * Deletes local surface + */ + void deleteLocalSurface(); + + /** + * Checks that local surface size is correct + */ + bool isLocalSurfaceValid(); + + /** + * Updates window surface info, i.e. fetches info from Qt + */ + void updateSurfaceData(); + + struct surfaceData + { + QWindowSurface* qSurface; + QPaintDevice* device; + QWidget* widget; + QImage* localSurface; + WindowSurfaceType type; + bool localSurfaceInUse; + surfaceData() : qSurface(NULL), + device(NULL), + widget(NULL), + localSurface(NULL), + type(WsTypeUnknown), + localSurfaceInUse(false) + {} + }; + + + surfaceData mMainSurface; + QPainter mPainter; + bool mIsBound; + bool mBufferedRendering; + bool mAutoRefresh; + bool mPaintingStarted; +}; + +} // namespace GFX +} // namespace Java + +#endif /*WINDOWSURFACEQT_H_*/ diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/qt/windowsurfaceimpl_symbian.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/qt/windowsurfaceimpl_symbian.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,372 @@ +/******************************************************************************* + * Copyright (c) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia Corporation - initial API and implementation + *******************************************************************************/ + +//#include +#include +#include +#include +#include "windowsurfaceimpl_symbian.h" +#include "gfxlog.h" + +namespace Java { namespace GFX { + +WindowSurfaceImpl::WindowSurfaceImpl(QPaintDevice* aSurface, WindowSurfaceType aType) +: mIsBound(false), + mBufferedRendering(false), + mAutoRefresh(false), + mPaintingStarted(false) +{ + GFX_LOG_FUNC_CALL(); + mMainSurface.device = aSurface; + mMainSurface.type = aType; +} + +WindowSurfaceImpl::WindowSurfaceImpl(QWidget* aWidget, bool aAutoRefresh) +: mIsBound(false), + mBufferedRendering(false), + mAutoRefresh(false), + mPaintingStarted(false) +{ + GFX_LOG_FUNC_CALL(); + if(aWidget == NULL) + { + throw GfxException(EGfxErrorIllegalArgument, "Target widget is NULL"); + } + mMainSurface.widget = aWidget; + mAutoRefresh = aAutoRefresh; + updateSurfaceData(); +} + + +WindowSurfaceImpl::~WindowSurfaceImpl() +{ + GFX_LOG_FUNC_CALL(); + if(mMainSurface.localSurface != NULL) + { + delete mMainSurface.localSurface; + mMainSurface.localSurface = NULL; + } +} + +void WindowSurfaceImpl::beginPaint(int aX, int aY, int aWidth, int aHeight) +{ + if(mAutoRefresh && (mMainSurface.widget != NULL)) + { + updateSurfaceData(); + } + if(!mMainSurface.localSurfaceInUse) + { + QRegion region(aX, aY, aWidth, aHeight); + mMainSurface.qSurface->beginPaint(region); + // In case local surface was used last round + // and we now have Qt's window surface again + // delete the local surface to save memory + if(mMainSurface.localSurface != NULL) + { + delete mMainSurface.localSurface; + mMainSurface.localSurface = NULL; + } + } + mPaintingStarted = true; +} + +void WindowSurfaceImpl::endPaint() +{ + if(!mMainSurface.localSurfaceInUse) + { + mMainSurface.qSurface->endPaint(QRegion()); + } + mPaintingStarted = false; +} + +void WindowSurfaceImpl::flush() +{ + if(!mMainSurface.localSurfaceInUse) + { + QRegion region(0,0,mMainSurface.device->width(), mMainSurface.device->height()); + mMainSurface.qSurface->flush(mMainSurface.widget, region, QPoint()); + } +} + +void WindowSurfaceImpl::bind(int aCapabilies) +{ + GFX_LOG_FUNC_CALL(); + // Bind is not allowed if beginPaint has not been called + if(!mPaintingStarted) + { + throw GfxException(EGfxErrorIllegalState, "beginPaint() not called before bind()"); + } + + switch (mMainSurface.type) + { + case WsTypeQtImage: + { + mBufferedRendering = true; + break; + } + + case WsTypeEglSurface: + { + // If caller does not support EGL surface + // create temp buffer to be used as target and + // copy pixels from window surface to temp buffer + if ((aCapabilies & WsTypeEglSurface) == 0) { + // TODO copy pixels from EGL surface to + // QImage created here + + } else { + // Caller supports EGL surface, so just + // save EGL state here + saveEglState(); + } + break; + } + case WsTypeSymbianBitmap: + { + break; + } + default: + { + // we should newer get here + } + } + mIsBound = true; +} + +int WindowSurfaceImpl::getType() +{ + GFX_LOG_FUNC_CALL(); + return mMainSurface.type; +} + +QPaintDevice* WindowSurfaceImpl::getDevice() +{ + return mMainSurface.device; +} + + +EGLSurface WindowSurfaceImpl::getEglSurface() +{ + return mEgl.drawSurface; +} + +EGLenum WindowSurfaceImpl::getEglApi() +{ + return mEgl.api; +} + +CFbsBitmap* WindowSurfaceImpl::getSymbianBitmap() +{ + return mMainSurface.symbianBitmap; +} + +QImage* WindowSurfaceImpl::getQtImage() +{ + return mMainSurface.localSurface; +} + +void WindowSurfaceImpl::refresh() +{ + updateSurfaceData(); +} + +void WindowSurfaceImpl::release() +{ + GFX_LOG_FUNC_CALL(); + if (!mIsBound) + { + return; + } + + if (mBufferedRendering) + { + // TODO draw QImage with painter to actual target + } + else + { + if(mMainSurface.type == WsTypeEglSurface) + { + restoreEglState(); + } + // pixels are already rendered to the target + // no post blitter hook needed + } + mIsBound = false; +} + +void WindowSurfaceImpl::dispose() +{ + GFX_LOG_FUNC_CALL(); + delete this; +} + +void WindowSurfaceImpl::saveEglState() +{ + // Some painter needs to be active on the device + // in order to get correct data from EGL, so if + // there's no active painter, activate one here + if(!mMainSurface.device->paintingActive()) + { + mPainter.begin(mMainSurface.device); + } + mEgl.drawSurface = eglGetCurrentSurface(EGL_DRAW); + mEgl.readSurface = eglGetCurrentSurface(EGL_READ); + mEgl.display = eglGetCurrentDisplay(); + mEgl.context = eglGetCurrentContext(); + mEgl.api = eglQueryAPI(); +} + +void WindowSurfaceImpl::restoreEglState() +{ + eglBindAPI(mEgl.api); + eglMakeCurrent(mEgl.display, mEgl.drawSurface, mEgl.readSurface, mEgl.context); + + // if owned painter was activate to the device + // release it + if(mPainter.isActive()) + { + mPainter.end(); + } +} + +// Private methods + +void WindowSurfaceImpl::createLocalSurface(int aWidth, int aHeight) +{ + mMainSurface.localSurface = new QImage(aWidth, aHeight, QImage::Format_ARGB32); + if(mMainSurface.localSurface->isNull()) + { + throw GfxException(EGfxErrorNoMemory, "Local Surface creation failed"); + } +} + +void WindowSurfaceImpl::deleteLocalSurface() +{ + if(mMainSurface.localSurface != NULL) + { + delete mMainSurface.localSurface; + mMainSurface.localSurface = NULL; + } + +} + +bool WindowSurfaceImpl::isLocalSurfaceValid() +{ + if(mMainSurface.localSurface == NULL) + { + return false; + } + + if((mMainSurface.localSurfaceInUse) && + (mMainSurface.localSurface->width() == mMainSurface.widget->width()) && + (mMainSurface.localSurface->height() == mMainSurface.widget->height())) + { + return true; + } + return false; +} + +void WindowSurfaceImpl::updateSurfaceData() +{ + // If painting is active, i.e. beginPaint has been called + // surface data is not updated + if(mPaintingStarted) + { + return; + } + QWindowSurface* surface = mMainSurface.widget->windowSurface(); + + // If window surface is null it means that the widget has been + // sent to background and widget's window surface has been deleted, + // in such case create own QImage as local surface in order to support + // rendering in background + if(surface == NULL || surface == 0) + { + // check if we already have local surface with valid size + if(!isLocalSurfaceValid()) + { + // incase we have invalid surface delete the current one + // and create new + if(mMainSurface.localSurfaceInUse) + { + deleteLocalSurface(); + } + createLocalSurface(mMainSurface.widget->width(), mMainSurface.widget->height()); + // set info + mMainSurface.qSurface = NULL; + mMainSurface.device = mMainSurface.localSurface; + mMainSurface.type = WsTypeQtImage; + mMainSurface.localSurfaceInUse = true; + return; + } + else + { + // We have valid local surface so just return + return; + } + } + else + { + // We got Qt's window surface, so in case we had local surface in use + // delete it as it's not used anymore + if(mMainSurface.localSurfaceInUse) + { + deleteLocalSurface(); + } + } + + // We got window surface so extract information + QPaintDevice* device = surface->paintDevice(); + if(device->paintingActive()) + { + throw GfxException(EGfxErrorIllegalState, "Internal error: Device active when refreshing data"); + } + + // Attach painter to device in oder to see which type + // of device it is working on + mPainter.begin(device); + QPaintEngine* engine = mPainter.paintEngine(); + + // determine the surface type based on the engine used + // as Qt does not provide exact info of the surface type + switch (engine->type()) + { + case QPaintEngine::OpenVG: + // surface is EGL window surface + mMainSurface.type = WsTypeEglSurface; + break; + case QPaintEngine::Raster: + mMainSurface.type = WsTypeSymbianBitmap; + if(device->devType() == QInternal::Pixmap) + { + QPixmap* pixmap = static_cast(device); + mMainSurface.symbianBitmap = pixmap->toSymbianCFbsBitmap(); + } + else + { + throw GfxException(EGfxErrorIllegalArgument, "Unsupported device type"); + } + break; + default: + throw GfxException(EGfxErrorIllegalArgument, "Unsupported widget window surface type"); + break; + } + + // release painter + mPainter.end(); + mMainSurface.qSurface = surface; + mMainSurface.device = device; + mMainSurface.localSurfaceInUse = false; +} + + +} // namespace GFX +} // namespace Java diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/qt/windowsurfaceimpl_symbian.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics/qt/windowsurfaceimpl_symbian.h Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,153 @@ +/******************************************************************************* + * Copyright (c) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia Corporation - initial API and implementation + *******************************************************************************/ +#ifndef WINDOWSURFACEQT_H_ +#define WINDOWSURFACEQT_H_ + +#include "graphics.h" +#include "qwindowsurface_p.h" + +namespace Java { namespace GFX { + +class WindowSurfaceImpl: public WindowSurface +{ +public: + /** + * Ctor for paint device + * @param surface The paindevice of Qt render surface + * @param type The type of the surface + */ + WindowSurfaceImpl(QPaintDevice* aSurface, WindowSurfaceType aType); + + /** + * Ctor for window owning widgets + * @param aWidget The target widget that this window surface is created on + * @param aAutoRefresh If true the Qt window surface pointer is updated each time + * the bind is called, otherwise not + */ + WindowSurfaceImpl(QWidget* aWidget, bool aAutoRefresh); + + /** + * Dtor + */ + virtual ~WindowSurfaceImpl(); + + /** + * From WindowSurface + * @see WindowSurface + */ + virtual void bind(int aCapabilies = WsTypeQtImage) ; + virtual void beginPaint(int aX, int aY, int aWidth, int aHeight); + virtual void endPaint(); + virtual void flush(); + virtual int getType(); + virtual QPaintDevice* getDevice(); + virtual EGLSurface getEglSurface(); + virtual EGLenum getEglApi(); + virtual QImage* getQtImage(); + virtual void refresh(); + virtual void release(); + virtual void dispose(); + virtual CFbsBitmap* getSymbianBitmap(); + +private: + + /** + * Creates and activates local off-screen buffer for rendering + * in background mode + */ + void createLocalSurface(int aWidth, int aHeight); + + /** + * Deletes local surface + */ + void deleteLocalSurface(); + + /** + * Checks that local surface size is correct + */ + bool isLocalSurfaceValid(); + + /** + * Updates window surface info, i.e. fetches info from Qt + */ + void updateSurfaceData(); + + /** + * Saves current EGL state + */ + void saveEglState(); + + /** + * Restores previously saved EGL state + */ + void restoreEglState(); + + + struct surfaceData + { + // The window surface that Qt has created + QWindowSurface* qSurface; + // The paint device QWindowSurface has + QPaintDevice* device; + // The Target widget which owns the QWindowSurface + QWidget* widget; + // Local surface used when widget is in background + // and QWindowSurface is not available + QImage* localSurface; + // The symbian bitmap used in a case where + // the widget is parially visible and Qt switches + // to software rendering + CFbsBitmap* symbianBitmap; + // The current type of the target surface + WindowSurfaceType type; + // Indicates if local surface is used + bool localSurfaceInUse; + surfaceData() : qSurface(NULL), + device(NULL), + widget(NULL), + localSurface(NULL), + symbianBitmap(NULL), + type(WsTypeUnknown), + localSurfaceInUse(false) + {} + }; + + /** + * Data collection for EGL surface + */ + struct eglData + { + EGLSurface drawSurface; + EGLSurface readSurface; + EGLContext context; + EGLenum api; + EGLDisplay display; + eglData() : drawSurface(EGL_NO_SURFACE), + readSurface(EGL_NO_SURFACE), + context(EGL_NO_CONTEXT), + api(EGL_OPENGL_ES_API), + display(EGL_DEFAULT_DISPLAY) + {} + }; + + surfaceData mMainSurface; + eglData mEgl; + QPainter mPainter; + bool mIsBound; + bool mBufferedRendering; + bool mAutoRefresh; + bool mPaintingStarted; +}; + +} // namespace GFX +} // namespace Java + +#endif /*WINDOWSURFACEQT_H_*/ diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/jniutils.cpp --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/jniutils.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/jniutils.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * Copyright (c) 2009, 2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -45,23 +45,15 @@ POINT, SWT, STRING, + DISPLAY, NUM_SWT_JCLASSES } SwtJClass; -JniUtils::JniUtils(JNIEnv* aEnv, jobject aDisplay) : - mUIThreadJniEnv(aEnv) +JniUtils::JniUtils(JNIEnv* aEnv) : mUIThreadJniEnv(aEnv) { SWT_LOG_FUNC_CALL(); - // Create global ref to Display - jobject display = mUIThreadJniEnv->NewGlobalRef( aDisplay ); - if( !display ) - { - throw std::bad_alloc(); - } - mDisplay = display; - // Get local class refs. These classes are needed by Display so they should // be already loaded at this point. This doesn't cause any additional // classes, that wouldn't potentially be needed, to be loaded. @@ -71,6 +63,7 @@ mJclasses[POINT] = mUIThreadJniEnv->FindClass("org/eclipse/swt/graphics/Point"); mJclasses[SWT] = mUIThreadJniEnv->FindClass("org/eclipse/swt/SWT"); mJclasses[STRING] = mUIThreadJniEnv->FindClass("java/lang/String"); + mJclasses[DISPLAY] = mUIThreadJniEnv->FindClass("org/eclipse/swt/widgets/Display"); // Check that local class refs ok for (int i = 0; i < NUM_SWT_JCLASSES; ++i) @@ -82,7 +75,8 @@ } // Create global class refs for caching. Global refs can be used across - // threads. + // threads. Keeping global class refs ensures that the classes won't get + // unloaded. for (int i = 0; i < NUM_SWT_JCLASSES; ++i) { jclass globalRef = static_cast(mUIThreadJniEnv->NewGlobalRef( mJclasses[i] )); @@ -108,12 +102,12 @@ } } - // Compute methodIDs for caching, only Display instance and static methods. - // Other instance methods are not cached here. MethodIDs have the same - // values for all threads so the cached values may be used by any thread. + // Compute methodIDs for caching. MethodIDs have the same values for all + // threads so the cached values may be used by any thread. MethodIDs are + // valid until objects are garbage collected or classes unloaded. mJmethodIds = new jmethodID[NUM_SWT_JMETHODIDS]; ::memset( mJmethodIds, 0, sizeof(jmethodID)*NUM_SWT_JMETHODIDS ); - mJmethodIds[DISPLAY_EVENTPROCESS_IIIIIIIISTRING_Z] = FindJavaMethodID(mUIThreadJniEnv, mDisplay, "eventProcess", "(IIIIIIIILjava/lang/String;)Z"); + mJmethodIds[DISPLAY_EVENTPROCESS_IIIIIIIISTRING_Z] = mUIThreadJniEnv->GetStaticMethodID(mJclasses[DISPLAY], "eventProcess", "(IIIIIIIILjava/lang/String;)Z"); mJmethodIds[RECTANGLE_INIT_IIII_V] = mUIThreadJniEnv->GetMethodID(mJclasses[RECTANGLE], "", "(IIII)V"); mJmethodIds[POINT_INIT_II_V] = mUIThreadJniEnv->GetMethodID(mJclasses[POINT], "", "(II)V"); mJmethodIds[SWT_ERROR_I_V] = mUIThreadJniEnv->GetStaticMethodID(mJclasses[SWT], "error", "(I)V"); @@ -145,8 +139,6 @@ delete mJmethodIds; mJmethodIds = NULL; - - mUIThreadJniEnv->DeleteGlobalRef(mDisplay); } bool JniUtils::eventProcess(const QObject* aQObject, const int& aQEventType, @@ -155,12 +147,41 @@ const jstring aString) { SWT_LOG_FUNC_CALL(); - return eventProcess(mDisplay, - mJmethodIds[DISPLAY_EVENTPROCESS_IIIIIIIISTRING_Z], reinterpret_cast(aQObject), + return eventProcess( + NULL, + mJclasses[DISPLAY], + mJmethodIds[DISPLAY_EVENTPROCESS_IIIIIIIISTRING_Z], + reinterpret_cast(aQObject), aQEventType, a1, a2, a3, a4, a5, aString); } bool JniUtils::eventProcess(jobject aObject, const jmethodID aMethodID, + const QObject* aQObject, const int& aQEventType, const int& a1, + const int& a2, const int& a3, const int& a4, const int& a5, + const jstring aString) +{ + return eventProcess( + aObject, + NULL, + aMethodID, + reinterpret_cast(aQObject), + aQEventType, a1, a2, a3, a4, a5, aString); +} + +bool JniUtils::eventProcess(jclass aClazz, const jmethodID aMethodID, + const QObject* aQObject, const int& aQEventType, const int& a1, + const int& a2, const int& a3, const int& a4, const int& a5, + const jstring aString) +{ + return eventProcess( + NULL, + aClazz, + aMethodID, + reinterpret_cast(aQObject), + aQEventType, a1, a2, a3, a4, a5, aString); +} + +bool JniUtils::eventProcess(jobject aObject, jclass aClazz, const jmethodID aMethodID, const int& aQObject, const int& aQEventType, const int& a1, const int& a2, const int& a3, const int& a4, const int& a5, const jstring aString) @@ -182,10 +203,20 @@ // return back through the call stack. This list of objects can be used // to determine if deletion of an object is safe in these terms. JavaCallbackCounter counter(mObjectsBeingHandled, reinterpret_cast(aQObject)); - + + jboolean result; + // Callback Java - jboolean result = mUIThreadJniEnv->CallBooleanMethod(aObject, aMethodID, - aQObject, aQEventType, swtApp->eventTime(), a1, a2, a3, a4, a5, aString); + if(aObject == NULL) + { + result = mUIThreadJniEnv->CallStaticBooleanMethod(aClazz, aMethodID, + aQObject, aQEventType, swtApp->eventTime(), a1, a2, a3, a4, a5, aString); + } + else + { + result = mUIThreadJniEnv->CallBooleanMethod(aObject, aMethodID, + aQObject, aQEventType, swtApp->eventTime(), a1, a2, a3, a4, a5, aString); + } // If an exception has occurred then any native eventloop we have // started, e.g. when opening a QDialog, must exit to allow Java stack @@ -207,11 +238,6 @@ return false; } -bool JniUtils::isDisplay(jobject aObject) -{ - return (mUIThreadJniEnv->IsSameObject(aObject, mDisplay) == JNI_TRUE); -} - void JniUtils::enterExec(QObject* aObject) { QDialog* dialog = qobject_cast( aObject ); @@ -273,7 +299,7 @@ return result; } -QString JniUtils::JavaStringToQString(JNIEnv* aEnv, jstring aJavaString) +SWTQT_EXPORT QString JniUtils::JavaStringToQString(JNIEnv* aEnv, jstring aJavaString) { SWT_LOG_FUNC_CALL(); if (aJavaString == NULL) @@ -296,7 +322,7 @@ } } -jstring JniUtils::QStringToJavaString(JNIEnv* aEnv, const QString& aQString) +SWTQT_EXPORT jstring JniUtils::QStringToJavaString(JNIEnv* aEnv, const QString& aQString) { SWT_LOG_FUNC_CALL(); @@ -417,7 +443,7 @@ return result; } -void JniUtils::Throw(JNIEnv* aEnv, const int& aError) +SWTQT_EXPORT void JniUtils::Throw(JNIEnv* aEnv, const int& aError) { SWT_LOG_FUNC_CALL(); aEnv->CallStaticVoidMethod(mJclasses[SWT], mJmethodIds[SWT_ERROR_I_V], diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/jniutils.h --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/jniutils.h Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/jniutils.h Fri Jun 11 13:33:44 2010 +0300 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * Copyright (c) 2009, 2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -19,6 +19,7 @@ #include #include #include +#include "swtexport.h" template class QStack; @@ -45,9 +46,8 @@ /** * The constructor. * @param aEnv The JNI environment pointer of the Qt GUI thread. - * @param aDisplay Local ref to the Java Display instance, JniUtils will create a global ref */ - JniUtils(JNIEnv* aEnv, jobject aDisplay); + JniUtils(JNIEnv* aEnv); /** * The destructor. @@ -55,7 +55,7 @@ virtual ~JniUtils(); /** - * Calls eventProcess Java method of the active Display instance. + * Calls eventProcess Java method of the Display class. * Can only be called in the UI thread. * @param aQObject Target QObject of the QEvent * @param aQEventType Type of the QEvent @@ -69,7 +69,7 @@ const jstring aString = NULL); /** - * Calls eventProcess Java method based on the given jobject and jmethodID. + * Calls eventProcess Java instance method based on the given jobject and jmethodID. * Can only be called in the UI thread. * @param aObject The Java object instance for the method call. * @param aMethodID The Java methodID for the method call. @@ -77,18 +77,23 @@ * @return True if the event should be canceled. */ bool eventProcess(jobject aObject, const jmethodID aMethodID, - const int& aQObject, const int& aQEventType, const int& a1, + const QObject* aQObject, const int& aQEventType, const int& a1, const int& a2, const int& a3, const int& a4, const int& a5, const jstring aString); /** - * Query if the jobject is the Display of the process. + * Calls static eventProcess Java method based on the given jclass and jmethodID. * Can only be called in the UI thread. - * @param aObject jobject to compare to the Display. - * @return true if given jobject is the Display + * @param aObject The Java class for the method call. + * @param aMethodID The Java methodID for the method call. + * @param ... Parameters to pass to the Java method. + * @return True if the event should be canceled. */ - bool isDisplay(jobject aObject); - + bool eventProcess(jclass aClazz, const jmethodID aMethodID, + const QObject* aQObject, const int& aQEventType, const int& a1, + const int& a2, const int& a3, const int& a4, const int& a5, + const jstring aString); + /** * This must be called before entering an event loop. E.g. dialogs and * menus need to call this before calling exec(). This will handle closing @@ -138,7 +143,7 @@ * @return A QString object. * @exception std::bad_alloc */ - QString JavaStringToQString(JNIEnv* aEnv, jstring aJavaString); + SWTQT_EXPORT QString JavaStringToQString(JNIEnv* aEnv, jstring aJavaString); /** * Creates a Java string from the given QString. @@ -147,7 +152,7 @@ * @return A Java string. * @exception std::bad_alloc */ - jstring QStringToJavaString(JNIEnv* aEnv, const QString& aQString); + SWTQT_EXPORT jstring QStringToJavaString(JNIEnv* aEnv, const QString& aQString); /** * Creates a new Java integer array from the given native int array. @@ -201,7 +206,7 @@ * @param aEnv JNI environment for the thread * @param aError The SWT error code to throw. */ - void Throw(JNIEnv* aEnv, const int& aError); + SWTQT_EXPORT void Throw(JNIEnv* aEnv, const int& aError); /** * Throws a custom Java exception from the current JNI call. @@ -341,6 +346,20 @@ JniUtils() {}; /** + * Calls back Java eventProcess method which can be either static class + * method of the given class or an instance method of the given object. + * @param aObject Java object instance or NULL if the method is static. + * @param aClazz Java class or NULL if the method is an instance method. + * @param aMethodID The Java methodID for the method call. + * @param ... Parameters to pass to the Java method. + * @return True if the event should be canceled. + */ + bool eventProcess(jobject aObject, jclass aClazz, const jmethodID aMethodID, + const int& aQObject, const int& aQEventType, const int& a1, + const int& a2, const int& a3, const int& a4, const int& a5, + const jstring aString); + + /** * Creates a native palette data object based on the given palette data object. * @param aEnv JNI environment * @param aJavaPaletteData Java side image data object @@ -385,7 +404,6 @@ }; JNIEnv* mUIThreadJniEnv; - jobject mDisplay; jclass* mJclasses; jmethodID* mJmethodIds; ExecStack mExecStack; diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/listdatamodel.cpp --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/listdatamodel.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/listdatamodel.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -27,7 +27,6 @@ * list type */ const static int LISTTYPE_SORTEDLIST = 0x2; -const static int LISTTYPE_LISTVIEW = 0x4; const static int LISTTYPE_LISTBOX = 0x8; /** diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/os.cpp --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/os.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/os.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -78,12 +78,6 @@ #include #include -#ifndef QT_NO_WEBKIT -#include -#include -#include -#endif - #ifdef __SYMBIAN32__ #include #include @@ -99,6 +93,7 @@ #include "jniutils.h" #include "swtfontcache.h" #include "swt.h" +#include "swterror.h" #include "listdatamodel.h" #include "qcaptionedwidget.h" #include "qswttimeedit.h" @@ -116,33 +111,6 @@ #define OS_NATIVE(func) Java_org_eclipse_swt_internal_qt_OS_##func -#define POINTER_TO_HANDLE(pointer) reinterpret_cast(static_cast(pointer)) -#define HANDLE_TO_POINTER(type, variable, handle) type variable = qobject_cast(static_cast(reinterpret_cast( handle ))) - -#define QCOLOR_TO_HANDLE(pointer) reinterpret_cast(static_cast(pointer)) -#define HANDLE_TO_QCOLOR(variable, handle) QColor* variable = static_cast(reinterpret_cast( handle )) - -#define QTABLEWIDGETITEM_TO_HANDLE(pointer) reinterpret_cast(static_cast(pointer)) -#define HANDLE_TO_QTABLEWIDGETITEM(variable, handle) QTableWidgetItem* variable = static_cast(reinterpret_cast( handle )) -#define QTREEWIDGETITEM_TO_HANDLE(pointer) reinterpret_cast(static_cast(pointer)) -#define HANDLE_TO_QTREEWIDGETITEM(variable, handle) QTreeWidgetItem* variable = static_cast(reinterpret_cast( handle )) - -#define SWT_TRY try -#define SWT_CATCH \ -catch(std::bad_alloc const&)\ - {\ - swtApp->jniUtils().Throw( aJniEnv, ESwtErrorNoHandles );\ - }\ -catch(std::exception const&)\ - {\ - swtApp->jniUtils().Throw( aJniEnv, ESwtErrorUnspecified );\ - } -#define SWT_CATCH_1(err) \ -catch(std::exception const&)\ - {\ - swtApp->jniUtils().Throw( aJniEnv, err );\ - } - #ifdef Q_WS_X11 void extern qt_x11_wait_for_window_manager(QWidget* widget); #endif @@ -10194,297 +10162,6 @@ return ( result ? JNI_TRUE : JNI_FALSE ); } - -// -// QWebView -// -JNIEXPORT jint JNICALL OS_NATIVE( QWebView_1new ) - ( JNIEnv* aJniEnv , jclass ) - { -#ifndef QT_NO_WEBKIT - QWebView* browser = NULL; - SWT_TRY - { - SWT_LOG_JNI_CALL(); - browser = new QWebView(); - } - SWT_CATCH - return POINTER_TO_HANDLE( browser ); -#endif -#ifdef QT_NO_WEBKIT - swtApp->jniUtils().Throw( aJniEnv, ESwtErrorNotImplemented ); - return 0; -#endif - } - -JNIEXPORT void JNICALL OS_NATIVE( QWebView_1back ) - ( JNIEnv* aJniEnv , jclass, jint -#ifndef QT_NO_WEBKIT -aHandle -#endif -) - { - SWT_TRY - { - SWT_LOG_JNI_CALL(); -#ifndef QT_NO_WEBKIT - HANDLE_TO_POINTER( QWebView*, browser, aHandle ); - browser->back(); -#endif - } - SWT_CATCH - } - -JNIEXPORT void JNICALL OS_NATIVE( QWebView_1forward ) - ( JNIEnv* aJniEnv , jclass, jint -#ifndef QT_NO_WEBKIT -aHandle -#endif -) - { - SWT_TRY - { - SWT_LOG_JNI_CALL(); -#ifndef QT_NO_WEBKIT - HANDLE_TO_POINTER( QWebView*, browser, aHandle ); - browser->forward(); -#endif - } - SWT_CATCH - } - -JNIEXPORT void JNICALL OS_NATIVE( QWebView_1reload ) - ( JNIEnv* aJniEnv , jclass, jint -#ifndef QT_NO_WEBKIT -aHandle -#endif -) - { - SWT_TRY - { - SWT_LOG_JNI_CALL(); -#ifndef QT_NO_WEBKIT - HANDLE_TO_POINTER( QWebView*, browser, aHandle ); - browser->reload(); -#endif - } - SWT_CATCH - } - -JNIEXPORT void JNICALL OS_NATIVE( QWebView_1setHtml ) - ( JNIEnv* aJniEnv , jclass, jint -#ifndef QT_NO_WEBKIT -aHandle -#endif -, jstring -#ifndef QT_NO_WEBKIT -aText -#endif -) - { - SWT_TRY - { - SWT_LOG_JNI_CALL(); -#ifndef QT_NO_WEBKIT - HANDLE_TO_POINTER( QWebView*, browser, aHandle ); - browser->setHtml( swtApp->jniUtils().JavaStringToQString( aJniEnv, aText ) ); -#endif - } - SWT_CATCH - } - -JNIEXPORT void JNICALL OS_NATIVE( QWebView_1setUrl ) - ( JNIEnv* aJniEnv , jclass, jint -#ifndef QT_NO_WEBKIT -aHandle -#endif -, jstring -#ifndef QT_NO_WEBKIT -aText -#endif -) - { - SWT_TRY - { - SWT_LOG_JNI_CALL(); -#ifndef QT_NO_WEBKIT - HANDLE_TO_POINTER( QWebView*, browser, aHandle ); - browser->setUrl( QUrl( swtApp->jniUtils().JavaStringToQString( aJniEnv, aText ) ) ); -#endif - } - SWT_CATCH - } - -JNIEXPORT void JNICALL OS_NATIVE( QWebView_1stop ) - ( JNIEnv* aJniEnv , jclass, jint -#ifndef QT_NO_WEBKIT -aHandle -#endif -) - { - SWT_TRY - { - SWT_LOG_JNI_CALL(); -#ifndef QT_NO_WEBKIT - HANDLE_TO_POINTER( QWebView*, browser, aHandle ); - browser->stop(); -#endif - } - SWT_CATCH - } - -JNIEXPORT jstring JNICALL OS_NATIVE( QWebView_1swt_1backUrl ) - ( JNIEnv* aJniEnv , jclass, jint -#ifndef QT_NO_WEBKIT -aHandle -#endif -) - { - jstring res = NULL; - SWT_TRY - { - SWT_LOG_JNI_CALL(); -#ifndef QT_NO_WEBKIT - HANDLE_TO_POINTER( QWebView*, browser, aHandle ); - QWebHistory* history = browser->history(); - if ( history && history->canGoBack() ) - { - res = swtApp->jniUtils().QStringToJavaString( aJniEnv, history->backItem().url().toString() ); - } -#endif - } - SWT_CATCH - return res; - } - -JNIEXPORT jboolean JNICALL OS_NATIVE( QWebView_1swt_1canGoBack ) - ( JNIEnv* aJniEnv , jclass, jint -#ifndef QT_NO_WEBKIT -aHandle -#endif -) - { - jboolean res = false; - SWT_TRY - { - SWT_LOG_JNI_CALL(); -#ifndef QT_NO_WEBKIT - HANDLE_TO_POINTER( QWebView*, browser, aHandle ); - QWebHistory* history = browser->history(); - if ( history ) - { - res = history->canGoBack(); - } -#endif - } - SWT_CATCH - return res; - } - -JNIEXPORT jboolean JNICALL OS_NATIVE( QWebView_1swt_1canGoForward ) - ( JNIEnv* aJniEnv , jclass, jint -#ifndef QT_NO_WEBKIT -aHandle -#endif -) - { - jboolean res = false; - SWT_TRY - { - SWT_LOG_JNI_CALL(); -#ifndef QT_NO_WEBKIT - HANDLE_TO_POINTER( QWebView*, browser, aHandle ); - QWebHistory* history = browser->history(); - if ( history ) - { - res = history->canGoForward(); - } -#endif - } - SWT_CATCH - return res; - } - -JNIEXPORT jboolean JNICALL OS_NATIVE( QWebView_1swt_1evaluateJavaScript ) - ( JNIEnv* aJniEnv , jclass, jint -#ifndef QT_NO_WEBKIT -aHandle -#endif -, jstring -#ifndef QT_NO_WEBKIT -aText -#endif -) - { - jboolean res = false; - SWT_TRY - { - SWT_LOG_JNI_CALL(); -#ifndef QT_NO_WEBKIT - HANDLE_TO_POINTER( QWebView*, browser, aHandle ); - QWebPage* page = browser->page(); - if ( page ) - { - QWebFrame* frame = page->currentFrame(); - if ( !frame ) - { - frame = page->mainFrame(); - } - if ( frame ) - { - res = ( frame->evaluateJavaScript( swtApp->jniUtils().JavaStringToQString( aJniEnv, aText ) ) ).toBool(); - } - } -#endif - } - SWT_CATCH - return res; - } - -JNIEXPORT jstring JNICALL OS_NATIVE( QWebView_1swt_1forwardUrl ) - ( JNIEnv* aJniEnv , jclass, jint -#ifndef QT_NO_WEBKIT -aHandle -#endif -) - { - jstring res = NULL; - SWT_TRY - { - SWT_LOG_JNI_CALL(); -#ifndef QT_NO_WEBKIT - HANDLE_TO_POINTER( QWebView*, browser, aHandle ); - QWebHistory* history = browser->history(); - if ( history && history->canGoForward() ) - { - res = swtApp->jniUtils().QStringToJavaString( aJniEnv, history->forwardItem().url().toString() ); - } -#endif - } - SWT_CATCH - return res; - } - -JNIEXPORT jstring JNICALL OS_NATIVE( QWebView_1url ) - ( JNIEnv* aJniEnv , jclass, jint -#ifndef QT_NO_WEBKIT -aHandle -#endif -) - { - jstring res = NULL; - SWT_TRY - { - SWT_LOG_JNI_CALL(); -#ifndef QT_NO_WEBKIT - HANDLE_TO_POINTER( QWebView*, browser, aHandle ); - res = swtApp->jniUtils().QStringToJavaString( aJniEnv, browser->url().toString() ); -#endif - } - SWT_CATCH - return res; - } - // // Special purpose global functions exported by Qt // @@ -11730,7 +11407,6 @@ { #ifdef __SYMBIAN32__ bool result = false; - XQServiceRequest* client = NULL; SWT_TRY { SWT_LOG_JNI_CALL(); @@ -12110,6 +11786,24 @@ } JNIEXPORT jint JNICALL OS_NATIVE(SignalHandler_1new) + (JNIEnv* aJniEnv, jclass, jint aWidget, jint aSignalId ) + { + SlotCallback* cb = NULL; + SWT_TRY + { + SWT_LOG_JNI_CALL(); + SWT_LOG_DATA_1("peer=%x", aPeer); + + HANDLE_TO_POINTER( QObject*, widget, aWidget ); + + // Widget takes ownership of the signal handler instance + cb = new SlotCallback( aJniEnv, NULL, widget, aSignalId ); + } + SWT_CATCH + return POINTER_TO_HANDLE( cb ); + } + +JNIEXPORT jint JNICALL OS_NATIVE(SignalForwarder_1new) (JNIEnv* aJniEnv, jclass, jint aWidget, jobject aPeer, jint aSignalId ) { SlotCallback* cb = NULL; @@ -12128,12 +11822,12 @@ } JNIEXPORT jint JNICALL OS_NATIVE( JniUtils_1new ) - (JNIEnv* aJniEnv, jclass, jobject aDisplay) + (JNIEnv* aJniEnv, jclass) { // Note that JNI callbacks are not possible before first successfully creating jniUtils JniUtils* jniUtils = NULL; try { - jniUtils = new JniUtils(aJniEnv, aDisplay); + jniUtils = new JniUtils(aJniEnv); } catch(...) { @@ -12220,7 +11914,7 @@ (JNIEnv*, jclass, jobject, jint) #endif { - jint retVal = 0; + jint retVal = -1; #ifdef __SYMBIAN32__ retVal = static_cast(SymbianUtils::startUI( aJniEnv, aRunner, aUid)); #endif diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/slotcallback.cpp --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/slotcallback.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/slotcallback.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -21,9 +21,9 @@ #include "QListWidgetItem" #include "slotcallback.h" -#include "swt.h" #include "jniutils.h" #include "swtapplication.h" +#include "swtlog.h" using namespace Java::eSWT; @@ -38,7 +38,7 @@ // If Java peer is not Display then jobject ref and methodID are needed. // Otherwise they are managed by JniUtils. - if (!swtApp->jniUtils().isDisplay(aPeer)) + if (aPeer != NULL) { mPeer = aJniEnv->NewGlobalRef(aPeer); if(!mPeer) @@ -70,7 +70,7 @@ if (mPeer) { // Call non-Display peer using our own jobject ref and jmethodID - jniUtils.eventProcess(mPeer, mJmethod, reinterpret_cast(parent()), mSignalId, a1, a2, a3, a4, a5, aString); + jniUtils.eventProcess(mPeer, mJmethod, parent(), mSignalId, a1, a2, a3, a4, a5, aString); } else { diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/slotcallback.h --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/slotcallback.h Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/slotcallback.h Fri Jun 11 13:33:44 2010 +0300 @@ -16,9 +16,7 @@ #ifndef QT_NO_SYSTEMTRAYICON #include #endif -#include "swtlog.h" #include "jni.h" -#include "swt.h" class QPoint; class QItemSelection; @@ -39,8 +37,10 @@ * Constructor. * @param aJniEnv JNIEnv pointer for the GUI thread. * @param aPeer Local ref to the peer jobject that signals are forwarded to - * @param aParent Source QObject of the signal - * @param aSignalId Signal ID that will be used to identify the signal in Java code + * or NULL if forwarded to a class (static) method of the + * class Display. + * @param aParent Source QObject of the signal. + * @param aSignalId Signal ID that will be used to identify the signal in Java code. */ SlotCallback( JNIEnv* aJniEnv, jobject aPeer, diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/swt.h --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/swt.h Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/swt.h Fri Jun 11 13:33:44 2010 +0300 @@ -12,49 +12,37 @@ #ifndef _SWT_H_ #define _SWT_H_ -namespace Java { namespace eSWT { +#include "swterror.h" + +// Pointer-handle conversion macros + +#define POINTER_TO_HANDLE(pointer) reinterpret_cast(static_cast(pointer)) +#define HANDLE_TO_POINTER(type, variable, handle) type variable = qobject_cast(static_cast(reinterpret_cast( handle ))) + +#define QCOLOR_TO_HANDLE(pointer) reinterpret_cast(static_cast(pointer)) +#define HANDLE_TO_QCOLOR(variable, handle) QColor* variable = static_cast(reinterpret_cast( handle )) + +#define QTABLEWIDGETITEM_TO_HANDLE(pointer) reinterpret_cast(static_cast(pointer)) +#define HANDLE_TO_QTABLEWIDGETITEM(variable, handle) QTableWidgetItem* variable = static_cast(reinterpret_cast( handle )) +#define QTREEWIDGETITEM_TO_HANDLE(pointer) reinterpret_cast(static_cast(pointer)) +#define HANDLE_TO_QTREEWIDGETITEM(variable, handle) QTreeWidgetItem* variable = static_cast(reinterpret_cast( handle )) -enum SwtError - { - ESwtErrorNone = 0, - ESwtErrorUnspecified = 1, - ESwtErrorNoHandles = 2, - ESwtErrorNoMoreCallbacks = 3, - ESwtErrorNullArgument = 4, - ESwtErrorInvalidArgument = 5, - ESwtErrorInvalidRange = 6, - ESwtErrorCannotBeZero = 7, - ESwtErrorCannotGetItem = 8, - ESwtErrorCannotGetSelection = 9, - ESwtErrorCannotGetItemHeight = 11, - ESwtErrorCannotGetText = 12, - ESwtErrorCannotSetText = 13, - ESwtErrorItemNotAdded = 14, - ESwtErrorItemNotRemoved = 15, - ESwtErrorNotImplemented = 20, - ESwtErrorMenuNotDropDown = 21, - ESwtErrorThreadInvalidAccess = 22, - ESwtErrorWidgetDisposed = 24, - ESwtErrorMenuItemNotCascade = 27, - ESwtErrorCannotSetSelection = 28, - ESwtErrorCannotSetMenu = 29, - ESwtErrorCannotSetEnabled = 30, - ESwtErrorCannotGetEnabled = 31, - ESwtErrorInvalidParent = 32, - ESwtErrorMenuNotBar = 33, - ESwtErrorCannotGetCount = 36, - ESwtErrorMenuNotPopUp = 37, - ESwtErrorUnsupportedDepth = 38, - ESwtErrorIO = 39, - ESwtErrorInvalidImage = 40, - ESwtErrorUnsupportedFormat = 42, - ESwtErrorInvalidSubclass = 43, - ESwtErrorGraphicDisposed = 44, - ESwtErrorDeviceDisposed = 45, - ESwtErrorFailedExec = 46, - ESwtErrorFailedLoadLibrary = 47 - }; +// Try-catch macros for to be used in the JNI functions -}} +#define SWT_TRY try +#define SWT_CATCH \ +catch(std::bad_alloc const&)\ + {\ + swtApp->jniUtils().Throw( aJniEnv, ESwtErrorNoHandles );\ + }\ +catch(std::exception const&)\ + {\ + swtApp->jniUtils().Throw( aJniEnv, ESwtErrorUnspecified );\ + } +#define SWT_CATCH_1(err) \ +catch(std::exception const&)\ + {\ + swtApp->jniUtils().Throw( aJniEnv, err );\ + } #endif // _SWT_H_ diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/swt.pro --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/swt.pro Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/swt.pro Fri Jun 11 13:33:44 2010 +0300 @@ -9,19 +9,18 @@ # Nokia Corporation - initial implementation #******************************************************************************/ -TEMPLATE = lib -TARGET = eswtqt +SWTLIBNAME = eswtqt +SWTGENERATEDDIR = $$PWD/generated/$$SWTLIBNAME -QT += core \ - gui \ - webkit +TEMPLATE = lib +TARGET = $$SWTLIBNAME -MOC_DIR= ./generated +MOC_DIR= $$SWTGENERATEDDIR include(eswt_widgets.pri) include(./graphics/graphics.pri) unix { - INCLUDEPATH +=$(JAVA_HOME)/include \ + INCLUDEPATH += $(JAVA_HOME)/include \ $(JAVA_HOME)/include/linux } @@ -29,39 +28,6 @@ INCLUDEPATH += $(JAVA_HOME)/include \ $(JAVA_HOME)/include/win32 - # Required for win32, can be replaced with an auto-generate - DEF_FILE = swt.def + # Required for win32, can be replaced with an auto-generate + DEF_FILE = swt.def } - -symbian { - TARGET.UID =0x101FD687 - TARGET.CAPABILITY ="ALL -TCB" - - # Temporarily allow WSD, to be removed later if possible - TARGET.EPOCALLOWDLLDATA = 1 - - # Prepend to includepath to avoid problems with Qt's overriding files - INCLUDEPATH = \epoc32\include \ - \epoc32\include\stdapis \ - \epoc32\include\osextensions\stdapis\sys \ - \epoc32\include\osextensions\stdapis\stlport \ - \epoc32\include\osextensions\stdapis\stlport\stl \ - $$INCLUDEPATH - - INCLUDEPATH += \epoc32\include\middleware \ - \epoc32\include\domain\middleware - - # J9 VM specific definitions - DEFINES+=J9EPOC32 - - # Std cpp requirements - LIBS += -llibc - LIBS += -leuser - LIBS += -llibstdcpp - - DEFINES+= MACRO_WCHAR_T_DECLARED - QMAKE_CXXFLAGS.CW += -wchar_t on - - # jni lookup - SOURCES += $$PWD/generated/jni_lookup.cpp -} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/swtapplication.cpp --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/swtapplication.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/swtapplication.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -21,16 +21,12 @@ #include "swtapplication.h" #include "jniutils.h" #include "swtfontcache.h" -#include "swt.h" #include "swtlog.h" #ifdef __SYMBIAN32__ #include "swts60.h" #endif - - - using namespace Java::eSWT; SwtApplication::SwtApplication(int &argc, char **argv, JniUtils* aJniUtils, int version) diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/swtapplication.h --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/swtapplication.h Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/swtapplication.h Fri Jun 11 13:33:44 2010 +0300 @@ -128,13 +128,13 @@ QEvent* mEvent; }; - QTime mStartTime; - QPointer mJniUtils; - SwtFontCache* mFontCache; QVector mDeferredEvents; #ifdef __SYMBIAN32__ CSwtMobileDevice* iMobileDevice; #endif + QPointer mJniUtils; + SwtFontCache* mFontCache; + QTime mStartTime; }; } diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/swterror.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/swterror.h Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia Corporation - initial implementation + *******************************************************************************/ + +#ifndef SWTERROR_H_ +#define SWTERROR_H_ + +namespace Java { namespace eSWT { + +// SWT error types used for throwing Java exceptions. +// Values duplicated from Java definitions. +enum SwtError + { + ESwtErrorNone = 0, + ESwtErrorUnspecified = 1, + ESwtErrorNoHandles = 2, + ESwtErrorNoMoreCallbacks = 3, + ESwtErrorNullArgument = 4, + ESwtErrorInvalidArgument = 5, + ESwtErrorInvalidRange = 6, + ESwtErrorCannotBeZero = 7, + ESwtErrorCannotGetItem = 8, + ESwtErrorCannotGetSelection = 9, + ESwtErrorCannotGetItemHeight = 11, + ESwtErrorCannotGetText = 12, + ESwtErrorCannotSetText = 13, + ESwtErrorItemNotAdded = 14, + ESwtErrorItemNotRemoved = 15, + ESwtErrorNotImplemented = 20, + ESwtErrorMenuNotDropDown = 21, + ESwtErrorThreadInvalidAccess = 22, + ESwtErrorWidgetDisposed = 24, + ESwtErrorMenuItemNotCascade = 27, + ESwtErrorCannotSetSelection = 28, + ESwtErrorCannotSetMenu = 29, + ESwtErrorCannotSetEnabled = 30, + ESwtErrorCannotGetEnabled = 31, + ESwtErrorInvalidParent = 32, + ESwtErrorMenuNotBar = 33, + ESwtErrorCannotGetCount = 36, + ESwtErrorMenuNotPopUp = 37, + ESwtErrorUnsupportedDepth = 38, + ESwtErrorIO = 39, + ESwtErrorInvalidImage = 40, + ESwtErrorUnsupportedFormat = 42, + ESwtErrorInvalidSubclass = 43, + ESwtErrorGraphicDisposed = 44, + ESwtErrorDeviceDisposed = 45, + ESwtErrorFailedExec = 46, + ESwtErrorFailedLoadLibrary = 47 + }; + +}} // namespaces + +#endif /* SWTERROR_H_ */ diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/swtexport.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/swtexport.h Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia Corporation - initial implementation + *******************************************************************************/ + +#ifndef SWTEXPORT_H_ +#define SWTEXPORT_H_ + +// Macros for exporting/importing symbols using the correct Qt-macro. +// SWTQT_LIBRARY is defined in the Qt project file of the exporting library. + +#if defined(SWTQT_LIBRARY) +# define SWTQT_EXPORT Q_DECL_EXPORT +#else +# define SWTQT_EXPORT Q_DECL_IMPORT +#endif + +#endif /* SWTEXPORT_H_ */ diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/swtmobiledevice.cpp --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/swtmobiledevice.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/swtmobiledevice.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -42,9 +42,10 @@ // --------------------------------------------------------------------------- // CSwtMobileDevice::CSwtMobileDevice() - :iSupportedLights(CHWRMLight::ENoTarget), - iLightLevel(KErrNotFound), - iHWRMLight(NULL), iVibra(NULL) + : iVibra(NULL), + iHWRMLight(NULL), + iSupportedLights(CHWRMLight::ENoTarget), + iLightLevel(KErrNotFound) { } diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/swts60.cpp --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/swts60.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/swts60.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -38,8 +38,8 @@ // Stack size for the UI thread, 0x14000 = 80kB const TInt KSwtUiThreadStackSize = 0x14000; -// Stack size for the support thread, 0x200 = 0.5kB -const TInt KSwtSupportThreadStackSize = 0x200; +// Stack size for the support thread, 0x1F40 = 8kB +const TInt KSwtSupportThreadStackSize = 0x1F40; static const char* const EVENT_FILTER = "swt_event_filter"; @@ -449,6 +449,7 @@ // Wait until the process dies. If the UI thread dies notify MIDP // application management software that the MIDlet should die. + // This is a workaround until QTBUG-5284 is resolved. while(ETrue) { User::WaitForAnyRequest(); diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/webkit/eswt_webkit.pri --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/webkit/eswt_webkit.pri Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,21 @@ +#******************************************************************************* +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Nokia Corporation - initial implementation +#******************************************************************************* + +QT += core \ + gui \ + webkit + +INCLUDEPATH += $$PWD $$PWD/.. +DEPENDPATH += $$PWD + +SOURCES += os.cpp + +LIBS += -leswtqt diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/webkit/os.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/webkit/os.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,316 @@ +/******************************************************************************* + * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia Corporation - initial implementation + *******************************************************************************/ + +#ifndef QT_NO_WEBKIT +#include +#include +#include +#endif + +#include "org_eclipse_swt_internal_qt_webkit_OS_0005fwebkit.h" +#include "swt.h" +#include "swtlog.h" +#include "swtapplication.h" +#include "jniutils.h" + +#define OS_NATIVE(func) Java_org_eclipse_swt_internal_qt_webkit_OS_1webkit_##func + +using namespace Java::eSWT; + +// +// QWebView +// +JNIEXPORT jint JNICALL OS_NATIVE( QWebView_1new ) + ( JNIEnv* aJniEnv , jclass ) + { +#ifndef QT_NO_WEBKIT + QWebView* browser = NULL; + SWT_TRY + { + SWT_LOG_JNI_CALL(); + browser = new QWebView(); + } + SWT_CATCH + return POINTER_TO_HANDLE( browser ); +#endif +#ifdef QT_NO_WEBKIT + swtApp->jniUtils().Throw( aJniEnv, ESwtErrorNotImplemented ); + return 0; +#endif + } + +JNIEXPORT void JNICALL OS_NATIVE( QWebView_1back ) + ( JNIEnv* aJniEnv , jclass, jint +#ifndef QT_NO_WEBKIT +aHandle +#endif +) + { + SWT_TRY + { + SWT_LOG_JNI_CALL(); +#ifndef QT_NO_WEBKIT + HANDLE_TO_POINTER( QWebView*, browser, aHandle ); + browser->back(); +#endif + } + SWT_CATCH + } + +JNIEXPORT void JNICALL OS_NATIVE( QWebView_1forward ) + ( JNIEnv* aJniEnv , jclass, jint +#ifndef QT_NO_WEBKIT +aHandle +#endif +) + { + SWT_TRY + { + SWT_LOG_JNI_CALL(); +#ifndef QT_NO_WEBKIT + HANDLE_TO_POINTER( QWebView*, browser, aHandle ); + browser->forward(); +#endif + } + SWT_CATCH + } + +JNIEXPORT void JNICALL OS_NATIVE( QWebView_1reload ) + ( JNIEnv* aJniEnv , jclass, jint +#ifndef QT_NO_WEBKIT +aHandle +#endif +) + { + SWT_TRY + { + SWT_LOG_JNI_CALL(); +#ifndef QT_NO_WEBKIT + HANDLE_TO_POINTER( QWebView*, browser, aHandle ); + browser->reload(); +#endif + } + SWT_CATCH + } + +JNIEXPORT void JNICALL OS_NATIVE( QWebView_1setHtml ) + ( JNIEnv* aJniEnv , jclass, jint +#ifndef QT_NO_WEBKIT +aHandle +#endif +, jstring +#ifndef QT_NO_WEBKIT +aText +#endif +) + { + SWT_TRY + { + SWT_LOG_JNI_CALL(); +#ifndef QT_NO_WEBKIT + HANDLE_TO_POINTER( QWebView*, browser, aHandle ); + browser->setHtml( swtApp->jniUtils().JavaStringToQString( aJniEnv, aText ) ); +#endif + } + SWT_CATCH + } + +JNIEXPORT void JNICALL OS_NATIVE( QWebView_1setUrl ) + ( JNIEnv* aJniEnv , jclass, jint +#ifndef QT_NO_WEBKIT +aHandle +#endif +, jstring +#ifndef QT_NO_WEBKIT +aText +#endif +) + { + SWT_TRY + { + SWT_LOG_JNI_CALL(); +#ifndef QT_NO_WEBKIT + HANDLE_TO_POINTER( QWebView*, browser, aHandle ); + browser->setUrl( QUrl( swtApp->jniUtils().JavaStringToQString( aJniEnv, aText ) ) ); +#endif + } + SWT_CATCH + } + +JNIEXPORT void JNICALL OS_NATIVE( QWebView_1stop ) + ( JNIEnv* aJniEnv , jclass, jint +#ifndef QT_NO_WEBKIT +aHandle +#endif +) + { + SWT_TRY + { + SWT_LOG_JNI_CALL(); +#ifndef QT_NO_WEBKIT + HANDLE_TO_POINTER( QWebView*, browser, aHandle ); + browser->stop(); +#endif + } + SWT_CATCH + } + +JNIEXPORT jstring JNICALL OS_NATIVE( QWebView_1swt_1backUrl ) + ( JNIEnv* aJniEnv , jclass, jint +#ifndef QT_NO_WEBKIT +aHandle +#endif +) + { + jstring res = NULL; + SWT_TRY + { + SWT_LOG_JNI_CALL(); +#ifndef QT_NO_WEBKIT + HANDLE_TO_POINTER( QWebView*, browser, aHandle ); + QWebHistory* history = browser->history(); + if ( history && history->canGoBack() ) + { + res = swtApp->jniUtils().QStringToJavaString( aJniEnv, history->backItem().url().toString() ); + } +#endif + } + SWT_CATCH + return res; + } + +JNIEXPORT jboolean JNICALL OS_NATIVE( QWebView_1swt_1canGoBack ) + ( JNIEnv* aJniEnv , jclass, jint +#ifndef QT_NO_WEBKIT +aHandle +#endif +) + { + jboolean res = false; + SWT_TRY + { + SWT_LOG_JNI_CALL(); +#ifndef QT_NO_WEBKIT + HANDLE_TO_POINTER( QWebView*, browser, aHandle ); + QWebHistory* history = browser->history(); + if ( history ) + { + res = history->canGoBack(); + } +#endif + } + SWT_CATCH + return res; + } + +JNIEXPORT jboolean JNICALL OS_NATIVE( QWebView_1swt_1canGoForward ) + ( JNIEnv* aJniEnv , jclass, jint +#ifndef QT_NO_WEBKIT +aHandle +#endif +) + { + jboolean res = false; + SWT_TRY + { + SWT_LOG_JNI_CALL(); +#ifndef QT_NO_WEBKIT + HANDLE_TO_POINTER( QWebView*, browser, aHandle ); + QWebHistory* history = browser->history(); + if ( history ) + { + res = history->canGoForward(); + } +#endif + } + SWT_CATCH + return res; + } + +JNIEXPORT jboolean JNICALL OS_NATIVE( QWebView_1swt_1evaluateJavaScript ) + ( JNIEnv* aJniEnv , jclass, jint +#ifndef QT_NO_WEBKIT +aHandle +#endif +, jstring +#ifndef QT_NO_WEBKIT +aText +#endif +) + { + jboolean res = false; + SWT_TRY + { + SWT_LOG_JNI_CALL(); +#ifndef QT_NO_WEBKIT + HANDLE_TO_POINTER( QWebView*, browser, aHandle ); + QWebPage* page = browser->page(); + if ( page ) + { + QWebFrame* frame = page->currentFrame(); + if ( !frame ) + { + frame = page->mainFrame(); + } + if ( frame ) + { + res = ( frame->evaluateJavaScript( swtApp->jniUtils().JavaStringToQString( aJniEnv, aText ) ) ).toBool(); + } + } +#endif + } + SWT_CATCH + return res; + } + +JNIEXPORT jstring JNICALL OS_NATIVE( QWebView_1swt_1forwardUrl ) + ( JNIEnv* aJniEnv , jclass, jint +#ifndef QT_NO_WEBKIT +aHandle +#endif +) + { + jstring res = NULL; + SWT_TRY + { + SWT_LOG_JNI_CALL(); +#ifndef QT_NO_WEBKIT + HANDLE_TO_POINTER( QWebView*, browser, aHandle ); + QWebHistory* history = browser->history(); + if ( history && history->canGoForward() ) + { + res = swtApp->jniUtils().QStringToJavaString( aJniEnv, history->forwardItem().url().toString() ); + } +#endif + } + SWT_CATCH + return res; + } + +JNIEXPORT jstring JNICALL OS_NATIVE( QWebView_1url ) + ( JNIEnv* aJniEnv , jclass, jint +#ifndef QT_NO_WEBKIT +aHandle +#endif +) + { + jstring res = NULL; + SWT_TRY + { + SWT_LOG_JNI_CALL(); +#ifndef QT_NO_WEBKIT + HANDLE_TO_POINTER( QWebView*, browser, aHandle ); + res = swtApp->jniUtils().QStringToJavaString( aJniEnv, browser->url().toString() ); +#endif + } + SWT_CATCH + return res; + } diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/webkit/swt.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/webkit/swt.pro Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,40 @@ +#****************************************************************************** +# Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Nokia Corporation - initial implementation +#******************************************************************************/ + +SWTLIBNAME = eswtqtwebkit +SWTGENERATEDDIR = ../generated/$$SWTLIBNAME + +TEMPLATE = lib +TARGET = $$SWTLIBNAME + +MOC_DIR= $$SWTGENERATEDDIR + +# Locate the main eswtqt lib +CONFIG(debug, debug|release) { + LIBS += -L../debug +} else { + LIBS += -L../release +} + +include(eswt_webkit.pri) + +unix { + INCLUDEPATH += $(JAVA_HOME)/include \ + $(JAVA_HOME)/include/linux +} + +win32 { + INCLUDEPATH += $(JAVA_HOME)/include \ + $(JAVA_HOME)/include/win32 + + # Required for win32, can be replaced with an auto-generate + DEF_FILE = swt.def +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/graphics/Internal_GfxPackageSupport.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/graphics/Internal_GfxPackageSupport.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/graphics/Internal_GfxPackageSupport.java Fri Jun 11 13:33:44 2010 +0300 @@ -39,6 +39,15 @@ public static int getPixmapHandle(Image i) { return i.getPixmapHandle(); } +/* + * From the class Device + */ +public static boolean internal(Device d) { + return d.internal; +} +public static boolean initialized() { + return Device.initialized; +} public static Color newColor(Device device, int handle) { return Color.qt_new(device, handle); diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/ApplicationUIListener.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/ApplicationUIListener.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,23 @@ +/******************************************************************************* + * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia Corporation - initial implementation + *******************************************************************************/ +package org.eclipse.swt.internal.qt; + +/** + * An internal interface for providing notifications about the state of the UI + * during the life-time of the application. + */ +public interface ApplicationUIListener { + /** + * Called when the application requests the UI thread to call back a + * Runnable that the application provided. + */ + public void applicationUIThreadRequest(); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/BaseCSSEngine.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/BaseCSSEngine.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/BaseCSSEngine.java Fri Jun 11 13:33:44 2010 +0300 @@ -38,7 +38,7 @@ public BaseCSSEngine(Display display){ if (display == null) SWT.error (SWT.ERROR_NULL_ARGUMENT); if (display.isDisposed ()) SWT.error (SWT.ERROR_INVALID_ARGUMENT); - if (Display.getCurrent() == null ) SWT.error (SWT.ERROR_THREAD_INVALID_ACCESS); + if (display.getThread() != Thread.currentThread()) SWT.error (SWT.ERROR_THREAD_INVALID_ACCESS); this.parent = display; } @@ -145,12 +145,14 @@ * */ public void dispose(){ - if (Display.getCurrent() == null ) SWT.error (SWT.ERROR_THREAD_INVALID_ACCESS); - parent = null; + if(parent != null) { + if (parent.getThread() != Thread.currentThread()) SWT.error (SWT.ERROR_THREAD_INVALID_ACCESS); + parent = null; + } } private void checkEngine(){ if ( parent == null || parent.isDisposed() ) SWT.error( SWT.ERROR_WIDGET_DISPOSED); - if (Display.getCurrent() == null ) SWT.error (SWT.ERROR_THREAD_INVALID_ACCESS); + if ( parent.getThread() != Thread.currentThread() ) SWT.error (SWT.ERROR_THREAD_INVALID_ACCESS); } } diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/CommandArranger.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/CommandArranger.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/CommandArranger.java Fri Jun 11 13:33:44 2010 +0300 @@ -64,7 +64,6 @@ Command[] newList = new Command[size]; // find the insertion point so that the order is correct int insertPoint = 0; - Display display = Display.getCurrent(); Shell activeShell = display.getActiveShell(); Control ctrl = display.getFocusControl(); while (ctrl != null && ctrl != activeShell) { @@ -170,9 +169,11 @@ private CommandCollection currentCommands; private CommandPresentationStrategy strategy; private Command defaultCommand; + private Display display; - public CommandArranger(){ + public CommandArranger(Display display){ super(); + this.display = display; currentCommands = new CommandCollection(); strategy = CommandPresentationStrategyWrapper.createStrategy(); } @@ -206,7 +207,6 @@ * @see Control#qt_swt_event_focusWasGained() */ public void focusedControlChanged(){ - Display display = Display.getCurrent(); Control focusControl = display.getFocusControl(); if (focusControl == focusedControl) { return; @@ -263,6 +263,7 @@ strategy.dispose(); strategy = null; currentCommands = null; + display = null; } /** * Called when a Command is set default diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/OS.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/OS.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/OS.java Fri Jun 11 13:33:44 2010 +0300 @@ -167,7 +167,6 @@ // QInputContextFactory key public static final String QINPUTCONTEXT_COEFEP = "coefep"; - // CntServicesContact actions public static final String CNT_ACTIONALL = "all"; public static final String CNT_ACTIONCALL ="call"; @@ -178,9 +177,6 @@ public static final String CNT_DISPLAYALL = "all"; public static final String CNT_FILTERDISPLAYFAVORITES = "favorites"; - - - // Implementation specific codes for the signals emitted by the Qt widgets public static final int QSIGNAL_ID_RANGE_FIRST = 1000; public static final int QSIGNAL_PRESSED = QSIGNAL_ID_RANGE_FIRST; @@ -1502,23 +1498,6 @@ int max, int defaultValue, String dialogId, int layoutDirection); // - // QWebView - // - public static final native int QWebView_new(); - public static final native void QWebView_back(int handle); - public static final native void QWebView_forward(int handle); - public static final native void QWebView_reload(int handle); - public static final native void QWebView_setHtml(int handle, String html); - public static final native void QWebView_setUrl(int handle, String url); - public static final native void QWebView_stop(int handle); - public static final native String QWebView_swt_backUrl(int handle); - public static final native boolean QWebView_swt_canGoBack(int handle); - public static final native boolean QWebView_swt_canGoForward(int handle); - public static final native boolean QWebView_swt_evaluateJavaScript(int handle, String script); - public static final native String QWebView_swt_forwardUrl(int handle); - public static final native String QWebView_url(int handle); - - // // QSystemTrayIcon // public static final native boolean QSystemTrayIcon_isSystemTrayAvailable(); @@ -1727,22 +1706,32 @@ // Other // public static final native int EventHandler_new( ); - public static final native void EventHandler_destroy( int handle ); + public static final native void EventHandler_destroy(int handle); + /** - * Creates a QObject which implements slots to receive the signals and passes - * them to Java along with signal parameters and the signal id. + * Creates a QObject which implements slots to receive signals and passes + * them to the Display along with the signal parameters and the signal id. * @param widget The handle of the widget which will send the signal. - * @param peer The peer Java object where signal is delivered to (The Display) * @param signalId The id that can be used to identify the signal. - * @return handle of the slot object, owned by the widget + * @return Handle of the slot object, owned by the widget that was passed as the first parameter. */ - public static final native int SignalHandler_new( int widget, Object peer, int signalId ); + public static final native int SignalHandler_new(int widget, int signalId); + + /** + * Creates a QObject which implements slots to receive signals and forwards + * them to the given Object along with the signal parameters and the signal id. + * @param widget The handle of the widget which will send the signal. + * @param peer The peer Java object where the signal is delivered to. + * @param signalId The id that can be used to identify the signal. + * @return Handle of the slot object, owned by the widget that was passed as the first parameter. + */ + public static final native int SignalForwarder_new(int widget, Object peer, int signalId); + /** * Creates the JNI utility used for all JNI activity. - * @param display The Display * @return handle or 0 in case of failure, doesn't throw an exception */ - public static final native int JniUtils_new(Object display); + public static final native int JniUtils_new(); /** * Performs a check if the QObject can be safely deleted immediately. If not @@ -1750,6 +1739,7 @@ * be deleted safely e.g. when inside an event listener of the object. */ public static final native boolean JniUtils_safeToDelete(int handle, int qObjectHandle); + private static final native int windowServer(); /** @@ -1759,6 +1749,7 @@ * @return 0 in case of success, non-zero in case of failure. */ public static final native int initUiThread(int uid); + /** * Some platforms require initialization before Qt-APIs can be used * and cleaning up after the application is done with them. This method will @@ -1766,10 +1757,7 @@ */ public static final native void cleanUpUiThread(); - // Add new stuff above Other, Other is the last category - - public static final native void setSymbianAppName(String name); - + // Add new stuff above the category "Other", that is the last category } diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/UIThreadManager.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/UIThreadManager.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,184 @@ +/******************************************************************************* + * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia Corporation - initial implementation + *******************************************************************************/ + +package org.eclipse.swt.internal.qt; + +import org.eclipse.swt.internal.qt.ApplicationUIListener; +import org.eclipse.swt.internal.qt.midp.UIThreadLauncher; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Internal_PackageSupport; +import org.eclipse.swt.widgets.Shell; + +/** + * A class that manages the UI thread hand-over from the internal UI event loop + * to the application. + */ +public final class UIThreadManager { + private static Object lock = new Object(); + private static boolean threadWaitingForApplication; + private static Runnable applicationRunnable; + private static ApplicationUIListener applicationUIListener; + + /** + * Pass the control of the thread to the application by calling a Runnable + * provided by the application. If the Runnable has not yet been provided + * then the thread waits until it becomes available, or the wait is aborted + * by calling abortWait(). + */ + public static void runApplicationUI() { + synchronized(lock) { + if(!applicationWaiting()) { + waitForApplication(); + } + callback(); + } + } + + /** + * If the UI thread is waiting for the application to request the callback + * in the UI thread then calling this will abort the wait and make the UI + * thread to return back from the runApplicationUI(). + */ + public static void abortWait() { + synchronized(lock) { + lock.notify(); + } + } + + /** + * Called indirectly by the application when it's requesting the UI thread. + * Application will pass a Runnable as a parameter and expects it to get called + * in the UI thread. + * + * @param runnable + * The Runnable to call in the UI thread. + * @return True if obtaining the UI thread was successful and the runnable + * will be called. + */ + public static boolean startInUIThread(Runnable runnable) { + synchronized(lock) { + applicationRunnable = runnable; + if(threadWaitingForApplication) { + lock.notify(); + } else { + if(!waitForUIThread()) { + // If the internal UI has not been created then it can't be + // signaled and we can't wait for it. This must mean there's + // no UI thread yet in the process and we can create it here. + if(!UIThreadLauncher.startInUIThread(runnable)) { + return false; + } + } + } + } + return true; + } + + /** + * Sets the listener that will be notified of the state of the UI during its + * life-time. + */ + public static void setApplicationUIListener(ApplicationUIListener listener) { + synchronized(lock) { + applicationUIListener = listener; + } + } + + /* + * Signal the internal UI loop and wait until it passes the control of the + * UI thread into runApplicationUI(). Return false if the internal UI can't + * be signaled. + */ + private static boolean waitForUIThread() { + if(signalUIThreadRequest()) { + try { + lock.wait(); + } catch(InterruptedException e) { + // Nothing to do + } + return true; + } + return false; + } + + /* + * Wait until signaled by the application requesting the callback to its + * Runnable, or by abortWait(). + */ + private static void waitForApplication() { + threadWaitingForApplication = true; + try { + lock.wait(); + } catch(InterruptedException e) { + // Nothing to do + } finally { + threadWaitingForApplication = false; + } + } + + /* + * Returns true if application has provided the Runnable and is thus waiting + * for the callback. + */ + private static boolean applicationWaiting() { + return (applicationRunnable != null); + } + + /* + * Post an event to the internal Display to request the control of the UI + * thread. After this runApplication() should get called in the UI thread. + */ + private static boolean signalUIThreadRequest() { + Display internalDisplay = Internal_PackageSupport.getInternalDisplayInstance(); + if(internalDisplay != null) { + if(applicationUIListener != null) { + applicationUIListener.applicationUIThreadRequest(); + } + return true; + } + return false; + } + + /* + * Call back the application's runnable + */ + private static void callback() { + try { + if(applicationRunnable != null) { + flushInternals(); + applicationRunnable.run(); + } + } finally { + applicationRunnable = null; + } + } + + /* + * Clear any events or other items possibly left over by any previous usage + * of the UI resources. There must not be anything that can interfere with + * the application. It must appear as the application starts with an + * uninitialized UI. + */ + private static void flushInternals() { + Display internalDisplay = Internal_PackageSupport.getInternalDisplayInstance(); + + // Dispose all widgets + Shell[] shells = internalDisplay.getShells(); + for(int i = 0; i < shells.length; ++i) { + if(shells[i] != null && !shells[i].isDisposed()) { + shells[i].dispose(); + } + } + + // Flush the event queue + while(internalDisplay.readAndDispatch()) {} + } +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/graphics/GraphicsContext.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/graphics/GraphicsContext.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/graphics/GraphicsContext.java Fri Jun 11 13:33:44 2010 +0300 @@ -1136,6 +1136,28 @@ } /** + * Draws given WindowSurface. Supported only when WindowSurface + * uses local off-screen image as draw surface. + * The defined rectangular area is drawn to the same x and y position in the + * target as the given arguments x and y specify. + * + * @param surface The WindowSurface to draw + * @param x The x-coordinate of the source area to draw + * @param y The y-coordinate of the source area to draw + * @param width The width of the source area to draw + * @param height The height of the source area to draw + * @throws NullPointerException if surface is null + */ + public void drawWindowSurface(WindowSurface surface, int x, int y, int width, int height) { + if(surface == null) + { + throw new NullPointerException("surface is null"); + } + OS.graphicsContext_drawWindowSurface(handle, surface.handle, x, y, width, height); + } + + + /** * Fill interior of circular or elliptical arc within specified rectangular area, using background color. * * @param x The x coordinate of top left corner of arc rectangle diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/graphics/OS.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/graphics/OS.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/graphics/OS.java Fri Jun 11 13:33:44 2010 +0300 @@ -39,6 +39,7 @@ static final native void graphicsContext_drawRoundRect(int handle,int x,int y,int width,int height,int arcWidth,int arcHeight); static final native void graphicsContext_drawString(int handle, String string, int x, int y, int width, int height, int alignments, int flags, boolean isTransparent); + static final native void graphicsContext_drawWindowSurface(int handle, int surfaceHandle, int x, int y, int width, int height); static final native void graphicsContext_fillArc(int handle, int x, int y, int width, int height, int startAngle, int arcAngle); static final native void graphicsContext_fillEllipse(int handle, int x, int y, int width, int height); static final native void graphicsContext_fillGradientRect(int handle, int x, int y, int width, int height, boolean vertical, boolean swapColors); diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/graphics/Utils.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/graphics/Utils.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/internal/qt/graphics/Utils.java Fri Jun 11 13:33:44 2010 +0300 @@ -11,6 +11,7 @@ package org.eclipse.swt.internal.qt.graphics; import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Internal_PackageSupport; /** * Class for general utilities for common graphics @@ -28,10 +29,13 @@ if (!Config.ENABLE_UI_THREAD_VALIDATION) { return; } - if (Display.getCurrent() == null) { + Display display = Internal_PackageSupport.getDisplayInstance(); + if(display == null) { + display = Internal_PackageSupport.getInternalDisplayInstance(); + } + if (display == null) { throw new Error("Ui thread not initialized or call was made outside ui thread"); } else { - Display display = Display.getCurrent(); if (Thread.currentThread() != display.getThread()) { throw new Error("Call to common graphics object occured outside ui thread"); } diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/widgets/Internal_PackageSupport.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/widgets/Internal_PackageSupport.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/org/eclipse/swt/widgets/Internal_PackageSupport.java Fri Jun 11 13:33:44 2010 +0300 @@ -13,9 +13,9 @@ import org.eclipse.ercp.swt.mobile.Command; import org.eclipse.ercp.swt.mobile.MobileDevice; -import org.eclipse.ercp.swt.mobile.TextExtension; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.internal.qt.CommandArranger; import org.eclipse.swt.internal.qt.graphics.WindowSurface; /** @@ -348,17 +348,29 @@ public static Display getDisplayInstance() { return Display.Default; } +public static Display getInternalDisplayInstance() { + return Display.Internal; +} +public static Display internalInstance() { + return Display.internalInstance(); +} public static Widget getDWidget(Display display, int widgetHandle) { - return display.getWidget(widgetHandle); + return Display.getWidget(widgetHandle); } public static int initializeMobileDevice(Display display) { - return display.initializeMobileDevice(); + return Display.initializeMobileDevice(); } public static int handle(Display d) { - return d.handle; + return Display.handle; } public static Point readAndClearImageLoadSize(Display d) { - return d.readAndClearImageLoadSize(); + return Display.readAndClearImageLoadSize(); +} +public static CommandArranger commandArranger() { + return Display.commandArranger; +} +public static int untranslateKey (int key) { + return Display.untranslateKey(key); } /* * From the class Label @@ -368,7 +380,7 @@ } public static void setMobileDevice(Display display, MobileDevice mobileDevice){ - display.mobileDevice = mobileDevice; + Display.mobileDevice = mobileDevice; } } diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/s60/eswt.odc --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/s60/eswt.odc Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/s60/eswt.odc Fri Jun 11 13:33:44 2010 +0300 @@ -8,7 +8,9 @@ org/eclipse/swt/graphics org/eclipse/swt/internal org/eclipse/swt/internal/qt +org/eclipse/swt/internal/qt/midp org/eclipse/swt/internal/qt/graphics +org/eclipse/swt/internal/qt/webkit org/eclipse/swt/internal/image org/eclipse/swt/internal/extension org/eclipse/swt/layout diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/s60/org/eclipse/swt/internal/qt/midp/UIThreadLauncher.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/s60/org/eclipse/swt/internal/qt/midp/UIThreadLauncher.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia Corporation - initial implementation + *******************************************************************************/ +package org.eclipse.swt.internal.qt.midp; + +import org.eclipse.swt.internal.qt.s60.OS; + +/** + * Symbian specific implementation of launching the UI thread for a MIDlet. + */ +public final class UIThreadLauncher { + public static boolean startInUIThread(Runnable runnable) { + int status = OS.startUI(runnable); + if(status != 0) { + return false; + } + return true; + } +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/s60/org/eclipse/swt/internal/qt/s60/OS.java --- a/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/s60/org/eclipse/swt/internal/qt/s60/OS.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/s60/org/eclipse/swt/internal/qt/s60/OS.java Fri Jun 11 13:33:44 2010 +0300 @@ -19,19 +19,21 @@ private static boolean started; - /** - * Obtains the platform specific UI thread where SWT UI APIs can be accessed - * in and calls the provided UIThreadCallback in it. This method instantly - * returns leaving two threads running concurrently: the calling thread and - * the UI thread. Only one UI thread can exist per process and this method - * can be called only once to obtain it. Subsequent calls will result in an - * exception being thrown. This method can be called by any thread. - * - * @param callback An object to call in the UI thread. - * @return 0 In case of success, non-zero if starting failed and - * callback object will never be called. - * @exception RuntimeException If called again after already started - */ + /** + * Obtains the platform specific UI thread where SWT UI APIs can be accessed + * in and calls the provided Runnable in it. This method instantly returns + * leaving two threads running concurrently: the calling thread and the UI + * thread. Only one UI thread can exist per process and this method can be + * called only once to obtain it. Subsequent calls will result in an + * exception being thrown. This method can be called by any thread. + * + * @param callback + * An object to call in the UI thread. + * @return 0 In case of success, non-zero if starting failed and callback + * object will never be called. + * @exception RuntimeException + * If called again after already started + */ public synchronized static final int startUI( final Runnable callback) { if (started) { diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/webkit/org/eclipse/swt/internal/qt/webkit/OS_webkit.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/webkit/org/eclipse/swt/internal/qt/webkit/OS_webkit.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Nokia Corporation - initial implementation + *******************************************************************************/ +package org.eclipse.swt.internal.qt.webkit; + +import org.eclipse.swt.internal.Library; + +/** + * Native methods requiring QtWebkit. They are separated to avoid + * loading the related libraries until they are needed. + */ +public final class OS_webkit { + static { + Library.loadLibrary("eswtqtwebkit"); + } + + // + // QWebView + // + public static final native int QWebView_new(); + public static final native void QWebView_back(int handle); + public static final native void QWebView_forward(int handle); + public static final native void QWebView_reload(int handle); + public static final native void QWebView_setHtml(int handle, String html); + public static final native void QWebView_setUrl(int handle, String url); + public static final native void QWebView_stop(int handle); + public static final native String QWebView_swt_backUrl(int handle); + public static final native boolean QWebView_swt_canGoBack(int handle); + public static final native boolean QWebView_swt_canGoForward(int handle); + public static final native boolean QWebView_swt_evaluateJavaScript(int handle, String script); + public static final native String QWebView_swt_forwardUrl(int handle); + public static final native String QWebView_url(int handle); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/s60utils/.project --- a/javauis/eswt_qt/s60utils/.project Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ - - - s60utils - - - - - - com.nokia.carbide.cdt.builder.carbideCPPBuilder - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.core.ccnature - com.nokia.carbide.cdt.builder.carbideCPPBuilderNature - - diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/s60utils/bwins/s60uitestutilsu.def --- a/javauis/eswt_qt/s60utils/bwins/s60uitestutilsu.def Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -EXPORTS - ?jni_lookup@@YAP6AXXZPBD@Z @ 1 NONAME ; void (*)(void) jni_lookup(char const *) - diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/s60utils/exports.inf --- a/javauis/eswt_qt/s60utils/exports.inf Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -// exports.inf - -#ifndef __UITESTUTILSIMPL_EXPORTS_INF__ -#define __UITESTUTILSIMPL_EXPORTS_INF__ - -#include - -PRJ_EXPORTS - -#endif // __UITESTUTILSIMPL_EXPORTS_INF__ diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/s60utils/java/src/com/nokia/mj/impl/uitestutils/ImageTestUtils.java --- a/javauis/eswt_qt/s60utils/java/src/com/nokia/mj/impl/uitestutils/ImageTestUtils.java Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,655 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -package com.nokia.mj.impl.uitestutils; - -import org.eclipse.swt.internal.qt.graphics.Image; -import java.util.Arrays; - -/** - * Image utils for verifying image pixels against mask - * plus some other helpers for verifying image properties. - * - * NOTE. Currently only CGFX images are supported however eSWT images - * can be verified by using org.eclipse.swt.internal.qt.graphics.Image internal_getImage() - * to obtain wrapped CGFX image. - * - * Usage example - * - * create a mask from mask data and then mask by giving data and scanlenght. - * - * int[] maskData = { - * 0,0,0,0,0,0,0,0,0, - * 0,0,0,0,1,0,0,0,0, - * 0,0,0,0,1,0,0,0,0, - * 0,0,0,0,1,0,0,0,0, - * 0,0,0,0,1,0,0,0,0, - * 0,0,0,0,1,0,0,0,0, - * 0,0,0,0,1,0,0,0,0, - * 0,0,0,0,0,0,0,0,0 - * }; - * - * Mask mask = new Mask(maskData, 9); - * - * - * Then image pixels can be validated with ImageTestUtils. That is where there is 1 in mask it is - * compared against maskArgb and all where there is 0 in mask it is compared against bgArgb. - * - * ImageTestUtils.validatePixels(imageToValidate, mask, maskArgb, bgArgb); - * - * - * @author sampkaar - * - */ -public class ImageTestUtils { - - /** - * This pixel is rendering target image background color. - */ - public static final int IMAGE_BACKGROUND_COLOR = 0; - - /** - * This pixel is foreground color set to GC. - */ - public static final int GC_FOREGROUND_COLOR = 1; - - /** - * This pixel is either foreground or image background color. - * Used for example in drawRoundRect and drawEllipse tests. - */ - public static final int FOREGROUND_OR_IMAGE_BACKGROUND_COLOR = 2; - - /** - * This pixel is background color set to GC. - * Used for example in fillGradientRect test. - */ - public static final int GC_BACKGROUND_COLOR = 3; - - /** - * This pixel is neither foreground nor gc background color. - * Used for example in fillGradientRect test. - */ - public static final int NEITHER_FOREGROUND_NOR_GC_BACKGROUND_COLOR = 4; - - /** - * This pixel can be ignored. - * Used for example in fillGradientRect test. - */ - public static final int IGNORE_COLOR = 5; - - /** - * Validates image dimensions against reference width and height. - * Prints possible problems to System.out. - * - * @param img - The image to check - * @param refWidth - The reference width - * @param refHeight - The reference height - */ - public static final boolean validateImageDimensions(Image img, int refWidth, int refHeight) { - if ((refWidth != img.getWidth()) || (refHeight != img.getHeight())) { - System.out.println("Image size should be ("+refWidth+","+refHeight+"), "+ - "but is ("+img.getWidth()+","+img.getHeight()+")"); - return false; - } - return true; - } - - /** - * Validates image pixels which are outside specified rectangle ingoreRect against given reference color. - * - * @param ignoreRect The area that is to be ingnored - * @param img Image to validate - * @param argb The reference color - * @return true if all pixels outside ingoreRect have reference color orherwise false - */ - public static final boolean validatePixels(Rect ignoreRect, Image img, int argb) { - final int width = img.getWidth(); - final int height = img.getHeight(); - final int pixels = width * height; - final int scanlength = img.getWidth(); - - // data array for image data - int[] imageData = new int[pixels]; - - // get data for whole image - img.getRGB(imageData, 0, width, 0, 0, width, height); - - // calculate start index - int start = scanlength*ignoreRect.y(); - for(int y = 0; y> 24) & 0xff; - final int refRed = (argb >> 16) & 0xff; - final int refGreen = (argb >> 8) & 0xff; - final int refBlue = (argb) & 0xff; - - // data array for image data - int[] imageData = new int[pixels]; - - // get data for whole image - img.getRGB(imageData, 0, width, 0, 0, width, height); - - // check each pixel in image, break if pixel does not match - for(int i=0; i < pixels; i++) { - if (refAlpha != ((imageData[i] >> 24) & 0xff)) return false; - if (refRed != ((imageData[i] >> 16) & 0xff)) return false; - if (refGreen != ((imageData[i] >> 8 ) & 0xff)) return false; - if (refBlue != ( imageData[i] & 0xff)) return false; - } - return true; - } - - /** - * Validates that given pixels are equal to - * reference pixel color (argb) and background color in given rgb data - * - * @param rgbdata - The image data to be checked - * @param mask - the reference mask - * @param maskArgb - The reference color for pixels with value 1 in mask - * @param bgArgb - The reference color for pixels with value 0 in mask - * - */ - public static final boolean validatePixels(int[] rgbdata, Mask mask, int maskArgb, int bgArgb) { - return doCheckPixels(rgbdata, mask, maskArgb, bgArgb, 0, false); - } - - /** - * Validates that given pixels are equal to - * reference pixel color (argb) and background color in given rgb data - * - * @param rgbdata - The image data to be checked - * @param dataOffset The offset from beginning of rgbdata where image data starts - * @param dataLength The lenght of image data after offset - * @param mask - the reference mask - * @param maskArgb - The reference color for pixels with value 1 in mask - * @param bgArgb - The reference color for pixels with value 0 in mask - * - */ - public static final boolean validatePixels(int[] rgbdata, int dataOffset, int dataLength, Mask mask, int maskArgb, int bgArgb) { - - // create array for data - int[] data = new int[dataLength]; - - // copy from rgbdata to data - for(int i=dataOffset; i < rgbdata.length; i++) { - data[i-dataOffset] = rgbdata[i]; - } - - //System.out.println("\n mask size: " + mask.getData().length+", dataSize: " + rgbdata.length); - return doCheckPixels(data, mask, maskArgb, bgArgb, 0, false); - } - - /** - * Validates that given pixels are equal to - * reference pixel color (argb) and background color in image - * - * @param img - The image to check - * @param mask - the reference mask - * @param maskArgb - The reference color for pixels with value 1 in mask - * @param bgArgb - The reference color for pixels with value 0 in mask - * - */ - public static final boolean validatePixels(Image img, Mask mask, int maskArgb, int bgArgb) { - - // data array for image data - int[] imageData = new int[img.getWidth()*img.getHeight()]; - - // get data for whole image - img.getRGB(imageData, 0, img.getWidth(), 0, 0, img.getWidth(), img.getHeight()); - - // check pixels - return doCheckPixels(imageData, mask, maskArgb, bgArgb, 0, false); - } - - /** - * Validates that given pixels are equal to - * reference pixel color (argb) and background color in image - * - * @param img - The image to check - * @param mask - the reference mask - * @param maskArgb - The reference color for pixels with value 1 in mask - * @param bgArgb - The reference color for pixels with value 0 in mask - * @param ingoreAlpha If true alpha value is not validated - * @return true if mask and image match otherwise false - */ - public static final boolean validatePixels(Image img, Mask mask, int maskArgb, int bgArgb, boolean ignoreAlpha) { - - // data array for image data - int[] imageData = new int[img.getWidth()*img.getHeight()]; - - // get data for whole image - img.getRGB(imageData, 0, img.getWidth(), 0, 0, img.getWidth(), img.getHeight()); - - // check pixels - return doCheckPixels(imageData, mask, maskArgb, bgArgb, 0, ignoreAlpha); - } - - /** - * Validates that given pixels are equal to - * foreground color (argb), image background color and gc background color in image - * - * @param img - The image to check - * @param mask - the reference mask - * @param fgArgb - The reference color for pixels with value 1 GC_FOREGROUND_COLOR in mask - * @param gcBgArgb - The reference color for pixels with value 3 GC_BACKGROUND_COLOR in mask - * @param imgBgArgb - The reference color for pixels with value 0 IMAGE_BACKGROUND_COLOR in mask - * @param ingoreAlpha If true alpha value is not validated - * @return true if mask and image match otherwise false - */ - public static final boolean validatePixels(Image img, Mask mask, int fgArgb, int gcBgArgb, int imgBgArgb, boolean ignoreAlpha) { - - // data array for image data - int[] imageData = new int[img.getWidth()*img.getHeight()]; - - // get data for whole image - img.getRGB(imageData, 0, img.getWidth(), 0, 0, img.getWidth(), img.getHeight()); - - // check pixels - return doCheckPixels(imageData, mask, fgArgb, imgBgArgb, gcBgArgb, ignoreAlpha); - } - - /* - * method for checking pixels against mask - * The imageData and the data in mask must be same size. - */ - private static final boolean doCheckPixels(int[] imageData, Mask mask, int fgColorArgb, int imgBgColorArgb, int gcBgColorArgb, boolean ignoreAlpha ) { - - // get color components for GC foreground color - final int fgAlpha = (fgColorArgb >> 24) & 0xff; - final int fgRed = (fgColorArgb >> 16) & 0xff; - final int fgGreen = (fgColorArgb >> 8) & 0xff; - final int fgBlue = (fgColorArgb) & 0xff; - - // get color components for image background color - final int imgBgAlpha = (imgBgColorArgb >> 24) & 0xff; - final int imgBgRed = (imgBgColorArgb >> 16) & 0xff; - final int imgBgGreen = (imgBgColorArgb >> 8) & 0xff; - final int imgBgBlue = (imgBgColorArgb) & 0xff; - - // get color components for GC background color - int gcBgAlpha = 0; - int gcBgRed = 0; - int gcBgGreen = 0; - int gcBgBlue = 0; - if (gcBgColorArgb != 0){ // GC Background color is defined - gcBgAlpha = (gcBgColorArgb >> 24) & 0xff; - gcBgRed = (gcBgColorArgb >> 16) & 0xff; - gcBgGreen = (gcBgColorArgb >> 8) & 0xff; - gcBgBlue = (gcBgColorArgb) & 0xff; - } - - // get mask data - int[] maskdata = mask.getData(); - - // verify background & pixels - for(int i=0; i < imageData.length; i++) { - - // if mask pixel is GC_FOREGROUND_COLOR (1), check against fgArgb - if(maskdata[i] == GC_FOREGROUND_COLOR) { - if (!ignoreAlpha) { - if (fgAlpha != ((imageData[i] >> 24) & 0xff)) return false; - } - if (fgRed != ((imageData[i] >> 16) & 0xff)) return false; - if (fgGreen != ((imageData[i] >> 8 ) & 0xff)) return false; - if (fgBlue != ( imageData[i] & 0xff)) return false; - } - // if mask pixel is FOREGROUND_OR_IMAGE_BACKGROUND_COLOR (2), this pixel is either - // foreground or image background color. - // Used for example in drawRoundRect and drawEllipse tests. - else if(maskdata[i] == FOREGROUND_OR_IMAGE_BACKGROUND_COLOR) { - if (!ignoreAlpha) { - if (fgAlpha != ((imageData[i] >> 24) & 0xff) && - imgBgAlpha != ((imageData[i] >> 24) & 0xff)) return false; - } - if (fgRed != ((imageData[i] >> 16) & 0xff) && - imgBgRed != ((imageData[i] >> 16) & 0xff)) return false; - - if (fgGreen != ((imageData[i] >> 8 ) & 0xff) && - imgBgGreen != ((imageData[i] >> 8 ) & 0xff)) return false; - - if (fgBlue != ( imageData[i] & 0xff) && - imgBgBlue != ( imageData[i] & 0xff)) return false; - } - // if mask pixel is GC_BACKGROUND_COLOR (3), this pixel is background color set to GC. - // Used for example in fillGradientRect test. - else if(maskdata[i] == GC_BACKGROUND_COLOR) { - if (!ignoreAlpha) { - if (gcBgAlpha != ((imageData[i] >> 24) & 0xff)) return false; - } - if (gcBgRed != ((imageData[i] >> 16) & 0xff)) return false; - if (gcBgGreen != ((imageData[i] >> 8 ) & 0xff)) return false; - if (gcBgBlue != ( imageData[i] & 0xff)) return false; - } - // if mask pixel is NEITHER_FOREGROUND_NOR_GC_BACKGROUND_COLOR (4), this pixel is neither - // foreground nor gc background color. - // Used for example in fillGradientRect test. - else if(maskdata[i] == NEITHER_FOREGROUND_NOR_GC_BACKGROUND_COLOR) { - if (!ignoreAlpha) { - if (fgAlpha != gcBgAlpha){ - if (fgAlpha == ((imageData[i] >> 24) & 0xff) || - gcBgAlpha == ((imageData[i] >> 24) & 0xff)) return false; - } - } - - if (fgRed != gcBgRed){ - if (fgRed == ((imageData[i] >> 16) & 0xff) || - gcBgRed == ((imageData[i] >> 16) & 0xff)) return false; - } - if (fgGreen != gcBgGreen){ - if (fgGreen == ((imageData[i] >> 8 ) & 0xff) || - gcBgGreen == ((imageData[i] >> 8 ) & 0xff)) return false; - } - if (fgBlue != gcBgBlue){ - if (fgBlue == ( imageData[i] & 0xff) || - gcBgBlue == ( imageData[i] & 0xff)) return false; - } - } - else if(maskdata[i] == IGNORE_COLOR) { - // skip the pixel - } - // if mask pixel is IMAGE_BACKGROUND_COLOR (1), check against imgBg - else if(maskdata[i] == IMAGE_BACKGROUND_COLOR) { - if (!ignoreAlpha) { - if (imgBgAlpha != ((imageData[i] >> 24) & 0xff)) return false; - } - if (imgBgRed != ((imageData[i] >> 16) & 0xff)) return false; - if (imgBgGreen != ((imageData[i] >> 8 ) & 0xff)) return false; - if (imgBgBlue != ( imageData[i] & 0xff)) return false; - } - // If mask pixel is something else that's error - else { - return false; - } - } - return true; - } - - /** - * prints black & white image to console. - * black is printed as 1 and white as 0. - */ - public static final void print(Image img) { - - final int width = img.getWidth(); - final int height = img.getHeight(); - final int pixels = img.getWidth() * img.getHeight(); - - // data array for image data - int[] imageData = new int[pixels]; - - // get data for whole image - img.getRGB(imageData, 0, width, 0, 0, width, height); - - String output = "Image("+img.getWidth()+","+img.getHeight()+"):\n"; - int y = 0; - for(int i = 0; i < imageData.length; i++) { - - int a = ((imageData[i] >> 24) & 0xff); - int r = ((imageData[i] >> 16) & 0xff); - int b = ((imageData[i] >> 8 ) & 0xff); - int g = ( imageData[i] & 0xff); - - if (a == 255 && r == 0 && g == 0 && b == 0) { - output += "1,"; - } else if (a == 255 && r == 255 && g == 255 && b == 255) { - output += "0,"; - } - else { - output += "("+a+","+r+","+b+","+g+")"; - } - - if(i==((y*width) + (width-1))) { - output += "\n"; - y++; - } - } - System.out.println(output); - } - - public static final void print(int[] array, int scanlength) { - final int width = scanlength; - String output = ""; - - int y = 0; - for(int i = 0; i < array.length; i++) { - - int a = ((array[i] >> 24) & 0xff); - int r = ((array[i] >> 16) & 0xff); - int b = ((array[i] >> 8 ) & 0xff); - int g = ( array[i] & 0xff); - - if (a == 255 && r == 0 && g == 0 && b == 0) { - output += "1,"; - } else if (a == 255 && r == 255 && g == 255 && b == 255) { - output += "0,"; - } - else { - output += "x,"; - } - - if(i==((y*width) + (width-1))) { - output += "\n"; - y++; - } - } - System.out.println(output); - } - - private int getIndexForPoint(int scanlength, int x, int y) { - return y*scanlength+x; - } - - -} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/s60utils/java/src/com/nokia/mj/impl/uitestutils/Key.java --- a/javauis/eswt_qt/s60utils/java/src/com/nokia/mj/impl/uitestutils/Key.java Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,548 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -//Key.java -// -// -// - -package com.nokia.mj.impl.uitestutils; - -public class Key { - - // - // NON UNICODE LOGICAL KEY CODES - // pass them to class c.tor to generate symbian symbian scan and key codes - // (for unicode keys use unicode char) - // - - //non unicode MIDP key codes - public static final int UpArrow = -1; - public static final int DownArrow = -2; - public static final int LeftArrow = -3; - public static final int RightArrow = -4; - public static final int Clear = -5; // Clear key - public static final int Select = -6; // Selection key - public static final int Edit = -7; // Edit Key - public static final int Send = -8; // Send Key - public static final int CBA1 = -9; // Left CBA - public static final int CBA2 = -10; // Right CBA - public static final int End = -11; // End key - public static final int Applications = -12; // Applications key - public static final int Voice = -13; // Voice key - - //non unicode non MIDP key codes - public static final int Power = -14; - public static final int Backspace = -15; - public static final int GripOpen = -16; - public static final int GripClose = -17; - public static final int Camera = -18; - public static final int VolumeUp = -19; - public static final int VolumeDown = -20; - public static final int PlayPause = -21; //Media key - public static final int Stop = -22; //Media Key - public static final int NextFF = -23; //Media key - public static final int PreviousRew = -24; //Media key - - public static final int PageUp = -25; - public static final int PageDown = -26; - public static final int HomeKey = -27; - public static final int EndKey = -28; - // Activate key represents a key that will cause a "default selection" of an item. On Linux - // this is Enter, but on S60 it may be the same key as Select. - public static final int Activate = -29; - public static final int InsertKey = -30; - public static final int ReturnKey = -31; - public static final int DeleteKey = -32; - public static final int Escape = -33; - - - - // - // SYMBIAN SCAN CODES - copied from e32keys.h - // - - public static final int EStdKeyNull=0x00; /**< No key present. */ - public static final int EStdKeyBackspace=0x01; /**< Scan code for Backspace key.*/ - public static final int EStdKeyTab=0x02; /**< Scan code for Tab key. */ - public static final int EStdKeyEnter=0x03; /**< Scan code for Enter key.*/ - public static final int EStdKeyEscape=0x04; /**< Scan code for Escape (Esc) key.*/ - public static final int EStdKeySpace=0x05; /**< Scan code for Space key.*/ - public static final int EStdKeyPrintScreen=0x06; /**< Scan code for Print Screen key.*/ - public static final int EStdKeyPause=0x07; /**< Scan code for Pause key.*/ - public static final int EStdKeyHome=0x08; /**< Scan code for Home key.*/ - public static final int EStdKeyEnd=0x09; /**< Scan code for End key.*/ - public static final int EStdKeyPageUp=0x0a; /**< Scan code for Page Up key.*/ - public static final int EStdKeyPageDown=0x0b; /**< Scan code for Page Down key.*/ - public static final int EStdKeyInsert=0x0c; /**< Scan code for Insert key.*/ - public static final int EStdKeyDelete=0x0d; /**< Scan code for Delete (Del) key.*/ - public static final int EStdKeyLeftArrow=0x0e; /**< Scan code for Left arrow key.*/ - public static final int EStdKeyRightArrow=0x0f; /**< Scan code for Right arrow key.*/ - public static final int EStdKeyUpArrow=0x10; /**< Scan code for Up arrow key.*/ - public static final int EStdKeyDownArrow=0x11; /**< Scan code for Down arrow key.*/ - public static final int EStdKeyLeftShift=0x12; /**< Scan code for left Shift key.*/ - public static final int EStdKeyRightShift=0x13; /**< Scan code for right Shift key.*/ - public static final int EStdKeyLeftAlt=0x14; /**< Scan code for left Alt key.*/ - public static final int EStdKeyRightAlt=0x15; /**< Scan code for right Alt key.*/ - public static final int EStdKeyLeftCtrl=0x16; /**< Scan code for left Control (Ctrl) key.*/ - public static final int EStdKeyRightCtrl=0x17; /**< Scan code for right Control (Ctrl) key.*/ - public static final int EStdKeyLeftFunc=0x18; /**< Scan code for left Fn key.*/ - public static final int EStdKeyRightFunc=0x19; /**< Scan code for right Fn key.*/ - public static final int EStdKeyCapsLock=0x1a; /**< Scan code for Caps lock key.*/ - public static final int EStdKeyNumLock=0x1b; /**< Scan code for Num lock key.*/ - public static final int EStdKeyScrollLock=0x1c; /**< Scan code for Scroll lock key.*/ - public static final int EStdKeyF1=0x60; /**< Scan code for function key F1.*/ - public static final int EStdKeyF2=0x61; /**< Scan code for function key F2.*/ - public static final int EStdKeyF3=0x62; /**< Scan code for function key F3.*/ - public static final int EStdKeyF4=0x63; /**< Scan code for function key F4.*/ - public static final int EStdKeyF5=0x64; /**< Scan code for function key F5*/ - public static final int EStdKeyF6=0x65; /**< Scan code for function key F6*/ - public static final int EStdKeyF7=0x66; /**< Scan code for function key F7*/ - public static final int EStdKeyF8=0x67; /**< Scan code for function key F8*/ - public static final int EStdKeyF9=0x68; /**< Scan code for function key F9*/ - public static final int EStdKeyF10=0x69; /**< Scan code for function key F10*/ - public static final int EStdKeyF11=0x6a; /**< Scan code for function key F11*/ - public static final int EStdKeyF12=0x6b; /**< Scan code for function key F12*/ - public static final int EStdKeyF13=0x6c; /**< Scan code for function key F13*/ - public static final int EStdKeyF14=0x6d; /**< Scan code for function key F14*/ - public static final int EStdKeyF15=0x6e; /**< Scan code for function key F15*/ - public static final int EStdKeyF16=0x6f; /**< Scan code for function key F16*/ - public static final int EStdKeyF17=0x70; /**< Scan code for function key F17*/ - public static final int EStdKeyF18=0x71; /**< Scan code for function key F18*/ - public static final int EStdKeyF19=0x72; /**< Scan code for function key F19*/ - public static final int EStdKeyF20=0x73; /**< Scan code for function key F20*/ - public static final int EStdKeyF21=0x74; /**< Scan code for function key F21*/ - public static final int EStdKeyF22=0x75; /**< Scan code for function key F22.*/ - public static final int EStdKeyF23=0x76; /**< Scan code for function key F23.*/ - public static final int EStdKeyF24=0x77; /**< Scan code for function key F24.*/ - public static final int EStdKeyXXX=0x78; /**< Scan code for the key to the left of the 1 key on a standard keyboard.*/ - public static final int EStdKeyComma=0x79; /**< Scan code for Comma (,) key.*/ - public static final int EStdKeyFullStop=0x7a; /**< Scan code for Full stop (.) key.*/ - public static final int EStdKeyForwardSlash=0x7b; /**< Scan code for Forward slash (/) key.*/ - public static final int EStdKeyBackSlash=0x7c; /**< Scan code for Back slash (\) key.*/ - public static final int EStdKeySemiColon=0x7d; /**< Scan code for Semi colon (;) key.*/ - public static final int EStdKeySingleQuote=0x7e; /**< Scan code for Single quote (') key.*/ - public static final int EStdKeyHash=0x7f; /**< Scan code for Hash key (#) key.*/ - public static final int EStdKeySquareBracketLeft=0x80; /**< Scan code for left Square bracket ([) key.*/ - public static final int EStdKeySquareBracketRight=0x81; /**< Scan code for right Square bracket (]) key.*/ - public static final int EStdKeyMinus=0x82; /**< Scan code for Minus key (-) key.*/ - public static final int EStdKeyEquals=0x83; /**< Scan code for Equals key (=) key.*/ - public static final int EStdKeyNkpForwardSlash=0x84; /**< Scan code for forward slash (/) key on the Numeric keypad.*/ - public static final int EStdKeyNkpAsterisk=0x85; /**< Scan code for Asterisk (*) key on the Numeric keypad.*/ - public static final int EStdKeyNkpMinus=0x86; /**< Scan code for Minus (-) key on the Numeric keypad.*/ - public static final int EStdKeyNkpPlus=0x87; /**< Scan code for Plus (+) key on the Numeric keypad.*/ - public static final int EStdKeyNkpEnter=0x88; /**< Scan code for Enter key on the Numeric keypad.*/ - public static final int EStdKeyNkp1=0x89; /**< Scan code for the 1 key on the Numeric keypad.*/ - public static final int EStdKeyNkp2=0x8a; /**< Scan code for the 2 key on the Numeric keypad.*/ - public static final int EStdKeyNkp3=0x8b; /**< Scan code for the 3 key on the Numeric keypad.*/ - public static final int EStdKeyNkp4=0x8c; /**< Scan code for the 4 key on the Numeric keypad.*/ - public static final int EStdKeyNkp5=0x8d; /**< Scan code for the 5 key on the Numeric keypad.*/ - public static final int EStdKeyNkp6=0x8e; /**< Scan code for the 6 key on the Numeric keypad.*/ - public static final int EStdKeyNkp7=0x8f; /**< Scan code for the 7 key on the Numeric keypad.*/ - public static final int EStdKeyNkp8=0x90; /**< Scan code for the 8 key on the Numeric keypad.*/ - public static final int EStdKeyNkp9=0x91; /**< Scan code for the 9 key on the Numeric keypad.*/ - public static final int EStdKeyNkp0=0x92; /**< Scan code for the 0 key on the Numeric keypad.*/ - public static final int EStdKeyNkpFullStop=0x93; /**< Scan code for Full stop (.) key on the Numeric keypad.*/ - public static final int EStdKeyMenu=0x94; /**< Scan code for Menu key.*/ - public static final int EStdKeyBacklightOn=0x95; /**< Scan code for Backlight on key.*/ - public static final int EStdKeyBacklightOff=0x96; /**< Scan code for Backlight off key.*/ - public static final int EStdKeyBacklightToggle=0x97; /**< Scan code for Backlight toggle key.*/ - public static final int EStdKeyIncContrast=0x98; /**< Scan code for Increase contrast key.*/ - public static final int EStdKeyDecContrast=0x99; /**< Scan code for Decrease contrast key.*/ - public static final int EStdKeySliderDown=0x9a; /**< Scan code for Slider down key.*/ - public static final int EStdKeySliderUp=0x9b; /**< Scan code for Slider up key.*/ - public static final int EStdKeyDictaphonePlay=0x9c; /**< Scan code for Dictaphone play key.*/ - public static final int EStdKeyDictaphoneStop=0x9d; /**< Scan code for Dictaphone stop key.*/ - public static final int EStdKeyDictaphoneRecord=0x9e; /**< Scan code for Dictaphone record key.*/ - public static final int EStdKeyHelp=0x9f; /**< Scan code for Help key */ - public static final int EStdKeyOff=0xa0; /**< Scan code for Off key.*/ - public static final int EStdKeyDial=0xa1; /**< Scan code for Dial key.*/ - public static final int EStdKeyIncVolume=0xa2; /**< Scan code for Increase volume key.*/ - public static final int EStdKeyDecVolume=0xa3; /**< Scan code for Decrease volume key.*/ - public static final int EStdKeyDevice0=0xa4; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ - public static final int EStdKeyDevice1=0xa5; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ - public static final int EStdKeyDevice2=0xa6; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ - public static final int EStdKeyDevice3=0xa7; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ - public static final int EStdKeyDevice4=0xa8; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ - public static final int EStdKeyDevice5=0xa9; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ - public static final int EStdKeyDevice6=0xaa; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ - public static final int EStdKeyDevice7=0xab; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ - public static final int EStdKeyDevice8=0xac; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ - public static final int EStdKeyDevice9=0xad; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ - public static final int EStdKeyDeviceA=0xae; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ - public static final int EStdKeyDeviceB=0xaf; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ - public static final int EStdKeyDeviceC=0xb0; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ - public static final int EStdKeyDeviceD=0xb1; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ - public static final int EStdKeyDeviceE=0xb2; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ - public static final int EStdKeyDeviceF=0xb3; /**< Device-specific scan code - usually represents an extra hardware key on the phone.*/ - public static final int EStdKeyApplication0=0xb4; /**< Scan code for device-specific application launcher key.*/ - public static final int EStdKeyApplication1=0xb5; /**< Scan code for device-specific application launcher key.*/ - public static final int EStdKeyApplication2=0xb6; /**< Scan code for device-specific application launcher key.*/ - public static final int EStdKeyApplication3=0xb7; /**< Scan code for device-specific application launcher key.*/ - public static final int EStdKeyApplication4=0xb8; /**< Scan code for device-specific application launcher key.*/ - public static final int EStdKeyApplication5=0xb9; /**< Scan code for device-specific application launcher key.*/ - public static final int EStdKeyApplication6=0xba; /**< Scan code for device-specific application launcher key.*/ - public static final int EStdKeyApplication7=0xbb; /**< Scan code for device-specific application launcher key.*/ - public static final int EStdKeyApplication8=0xbc; /**< Scan code for device-specific application launcher key.*/ - public static final int EStdKeyApplication9=0xbd; /**< Scan code for device-specific application launcher key.*/ - public static final int EStdKeyApplicationA=0xbe; /**< Scan code for device-specific application launcher key.*/ - public static final int EStdKeyApplicationB=0xbf; /**< Scan code for device-specific application launcher key.*/ - public static final int EStdKeyApplicationC=0xc0; /**< Scan code for device-specific application launcher key.*/ - public static final int EStdKeyApplicationD=0xc1; /**< Scan code for device-specific application launcher key.*/ - public static final int EStdKeyApplicationE=0xc2; /**< Scan code for device-specific application launcher key.*/ - public static final int EStdKeyApplicationF=0xc3; /**< Scan code for device-specific application launcher key.*/ - public static final int EStdKeyYes=0xc4; /**< Scan code for Yes key.*/ - public static final int EStdKeyNo=0xc5; /**< Scan code for No key.*/ - public static final int EStdKeyIncBrightness=0xc6; /**< Scan code for Increase brightness key.*/ - public static final int EStdKeyDecBrightness=0xc7; /**< Scan code for Decrease brightness key.*/ - public static final int EStdKeyKeyboardExtend=0xc8; /**< Scan code for flip actuated when keypad extends to full keyboard.*/ - public static final int EStdKeyDevice10 = 0xc9; /**< Diagonal LeftUpArrow.*/ - public static final int EStdKeyDevice11 = 0xca; /**< Diagonal RightUpArrow.*/ - public static final int EStdKeyDevice12 = 0xcb; /**< Diagonal RightDownArrow.*/ - public static final int EStdKeyDevice13 = 0xcc; /**< Diagonal LeftDownArrow.*/ - - // - // SYMBIAN KEY CODES - // - - public static final int ENonCharacterKeyBase = 0xf800; - - public static final int EKeyNull=0x0000; /**< Code for the Null key. */ - public static final int EKeyBell=0x0007; /**< Code for the Bell key*/ - public static final int EKeyBackspace=0x0008; /**< Code for the Backspace key */ - public static final int EKeyTab=0x0009; /**< Code for the Tab key*/ - public static final int EKeyLineFeed=0x000a; /**< Code for the Linefeed key*/ - public static final int EKeyVerticalTab=0x000b; /**< Code for the Vertical tab key*/ - public static final int EKeyFormFeed=0x000c; /**< Code for the Form feed key*/ - public static final int EKeyEnter=0x000d; /**< Code for the Enter key */ - public static final int EKeyEscape=0x001b; /**< Code for the Escape key */ - public static final int EKeySpace=0x0020; /**< Code for the Space key*/ - public static final int EKeyDelete=0x007f; /**< Code for the Delete (Del) key*/ - public static final int EKeyPrintScreen = ENonCharacterKeyBase;/**< Code for the Print screen key */ - public static final int EKeyPause = ENonCharacterKeyBase + 1; /**< Code for the Pause key*/ - public static final int EKeyHome = ENonCharacterKeyBase + 2; /**< Code for the Home key*/ - public static final int EKeyEnd = ENonCharacterKeyBase + 3; /**< Code for the End key*/ - public static final int EKeyPageUp = ENonCharacterKeyBase + 4; /**< Code for the Page up key*/ - public static final int EKeyPageDown = ENonCharacterKeyBase + 5; /**< Code for the Page down key*/ - public static final int EKeyInsert = ENonCharacterKeyBase + 6; /**< Code for the Insert key*/ - public static final int EKeyLeftArrow = ENonCharacterKeyBase + 7; /**< Code for the Left arrow key*/ - public static final int EKeyRightArrow = ENonCharacterKeyBase + 8; /**< Code for the Right arrow key*/ - public static final int EKeyUpArrow = ENonCharacterKeyBase + 9; /**< Code for the Up arrow key*/ - public static final int EKeyDownArrow = ENonCharacterKeyBase + 10; /**< Code for the Down arrow key*/ - public static final int EKeyLeftShift = ENonCharacterKeyBase + 11; /**< Code for the left Shift key*/ - public static final int EKeyRightShift = ENonCharacterKeyBase + 12; /**< Code for the right Shift key*/ - public static final int EKeyLeftAlt = ENonCharacterKeyBase + 13; /**< Code for the left Alt key*/ - public static final int EKeyRightAlt = ENonCharacterKeyBase + 14; /**< Code for the right Alt key*/ - public static final int EKeyLeftCtrl = ENonCharacterKeyBase + 15; /**< Code for the left Control (Ctrl) key*/ - public static final int EKeyRightCtrl = ENonCharacterKeyBase + 16; /**< Code for the right Control (Ctrl) key.*/ - public static final int EKeyLeftFunc = ENonCharacterKeyBase + 17; /**< Code for the left Fn key.*/ - public static final int EKeyRightFunc = ENonCharacterKeyBase + 18; /**< Code for the right Fn key.*/ - public static final int EKeyCapsLock = ENonCharacterKeyBase + 19; /**< Code for the Caps lock key.*/ - public static final int EKeyNumLock = ENonCharacterKeyBase + 20; /**< Code for the Num lock key.*/ - public static final int EKeyScrollLock = ENonCharacterKeyBase + 21; /**< Code for the Scroll lock key.*/ - public static final int EKeyF1 = ENonCharacterKeyBase + 22; /**< Code for the F1 function key.*/ - public static final int EKeyF2 = ENonCharacterKeyBase + 23; /**< Code for the F2 function key.*/ - public static final int EKeyF3 = ENonCharacterKeyBase + 24; /**< Code for the F3 function key.*/ - public static final int EKeyF4 = ENonCharacterKeyBase + 25; /**< Code for the F4 function key.*/ - public static final int EKeyF5 = ENonCharacterKeyBase + 26; /**< Code for the F5 function key.*/ - public static final int EKeyF6 = ENonCharacterKeyBase + 27; /**< Code for the F6 function key.*/ - public static final int EKeyF7 = ENonCharacterKeyBase + 28; /**< Code for the F7 function key.*/ - public static final int EKeyF8 = ENonCharacterKeyBase + 29; /**< Code for the F8 function key.*/ - public static final int EKeyF9 = ENonCharacterKeyBase + 30; /**< Code for the F9 function key.*/ - public static final int EKeyF10 = ENonCharacterKeyBase + 31; /**< Code for the F10 function key.*/ - public static final int EKeyF11 = ENonCharacterKeyBase + 21; /**< Code for the F11 function key.*/ - public static final int EKeyF12 = ENonCharacterKeyBase + 33; /**< Code for the F12 function key.*/ - public static final int EKeyF13 = ENonCharacterKeyBase + 34; /**< Code for the F13 function key.*/ - public static final int EKeyF14 = ENonCharacterKeyBase + 35; /**< Code for the F14 function key.*/ - public static final int EKeyF15 = ENonCharacterKeyBase + 36; /**< Code for the F15 function key.*/ - public static final int EKeyF16 = ENonCharacterKeyBase + 37; /**< Code for the F16 function key.*/ - public static final int EKeyF17 = ENonCharacterKeyBase + 38; /**< Code for the F17 function key.*/ - public static final int EKeyF18 = ENonCharacterKeyBase + 39; /**< Code for the F18 function key.*/ - public static final int EKeyF19 = ENonCharacterKeyBase + 40; /**< Code for the F19 function key.*/ - public static final int EKeyF20 = ENonCharacterKeyBase + 41; /**< Code for the F20 function key.*/ - public static final int EKeyF21 = ENonCharacterKeyBase + 42; /**< Code for the F21 function key.*/ - public static final int EKeyF22 = ENonCharacterKeyBase + 43; /**< Code for the F22 function key.*/ - public static final int EKeyF23 = ENonCharacterKeyBase + 44; /**< Code for the F23 function key.*/ - public static final int EKeyF24 = ENonCharacterKeyBase + 45; /**< Code for the F24 function key.*/ - public static final int EKeyOff = ENonCharacterKeyBase + 46; /**< Code for the Off key.*/ - public static final int EKeyIncContrast = ENonCharacterKeyBase + 47; /**< Code for the Increase contrast key.*/ - public static final int EKeyDecContrast = ENonCharacterKeyBase + 48; /**< Code for the Decrease contrast key.*/ - public static final int EKeyBacklightOn = ENonCharacterKeyBase + 49; /**< Code for the Backlight on key.*/ - public static final int EKeyBacklightOff = ENonCharacterKeyBase + 50; /**< Code for the Backlight off key.*/ - public static final int EKeyBacklightToggle = ENonCharacterKeyBase + 51; /**< Code for the Backlight toggle key.*/ - public static final int EKeySliderDown = ENonCharacterKeyBase + 52; /**< Code for the Slider down key.*/ - public static final int EKeySliderUp = ENonCharacterKeyBase + 53; /**< Code for the Slider up key.*/ - public static final int EKeyMenu = ENonCharacterKeyBase + 54; /**< Code for the Menu key.*/ - public static final int EKeyDictaphonePlay = ENonCharacterKeyBase + 55; /**< Code for the Dictaphone play key.*/ - public static final int EKeyDictaphoneStop = ENonCharacterKeyBase + 56; /**< Code for the Dictaphone stop key.*/ - public static final int EKeyDictaphoneRecord = ENonCharacterKeyBase + 57; /**< Code for the Dictaphone record key.*/ - public static final int EKeyHelp = ENonCharacterKeyBase + 58; /**< Code for the Help key.*/ - public static final int EKeyDial = ENonCharacterKeyBase + 59; /**< Code for the Dial key.*/ - public static final int EKeyScreenDimension0 = ENonCharacterKeyBase + 60; /**< Code for the first Screen dimension change key.*/ - public static final int EKeyScreenDimension1 = ENonCharacterKeyBase + 61; /**< Code for the second Screen dimension change key.*/ - public static final int EKeyScreenDimension2 = ENonCharacterKeyBase + 62; /**< Code for the third Screen dimension change key.*/ - public static final int EKeyScreenDimension3 = ENonCharacterKeyBase + 63; /**< Code for the fourth Screen dimension change key.*/ - public static final int EKeyIncVolume = ENonCharacterKeyBase + 64; /**< Code for the increase colume key.*/ - public static final int EKeyDecVolume = ENonCharacterKeyBase + 65; /**< Code for the decrease volume key.*/ - public static final int EKeyDevice0 = ENonCharacterKeyBase + 66; /**< Code for a device specific key.*/ - public static final int EKeyDevice1 = ENonCharacterKeyBase + 67; /**< Code for a device specific key.*/ - public static final int EKeyDevice2 = ENonCharacterKeyBase + 68; /**< Code for a device specific key. */ - public static final int EKeyDevice3 = ENonCharacterKeyBase + 69; /**< Code for a device specific key.*/ - public static final int EKeyDevice4 = ENonCharacterKeyBase + 70; /**< Code for a device specific key.*/ - public static final int EKeyDevice5 = ENonCharacterKeyBase + 71; /**< Code for a device specific key.*/ - public static final int EKeyDevice6 = ENonCharacterKeyBase + 72; /**< Code for a device specific key.*/ - public static final int EKeyDevice7 = ENonCharacterKeyBase + 73; /**< Code for a device specific key.*/ - public static final int EKeyDevice8 = ENonCharacterKeyBase + 74; /**< Code for a device specific key.*/ - public static final int EKeyDevice9 = ENonCharacterKeyBase + 75; /**< Code for a device specific key.*/ - public static final int EKeyDeviceA = ENonCharacterKeyBase + 76; /**< Code for a device specific key.*/ - public static final int EKeyDeviceB = ENonCharacterKeyBase + 77; /**< Code for a device specific key.*/ - public static final int EKeyDeviceC = ENonCharacterKeyBase + 78; /**< Code for a device specific key.*/ - public static final int EKeyDeviceD = ENonCharacterKeyBase + 79; /**< Code for a device specific key.*/ - public static final int EKeyDeviceE = ENonCharacterKeyBase + 80; /**< Code for a device specific key.*/ - public static final int EKeyDeviceF = ENonCharacterKeyBase + 81; /**< Code for a device specific key.*/ - public static final int EKeyApplication0 = ENonCharacterKeyBase + 82; /**< Code for an Application launcher key.*/ - public static final int EKeyApplication1 = ENonCharacterKeyBase + 83; /**< Code for an Application launcher key.*/ - public static final int EKeyApplication2 = ENonCharacterKeyBase + 84; /**< Code for an Application launcher key.*/ - public static final int EKeyApplication3 = ENonCharacterKeyBase + 85; /**< Code for an Application launcher key.*/ - public static final int EKeyApplication4 = ENonCharacterKeyBase + 86; /**< Code for an Application launcher key.*/ - public static final int EKeyApplication5 = ENonCharacterKeyBase + 87; /**< Code for an Application launcher key.*/ - public static final int EKeyApplication6 = ENonCharacterKeyBase + 88; /**< Code for an Application launcher key.*/ - public static final int EKeyApplication7 = ENonCharacterKeyBase + 89; /**< Code for an Application launcher key.*/ - public static final int EKeyApplication8 = ENonCharacterKeyBase + 90; /**< Code for an Application launcher key.*/ - public static final int EKeyApplication9 = ENonCharacterKeyBase + 91; /**< Code for an Application launcher key.*/ - public static final int EKeyApplicationA = ENonCharacterKeyBase + 92; /**< Code for an Application launcher key.*/ - public static final int EKeyApplicationB = ENonCharacterKeyBase + 93; /**< Code for an Application launcher key.*/ - public static final int EKeyApplicationC = ENonCharacterKeyBase + 94; /**< Code for an Application launcher key.*/ - public static final int EKeyApplicationD = ENonCharacterKeyBase + 95; /**< Code for an Application launcher key.*/ - public static final int EKeyApplicationE = ENonCharacterKeyBase + 96; /**< Code for an Application launcher key.*/ - public static final int EKeyApplicationF = ENonCharacterKeyBase + 97; /**< Code for an Application launcher key.*/ - public static final int EKeyYes = ENonCharacterKeyBase + 98; /**< Code for the Yes key.*/ - public static final int EKeyNo = ENonCharacterKeyBase + 99; /**< Code for the No key.*/ - public static final int EKeyIncBrightness = ENonCharacterKeyBase + 100; /**< Code for the increase brightness key.*/ - public static final int EKeyDecBrightness = ENonCharacterKeyBase + 101; /**< Code for the decrease brightness key. */ - public static final int EKeyKeyboardExtend = ENonCharacterKeyBase + 102; /**< Code for flip actuated when keypad extends to full keyboard.*/ - public static final int EKeyDevice10 = ENonCharacterKeyBase + 103; /**< Diagonal LeftUpArrow.*/ - public static final int EKeyDevice11 = ENonCharacterKeyBase + 104; /**< Diagonal RightUpArrow.*/ - public static final int EKeyDevice12 = ENonCharacterKeyBase + 105; /**< Diagonal RightDownArrow.*/ - public static final int EKeyDevice13 = ENonCharacterKeyBase + 106; /**< Diagonal LeftDownArrow.*/ - - /** map from logical key codes to symbian key codes - * (index is logical key codes above with opposite sign) - * */ - private int logicalKeyCodes[] = { - EKeyUpArrow, //UpArrow - EKeyDownArrow,//DownArrow - EKeyLeftArrow,//LeftArrow - EKeyRightArrow,//RightArrow - EStdKeyDelete, //Clear - EKeyDevice3, //Select - EKeyRightShift, //Edit - EKeyYes, //Send - EKeyDevice0, //CBA1 - EKeyDevice1, //CBA2 - EKeyNo, //End - EKeyApplication0, //Applications - EKeyDevice6, //Voice - EKeyDevice7, //Power - EKeyDelete, //Backspace - EKeySliderDown, //GripOpen - EKeySliderUp, //GripClose - EKeyDevice7, //Camera - EKeyIncVolume, //VolumeUp - EKeyDecVolume, //VolumeDown - EKeyApplication2, //PlayPause - EKeyApplication3, //Stop - EKeyApplication4, //NextFF - EKeyApplication5, //PreviousRew - EKeyPageUp, // PageUp - EKeyPageDown, // PageDown - EKeyHome, // HomeKey - EKeyEnd, // EndKey - EKeyDevice3, // Activate - EKeyInsert, // InsertKey - EKeyEnter, // ReturnKey - EKeyDelete, // DeleteKey - EKeyEscape, // Escape - EKeyDevice10, //Diagonal LeftUpArrow - EKeyDevice11, //Diagonal RightUpArrow - EKeyDevice12, //Diagonal RightDownArrow - EKeyDevice13 //Diagonal LeftDownArrow - }; - - /** map from logical key codes to symbian scan codes - * (index is logical key codes above with opposite sign) - * */ - private int logicalScanCodes[] = { - EStdKeyUpArrow, //UpArrow - EStdKeyDownArrow, //DownArrow - EStdKeyLeftArrow, //LeftArrow - EStdKeyRightArrow, //RightArrow - EStdKeyBackspace, //Clear - EStdKeyDevice3, //Select - EStdKeyRightShift, //Edit - EStdKeyYes, //Send - EStdKeyDevice0, //CBA1 - EStdKeyDevice1, //CBA2 - EStdKeyNo, //End - EStdKeyApplication0, //Applications - EStdKeyDevice6, //Voice - EStdKeyDevice2, //Power - EStdKeyBackspace, //Backspace - EStdKeyNull, //GripOpen //TODO - EStdKeyNull, //GripClose //TODO - EStdKeyDevice7, //Camera - EStdKeyIncVolume, //VolumeUp - EStdKeyDecVolume, //VolumeDown - EStdKeyApplication2, //PlayPause - EStdKeyApplication3, //Stop - EStdKeyApplication4, //NextFF - EStdKeyApplication5, //PreviousRew - EStdKeyPageUp,// PageUp - EStdKeyPageDown,// PageDown - EStdKeyHome,// HomeKey - EStdKeyEnd,// EndKey - EStdKeyDevice3,// Activate - EStdKeyInsert,// InsertKey - EStdKeyEnter,// ReturnKey - EStdKeyDelete,// DeleteKey - EStdKeyEscape,// Escape - EStdKeyDevice10, //Diagonal LeftUpArrow - EStdKeyDevice11, //Diagonal RightUpArrow - EStdKeyDevice12, //Diagonal RightDownArrow - EStdKeyDevice13 //Diagonal LeftDownArrow - - - }; - - /** Default constructor */ - public Key() { - this.keyCode = 0; - this.scanCode = 0; - } - - /** Constructor accepting symbian key and scan codes defined above */ - public Key(int keyCode, int scanCode) { - this.keyCode = keyCode; - this.scanCode = scanCode; - } - - /** Constructor accepting unicode or logical key codes defined above */ - public Key(int keyCode) { - //JDEBUG("Key: Converting logical code " + keyCode); - - if (keyCode < 0) { - this.keyCode = logicalKeyCodes[-keyCode -1]; - this.scanCode = logicalScanCodes[-keyCode -1]; - } else if (keyCode >= 'a' && keyCode <= 'z') { - this.keyCode = keyCode; - this.scanCode = keyCode - 'a' + 'A'; - } else if (keyCode == '*') { - this.keyCode = keyCode; - this.scanCode = EStdKeyNkpAsterisk; - - } else if (keyCode == '#') { - this.keyCode = keyCode; - this.scanCode = EStdKeyHash; - } else if (keyCode == '/' || keyCode == '?') { - this.keyCode = keyCode; - this.scanCode = EStdKeyForwardSlash; - } - else if (keyCode == EKeyBackspace) { - this.keyCode = keyCode; - this.scanCode = EStdKeyBackspace; - } - else if (keyCode == EKeyEnter) { - this.keyCode = keyCode; - this.scanCode = EStdKeyEnter; - } - else if (keyCode == EKeyEscape) { - this.keyCode = keyCode; - this.scanCode = EStdKeyEscape; - } - else if (keyCode == EKeyDelete) { - this.keyCode = keyCode; - this.scanCode = EStdKeyDelete; - } - else if (keyCode == EKeyTab) { - this.keyCode = keyCode; - this.scanCode = EStdKeyTab; - } - else if (keyCode == '-' || keyCode == '_') { - this.keyCode = keyCode; - this.scanCode = EStdKeyMinus; - } - else if (keyCode == '=') { - this.keyCode = keyCode; - this.scanCode = EStdKeyEquals; - } - else if (keyCode == '+') { - this.keyCode = keyCode; - this.scanCode = EStdKeyNkpPlus; - } - else if (keyCode == ';' || keyCode == ':') { - this.keyCode = keyCode; - this.scanCode = EStdKeySemiColon; - } - else if (keyCode == '\'' || keyCode == '\"' ) { - this.keyCode = keyCode; - this.scanCode = EStdKeySingleQuote; - } - else if (keyCode >= '0' && keyCode <= '9') { - this.keyCode = keyCode; - this.scanCode = keyCode; - } - else if (keyCode == EKeySpace) { - this.keyCode = keyCode; - this.scanCode = EStdKeySpace; - } - else if (keyCode == DownArrow) { - this.keyCode = keyCode; - this.scanCode = EStdKeyDownArrow; - } - else if (keyCode == UpArrow) { - this.keyCode = keyCode; - this.scanCode = EStdKeyUpArrow; - } - else if (keyCode == LeftArrow) { - this.keyCode = keyCode; - this.scanCode = EStdKeyLeftArrow; - } - else if (keyCode == RightArrow) { - this.keyCode = keyCode; - this.scanCode = EStdKeyRightArrow; - } - else if (keyCode == ',') { - this.keyCode = keyCode; - this.scanCode = EStdKeyComma; - } - else if (keyCode == '.') { - this.keyCode = keyCode; - this.scanCode = EStdKeyFullStop; - } else { - this.keyCode = keyCode; - this.scanCode = keyCode; - } - } - - /** The symbian key code */ - public int keyCode; - - /** The symbian scan code */ - public int scanCode; - - /** Modifiers, for compatibility with XlibUtils **/ - public int modifiers; -} \ No newline at end of file diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/s60utils/java/src/com/nokia/mj/impl/uitestutils/KeyFactory.java --- a/javauis/eswt_qt/s60utils/java/src/com/nokia/mj/impl/uitestutils/KeyFactory.java Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -package com.nokia.mj.impl.uitestutils; - -public class KeyFactory -{ - - public static Key RIGHT_ARROW = new Key(Key.RightArrow); - public static Key LEFT_ARROW = new Key(Key.LeftArrow); - public static Key UP_ARROW = new Key(Key.UpArrow); - public static Key DOWN_ARROW = new Key(Key.DownArrow); - public static Key LEFTUP_ARROW = new Key(Key.EStdKeyDevice10); - public static Key RIGHTUP_ARROW = new Key(Key.EStdKeyDevice11); - public static Key RIGHTDOWN_ARROW = new Key(Key.EStdKeyDevice12); - public static Key LEFTDOWN_ARROW = new Key(Key.EStdKeyDevice13); - - public static Key SELECT_KEY = new Key(Key.Select); - public static Key SK1 = new Key(Key.CBA1); - public static Key SK2 = new Key(Key.CBA2); - - public static Key KEYPAD_0 = new Key(Key.EStdKeyNkp0); - public static Key KEYPAD_1 = new Key(Key.EStdKeyNkp1); - public static Key KEYPAD_2 = new Key(Key.EStdKeyNkp2); - public static Key KEYPAD_3 = new Key(Key.EStdKeyNkp3); - public static Key KEYPAD_4 = new Key(Key.EStdKeyNkp4); - public static Key KEYPAD_5 = new Key(Key.EStdKeyNkp5); - public static Key KEYPAD_6 = new Key(Key.EStdKeyNkp6); - public static Key KEYPAD_7 = new Key(Key.EStdKeyNkp7); - public static Key KEYPAD_8 = new Key(Key.EStdKeyNkp8); - public static Key KEYPAD_9 = new Key(Key.EStdKeyNkp9); - - public static Key F1 = new Key(Key.EKeyF1); - public static Key F2 = new Key(Key.EKeyF2); - public static Key F3 = new Key(Key.EKeyF3); - public static Key F4 = new Key(Key.EKeyF4); - public static Key F5 = new Key(Key.EKeyF5); - public static Key F6 = new Key(Key.EKeyF6); - public static Key F7 = new Key(Key.EKeyF7); - public static Key F8 = new Key(Key.EKeyF8); - public static Key F9 = new Key(Key.EKeyF9); - public static Key F10 = new Key(Key.EKeyF10); - public static Key F11 = new Key(Key.EKeyF11); - public static Key F12 = new Key(Key.EKeyF12); - public static Key F13 = new Key(Key.EKeyF13); - public static Key F14 = new Key(Key.EKeyF14); - public static Key F15 = new Key(Key.EKeyF15); - - public static Key BACKSPACE = new Key(Key.Backspace); - public static Key ENTER = new Key(Key.EKeyEnter); - public static Key ESCAPE = new Key(Key.EKeyEscape); - public static Key TAB = new Key(Key.EKeyTab); - public static Key CTRL_RIGHT = new Key(Key.EStdKeyRightCtrl); - public static Key CTRL_LEFT = new Key(Key.EStdKeyLeftCtrl); - public static Key SHIFT_RIGHT = new Key(Key.EStdKeyRightShift); - public static Key SHIFT_LEFT = new Key(Key.EStdKeyLeftShift); - public static Key SPACE = new Key(Key.EStdKeySpace); - public static Key DEL = new Key(Key.EKeyDelete); - - public static Key STAR = new Key('*'); - public static Key DIVIDE = new Key(Key.EStdKeyNkpForwardSlash); - public static Key ADD = new Key(Key.EStdKeyNkpPlus); - public static Key SUBTRACT = new Key(Key.EStdKeyNkpMinus); - public static Key HASH = new Key('#'); - public static Key CLEAR = new Key(Key.EStdKeyBackspace); - public static Key EDIT = new Key(Key.EStdKeyRightShift); - public static Key SEND = new Key(Key.EStdKeyYes); - public static Key END = new Key(Key.EStdKeyNo); - public static Key APPLICATIONS = new Key(Key.EStdKeyApplication0); - public static Key VOICE = new Key(Key.EStdKeyDevice6); - public static Key SOFTKEY_1 = new Key(Key.EStdKeyDevice0); - public static Key SOFTKEY_2 = new Key(Key.EStdKeyDevice1); - - public static Key key(int keyCode) - { - return new Key(keyCode); - } -} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/s60utils/java/src/com/nokia/mj/impl/uitestutils/Mask.java --- a/javauis/eswt_qt/s60utils/java/src/com/nokia/mj/impl/uitestutils/Mask.java Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,291 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -package com.nokia.mj.impl.uitestutils; - -/** - * Mask implementation for storing and manipulating reference mask - * for pixel checking. Mask can be mirrored, rotated, restored etc. - * - * A new mask can be created from int[] array which holds indexes for - * refrence colors, e.g. value 1 can stand for red and 0 for white. - * - * example: - * - * int[] maskData = { - * 0,0,0,0,0,0,0,0,0, - * 0,0,0,0,1,0,0,0,0, - * 0,0,0,0,1,0,0,0,0, - * 0,0,0,0,1,0,0,0,0, - * 0,0,0,0,1,0,0,0,0, - * 0,0,0,0,1,0,0,0,0, - * 0,0,0,0,1,0,0,0,0, - * 0,0,0,0,0,0,0,0,0 - * }; - * - * - * ImageUtils can validate image pixels against mask indexes and given index colors. - * - * @author sampkaar - */ - - -public class Mask { - - int[] iMask = null; - int[] iOrigMask = null; - int iScanlength = 0; - int iWidth = 0; - int iHeight = 0; - Point iCenter; - - /** - * Creates instance of Mask. - * - * @param mask - int array for mask to be created, values should be 0 or 1 - * @param scanlength - length of line in mask - * - * @throws IllegalArgumentException - if mask is null - * @throws IllegalArgumentException - if remainder or mask.length/scanlength is not zero - */ - public Mask(int[] mask, int scanlength) { - if(mask == null) { - throw new IllegalArgumentException("mask is null"); - } - if((mask.length % scanlength) != 0) { - throw new IllegalArgumentException("Illegal scanlength"); - } - iMask = mask; - iOrigMask = mask; - iScanlength = scanlength; - iCenter = new Point(scanlength/2, (iMask.length/scanlength)/2); - iWidth = scanlength; - iHeight = iMask.length/scanlength; - } - - /** - * Returns mask's data array. - */ - public int[] getData() { - return iMask; - } - - /** - * gets subarea (rect) of mask specified by given arguments. - * - * @param x The x-coordinate of ractangle - * @param y The y-coordinate of ractangle - * @param width The width of ractangle - * @param height The height of ractangle - */ - public int[] getData(int x, int y, int width, int height) { - // specified area cannot exceed mask bounds - if((x+width > iWidth) || (y+height > iHeight)) { - throw new IllegalArgumentException("Area to be retrieved exceeds mask bounds"); - } - - // create new array - int[] result = new int[width*height]; - final int h = y+height; - final int w = x+width; - - // populate array - int resultIndex = 0; - for(int i = y; i < h ; i++) { - for(int j=x; j= 0; srcIndex -= iScanlength) { - System.arraycopy(iMask, srcIndex, resultMask, dstIndex, iScanlength); - dstIndex += iScanlength; - } - } - // save result mask - iMask = resultMask; - } - - /** - * Prints mask contents to console - */ - public void print() { - String output = "\n Mask("+iScanlength+","+iMask.length/iScanlength+"):\n"; - int y = 0; - for(int i = 0; i < iMask.length; i++) { - output += iMask[i]+","; - if(i==((y*iScanlength) + (iScanlength-1))) { - output += "\n"; - y++; - } - } - System.out.println(output); - } - - /** - * prints given mask data - * - * @param maskData The data of mask to be printed - * @param scanlengt The scanlength of one line in maskData - */ - public void print(int[] maskData, int scanlength) { - - final int width = scanlength; - final int height = maskData.length / width; - - String output = "\n Mask("+width+","+height+"):\n"; - - int y = 0; - for(int i = 0; i < maskData.length; i++) { - output += maskData[i]+","; - if(i==((y*width) + (width-1))) { - output += "\n"; - y++; - } - } - System.out.println(output); - } - - /** - * Resets mask to original mask given in constructor. - */ - public void resetOriginal() { - iMask = iOrigMask; - } - - /** - * Rotates mask. - * Positive angle rotates clockwise - * Negative angle rotates counterclockwise - * - * NOTE output is 100% correct only if width/height of mask is not even, i.e. - * 21 is ok, but 20 not. This is because currently the rotation is done after - * translating origin to the center of the mask and if width is 20 there no clear - * center... - * - * @param angel - The rotation angel - * @throws IllegalArgumentException - if remainder of angle / 90 is not zero - */ - public void rotate(float angle) { - if((angle % 90) != 0) { - throw new IllegalArgumentException("do not use other than 90 degree rotations"); - } - Matrix m = new Matrix(); - m.translate(iCenter.x, iCenter.y); - m.rotate(angle); - m.translate(-iCenter.x, -iCenter.y); - transform(m); - } - - /** - * Transforms mask based on given transform matrix. - * Note e.g. 45 degree rotation will fail as it needs bigger - * buffer, which is not supported. - * - * @param m - The trasformation matrix - * @throws IllegalArgumentException - if matrix m is null - * - */ - private void transform(Matrix m) { - if(m == null) { - throw new IllegalArgumentException("Matrix m is null"); - } - - int[] resultMask = new int[iMask.length]; - int y = 0; // line in source mask - int targetIndex = 0; // result mask index - - // points for source and target - Point sourcePoint; - Point targetPoint; - - for(int i=0; i< iMask.length ; i++){ - sourcePoint = new Point((i-(y*iScanlength)), y); - targetPoint = m.transform(sourcePoint); - targetIndex = (round(targetPoint.y)*iScanlength)+round(targetPoint.x); - resultMask[targetIndex] = iMask[i]; - - if(i==((y*iScanlength) + (iScanlength-1))) { - y++; - } - } - iMask = resultMask; - } - - /** - * Rounds given float to closest int value, e.g. - * If value >= 0.5 result is 1 - * if value <= 0.49 result is 0 - * - * @param value - The value to be rounded - */ - private int round(float value) { - int result = 0; - float temp = (int)value; - - if((temp+0.5 <= value)) { - result = (int)value+1; - } else { - result = (int)value; - } - return result; - } -} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/s60utils/java/src/com/nokia/mj/impl/uitestutils/Matrix.java --- a/javauis/eswt_qt/s60utils/java/src/com/nokia/mj/impl/uitestutils/Matrix.java Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,274 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -package com.nokia.mj.impl.uitestutils; - -/** - * Matrix calculation implementation. - * - */ -public class Matrix { - - static final int ARRAY_SIZE = 6; - // Array index - static private final int M00 = 0; - static private final int M10 = 1; - static private final int M01 = 2; - static private final int M11 = 3; - static private final int M02 = 4; - static private final int M12 = 5; - - private float iComponents[]; - - /** - * Construct a matrix with the following components: - *
                -     * [1 0 0]
                -     * [0 1 0]
                -     * 
                - */ - public Matrix() { - iComponents = new float[ARRAY_SIZE]; - identity(); - } - - /** - * Construct a matrix with the following components: - *
                -     * [aM00 aM01 aM02]
                -     * [aM10 aM11 aM12]
                -     * 
                - * @param aM00 the x scaling component - * @param aM10 the y shearing component - * @param aM01 the x shearing component - * @param aM11 the y scaling component - * @param aM02 the x translation component - * @param aM12 the y translation component - */ - public Matrix(float aM00, float aM10, float aM01, - float aM11, float aM02, float aM12) { - iComponents = new float[ARRAY_SIZE]; - iComponents[M00] = aM00; iComponents[M01] = aM01; iComponents[M02] = aM02; - iComponents[M10] = aM10; iComponents[M11] = aM11; iComponents[M12] = aM12; - } - - /** - * Constructor - * Create a new matrix by coping the given one. - * @param aMatrix the matrix to copy - */ - public Matrix(Matrix aMatrix) { - iComponents = new float[aMatrix.iComponents.length]; - for(int index = 0; index < iComponents.length; index++) { - iComponents[index] = aMatrix.iComponents[index]; - } - } - - /** - * - */ - public float getComponent(int index) { - return iComponents[index]; - } - - /** - * Set matrix components: - *
                -     * [1 0 0]
                -     * [0 1 0]
                -     * 
                - * - */ - public void identity() - { - iComponents[M00] = 1; iComponents[M01] = 0; iComponents[M02] = 0; - iComponents[M10] = 0; iComponents[M11] = 1; iComponents[M12] = 0; - } - - /** - * Return transformed Point instance - * - * The transformation can be represented using matrix math on a 3x3 array. - * Given (x,y), the transformation (x',y') can be found by: - * [ x'] [ m00 m01 m02 ] [ x ] [ m00*x + m01*y + m02 ] - * [ y'] = [ m10 m11 m12 ] [ y ] = [ m10*x + m11*y + m12 ] - * [ 1 ] [ 0 0 1 ] [ 1 ] [ 1 ] - * - * The bottom row of the matrix is constant, so a transform can be uniquely - * represented by "[[m00, m01, m02], [m10, m11, m12]]". - * @param p the source point - * @return new point instance - */ - public Point transform(final Point p) - { - return new Point( - iComponents[M00] * p.x + iComponents[M01] * p.y + iComponents[M02], - iComponents[M10] * p.x + iComponents[M11] * p.y + iComponents[M12]); - } - - /** - * Return the matrix of components used in this transform. The resulting - * values are: - *
                -     * [array[0] array[2] array[4]]
                -     * [array[1] array[3] array[5]]
                -     * 
                - * @return array that contains the matrix components. - */ - float[] getComponents() { - return iComponents; - } - - - /** - * Return the determinant of this transform matrix. If the determinant is - * non-zero, the transform is invertible. - * The determinant is calculated as: - *
                -     * [m00 m01 m02] 
                -     * [m10 m11 m12] = m00 * m11 - m01 * m10
                -     * [ 0   0   1 ]
                -     * 
                - * @return the determinant - */ - public float determinant() { - return ((iComponents[M00] * iComponents[M11]) - - (iComponents[M01] * iComponents[M10])); - } - - /** - * The inverse is calculated as: - *
                -     *     [m00 m01 m02]
                -     *  M= [m10 m11 m12]
                -     *     [ 0   0   1 ] 
                -     *
                -     *              1                 [ m11/det  -m01/det   (m01*m12-m02*m11)/det]     
                -     * inverse(M)= --- x adjoint(M) = [-m10/det   m00/det   (m10*m02-m00*m12)/det] 
                -     *             det                [    0         0               1           ]  
                -     * 
                - */ - public Matrix inverse() { - // The inversion is useful for undoing transformations. - float det = determinant(); - if (det == 0) - { - throw new RuntimeException("Invalid determinant"); - } - return new Matrix( - iComponents[M11] / det, // iMtx[M00] - (-iComponents[M10]) / det, // iMtx[M10] - (-iComponents[M01]) / det, // iMtx[M01] - iComponents[M00] / det, // iMtx[M11] - ((iComponents[M01] * iComponents[M12]) - (iComponents[M02] * iComponents[M11])) / det, - ((iComponents[M10] * iComponents[M02]) - (iComponents[M00] * iComponents[M12])) / det); - } - - /** - * The multiply is calculated as: - *
                -     *       [a00 a01 a02]   [b00 b01 b02]
                -     *  this=[a10 a11 a12] B=[b10 b11 b12] 
                -     *       [ 0   0   1 ]   [ 0   0   1 ]
                -     *
                -     *                       [(a00*b00+a01*b10) (a00*b01+a01*b11) (a00*b02+a01*b12+a02)]   
                -	 * [this] = [this]x[B] = [(a10*b00+a11*b10) (a10*b01+a11*b11) (a10*b02+a11*b12+a12)]
                -     *                       [       0                   0                     1       ]
                -     * 
                - */ - public Matrix multiply(Matrix b) { - if(b == null) - { - throw new NullPointerException(); - } - float a00 = iComponents[M00]; // a - float a10 = iComponents[M10]; // b - float a01 = iComponents[M01]; // c - float a11 = iComponents[M11]; // d - float a02 = iComponents[M02]; // e - float a12 = iComponents[M12]; // f - iComponents[M00] = (a00 * b.iComponents[M00]) + (a01 * b.iComponents[M10]); // a - iComponents[M10] = (a10 * b.iComponents[M00]) + (a11 * b.iComponents[M10]); // b - iComponents[M01] = (a00 * b.iComponents[M01]) + (a01 * b.iComponents[M11]); // c - iComponents[M11] = (a10 * b.iComponents[M01]) + (a11 * b.iComponents[M11]); // d - iComponents[M02] = (a00 * b.iComponents[M02]) + (a01 * b.iComponents[M12]) + a02; // e - iComponents[M12] = (a10 * b.iComponents[M02]) + (a11 * b.iComponents[M12]) + a12; // f - return this; - } - - /** - * The rotation is calculated as: - *
                -     *          [ cos(angle) -sin(angle) 0 ]
                -     * [this] x [ sin(angle)  cos(angle) 0 ]
                -     *          [     0           0      1 ]
                -     * 
                - */ - public Matrix rotate(float angle) { - if (angle % 360 == 0) { - return this; - } - // Must convert degrees to radians since java.lang.Math expects radians - angle = angle * (float)Math.PI / 180.0f; - float c = (float)Math.cos(angle); - float s = (float)Math.sin(angle); - float m00 = iComponents[M00]; - float m10 = iComponents[M10]; - float m01 = iComponents[M01]; - float m11 = iComponents[M11]; - iComponents[M00] = m00 * c + m01 * s; - iComponents[M10] = m10 * c + m11 * s; - iComponents[M01] = m01 * c - m00 * s; - iComponents[M11] = m11 * c - m10 * s; - return this; - } - - /** - * The multiply is calculated as: - *
                -     *       [m00 m01 m02]   [scaleFactor      0      0]
                -     *  this=[m10 m11 m12] B=[    0       scaleFactor 0] 
                -     *       [ 0   0   1 ]   [    0            0      1]
                -     *
                -     *                       [(a00*scaleFactor) (a01*scaleFactor) a02]   
                -     * [this] = [this]x[B] = [(a10*scaleFactor) (a11*scaleFactor) a12]
                -     *                       [       0                   0         1 ]
                -     * 
                - * @see org.w3c.dom.svg.SVGMatrix#mScale() - */ - public Matrix scale(float scaleFactor) { - if(scaleFactor == 1) { - return this; - } - iComponents[M00] *= scaleFactor; - iComponents[M01] *= scaleFactor; - iComponents[M10] *= scaleFactor; - iComponents[M11] *= scaleFactor; - return this; - } - - /** - * - */ - public Matrix translate(float x, float y) { - if(x == 0 && y == 0) { - return this; - } - iComponents[M02] += (iComponents[M00] * x) + (iComponents[M01] * y); - iComponents[M12] += (iComponents[M10] * x) + (iComponents[M11] * y); - return this; - } -} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/s60utils/java/src/com/nokia/mj/impl/uitestutils/Modifier.java --- a/javauis/eswt_qt/s60utils/java/src/com/nokia/mj/impl/uitestutils/Modifier.java Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,30 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -package com.nokia.mj.impl.uitestutils; - -public final class Modifier { - - // Bitmask for sending modifiers - // Values taken from /usr/include/X11/X.h - public static final int Shift = (1<<0); - public static final int CapsLock = (1<<1); - public static final int Control = (1<<2); - public static final int Alt = (1<<3); - public static final int NumLock = (1<<4); - public static final int ScrllLock = (1<<4); - public static final int AltGr = (1<<7); -} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/s60utils/java/src/com/nokia/mj/impl/uitestutils/Point.java --- a/javauis/eswt_qt/s60utils/java/src/com/nokia/mj/impl/uitestutils/Point.java Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -package com.nokia.mj.impl.uitestutils; - -/** - * Class for storing point, i.e. x and y values. - * This is used in matric calculations. - * - * @author ktuokkol - */ -public class Point { - public float x; - public float y; - - /** - * Ctor - */ - public Point() { - x = 0f; - y = 0f; - } - - /** - * Ctor - * @param x - * @param y - */ - public Point(float x, float y) { - this.x = x; - this.y = y; - } - -} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/s60utils/java/src/com/nokia/mj/impl/uitestutils/Rect.java --- a/javauis/eswt_qt/s60utils/java/src/com/nokia/mj/impl/uitestutils/Rect.java Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,116 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -package com.nokia.mj.impl.uitestutils; - -/** - * Simple rect container - * @author sampkaar - * - */ -public class Rect { - - private int x; - private int y; - private int width; - private int height; - - public Rect(int x, int y, int width, int height) { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - } - - public int x() { - return this.x; - } - - public int y() { - return this.y; - } - - public int width() { - return this.width; - } - - public int height() { - return this.height; - } - - public Rect intersection(Rect aRect){ - - if( aRect.x < this.x && aRect.x+aRect.width < this.x || - aRect.x > this.x+this.width && aRect.x+aRect.width > this.x+this.width) - { // no intersection - return new Rect(0,0,0,0); - } - if( aRect.y < this.y && aRect.y+aRect.height < this.y || - aRect.y > this.y+this.height && aRect.y+aRect.height > this.y+this.height) - { // no intersection - return new Rect(0,0,0,0); - } - int x = 0; - int y = 0; - int w = 0; - int h = 0; - - if(aRect.x < this.x) - { - x = this.x; - if (this.x + this.width < aRect.x + aRect.width) - { - w = this.width; - }else - { - w = aRect.x + aRect.width - this.x; - } - } else - { // aRect.x >= this.x - x = aRect.x; - if (aRect.x + aRect.width < this.x + this.width) - { - w = aRect.width; - }else - { - w = this.x + this.width - aRect.x; - } - } - if(aRect.y < this.y) - { - y = this.y; - if (this.y + this.height < aRect.y + aRect.height) - { - h = this.height; - }else - { - h = aRect.y + aRect.height - this.y; - } - } else - { // aRect.y >= this.y - y = aRect.y; - if (aRect.y + aRect.height < this.y + this.height) - { - h = aRect.height; - }else - { - h = this.y + this.height - aRect.y; - } - } - return new Rect(x, y, w, h); - } - -} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/s60utils/java/src/com/nokia/mj/impl/uitestutils/RuntimeUtils.java --- a/javauis/eswt_qt/s60utils/java/src/com/nokia/mj/impl/uitestutils/RuntimeUtils.java Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,40 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -package com.nokia.mj.impl.uitestutils; - -import org.eclipse.ercp.swt.midp.UIThreadSupport; - -public class RuntimeUtils { - - public static final int S60 = 1; - public static final int X11 = 2; - - public static int getPlatform() { - return S60; - } - - public synchronized static final int startUI( - final Runnable callback) { - UIThreadSupport.startInUIThread(new Runnable() { - public void run() { - callback.run(); - } - }); - return 0; - } -} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/s60utils/java/src/com/nokia/mj/impl/uitestutils/S60Utils.java --- a/javauis/eswt_qt/s60utils/java/src/com/nokia/mj/impl/uitestutils/S60Utils.java Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,128 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -package com.nokia.mj.impl.uitestutils; - - -final class S60Utils { - - static { - // Should use vmport, this is CDC/J2SE API - //System.loadLibrary("s60uitestutils"); - org.eclipse.swt.internal.Library.loadLibrary("s60uitestutils"); - } - - /** - * Constant for key press event. - */ - static final int PRESS = 0; - - /** - * Constant for key release event. - */ - static final int RELEASE = 1; - - /** - * Button constants. - */ - static final int BUTTON1 = 1; - static final int BUTTON2 = 2; - static final int BUTTON3 = 3; - - - /** - * Sends a key event to the window which has the keyboard focus. Get the keycode of - * the desired symbol using XKeysymToKeycode and pass that here. Or if the desired - * keycode is known it can be passed directly. - * @param keycode The keycode of the key to send. - * @param modifiers The modifiers to send. - * @param pressOrRelease Either PRESS or RELEASE must be passed here. - * @return 0 if successful, otherwise a non-zero error code - * @see XlibKeys - */ - static final native int S60SendKeyToFocusWindow(int keycode, int modifiers, int pressOrRelease); - - /** - * Returns the keycode of the given symbol (keysym) in the currently active - * keyboard layout. Keysym constants are defined in XlibKeys. - * @param keysym - * @return The keycode or zero in case of an error - * @see XlibKeys - */ - static final native int S60KeysymToKeycode(int keysym); - - /** - * Sends a pointer press or release event. - * @param x X-coordinate to send, relative to X root window (i.e. screen). - * @param y Y-coordinate to send, relative to X root window (i.e. screen). - * @param modifiers The modifiers to send. - * @param button The button that's pressed or released. - * @param pressOrRelease Either PRESS or RELEASE must be passed here. - * @return 0 if successful, otherwise a non-zero error code - */ - static final native int S60SendPointerEvent(int x, int y, int button, int pressOrRelease); - - /** - * Sends a pointer move event. - * @param x X-coordinate to send, relative to X root window (i.e. screen). - * @param y Y-coordinate to send, relative to X root window (i.e. screen). - * @param button The button that's held pressed during the move. - * @return 0 if successful, otherwise a non-zero error code - */ - static final native int S60SendPointerMoveEvent(int x, int y, int button); - - /** - * Disables the screensaver. - */ - static final native void S60DisableScreensaver(); - - /** - * Sets the doubleclick interval. Set to 0 to disable doubleclicks. - * @param interval New doubleclick interval - */ - static final native void S60SetDoubleclickInterval(int interval); - - /*static final native int _create(int toolkitHandle, UITestUtils testUtils); - static final native void _dispose(int toolkitHandle, UITestUtils testUtils, int testUtilsHandle); - - static final native void _startTest(int toolkitHandle, int handle, String screenShotDir); - static final native void _endTest(int toolkitHandle, int handle, boolean passed, String msg); - - static final native void _log(int toolkitHandle, int handle, String msg); - static final native void _logResult(int toolkitHandle, int handle, boolean passed, String msgPassed, String msgFailed); - - static final native void _triggerKeyPressEvent(int toolkitHandle, int handle, int keyCode, int scanCode); - static final native int _triggerKeyRepeatEvents(int toolkitHandle, int handle, int keyCode, int scanCode, int count); - static final native int _triggerMediaKeyRepeatEvents(int toolkitHandle, int handle, int keyCode, int scanCode, int pressedTimeInMillis); - - static final native boolean _getScreenShot(int toolkitHandle, int handle, String screenShotName); - static final native boolean _getScreenShot(int toolkitHandle, int handle, String screenShotName, - int areaToCompare, int displayableType); - static final native boolean _getScreenShot(int toolkitHandle, int handle, String screenShotName, - int topLeftX, int topLeftY, int bottomRightX, int bottomRightY); - - static final native void _triggerPointerDownEvent(int toolkitHandle, int handle, int x, int y); - static final native void _triggerPointerUpEvent(int toolkitHandle, int handle, int x, int y); - static final native void _triggerPointerDragEvent(int toolkitHandle, int handle, int x, int y); - - static final native void _changeQwertyInput(int toolkitHandle, int handle, boolean aOn); - static final native int _switchResolution(int toolkitHandle, int handle, int numTimes, int delayMillis); - - static final native void _getBoundsOf(int toolkitHandle, int handle, int type, int[] coordinates); - - static final native void _allowScreenSaver(int toolkitHandle, int handle, int allow);*/ - -} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/s60utils/java/src/com/nokia/mj/impl/uitestutils/UITestUtils.java --- a/javauis/eswt_qt/s60utils/java/src/com/nokia/mj/impl/uitestutils/UITestUtils.java Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,203 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -// UITestUtils.java // // // - -package com.nokia.mj.impl.uitestutils; - -import java.lang.String; -import org.eclipse.swt.internal.qt.OS; - -public class UITestUtils { - - private static final int RES_CHANGE_DEFAULT_DELAY = 5000; - - public UITestUtils() { - // Always disable screensaver when running tests. - S60Utils.S60DisableScreensaver(); - } - - /** Init test and s. shot directory, make sure you use slashes to start and - end it dir name */ - public void startTest(String screenShotDir) { - } - - /** Ends the test, prints a summary, etc */ - public void endTest(boolean passed, String msg) { - } - - /** Log a message */ - public void log(String msg) { - } - - /** Logs one of the two messages and either PASSED or FAILED according to - value of passed parameter */ - public void log(boolean passed, String msgPassed, String msgFailed) { - } - - /** Sends a key event to the midlet using the specified key and scan code */ - public void triggerKeyPressEvent(Key key) { - int keycode = key.scanCode; - int modifiers = key.modifiers; - if(S60Utils.S60SendKeyToFocusWindow(keycode, modifiers, S60Utils.PRESS) != 0) - throw new RuntimeException("Emulating key press failed"); - if(S60Utils.S60SendKeyToFocusWindow(keycode, modifiers, S60Utils.RELEASE) != 0) - throw new RuntimeException("Emulating key release failed"); - } - - /** Sends a key down event to the application using the specified key */ - public void triggerKeyDownEvent(Key key) { - int keycode = key.scanCode; - int modifiers = key.modifiers; - if(S60Utils.S60SendKeyToFocusWindow(keycode, modifiers, S60Utils.PRESS) != 0) - throw new RuntimeException("Emulating key press failed"); - } - - /** Sends a key up event to the application using the specified key */ - public void triggerKeyUpEvent(Key key) { - int keycode = key.scanCode; - int modifiers = key.modifiers; - if(S60Utils.S60SendKeyToFocusWindow(keycode, modifiers, S60Utils.RELEASE) != 0) - throw new RuntimeException("Emulating key release failed"); - } - - - /** Triggers key repeat events using the specified key and scan code. - Calling this method will trigger the following events to Canvas/CustomItem: - 1. keyPressed event - 2. keyRepeated events, the number of events is indicated by count parameter - 3. keyReleased events - - NOTE 1: This method returns right after triggering the keyPressed event. There should be enough delay - after calling this so that all repeat events can be handled before the test result is checked. - The delay before triggering first repeat event is 0.6 seconds and between sequential repeat - events 0.2 seconds. - - NOTE 2: For triggering media key repeat events triggerMediaKeyRepeatEvents() - must be used. - */ - public int triggerKeyRepeatEvents(Key key, int count) { - return 0; - } - - /** This method must be used when triggering repeat events for media keys. - pressedTimeInMillis defines how long a key is kept pressed down. - - NOTE 1: This method returns right after triggering the keyDown event. There should be enough delay - (> pressedTimeInMillis) after calling this so that all repeat events and key up can be handled before - the test result is checked. - */ - public int triggerMediaKeyRepeatEvents(Key key, int pressedTimeInMillis) { - return 0; - } - - /** Sends pointer down event to the midlet */ - public void triggerPointerDownEvent(int x, int y) { - // Setting double click interval to 0 disables double clicks, making it possible - // to click around in the test cases quickly without causing unwanted double click - // events - OS.QApplication_setDoubleClickInterval(0); - if(S60Utils.S60SendPointerEvent(x, y, S60Utils.BUTTON1, S60Utils.PRESS) != 0) - throw new RuntimeException("Emulating pointer down failed"); - } - - /** Sends pointer up event to the midlet */ - public void triggerPointerUpEvent(int x, int y) { - if(S60Utils.S60SendPointerEvent(x, y, S60Utils.BUTTON1, S60Utils.RELEASE) != 0) - throw new RuntimeException("Emulating pointer up failed"); - } - - /** Sends pointer drag event to the midlet */ - public void triggerPointerDragEvent(int x, int y) { - if(S60Utils.S60SendPointerMoveEvent(x, y, S60Utils.BUTTON1) != 0 ) { - throw new RuntimeException("Emulating pointer move failed"); - } - } - - /** - * Sends a pointer event to open up a context menu. E.g. long-press, right-click - * or such depending on the platform. - */ - public void triggerContextPointerEvent(int x, int y) { - if(S60Utils.S60SendPointerEvent(x, y, S60Utils.BUTTON3, S60Utils.PRESS) != 0) - throw new RuntimeException("Emulating pointer down failed"); - if(S60Utils.S60SendPointerEvent(x, y, S60Utils.BUTTON3, S60Utils.RELEASE) != 0) - throw new RuntimeException("Emulating pointer up failed"); - } - - /** Takes a screen shot and saves it into a .png file. Returns true if - reference screen shot exists and is identical to the new screen shot*/ - public boolean getScreenShot(String screenShotName) { - return true; - } - - /** Takes a screen shot and saves it into a .png file. Returns true if - reference screen shot exists and compared area is identical in the reference and new screen shot. - areaToCompare and displayableType define the area that is compared. See also SpedeRunner.java.*/ - public boolean getScreenShot(String screenShotName, int areaToCompare, int displayableType) { - return true; - } - - /** Takes a screen shot and saves it into a .png file. Returns true if - reference screen shot exists and compared area is identical in the reference and new screen shot. - Four integer parameters define the rectangle area for screen shot comparison. */ - public boolean getScreenShot(String screenShotName, int topLeftX, int topLeftY, - int bottomRightX, int bottomRightY) { - return true; - } - - public void dispose() { - } - - /** Enable or disable QWERTY input */ - public void changeQwertyInput(boolean aOn) { - } - - public int switchResolution() { - return switchResolution(1); - } - - /** Change the screen resolution - works only on the emulator */ - public int switchResolution(int numTimes) { - return 0; - } - - /** Change the screen resolution - works only on the emulator */ - public int switchResolutionWithDelay(int delayMillis) { - return 0; - } - - /** - * Get the top left and bottom right coordinates of main pane, form rect, etc. - * - * @param coordinates The coordinates are returned in this array - * @param type Defines for which area the coordinates are fetched - */ - public void getBoundsOf(int type, int[] coordinates) { - } - - /** - * Disable screen saver - */ - public void disableScreenSaver() { - } - - /** - * Enable screen saver - */ - public void enableScreenSaver() { - } -} diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/s60utils/native/native.pro --- a/javauis/eswt_qt/s60utils/native/native.pro Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,34 +0,0 @@ -###################################################################### -# Automatically generated by qmake (2.01a) Wed 9. Sep 14:45:48 2009 -###################################################################### - -TEMPLATE = lib -TARGET = s60uitestutils -DEPENDPATH += . -INCLUDEPATH += . /epoc32/include /epoc32/include/domain/middleware -INCLUDEPATH += ../../../../inc - -# Input -HEADERS += s60utils.h -SOURCES += s60utils.cpp jni_lookup.cpp - -QT += core - -TARGET.UID = 0x1000008d -TARGET.CAPABILITY ="ALL -TCB" - -# Temporarily allow WSD, to be removed later if possible -TARGET.EPOCALLOWDLLDATA = 1 - -LIBS += -leikcore - -DEFINES+=J9EPOC32 - -# Std cpp requirements -LIBS += -llibc -LIBS += -leuser -LIBS += -llibstdcpp -LIBS += -ljavautils - -DEFINES+= MACRO_WCHAR_T_DECLARED -QMAKE_CXXFLAGS.CW += -wchar_t on diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/s60utils/native/s60utils.cpp --- a/javauis/eswt_qt/s60utils/native/s60utils.cpp Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,162 +0,0 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -#include -#include -#include -#include -#include -#include -#include -#include - -//#include - -#include "s60utils.h" -// Note following modifilers are from X11 instead of Symbian -static const TInt Shift = (1<<0); -static const TInt CapsLock = (1<<1); -static const TInt Control = (1<<2); -static const TInt Alt = (1<<3); -static const TInt NumLock = (1<<4); -static const TInt ScrllLock = (1<<4); -static const TInt AltGr = (1<<7); - - -static TInt symbianKeyCode(TInt aX11Modifier) - { - TInt keyCode(0); - if( (aX11Modifier & Shift) > 0 ) - { - keyCode = EStdKeyLeftShift; - } - else if( (aX11Modifier & CapsLock) > 0 ) - { - keyCode = EStdKeyCapsLock; - } - else if( (aX11Modifier & Control) > 0 ) - { - keyCode = EStdKeyLeftCtrl; - } - else if( (aX11Modifier & Alt) > 0 ) - { - keyCode = EStdKeyLeftAlt; - } - else if( (aX11Modifier & NumLock) > 0 ) - { - keyCode = EStdKeyNumLock; - } - else if( (aX11Modifier & ScrllLock) > 0 ) - { - keyCode = EStdKeyScrollLock; - } - else if( (aX11Modifier & AltGr) > 0 ) - { - keyCode = EStdKeyRightAlt; - } - return keyCode; - } - -JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_uitestutils_S60Utils_S60SendKeyToFocusWindow - (JNIEnv *, jclass, jint aKeyCode, jint aModifier, jint aPressOrRelease) - { - RDebug::Print(_L("S60UITestUtils : S60SendKeyToFocusWindow, keycode=%d"), aKeyCode); - - User::ResetInactivityTime();// Reset user inactivity timers - - if(aModifier > 0 && aPressOrRelease == com_nokia_mj_impl_uitestutils_S60Utils_PRESS) - { - TRawEvent mevent; - TInt keyCode = symbianKeyCode( aModifier); - mevent.Set(TRawEvent::EKeyDown, keyCode); - UserSvr::AddEvent(mevent); - User::After(100000); - } - - TRawEvent event; - - if (aPressOrRelease == com_nokia_mj_impl_uitestutils_S60Utils_PRESS) - { - event.Set(TRawEvent::EKeyDown, aKeyCode); - } - else - { - event.Set(TRawEvent::EKeyUp, aKeyCode); - } - - UserSvr::AddEvent(event); - User::After(100000); - if(aModifier > 0 && aPressOrRelease == com_nokia_mj_impl_uitestutils_S60Utils_RELEASE) - { - TRawEvent mevent; - TInt keyCode = symbianKeyCode(aModifier); - mevent.Set(TRawEvent::EKeyUp, keyCode); - UserSvr::AddEvent(mevent); - User::After(100000); - } - - return 0; - } - -JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_uitestutils_S60Utils_S60KeysymToKeycode - (JNIEnv *, jclass, jint) - { - return 0; - } - -JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_uitestutils_S60Utils_S60SendPointerEvent - (JNIEnv *, jclass, jint aX, jint aY, jint /*aButton*/, jint aPressOrRelease) - { - User::ResetInactivityTime();// Reset user inactivity timers - - TRawEvent event; - - if (aPressOrRelease == com_nokia_mj_impl_uitestutils_S60Utils_PRESS) { - event.Set(TRawEvent::EButton1Down, aX, aY); - } else { - event.Set(TRawEvent::EButton1Up, aX, aY); - } - UserSvr::AddEvent(event); - return 0; - } - -JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_uitestutils_S60Utils_S60SendPointerMoveEvent - (JNIEnv *, jclass, jint aX, jint aY, jint) - { - User::ResetInactivityTime();// Reset user inactivity timers - TRawEvent event; - event.Set(TRawEvent::EPointerMove, aX, aY); - UserSvr::AddEvent(event); - return 0; - } - -JNIEXPORT void JNICALL Java_com_nokia_mj_impl_uitestutils_S60Utils_S60DisableScreensaver - (JNIEnv *, jclass) - { - RProperty::Set( KPSUidScreenSaver, KScreenSaverAllowScreenSaver, 1 ); - } - -JNIEXPORT void JNICALL Java_com_nokia_mj_impl_uitestutils_S60Utils_S60SetDoubleclickInterval - (JNIEnv *, jclass, jint aInterval) - { - // Commented out for now. This can be taken into use once Qt doesn't need WSD to be allowed - /*QApplication* app = static_cast(QCoreApplication::instance()); - if ( app ) - { - app->setDoubleClickInterval( aInterval ); - }*/ - } - \ No newline at end of file diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/subsystem.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/subsystem.mk Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,24 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +include $(JAVA_SRC_ROOT)/build/Makefile.defs + +COMPONENTS = \ + eswtuitestutils/build \ + nokiatests/build \ + + +include ${JAVA_SRC_ROOT}/build/Makefile.subsystem \ No newline at end of file diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/ui_mts_sis/Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/ui_mts_sis/Makefile Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,58 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +# About signing certificates: +# Used signing certificates can be given by specifying certificate +# directories with macro SIGNING_KEY_DIRS. Each .der file in the +# directories is used as certificate, and must be accompanied with +# a .key file having same basename. Directories must be specificed +# using slashes as directory separator also in windows. Any path +# accessible by OS can be used, including windows share UNCs. + +include $(JAVA_SRC_ROOT)/build/Makefile.defs + +SISFILES = java_3_1.sis + + +all: $(SISFILES) + +# Find signing certificates from SIGNING_KEY_DIR (*.der, each having .key file) +# Fix path to native separator +SIGNING_CERTS=$(call PATHFIX,$(wildcard $(addsuffix /*.der,$(SIGNING_KEY_DIRS)))) + +$(DEPLOYDIR)/% :: % + if not exist $(WINDEPLOYDIR) mkdir $(WINDEPLOYDIR) + copy $< $(subst /,\,$@) + +# Recreate the SIS files always +.phony: ALWAYS +.phony: all clean reallyclean + + +CPP_SIS_CMD = cpp -lang-asm -P -undef + +%.sis: %.pkg ALWAYS + $(CPP_SIS_CMD) $< $<.pkg + makesis $<.pkg unsigned.$@ + copy unsigned.$@ $@ + echo Signing with $(SIGNING_CERTS) \ + $(foreach cert,$(SIGNING_CERTS), && signsis $@ $@ $(cert) $(basename $(cert)).key) + del $<.pkg + +clean: + del *.sis* 2>NUL + +reallyclean: clean diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/ui_mts_sis/java_3_1.pkg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/eswt_qt/ui_mts_sis/java_3_1.pkg Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,52 @@ +; +; Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +; All rights reserved. +; This component and the accompanying materials are made available +; under the terms of "Eclipse Public License v1.0" +; which accompanies this distribution, and is available +; at the URL "http://www.eclipse.org/legal/epl-v10.html". +; +; Initial Contributors: +; Nokia Corporation - initial contribution. +; +; Contributors: +; +; Description: +; +;Languages +&EN + +#include "../../../inc/build_defines.hrh" + +; UID of the sis file +#{"Java Runtime"},(0x2001FD68), RD_JAVA_VERSION, TYPE=SA,RU + +;Localised Vendor name +%{"Nokia"} + +;Unique Vendor name +:"Nokia" + +;Supports Series 60 v 5.0 +;This line indicates that this installation is for the Series 60 platform v3.0 +;This line must appear _exactly_ as shown below in the sis file +;If this line is missing or incorrect, the sis file will not be able +;to be installed on Series 60 v5.0 platforms +[0x1028315F], 0, 0, 0, {"Series60ProductID"} + + +; Jars +"\epoc32\release\armv5\urel\z\resource\java\jvm\lib\jrt\nokiaeswttests.jar"-"c:\resource\java\jvm\lib\jrt\nokiaeswttests.jar" +"\epoc32\release\armv5\urel\z\resource\java\jvm\lib\jrt\eswtuitestutils.jar"-"c:\resource\java\jrt\lib\common\eswtuitestutils.jar" +"\epoc32\release\armv5\urel\z\resource\java\jvm\lib\jrt\junit-3.8.1.1.jar"-"c:\resource\java\jvm\lib\jrt\junit-3.8.1.1.jar" +"\epoc32\release\armv5\urel\z\resource\java\jvm\lib\jrt\openlcduitests.jar"-"c:\resource\java\jvm\lib\jrt\openlcduitests.jar" + +; test odc files +"\epoc32\release\armv5\urel\z\resource\java\jvm\lib\jrt\nokiaeswttests.odc"-"c:\resource\java\jvm\lib\jrt\nokiaeswttests.odc" +"\epoc32\release\armv5\urel\z\resource\java\jvm\lib\jrt\openlcduitests.odc"-"c:\resource\java\jvm\lib\jrt\openlcduitests.odc" +"\epoc32\release\armv5\urel\z\resource\java\jvm\lib\jrt\eswtuitestutils.odc"-"c:\resource\java\jvm\lib\jrt\eswtuitestutils.odc" +"\epoc32\release\armv5\urel\z\resource\java\jvm\lib\jrt\junit-3.8.1.1.odc"-"c:\resource\java\jvm\lib\jrt\junit-3.8.1.1.odc" + +"\epoc32\release\armv5\urel\eswtuitestutils.dll"-"c:\sys\bin\eswtuitestutils.dll" + +"\epoc32\data\z\resource\java\installerodclist"-"c:\resource\java\installerodclist" \ No newline at end of file diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/ImageTestUtils.java --- a/javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/ImageTestUtils.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/ImageTestUtils.java Fri Jun 11 13:33:44 2010 +0300 @@ -1,19 +1,3 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ package com.nokia.mj.impl.uitestutils; import org.eclipse.swt.internal.qt.graphics.Image; diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/Key.java --- a/javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/Key.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/Key.java Fri Jun 11 13:33:44 2010 +0300 @@ -1,19 +1,3 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ package com.nokia.mj.impl.uitestutils; /** diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/KeyFactory.java --- a/javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/KeyFactory.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/KeyFactory.java Fri Jun 11 13:33:44 2010 +0300 @@ -1,19 +1,3 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ package com.nokia.mj.impl.uitestutils; public class KeyFactory diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/Mask.java --- a/javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/Mask.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/Mask.java Fri Jun 11 13:33:44 2010 +0300 @@ -1,19 +1,3 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ package com.nokia.mj.impl.uitestutils; /** diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/Matrix.java --- a/javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/Matrix.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/Matrix.java Fri Jun 11 13:33:44 2010 +0300 @@ -1,19 +1,3 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ package com.nokia.mj.impl.uitestutils; /** diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/Modifier.java --- a/javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/Modifier.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/Modifier.java Fri Jun 11 13:33:44 2010 +0300 @@ -1,19 +1,3 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ package com.nokia.mj.impl.uitestutils; public final class Modifier { diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/Point.java --- a/javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/Point.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/Point.java Fri Jun 11 13:33:44 2010 +0300 @@ -1,19 +1,3 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ package com.nokia.mj.impl.uitestutils; diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/Rect.java --- a/javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/Rect.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/Rect.java Fri Jun 11 13:33:44 2010 +0300 @@ -1,19 +1,3 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ package com.nokia.mj.impl.uitestutils; /** diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/RuntimeUtils.java --- a/javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/RuntimeUtils.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/RuntimeUtils.java Fri Jun 11 13:33:44 2010 +0300 @@ -1,19 +1,3 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ package com.nokia.mj.impl.uitestutils; public class RuntimeUtils { diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/UITestUtils.java --- a/javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/UITestUtils.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/UITestUtils.java Fri Jun 11 13:33:44 2010 +0300 @@ -1,19 +1,3 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ package com.nokia.mj.impl.uitestutils; /** diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/XlibKeys.java --- a/javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/XlibKeys.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/XlibKeys.java Fri Jun 11 13:33:44 2010 +0300 @@ -1,19 +1,3 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ package com.nokia.mj.impl.uitestutils; final class XlibKeys { diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/XlibUtils.java --- a/javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/XlibUtils.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/xlibutils/java/src/com/nokia/mj/impl/uitestutils/XlibUtils.java Fri Jun 11 13:33:44 2010 +0300 @@ -1,19 +1,3 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ package com.nokia.mj.impl.uitestutils; import org.eclipse.swt.internal.Library; diff -r dc7c549001d5 -r 85266cc22c7f javauis/eswt_qt/xlibutils/native/os.cpp --- a/javauis/eswt_qt/xlibutils/native/os.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javauis/eswt_qt/xlibutils/native/os.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -1,19 +1,3 @@ -/* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ // Description: Testing utility for emulating pointer/key input events in X. #include diff -r dc7c549001d5 -r 85266cc22c7f javauis/javalegacyutils/javasrc/com/nokia/mj/impl/rt/legacy/ToolkitInvoker.java --- a/javauis/javalegacyutils/javasrc/com/nokia/mj/impl/rt/legacy/ToolkitInvoker.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/javalegacyutils/javasrc/com/nokia/mj/impl/rt/legacy/ToolkitInvoker.java Fri Jun 11 13:33:44 2010 +0300 @@ -88,6 +88,15 @@ */ public abstract boolean isNgaEnabled(); + + /** + * NGA specific change. + * LCDUI's client APIs (e.g M3G) can check are they on foreground or not. + * @return true if MIDlet is on foreground. + * @since S60 9.2 + */ + public abstract boolean isForeground(); + // // Image access // diff -r dc7c549001d5 -r 85266cc22c7f javauis/javalegacyutils/javasrc/com/nokia/mj/impl/rt/legacy/ToolkitObserverNGAExtension.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/javalegacyutils/javasrc/com/nokia/mj/impl/rt/legacy/ToolkitObserverNGAExtension.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,29 @@ +/* +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package com.nokia.mj.impl.rt.legacy; + +public interface ToolkitObserverNGAExtension extends ToolkitObserver +{ + /** + * Notification about MIDlet going to background or coming foreground. + * @param foreground true, when MIDlet came to foreground + * false, when MIDlet was sent to background + */ + void foregroundEvent(boolean foreground); +} \ No newline at end of file diff -r dc7c549001d5 -r 85266cc22c7f javauis/javauis.pro --- a/javauis/javauis.pro Thu May 27 12:49:31 2010 +0300 +++ b/javauis/javauis.pro Fri Jun 11 13:33:44 2010 +0300 @@ -14,12 +14,14 @@ # Description: Generated file - do not edit manually # TEMPLATE = subdirs -SUBDIRS += eswt_qt/build/eswtqt.pro +SUBDIRS += nokiasound/build/javanokiasound.pro +SUBDIRS += eswt_qt/build SUBDIRS += lcdui_qt/build/openlcdui.pro SUBDIRS += runtimeui_qt/build/javaruntimeui.pro SUBDIRS += nokiauiapi_qt/build/nokiauiapiqt.pro SUBDIRS += mmapi_qt/build/javamobilemedia.pro SUBDIRS += amms_qt/build/javaamms.pro +SUBDIRS += m3g_qt/build/javam3g.pro SUBDIRS += javalegacyutils BLD_INF_RULES.prj_extensions += "$${LITERAL_HASH}include \"coreui/build/bld.inf\"" BLD_INF_RULES.prj_extensions += "prj_extensions" diff -r dc7c549001d5 -r 85266cc22c7f javauis/lcdui_qt/src/com/nokia/mj/impl/nokialcdui/LCDUIInvoker.java --- a/javauis/lcdui_qt/src/com/nokia/mj/impl/nokialcdui/LCDUIInvoker.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/lcdui_qt/src/com/nokia/mj/impl/nokialcdui/LCDUIInvoker.java Fri Jun 11 13:33:44 2010 +0300 @@ -94,6 +94,16 @@ } /** + * Returns the WindowSurface where g will be drawing. + * @param g The graphics object + * @return WindowSurface where g will be drawing. + */ + public static org.eclipse.swt.internal.qt.graphics.WindowSurface getWindowSurface(Graphics g) + { + return invokerInstance.doGetWindowSurface(g); + } + + /** * Creates LCDUI Image from an eSWT Image. The returned object is a new * LCDUI Image object created from the eSWT Image, so this method is not * as efficient as getEswtImage. @@ -202,6 +212,47 @@ } /** + * Synchronizes any pending buffered draw commands to the target of the + * graphics object. + * + * Must be called from UI-thread. + * + * @param graphics The object to synchronize + */ + public static void sync(Object graphics) + { + invokerInstance.doSync(graphics); + } + + /** + * Begins an external renderer session to given Graphics. An external renderer + * could be, for example, M3G renderer. The opened rendering session must be + * ended by calling the endExternalRendering(). + * + * This function must be called from UI-thread only. + * + * @param g Graphics where the rendering session starts. + */ + public static void startExternalRendering(Graphics g) + { + invokerInstance.doStartExternalRendering(g); + } + + /** + * Ends the external rendering session on given Graphics that was started + * by calling startExternalRendering(). + * + * This function must be called from UI-thread only. + * + * @param g The Graphics instance. + */ + public static void endExternalRendering(Graphics g) + { + invokerInstance.doEndExternalRendering(g); + } + + + /** * Returns the dynamic property value. * * @param key property key @@ -240,6 +291,8 @@ protected abstract void doSetItemControlStateChangeListener(ItemControlStateChangeListener listener,Item item); + protected abstract org.eclipse.swt.internal.qt.graphics.WindowSurface doGetWindowSurface( Graphics g ); + // DirectGraphics support protected abstract DirectGraphics doGetDirectGraphics(Graphics g); @@ -264,6 +317,12 @@ protected abstract void doFlushGraphics(Object canvas, int x, int y, int width, int height); + protected abstract void doSync(Object graphics); + + protected abstract void doStartExternalRendering(Graphics g); + + protected abstract void doEndExternalRendering(Graphics g); + protected abstract String doGetDynamicProperty(String key); protected abstract boolean doDetectCollision(Image image1, int transform1, int p1x, int p1y, diff -r dc7c549001d5 -r 85266cc22c7f javauis/lcdui_qt/src/javax/microedition/lcdui/Buffer.java --- a/javauis/lcdui_qt/src/javax/microedition/lcdui/Buffer.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/Buffer.java Fri Jun 11 13:33:44 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009,2010 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -14,11 +14,14 @@ * Description: * */ + package javax.microedition.lcdui; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Widget; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.internal.qt.OS; import org.eclipse.swt.internal.qt.graphics.GraphicsContext; import org.eclipse.swt.internal.qt.graphics.JavaCommandBuffer; import org.eclipse.swt.internal.qt.graphics.WindowSurface; @@ -40,6 +43,13 @@ abstract class Buffer { + // Default values for Graphics + final static Font defaultFont = Font.getDefaultFont(); + final static int defaultColor = 0xff000000; + final static int defaultStrokeStyle = Graphics.SOLID; + final static int defaultTranslateX = 0; + final static int defaultTranslateY = 0; + // Constants for buffer host types final static int HOST_TYPE_IMAGE = 1; final static int HOST_TYPE_CANVAS = 2; @@ -68,12 +78,10 @@ private JavaCommandBuffer commandBuffer; private Rectangle hostBounds; private Graphics currentClient; - private boolean started; + private boolean isInitialized; private int clientCount; - - // The target window surface where this - // instance flushes draw primitives - WindowSurface windowSurface; + + private boolean isSurfaceSessionOpen; /** * Constructor @@ -90,16 +98,57 @@ } /** + * Creates Buffer instance based on the type of given host object + * and the platform (symbian/linux) currently running on. + * + * @param host The host target where pixels are drawn. Given object must be Canvas, CustomItem or Image. + * @param control The eSWT control associated with the target, or null if the host is Image + * @return New buffer instance + */ + static Buffer createInstance(Object host, Control control) + { + if(host instanceof Canvas) + { + if(OS.windowServer == OS.WS_SYMBIAN_S60) + { + return new CanvasBufferSymbian((Canvas) host, control); + } + else if(OS.windowServer == OS.WS_X11) + { + return new CanvasBufferLinux((Canvas) host, control); + } + return null; + } + else if(host instanceof CustomItem) + { + if(OS.windowServer == OS.WS_SYMBIAN_S60) + { + return new CustomItemBufferSymbian((CustomItem) host, control); + } + else if(OS.windowServer == OS.WS_X11) + { + return new CustomItemBufferLinux((CustomItem) host, control); + } + return null; + } + else if(host instanceof Image) + { + return new ImageBuffer((Image) host); + } + return null; + } + + /** * Initializes data, called once */ - void init() + protected void init() { clientCount = 0; gc = new GraphicsContext(); commandBuffer = new JavaCommandBuffer(); gc.bindTarget(commandBuffer); writeControlBoundsToBuffer(false); - started = true; + isInitialized = true; } /** @@ -113,86 +162,182 @@ */ void setControlBounds(final Control control) { - ESWTUIThreadRunner.safeSyncExec(new Runnable() - { - public void run() - { - // This implementation is based on the fact that - // the QWindowSurface has the size of the shell active area - // not the whole display, thus Shell clientArea equals QWindowSurface. - // This might change in future if/when Qt starts - // rendering e.g. the status pane i.e. the whole display - // to window surface - Point controlLoc = control.toDisplay(0,0); - Point shellLoc = control.getShell().toDisplay(0,0); - hostBounds.x = controlLoc.x - shellLoc.x; - hostBounds.y = controlLoc.y - shellLoc.y; - hostBounds.width = control.getBounds().width; - hostBounds.height = control.getBounds().height; - } - }); + // This implementation is based on the fact that + // the QWindowSurface has the size of the shell active area + // not the whole display, thus Shell clientArea equals QWindowSurface. + // This might change in future if/when Qt starts + // rendering e.g. the status pane i.e. the whole display + // to window surface + Point controlLoc = control.toDisplay(0,0); + Point shellLoc = control.getShell().toDisplay(0,0); + hostBounds.x = controlLoc.x - shellLoc.x; + hostBounds.y = controlLoc.y - shellLoc.y; + hostBounds.width = control.getBounds().width; + hostBounds.height = control.getBounds().height; } /** - * Performs binding to target in host specific way + * Prepares surface for a new frame and starts paint session. + * Must be called in UI thread (sync calls this automatically) + * and at the start of new frame. The rectangle provided as + * arguments are in control coordinates. + * + * @param x The x-coordinate of the area to be painted + * @param y The y-coordinate of the area to be painted + * @param w The width of the area to be painted + * @param h The height of the area to be painted + */ + void startFrame(int x, int y, int w, int h) + { + if(!isSurfaceSessionOpen) + { + beginPaint(x, y, w, h); + isSurfaceSessionOpen = true; + } + } + + /** + * Ends frame painting session. Must be called in UI thread and + * at the end of the frame. BlitToDisplay calls this automatically. + */ + void endFrame() + { + if(isSurfaceSessionOpen) + { + endPaint(); + isSurfaceSessionOpen = false; + } + } + + /** + * Transfers the result of rendering to display. + * @param gc The graphics context used for blit, may be null in some cases + * @param widget The widget that is the target + */ + void blitToDisplay(GraphicsContext gc, Widget widget) + { + endFrame(); + blit(gc, widget); + } + + /** + * Prepares surface for painting, implemented by + * child implementation. + * @param x The x-coordinate of the area to be painted + * @param y The y-coordinate of the area to be painted + * @param w The width of the area to be painted + * @param h The height of the area to be painted + */ + abstract void beginPaint(int x, int y, int w, int h); + + /** + * Ends frame painting session. Must be called in UI thread and + * at the end of the frame. Implemented by + * child implementation. + */ + abstract void endPaint(); + + /** + * Performs binding to target in host specific way. Implemented by + * child implementation. */ abstract void bindToHost(GraphicsContext gc); - + + /** + * Performs the actual blit operation in child class implementation. + * @param gc The graphics context used for blit, may be null in some cases + * @param widget The widget that is the target + */ + abstract void blit(GraphicsContext gc, Widget widget); + /** - * Getter for the host of the buffer + * Getter for the host of the buffer, implemented by + * child implementation. * @return The host */ abstract Object getHost(); /** - * Getter for the host type + * Getter for the host type,implemented by + * child implementation. * @return One of host types defined in this class */ abstract int getHostType(); /** - * Setups the window surface if not setup already. - * This method must be called before flushing buffer to - * window surface - * Note. must be called in UI thread + * Status checker that indicates if this instance has requested a synchronous paint event, + * implemented by child implementation. + * @return True if this instance has requested a redraw paint event, otherwise false */ - abstract void setupWindowSurface(); - + abstract boolean isPaintingActive(); + /** * Creates and returns new Graphics instance * @return new Graphics instance */ Graphics getGraphics() { - if(!started) + if(!isInitialized) { init(); } clientCount++; - return new Graphics(this); + // In case this is the first Graphics instance + // write the default values to the buffer + if(clientCount == 1) + { + writeDefaultValuesToBuffer(); + } + return new Graphics(this, hostBounds ); } /** * Synchronizes this buffer with the actual target * must be called in UI thread. If no Graphics instances - * are creates, sync has no effect + * are created, sync has no effect. This variant always closes + * the surface session unconditionally */ - void sync() + void sync() { - if(!started) + sync(true); + } + + /** + * Synchronizes this buffer with the actual target + * must be called in UI thread. If no Graphics instances + * are created, sync has no effect + * + * @param closeSurfaceSession If true the endFrame is called after sync has been + * performed closing the surface session, otherwise + * endFrame is performed and surface session is left open + */ + void sync(boolean closeSurfaceSession) + { + if(!isInitialized) { return; } + // if there's nothing to flush return if(!commandBuffer.containsDrawnPrimitives()) { return; } + + // Start surface session if not started yet + startFrame(hostBounds.x, hostBounds.y , hostBounds.width , hostBounds.height); + doRelease(); bindToHost(gc); gc.render(commandBuffer); doRelease(); + // Close surface session + if(closeSurfaceSession) + { + endFrame(); + } + // Reset commands commandBuffer.reset(); @@ -220,9 +365,12 @@ */ void dispose() { - doRelease(); - gc.dispose(); - gc = null; + if(gc != null) + { + doRelease(); + gc.dispose(); + gc = null; + } commandBuffer = null; } @@ -501,6 +649,16 @@ /** + * Returns the WindowSurface that relates to this Buffer + * + * @return WindowSurface owned by this Buffer + */ + WindowSurface getWindowSurface() + { + return null; + } + + /** * Translates given rectangle to display/window surface coordinates * and outlines the clip inside the control bounds. * @@ -607,10 +765,10 @@ } if((STROKESTYLE & flags) != 0) { - if(bufferStrokeStyle != client.currentStrokeSyle) + if(bufferStrokeStyle != client.currentStrokeStyle) { - gc.setStrokeStyle(Graphics.mapStrokeStyle(client.currentStrokeSyle)); - bufferStrokeStyle = client.currentStrokeSyle; + gc.setStrokeStyle(Graphics.mapStrokeStyle(client.currentStrokeStyle)); + bufferStrokeStyle = client.currentStrokeStyle; } } } @@ -655,6 +813,24 @@ } } + /** + * Writes Graphics default values to buffer + */ + private void writeDefaultValuesToBuffer() + { + int handle = Font.getESWTFont(defaultFont).handle; + gc.setFont(handle); + bufferFontHandle = handle; + gc.setBackgroundColor(defaultColor, true); + gc.setForegroundColor(defaultColor, true); + bufferColor = defaultColor; + gc.setStrokeStyle(Graphics.mapStrokeStyle(defaultStrokeStyle)); + bufferStrokeStyle = defaultStrokeStyle; + gc.resetTransform(); + bufferTranslateX = defaultTranslateX; + bufferTranslateY = defaultTranslateY; + } + private void doRelease() { gc.releaseTarget(); diff -r dc7c549001d5 -r 85266cc22c7f javauis/lcdui_qt/src/javax/microedition/lcdui/Canvas.java --- a/javauis/lcdui_qt/src/javax/microedition/lcdui/Canvas.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/Canvas.java Fri Jun 11 13:33:44 2010 +0300 @@ -158,8 +158,12 @@ // Canvas Graphics object passed to paint(Graphics g) private Graphics canvasGraphics; + // Graphics object for transferring return values + // from UI thread + private Graphics tempGraphics; + // Graphics command buffer for this instance - CanvasBuffer graphicsBuffer; + Buffer graphicsBuffer; //On Screen Keypad //private Composite keypadComposite; @@ -209,7 +213,6 @@ cleanupLock = new Object(); construct(); keysPressed = new Vector(); - graphicsBuffer = new CanvasBuffer(this, getContentComp()); } /* (non-Javadoc) @@ -301,6 +304,8 @@ onScreenkeypad = new CanvasKeypad(this, canvasComp, oskAttr); } + // create graphics buffer + graphicsBuffer = Buffer.createInstance(this, canvasComp); return canvasComp; } @@ -622,7 +627,15 @@ */ final Graphics getGameBufferGraphics() { - return graphicsBuffer.getGraphics(); + tempGraphics = null; + ESWTUIThreadRunner.safeSyncExec(new Runnable() + { + public void run() + { + tempGraphics = graphicsBuffer.getGraphics(); + } + }); + return tempGraphics; } CanvasKeypad getCanvasKeypad() @@ -666,11 +679,18 @@ void flushGameBuffer(final int x, final int y, final int width, final int height) { - synchronized(graphicsBuffer) + synchronized(graphicsBuffer) { - flushGraphicsBuffer(x, y, width, height); + ESWTUIThreadRunner.safeSyncExec(new Runnable() + { + public void run() + { + graphicsBuffer.sync(); + graphicsBuffer.blitToDisplay(null, getContentComp()); + } + }); } - } + } /** * Called by ShellListener when shell gets activated. @@ -708,10 +728,9 @@ { super.eswtHandleResizeEvent(width, height); // update new bounds to graphicsBuffer - synchronized(graphicsBuffer) - { - graphicsBuffer.setControlBounds(getContentComp()); - } + // this call must not be synchronized as we + // cannot use locking in UI thread + graphicsBuffer.setControlBounds(getContentComp()); synchronized(cleanupLock) { cleanupNeeded = true; @@ -739,26 +758,33 @@ */ class CanvasShellPaintListener implements PaintListener { - public void paintControl(PaintEvent pe) { - // Native toolkit is requesting an update of an area that has - // become invalid. Can't do anything here because the contents - // need to be queried from the MIDlet in another thread by - // a paint callback. For this a paint callback event is posted. - // For a moment the native toolkit thinks that the area has - // been validated when in truth it will be painted later after - // the paint callback has been executed. - EventDispatcher eventDispatcher = EventDispatcher.instance(); - LCDUIEvent event = eventDispatcher.newEvent( - LCDUIEvent.CANVAS_PAINT_NATIVE_REQUEST, - javax.microedition.lcdui.Canvas.this); - event.x = pe.x; - event.y = pe.y; - event.width = pe.width; - event.height = pe.height; - event.widget = pe.widget; - eventDispatcher.postEvent(event); + // Check if we got here from buffer flush + if(graphicsBuffer.isPaintingActive()) + { + graphicsBuffer.blitToDisplay(pe.gc.getGCData().internalGc, null); + } + else + { + // Native toolkit is requesting an update of an area that has + // become invalid. Can't do anything here because the contents + // need to be queried from the MIDlet in another thread by + // a paint callback. For this a paint callback event is posted. + // For a moment the native toolkit thinks that the area has + // been validated when in truth it will be painted later after + // the paint callback has been executed. + EventDispatcher eventDispatcher = EventDispatcher.instance(); + LCDUIEvent event = eventDispatcher.newEvent( + LCDUIEvent.CANVAS_PAINT_NATIVE_REQUEST, + javax.microedition.lcdui.Canvas.this); + event.x = pe.x; + event.y = pe.y; + event.width = pe.width; + event.height = pe.height; + event.widget = pe.widget; + eventDispatcher.postEvent(event); + } } } @@ -851,7 +877,14 @@ // Create instance of Graphics if not created yet if(canvasGraphics == null) { - canvasGraphics = graphicsBuffer.getGraphics(); + ESWTUIThreadRunner.safeSyncExec(new Runnable() + { + public void run() + { + canvasGraphics = graphicsBuffer.getGraphics(); + canvasGraphics.setSyncStrategy(Graphics.SYNC_LEAVE_SURFACE_SESSION_OPEN); + } + }); } // Clean the background if dirty, buffer the operations. @@ -877,29 +910,22 @@ // The callback paint(canvasGraphics); - - // Flush drawn graphics to display - synchronized(graphicsBuffer) - { - flushGraphicsBuffer(redrawNowX, redrawNowY, redrawNowW, redrawNowH); - } - } - - private void flushGraphicsBuffer(final int redrawNowX, final int redrawNowY, final int redrawNowW, final int redrawNowH) - { - ESWTUIThreadRunner.safeSyncExec(new Runnable() + // Blit frame to display + synchronized(graphicsBuffer) { - public void run() + ESWTUIThreadRunner.safeSyncExec(new Runnable() { - graphicsBuffer.setupWindowSurface(); - Rectangle rect = graphicsBuffer.toWindowCoordinates(redrawNowX, redrawNowY, redrawNowW, redrawNowH); - graphicsBuffer.windowSurface.beginPaint(rect.x, rect.y, rect.width, rect.height); - graphicsBuffer.sync(); - graphicsBuffer.windowSurface.endPaint(); - graphicsBuffer.windowSurface.flush(); - } - - }); + public void run() + { + if(event.widget.isDisposed()) + { + return; + } + graphicsBuffer.sync(); + graphicsBuffer.blitToDisplay(null, event.widget); + } + }); + } } /* diff -r dc7c549001d5 -r 85266cc22c7f javauis/lcdui_qt/src/javax/microedition/lcdui/CanvasBuffer.java --- a/javauis/lcdui_qt/src/javax/microedition/lcdui/CanvasBuffer.java Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -/* -* Copyright (c) 2009,2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -package javax.microedition.lcdui; - -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.internal.qt.graphics.GraphicsContext; -import org.eclipse.swt.widgets.Internal_PackageSupport; - -final class CanvasBuffer extends Buffer -{ - - private Canvas host; - - CanvasBuffer(Canvas canvas, Control ctrl) - { - super(); - setControlBounds(ctrl); - host = canvas; - } - - int getHostType() - { - return HOST_TYPE_CANVAS; - } - - void setupWindowSurface() - { - if(super.windowSurface == null) - { - super.windowSurface = Internal_PackageSupport.getWindowsurface(host.getShell()); - } - } - - Object getHost() - { - return host; - } - - void bindToHost(GraphicsContext gc) - { - gc.bindTarget(super.windowSurface); - } -} diff -r dc7c549001d5 -r 85266cc22c7f javauis/lcdui_qt/src/javax/microedition/lcdui/CanvasBufferLinux.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/CanvasBufferLinux.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,113 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package javax.microedition.lcdui; + +import org.eclipse.swt.internal.extension.CompositeExtension; +import org.eclipse.swt.internal.qt.graphics.GraphicsContext; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Internal_PackageSupport; +import org.eclipse.swt.widgets.Widget; +import org.eclipse.swt.internal.qt.graphics.WindowSurface; + + +final class CanvasBufferLinux extends Buffer { + + private Canvas host; + private WindowSurface surface; + private boolean syncPaintCallback; + private int paintX, paintY; + private int paintW, paintH; + + CanvasBufferLinux(Canvas canvas, Control ctrl) + { + super(); + setControlBounds(ctrl); + host = canvas; + } + + protected void init() + { + super.init(); + surface = Internal_PackageSupport.getWindowsurface(host.getShell()); + } + + void bindToHost(GraphicsContext gc) + { + gc.bindTarget(surface); + } + + void beginPaint(int x, int y, int w, int h) + { + paintX = x; + paintY = y; + paintW = w; + paintH = h; + surface.beginPaint(paintX, paintY, paintW, paintH); + } + + void endPaint() + { + // nothing to do + } + + void blit(GraphicsContext gc, Widget widget) + { + // On linux platform this method is called in order to + // request new paint event and also from the actual paint event itself to blit the + // frame to display. + // The behavior of this method depends on the syncpaintCallback flag, which + // indicates on which above scenario we are in each time. + + // If we are within the paint callback + // draw the window surface to display + if(syncPaintCallback) + { + gc.drawWindowSurface(surface, paintX, paintX, paintW, paintH); + } + else + { + // We are requesting a paint event + syncPaintCallback = true; + ((CompositeExtension)widget).redrawNow(paintX, paintY, paintW, paintH); + syncPaintCallback = false; + + // Once the display has been updated, + // clear the invalidate area + paintX = paintY = paintW = paintH = 0; + } + } + + Object getHost() + { + return host; + } + + int getHostType() + { + return HOST_TYPE_CANVAS; + } + + boolean isPaintingActive() { + return syncPaintCallback; + } + + WindowSurface getWindowSurface() + { + return surface; + } +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/lcdui_qt/src/javax/microedition/lcdui/CanvasBufferSymbian.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/CanvasBufferSymbian.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,87 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +package javax.microedition.lcdui; + +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Widget; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.internal.qt.graphics.GraphicsContext; +import org.eclipse.swt.widgets.Internal_PackageSupport; +import org.eclipse.swt.internal.qt.graphics.WindowSurface; + +final class CanvasBufferSymbian extends Buffer +{ + private Canvas host; + private WindowSurface surface; + + CanvasBufferSymbian(Canvas canvas, Control ctrl) + { + super(); + setControlBounds(ctrl); + host = canvas; + } + + void ensureWindowSurface() + { + if(surface == null) + { + surface = Internal_PackageSupport.getWindowsurface(host.getShell()); + } + } + + void beginPaint(int x, int y, int w, int h) { + ensureWindowSurface(); + Rectangle rect = toWindowCoordinates(x, y, w, h); + surface.beginPaint(rect.x, rect.y, rect.width, rect.height); + } + + void endPaint() { + surface.endPaint(); + } + + void blit(GraphicsContext gc, Widget widget) + { + if( surface != null ) + { + surface.flush(); + } + } + + int getHostType() + { + return HOST_TYPE_CANVAS; + } + + Object getHost() + { + return host; + } + + void bindToHost(GraphicsContext gc) + { + gc.bindTarget(surface); + } + + boolean isPaintingActive() { + return false; + } + + WindowSurface getWindowSurface() + { + return surface; + } +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/lcdui_qt/src/javax/microedition/lcdui/CustomItem.java --- a/javauis/lcdui_qt/src/javax/microedition/lcdui/CustomItem.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/CustomItem.java Fri Jun 11 13:33:44 2010 +0300 @@ -67,7 +67,7 @@ private com.nokia.mj.impl.rt.support.Finalizer finalizer; // Graphics command buffer for this instance - CustomItemBuffer graphicsBuffer; + Buffer graphicsBuffer; Graphics CustomItemGraphics; CustomItemLayouter layouter; @@ -552,8 +552,9 @@ } if(CustomItemGraphics == null) { - graphicsBuffer = new CustomItemBuffer(self, (Control)event.widget); + graphicsBuffer = Buffer.createInstance(self, (Control)event.widget); CustomItemGraphics = graphicsBuffer.getGraphics(); + CustomItemGraphics.setSyncStrategy(Graphics.SYNC_LEAVE_SURFACE_SESSION_OPEN); } else { @@ -604,31 +605,8 @@ { return; } - // Transform invalid area to Display coordinates - // as the CustomItem is rendered directly to the - // window surface - Point topleft = ((Control)event.widget).toDisplay(redrawNowX, redrawNowY); - - synchronized(graphicsBuffer) - { - flushGraphicsBuffer(topleft.x, topleft.y, redrawNowW, redrawNowH); - } - } - }); - } - - private void flushGraphicsBuffer(final int redrawNowX, final int redrawNowY, final int redrawNowW, final int redrawNowH) - { - ESWTUIThreadRunner.safeSyncExec(new Runnable() - { - public void run() - { - graphicsBuffer.setupWindowSurface(); - Rectangle rect = graphicsBuffer.toWindowCoordinates(redrawNowX, redrawNowY, redrawNowW, redrawNowH); - graphicsBuffer.windowSurface.beginPaint(rect.x, rect.y, rect.width, rect.height); graphicsBuffer.sync(); - graphicsBuffer.windowSurface.endPaint(); - graphicsBuffer.windowSurface.flush(); + graphicsBuffer.blitToDisplay(null, event.widget); } }); } diff -r dc7c549001d5 -r 85266cc22c7f javauis/lcdui_qt/src/javax/microedition/lcdui/CustomItemBuffer.java --- a/javauis/lcdui_qt/src/javax/microedition/lcdui/CustomItemBuffer.java Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* -* Copyright (c) 2009,2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ -package javax.microedition.lcdui; - -import org.eclipse.swt.graphics.Rectangle; -import org.eclipse.swt.internal.qt.graphics.GraphicsContext; -import org.eclipse.swt.widgets.Control; - -final class CustomItemBuffer extends Buffer -{ - - private CustomItem host; - - CustomItemBuffer(CustomItem customItem, Control ctrl) - { - super(); - setControlBounds(ctrl); - host = customItem; - } - - int getHostType() - { - return HOST_TYPE_CUSTOMITEM; - } - - void setupWindowSurface() - { - throw new IllegalStateException("not impl yet"); - // TODO Auto-generated method stub - - } - - Object getHost() - { - return host; - } - - void bindToHost(GraphicsContext gc) - { - gc.bindTarget(super.windowSurface); - } - -} diff -r dc7c549001d5 -r 85266cc22c7f javauis/lcdui_qt/src/javax/microedition/lcdui/CustomItemBufferLinux.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/CustomItemBufferLinux.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,107 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package javax.microedition.lcdui; + +import org.eclipse.swt.internal.extension.CanvasExtension; +import org.eclipse.swt.internal.qt.graphics.GraphicsContext; +import org.eclipse.swt.internal.qt.graphics.WindowSurface; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Internal_PackageSupport; +import org.eclipse.swt.widgets.Widget; + + +final class CustomItemBufferLinux extends Buffer { + + private CustomItem host; + private WindowSurface surface; + private boolean syncPaintCallback; + private int paintX, paintY; + private int paintW, paintH; + + CustomItemBufferLinux(CustomItem customItem, Control ctrl) + { + super(); + setControlBounds(ctrl); + host = customItem; + } + + protected void init() + { + super.init(); + surface = Internal_PackageSupport.getWindowsurface(host.layouter.dfi.getForm().getContentComp().getShell()); + } + + void bindToHost(GraphicsContext gc) { + gc.bindTarget(surface); + } + + void blit(GraphicsContext gc, Widget widget) { + // On linux platform this method is called in order to + // request new paint event and also from the actual paint event itself to blit the + // frame to display. + // The behavior of this method depends on the syncpaintCallback flag, which + // indicates on which above scenario we are in each time. + + // If we are within the paint callback + // draw the window surface to display + if(syncPaintCallback) + { + gc.drawWindowSurface(surface, paintX, paintX, paintW, paintH); + } + else + { + // We are requesting a paint event + syncPaintCallback = true; + ((CanvasExtension)widget).redrawNow(paintX, paintY, paintW, paintH); + syncPaintCallback = false; + + // Once the display has been updated, + // clear the invalidate area + paintX = paintY = paintW = paintH = 0; + } + } + + void endPaint() { + // nothing to do + } + + Object getHost() { + return host; + } + + int getHostType() { + return Buffer.HOST_TYPE_CUSTOMITEM; + } + + void beginPaint(int x, int y, int w, int h) { + paintX = x; + paintY = y; + paintW = w; + paintH = h; + surface.beginPaint(paintX, paintY, paintW, paintH); + } + + boolean isPaintingActive() { + return syncPaintCallback; + } + + WindowSurface getWindowSurface() + { + return surface; + } +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/lcdui_qt/src/javax/microedition/lcdui/CustomItemBufferSymbian.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/CustomItemBufferSymbian.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,81 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package javax.microedition.lcdui; + +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.internal.qt.graphics.GraphicsContext; +import org.eclipse.swt.internal.qt.graphics.WindowSurface; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Internal_PackageSupport; +import org.eclipse.swt.widgets.Widget; + +final class CustomItemBufferSymbian extends Buffer +{ + private CustomItem host; + private WindowSurface surface; + + CustomItemBufferSymbian(CustomItem customItem, Control ctrl) + { + super(); + setControlBounds(ctrl); + host = customItem; + } + + protected void init() + { + super.init(); + surface = Internal_PackageSupport.getWindowsurface(host.layouter.dfi.getForm().getContentComp().getShell()); + } + + int getHostType() + { + return HOST_TYPE_CUSTOMITEM; + } + + Object getHost() + { + return host; + } + + void bindToHost(GraphicsContext gc) + { + gc.bindTarget(surface); + } + + void blit(GraphicsContext gc, Widget widget) { + surface.flush(); + } + + void endPaint() { + surface.endPaint(); + } + + void beginPaint(int x, int y, int w, int h) { + Rectangle rect = toWindowCoordinates(x, y, w, h); + surface.beginPaint(rect.x, rect.y, rect.width, rect.height); + } + + boolean isPaintingActive() { + return false; + } + + WindowSurface getWindowSurface() + { + return surface; + } +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/lcdui_qt/src/javax/microedition/lcdui/CustomItemLayouter.java --- a/javauis/lcdui_qt/src/javax/microedition/lcdui/CustomItemLayouter.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/CustomItemLayouter.java Fri Jun 11 13:33:44 2010 +0300 @@ -423,23 +423,37 @@ public void paintControl(PaintEvent pe) { - // Native toolkit is requesting an update of an area that has - // become invalid. Can't do anything here because the contents - // need to be queried from the MIDlet in another thread by - // a paint callback. For this a paint callback event is posted. - // For a moment the native toolkit thinks that the area has - // been validated when in truth it will be painted later after - // the paint callback has been executed. - EventDispatcher eventDispatcher = EventDispatcher.instance(); - LCDUIEvent event = eventDispatcher.newEvent( - LCDUIEvent.CUSTOMITEM_PAINT_NATIVE_REQUEST, dfi.getForm()); - event.x = pe.x; - event.y = pe.y; - event.width = pe.width; - event.height = pe.height; - event.widget = pe.widget; - event.item = customItem; - eventDispatcher.postEvent(event); + // graphicsBuffer may be null when control + // is brought to foreground the first time + if(customItem.graphicsBuffer != null) + { + // If we have initiated a synchronous paint event + // draw the buffer to display here + if(customItem.graphicsBuffer.isPaintingActive()) + { + customItem.graphicsBuffer.blitToDisplay(pe.gc.getGCData().internalGc, null); + } + } + else + { + // Native toolkit is requesting an update of an area that has + // become invalid. Can't do anything here because the contents + // need to be queried from the MIDlet in another thread by + // a paint callback. For this a paint callback event is posted. + // For a moment the native toolkit thinks that the area has + // been validated when in truth it will be painted later after + // the paint callback has been executed. + EventDispatcher eventDispatcher = EventDispatcher.instance(); + LCDUIEvent event = eventDispatcher.newEvent( + LCDUIEvent.CUSTOMITEM_PAINT_NATIVE_REQUEST, dfi.getForm()); + event.x = pe.x; + event.y = pe.y; + event.width = pe.width; + event.height = pe.height; + event.widget = pe.widget; + event.item = customItem; + eventDispatcher.postEvent(event); + } } } diff -r dc7c549001d5 -r 85266cc22c7f javauis/lcdui_qt/src/javax/microedition/lcdui/Font.java --- a/javauis/lcdui_qt/src/javax/microedition/lcdui/Font.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/Font.java Fri Jun 11 13:33:44 2010 +0300 @@ -459,7 +459,14 @@ */ public int charsWidth(char[] c, int offset, int length) { - return stringWidth(new String(c, offset, length)); + try + { + final String string = new String(c, offset, length); + return stringWidth(string); + }catch (StringIndexOutOfBoundsException ex) + { + throw new ArrayIndexOutOfBoundsException(); + } } /** diff -r dc7c549001d5 -r 85266cc22c7f javauis/lcdui_qt/src/javax/microedition/lcdui/Form.java --- a/javauis/lcdui_qt/src/javax/microedition/lcdui/Form.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/Form.java Fri Jun 11 13:33:44 2010 +0300 @@ -250,7 +250,7 @@ throw new IllegalStateException( MsgRepository.FORM_EXCEPTION_ITEM_OWNED_BY_CONTAINER); } - if((position < 0) || (position > (items.size() - 1))) + if ((position < 0) || (position > items.size() )) { throw new IndexOutOfBoundsException( MsgRepository.FORM_EXCEPTION_INVALID_ITEM_INDEX); diff -r dc7c549001d5 -r 85266cc22c7f javauis/lcdui_qt/src/javax/microedition/lcdui/Graphics.java --- a/javauis/lcdui_qt/src/javax/microedition/lcdui/Graphics.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/Graphics.java Fri Jun 11 13:33:44 2010 +0300 @@ -84,28 +84,30 @@ static final int COMPONENT_MASK = 0xFF; + /** + * Constants for sync strategy + */ + static final int SYNC_LEAVE_SURFACE_SESSION_CLOSED = 10; + static final int SYNC_LEAVE_SURFACE_SESSION_OPEN = 11; + + // Set default sync strategy as closed + private int syncStrategy = SYNC_LEAVE_SURFACE_SESSION_CLOSED; + private DirectGraphics directGraphics; private Buffer graphicsBuffer; - // Off-screen buffer. - //private org.eclipse.swt.internal.qt.graphics.Image frameBuffer; - // Current font for rendering texts. Font currentFont; int currentColor; int translateX; int translateY; int[] currentClip = new int[4]; - int currentStrokeSyle; + int currentStrokeStyle; private com.nokia.mj.impl.rt.support.Finalizer finalizer; - // serialization lock for command buffering and flush - private final Object flushLock = new Object(); - private Canvas canvasParent; - private CustomItem customItemParent; //Constructor - Graphics(Buffer buffer) + Graphics(Buffer buffer, Rectangle clipRect) { finalizer = ((finalizer != null) ? finalizer : new com.nokia.mj.impl.rt.support.Finalizer() @@ -129,6 +131,10 @@ } } }); + currentClip[0] = clipRect.x; + currentClip[1] = clipRect.y; + currentClip[2] = clipRect.width; + currentClip[3] = clipRect.height; graphicsBuffer = buffer; reset(); } @@ -151,11 +157,11 @@ */ void reset() { - setColor(0, 0, 0); - setFont(Font.getDefaultFont()); - setStrokeStyle(Graphics.SOLID); - this.translateX = 0; - this.translateY = 0; + currentFont = Buffer.defaultFont; + currentColor = Buffer.defaultColor; + currentStrokeStyle = Buffer.defaultStrokeStyle; + translateX = Buffer.defaultTranslateX; + translateY = Buffer.defaultTranslateY; } /** @@ -180,7 +186,19 @@ setColor(savedColor); } - + /** + * Sets the sync strategy for this instance. + * This affects on the behavior of the sync method of this class + * which is called via LCDUIInvoker + */ + void setSyncStrategy(int strategy) + { + if((strategy != SYNC_LEAVE_SURFACE_SESSION_CLOSED) && (strategy != SYNC_LEAVE_SURFACE_SESSION_OPEN)) + { + throw new IllegalArgumentException("Internal: Invalid strategy value"); + } + syncStrategy = strategy; + } /** * Sets coordinate translation. Translations are cumulative. @@ -855,8 +873,22 @@ synchronized(image.graphicsBuffer) { - image.sync(); - graphicsBuffer.drawImage(Internal_GfxPackageSupport.getImage(Image.getESWTImage(image)), x, y, this); + final Image localLcduiImage = image; + final org.eclipse.swt.internal.qt.graphics.Image localCgfxImage = + Internal_GfxPackageSupport.getImage(Image.getESWTImage(image)); + final int localX = x; + final int localY = y; + final Graphics self = this; + + ESWTUIThreadRunner.safeSyncExec(new Runnable() + { + public void run() + { + localLcduiImage.sync(false); + graphicsBuffer.drawImage(localCgfxImage, localX, localY, self); + } + }); + } } } @@ -910,7 +942,7 @@ */ public void setStrokeStyle(int newStyle) { - if(newStyle == currentStrokeSyle) + if(newStyle == currentStrokeStyle) { return; } @@ -923,7 +955,7 @@ MsgRepository.GRAPHICS_EXCEPTION_ILLEGAL_STROKE_STYLE); } graphicsBuffer.setStrokeStyle(styleToApply, newStyle, this); - currentStrokeSyle = newStyle; + currentStrokeStyle = newStyle; } } @@ -936,7 +968,7 @@ { synchronized(graphicsBuffer) { - return currentStrokeSyle; + return currentStrokeStyle; } } @@ -1150,14 +1182,55 @@ final int gcTransform = Image.getCgTransformValue(transform); synchronized(srcImage.graphicsBuffer) { - srcImage.sync(); - graphicsBuffer.drawImage(Internal_GfxPackageSupport.getImage(Image.getESWTImage(srcImage)), - x, y, width, height, xSrc, ySrc, width, height, gcTransform, this); + final Image localLcduiSrcImage = srcImage; + final org.eclipse.swt.internal.qt.graphics.Image localCgfxImage = + Internal_GfxPackageSupport.getImage(Image.getESWTImage(srcImage)); + final int localX = x; + final int localY = y; + final int localW = width; + final int localH = height; + final int localXSrc = xSrc; + final int localYSrc = ySrc; + final int localGcTransform = gcTransform; + final Graphics self = this; + ESWTUIThreadRunner.safeSyncExec(new Runnable() + { + public void run() + { + localLcduiSrcImage.sync(false); + graphicsBuffer.drawImage(localCgfxImage, + localX, localY, localW, localH, localXSrc, localYSrc, localW, localH, localGcTransform, self); + } + }); } } } /** + * Performs synchronization on the graphics buffer, i.e. + * the buffered draw commands are rasterized to the surface. + */ + void sync() + { + synchronized(graphicsBuffer) + { + if(syncStrategy == SYNC_LEAVE_SURFACE_SESSION_OPEN) + { + // This instance is used only with paint callbacks, thus + // sync is called with the indication that surface paint + // session can be left open as it will be closed when the + // callback returns. + graphicsBuffer.sync(false); + } + else + { + graphicsBuffer.sync(true); + } + } + } + + + /** * Return DirectGraphics associated with this instance. */ DirectGraphics getDirectGraphics() @@ -1170,6 +1243,15 @@ } /** + * Getter for graphics buffer. + * @return The Buffer. + */ + Buffer getGraphicsBuffer() + { + return graphicsBuffer; + } + + /** * Maps stroke style constant from values used by * Graphics to values defined in GraphicsContext */ diff -r dc7c549001d5 -r 85266cc22c7f javauis/lcdui_qt/src/javax/microedition/lcdui/Image.java --- a/javauis/lcdui_qt/src/javax/microedition/lcdui/Image.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/Image.java Fri Jun 11 13:33:44 2010 +0300 @@ -43,6 +43,10 @@ // buffer has package visibility so that it can be used as // a lock in other classes ImageBuffer graphicsBuffer; + + // Graphics for transferring instance + // between application and UI thread + Graphics tempGraphics; /** * Constructor. @@ -647,14 +651,33 @@ } /** - * Synchronizes any pending draw commands to this image + * Synchronizes any pending draw commands to this image. The buffer sync + * must be executed in UI thread and if this method is not requested to switch to + * UI thread, the caller must take care of serializing the call over the graphicsBuffer + * of this instance. + * + * @param switchToUIThread If true the sync is run in UI thread, oherwise + * caller must take care of switching to UI thread */ - void sync() + void sync(boolean switchToUIThread) { - synchronized(graphicsBuffer) - { - graphicsBuffer.sync(); - } + if(switchToUIThread) + { + synchronized(graphicsBuffer) + { + ESWTUIThreadRunner.safeSyncExec(new Runnable() + { + public void run() + { + graphicsBuffer.sync(); + } + }); + } + } + else + { + graphicsBuffer.sync(); + } } /** @@ -762,7 +785,6 @@ synchronized(graphicsBuffer) { - graphicsBuffer.sync(); final int[] localRgbData = rgbData; final int localOffset = offset; final int localLength = length; @@ -774,6 +796,7 @@ { public void run() { + graphicsBuffer.sync(); org.eclipse.swt.internal.qt.graphics.Image cgImage = Internal_GfxPackageSupport.getImage(eswtImage); cgImage.getRGB(localRgbData, localOffset, localLength, localX, localY, localW, localH); @@ -791,8 +814,16 @@ public Graphics getGraphics() { if(mutable) - { - return graphicsBuffer.getGraphics(); + { + tempGraphics = null; + ESWTUIThreadRunner.safeSyncExec(new Runnable() + { + public void run() + { + tempGraphics = graphicsBuffer.getGraphics(); + } + }); + return tempGraphics; } throw new IllegalStateException(MsgRepository.IMAGE_EXCEPTION_IMMUTABLE); } diff -r dc7c549001d5 -r 85266cc22c7f javauis/lcdui_qt/src/javax/microedition/lcdui/ImageBuffer.java --- a/javauis/lcdui_qt/src/javax/microedition/lcdui/ImageBuffer.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/ImageBuffer.java Fri Jun 11 13:33:44 2010 +0300 @@ -14,10 +14,12 @@ * Description: * */ + package javax.microedition.lcdui; import org.eclipse.swt.graphics.Internal_GfxPackageSupport; import org.eclipse.swt.internal.qt.graphics.GraphicsContext; +import org.eclipse.swt.widgets.Widget; final class ImageBuffer extends Buffer { @@ -34,11 +36,6 @@ return HOST_TYPE_IMAGE; } - void setupWindowSurface() - { - // nothing to do here - } - Object getHost() { return host; @@ -49,4 +46,20 @@ gc.bindTarget(Internal_GfxPackageSupport.getImage(Image.getESWTImage(host))); } + void blit(GraphicsContext gc, Widget widget) { + // nothing to do + } + + void endPaint() { + // nothing to do + } + + boolean isPaintingActive() { + return false; + } + + void beginPaint(int x, int y, int w, int h) { + // nothing to do + } + } diff -r dc7c549001d5 -r 85266cc22c7f javauis/lcdui_qt/src/javax/microedition/lcdui/LCDUIInvokerImpl.java --- a/javauis/lcdui_qt/src/javax/microedition/lcdui/LCDUIInvokerImpl.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/LCDUIInvokerImpl.java Fri Jun 11 13:33:44 2010 +0300 @@ -205,6 +205,15 @@ return ((Canvas) canvas).getGameBufferGraphics(); } + protected org.eclipse.swt.internal.qt.graphics.WindowSurface doGetWindowSurface( Graphics g ) + { + if( g != null ) + { + return g.getGraphicsBuffer().getWindowSurface(); + } + return null; + } + protected Object doGetFlushLock(Object graphics) { //return ((Graphics) graphics).graphicsBuffer; @@ -227,6 +236,26 @@ ((Canvas) canvas).flushGameBuffer(x, y, width, height); } + protected void doSync(Object graphics) + { + ((Graphics)graphics).sync(); + } + + protected void doStartExternalRendering(Graphics g) + { + // Flush any pending 2D graphics. + g.sync(); + g.getGraphicsBuffer().startFrame( g.getClipX(), + g.getClipY(), + g.getClipWidth(), + g.getClipHeight() ); + } + + protected void doEndExternalRendering(Graphics g) + { + g.getGraphicsBuffer().endFrame(); + } + protected String doGetDynamicProperty(String key) { if("com.nokia.key.scancode".equals(key)) diff -r dc7c549001d5 -r 85266cc22c7f javauis/lcdui_qt/src/javax/microedition/lcdui/List.java --- a/javauis/lcdui_qt/src/javax/microedition/lcdui/List.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/List.java Fri Jun 11 13:33:44 2010 +0300 @@ -311,7 +311,11 @@ */ public void delete(int position) { -// choiceImpl.delete(position); + if (position < 0 || ( position >= size())) + { + throw new IndexOutOfBoundsException( + MsgRepository.CHOICE_EXCEPTION_INVALID_ITEM_INDEX); + } final int index = position; // index of changed element ESWTUIThreadRunner.syncExec(new Runnable() { diff -r dc7c549001d5 -r 85266cc22c7f javauis/lcdui_qt/src/javax/microedition/lcdui/StringItem.java --- a/javauis/lcdui_qt/src/javax/microedition/lcdui/StringItem.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/StringItem.java Fri Jun 11 13:33:44 2010 +0300 @@ -82,7 +82,7 @@ */ public void setText(String newTxt) { - if((newTxt == null) || (newTxt.equals(""))) + if(newTxt == null) { text = null; } diff -r dc7c549001d5 -r 85266cc22c7f javauis/lcdui_qt/src/javax/microedition/lcdui/TextFieldLayouter.java --- a/javauis/lcdui_qt/src/javax/microedition/lcdui/TextFieldLayouter.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/TextFieldLayouter.java Fri Jun 11 13:33:44 2010 +0300 @@ -16,14 +16,13 @@ */ package javax.microedition.lcdui; -import org.eclipse.ercp.swt.mobile.ConstrainedText; import org.eclipse.ercp.swt.mobile.TextExtension; import org.eclipse.swt.SWT; import org.eclipse.swt.events.*; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; - +import org.eclipse.swt.internal.extension.TextExtensionExtension; /** * Responsible for correct layout of TextField in a Form. */ @@ -54,12 +53,6 @@ // private static Control[] staticControls = new Control[6]; - private static TextExtension any; - private static ConstrainedText numeric; - private static ConstrainedText phonenr; - private static ConstrainedText decimal; - private static TextExtension email; - private static TextExtension url; private static boolean isCorrectText; /** @@ -91,45 +84,23 @@ } */ - if(constraint == TextField.NUMERIC) - { - if(numeric == null) - { - numeric = new ConstrainedText(eswtGetStaticShell(), SWT.SINGLE, - ConstrainedText.NUMERIC); - } - ret = numeric; + if (constraint == TextField.NUMERIC) { + constraint = TextExtensionExtension.NUMERIC; } - else if(constraint == TextField.DECIMAL) - { - if(decimal == null) - { - decimal = new ConstrainedText(eswtGetStaticShell(), SWT.SINGLE, - ConstrainedText.DECIMAL); - } - ret = decimal; + else if (constraint == TextField.DECIMAL) { + constraint = TextExtensionExtension.DECIMAL; } - else if(constraint == TextField.PHONENUMBER) - { - if(phonenr == null) - { - phonenr = new ConstrainedText(eswtGetStaticShell(), SWT.SINGLE, - ConstrainedText.PHONENUMBER); - } - ret = phonenr; + else if (constraint == TextField.PHONENUMBER) { + constraint = TextExtensionExtension.PHONENUMBER; } else { // TODO: eSWT support required - text validation on EMAIL and URL constraints // default - if(any == null) - { - any = new TextExtension(eswtGetStaticShell(), SWT.MULTI | SWT.WRAP); - } - ret = any; + constraint = 0; } - return ret; + return new TextExtensionExtension(eswtGetStaticShell(), SWT.MULTI | SWT.WRAP,constraint); } /** @@ -194,8 +165,7 @@ */ boolean eswtIsSpecificControl(Item item, Control control) { - return (control instanceof TextExtension - || control instanceof ConstrainedText); + return (control instanceof TextExtension); } /** diff -r dc7c549001d5 -r 85266cc22c7f javauis/lcdui_qt/src/javax/microedition/lcdui/TextWrapper.java --- a/javauis/lcdui_qt/src/javax/microedition/lcdui/TextWrapper.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/lcdui_qt/src/javax/microedition/lcdui/TextWrapper.java Fri Jun 11 13:33:44 2010 +0300 @@ -16,8 +16,8 @@ */ package javax.microedition.lcdui; -import org.eclipse.ercp.swt.mobile.ConstrainedText; import org.eclipse.ercp.swt.mobile.TextExtension; +import org.eclipse.swt.internal.extension.TextExtensionExtension; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionListener; @@ -326,7 +326,6 @@ { retTopPixel = ((TextExtension) control).getTopPixel(); } - // ConstrainedText does not scroll -> value is 0 } }); } @@ -837,10 +836,6 @@ { ((TextExtension) control).addModifyListener(ltnr); } - else - { - ((ConstrainedText) control).addModifyListener(ltnr); - } } } @@ -858,10 +853,6 @@ { ((TextExtension) control).addSelectionListener(ltnr); } - else - { - ((ConstrainedText) control).addSelectionListener(ltnr); - } } } @@ -875,7 +866,6 @@ */ static Control eswtConstructText(Composite parent, int aStyle, int aConstraints) { - Control ret = null; int style = aStyle; int extractedFlag = aConstraints & ~TextField.CONSTRAINT_MASK; @@ -884,6 +874,7 @@ if((extractedFlag & TextField.PASSWORD) == TextField.PASSWORD) { // Text class will remove incompatible flags for SINGLE + style &= ~SWT.MULTI; style |= SWT.SINGLE | SWT.PASSWORD; } if((extractedFlag & TextField.UNEDITABLE) == TextField.UNEDITABLE) @@ -893,27 +884,20 @@ if(extractedConstraint == TextField.NUMERIC) { - ret = new ConstrainedText(parent, style, ConstrainedText.NUMERIC); + extractedConstraint = TextExtensionExtension.NUMERIC; } else if(extractedConstraint == TextField.DECIMAL) { - ret = new ConstrainedText(parent, style, ConstrainedText.DECIMAL); + extractedConstraint = TextExtensionExtension.DECIMAL; } else if(extractedConstraint == TextField.PHONENUMBER) { - ret = new ConstrainedText(parent, style, ConstrainedText.PHONENUMBER); - } - else if(extractedConstraint == TextField.NON_PREDICTIVE - || extractedConstraint == TextField.SENSITIVE) - { - // We treat non-predictive and sensitive to be equal - ret = new TextExtension(parent, style, TextExtension.NON_PREDICTIVE); - } - else - { - ret = new TextExtension(parent, style); - } - return ret; + extractedConstraint = TextExtensionExtension.PHONENUMBER; + } + else { + extractedConstraint = 0; + } + return new TextExtensionExtension(parent, style,extractedConstraint); } /** @@ -930,10 +914,6 @@ { ret = ((TextExtension) control).getCaretPosition(); } - else - { - ret = ((ConstrainedText) control).getCaretPosition(); - } } return ret; } @@ -970,10 +950,6 @@ { ret = ((TextExtension) control).getText(); } - else - { - ret = ((ConstrainedText) control).getText(); - } } return ret; } @@ -1010,10 +986,6 @@ { ret = ((TextExtension) control).getLineHeight(); } - else - { - ret = ((ConstrainedText) control).getSize().y; - } } return ret; } @@ -1032,10 +1004,6 @@ { ret = ((TextExtension) control).getTextLimit(); } - else - { - ret = ((ConstrainedText) control).getTextLimit(); - } } return ret; } @@ -1054,11 +1022,6 @@ { ret = ((TextExtension) control).getSelectionText(); } - else - { - // TODO: eSWT support required - get selection in ConstrainedText - ret = ((ConstrainedText) control).getText(); - } } return ret; } @@ -1077,10 +1040,6 @@ { ret = ((TextExtension) control).getCharCount(); } - else - { - ret = ((ConstrainedText) control).getCharCount(); - } } return ret; } @@ -1099,10 +1058,6 @@ { ((TextExtension) control).removeModifyListener(ltnr); } - else - { - ((ConstrainedText) control).removeModifyListener(ltnr); - } } } @@ -1120,10 +1075,6 @@ { ((TextExtension) control).removeSelectionListener(ltnr); } - else - { - ((ConstrainedText) control).removeSelectionListener(ltnr); - } } } @@ -1141,10 +1092,6 @@ { ((TextExtension) control).setText(text); } - else - { - ((ConstrainedText) control).setText(text); - } } } @@ -1233,10 +1180,6 @@ { ((TextExtension) control).setTextLimit(maxSize); } - else - { - ((ConstrainedText) control).setTextLimit(maxSize); - } } } @@ -1255,10 +1198,6 @@ { ((TextExtension) control).setSelection(sta, end); } - else - { - ((ConstrainedText) control).setSelection(sta, end); - } } } diff -r dc7c549001d5 -r 85266cc22c7f javauis/lcdui_qt/tsrc/.classpath --- a/javauis/lcdui_qt/tsrc/.classpath Thu May 27 12:49:31 2010 +0300 +++ b/javauis/lcdui_qt/tsrc/.classpath Fri Jun 11 13:33:44 2010 +0300 @@ -3,12 +3,10 @@ - - - - - + + + diff -r dc7c549001d5 -r 85266cc22c7f javauis/lcdui_qt/tsrc/build/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/lcdui_qt/tsrc/build/build.xml Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,111 @@ + + + + + + Builds OpenLcdui Tests on eSWT + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + junit-3.8.1.1.odc${line.separator} + junit-3.8.1.1.jar${line.separator} + + + + ${component.dir}.odc${line.separator} + ${component.dir}.jar${line.separator} + + + + openlcdui.odc${line.separator} + + + + javanokiaui.odc${line.separator} + + + diff -r dc7c549001d5 -r 85266cc22c7f javauis/lcdui_qt/tsrc/build/bwins/openlcduitestsu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/lcdui_qt/tsrc/build/bwins/openlcduitestsu.def Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,3 @@ +EXPORTS + ?jni_lookup@@YAP6AXXZPBD@Z @ 1 NONAME ; void (*)(void) jni_lookup(char const *) + diff -r dc7c549001d5 -r 85266cc22c7f javauis/lcdui_qt/tsrc/build/eabi/openlcduitestsu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/lcdui_qt/tsrc/build/eabi/openlcduitestsu.def Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,3 @@ +EXPORTS + _Z10jni_lookupPKc @ 1 NONAME + diff -r dc7c549001d5 -r 85266cc22c7f javauis/lcdui_qt/tsrc/build/openlcduitests.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/lcdui_qt/tsrc/build/openlcduitests.pro Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,24 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +TEMPLATE=lib +TARGET=openlcduitests +CONFIG += omj java javaonly +CONFIG -= qt + +TARGET.UID3 = 0x2002E69A + +include(../../../../build/omj.pri) diff -r dc7c549001d5 -r 85266cc22c7f javauis/lcdui_qt/tsrc/junit-3.8.1.1.odc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/lcdui_qt/tsrc/junit-3.8.1.1.odc Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,13 @@ +[container] +name=junit-3.8.1.1 +type=JXESL + +[packages] +junit/awtui +junit/extensions +junit/framework +junit/runner +junit/swingui +junit/textui + +[properties] \ No newline at end of file diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/build/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/build/build.xml Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,110 @@ + + + + + + Builds M3G on Qt. + + + + + + + + + + + + + + + + + + + microedition.m3g.version=1.1 + + + + + + + + diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/build/bwins/javam3gu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/build/bwins/javam3gu.def Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,3 @@ +EXPORTS + ?jni_lookup@@YAP6AXXZPBD@Z @ 1 NONAME ; void (*)(void) jni_lookup(char const *) + diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/build/eabi/javam3gu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/build/eabi/javam3gu.def Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,3 @@ +EXPORTS + _Z10jni_lookupPKc @ 1 NONAME + diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/build/javam3g.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/build/javam3g.pro Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,42 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +TEMPLATE=lib +TARGET=javam3g +CONFIG += omj java staticdata stl +#CONFIG -= qt + +QT += core gui + +INCLUDEPATH += ../inc +INCLUDEPATH += ../src/jni +INCLUDEPATH += ../../eswt_qt/org.eclipse.swt/Eclipse_SWT_PI/qt/library/graphics + + + +SOURCES += ../src/*.cpp + +DEFINES += M3G_TARGET_SYMBIAN +DEFINES += M3G_NATIVE_LOADER + +LIBS += -lcone \ + -lezlib \ + -lfbscli \ + -llibgles_cm \ + -llibegl \ + -lm3gcore + +include(../../../build/omj.pri) diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/inc/CSynchronization.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/inc/CSynchronization.h Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,85 @@ +/* +* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: M3GCore function call serialization and synchronization +* +*/ + +#ifndef CSYNCHRONIZATION_H +#define CSYNCHRONIZATION_H + +// INCLUDE FILES +#include +#include + +// CLASS DECLARATION +/** + * @class CSynchronization + */ +class CSynchronization : public CBase +{ +public: + /** + * Two-phased constructor. + */ + static CSynchronization* InstanceL(); + + /** + * Dtor + */ + ~CSynchronization(); + + /** + * Locks the semaphore + */ + void Lock(); + + /** + * Unlocks the semaphore + */ + void Unlock(); + + /** + * Sets error code for error occured during lock period + */ + void SetErrorCode(TInt aCode); + + /** + * Returns error string set with SetErrorString + */ + TInt GetErrorCode(); + +private: // METHODS + /** + * Constructor + */ + CSynchronization(); + + /** + * Two-phased constructor. + * @return New object + */ + static CSynchronization* NewL(); + + /** + * Constructor + */ + void ConstructL(); + +private: // MEMBER VARIABLES + static CSynchronization* iSelf; + RCriticalSection iGuard; + TInt iErrorCode; +}; + +#endif // CSYNCHRONIZATION_H diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/inc/m3g_jsr184.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/inc/m3g_jsr184.h Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#ifndef M3G_JSR184_H +#define M3G_JSR184_H + +/*! + * \file \brief Global enumerations for JSR-184 + * + */ + +#if defined(M3G_CORE_INCLUDE) +# error includes Java dependencies; do not include into the core module. +#endif + +#include + +#if defined(__cplusplus) +extern "C" +{ +#endif + + /*---------------------------------------------------------------------- + * Enumerations + *--------------------------------------------------------------------*/ + + /*---------------------------------------------------------------------- + * JSR-184 API internal functions + *--------------------------------------------------------------------*/ + + static M3Guint jsr184BytesPerPixels(int format); + static const char *jsr184Exception(M3Genum errorCode); + +#if defined(__cplusplus) +} /* extern "C" */ +#endif + +#endif // M3G_JSR184_H + diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/com/dummy.txt diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/AnimationController.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/AnimationController.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,110 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +public class AnimationController extends Object3D +{ + //------------------------------------------------------------------ + // Constructor + //------------------------------------------------------------------ + + public AnimationController() + { + super(_ctor(Interface.getHandle())); + } + + /** + */ + AnimationController(int handle) + { + super(handle); + } + + //------------------------------------------------------------------ + // Public methods + //------------------------------------------------------------------ + + public void setActiveInterval(int worldTimeMin, int worldTimeMax) + { + _setActiveInterval(handle, worldTimeMin, worldTimeMax); + } + + public int getActiveIntervalStart() + { + return _getActiveIntervalStart(handle); + } + + public int getActiveIntervalEnd() + { + return _getActiveIntervalEnd(handle); + } + + public void setSpeed(float factor, int worldTime) + { + _setSpeed(handle, factor, worldTime); + } + + public float getSpeed() + { + return _getSpeed(handle); + } + + public void setPosition(float time, int worldTime) + { + _setPosition(handle, time, worldTime); + } + + public float getPosition(int worldTime) + { + return _getPosition(handle, worldTime); + } + + public void setWeight(float weight) + { + _setWeight(handle, weight); + } + + public float getWeight() + { + return _getWeight(handle); + } + + // M3G maintenance version 1.1 + public int getRefWorldTime() + { + return _getRefWorldTime(handle); + } + + + // Native methods + private native static int _ctor(int hInterface); + private native static void _setActiveInterval(int handle, int worldTimeMin, int worldTimeMax); + private native static int _getActiveIntervalStart(int handle); + private native static int _getActiveIntervalEnd(int handle); + private native static void _setSpeed(int handle, float factor, int worldTime); + private native static float _getSpeed(int handle); + private native static void _setPosition(int handle, float time, int worldTime); + private native static float _getPosition(int handle, int worldTime); + private native static void _setWeight(int handle, float weight); + private native static float _getWeight(int handle); + + // M3G maintenance version 1.1 + private native static int _getRefWorldTime(int handle); + +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/AnimationTrack.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/AnimationTrack.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,110 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +public class AnimationTrack extends Object3D +{ + //------------------------------------------------------------------ + // Static data + //------------------------------------------------------------------ + + public static final int ALPHA = 256; + public static final int AMBIENT_COLOR = 257; + public static final int COLOR = 258; + public static final int CROP = 259; + public static final int DENSITY = 260; + public static final int DIFFUSE_COLOR = 261; + public static final int EMISSIVE_COLOR = 262; + public static final int FAR_DISTANCE = 263; + public static final int FIELD_OF_VIEW = 264; + public static final int INTENSITY = 265; + public static final int MORPH_WEIGHTS = 266; + public static final int NEAR_DISTANCE = 267; + public static final int ORIENTATION = 268; + public static final int PICKABILITY = 269; + public static final int SCALE = 270; + public static final int SHININESS = 271; + public static final int SPECULAR_COLOR = 272; + public static final int SPOT_ANGLE = 273; + public static final int SPOT_EXPONENT = 274; + public static final int TRANSLATION = 275; + public static final int VISIBILITY = 276; + + //------------------------------------------------------------------ + // Instance data + //------------------------------------------------------------------ + + private AnimationController controller; + private KeyframeSequence sequence; + + //------------------------------------------------------------------ + // Constructors + //------------------------------------------------------------------ + + AnimationTrack(int handle) + { + super(handle); + controller = (AnimationController)getInstance(_getController(handle)); + sequence = (KeyframeSequence)getInstance(_getSequence(handle)); + } + + public AnimationTrack(KeyframeSequence sequence, int property) + { + super(_ctor(Interface.getHandle(), + sequence != null ? sequence.handle : 0, property)); + this.sequence = sequence; + } + + //------------------------------------------------------------------ + // Public methods + //------------------------------------------------------------------ + + public void setController(AnimationController controller) + { + _setController(handle, controller != null ? controller.handle : 0); + this.controller = controller; + } + + public AnimationController getController() + { + return controller; + } + + public KeyframeSequence getKeyframeSequence() + { + return sequence; + } + + public int getTargetProperty() + { + return _getTargetProperty(handle); + } + + //------------------------------------------------------------------ + // Private methods + //------------------------------------------------------------------ + + private native static int _ctor(int hInterface, + int hSequence, + int property); + private native static int _getController(int handle); + private native static int _getSequence(int handle); + private native static int _getTargetProperty(int handle); + private native static void _setController(int handle, int hController); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/Appearance.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/Appearance.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,159 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +public class Appearance extends Object3D +{ + //------------------------------------------------------------------ + // Instance data + //------------------------------------------------------------------ + + private CompositingMode compositingMode; + private Fog fog; + private Material material; + private PolygonMode polygonMode; + private Texture2D[] textures; + + //------------------------------------------------------------------ + // Constructor(s) + //------------------------------------------------------------------ + + public Appearance() + { + super(_ctor(Interface.getHandle())); + } + + /** + */ + Appearance(int handle) + { + super(handle); + + compositingMode = (CompositingMode) getInstance(_getCompositingMode(handle)); + fog = (Fog) getInstance(_getFog(handle)); + material = (Material) getInstance(_getMaterial(handle)); + polygonMode = (PolygonMode) getInstance(_getPolygonMode(handle)); + + textures = new Texture2D[Defs.NUM_TEXTURE_UNITS]; + + for (int i = 0; i < Defs.NUM_TEXTURE_UNITS; ++i) + { + textures[i] = (Texture2D) getInstance(_getTexture(handle, i)); + } + } + + //------------------------------------------------------------------ + // Public methods + //------------------------------------------------------------------ + + public void setCompositingMode(CompositingMode compositingMode) + { + _setCompositingMode(handle, + compositingMode != null + ? compositingMode.handle + : 0); + this.compositingMode = compositingMode; + } + + public CompositingMode getCompositingMode() + { + return compositingMode; + } + + public void setFog(Fog fog) + { + _setFog(handle, fog != null ? fog.handle : 0); + this.fog = fog; + } + + public Fog getFog() + { + return fog; + } + + public void setPolygonMode(PolygonMode polygonMode) + { + _setPolygonMode(handle, polygonMode != null ? polygonMode.handle : 0); + this.polygonMode = polygonMode; + } + + public PolygonMode getPolygonMode() + { + return polygonMode; + } + + public void setLayer(int index) + { + _setLayer(handle, index); + } + + public int getLayer() + { + return _getLayer(handle); + } + + public void setMaterial(Material material) + { + _setMaterial(handle, material != null ? material.handle : 0); + this.material = material; + } + + public Material getMaterial() + { + return material; + } + + public void setTexture(int unit, Texture2D texture) + { + _setTexture(handle, unit, texture != null ? texture.handle : 0); + + if (textures == null) + { + textures = new Texture2D[Defs.NUM_TEXTURE_UNITS]; + } + textures[unit] = texture; + } + + public Texture2D getTexture(int unit) + { + return (Texture2D) getInstance(_getTexture(handle, unit)); + } + + //------------------------------------------------------------------ + // Private methods + //------------------------------------------------------------------ + + private static native int _ctor(int hInterface); + + private static native int _getCompositingMode(int hApp); + private static native int _getFog(int hApp); + private static native int _getLayer(int hApp); + private static native int _getMaterial(int hApp); + private static native int _getPolygonMode(int hApp); + private static native int _getTexture(int hApp, int unit); + + private static native void _setCompositingMode(int hApp, int hMode); + private static native void _setFog(int hApp, int hFog); + private static native void _setLayer(int hApp, int layer); + private static native void _setMaterial(int hApp, int hMaterial); + private static native void _setPolygonMode(int hApp, int hMode); + private static native void _setTexture(int hApp, + int unit, + int hTexture); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/Background.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/Background.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,154 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +public class Background extends Object3D +{ + //------------------------------------------------------------------ + // Static data + //------------------------------------------------------------------ + + public static final int BORDER = 32; + public static final int REPEAT = 33; + + //------------------------------------------------------------------ + // Instance data + //------------------------------------------------------------------ + + private Image2D image; + + //------------------------------------------------------------------ + // Constructors + //------------------------------------------------------------------ + + public Background() + { + super(_ctor(Interface.getHandle())); + } + + /** + */ + Background(int handle) + { + super(handle); + image = (Image2D) getInstance(_getImage(handle)); + } + + //------------------------------------------------------------------ + // Public methods + //------------------------------------------------------------------ + + public void setColor(int ARGB) + { + _setColor(handle, ARGB); + } + + public int getColor() + { + return _getColor(handle); + } + + public void setImage(Image2D image) + { + _setImage(handle, image != null ? image.handle : 0); + this.image = image; + } + + public Image2D getImage() + { + return image; + } + + public void setImageMode(int modeX, int modeY) + { + _setImageMode(handle, modeX, modeY); + } + + public int getImageModeX() + { + return _getImageMode(handle, Defs.GET_MODEX); + } + + public int getImageModeY() + { + return _getImageMode(handle, Defs.GET_MODEY); + } + + public void setColorClearEnable(boolean enable) + { + _enable(handle, Defs.SETGET_COLORCLEAR, enable); + } + + public void setDepthClearEnable(boolean enable) + { + _enable(handle, Defs.SETGET_DEPTHCLEAR, enable); + } + + public boolean isColorClearEnabled() + { + return _isEnabled(handle, Defs.SETGET_COLORCLEAR); + } + + public boolean isDepthClearEnabled() + { + return _isEnabled(handle, Defs.SETGET_DEPTHCLEAR); + } + + public void setCrop(int cropX, int cropY, int width, int height) + { + _setCrop(handle, cropX, cropY, width, height); + } + + public int getCropX() + { + return _getCrop(handle, Defs.GET_CROPX); + } + + public int getCropY() + { + return _getCrop(handle, Defs.GET_CROPY); + } + + public int getCropWidth() + { + return _getCrop(handle, Defs.GET_CROPWIDTH); + } + + public int getCropHeight() + { + return _getCrop(handle, Defs.GET_CROPHEIGHT); + } + + //------------------------------------------------------------------ + // Private methods + //------------------------------------------------------------------ + + // Native functions + private static native int _ctor(int hInterface); + private static native void _setColor(int handle, int ARGB); + private static native int _getColor(int handle); + private static native void _setImage(int handle, int hImage); + private static native int _getImage(int handle); + private static native void _setImageMode(int handle, int modeX, int modeY); + private static native int _getImageMode(int handle, int which); + private static native void _enable(int handle, int which, boolean enable); + private static native boolean _isEnabled(int handle, int which); + private static native void _setCrop(int handle, int cropX, int cropY, int width, int height); + private static native int _getCrop(int handle, int which); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/Camera.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/Camera.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,87 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +public class Camera extends Node +{ + //------------------------------------------------------------------ + // Static data + //------------------------------------------------------------------ + + public static final int GENERIC = 48; + public static final int PARALLEL = 49; + public static final int PERSPECTIVE = 50; + + //------------------------------------------------------------------ + // Constructors + //------------------------------------------------------------------ + + public Camera() + { + super(_ctor(Interface.getHandle())); + } + + /** + */ + Camera(int handle) + { + super(handle); + } + + //------------------------------------------------------------------ + // Public methods + //------------------------------------------------------------------ + + public void setParallel(float height, float aspectRatio, float near, float far) + { + _setParallel(handle, height, aspectRatio, near, far); + } + + public void setPerspective(float fovy, float aspectRatio, float near, float far) + { + _setPerspective(handle, fovy, aspectRatio, near, far); + } + + public void setGeneric(Transform transform) + { + _setGeneric(handle, transform.matrix); + } + + public int getProjection(Transform transform) + { + return _getProjectionAsTransform(handle, transform != null ? transform.matrix : null); + } + + public int getProjection(float[] params) + { + return _getProjectionAsParams(handle, params); + } + + //------------------------------------------------------------------ + // Private methods + //------------------------------------------------------------------ + + // Native methods + private static native int _ctor(int hInterface); + private static native void _setParallel(int handle, float height, float aspectRatio, float near, float far); + private static native void _setPerspective(int handle, float fovy, float aspectRatio, float near, float far); + private static native void _setGeneric(int handle, byte[] transform); + private static native int _getProjectionAsTransform(int handle, byte[] transform); + private static native int _getProjectionAsParams(int handle, float[] params); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/CompositingMode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/CompositingMode.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,148 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +public class CompositingMode extends Object3D +{ + //------------------------------------------------------------------ + // Static data + //------------------------------------------------------------------ + + public static final int ALPHA = 64; + public static final int ALPHA_ADD = 65; + public static final int MODULATE = 66; + public static final int MODULATE_X2 = 67; + public static final int REPLACE = 68; + + //------------------------------------------------------------------ + // Constructors + //------------------------------------------------------------------ + + public CompositingMode() + { + super(_ctor(Interface.getHandle())); + } + + /** + */ + CompositingMode(int handle) + { + super(handle); + } + + //------------------------------------------------------------------ + // Public methods + //------------------------------------------------------------------ + + public void setBlending(int mode) + { + _setBlending(handle, mode); + } + + public int getBlending() + { + return _getBlending(handle); + } + + public void setAlphaThreshold(float threshold) + { + _setAlphaThreshold(handle, threshold); + } + + public float getAlphaThreshold() + { + return _getAlphaThreshold(handle); + } + + public void setAlphaWriteEnable(boolean enable) + { + _setAlphaWriteEnable(handle, enable); + } + + public boolean isAlphaWriteEnabled() + { + return _isAlphaWriteEnabled(handle); + } + + public void setColorWriteEnable(boolean enable) + { + _enableColorWrite(handle, enable); + } + + public boolean isColorWriteEnabled() + { + return _isColorWriteEnabled(handle); + } + + public void setDepthWriteEnable(boolean enable) + { + _enableDepthWrite(handle, enable); + } + + public boolean isDepthWriteEnabled() + { + return _isDepthWriteEnabled(handle); + } + + public void setDepthTestEnable(boolean enable) + { + _enableDepthTest(handle, enable); + } + + public boolean isDepthTestEnabled() + { + return _isDepthTestEnabled(handle); + } + + public void setDepthOffset(float factor, float units) + { + _setDepthOffset(handle, factor, units); + } + + public float getDepthOffsetFactor() + { + return _getDepthOffsetFactor(handle); + } + + public float getDepthOffsetUnits() + { + return _getDepthOffsetUnits(handle); + } + + //------------------------------------------------------------------ + // Private methods + //------------------------------------------------------------------ + + private native static int _ctor(int hInterface); + private native static void _setBlending(int handle, int mode); + private native static int _getBlending(int handle); + private native static void _setAlphaThreshold(int handle, float threshold); + private native static float _getAlphaThreshold(int handle); + private native static void _setAlphaWriteEnable(int handle, boolean enable); + private native static boolean _isAlphaWriteEnabled(int handle); + private native static void _enableDepthTest(int handle, boolean enable); + private native static boolean _isDepthTestEnabled(int handle); + private native static void _enableDepthWrite(int handle, boolean enable); + private native static boolean _isDepthWriteEnabled(int handle); + private native static void _enableColorWrite(int handle, boolean enable); + private native static boolean _isColorWriteEnabled(int handle); + private native static void _setDepthOffset(int handle, float factor, float units); + private native static float _getDepthOffsetFactor(int handle); + private native static float _getDepthOffsetUnits(int handle); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/Defs.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/Defs.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,66 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +class Defs +{ + static boolean supportDithering = false; + static boolean supportTrueColor = false; + static boolean supportAntialiasing = true; + static boolean supportMipmapping = true; + static boolean supportPerspectiveCorrection = true; + static boolean supportLocalCameraLighting = false; + + static int MAX_LIGHTS = 8; + static int MAX_TEXTURE_DIMENSION = 1024; + static int MAX_TRANSFORMS_PER_VERTEX = 4; + static int MAX_VIEWPORT_WIDTH = 1024; + static int MAX_VIEWPORT_HEIGHT = 1024; + static int MAX_VIEWPORT_DIMENSION = 1024; + static int NUM_TEXTURE_UNITS = 2; + + /* Constants used in various setters/getters */ + + /* VertexBuffer */ + static final int GET_POSITIONS = 0; + static final int GET_NORMALS = 1; + static final int GET_COLORS = 2; + static final int GET_TEXCOORDS0 = 3; + /* GET_TEXCOORDS1 = 4 */ + /* Sprite and Background */ + static final int GET_CROPX = 0; + static final int GET_CROPY = 1; + static final int GET_CROPWIDTH = 2; + static final int GET_CROPHEIGHT = 3; + /* Background */ + static final int GET_MODEX = 0; + static final int GET_MODEY = 1; + static final int SETGET_COLORCLEAR = 0; + static final int SETGET_DEPTHCLEAR = 1; + /* Fog */ + static final int GET_NEAR = 0; + static final int GET_FAR = 1; + /* Node */ + static final int SETGET_RENDERING = 0; + static final int SETGET_PICKING = 1; + /* Light */ + static final int GET_CONSTANT = 0; + static final int GET_LINEAR = 1; + static final int GET_QUADRATIC = 2; +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/Fog.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/Fog.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,93 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +public class Fog extends Object3D +{ + public static final int EXPONENTIAL = 80; + public static final int LINEAR = 81; + + public Fog() + { + super(_ctor(Interface.getHandle())); + } + + /** + */ + Fog(int handle) + { + super(handle); + } + + public void setMode(int mode) + { + _setMode(handle, mode); + } + + public int getMode() + { + return _getMode(handle); + } + + public void setLinear(float near, float far) + { + _setLinear(handle, near, far); + } + + public float getNearDistance() + { + return _getDistance(handle, Defs.GET_NEAR); + } + + public float getFarDistance() + { + return _getDistance(handle, Defs.GET_FAR); + } + + public void setDensity(float density) + { + _setDensity(handle, density); + } + + public float getDensity() + { + return _getDensity(handle); + } + + public void setColor(int RGB) + { + _setColor(handle, RGB); + } + + public int getColor() + { + return _getColor(handle); + } + + // Native methods + private static native int _ctor(int hInterface); + private static native void _setMode(int handle, int mode); + private static native int _getMode(int handle); + private static native void _setLinear(int handle, float near, float far); + private static native float _getDistance(int handle, int which); + private static native void _setDensity(int handle, float density); + private static native float _getDensity(int handle); + private static native void _setColor(int handle, int RGB); + private static native int _getColor(int handle); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/Graphics3D.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/Graphics3D.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,743 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +import javax.microedition.lcdui.Graphics; +import java.util.Hashtable; +import java.util.Vector; +import org.eclipse.swt.widgets.*; +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.internal.qt.graphics.*; +import org.eclipse.swt.internal.qt.GCData; +import com.nokia.mj.impl.rt.support.ShutdownListener; +import com.nokia.mj.impl.rt.support.ApplicationUtils; +import com.nokia.mj.impl.nokialcdui.LCDUIInvoker; + + +public class Graphics3D +{ + //------------------------------------------------------------------ + // Static data + //------------------------------------------------------------------ + + public static final int ANTIALIAS = 2; + public static final int DITHER = 4; + public static final int TRUE_COLOR = 8; + + // M3G 1.1 + public static final int OVERWRITE = 16; + + // Singleton instances + static Graphics3D s_instance = null; + + //------------------------------------------------------------------ + // Instance data + //------------------------------------------------------------------ + + int handle; + int iSurfaceHandle; + + private Camera camera = null; + private Vector lights = new Vector(); + + private java.lang.Object currentTarget = null; + private int offsetX, offsetY, hints = 0; + private boolean depthEnabled = true; + private Destroyer destroyer; + private Interface iInterface; + + // this flag is for identification of image target types + // - True for mutable off-screen images + // - False for canvas/GameCanvas framebuffer + private boolean iIsImageTarget; + + // this flag is for identification if MBX HW accelerator is present + // - True - MBX is NOT present + // - False - MBX is present + private boolean iIsProperRenderer; + + private boolean iNativeInitialized = false; + + // Shutdown listener + private class Destroyer implements ShutdownListener + { + Graphics3D target; + + Destroyer(Graphics3D g3d) + { + target = g3d; + ApplicationUtils appUtils = ApplicationUtils.getInstance(); + appUtils.addShutdownListener(this); + } + + // This method gets called when application is shuttingdown + public void shuttingDown() + { + + // Finalize native peer + Platform.finalizeObject(target.handle, target.iInterface); + + // signal shutdown (set shutdown flag) + // and remove references + target.iInterface.signalShutdown(); + target.iInterface = null; + target.camera = null; + //target.s_instance = null; + + // All done, Call gc() and finalization to collect + // remaining objects, thus zeroying liveObjects count + // in interface instance + + } + } + + //------------------------------------------------------------------ + // Constructor(s) + //------------------------------------------------------------------ + public static final Graphics3D getInstance() + { + + if (s_instance == null) + { + s_instance = new Graphics3D(); + } + return s_instance; + } + + private Graphics3D() + { + iInterface = Interface.getInstance(); + initNativePeer(); + + // setup listener for singleton teardown + destroyer = new Destroyer(this); + } + + //------------------------------------------------------------------ + // Public methods + //------------------------------------------------------------------ + + /** + */ + public void bindTarget(java.lang.Object target) + { + bindTarget(target, true, 0); + } + + /** + * + */ + public void bindTarget(java.lang.Object target, boolean depth, int flags) + { + integrityCheck(); + if (currentTarget != null) + { + throw new IllegalStateException(); + } + + if (target == null) + { + throw new NullPointerException(); + } + + final int finalFlags = flags; + final boolean finalDepth = depth; + + if (target instanceof org.eclipse.swt.graphics.GC) + { + Rectangle clip = ((org.eclipse.swt.graphics.GC)target).getClipping(); + final int clipW = clip.width; + final int clipH = clip.height; + final int clipX = clip.x; + final int clipY = clip.y; + + if (clipW > Defs.MAX_VIEWPORT_WIDTH || + clipH > Defs.MAX_VIEWPORT_HEIGHT) + { + throw new IllegalArgumentException(); + } + + final Object finalTarget = target; + Platform.executeInUIThread( + new M3gRunnable() + { + public void doRun() + { + GCData gcData = ((org.eclipse.swt.graphics.GC)finalTarget).getGCData(); + iSurfaceHandle = gcData.internalGc.getWindowSurface().getHandle(); + iIsImageTarget = _bindGraphics( + handle, + iSurfaceHandle, + clipX, clipY, + clipW, clipH, + finalDepth, finalFlags, + iIsProperRenderer); + } + }); + currentTarget = target; + } + + else if (target instanceof Graphics) + { + + Graphics g = (Graphics) target; + //Platform.sync(g); + + if (g.getClipWidth() > Defs.MAX_VIEWPORT_WIDTH || + g.getClipHeight() > Defs.MAX_VIEWPORT_HEIGHT) + { + throw new IllegalArgumentException(); + } + + offsetX = g.getTranslateX(); + offsetY = g.getTranslateY(); + + final Graphics finalG = g; + + Platform.executeInUIThread( + new M3gRunnable() + { + public void doRun() + { + LCDUIInvoker.startExternalRendering( finalG ); + iSurfaceHandle = LCDUIInvoker.getWindowSurface(finalG).getHandle(); + iIsImageTarget = _bindGraphics( + handle, + iSurfaceHandle, + finalG.getClipX() + offsetX, finalG.getClipY() + offsetY, + finalG.getClipWidth(), finalG.getClipHeight(), + finalDepth, finalFlags, + iIsProperRenderer); + } + }); + currentTarget = g; + } + else if (target instanceof Image2D) + { + Image2D img = (Image2D) target; + + offsetX = offsetY = 0; + final int imageHandle = img.handle; + + Platform.executeInUIThread( + new M3gRunnable() + { + public void doRun() + { + _bindImage(handle, imageHandle, finalDepth, finalFlags); + } + }); + currentTarget = img; + } + else + { + throw new IllegalArgumentException(); + } + + hints = flags; + depthEnabled = depth; + } + + /** + * + */ + public void releaseTarget() + { + integrityCheck(); + if (currentTarget == null) + { + return; + } + + if (currentTarget instanceof org.eclipse.swt.graphics.GC) + { + Platform.executeInUIThread( + new M3gRunnable() + { + public void doRun() + { + _releaseGraphics(handle, + iSurfaceHandle, iIsImageTarget, iIsProperRenderer); + } + }); + } + else if (currentTarget instanceof Graphics) + { + final Graphics finalG = (Graphics)currentTarget; + Platform.executeInUIThread( + new M3gRunnable() + { + public void doRun() + { + _releaseGraphics(handle, + iSurfaceHandle, iIsImageTarget, iIsProperRenderer); + LCDUIInvoker.endExternalRendering( finalG ); + } + }); + /* + Graphics g = (Graphics) currentTarget; + + //ToolkitInvoker invoker = ToolkitInvoker.getToolkitInvoker(); + + Platform.getUIThread().syncExec( + new Runnable() { + public void run() { + _releaseGraphics( handle, + invoker.graphicsGetHandle(g), iIsImageTarget, iIsProperRenderer ); + } + }); + */ + } + else if (currentTarget instanceof Image2D) + { + Platform.executeInUIThread( + new M3gRunnable() + { + public void doRun() + { + _releaseImage(handle); + } + }); + } + else + { + throw new Error(); + } + currentTarget = null; + iSurfaceHandle = 0; + } + + /** + * + */ + public void setViewport(int x, int y, int width, int height) + { + integrityCheck(); + if (width <= 0 || height <= 0 + || width > Defs.MAX_VIEWPORT_DIMENSION + || height > Defs.MAX_VIEWPORT_DIMENSION) + { + throw new IllegalArgumentException(); + } + _setViewport(handle, x + offsetX, y + offsetY, width, height); + } + + /** + * + */ + public void clear(Background background) + { + integrityCheck(); + final Background finalBackground = background; + Platform.executeInUIThread( + new M3gRunnable() + { + public void doRun() + { + _clear(handle, finalBackground != null ? finalBackground.handle : 0); + } + }); + } + + /** + * + */ + public void render(World world) + { + integrityCheck(); + final World finalWorld = world; + Platform.executeInUIThread( + new M3gRunnable() + { + public void doRun() + { + _renderWorld(handle, finalWorld.handle); + } + }); + } + + /** + * + */ + public void render(VertexBuffer vertices, + IndexBuffer primitives, + Appearance appearance, + Transform transform) + { + // Call rendering method with default visibility + integrityCheck(); + render(vertices, primitives, appearance, transform, -1); + } + + /** + * + */ + public void render(VertexBuffer vertices, + IndexBuffer primitives, + Appearance appearance, + Transform transform, + int scope) + { + + // null pointer exceptions thrown automatically below + integrityCheck(); + + final VertexBuffer finalVertices = vertices; + final IndexBuffer finalPrimitives = primitives; + final Appearance finalAppearance = appearance; + final Transform finalTransform = transform; + final int finalScope = scope; + + Platform.executeInUIThread( + new M3gRunnable() + { + public void doRun() + { + _render(handle, + finalVertices.handle, + finalPrimitives.handle, + finalAppearance.handle, + finalTransform != null ? finalTransform.matrix : null, + finalScope); + } + }); + } + + /** + * + */ + public void render(Node node, Transform transform) + { + if (!(node instanceof Mesh + || node instanceof Sprite3D + || node instanceof Group) + && node != null) + { + throw new IllegalArgumentException(); + } + integrityCheck(); + + final Node finalNode = node; + final Transform finalTransform = transform; + + Platform.executeInUIThread( + new M3gRunnable() + { + public void doRun() + { + _renderNode(handle, + finalNode.handle, + finalTransform != null ? finalTransform.matrix : null); + } + }); + } + + + public void setCamera(Camera camera, Transform transform) + { + integrityCheck(); + _setCamera(handle, + camera != null ? camera.handle : 0, + transform != null ? transform.matrix : null); + + this.camera = camera; + } + + /** + */ + public int addLight(Light light, Transform transform) + { + integrityCheck(); + int index = _addLight(handle, + light.handle, + transform != null ? transform.matrix : null); + if (lights.size() < index + 1) + { + lights.setSize(index + 1); + } + lights.setElementAt(light, index); + return index; + } + + /** + * + */ + public void setLight(int index, Light light, Transform transform) + { + integrityCheck(); + _setLight(handle, + index, + light != null ? light.handle : 0, + transform != null ? transform.matrix : null); + lights.setElementAt(light, index); + } + + /** + */ + public void resetLights() + { + integrityCheck(); + _resetLights(handle); + lights.removeAllElements(); + } + + /** + * + */ + public static final Hashtable getProperties() + { + Hashtable props = new Hashtable(); + + props.put("supportAntialiasing", new java.lang.Boolean( + _isAASupported(Interface.getHandle()))); + props.put("supportTrueColor", new java.lang.Boolean(Defs.supportTrueColor)); + props.put("supportDithering", new java.lang.Boolean(Defs.supportDithering)); + props.put("supportMipmapping", new java.lang.Boolean(Defs.supportMipmapping)); + props.put("supportPerspectiveCorrection", new java.lang.Boolean(Defs.supportPerspectiveCorrection)); + props.put("supportLocalCameraLighting", new java.lang.Boolean(Defs.supportLocalCameraLighting)); + props.put("maxLights", new java.lang.Integer(Defs.MAX_LIGHTS)); + props.put("maxViewportWidth", new java.lang.Integer(Defs.MAX_VIEWPORT_WIDTH)); + props.put("maxViewportHeight", new java.lang.Integer(Defs.MAX_VIEWPORT_HEIGHT)); + props.put("maxViewportDimension", new java.lang.Integer(Defs.MAX_VIEWPORT_DIMENSION)); + props.put("maxTextureDimension", new java.lang.Integer(Defs.MAX_TEXTURE_DIMENSION)); + props.put("maxSpriteCropDimension", new java.lang.Integer(Defs.MAX_TEXTURE_DIMENSION)); + props.put("numTextureUnits", new java.lang.Integer(Defs.NUM_TEXTURE_UNITS)); + props.put("maxTransformsPerVertex", new java.lang.Integer(Defs.MAX_TRANSFORMS_PER_VERTEX)); + + // Extra properties + props.put("m3gRelease", new java.lang.String("04_wk49")); + + return props; + } + + /** + * + */ + public void setDepthRange(float near, float far) + { + integrityCheck(); + _setDepthRange(handle, near, far); + } + + // M3G 1.1 + + public Camera getCamera(Transform transform) + { + integrityCheck(); + if (transform != null) + { + _getViewTransform(handle, transform.matrix); + } + + return (Camera) Object3D.getInstance(_getCamera(handle)); + } + + public float getDepthRangeFar() + { + integrityCheck(); + return _getDepthRangeFar(handle); + } + + public float getDepthRangeNear() + { + integrityCheck(); + return _getDepthRangeNear(handle); + } + + public Light getLight(int index, Transform transform) + { + integrityCheck(); + if (index < 0 || index >= _getLightCount(handle)) + { + throw new IndexOutOfBoundsException(); + } + + return (Light) Object3D.getInstance(_getLightTransform(handle, + index, + transform != null ? transform.matrix : null)); + } + + public int getLightCount() + { + integrityCheck(); + return _getLightCount(handle); + } + + public java.lang.Object getTarget() + { + return currentTarget; + } + + public int getViewportHeight() + { + integrityCheck(); + return _getViewportHeight(handle); + } + + public int getViewportWidth() + { + integrityCheck(); + return _getViewportWidth(handle); + } + + public int getViewportX() + { + integrityCheck(); + return _getViewportX(handle) - offsetX; + } + + public int getViewportY() + { + integrityCheck(); + return _getViewportY(handle) - offsetY; + } + + public int getHints() + { + return hints; + } + + public boolean isDepthBufferEnabled() + { + return depthEnabled; + } + + // M3G 1.1 getters END + + //------------------------------------------------------------------ + // Private methods + //------------------------------------------------------------------ + + private void integrityCheck() + { + if (iInterface == null) + { + throw new RuntimeException("Graphics3D closed"); + } + if (!iNativeInitialized) + { + // If native interface cannot be initialized we cannot recover from it + if (!initNativePeer()) + { + throw new Error("UI thread not available"); + } + } + } + + /** + * Initializes native peer + * @return true if native interface was succesfully inialized otherwise false + */ + private boolean initNativePeer() + { + if (iNativeInitialized) + { + return true; + } + if (iInterface.isFullyInitialized() && Platform.uiThreadAvailable()) + { + handle = _ctor(iInterface.getHandle()); + _addRef(handle); + + Platform.executeInUIThread( + new M3gRunnable() + { + public void doRun() + { + iIsProperRenderer = _isProperRenderer(); + } + }); + iNativeInitialized = true; + return true; + } + else + { + return false; + } + } + + //------------------------------------------------------------------ + // Native implementation methods + //------------------------------------------------------------------ + private native static int _ctor(int hInterface); + private native static void _addRef(int hObject); + private native static int _addLight(int handle, + int hLight, + byte[] transform); + private native static boolean _bindGraphics(int handle, + int surfaceHandle, + int clipX, int clipY, + int clipW, int clipH, + boolean depth, + int hintBits, + boolean aIsProperRenderer); + private native static void _bindImage(int handle, int imgHandle, boolean depth, int hintBits); + private native static void _releaseGraphics(int handle, + int surfaceHandle, + boolean aIsImageTarget, + boolean aIsProperRenderer); + private native static void _releaseImage(int handle); + private native static void _resetLights(int handle); + private native static void _clear(int handle, int hBackground); + private native static void _render(int handle, + int hVtxBuffer, + int hIdxBuffer, + int hAppearance, + byte[] transform, + int scope); + private native static void _renderNode(int handle, int hNode, byte[] transform); + private native static void _renderWorld(int handle, int hWorld); + private native static void _setCamera(int handle, + int hCamera, + byte[] transform); + private native static void _setViewport(int handle, + int x, int y, + int width, int height); + private native static void _setLight(int handle, + int index, + int hLight, + byte[] transform); + private native static void _setDepthRange(int handle, + float near, + float far); + + // M3G 1.1 + // Maintenance release getters + + private native static void _getViewTransform(int handle, + byte[] transform); + private native static int _getCamera(int handle); + private native static int _getLightTransform(int handle, + int index, + byte[] transform); + private native static int _getLightCount(int handle); + private native static float _getDepthRangeNear(int handle); + private native static float _getDepthRangeFar(int handle); + private native static int _getViewportX(int handle); + private native static int _getViewportY(int handle); + private native static int _getViewportWidth(int handle); + private native static int _getViewportHeight(int handle); + + /* Statistics support, MUST be disabled in official releases! */ + /* + public native static int getStatistics(int[] statistics); + */ + private native static boolean _isAASupported(int handle); + private native static boolean _isProperRenderer(); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/Group.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/Group.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,191 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +import java.util.Vector; + +public class Group extends Node +{ + //------------------------------------------------------------------ + // Instance data + //------------------------------------------------------------------ + + // The child links are duplicated on the Java side for the same + // reason as the other node->node references; see Node.java + + Vector children; + + //------------------------------------------------------------------ + // Constructors + //------------------------------------------------------------------ + + public Group() + { + super(_ctor(Interface.getHandle())); + } + + Group(int handle) + { + super(handle); + int n = _getChildCount(handle); + while (n-- > 0) + { + linkChild((Node) getInstance(_getChild(handle, n))); + } + } + + //------------------------------------------------------------------ + // Public methods + //------------------------------------------------------------------ + + public void addChild(Node child) + { + _addChild(handle, child != null ? child.handle : 0); + if (child != null) + { + linkChild(child); + } + } + + public void removeChild(Node child) + { + if (child != null) + { + _removeChild(handle, child.handle); + detachChild(child); + } + } + + public int getChildCount() + { + return _getChildCount(handle); + } + + public Node getChild(int index) + { + + /* Instead of trying to match the indexing of children on the + * native side, we just call the native getter. This may have + * some performance penalty, but likely not enough to make it + * worth the extra maintenance burden of duplicating the + * native ordering here. */ + + return (Node) getInstance(_getChild(handle, index)); + } + + public boolean pick(int mask, + float ox, float oy, float oz, + float dx, float dy, float dz, + RayIntersection ri) + { + float[] result = RayIntersection.createResult(); + float[] ray = {ox, oy, oz, dx, dy, dz}; + int hIntersected; + + hIntersected = _pick3D(handle, mask, ray, result); + + if (hIntersected != 0) + { + if (ri != null) + { + ri.fill(hIntersected, result); + } + return true; + } + else + { + return false; + } + } + + public boolean pick(int mask, float x, float y, Camera camera, RayIntersection ri) + { + float[] result = RayIntersection.createResult(); + int hIntersected; + + hIntersected = _pick2D(handle, mask, x, y, camera != null ? camera.handle : 0, result); + + if (hIntersected != 0) + { + if (ri != null) + { + ri.fill(hIntersected, result); + } + return true; + } + else + { + return false; + } + } + + //------------------------------------------------------------------ + // Private methods + //------------------------------------------------------------------ + + /** + * Adds a Java-side child link in this Group. + */ + private void linkChild(Node child) + { + if (child == null) + { + throw new Error(); // DEBUG + } + if (children == null) + { + children = new Vector(); + } + children.addElement(child); + child.setParent(this); + } + + /** + * Removes a Java-side child link from this Group. + */ + private void detachChild(Node child) + { + if (children != null) + { + if (children.removeElement(child)) + { + /* If no children remain, we delete the array to free some + * memory. If a Group is frequently cleared and + * re-populated, this should be covered by the free list + * used by most VM implementations without causing + * significant performance degradation. */ + if (children.isEmpty()) + { + children = null; + } + + child.setParent(null); + } + } + } + + // Native methods + private static native int _ctor(int hInterface); + private static native void _addChild(int handle, int hNode); + private static native void _removeChild(int handle, int hNode); + private static native int _getChildCount(int handle); + private static native int _getChild(int handle, int index); + private static native int _pick3D(int handle, int mask, float[] ray, float[] result); + private static native int _pick2D(int handle, int mask, float x, float y, int hCamera, float[] result); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/Image2D.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/Image2D.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,232 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +import javax.microedition.lcdui.Image; +import org.eclipse.swt.graphics.*; +import org.eclipse.swt.internal.qt.graphics.*; +import com.nokia.mj.impl.nokialcdui.LCDUIInvoker; +import org.eclipse.swt.widgets.Internal_PackageSupport; + +public class Image2D extends Object3D +{ + //------------------------------------------------------------------ + // Static data + //------------------------------------------------------------------ + + public static final int ALPHA = 96; + public static final int LUMINANCE = 97; + public static final int LUMINANCE_ALPHA = 98; + public static final int RGB = 99; + public static final int RGBA = 100; + + static int tempHandle; + + //------------------------------------------------------------------ + // Constructor(s) + //------------------------------------------------------------------ + + public Image2D(int format, Object image) + { + // If image is instance of lcdui.Image then checkAndCreate + // builds the image and returns the handle to native image, + // otherwise throws exception Done this way because class of + // image cannot be checked befor calling super() + super(Image2D.checkAndCreate(format, image)); + } + + public Image2D(int format, int width, int height, byte[] image) + { + super(createHandle(format, width, height, image)); + } + + public Image2D(int format, + int width, int height, + byte[] image, + byte[] palette) + { + super(createHandle(format, width, height, image, palette)); + } + + public Image2D(int format, int width, int height) + { + super(createHandle(format, width, height)); + } + + Image2D(int handle) + { + super(handle); + } + + //------------------------------------------------------------------ + // Public methods + //------------------------------------------------------------------ + + public void set(int x, int y, int width, int height, byte[] image) + { + if (image == null) + { + throw new NullPointerException(); + } + _set(handle, x, y, width, height, image); + } + + public boolean isMutable() + { + return _isMutable(handle); + } + + public int getFormat() + { + return _getFormat(handle); + } + + public int getWidth() + { + return _getWidth(handle); + } + + public int getHeight() + { + return _getHeight(handle); + } + + //------------------------------------------------------------------ + // Private methods + //------------------------------------------------------------------ + + private static int checkAndCreate(int format, Object image) + { + if (image == null) + { + throw new NullPointerException(); + } + if (!(image instanceof javax.microedition.lcdui.Image) && + !(image instanceof org.eclipse.swt.graphics.Image)) + { + throw new IllegalArgumentException(); + } + + final int finalFormat = format; + tempHandle = 0; + + if (image instanceof org.eclipse.swt.graphics.Image) + { + // get internal image + final org.eclipse.swt.internal.qt.graphics.Image cgfxImage = + Internal_GfxPackageSupport.getImage((org.eclipse.swt.graphics.Image)image); + // excute in UI thread + Platform.executeInUIThread( + new M3gRunnable() + { + void doRun() + { + tempHandle = _ctorImage(Interface.getHandle(), finalFormat, cgfxImage.getHandle()); + } + }); + } + else if (image instanceof javax.microedition.lcdui.Image) + { + final org.eclipse.swt.internal.qt.graphics.Image cgfxImage = + Internal_GfxPackageSupport.getImage( + LCDUIInvoker.getEswtImage( (javax.microedition.lcdui.Image)image ) ); + + // excute in UI thread + Platform.executeInUIThread( + new M3gRunnable() + { + void doRun() + { + tempHandle = _ctorImage(Interface.getHandle(), finalFormat, cgfxImage.getHandle()); + } + }); + } + return tempHandle; + } + + //Platform.heuristicGC(); + //ToolkitInvoker invoker = ToolkitInvoker.getToolkitInvoker(); + + // Decide if trueAlpha + //Image i = (Image)image; + //boolean trueAlpha = !(i.isMutable() && format == ALPHA); + + //Platform.sync((Image) image); + +// Platform.getUIThread().syncExec( +// new Runnable() { +// public void run() { +// tempHandle = _ctorImage(/*Interface.getEventSourceHandle(),*/ Interface.getHandle(), finalFormat, /*invoker.imageGetHandle(image)*/ 5); +// } +// }); +// return tempHandle; + + + private static int createHandle(int format, int width, int height, byte[] image) + { + Platform.heuristicGC(); + return _ctorSizePixels(Interface.getHandle(), + format, + width, height, + image); + } + + private static int createHandle(int format, + int width, int height, + byte[] image, + byte[] palette) + { + Platform.heuristicGC(); + return _ctorSizePixelsPalette(Interface.getHandle(), + format, + width, height, + image, palette); + } + + private static int createHandle(int format, int width, int height) + { + Platform.heuristicGC(); + return _ctorSize(Interface.getHandle(), format, width, height); + } + + // Native methods + private native static int _ctorImage(/*int eventSourceHandle,*/ + int hInterface, + int format, + int imageHandle); + private native static int _ctorSizePixels(int hInterface, + int format, + int width, int height, + byte[] image); + private native static int _ctorSizePixelsPalette(int hInterface, + int format, + int width, int height, + byte[] image, + byte[] palette); + private native static int _ctorSize(int hInterface, + int format, + int width, int height); + + private native static void _set(int handle, int x, int y, int width, + int height, byte[] image); + private native static boolean _isMutable(int handle); + private native static int _getFormat(int handle); + private native static int _getWidth(int handle); + private native static int _getHeight(int handle); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/IndexBuffer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/IndexBuffer.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,33 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +public abstract class IndexBuffer extends Object3D +{ + /** + * Only a package private constructor exists for this class. + */ + IndexBuffer(int handle) + { + super(handle); + } + + public abstract int getIndexCount(); + public abstract void getIndices(int[] indices); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/Interface.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/Interface.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,403 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +package javax.microedition.m3g; + +import java.lang.ref.WeakReference; +import java.util.Hashtable; +import org.eclipse.swt.widgets.Display; +//#ifdef RD_JAVA_OMJ +import com.nokia.mj.impl.rt.support.Finalizer; +//#endif // RD_JAVA_OMJ + +/** + * M3G interface object. An interface is automatically created for + * each MIDlet using the 3D API to keep track of Java-side object + * lifetimes etc. + */ +class Interface +{ + //------------------------------------------------------------------ + // Static data + //------------------------------------------------------------------ + + // Common class enumeration for Java and native code + + private static final int ANIMATION_CONTROLLER = 0x01; + private static final int ANIMATION_TRACK = 0x02; + private static final int APPEARANCE = 0x03; + private static final int BACKGROUND = 0x04; + private static final int CAMERA = 0x05; + private static final int COMPOSITING_MODE = 0x06; + private static final int FOG = 0x07; + private static final int GROUP = 0x08; + private static final int IMAGE_2D = 0x09; + private static final int INDEX_BUFFER = 0x0A; + private static final int KEYFRAME_SEQUENCE = 0x0B; + private static final int LIGHT = 0x0C; + private static final int LOADER = 0x0D; + private static final int MATERIAL = 0x0E; + private static final int MESH = 0x0F; + private static final int MORPHING_MESH = 0x10; + private static final int POLYGON_MODE = 0x11; + private static final int RENDER_CONTEXT = 0x12; + private static final int SKINNED_MESH = 0x13; + private static final int SPRITE_3D = 0x14; + private static final int TEXTURE_2D = 0x15; + private static final int VERTEX_ARRAY = 0x16; + private static final int VERTEX_BUFFER = 0x17; + private static final int WORLD = 0x18; + + // Once created, the interface singleton currently remains in + // memory until VM exit. By using a WeakReference here, with hard + // references stored in each object, it could be GC'd when no more + // objects exist, but that probably isn't worth the extra memory + // overhead. + + //private static Hashtable s_instances = new Hashtable(); + private static Interface instance = null; + + //------------------------------------------------------------------ + // Instance data + //------------------------------------------------------------------ + + /** + * Handle of the native interface object. + */ + private int handle; + + /** + * Global handle-to-Object3D map used to both find the Java + * counterparts of objects returned from the native methods, and + * keep certain objects from being garbage collected. + */ + private final Hashtable liveObjects = new Hashtable(); + + /** + * Flag for shutdown signal + */ + private boolean iShutdown = false; + + /** + * Flag for native peer init state + */ + private boolean iNativeInitialized = false; + + +//#ifdef RD_JAVA_OMJ + private Finalizer mFinalizer; +//#endif // RD_JAVA_OMJ + + //------------------------------------------------------------------ + // Constructors + //------------------------------------------------------------------ + + private Interface() + { + + // Contruct native peer + initNativePeer(); + +//#ifdef RD_JAVA_OMJ + mFinalizer = new Finalizer() + { + public void finalizeImpl() + { + doFinalize(); + } + }; +//#else // RD_JAVA_OMJ +// Platform.registerFinalizer(this); +//#endif // RD_JAVA_OMJ + } + + //------------------------------------------------------------------ + // Package methods + //------------------------------------------------------------------ + + /** + * Returns the M3G interface instance for the current MIDlet. + */ + static final Interface getInstance() + { + if (instance == null) + { + instance = new Interface(); + } + return instance; + } + + /** + * Returns the native handle of the current Interface instance. + */ + static final int getHandle() + { + getInstance().integrityCheck(); + return getInstance().handle; + } + + /** + * Registers an Object3D with this interface. The object is added + * to the global handle-to-object map, and the native finalization + * callback is set up. The handle of the object must already be + * set at this point! + */ + static final void register(Object3D obj) + { + Platform.registerFinalizer(obj); + getInstance().liveObjects.put(new Integer(obj.handle), + new WeakReference(obj)); + } + + static final void register(Loader obj) + { + Platform.registerFinalizer(obj); + getInstance().liveObjects.put(new Integer(obj.handle), + new WeakReference(obj)); + } + + /** + * Finds an Object3D in the global handle-to-object map. Also + * removes dead objects (that is, null references) from the map + * upon encountering them. + */ + static final Object3D findObject(int handle) + { + Interface self = getInstance(); + Integer iHandle = new Integer(handle); + Object ref = self.liveObjects.get(iHandle); + + if (ref != null) + { + Object3D obj = (Object3D)((WeakReference)ref).get(); + if (obj == null) + { + self.liveObjects.remove(iHandle); + } + return obj; + } + else + { + return null; + } + } + + /** + * Returns the Java object representing a native object, or + * creates a new proxy/peer if one doesn't exist yet. + */ + static final Object3D getObjectInstance(int handle) + { + + // A zero handle equals null + + if (handle == 0) + { + return null; + } + + // Then try to find an existing Java representative for the + // object + + Object3D obj = findObject(handle); + if (obj != null) + { + return obj; + } + + // Not found, create a new Java object. Note that only + // non-abstract classes can possibly be returned. + + switch (_getClassID(handle)) + { + case ANIMATION_CONTROLLER: + return new AnimationController(handle); + case ANIMATION_TRACK: + return new AnimationTrack(handle); + case APPEARANCE: + return new Appearance(handle); + case BACKGROUND: + return new Background(handle); + case CAMERA: + return new Camera(handle); + case COMPOSITING_MODE: + return new CompositingMode(handle); + case FOG: + return new Fog(handle); + case GROUP: + return new Group(handle); + case IMAGE_2D: + return new Image2D(handle); + case INDEX_BUFFER: + return new TriangleStripArray(handle); + case KEYFRAME_SEQUENCE: + return new KeyframeSequence(handle); + case LIGHT: + return new Light(handle); + //case LOADER: + case MATERIAL: + return new Material(handle); + case MESH: + return new Mesh(handle); + case MORPHING_MESH: + return new MorphingMesh(handle); + case POLYGON_MODE: + return new PolygonMode(handle); + //case RENDER_CONTEXT: + case SKINNED_MESH: + return new SkinnedMesh(handle); + case SPRITE_3D: + return new Sprite3D(handle); + case TEXTURE_2D: + return new Texture2D(handle); + case VERTEX_ARRAY: + return new VertexArray(handle); + case VERTEX_BUFFER: + return new VertexBuffer(handle); + case WORLD: + return new World(handle); + default: + throw new Error(); + } + } + + /** + * Forces removal of an object from the handle-to-object map. + */ + static final void deregister(Object3D obj, Interface self) + { + self.liveObjects.remove(new Integer(obj.handle)); + if (self.liveObjects.isEmpty() && self.iShutdown) + { + self.registeredFinalize(); + } + } + + /** + * Forces removal of an object from the handle-to-object map. + */ + static final void deregister(Loader obj, Interface self) + { + self.liveObjects.remove(new Integer(obj.handle)); + if (self.liveObjects.isEmpty() && self.iShutdown) + { + self.registeredFinalize(); + } + } + + /** + * Sets shutdown indication flag. Actual native + * cleanup occurs when liveObjects count is zero + */ + void signalShutdown() + { + iShutdown = true; + } + + /** + * Gets the state of this interface + * @return true if interface is fully constructed, otherwise false + */ + boolean isFullyInitialized() + { + return iNativeInitialized; + } + + //------------------------------------------------------------------ + // Private methods + //------------------------------------------------------------------ + + /** + * Checks the status of the native interface + */ + private void integrityCheck() + { + if (!iNativeInitialized) + { + // If native interface cannot be initialized we cannot recover from it + if (!initNativePeer()) + { + throw new Error("UI thread not available"); + } + } + } + + /** + * Initializes native peer + * @return true if native interface was succesfully inialized otherwise false + */ + private boolean initNativePeer() + { + if (iNativeInitialized) + { + return true; + } + if (Platform.uiThreadAvailable()) + { + Platform.executeInUIThread( + new M3gRunnable() + { + public void doRun() + { + handle = _ctor(); + } + }); + iNativeInitialized = true; + return true; + } + else + { + return false; + } + } + + +//#ifdef RD_JAVA_OMJ + private void doFinalize() + { + if (mFinalizer != null) + { + registeredFinalize(); + mFinalizer = null; + } + } +//#endif // RD_JAVA_OMJ + + // Native finalization hook, for Symbian only + final private void registeredFinalize() + { + if (Interface.instance != null) + { + // Finalize M3G interface + Platform.executeInUIThread( + new M3gRunnable() + { + public void doRun() + { + Platform.finalizeInterface(handle); + } + }); + Interface.instance = null; + } + } + + // Native constructor + private static native int _ctor(); + + // Native class ID resolver + private static native int _getClassID(int hObject); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/KeyframeSequence.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/KeyframeSequence.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,150 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +public class KeyframeSequence extends Object3D +{ + //------------------------------------------------------------------ + // Static data + //------------------------------------------------------------------ + + public static final int LINEAR = 176; + public static final int SLERP = 177; + public static final int SPLINE = 178; + public static final int SQUAD = 179; + public static final int STEP = 180; + + public static final int CONSTANT = 192; + public static final int LOOP = 193; + + //------------------------------------------------------------------ + // Constructor + //------------------------------------------------------------------ + + public KeyframeSequence(int numKeyframes, + int numComponents, + int interpolation) + { + super(_ctor(Interface.getHandle(), + numKeyframes, + numComponents, + interpolation)); + } + + /** + */ + KeyframeSequence(int handle) + { + super(handle); + } + + //------------------------------------------------------------------ + // Public methods + //------------------------------------------------------------------ + + public void setKeyframe(int index, int time, float[] value) + { + _setKeyframe(handle, index, time, value); + } + + public void setValidRange(int first, int last) + { + _setValidRange(handle, first, last); + } + + public void setDuration(int duration) + { + _setDuration(handle, duration); + } + + public int getDuration() + { + return _getDuration(handle); + } + + /** + */ + public void setRepeatMode(int mode) + { + _setRepeatMode(handle, mode); + } + + /** + */ + public int getRepeatMode() + { + return _getRepeatMode(handle); + } + + // M3G 1.1 Maintenance release getters + + public int getComponentCount() + { + return _getComponentCount(handle); + } + + public int getInterpolationType() + { + return _getInterpolationType(handle); + } + + public int getKeyframe(int index, float[] value) + { + return _getKeyframe(handle, index, value); + } + + public int getKeyframeCount() + { + return _getKeyframeCount(handle); + } + + public int getValidRangeFirst() + { + return _getValidRangeFirst(handle); + } + + public int getValidRangeLast() + { + return _getValidRangeLast(handle); + } + + + //------------------------------------------------------------------ + // Private methods + //------------------------------------------------------------------ + + private native static int _ctor(int hInterface, + int numKeyframes, + int numComponents, + int interpolation); + private native static void _setValidRange(int handle, int first, int last); + private native static void _setKeyframe(int handle, int index, int time, float[] value); + private native static void _setDuration(int handle, int duration); + private native static int _getDuration(int handle); + private native static void _setRepeatMode(int handle, int mode); + private native static int _getRepeatMode(int handle); + + // M3G 1.1 Maintenance release getters + private native static int _getComponentCount(int handle); + private native static int _getInterpolationType(int handle); + private native static int _getKeyframe(int handle, int index, float[] value); + private native static int _getKeyframeCount(int handle); + private native static int _getValidRangeFirst(int handle); + private native static int _getValidRangeLast(int handle); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/Light.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/Light.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,124 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +public class Light extends Node +{ + public static final int AMBIENT = 128; + public static final int DIRECTIONAL = 129; + public static final int OMNI = 130; + public static final int SPOT = 131; + + public Light() + { + super(_ctor(Interface.getHandle())); + } + + /** + */ + Light(int handle) + { + super(handle); + } + + public void setIntensity(float intensity) + { + _setIntensity(handle, intensity); + } + + public float getIntensity() + { + return _getIntensity(handle); + } + + public void setColor(int RGB) + { + _setColor(handle, RGB); + } + + public int getColor() + { + return _getColor(handle); + } + + public void setMode(int mode) + { + _setMode(handle, mode); + } + + public int getMode() + { + return _getMode(handle); + } + + public void setSpotAngle(float angle) + { + _setSpotAngle(handle, angle); + } + + public float getSpotAngle() + { + return _getSpotAngle(handle); + } + + public void setSpotExponent(float exponent) + { + _setSpotExponent(handle, exponent); + } + + public float getSpotExponent() + { + return _getSpotExponent(handle); + } + + public void setAttenuation(float constant, float linear, float quadratic) + { + _setAttenuation(handle, constant, linear, quadratic); + } + + public float getConstantAttenuation() + { + return _getAttenuation(handle, Defs.GET_CONSTANT); + } + + public float getLinearAttenuation() + { + return _getAttenuation(handle, Defs.GET_LINEAR); + } + + public float getQuadraticAttenuation() + { + return _getAttenuation(handle, Defs.GET_QUADRATIC); + } + + // Native methods + private static native int _ctor(int hInterface); + private static native void _setIntensity(int handle, float intensity); + private static native float _getIntensity(int handle); + private static native void _setColor(int handle, int RGB); + private static native int _getColor(int handle); + private static native void _setMode(int handle, int mode); + private static native int _getMode(int handle); + private static native void _setSpotAngle(int handle, float angle); + private static native float _getSpotAngle(int handle); + private static native void _setSpotExponent(int handle, float exponent); + private static native float _getSpotExponent(int handle); + private static native void _setAttenuation(int handle, float constant, float linear, float quadratic); + private static native float _getAttenuation(int handle, int type); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/Loader.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/Loader.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,1123 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +import java.io.*; +import java.io.IOException; + +import java.util.Vector; +import java.util.Hashtable; + +import javax.microedition.io.*; +import javax.microedition.lcdui.Image; +import javax.microedition.io.Connector; +import javax.microedition.io.HttpConnection; +//#ifdef RD_JAVA_OMJ +import com.nokia.mj.impl.rt.support.Finalizer; +//#endif // RD_JAVA_OMJ + +public class Loader +{ + // M3G + static final byte[] M3G_FILE_IDENTIFIER = + { + -85, 74, 83, 82, 49, 56, 52, -69, 13, 10, 26, 10 + }; + // PNG + static final byte[] PNG_FILE_IDENTIFIER = + { + -119, 80, 78, 71, 13, 10, 26, 10 + }; + static final int PNG_IHDR = ((73 << 24) + (72 << 16) + (68 << 8) + 82); + static final int PNG_tRNS = ((116 << 24) + (82 << 16) + (78 << 8) + 83); + static final int PNG_IDAT = ((73 << 24) + (68 << 16) + (65 << 8) + 84); + + // JPEG + static final byte[] JPEG_FILE_IDENTIFIER = + { + -1, -40 + }; + static final int JPEG_JFIF = ((74 << 24) + (70 << 16) + (73 << 8) + 70); + // Bytes before colour info in a frame header 'SOFn': + // length (2 bytes), precision (1 byte), image height & width (4 bytes) + static final int JPEG_SOFn_DELTA = 7; + static final int JPEG_INVALID_COLOUR_FORMAT = -1; + + // File identifier types + private static final int INVALID_HEADER_TYPE = -1; + private static final int M3G_TYPE = 0; + private static final int PNG_TYPE = 1; + private static final int JPEG_TYPE = 2; + + // Misc. + private static final int MAX_IDENTIFIER_LENGTH = M3G_FILE_IDENTIFIER.length; + + // Initial buffer length for the header + private static final int AVG_HEADER_SEC_LENGTH = 64; + + // Initial buffer length for the xref section + private static final int AVG_XREF_SEC_LENGTH = 128; + + // Instance specific + int handle; + + private Vector iLoadedObjects = new Vector(); + private Vector iFileHistory = new Vector(); + private String iResourceName = null; + private String iParentResourceName = null; + + private int iTotalFileSize = 0; + private int iBytesRead = M3G_FILE_IDENTIFIER.length; + + private byte[] iStreamData = null; + private int iStreamOffset = 0; + + private Interface iInterface; + +//#ifdef RD_JAVA_OMJ + private Finalizer mFinalizer = new Finalizer() + { + public void finalizeImpl() + { + doFinalize(); + } + }; +//#endif // RD_JAVA_OMJ + + /** + * Default ctor + */ + private Loader() + { + iInterface = Interface.getInstance(); + } + + /** + * Ctor + * @param aFileHistory File storage + * @param aParentResourceName Resource name + */ + private Loader(Vector aFileHistory, String aParentResourceName) + { + iParentResourceName = aParentResourceName; + iFileHistory = aFileHistory; + iInterface = Interface.getInstance(); + } + + public static Object3D[] load(String name) throws IOException + { + if (name == null) + { + throw new NullPointerException(); + } + + try + { + return (new Loader()).loadFromStream(name); + } + catch (SecurityException e) + { + throw e; + } + catch (IOException e) + { + throw e; + } + catch (Exception e) + { + throw new IOException("Load error " + e); + } + } + + public static Object3D[] load(byte[] data, int offset) throws IOException + { + if (data == null) + { + throw new NullPointerException(); + } + + if (offset < 0 || offset >= data.length) + { + throw new IndexOutOfBoundsException(); + } + try + { + return (new Loader()).loadFromByteArray(data, offset); + } + catch (SecurityException e) + { + throw e; + } + catch (IOException e) + { + throw e; + } + catch (Exception e) + { + throw new IOException("Load error " + e); + } + } + + /** + * @see javax.microedition.m3g.Loader#load(String) + */ + private Object3D[] loadFromStream(String aName) throws IOException + { + if (aName == null) + { + throw new NullPointerException(); + } + + if (inFileHistory(aName)) + { + throw new IOException("Reference loop detected."); + } + iResourceName = aName; + iFileHistory.addElement(aName); + PeekInputStream stream = new PeekInputStream( + getInputStream(aName), MAX_IDENTIFIER_LENGTH); + // png, jpeg or m3g + int type = getIdentifierType(stream); + stream.rewind(); + iStreamData = null; + iStreamOffset = 0; + + Object3D[] objects; + try + { + objects = doLoad(stream, type); + } + finally + { + try + { + stream.close(); + stream = null; + } + catch (Exception e) {} + } + // Finally, remove file from history + iFileHistory.removeElement(aName); + return objects; + } + + /** + * @see javax.microedition.m3g.Loader#load(byte[], int) + */ + private Object3D[] loadFromByteArray(byte[] aData, int aOffset) throws IOException + { + if (aData == null) + { + throw new NullPointerException("Resource byte array is null."); + } + int type = getIdentifierType(aData, aOffset); + ByteArrayInputStream stream = + new ByteArrayInputStream(aData, aOffset, aData.length - aOffset); + iStreamData = aData; + iStreamOffset = aOffset; + iResourceName = "ByteArray"; + + Object3D[] objects; + try + { + objects = doLoad(stream, type); + } + finally + { + try + { + stream.close(); + stream = null; + } + catch (Exception e) {} + } + return objects; + } + + /** + * Dispatcher + * @param aStream Source stream + * @param aType Resource type + */ + private Object3D[] doLoad(InputStream aStream, int aType) throws IOException + { + if (aType == M3G_TYPE) + { + return loadM3G(aStream); + } + else if (aType == PNG_TYPE) + { + return loadPNG(aStream); + } + else if (aType == JPEG_TYPE) + { + return loadJPEG(aStream); + } + throw new IOException("File not recognized."); + } + + /** + * PNG resource loader + * @param aStream Resource stream + * @return An array of newly created Object3D instances + */ + private Object3D[] loadPNG(InputStream aStream) throws IOException + { + int format = Image2D.RGB; + DataInputStream in = new DataInputStream(aStream); + + // Scan chuncs that have effect on Image2D format + in.skip(PNG_FILE_IDENTIFIER.length); + + try + { + while (true) + { + int length = in.readInt(); + int type = in.readInt(); + // IHDR + if (type == PNG_IHDR) + { + in.skip(9); + int colourType = in.readUnsignedByte(); + length -= 10; + + switch (colourType) + { + case 0: + format = Image2D.LUMINANCE; + break; + case 2: + format = Image2D.RGB; + break; + case 3: + format = Image2D.RGB; + break; + case 4: + format = Image2D.LUMINANCE_ALPHA; + break; + case 6: + format = Image2D.RGBA; + break; + } + } + // tRNS + if (type == PNG_tRNS) + { + switch (format) + { + case Image2D.LUMINANCE: + format = Image2D.LUMINANCE_ALPHA; + break; + case Image2D.RGB: + format = Image2D.RGBA; + break; + } + } + // IDAT + if (type == PNG_IDAT) + { + break; + } + + in.skip(length + 4); + } + } + // EOF + catch (Exception e) + { + } + // Close the data stream + try + { + in.close(); + in = null; + } + catch (Exception e) {} + return buildImage2D(format); + } + + /** + * JPEG (with the same detailed definitions about the JPEG image format as defined in the + * JSR 118 MIDP 2.1 specification for LCDUI) MUST be supported by compliant + * implementations as a 2D bitmap image format for the Image2D class using the + * javax.microedition.m3g.Loader class, and for M3G content files referencing bitmap images. + * For colour JPEG images, the pixel format of the returned Image2D object MUST be + * Image2D.RGB and for monochrome JPEG images, the pixel format MUST be + * Image2D.LUMINANCE. + * + * JPEG marker: A two-byte code in which the first byte is 0xFF and the second + * byte is a value between 1 and 0xFE. + * + * A JFIF file uses APP0 (0xe0) marker segments and constrains certain parameters in the frame. + * + * A frame header: + * - 0xff, 'SOFn' + * - length (2 bytes, Hi-Lo) + * - data precision (1 byte) + * - image height (2 bytes, Hi-Lo) + * - image width (2 bytes, Hi-Lo) + * - number of components (1 byte): 1 = grey scaled, 3 = color YCbCr or YIQ, 4 = color CMYK) + * + * @param aStream Resource stream + * @return An array of newly created Object3D instances + */ + private Object3D[] loadJPEG(InputStream aStream) throws IOException + { + int format = JPEG_INVALID_COLOUR_FORMAT; + DataInputStream in = new DataInputStream(aStream); + // Skip file identifier + in.skip(JPEG_FILE_IDENTIFIER.length); + try + { + int marker; + do + { + // Find marker + while (in.readUnsignedByte() != 0xff); + do + { + marker = in.readUnsignedByte(); + } + while (marker == 0xff); + + // Parse marker + switch (marker) + { + // 'SOFn' (Start Of Frame n) + case 0xC0: + case 0xC1: + case 0xC2: + case 0xC3: + case 0xC5: + case 0xC6: + case 0xC7: + case 0xC9: + case 0xCA: + case 0xCB: + case 0xCD: + case 0xCE: + case 0xCF: + // Skip length(2), precicion(1), width(2), height(2) + in.skip(JPEG_SOFn_DELTA); + switch (in.readUnsignedByte()) + { + case 1: + format = Image2D.LUMINANCE; + break; + case 3: + format = Image2D.RGB; + break; + default: + throw new IOException("Unknown JPG format."); + } + break; + // APP0 (0xe0) marker segments and constrains certain parameters in the frame. + case 0xe0: + int length = in.readUnsignedShort(); + if (JPEG_JFIF != in.readInt()) + { + throw new IOException("Not a valid JPG file."); + } + in.skip(length - 4 - 2); + break; + default: + // Skip variable data + in.skip(in.readUnsignedShort() - 2); + break; + } + } + while (format == JPEG_INVALID_COLOUR_FORMAT); + } + catch (Exception e) {} + // Close the data stream + try + { + in.close(); + in = null; + } + catch (Exception e) {} + return buildImage2D(format); + } + + /** + * Image2D builder + * @param aColourFormat Colour format + * @return An array of newly created Object3D instances + */ + private Object3D[] buildImage2D(int aColourFormat) throws IOException + { + InputStream stream; + if (iStreamData == null) + { + stream = getInputStream(iResourceName); + } + else + { + stream = (InputStream) new ByteArrayInputStream( + iStreamData, iStreamOffset, iStreamData.length - iStreamOffset); + } + // Create an image object + Image2D i2d; + try + { + i2d = new Image2D(aColourFormat, Image.createImage(stream)); + } + finally + { + try + { + stream.close(); + } + catch (Exception e) {} + } + return new Object3D[] { i2d }; + } + + + /** + * M3G resource loader + * @param aStream Resource stream + * @return An array of newly created Object3D instances + */ + private Object3D[] loadM3G(InputStream aStream) throws IOException + { + aStream.skip(M3G_FILE_IDENTIFIER.length); + if (aStream instanceof PeekInputStream) + ((PeekInputStream)aStream).increasePeekBuffer(AVG_HEADER_SEC_LENGTH); + + // Read header + int compressionScheme = readByte(aStream); + int totalSectionLength = readUInt32(aStream); + if (aStream instanceof PeekInputStream && totalSectionLength > AVG_HEADER_SEC_LENGTH) + ((PeekInputStream)aStream).increasePeekBuffer(totalSectionLength - AVG_HEADER_SEC_LENGTH); + int uncompressedLength = readUInt32(aStream); + + int objectType = readByte(aStream); + int length = readUInt32(aStream); + + byte vMajor = (byte) readByte(aStream); + byte vMinor = (byte) readByte(aStream); + boolean externalLinks = readBoolean(aStream); + iTotalFileSize = readUInt32(aStream); + int approximateContentSize = readUInt32(aStream); + String authoringField = readString(aStream); + + int checksum = readUInt32(aStream); + + /* Create and register a new native Loader */ + handle = _ctor(Interface.getHandle()); + Interface.register(this); + + if (externalLinks) + { + if (aStream instanceof PeekInputStream) + ((PeekInputStream)aStream).increasePeekBuffer(AVG_XREF_SEC_LENGTH); + loadExternalRefs(aStream); + if (iLoadedObjects.size() > 0) // Load and set external references + { + int[] xRef = new int[iLoadedObjects.size()]; + for (int i = 0; i < xRef.length; i++) + xRef[i] = ((Object3D)iLoadedObjects.elementAt(i)).handle; + _setExternalReferences(handle, xRef); + } + else + { + throw new IOException("No external sections [" + iResourceName + "]."); + } + } + + // Reset stream + if (aStream instanceof PeekInputStream) + ((PeekInputStream)aStream).rewind(); + else if (aStream.markSupported()) + aStream.reset(); // Reset is supported in ByteArrayInputStreams + + int read = 0; + int size = aStream.available(); + + if (size == 0) + { + size = 2048; // start with some size + } + + while (read < iTotalFileSize) + { + if (read + size > iTotalFileSize) + { + size = iTotalFileSize - read; + } + // Use native loader to load objects + byte[] data = new byte[size]; + if (aStream.read(data) == -1) + { + break; + } + read += size; + + size = _decodeData(handle, 0, data); + if (size > 0 && aStream.available() > size) + { + size = aStream.available(); + } + } + if (size != 0 || read != iTotalFileSize) + { + throw new IOException("Invalid file length [" + iResourceName + "]."); + } + + Object3D[] objects = null; + int num = _getLoadedObjects(handle, null); + if (num > 0) + { + int[] obj = new int[num]; + _getLoadedObjects(handle, obj); + objects = new Object3D[num]; + for (int i = 0; i < objects.length; i++) + { + objects[i] = Interface.getObjectInstance(obj[i]); + } + setUserObjects(); + } + return objects; + } + + /** + * + */ + private void setUserObjects() throws IOException + { + int numObjects = _getObjectsWithUserParameters(handle, null); + int[] obj = null; + if (numObjects > 0) + { + obj = new int[numObjects]; + _getObjectsWithUserParameters(handle, obj); + } + for (int i = 0; i < numObjects; i++) + { + int num = _getNumUserParameters(handle, i); + if (num > 0) + { + Hashtable hash = new Hashtable(); + for (int j = 0; j < num; j++) + { + int len = _getUserParameter(handle, i, j, null); + byte[] data = new byte[len]; + int id = _getUserParameter(handle, i, j, data); + if (hash.put(new Integer(id), data) != null) + throw new IOException("Duplicate id in user data [" + iResourceName + "].");; + } + Object3D object = Interface.getObjectInstance(obj[i]); + object.setUserObject(hash); + } + } + } + + /** + * Load external resources + */ + private void loadExternalRefs(InputStream aStream) throws IOException + { + // Check for the end of the aStream or file + int firstByte = readByte(aStream); + if (firstByte == -1 || (iTotalFileSize != 0 && iBytesRead >= iTotalFileSize)) + { + return; + } + + int compressionScheme = firstByte; + + int totalSectionLength = readUInt32(aStream); + iBytesRead += totalSectionLength; + if (aStream instanceof PeekInputStream && totalSectionLength > AVG_XREF_SEC_LENGTH) + ((PeekInputStream)aStream).increasePeekBuffer(totalSectionLength - AVG_XREF_SEC_LENGTH); + int uncompressedLength = readUInt32(aStream); + int expectedCount = totalSectionLength; + + // Decompress data if necessary + CountedInputStream uncompressedStream = null; + if (compressionScheme == 0) + { + uncompressedStream = new CountedInputStream(aStream); + if (uncompressedLength != totalSectionLength - 13) + { + throw new IOException("Section length mismatch [" + iResourceName + "]."); + } + } + else if (compressionScheme == 1) + { + if (uncompressedLength == 0 && totalSectionLength - 13 == 0) + { + uncompressedStream = new CountedInputStream(null); + } + else + { + if (uncompressedLength <= 0 || totalSectionLength - 13 <= 0) + { + throw new IOException("Section length mismatch [" + iResourceName + "]."); + } + byte[] compressed = new byte[(int) totalSectionLength - 13]; + aStream.read(compressed); + + byte[] uncompressed = new byte[(int) uncompressedLength]; + + // zlib decompression + if (!_inflate(compressed, uncompressed)) + { + throw new IOException("Decompression error."); + } + uncompressedStream = new CountedInputStream( + new ByteArrayInputStream(uncompressed)); + } + } + else + { + throw new IOException("Unrecognized compression scheme [" + iResourceName + "]."); + } + + // load all objects in this section + uncompressedStream.resetCounter(); + + while (uncompressedStream.getCounter() < uncompressedLength) + { + iLoadedObjects.addElement(loadObject(uncompressedStream)); + } + + if (uncompressedStream.getCounter() != uncompressedLength) + { + throw new IOException("Section length mismatch [" + iResourceName + "]."); + } + + // read checksum + int checksum = readUInt32(aStream); + } + + private Object3D loadObject(CountedInputStream aStream) throws IOException + { + int objectType = readByte(aStream); + int length = readUInt32(aStream); + + int expectedCount = aStream.getCounter() + length; + Object3D newObject = null; + + if (objectType == 255) + { + String xref = readString(aStream); + newObject = (new Loader(iFileHistory, iResourceName)).loadFromStream(xref)[0]; + } + else + { + throw new IOException("Invalid external section [" + iResourceName + "]."); + } + + if (expectedCount != aStream.getCounter()) + { + throw new IOException("Object length mismatch [" + iResourceName + "]."); + } + + return newObject; + } + + /** + * Read a byte integer from a stream + */ + private static final int readByte(InputStream aStream) throws IOException + { + return aStream.read(); + } + + /** + * Read a boolean from a stream + */ + private static boolean readBoolean(InputStream aStream) throws IOException + { + int b = aStream.read(); + if (b == 0) + { + return false; + } + if (b != 1) + { + throw new IOException("Malformed boolean."); + } + return true; + } + + /** + * Read a unsigned integer from a stream + */ + private static final int readUInt32(InputStream aStream) throws IOException + { + return aStream.read() + + (aStream.read() << 8) + + (aStream.read() << 16) + + (aStream.read() << 24); + } + + /** + * Read a string from a stream + */ + private static String readString(InputStream aStream) throws IOException + { + StringBuffer result = new StringBuffer(); + int i = 0; + for (int c = aStream.read(); c != 0; c = aStream.read()) + { + if ((c & 0x80) == 0) // 0xxxxxxx => 1 byte + { + result.append((char)(c & 0x00FF)); + } + else if ((c & 0xE0) == 0xC0) // 110xxxxx => 2 bytes + { + int c2 = aStream.read(); + if ((c2 & 0xC0) != 0x80) // second byte is not 10yyyyyy + { + throw new IOException("Invalid UTF-8 string."); + } + else // 110xxxxx 10yyyyyy + { + result.append((char)(((c & 0x1F) << 6) | (c2 & 0x3F))); + } + } + else if ((c & 0xF0) == 0xE0) // 1110 xxxx => 3 bytes + { + int c2 = aStream.read(); + int c3 = aStream.read(); + if (((c2 & 0xC0) != 0x80) || // second byte is not 10yyyyyy + ((c3 & 0xC0) != 0x80)) // third byte is not 10zzzzzz + { + throw new IOException("Invalid UTF-8 string."); + } + else // 1110xxxx 10yyyyyy 10zzzzzz + { + result.append((char)(((c & 0x0F) << 12) | + ((c2 & 0x3F) <<6) | + (c3 & 0x3F))); + } + } + else // none of above + { + throw new IOException("Invalid UTF-8 string."); + } + } + + return result.toString(); + } + + /** + * Solve an identifier of the given data + * @param aStream Stream + * @return solved identifier. + */ + private int getIdentifierType(InputStream aStream) throws IOException + { + byte[] data = new byte[MAX_IDENTIFIER_LENGTH]; + aStream.read(data); + return getIdentifierType(data, 0); + } + + /** + * Solve an identifier of the given data + * @param aData Data + * @param aOffset Data offset + * @return solved identifier. + */ + private static int getIdentifierType(byte[] aData, int aOffset) + { + // Try the JPEG/JFIF identifier + if (parseIdentifier(aData, aOffset, JPEG_FILE_IDENTIFIER)) + { + return JPEG_TYPE; + } + // Try the PNG identifier + else if (parseIdentifier(aData, aOffset, PNG_FILE_IDENTIFIER)) + { + return PNG_TYPE; + } + // Try the M3G identifier + else if (parseIdentifier(aData, aOffset, M3G_FILE_IDENTIFIER)) + { + return M3G_TYPE; + } + return INVALID_HEADER_TYPE; + } + + /** + * Parse identifier from a data + * @param aData Source data + * @param aOffset Source data offset + * @param aIdentifier Identifier + * @return true if the data contains the given identifier + */ + private static boolean parseIdentifier(byte[] aData, int aOffset, byte[] aIdentifier) + { + if ((aData.length - aOffset) < aIdentifier.length) + { + return false; + } + for (int index = 0; index < aIdentifier.length; index++) + { + if (aData[index + aOffset] != aIdentifier[index]) + { + return false; + } + } + return true; + } + + /** + * File name storage for preventing multiple referencing + * @param name File name + * @return true if the storage contains the given file name + */ + private boolean inFileHistory(String name) + { + for (int i = 0; i < iFileHistory.size(); i++) + if (((String)iFileHistory.elementAt(i)).equals(name)) + { + return true; + } + return false; + } + + /* + * InputStream-related helper functions + */ + + /** + * Open a HTTP stream and check its MIME type + * @param name Resource name + * @return a http stream and checks the MIME type + */ + private InputStream getHttpInputStream(String name) throws IOException + { + InputConnection ic = (InputConnection)Connector.open(name); + // Content-Type is available for http and https connections + if (ic instanceof HttpConnection) + { + HttpConnection hc = (HttpConnection) ic; + // Check MIME type + String type = hc.getHeaderField("Content-Type"); + if (type != null && + !type.equals("application/m3g") && + !type.equals("image/png") && + !type.equals("image/jpeg")) + { + throw new IOException("Wrong MIME type: " + type + "."); + } + } + + InputStream is; + try + { + is = ic.openInputStream(); + } + finally + { + try + { + ic.close(); + ic = null; + } + catch (Exception e) {} + } + return is; + } + + // returns a stream built from the specified file or URI + private InputStream getInputStream(String name) throws IOException + { + if (name.indexOf(':') != -1) // absolute URI reference + { + return getHttpInputStream(name); + } + + if (name.charAt(0) == '/') // absolute file reference + { + return (new Object()).getClass().getResourceAsStream(name); + } + + if (iParentResourceName == null) + { + throw new IOException("Relative URI."); + } + + String uri = iParentResourceName.substring(0, iParentResourceName.lastIndexOf('/') + 1) + name; + + if (uri.charAt(0) == '/') + { + return (new Object()).getClass().getResourceAsStream(uri); + } + else + { + return getHttpInputStream(uri); + } + } + + class PeekInputStream extends InputStream + { + private int[] iPeekBuffer; + private InputStream iStream; + private int iBuffered; + private int iCounter; + + PeekInputStream(InputStream aStream, int aLength) + { + iStream = aStream; + iPeekBuffer = new int[aLength]; + } + + public int read() throws IOException + { + if (iCounter < iBuffered) + { + return iPeekBuffer[iCounter++]; + } + + int nv = iStream.read(); + + if (iBuffered < iPeekBuffer.length) + { + iPeekBuffer[iBuffered] = nv; + iBuffered++; + } + + iCounter++; + return nv; + } + + public void increasePeekBuffer(int aLength) + { + int[] temp = new int[iPeekBuffer.length + aLength]; + for (int i = 0; i < iBuffered; i++) + temp[i] = iPeekBuffer[i]; + iPeekBuffer = temp; + } + + public int available() throws IOException + { + if (iCounter < iBuffered) + { + return iBuffered - iCounter + iStream.available(); + } + return iStream.available(); + } + + public void close() + { + try + { + iStream.close(); + } + catch (IOException ioe) + { + // Intentionally left empty + } + } + + public void rewind() throws IOException + { + if (iCounter > iBuffered) + { + throw new IOException("Peek buffer overrun."); + } + iCounter = 0; + } + } + + class CountedInputStream extends InputStream + { + private InputStream iStream; + private int iCounter; + + public CountedInputStream(InputStream aStream) + { + iStream = aStream; + resetCounter(); + } + + public int read() throws IOException + { + iCounter++; + return iStream.read(); + } + + public void resetCounter() + { + iCounter = 0; + } + public int getCounter() + { + return iCounter; + } + + public void close() + { + try + { + iStream.close(); + } + catch (IOException ioe) + { + // Intentionally left empty + } + } + + public int available() throws IOException + { + return iStream.available(); + } + } + +//#ifdef RD_JAVA_OMJ + private void doFinalize() + { + if (mFinalizer != null) + { + registeredFinalize(); + mFinalizer = null; + } + } +//#endif // RD_JAVA_OMJ + + // Finalization method for Symbian + final private void registeredFinalize() + { + if (handle != 0) + { + Platform.finalizeObject(handle, iInterface); + iInterface.deregister(this, iInterface); + iInterface = null; + handle = 0; + } + } + + // zlib decompression + private native static boolean _inflate(byte[] data, byte[] buffer); + + // native loader + private native static int _ctor(int handle); + private native static int _decodeData(int handle, int offset, byte[] data); + private native static void _setExternalReferences(int handle, int[] references); + private native static int _getLoadedObjects(int handle, int[] objects); + private native static int _getObjectsWithUserParameters(int handle, int[] objects); + private native static int _getNumUserParameters(int handle, int obj); + private native static int _getUserParameter(int handle, int obj, int index, byte[] data); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/M3gRunnable.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/M3gRunnable.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +/** + * Class that wraps runnable in order to catch and forward + * exceptions that occured when executing in UI thread. + * This class is used only for running native methods in UI thread. + */ +abstract class M3gRunnable implements Runnable +{ + private Throwable e = null; + + /** + * From Runnable interface + */ + public void run() + { + try + { + doRun(); + } + catch (Throwable t) + { + e = t; + } + } + + /** + * Checks for possible exceptions and errors and throws them forward. + * Only unchecked exceptions and errors are thrown as only checked + * exception that m3gcore may throw comes from loader which is not + * executed in UI thread + * + * @throws RuntimeException + * @throws Error + */ + public void checkAndThrow() + { + if (e == null) + { + return; + } + if (e instanceof RuntimeException) + { + throw(RuntimeException)e; + } + else if (e instanceof Error) + { + throw(Error)e; + } + } + + /** + * Method to be implemented for the UI thead execution + */ + abstract void doRun(); +} \ No newline at end of file diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/Material.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/Material.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,93 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +public class Material extends Object3D +{ + //------------------------------------------------------------------ + // Static data + //------------------------------------------------------------------ + + public static final int AMBIENT = 1024; + public static final int DIFFUSE = 2048; + public static final int EMISSIVE = 4096; + public static final int SPECULAR = 8192; + + //------------------------------------------------------------------ + // Constructor(s) + //------------------------------------------------------------------ + + public Material() + { + super(_ctor(Interface.getHandle())); + } + + /** + */ + Material(int handle) + { + super(handle); + } + + //------------------------------------------------------------------ + // Public methods + //------------------------------------------------------------------ + + public void setColor(int target, int ARGB) + { + _setColor(handle, target, ARGB); + } + + public int getColor(int target) + { + return _getColor(handle, target); + } + + public void setShininess(float shininess) + { + _setShininess(handle, shininess); + } + + public float getShininess() + { + return _getShininess(handle); + } + + public void setVertexColorTrackingEnable(boolean enable) + { + _setVertexColorTrackingEnable(handle, enable); + } + + public boolean isVertexColorTrackingEnabled() + { + return _isVertexColorTrackingEnabled(handle); + } + + //------------------------------------------------------------------ + // Private methods + //------------------------------------------------------------------ + + private native static int _ctor(int hInstance); + private native static void _setColor(int handle, int target, int ARGB); + private native static int _getColor(int handle, int target); + private native static void _setShininess(int handle, float shininess); + private native static float _getShininess(int handle); + private native static void _setVertexColorTrackingEnable(int handle, boolean enable); + private native static boolean _isVertexColorTrackingEnabled(int handle); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/Mesh.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/Mesh.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,235 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +public class Mesh extends Node +{ + //------------------------------------------------------------------ + // Instance data + //------------------------------------------------------------------ + + private VertexBuffer vertices; + private Appearance[] appearances; + private IndexBuffer[] triangles; + + static private IndexBuffer[] tempTrianglesArray; + static private Appearance[] tempAppearanceArray; + + static private IndexBuffer tempTriangles; + static private Appearance tempAppearance; + + //------------------------------------------------------------------ + // Constructor(s) + //------------------------------------------------------------------ + + Mesh(int handle) + { + super(handle); + updateReferences(); + } + + public Mesh(VertexBuffer vertices, + IndexBuffer[] triangles, + Appearance[] appearances) + { + super(createHandle(vertices, triangles, appearances)); + updateReferences(); + } + + public Mesh(VertexBuffer vertices, + IndexBuffer triangles, + Appearance appearance) + { + super(createHandle(vertices, triangles, appearance)); + updateReferences(); + } + + //------------------------------------------------------------------ + // Public methods + //------------------------------------------------------------------ + + public void setAppearance(int index, Appearance appearance) + { + _setAppearance(handle, index, appearance != null ? appearance.handle : 0); + appearances[index] = appearance; + } + + public Appearance getAppearance(int index) + { + return appearances[index]; + } + + public IndexBuffer getIndexBuffer(int index) + { + return triangles[index]; + } + + public VertexBuffer getVertexBuffer() + { + return vertices; + } + + public int getSubmeshCount() + { + return _getSubmeshCount(handle); + } + + //------------------------------------------------------------------ + // Private methods + //------------------------------------------------------------------ + + static void verifyParams(VertexBuffer vertices, + IndexBuffer[] triangles, + Appearance[] appearances) + { + if (vertices == null || triangles == null) + { + throw new NullPointerException(); + } + if (triangles.length == 0 + || appearances != null && appearances.length < triangles.length) + { + throw new IllegalArgumentException(); + } + if (triangles.length == 0) + { + throw new IllegalArgumentException(); + } + for (int i = 0; i < triangles.length; ++i) + { + if (triangles[i] == null) + { + throw new NullPointerException(); + } + } + } + + static void verifyParams(VertexBuffer vertices, + IndexBuffer triangles) + { + if (vertices == null || triangles == null) + { + throw new NullPointerException(); + } + } + + void updateReferences() + { + triangles = new IndexBuffer[_getSubmeshCount(handle)]; + appearances = new Appearance[triangles.length]; + + vertices = (VertexBuffer)getInstance(_getVertexBuffer(handle)); + + for (int i = 0; i < triangles.length; i++) + { + triangles[i] = (IndexBuffer)getInstance(_getIndexBuffer(handle, i)); + appearances[i] = (Appearance)getInstance(_getAppearance(handle, i)); + } + } + + static int createHandle(VertexBuffer vertices, + IndexBuffer[] triangles, + Appearance[] appearances) + { + + tempTrianglesArray = triangles; + tempAppearanceArray = appearances; + + // Verify parameters + verifyParams(vertices, triangles, appearances); + + // Init the native side + int[] hTriangles = new int[triangles.length]; + int[] hAppearances = null; + + if (appearances != null) + { + hAppearances = new int[appearances.length]; + } + + for (int i = 0; i < triangles.length; i++) + { + hTriangles[i] = triangles[i].handle; + + if (appearances != null) + { + hAppearances[i] = appearances[i] != null ? appearances[i].handle : 0; + } + } + + int ret = _ctor(Interface.getHandle(), + vertices.handle, + hTriangles, + hAppearances); + + + tempTrianglesArray = null; + tempAppearanceArray = null; + + return ret; + + } + + static int createHandle(VertexBuffer vertices, + IndexBuffer triangles, + Appearance appearance) + { + + tempTriangles = triangles; + tempAppearance = appearance; + + verifyParams(vertices, triangles); + + // Init the native side + int[] hTriangles = new int[1]; + int[] hAppearances = null; + + hTriangles[0] = triangles.handle; + + if (appearance != null) + { + hAppearances = new int[1]; + hAppearances[0] = appearance.handle; + } + + int ret = _ctor(Interface.getHandle(), + vertices.handle, + hTriangles, + hAppearances); + + + tempTriangles = null; + tempAppearance = null; + + + return ret; + + } + + // Native methods + private static native int _ctor(int hInstance, + int hVertices, + int[] hTriangles, + int[] hAppearances); + private static native void _setAppearance(int handle, int index, int hAppearance); + private static native int _getAppearance(int handle, int index); + private static native int _getIndexBuffer(int handle, int index); + private static native int _getVertexBuffer(int handle); + private static native int _getSubmeshCount(int handle); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/MorphingMesh.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/MorphingMesh.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,199 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +public class MorphingMesh extends Mesh +{ + //------------------------------------------------------------------ + // Instance data + //------------------------------------------------------------------ + + private VertexBuffer[] targets; + + static private IndexBuffer[] tempTrianglesArray; + static private Appearance[] tempAppearanceArray; + + static private IndexBuffer tempTriangles; + static private Appearance tempAppearance; + + //------------------------------------------------------------------ + // Constructor(s) + //------------------------------------------------------------------ + + public MorphingMesh( + VertexBuffer base, + VertexBuffer[] targets, + IndexBuffer triangles, + Appearance appearance) + { + super(createHandle(base, targets, triangles, appearance)); + this.targets = new VertexBuffer[targets.length]; + System.arraycopy(targets, 0, this.targets, 0, targets.length); + } + + public MorphingMesh( + VertexBuffer base, + VertexBuffer[] targets, + IndexBuffer[] triangles, + Appearance[] appearances) + { + super(createHandle(base, targets, triangles, appearances)); + this.targets = new VertexBuffer[targets.length]; + System.arraycopy(targets, 0, this.targets, 0, targets.length); + } + + /** + */ + MorphingMesh(int handle) + { + super(handle); + targets = new VertexBuffer[_getMorphTargetCount(handle)]; + for (int i = 0; i < targets.length; i++) + { + targets[i] = (VertexBuffer)getInstance(_getMorphTarget(handle, i)); + } + } + + public VertexBuffer getMorphTarget(int index) + { + return targets[index]; + } + + public int getMorphTargetCount() + { + return _getMorphTargetCount(handle); + } + + public void setWeights(float[] weights) + { + _setWeights(handle, weights); + } + + public void getWeights(float[] weights) + { + _getWeights(handle, weights); + } + + //------------------------------------------------------------------ + // Private methods + //------------------------------------------------------------------ + + static int createHandle(VertexBuffer base, + VertexBuffer[] targets, + IndexBuffer triangles, + Appearance appearance) + { + + tempTriangles = triangles; + tempAppearance = appearance; + + verifyParams(base, triangles); + + int[] hTargets = new int[targets.length]; + int[] hTriangles = null; + int[] hAppearances = null; + + for (int i = 0; i < targets.length; i++) + { + hTargets[i] = targets[i].handle; + } + + hTriangles = new int[1]; + hTriangles[0] = triangles.handle; + + if (appearance != null) + { + hAppearances = new int[1]; + hAppearances[0] = appearance.handle; + } + + int ret = _ctor(Interface.getHandle(), + base.handle, + hTargets, + hTriangles, + hAppearances); + + tempTriangles = null; + tempAppearance = null; + + return ret; + } + + static int createHandle(VertexBuffer base, + VertexBuffer[] targets, + IndexBuffer[] triangles, + Appearance[] appearances) + { + + tempTrianglesArray = triangles; + tempAppearanceArray = appearances; + + + verifyParams(base, triangles, appearances); + + int[] hTargets = new int[targets.length]; + int[] hTriangles = null; + int[] hAppearances = null; + + for (int i = 0; i < targets.length; i++) + { + hTargets[i] = targets[i].handle; + } + + hTriangles = new int[triangles.length]; + + if (appearances != null) + { + hAppearances = new int[appearances.length]; + } + + for (int i = 0; i < triangles.length; i++) + { + hTriangles[i] = triangles[i].handle; + + if (hAppearances != null) + { + hAppearances[i] = appearances[i] != null ? appearances[i].handle : 0; + } + } + + int ret = _ctor(Interface.getHandle(), + base.handle, + hTargets, + hTriangles, + hAppearances); + + tempTrianglesArray = null; + tempAppearanceArray = null; + + return ret; + + } + + // Native methods + private static native int _ctor(int hInstance, + int handle, + int[] hTargets, + int[] hTriangles, + int[] hAppearances); + private static native void _setWeights(int handle, float[] weights); + private static native void _getWeights(int handle, float[] weights); + private static native int _getMorphTarget(int handle, int index); + private static native int _getMorphTargetCount(int handle); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/Node.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/Node.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,188 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +public abstract class Node extends Transformable +{ + //------------------------------------------------------------------ + // Static data + //------------------------------------------------------------------ + + public static final int NONE = 144; + public static final int ORIGIN = 145; + public static final int X_AXIS = 146; + public static final int Y_AXIS = 147; + public static final int Z_AXIS = 148; + + //------------------------------------------------------------------ + // Instance data + //------------------------------------------------------------------ + + // The node references are kept on the Java side to avoid having + // to replicate garbage collection in the native implementation. + // Instead, we let Java manage Node reachability detection and + // deletion. + + private Node parent; + private Node zRef, yRef; + + //------------------------------------------------------------------ + // Constructor(s) + //------------------------------------------------------------------ + + /** + * There is only a package private constructor. Applications can not extend + * this class directly.

                + */ + Node(int handle) + { + super(handle); + parent = (Node) getInstance(_getParent(handle)); + zRef = (Node) getInstance(_getZRef(handle)); + yRef = (Node) getInstance(_getYRef(handle)); + } + + //------------------------------------------------------------------ + // Public methods + //------------------------------------------------------------------ + + public Node getParent() + { + return parent; + } + + public boolean getTransformTo(Node target, Transform transform) + { + return _getTransformTo(handle, + target.handle, + transform != null ? transform.matrix : null); + } + + public void setAlignment(Node zReference, int zTarget, + Node yReference, int yTarget) + { + _setAlignment(handle, + zReference != null ? zReference.handle : 0, zTarget, + yReference != null ? yReference.handle : 0, yTarget); + zRef = zReference; + yRef = yReference; + } + + public void setAlphaFactor(float alphaFactor) + { + _setAlphaFactor(handle, alphaFactor); + } + + public float getAlphaFactor() + { + return _getAlphaFactor(handle); + } + + public void setRenderingEnable(boolean enable) + { + _enable(handle, Defs.SETGET_RENDERING, enable); + } + + public boolean isRenderingEnabled() + { + return _isEnabled(handle, Defs.SETGET_RENDERING); + } + + public void setPickingEnable(boolean enable) + { + _enable(handle, Defs.SETGET_PICKING, enable); + } + + public boolean isPickingEnabled() + { + return _isEnabled(handle, Defs.SETGET_PICKING); + } + + public void setScope(int id) + { + _setScope(handle, id); + } + + public int getScope() + { + return _getScope(handle); + } + + public final void align(Node reference) + { + _align(handle, reference != null ? reference.handle : 0); + } + + // M3G 1.1 Maintenance release getters + + public Node getAlignmentReference(int axis) + { + switch (axis) + { + case Y_AXIS: + return yRef; + case Z_AXIS: + return zRef; + default: + throw new IllegalArgumentException(); + } + } + + public int getAlignmentTarget(int axis) + { + return _getAlignmentTarget(handle, axis); + } + + + //------------------------------------------------------------------ + // Private methods + //------------------------------------------------------------------ + + void setParent(Node parent) + { + this.parent = parent; + } + + // Native methods + private static native boolean _getTransformTo(int handle, + int hTarget, + byte[] transform); + + private static native void _align(int handle, int refHandle); + private static native void _setAlignment(int handle, + int hZReference, int zTarget, + int hYReference, int yTarget); + + private static native void _setAlphaFactor(int handle, float alphaFactor); + private static native float _getAlphaFactor(int handle); + + private static native void _enable(int handle, int which, boolean enable); + private static native boolean _isEnabled(int handle, int which); + + private static native void _setScope(int handle, int id); + private static native int _getScope(int handle); + + private static native int _getParent(int handle); + private static native int _getZRef(int handle); + private static native int _getYRef(int handle); + static native int _getSubtreeSize(int handle); + + // M3G 1.1 Maintenance release getters + private static native int _getAlignmentTarget(int handle, int axis); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/Object3D.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/Object3D.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,241 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +import java.util.Enumeration; +import java.util.Vector; +import com.nokia.mj.impl.rt.support.Finalizer; + +/** +*/ +public abstract class Object3D +{ + //------------------------------------------------------------------ + // Instance data + //------------------------------------------------------------------ + + int handle; + + private Object userObject; + private Vector animTracks; + private Interface iInterface; + + private Finalizer mFinalizer = new Finalizer() + { + public void finalizeImpl() + { + doFinalize(); + } + }; + + //------------------------------------------------------------------ + // Constructor(s) + //------------------------------------------------------------------ + + /** + *

                Only a package private constructor exists for this class.

                + */ + Object3D(int handle) + { + if (handle != 0) + { + this.handle = handle; + _addRef(handle); + + // Get associated Interafece object and + // register this instance with that + iInterface = Interface.getInstance(); + iInterface.register(this); + + int n = _getAnimationTrackCount(handle); + while (n-- > 0) + { + linkAnimTrack((AnimationTrack) getInstance(_getAnimationTrack(handle, n))); + } + } + else + { + System.out.println("Warning: Object3D constructor called with zero handle"); + } + } + + //------------------------------------------------------------------ + // Public API + //------------------------------------------------------------------ + + public final Object3D duplicate() + { + int numRef = 1; + if (this instanceof Node) + { + numRef = ((Node)this)._getSubtreeSize(handle); + } + int[] handles = new int[numRef * 2]; + Object3D obj = getInstance(_duplicate(handle, handles)); + for (int i = 0; i < numRef; i++) + { + Object userObj = getInstance(handles[i * 2]).getUserObject(); + Object3D duplicateObj = getInstance(handles[i * 2 + 1]); + if (userObj != null) + { + duplicateObj.setUserObject(userObj); + } + } + return obj; + } + + public int getReferences(Object3D[] references) + { + int[] handles = null; + if (references != null) + { + handles = new int[references.length]; + } + int num = _getReferences(handle, handles); + if (references != null) + { + for (int i = 0; i < num; i++) + { + references[i] = getInstance(handles[i]); + } + } + return num; + } + + public void setUserID(int userID) + { + _setUserID(handle, userID); + } + + public int getUserID() + { + return _getUserID(handle); + } + + public Object3D find(int userID) + { + return getInstance(_find(handle, userID)); + } + + public void addAnimationTrack(AnimationTrack animationTrack) + { + _addAnimationTrack(handle, animationTrack.handle); + linkAnimTrack(animationTrack); + } + + public AnimationTrack getAnimationTrack(int index) + { + /* Don't try to match the native indexing here -- just call + * the native getter */ + return (AnimationTrack)getInstance(_getAnimationTrack(handle, index)); + } + + public void removeAnimationTrack(AnimationTrack animationTrack) + { + if (animationTrack != null) + { + _removeAnimationTrack(handle, animationTrack.handle); + + if (animTracks != null) + { + animTracks.removeElement(animationTrack); + if (animTracks.isEmpty()) + { + animTracks = null; + } + } + } + } + + public int getAnimationTrackCount() + { + return _getAnimationTrackCount(handle); + } + + public final int animate(int time) + { + return _animate(handle, time); + } + + public void setUserObject(Object obj) + { + userObject = obj; + } + + public Object getUserObject() + { + return userObject; + } + + //------------------------------------------------------------------ + // Private methods + //------------------------------------------------------------------ + + static final Object3D getInstance(int handle) + { + return Interface.getObjectInstance(handle); + } + + /** + * Adds a reference to an animation track. + */ + private void linkAnimTrack(AnimationTrack track) + { + if (animTracks == null) + { + animTracks = new Vector(); + } + animTracks.addElement(track); + } + + /** + * Native peer finalization + */ + private void doFinalize() + { + if (mFinalizer != null) + { + if (handle != 0) + { + // finalize native peer + Platform.finalizeObject(handle, iInterface); + iInterface.deregister(this, iInterface); + + // reset handles + iInterface = null; + handle= 0; + } + mFinalizer = null; + } + } + + // Native methods + private static native int _addAnimationTrack(int hObject, int hAnimationTrack); + private static native void _removeAnimationTrack(int hObject, int hAnimationTrack); + private static native int _getAnimationTrackCount(int hObject); + private static native int _animate(int hObject, int time); + private static native void _setUserID(int hObject, int userID); + private static native int _getUserID(int hObject); + + private static native void _addRef(int hObject); + private static native int _getAnimationTrack(int hObject, int index); + private static native int _duplicate(int hObject, int[] handles); + private static native int _getReferences(int hObject, int[] handles); + private static native int _find(int hObject, int userID); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/Platform.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/Platform.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,231 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +/** + * \file + * \brief Target platform dependent Java module for Symbian. + * + */ + +package javax.microedition.m3g; +import javax.microedition.lcdui.Graphics; +import javax.microedition.lcdui.Image; +import org.eclipse.swt.widgets.Display; + +import com.nokia.mj.impl.nokialcdui.LCDUIInvoker; +import org.eclipse.swt.internal.extension.DisplayExtension; + +/** + * Implements platform-dependent functionality. At the moment, this + * includes native finalization and some helper methods for + * synchronizing 2D and 3D rendering. + */ +class Platform +{ + /** + * eSWT display for ui thread access + */ + private static Display display = null; + private static boolean libraryLoaded = false; + + //------------------------------------------------------------------ + // Package private methods + //------------------------------------------------------------------ + + /** + * Executes given runnable in UI thread if caller thread is not UI thread + */ + static void executeInUIThread(M3gRunnable obj) + { + if (display == null) + { + if (!uiThreadAvailable()) + { + throw new Error("Ui thread not available"); + } + } + if (display.isDisposed()) + { + throw new Error("Display already disposed"); + } + + if (obj != null) + { + // If we are not in UI thread use display + if (Thread.currentThread() != display.getThread()) + { + display.syncExec(obj); + } + else + { + // In this case we are in UI thread so just execute directly + obj.run(); + } + // Check if any exceptions occured in execution + // and throw forward in caller thread + obj.checkAndThrow(); + } + } + + /** + * Check the UI thread / toolkit init status and store display if it is available + * @return true if either lcdui or eswt toolkit is initialized and ui thread is accessible + * otherwise false + */ + static boolean uiThreadAvailable() + { + if (display != null) + { + return true; + } + else + { + display = DisplayExtension.getDisplayInstance(); + if (display == null) + { + return false; + } + else + { + // UI thread is available, so load native library if not already loaded + if (!libraryLoaded) + { + com.nokia.mj.impl.rt.support.Jvm.loadSystemLibrary("javam3g"); + libraryLoaded = true; + } + return true; + } + } + } + + /** + * Registers an Object3D in the global handle-to-object map. The + * handle of the object must already be set at this point! + */ + static final void registerFinalizer(Object3D obj) + { + //heuristicGC(); + } + + /** + * Registers a Graphics3D object (not derived from Object3D) for + * finalization. + */ + static final void registerFinalizer(Graphics3D g3d) + { + //heuristicGC(); + } + + /** + * Registers an Interface object for finalization + */ + static final void registerFinalizer(Interface m3g) + { + } + + /** + * Registers a Loader object for finalization + */ + static final void registerFinalizer(Loader loader) + { + } + + /** + * Flushes all pending rendering to a Graphics context and blocks + * until finished + */ + static final void sync(Graphics g) + { + //ToolkitInvoker invoker = ToolkitInvoker.getToolkitInvoker(); + //invoker.toolkitSync(invoker.getToolkit()); + } + + /** + * Flushes all pending rendering to an Image object + */ + static final void sync(Image img) + { + //ToolkitInvoker invoker = ToolkitInvoker.getToolkitInvoker(); + //invoker.toolkitSync(invoker.getToolkit()); + } + + /** + * Finalizes the native peer of an interface + */ + static final native void finalizeInterface(int handle); + + /** + * Finalizes the native peer of an object + * JCF: added this wrapper method so we could pass the toolkit handle to the native method. + */ + static final void finalizeObject(int handle) + { + try + { + final int finalHandle = handle; + executeInUIThread( + new M3gRunnable() + { + void doRun() + { + _finalizeObject(finalHandle); + } + }); + } + catch (Exception e) + { + // do nothing + } + } + + /** + * Finalizes the native peer of an object associated with + * given Interface instance + */ + static final void finalizeObject(int handle, Interface aInterface) + { + try + { + final int finalHandle = handle; + executeInUIThread( + new M3gRunnable() + { + public void doRun() + { + _finalizeObject(finalHandle); + } + }); + } + catch (Exception e) + { + // do nothing + } + } + + + //------------------------------------------------------------------ + // Private methods + //------------------------------------------------------------------ + + /** + * Trigger GC if minimum free memory limit has been exceeded in the native side + */ + static final void heuristicGC() + { + } + private static final native void _finalizeObject(int handle); +} + diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/PolygonMode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/PolygonMode.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,139 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +public class PolygonMode extends Object3D +{ + + //------------------------------------------------------------------ + // Static data + //------------------------------------------------------------------ + + public static final int CULL_BACK = 0xA0; + public static final int CULL_FRONT = CULL_BACK + 1; + public static final int CULL_NONE = CULL_FRONT + 1; + public static final int SHADE_FLAT = 0xA4; + public static final int SHADE_SMOOTH = SHADE_FLAT + 1; + public static final int WINDING_CCW = 0xA8; + public static final int WINDING_CW = WINDING_CCW + 1; + + //------------------------------------------------------------------ + // Constructor(s) + //------------------------------------------------------------------ + + public PolygonMode() + { + super(_ctor(Interface.getHandle())); + } + + /** + */ + PolygonMode(int handle) + { + super(handle); + } + + //------------------------------------------------------------------ + // Public methods + //------------------------------------------------------------------ + + public void setCulling(int mode) + { + _setCulling(handle, mode); + } + + public int getCulling() + { + return _getCulling(handle); + } + + public void setWinding(int mode) + { + _setWinding(handle, mode); + } + + public int getWinding() + { + return _getWinding(handle); + } + + public void setShading(int mode) + { + _setShading(handle, mode); + } + + public int getShading() + { + return _getShading(handle); + } + + public void setTwoSidedLightingEnable(boolean enable) + { + _setTwoSidedLightingEnable(handle, enable); + } + + public boolean isTwoSidedLightingEnabled() + { + return _isTwoSidedLightingEnabled(handle); + } + + public void setLocalCameraLightingEnable(boolean enable) + { + _setLocalCameraLightingEnable(handle, enable); + } + + public void setPerspectiveCorrectionEnable(boolean enable) + { + _setPerspectiveCorrectionEnable(handle, enable); + } + + // M3G 1.1 Maintenance release getters + public boolean isLocalCameraLightingEnabled() + { + return _isLocalCameraLightingEnabled(handle); + } + + public boolean isPerspectiveCorrectionEnabled() + { + return _isPerspectiveCorrectionEnabled(handle); + } + + + //------------------------------------------------------------------ + // Private methods + //------------------------------------------------------------------ + + private native static int _ctor(int hInterface); + private native static void _setLocalCameraLightingEnable(int handle, boolean enable); + private native static void _setPerspectiveCorrectionEnable(int handle, boolean enable); + private native static void _setCulling(int handle, int mode); + private native static int _getCulling(int handle); + private native static void _setWinding(int handle, int mode); + private native static int _getWinding(int handle); + private native static void _setShading(int handle, int mode); + private native static int _getShading(int handle); + private native static void _setTwoSidedLightingEnable(int handle, boolean enable); + private native static boolean _isTwoSidedLightingEnabled(int handle); + + // M3G 1.1 Maintenance release getters + private native static boolean _isLocalCameraLightingEnabled(int handle); + private native static boolean _isPerspectiveCorrectionEnabled(int handle); + +} + diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/RayIntersection.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/RayIntersection.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,138 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +public class RayIntersection +{ + private Node intersected = null; + private float distance = 0.f; + private int submeshIndex = 0; + private float[] textureS = new float[Defs.NUM_TEXTURE_UNITS]; + private float[] textureT = new float[Defs.NUM_TEXTURE_UNITS]; + private float[] normal = new float[3]; + private float[] ray = new float[6]; + + public RayIntersection() + { + normal[0] = 0.f; + normal[1] = 0.f; + normal[2] = 1.f; + + ray[0] = 0.f; + ray[1] = 0.f; + ray[2] = 0.f; + ray[3] = 0.f; + ray[4] = 0.f; + ray[5] = 1.f; + } + + public Node getIntersected() + { + return intersected; + } + + public float getDistance() + { + return distance; + } + + public int getSubmeshIndex() + { + return submeshIndex; + } + + public float getTextureS(int index) + { + if (index < 0 || index >= textureS.length) + { + throw new IndexOutOfBoundsException(); + } + + return textureS[index]; + } + + public float getTextureT(int index) + { + if (index < 0 || index >= textureT.length) + { + throw new IndexOutOfBoundsException(); + } + + return textureT[index]; + } + + public float getNormalX() + { + return normal[0]; + } + + public float getNormalY() + { + return normal[1]; + } + + public float getNormalZ() + { + return normal[2]; + } + + public void getRay(float[] ray) + { + if (ray.length < 6) + { + throw new IllegalArgumentException(); + } + + ray[0] = this.ray[0]; + ray[1] = this.ray[1]; + ray[2] = this.ray[2]; + ray[3] = this.ray[3]; + ray[4] = this.ray[4]; + ray[5] = this.ray[5]; + } + + //------------------------------------------------------------------ + // Private methods + //------------------------------------------------------------------ + + static float[] createResult() + { + return new float[1 + 1 + 2 * Defs.NUM_TEXTURE_UNITS + 3 + 6]; + } + + void fill(int hIntersected, float[] result) + { + intersected = (Node)Object3D.getInstance(hIntersected); + distance = result[0]; + submeshIndex = (int)result[1]; + textureS[0] = result[2]; + textureS[1] = result[3]; + textureT[0] = result[4]; + textureT[1] = result[5]; + normal[0] = result[6]; + normal[1] = result[7]; + normal[2] = result[8]; + ray[0] = result[9]; + ray[1] = result[10]; + ray[2] = result[11]; + ray[3] = result[12]; + ray[4] = result[13]; + ray[5] = result[14]; + } +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/SkinnedMesh.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/SkinnedMesh.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,203 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +public class SkinnedMesh extends Mesh +{ + //------------------------------------------------------------------ + // Instance data + //------------------------------------------------------------------ + + private Group skeleton; + + static private IndexBuffer[] tempTrianglesArray; + static private Appearance[] tempAppearanceArray; + + static private IndexBuffer tempTriangles; + static private Appearance tempAppearance; + + + //------------------------------------------------------------------ + // Constructor(s) + //------------------------------------------------------------------ + + public SkinnedMesh(VertexBuffer vertices, + IndexBuffer[] triangles, + Appearance[] appearances, + Group skeleton) + { + super(createHandle(vertices, triangles, appearances, skeleton)); + skeleton.setParent(this); + this.skeleton = skeleton; + } + + public SkinnedMesh(VertexBuffer vertices, + IndexBuffer triangles, + Appearance appearance, + Group skeleton) + { + super(createHandle(vertices, triangles, appearance, skeleton)); + skeleton.setParent(this); + this.skeleton = skeleton; + } + + /** + */ + SkinnedMesh(int handle) + { + super(handle); + skeleton = (Group) getInstance(_getSkeleton(handle)); + } + + //------------------------------------------------------------------ + // Public methods + //------------------------------------------------------------------ + + public void addTransform(Node bone, + int weight, + int firstVertex, + int numVertices) + { + _addTransform(handle, + bone != null ? bone.handle : 0, + weight, + firstVertex, + numVertices); + } + + public Group getSkeleton() + { + return skeleton; + } + + // M3G 1.1 Maintenance release getters + + public void getBoneTransform(Node bone, Transform transform) + { + _getBoneTransform(handle, bone.handle, transform.matrix); + } + + public int getBoneVertices(Node bone, int[] indices, float[] weights) + { + return _getBoneVertices(handle, bone.handle, indices, weights); + } + + //------------------------------------------------------------------ + // Private methods + //------------------------------------------------------------------ + + static int createHandle(VertexBuffer vertices, + IndexBuffer[] triangles, + Appearance[] appearances, + Group skeleton) + { + + tempTrianglesArray = triangles; + tempAppearanceArray = appearances; + + verifyParams(vertices, triangles, appearances); + + if (skeleton == null) + { + throw new NullPointerException(); + } + + if (skeleton.getParent() != null || skeleton instanceof World) + { + throw new IllegalArgumentException(); + } + + int[] hTri = new int[triangles.length]; + int[] hApp = new int[triangles.length]; + for (int i = 0; i < triangles.length; i++) + { + hTri[i] = triangles[i].handle; + if (appearances != null && i < appearances.length) + { + hApp[i] = appearances[i] != null ? appearances[i].handle : 0; + } + } + int ret= _ctor(Interface.getHandle(), + vertices.handle, + hTri, + hApp, + skeleton.handle); + + tempTrianglesArray = triangles; + tempAppearanceArray = appearances; + + return ret; + } + + static int createHandle(VertexBuffer vertices, + IndexBuffer triangles, + Appearance appearance, + Group skeleton) + { + + tempTriangles = triangles; + tempAppearance = appearance; + + verifyParams(vertices, triangles); + + if (skeleton == null) + { + throw new NullPointerException(); + } + if (skeleton.getParent() != null || skeleton instanceof World) + { + throw new IllegalArgumentException(); + } + int[] hTri = {triangles.handle}; + int[] hApp = {appearance != null ? appearance.handle : 0}; + int ret = _ctor(Interface.getHandle(), + vertices.handle, + hTri, + hApp, + skeleton.handle); + + tempTriangles = null; + tempAppearance = null; + + return ret; + } + + // Native methods + private native static int _ctor(int hInstance, + int hVertices, + int[] hTriangles, + int[] hAppearances, + int hSkeleton); + private native static void _addTransform(int handle, + int hBone, + int weight, + int firstVertex, + int numVertices); + private native static int _getSkeleton(int handle); + + // M3G 1.1 Maintenance release getters + private native static void _getBoneTransform(int handle, + int hBone, + byte[] transform); + private native static int _getBoneVertices(int handle, + int hBone, + int[] indices, + float[] weights); + +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/Sprite3D.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/Sprite3D.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,128 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +public class Sprite3D extends Node +{ + //------------------------------------------------------------------ + // Instance data + //------------------------------------------------------------------ + + private Image2D image; + private Appearance appearance; + + //------------------------------------------------------------------ + // Constructors + //------------------------------------------------------------------ + + public Sprite3D(boolean scaled, Image2D image, Appearance appearance) + { + super(_ctor(Interface.getHandle(), + scaled, + image != null ? image.handle : 0, + appearance != null ? appearance.handle : 0)); + this.image = image; + this.appearance = appearance; + } + + /** + */ + Sprite3D(int handle) + { + super(handle); + image = (Image2D)getInstance(_getImage(handle)); + appearance = (Appearance)getInstance(_getAppearance(handle)); + } + + //------------------------------------------------------------------ + // Public methods + //------------------------------------------------------------------ + + public boolean isScaled() + { + return _isScaled(handle); + } + + public void setAppearance(Appearance appearance) + { + _setAppearance(handle, appearance != null ? appearance.handle : 0); + this.appearance = appearance; + } + + public Appearance getAppearance() + { + return appearance; + } + + public void setImage(Image2D image) + { + _setImage(handle, image != null ? image.handle : 0); + this.image = image; + } + + public Image2D getImage() + { + return image; + } + + public void setCrop(int cropX, int cropY, int width, int height) + { + _setCrop(handle, cropX, cropY, width, height); + } + + public int getCropX() + { + return _getCrop(handle, Defs.GET_CROPX); + } + + public int getCropY() + { + return _getCrop(handle, Defs.GET_CROPY); + } + + public int getCropWidth() + { + return _getCrop(handle, Defs.GET_CROPWIDTH); + } + + public int getCropHeight() + { + return _getCrop(handle, Defs.GET_CROPHEIGHT); + } + + //------------------------------------------------------------------ + // Private methods + //------------------------------------------------------------------ + + // Native methods + + private static native int _ctor(int hInterface, + boolean scaled, + int hImage, + int hAppearance); + private static native boolean _isScaled(int handle); + private static native void _setAppearance(int handle, int hAppearance); + private static native void _setImage(int handle, int hImage); + private static native void _setCrop(int handle, + int cropX, int cropY, + int width, int height); + private static native int _getCrop(int handle, int which); + private static native int _getAppearance(int handle); + private static native int _getImage(int handle); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/Texture2D.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/Texture2D.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,151 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +import javax.microedition.lcdui.Image; + +import java.io.*; + +public class Texture2D extends Transformable +{ + //------------------------------------------------------------------ + // Static data + //------------------------------------------------------------------ + + public static final int FILTER_BASE_LEVEL = 208; + public static final int FILTER_LINEAR = 209; + public static final int FILTER_NEAREST = 210; + public static final int FUNC_ADD = 224; + public static final int FUNC_BLEND = 225; + public static final int FUNC_DECAL = 226; + public static final int FUNC_MODULATE = 227; + public static final int FUNC_REPLACE = 228; + public static final int WRAP_CLAMP = 240; + public static final int WRAP_REPEAT = 241; + + //------------------------------------------------------------------ + // Instance data + //------------------------------------------------------------------ + + private Image2D image; + + //------------------------------------------------------------------ + // Constructor(s) + //------------------------------------------------------------------ + + public Texture2D(final Image2D image) + { + super(_ctor(Interface.getHandle(), image != null ? image.handle : 0)); + this.image = image; + } + + /** + */ + Texture2D(int handle) + { + super(handle); + image = (Image2D) getInstance(_getImage(handle)); + } + + //------------------------------------------------------------------ + // Public methods + //------------------------------------------------------------------ + + public void setImage(final Image2D image) + { + _setImage(handle, image != null ? image.handle : 0); + this.image = image; + } + + public Image2D getImage() + { + return image; + } + + public void setFiltering(int levelFilter, int imageFilter) + { + _setFiltering(handle, levelFilter, imageFilter); + } + + public void setWrapping(int wrapS, int wrapT) + { + _setWrapping(handle, wrapS, wrapT); + } + + public int getWrappingS() + { + return _getWrappingS(handle); + } + + public int getWrappingT() + { + return _getWrappingT(handle); + } + + public void setBlending(int func) + { + _setBlending(handle, func); + } + + public int getBlending() + { + return _getBlending(handle); + } + + public void setBlendColor(int RGB) + { + _setBlendColor(handle, RGB); + } + + public int getBlendColor() + { + return _getBlendColor(handle); + } + + // M3G 1.1 Maintenance release getters + + public int getImageFilter() + { + return _getImageFilter(handle); + } + + public int getLevelFilter() + { + return _getLevelFilter(handle); + } + + // Native methods + private native static int _ctor(int hInterface, int imageHandle); + + private native static void _setImage(int handle, int imageHandle); + private native static int _getImage(int handle); + + private native static void _setFiltering(int handle, int levelFilter, int imageFilter); + private native static void _setWrapping(int handle, int wrapS, int wrapT); + private native static int _getWrappingS(int handle); + private native static int _getWrappingT(int handle); + private native static void _setBlending(int handle, int func); + private native static int _getBlending(int handle); + private native static void _setBlendColor(int handle, int RGB); + private native static int _getBlendColor(int handle); + + // M3G 1.1 Maintenance release getters + private native static int _getImageFilter(int handle); + private native static int _getLevelFilter(int handle); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/Transform.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/Transform.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,169 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +public class Transform +{ + //------------------------------------------------------------------ + // Static data + //------------------------------------------------------------------ + + //------------------------------------------------------------------ + // Instance data + //------------------------------------------------------------------ + + // Check size from m3g_math.h Matrix + byte[] matrix = new byte[72]; + + //------------------------------------------------------------------ + // Constructor(s) + //------------------------------------------------------------------ + + public Transform() + { + if (!Platform.uiThreadAvailable()) + { + throw new Error("UI thread not initialized"); + } + setIdentity(); + } + + /** + */ + public Transform(Transform other) + { + if (!Platform.uiThreadAvailable()) + { + throw new Error("UI thread not initialized"); + } + set(other); + } + + //------------------------------------------------------------------ + // Public methods + //------------------------------------------------------------------ + + public void setIdentity() + { + _setIdentity(matrix); + } + + public void set(Transform transform) + { + System.arraycopy(transform.matrix, 0, + this.matrix, 0, + this.matrix.length); + } + + public void set(float[] matrix) + { + _setMatrix(this.matrix, matrix); + } + + public void get(float[] matrix) + { + _getMatrix(this.matrix, matrix); + } + + public void invert() + { + _invert(matrix); + } + + public void transpose() + { + _transpose(matrix); + } + + public void postMultiply(Transform transform) + { + _mul(this.matrix, this.matrix, transform.matrix); + } + + public void postScale(float sx, float sy, float sz) + { + _scale(matrix, sx, sy , sz); + } + + /** + */ + public void postRotate(float angle, float ax, float ay, float az) + { + _rotate(matrix, angle, ax, ay, az); + } + + /** + */ + public void postRotateQuat(float qx, float qy, float qz, float qw) + { + _rotateQuat(matrix, qx, qy, qz, qw); + } + + /** + */ + public void postTranslate(float tx, float ty, float tz) + { + _translate(matrix, tx, ty, tz); + } + + /** + */ + public void transform(float[] v) + { + if ((v.length % 4) != 0) + { + throw new IllegalArgumentException(); + } + + if (v.length != 0) + { + _transformTable(matrix, v); + } + } + + /** + */ + public void transform(VertexArray in, float[] out, boolean W) + { + if (in == null || out == null) + { + throw new NullPointerException(); + } + + _transformArray(matrix, in.handle, out, W); + } + + //------------------------------------------------------------------ + // Private methods + //------------------------------------------------------------------ + + // Native methods + private static native void _mul(byte[] prod, byte[] left, byte[] right); + private static native void _setIdentity(byte[] matrix); + private static native void _setMatrix(byte[] matrix, float[] srcMatrix); + private static native void _getMatrix(byte[] matrix, float[] dstMatrix); + private static native void _invert(byte[] matrix); + private static native void _transpose(byte[] matrix); + private static native void _rotate(byte[] matrix, float angle, float ax, float ay, float az); + private static native void _rotateQuat(byte[] matrix, float qx, float qy, float qz, float qw); + private static native void _scale(byte[] matrix, float sx, float sy, float sz); + private static native void _translate(byte[] matrix, float tx, float ty, float tz); + private static native void _transformTable(byte[] matrix, float[] v); + private static native void _transformArray(byte[] matrix, int handle, float[] out, boolean W); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/Transformable.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/Transformable.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,132 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +/** + * + */ +public abstract class Transformable extends Object3D +{ + //------------------------------------------------------------------ + // Constructor(s) + //------------------------------------------------------------------ + + Transformable(int handle) + { + super(handle); + } + + //------------------------------------------------------------------ + // Public methods + //------------------------------------------------------------------ + + + public void setOrientation(float angle, float ax, float ay, float az) + { + _setOrientation(handle, angle, ax, ay, az, true); + } + + public void postRotate(float angle, float ax, float ay, float az) + { + _setOrientation(handle, angle, ax, ay, az, false); + } + + public void preRotate(float angle, float ax, float ay, float az) + { + _preRotate(handle, angle, ax, ay, az); + } + + public void getOrientation(float[] angleAxis) + { + _getOrientation(handle, angleAxis); + } + + public void setScale(float sx, float sy, float sz) + { + _setScale(handle, sx, sy, sz, true); + } + + public void scale(float sx, float sy, float sz) + { + _setScale(handle, sx, sy, sz, false); + } + + public void getScale(float[] xyz) + { + _getScale(handle, xyz); + } + + public void setTranslation(float tx, float ty, float tz) + { + _setTranslation(handle, tx, ty, tz, true); + } + + public void translate(float tx, float ty, float tz) + { + _setTranslation(handle, tx, ty, tz, false); + } + + public void getTranslation(float[] xyz) + { + _getTranslation(handle, xyz); + } + + public void setTransform(Transform transform) + { + _setTransform(handle, (transform != null) ? transform.matrix : null); + } + + public void getTransform(Transform transform) + { + _getTransform(handle, transform.matrix); + } + + public void getCompositeTransform(Transform transform) + { + _getComposite(handle, transform.matrix); + } + + //------------------------------------------------------------------ + // Private methods + //------------------------------------------------------------------ + + private static native void _setOrientation(int handle, + float angle, + float ax, float ay, float az, + boolean absolute); + private static native void _preRotate(int handle, + float angle, + float ax, float ay, float az); + private static native void _getOrientation(int handle, float[] angleAxis); + + private static native void _setScale(int handle, + float sx, float sy, float sz, + boolean absolute); + private static native void _getScale(int handle, float[] scale); + + private static native void _setTranslation(int handle, + float tx, float ty, float tz, + boolean absolute); + private static native void _getTranslation(int handle, float[] translation); + + private static native void _setTransform(int handle, byte[] transform); + private static native void _getTransform(int handle, byte[] transform); + + private static native void _getComposite(int handle, byte[] transform); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/TriangleStripArray.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/TriangleStripArray.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,76 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +public class TriangleStripArray extends IndexBuffer +{ + //------------------------------------------------------------------ + // Constructors + //------------------------------------------------------------------ + + public TriangleStripArray(int firstIndex, final int[] stripLengths) + { + super(_createImplicit(Interface.getHandle(), + firstIndex, + stripLengths)); + } + + public TriangleStripArray(final int[] indices, final int[] stripLengths) + { + super(_createExplicit(Interface.getHandle(), indices, stripLengths)); + } + + TriangleStripArray(int handle) + { + super(handle); + } + + // M3G 1.1 Maintenance release getters + + public int getIndexCount() + { + return _getIndexCount(handle); + } + + public void getIndices(int[] indices) + { + if (indices.length < _getIndexCount(handle)) + { + throw new IllegalArgumentException(); + } + _getIndices(handle, indices); + } + + //------------------------------------------------------------------ + // Private methods + //------------------------------------------------------------------ + + // Native methods + private native static int _createImplicit(int hInterface, + int first, + final int[] lengths); + private native static int _createExplicit(int hInterface, + final int[] indices, + final int[] lengths); + + // M3G 1.1 Maintenance release getters + private native static int _getIndexCount(int handle); + private native static void _getIndices(int handle, int[] indices); + +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/VertexArray.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/VertexArray.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,120 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +public class VertexArray extends Object3D +{ + //------------------------------------------------------------------ + // Constructors + //------------------------------------------------------------------ + + public VertexArray(int numVertices, int numComponents, int componentSize) + { + super(createHandle(numVertices, + numComponents, + componentSize)); + } + + /** + */ + VertexArray(int handle) + { + super(handle); + } + + //------------------------------------------------------------------ + // Public methods + //------------------------------------------------------------------ + + public void set(int startIndex, int length, short[] values) + { + _setShort(handle, startIndex, length, values); + } + + public void set(int startIndex, int length, byte[] values) + { + _setByte(handle, startIndex, length, values); + } + + // M3G 1.1 Maintenance release getters + public void get(int firstVertex, int numVertices, byte[] values) + { + _getByte(handle, firstVertex, numVertices, values); + } + + public void get(int firstVertex, int numVertices, short[] values) + { + _getShort(handle, firstVertex, numVertices, values); + } + + public int getComponentCount() + { + return _getComponentCount(handle); + } + + public int getComponentType() + { + return _getComponentType(handle); + } + + public int getVertexCount() + { + return _getVertexCount(handle); + } + + //------------------------------------------------------------------ + // Private methods + //------------------------------------------------------------------ + + private static int createHandle(int numVertices, int numComponents, int componentSize) + { + Platform.heuristicGC(); + return _ctor(Interface.getHandle(), + numVertices, + numComponents, + componentSize); + } + + // Native methods + private native static int _ctor(int hInterface, + int numVertices, + int numComponents, + int componentSize); + private native static void _setByte(int handle, + int first, + int count, + byte[] src); + private native static void _setShort(int handle, + int first, + int count, + short[] src); + + // M3G 1.1 Maintenance release getters + private native static void _getByte(int handle, + int firstVertex, + int numVertices, + byte[] values); + private native static void _getShort(int handle, + int firstVertex, + int numVertices, + short[] values); + private native static int _getComponentCount(int handle); + private native static int _getComponentType(int handle); + private native static int _getVertexCount(int handle); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/VertexBuffer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/VertexBuffer.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,158 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +public class VertexBuffer extends Object3D +{ + //------------------------------------------------------------------ + // Instance data + //------------------------------------------------------------------ + + private VertexArray positions; + private VertexArray normals; + private VertexArray colors; + private VertexArray[] texCoords; + + //------------------------------------------------------------------ + // Constructors + //------------------------------------------------------------------ + + public VertexBuffer() + { + super(_ctor(Interface.getHandle())); + } + + /** + */ + VertexBuffer(int handle) + { + super(handle); + + positions = (VertexArray) getInstance(_getArray(handle, Defs.GET_POSITIONS, null)); + normals = (VertexArray) getInstance(_getArray(handle, Defs.GET_NORMALS, null)); + colors = (VertexArray) getInstance(_getArray(handle, Defs.GET_COLORS, null)); + + texCoords = new VertexArray[Defs.NUM_TEXTURE_UNITS]; + for (int i = 0; i < Defs.NUM_TEXTURE_UNITS; ++i) + { + texCoords[i] = + (VertexArray) getInstance(_getArray(handle, Defs.GET_TEXCOORDS0 + i, null)); + } + } + + //------------------------------------------------------------------ + // Public methods + //------------------------------------------------------------------ + + public int getVertexCount() + { + return _getVertexCount(handle); + } + + public void setPositions(VertexArray positions, float scale, float[] bias) + { + _setVertices(handle, + (positions != null) ? positions.handle : 0, + scale, + bias); + this.positions = positions; + } + + public void setTexCoords(int index, VertexArray texCoords, float scale, float[] bias) + { + _setTexCoords(handle, + index, + texCoords != null ? texCoords.handle : 0, + scale, + bias); + + if (this.texCoords == null) + { + this.texCoords = new VertexArray[Defs.NUM_TEXTURE_UNITS]; + } + this.texCoords[index] = texCoords; + } + + public void setNormals(VertexArray normals) + { + _setNormals(handle, normals != null ? normals.handle : 0); + this.normals = normals; + } + + public void setColors(VertexArray colors) + { + _setColors(handle, colors != null ? colors.handle : 0); + this.colors = colors; + } + + public VertexArray getPositions(float[] scaleBias) + { + /* Get scale and bias with native getter */ + _getArray(handle, Defs.GET_POSITIONS, scaleBias); + return positions; + } + + public VertexArray getTexCoords(int index, float[] scaleBias) + { + /* Index has to be checked here due to the native getter input params */ + if (index < 0 || index >= Defs.NUM_TEXTURE_UNITS) + { + throw new IndexOutOfBoundsException(); + } + + /* Get scale and bias with native getter */ + _getArray(handle, Defs.GET_TEXCOORDS0 + index, scaleBias); + return texCoords != null ? texCoords[index] : null; + } + + public VertexArray getNormals() + { + return normals; + } + + public VertexArray getColors() + { + return colors; + } + + public void setDefaultColor(int ARGB) + { + _setDefaultColor(handle, ARGB); + } + + public int getDefaultColor() + { + return _getDefaultColor(handle); + } + + //------------------------------------------------------------------ + // Private methods + //------------------------------------------------------------------ + + // Native methods + private static native int _ctor(int hInterface); + private static native void _setColors(int hBuffer, int hArray); + private static native void _setNormals(int hBuffer, int hArray); + private static native void _setTexCoords(int hBuffer, int unit, int hArray, float scale, float[] bias); + private static native void _setVertices(int hBuffer, int hArray, float scale, float[] bias); + private static native void _setDefaultColor(int hBuffer, int ARGB); + private static native int _getDefaultColor(int hBuffer); + private static native int _getArray(int hBuffer, int which, float[] scaleBias); + private static native int _getVertexCount(int hBuffer); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/javasrc/javax/microedition/m3g/World.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/javasrc/javax/microedition/m3g/World.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +package javax.microedition.m3g; + +public class World extends Group +{ + //------------------------------------------------------------------ + // Instance data + //------------------------------------------------------------------ + + private Camera activeCamera; + private Background background; + + //------------------------------------------------------------------ + // Constructor(s) + //------------------------------------------------------------------ + + public World() + { + super(_ctor(Interface.getHandle())); + } + + /** + */ + World(int handle) + { + super(handle); + background = (Background) getInstance(_getBackground(handle)); + activeCamera = (Camera) getInstance(_getActiveCamera(handle)); + } + + //------------------------------------------------------------------ + // Public methods + //------------------------------------------------------------------ + + public void setBackground(Background background) + { + _setBackground(handle, background != null ? background.handle : 0); + this.background = background; + } + + public Background getBackground() + { + return background; + } + + public void setActiveCamera(Camera camera) + { + _setActiveCamera(handle, camera != null ? camera.handle : 0); + this.activeCamera = camera; + } + + public Camera getActiveCamera() + { + return activeCamera; + } + + // Native methods + private static native int _ctor(int hInterface); + private static native void _setActiveCamera(int handle, int hCamera); + private static native void _setBackground(int handle, int hBackground); + private static native int _getActiveCamera(int handle); + private static native int _getBackground(int handle); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/CSynchronization.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/CSynchronization.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,137 @@ +/* +* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: M3GCore function call synchronization for J9 +* +*/ + +// INCLUDE FILES +#include "CSynchronization.h" + +NONSHARABLE_CLASS(M3gGlobals) +{ +public: + M3gGlobals() : mSync(0) {} + +public: + CSynchronization* mSync; +}; + +#if defined(__WINSCW__) + +#include +M3gGlobals* getM3gGlobals() +{ + // Access the PLS of this process. + return Pls(TUid::Uid(0x200211E2)); +} + +#else + +static M3gGlobals* sGlobals = 0; + +M3gGlobals* getM3gGlobals() +{ + if (sGlobals == 0) + { + sGlobals = new M3gGlobals(); + } + return sGlobals; +} +#endif + + +// STATIC MEMBERS +/*static*/ //CSynchronization* CSynchronization::iSelf = NULL; + +// ----------------------------------------------------------------------------- +// CSynchronization::InstanceL +// ----------------------------------------------------------------------------- +/*static*/ CSynchronization* CSynchronization::InstanceL() +{ + static M3gGlobals* globals = getM3gGlobals(); + if (!globals->mSync) + { + globals->mSync = CSynchronization::NewL(); + } + return globals->mSync; +} + +// ----------------------------------------------------------------------------- +// CSynchronization::NewL +// ----------------------------------------------------------------------------- +/*static*/ CSynchronization* CSynchronization::NewL() +{ + CSynchronization* self = new(ELeave) CSynchronization(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(); + return self; +} + +// ----------------------------------------------------------------------------- +// CSynchronization::ConstructL +// ----------------------------------------------------------------------------- +void CSynchronization::ConstructL() +{ + User::LeaveIfError(iGuard.CreateLocal()); +} + +// ----------------------------------------------------------------------------- +// CSynchronization::CSynchronization +// ----------------------------------------------------------------------------- +CSynchronization::CSynchronization() : iErrorCode(0) +{ +} + +// ----------------------------------------------------------------------------- +// CSynchronization::~CSynchronization +// ----------------------------------------------------------------------------- +CSynchronization::~CSynchronization() +{ + iGuard.Close(); +} + +// ----------------------------------------------------------------------------- +// CSynchronization::Lock +// ----------------------------------------------------------------------------- +void CSynchronization::Lock() +{ + iGuard.Wait(); + iErrorCode = 0; +} + +// ----------------------------------------------------------------------------- +// CSynchronization::Unlock +// ----------------------------------------------------------------------------- +void CSynchronization::Unlock() +{ + iErrorCode = 0; + iGuard.Signal(); +} + +// ----------------------------------------------------------------------------- +// CSynchronization::SetErrorCode +// ----------------------------------------------------------------------------- +void CSynchronization::SetErrorCode(TInt aCode) +{ + iErrorCode = aCode; +} + +// ----------------------------------------------------------------------------- +// CSynchronization::GetErrorCode +// ----------------------------------------------------------------------------- +TInt CSynchronization::GetErrorCode() +{ + return iErrorCode; +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/animationController.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/animationController.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,114 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "javax_microedition_m3g_AnimationController.h" + +JNIEXPORT jfloat JNICALL Java_javax_microedition_m3g_AnimationController__1getPosition +(JNIEnv* aEnv, jclass, jint aHController, jint aWorldTime) +{ + M3G_DO_LOCK + jfloat position = (jfloat)m3gGetPosition((M3GAnimationController)aHController, aWorldTime); + M3G_DO_UNLOCK(aEnv) + return position; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_AnimationController__1setWeight +(JNIEnv* aEnv, jclass, jint aHController, jfloat aWeight) +{ + M3G_DO_LOCK + m3gSetWeight((M3GAnimationController)aHController, aWeight); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_AnimationController__1setActiveInterval +(JNIEnv* aEnv, jclass, jint aHController, jint aWorldTimeMin, jint aWorldTimeMax) +{ + M3G_DO_LOCK + m3gSetActiveInterval((M3GAnimationController)aHController, aWorldTimeMin, aWorldTimeMax); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_AnimationController__1getActiveIntervalStart +(JNIEnv* aEnv, jclass, jint aHController) +{ + M3G_DO_LOCK + jint start = (jint)m3gGetActiveIntervalStart((M3GAnimationController)aHController); + M3G_DO_UNLOCK(aEnv) + return start; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_AnimationController__1ctor +(JNIEnv* aEnv, jclass, jint aM3g) +{ + M3G_DO_LOCK + jint handle = (jint)m3gCreateAnimationController((M3GInterface)aM3g); + M3G_DO_UNLOCK(aEnv) + return handle; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_AnimationController__1setPosition +(JNIEnv* aEnv, jclass, jint aHController, jfloat aTime, jint aWorldTime) +{ + M3G_DO_LOCK + m3gSetPosition((M3GAnimationController)aHController, aTime, aWorldTime); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_AnimationController__1setSpeed +(JNIEnv* aEnv, jclass, jint aHController, jfloat aFactor, jint aWorldTime) +{ + M3G_DO_LOCK + m3gSetSpeed((M3GAnimationController)aHController, aFactor, aWorldTime); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jfloat JNICALL Java_javax_microedition_m3g_AnimationController__1getSpeed +(JNIEnv* aEnv, jclass, jint aHController) +{ + M3G_DO_LOCK + jfloat speed = (jfloat)m3gGetSpeed((M3GAnimationController)aHController); + M3G_DO_UNLOCK(aEnv) + return speed; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_AnimationController__1getActiveIntervalEnd +(JNIEnv* aEnv, jclass, jint aHController) +{ + M3G_DO_LOCK + jint end = (jint)m3gGetActiveIntervalEnd((M3GAnimationController)aHController); + M3G_DO_UNLOCK(aEnv) + return end; +} + +JNIEXPORT jfloat JNICALL Java_javax_microedition_m3g_AnimationController__1getWeight +(JNIEnv* aEnv, jclass, jint aHController) +{ + M3G_DO_LOCK + jfloat weight = (jfloat)m3gGetWeight((M3GAnimationController)aHController); + M3G_DO_UNLOCK(aEnv) + return weight; +} + +/* M3G 1.1 JNI Calls*/ + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_AnimationController__1getRefWorldTime +(JNIEnv* aEnv, jclass, jint aHController) +{ + M3G_DO_LOCK + jint time = (jint)m3gGetRefWorldTime((M3GAnimationController)aHController); + M3G_DO_UNLOCK(aEnv) + return time; +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/animationTrack.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/animationTrack.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "javax_microedition_m3g_AnimationTrack.h" + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_AnimationTrack__1getTargetProperty +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jint props = (jint)m3gGetTargetProperty((M3GAnimationTrack)aHandle); + M3G_DO_UNLOCK(aEnv) + return props; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_AnimationTrack__1getSequence +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jint sequence = (jint)m3gGetSequence((M3GAnimationTrack)aHandle); + M3G_DO_UNLOCK(aEnv) + return sequence; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_AnimationTrack__1ctor +(JNIEnv* aEnv, jclass, jint aM3g, jint aHSequence, jint aProperty) +{ + M3G_DO_LOCK + jint handle = (jint)m3gCreateAnimationTrack((M3GInterface)aM3g, (M3GKeyframeSequence)aHSequence, (M3Gint)aProperty); + M3G_DO_UNLOCK(aEnv) + return handle; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_AnimationTrack__1getController +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jint controller = (jint)m3gGetController((M3GAnimationTrack)aHandle); + M3G_DO_UNLOCK(aEnv) + return controller; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_AnimationTrack__1setController +(JNIEnv* aEnv, jclass, jint aHandle, jint aHController) +{ + M3G_DO_LOCK + m3gSetController((M3GAnimationTrack)aHandle, (M3GAnimationController)aHController); + M3G_DO_UNLOCK(aEnv) +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/appearance.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/appearance.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,129 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "javax_microedition_m3g_Appearance.h" + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Appearance__1setLayer +(JNIEnv* aEnv, jclass, jint aHApp, jint aLayer) +{ + M3G_DO_LOCK + m3gSetLayer((M3GAppearance)aHApp, (M3Gint)aLayer); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Appearance__1getCompositingMode +(JNIEnv* aEnv, jclass, jint aHApp) +{ + M3G_DO_LOCK + jint compMode = (jint)m3gGetCompositingMode((M3GAppearance)aHApp); + M3G_DO_UNLOCK(aEnv) + return compMode; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Appearance__1getFog +(JNIEnv* aEnv, jclass, jint aHApp) +{ + M3G_DO_LOCK + jint fog = (jint)m3gGetFog((M3GAppearance)aHApp); + M3G_DO_UNLOCK(aEnv) + return fog; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Appearance__1getLayer +(JNIEnv* aEnv, jclass, jint aHApp) +{ + M3G_DO_LOCK + jint layer = (jint)m3gGetLayer((M3GAppearance)aHApp); + M3G_DO_UNLOCK(aEnv) + return layer; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Appearance__1setCompositingMode +(JNIEnv* aEnv, jclass, jint aHApp, jint aHMode) +{ + M3G_DO_LOCK + m3gSetCompositingMode((M3GAppearance)aHApp, (M3GCompositingMode)aHMode); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Appearance__1setPolygonMode +(JNIEnv* aEnv, jclass, jint aHApp, jint aHMode) +{ + M3G_DO_LOCK + m3gSetPolygonMode((M3GAppearance)aHApp, (M3GPolygonMode)aHMode); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Appearance__1getPolygonMode +(JNIEnv* aEnv, jclass, jint aHApp) +{ + M3G_DO_LOCK + jint polyMode = (jint)m3gGetPolygonMode((M3GAppearance)aHApp); + M3G_DO_UNLOCK(aEnv) + return polyMode; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Appearance__1setTexture +(JNIEnv* aEnv, jclass, jint aHApp, jint aUnit, jint aHTex) +{ + M3G_DO_LOCK + m3gSetTexture((M3GAppearance)aHApp, (M3Gint)aUnit, (M3GTexture)aHTex); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Appearance__1ctor +(JNIEnv* aEnv, jclass, jint aM3g) +{ + M3G_DO_LOCK + jint handle = (jint)m3gCreateAppearance((M3GInterface)aM3g); + M3G_DO_UNLOCK(aEnv) + return handle; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Appearance__1getTexture +(JNIEnv* aEnv, jclass, jint aHApp, jint aUnit) +{ + M3G_DO_LOCK + jint texture = (jint)m3gGetTexture((M3GAppearance)aHApp, (M3Gint)aUnit); + M3G_DO_UNLOCK(aEnv) + return texture; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Appearance__1setFog +(JNIEnv* aEnv, jclass, jint aHApp, jint aHFog) +{ + M3G_DO_LOCK + m3gSetFog((M3GAppearance)aHApp, (M3GFog)aHFog); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Appearance__1setMaterial +(JNIEnv* aEnv, jclass, jint aHApp, jint aHMaterial) +{ + M3G_DO_LOCK + m3gSetMaterial((M3GAppearance)aHApp, (M3GMaterial)aHMaterial); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Appearance__1getMaterial +(JNIEnv* aEnv, jclass, jint aHApp) +{ + M3G_DO_LOCK + jint material = (jint)m3gGetMaterial((M3GAppearance)aHApp); + M3G_DO_UNLOCK(aEnv) + return material; +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/background.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/background.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,112 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "javax_microedition_m3g_Background.h" + +JNIEXPORT jboolean JNICALL Java_javax_microedition_m3g_Background__1isEnabled +(JNIEnv* aEnv, jclass, jint aHandle, jint aWhich) +{ + M3G_DO_LOCK + jboolean enabled = (jboolean)m3gIsBgEnabled((M3GBackground)aHandle, aWhich); + M3G_DO_UNLOCK(aEnv) + return enabled; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Background__1setCrop +(JNIEnv* aEnv, jclass, jint aHandle, jint aCropX, jint aCropY, jint aWidth, jint aHeight) +{ + M3G_DO_LOCK + m3gSetBgCrop((M3GBackground)aHandle, (M3Gint)aCropX, (M3Gint)aCropY, (M3Gint)aWidth, (M3Gint)aHeight); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Background__1setImageMode +(JNIEnv* aEnv, jclass, jint aHandle, jint aModeX, jint aModeY) +{ + M3G_DO_LOCK + m3gSetBgMode((M3GBackground)aHandle, aModeX, aModeY); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Background__1ctor +(JNIEnv* aEnv, jclass, jint aM3g) +{ + M3G_DO_LOCK + jint handle = (jint)m3gCreateBackground((M3GInterface)aM3g); + M3G_DO_UNLOCK(aEnv) + return handle; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Background__1getCrop +(JNIEnv* aEnv, jclass, jint aHandle, jint aWhich) +{ + M3G_DO_LOCK + jint crop = (jint)m3gGetBgCrop((M3GBackground)aHandle, aWhich); + M3G_DO_UNLOCK(aEnv) + return crop; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Background__1getImageMode +(JNIEnv* aEnv, jclass, jint aHandle, jint aWhich) +{ + M3G_DO_LOCK + jint mode = (jint)m3gGetBgMode((M3GBackground)aHandle, aWhich); + M3G_DO_UNLOCK(aEnv) + return mode; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Background__1setImage +(JNIEnv* aEnv, jclass, jint aHandle, jint aHImage) +{ + M3G_DO_LOCK + m3gSetBgImage((M3GBackground)aHandle, (M3GImage)aHImage); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Background__1setColor +(JNIEnv* aEnv, jclass, jint aHandle, jint aARGB) +{ + M3G_DO_LOCK + m3gSetBgColor((M3GBackground)aHandle, aARGB); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Background__1enable +(JNIEnv* aEnv, jclass, jint aHandle, jint aWhich, jboolean aEnable) +{ + M3G_DO_LOCK + m3gSetBgEnable((M3GBackground)aHandle, aWhich, aEnable); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Background__1getImage +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jint image = (jint)m3gGetBgImage((M3GBackground)aHandle); + M3G_DO_UNLOCK(aEnv) + return image; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Background__1getColor +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jint color = (jint)m3gGetBgColor((M3GBackground)aHandle); + M3G_DO_UNLOCK(aEnv) + return color; +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/camera.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/camera.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,121 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "javax_microedition_m3g_Camera.h" + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Camera__1setPerspective +(JNIEnv* aEnv, jclass, jint aHandle, jfloat aFovy, jfloat aAspectRatio, jfloat aNear, jfloat aFar) +{ + M3G_DO_LOCK + m3gSetPerspective((M3GCamera)aHandle, aFovy, aAspectRatio, aNear, aFar); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Camera__1setGeneric +(JNIEnv* aEnv, jclass, jint aHandle, jbyteArray aTransform) +{ + jbyte* elems = NULL; + if (aTransform) + { + elems = aEnv->GetByteArrayElements(aTransform, NULL); + if (elems == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + } + M3G_DO_LOCK + m3gSetProjectionMatrix((M3GCamera)aHandle, + (const M3GMatrix *)elems); + M3G_DO_UNLOCK(aEnv) + if (elems) + aEnv->ReleaseByteArrayElements(aTransform, elems, 0); +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Camera__1getProjectionAsParams +(JNIEnv* aEnv, jclass, jint aHandle, jfloatArray aParams) +{ + jfloat* elems = NULL; + + if (aParams && aEnv->GetArrayLength(aParams) < 4) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/IllegalArgumentException"); + return 0; + } + elems = NULL; + if (aParams) + { + elems = aEnv->GetFloatArrayElements(aParams, NULL); + if (elems == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + } + + M3G_DO_LOCK + jint ret = m3gGetProjectionAsParams((M3GCamera)aHandle, (jfloat*)elems); + M3G_DO_UNLOCK(aEnv) + + if (elems) + { + aEnv->ReleaseFloatArrayElements(aParams, elems, 0); + } + + return ret; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Camera__1setParallel +(JNIEnv* aEnv, jclass, jint aHandle, jfloat aHeight, jfloat aAspectRatio, jfloat aNear, jfloat aFar) +{ + M3G_DO_LOCK + m3gSetParallel((M3GCamera)aHandle, aHeight, aAspectRatio, aNear, aFar); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Camera__1ctor +(JNIEnv* aEnv, jclass, jint aM3g) +{ + M3G_DO_LOCK + jint handle = (jint)m3gCreateCamera((M3GInterface)aM3g); + M3G_DO_UNLOCK(aEnv) + return handle; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Camera__1getProjectionAsTransform +(JNIEnv* aEnv, jclass, jint aHandle, jbyteArray aTransform) +{ + jbyte* elems = NULL; + if (aTransform) + { + elems = aEnv->GetByteArrayElements(aTransform, NULL); + if (elems == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + } + + M3G_DO_LOCK + jint ret = m3gGetProjectionAsMatrix((M3GCamera)aHandle, + (M3GMatrix *)elems); + M3G_DO_UNLOCK(aEnv) + + if (elems) + aEnv->ReleaseByteArrayElements(aTransform, elems, 0); + return ret; +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/compositingMode.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/compositingMode.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,155 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "javax_microedition_m3g_CompositingMode.h" + +JNIEXPORT jboolean JNICALL Java_javax_microedition_m3g_CompositingMode__1isDepthTestEnabled +(JNIEnv* aEnv, jclass, jint aHCompositingMode) +{ + M3G_DO_LOCK + jboolean enabled = (jboolean)m3gIsDepthTestEnabled((M3GCompositingMode)aHCompositingMode); + M3G_DO_UNLOCK(aEnv) + return enabled; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_CompositingMode__1getBlending +(JNIEnv* aEnv, jclass, jint aHCompositingMode) +{ + M3G_DO_LOCK + jint blending = (jint)m3gGetBlending((M3GCompositingMode)aHCompositingMode); + M3G_DO_UNLOCK(aEnv) + return blending; +} + +JNIEXPORT jboolean JNICALL Java_javax_microedition_m3g_CompositingMode__1isAlphaWriteEnabled +(JNIEnv* aEnv, jclass, jint aHCompositingMode) +{ + M3G_DO_LOCK + jboolean enabled = (jboolean)m3gIsAlphaWriteEnabled((M3GCompositingMode)aHCompositingMode); + M3G_DO_UNLOCK(aEnv) + return enabled; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_CompositingMode__1enableDepthWrite +(JNIEnv* aEnv, jclass, jint aHCompositingMode, jboolean aEnable) +{ + M3G_DO_LOCK + m3gEnableDepthWrite((M3GCompositingMode)aHCompositingMode, (M3Gbool)aEnable); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_CompositingMode__1setAlphaThreshold +(JNIEnv* aEnv, jclass, jint aHCompositingMode, jfloat aThreshold) +{ + M3G_DO_LOCK + m3gSetAlphaThreshold((M3GCompositingMode)aHCompositingMode, (M3Gfloat)aThreshold); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_CompositingMode__1enableColorWrite +(JNIEnv* aEnv, jclass, jint aHCompositingMode, jboolean aEnable) +{ + M3G_DO_LOCK + m3gEnableColorWrite((M3GCompositingMode)aHCompositingMode, (M3Gbool)aEnable); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_CompositingMode__1setDepthOffset +(JNIEnv* aEnv, jclass, jint aHCompositingMode, jfloat aFactor, jfloat aUnits) +{ + M3G_DO_LOCK + m3gSetDepthOffset((M3GCompositingMode)aHCompositingMode, (M3Gfloat)aFactor, (M3Gfloat)aUnits); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_CompositingMode__1enableDepthTest +(JNIEnv* aEnv, jclass, jint aHCompositingMode, jboolean aEnable) +{ + M3G_DO_LOCK + m3gEnableDepthTest((M3GCompositingMode)aHCompositingMode, (M3Gbool)aEnable); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_CompositingMode__1ctor +(JNIEnv* aEnv, jclass, jint aM3g) +{ + M3G_DO_LOCK + jint handle = (jint)m3gCreateCompositingMode((M3GInterface)aM3g); + M3G_DO_UNLOCK(aEnv) + return handle; +} + +JNIEXPORT jboolean JNICALL Java_javax_microedition_m3g_CompositingMode__1isColorWriteEnabled +(JNIEnv* aEnv, jclass, jint aHCompositingMode) +{ + M3G_DO_LOCK + jboolean enabled = (jboolean)m3gIsColorWriteEnabled((M3GCompositingMode)aHCompositingMode); + M3G_DO_UNLOCK(aEnv) + return enabled; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_CompositingMode__1setAlphaWriteEnable +(JNIEnv* aEnv, jclass, jint aHCompositingMode, jboolean aEnable) +{ + M3G_DO_LOCK + m3gSetAlphaWriteEnable((M3GCompositingMode)aHCompositingMode, (M3Gbool)aEnable); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jboolean JNICALL Java_javax_microedition_m3g_CompositingMode__1isDepthWriteEnabled +(JNIEnv* aEnv, jclass, jint aHCompositingMode) +{ + M3G_DO_LOCK + jboolean enabled = (jboolean)m3gIsDepthWriteEnabled((M3GCompositingMode)aHCompositingMode); + M3G_DO_UNLOCK(aEnv) + return enabled; +} + +JNIEXPORT jfloat JNICALL Java_javax_microedition_m3g_CompositingMode__1getDepthOffsetFactor +(JNIEnv* aEnv, jclass, jint aHCompositingMode) +{ + M3G_DO_LOCK + jfloat factor = (jfloat)m3gGetDepthOffsetFactor((M3GCompositingMode)aHCompositingMode); + M3G_DO_UNLOCK(aEnv) + return factor; +} + +JNIEXPORT jfloat JNICALL Java_javax_microedition_m3g_CompositingMode__1getDepthOffsetUnits +(JNIEnv* aEnv, jclass, jint aHCompositingMode) +{ + M3G_DO_LOCK + jfloat offset = (jfloat)m3gGetDepthOffsetUnits((M3GCompositingMode)aHCompositingMode); + M3G_DO_UNLOCK(aEnv) + return offset; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_CompositingMode__1setBlending +(JNIEnv* aEnv, jclass, jint aHCompositingMode, jint aMode) +{ + M3G_DO_LOCK + m3gSetBlending((M3GCompositingMode)aHCompositingMode, (int)aMode); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jfloat JNICALL Java_javax_microedition_m3g_CompositingMode__1getAlphaThreshold +(JNIEnv* aEnv, jclass, jint aHCompositingMode) +{ + M3G_DO_LOCK + jfloat treshold = (jfloat)m3gGetAlphaThreshold((M3GCompositingMode)aHCompositingMode); + M3G_DO_UNLOCK(aEnv) + return treshold; +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/fog.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/fog.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,95 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "javax_microedition_m3g_Fog.h" + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Fog__1setMode +(JNIEnv* aEnv, jclass, jint aHandle, jint aMode) +{ + M3G_DO_LOCK + m3gSetFogMode((M3GFog)aHandle, aMode); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Fog__1setLinear +(JNIEnv* aEnv, jclass, jint aHandle, jfloat aNear, jfloat aFar) +{ + M3G_DO_LOCK + m3gSetFogLinear((M3GFog)aHandle, aNear, aFar); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jfloat JNICALL Java_javax_microedition_m3g_Fog__1getDistance +(JNIEnv* aEnv, jclass, jint aHandle, jint aWhich) +{ + M3G_DO_LOCK + jfloat distance = (jfloat)m3gGetFogDistance((M3GFog)aHandle, aWhich); + M3G_DO_UNLOCK(aEnv) + return distance; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Fog__1ctor +(JNIEnv* aEnv, jclass, jint aM3g) +{ + M3G_DO_LOCK + jint handle = (jint)m3gCreateFog((M3GInterface)aM3g); + M3G_DO_UNLOCK(aEnv) + return handle; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Fog__1getMode +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jint mode = (jint)m3gGetFogMode((M3GFog)aHandle); + M3G_DO_UNLOCK(aEnv) + return mode; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Fog__1setDensity +(JNIEnv* aEnv, jclass, jint aHandle, jfloat aDensity) +{ + M3G_DO_LOCK + m3gSetFogDensity((M3GFog)aHandle, aDensity); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jfloat JNICALL Java_javax_microedition_m3g_Fog__1getDensity +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jfloat density = (jfloat)m3gGetFogDensity((M3GFog)aHandle); + M3G_DO_UNLOCK(aEnv) + return density; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Fog__1setColor +(JNIEnv* aEnv, jclass, jint aHandle, jint aRGB) +{ + M3G_DO_LOCK + m3gSetFogColor((M3GFog)aHandle, aRGB); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Fog__1getColor +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jint color = (jint)m3gGetFogColor((M3GFog)aHandle); + M3G_DO_UNLOCK(aEnv) + return color; +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/graphics3d.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/graphics3d.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,733 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "javax_microedition_m3g_Graphics3D.h" + +/* + * Must be executed in UI thread + */ +JNIEXPORT jboolean JNICALL Java_javax_microedition_m3g_Graphics3D__1isProperRenderer +(JNIEnv* /*aEnv*/, jclass) +{ + EGLContext ctx; + EGLConfig config; + EGLSurface surf; + EGLint attrib[5]; + EGLint numConfigs; + bool isProperRenderer; + + // initialize EGL and create a temporary surface & context for reading + // the renderer string + eglInitialize(eglGetDisplay(EGL_DEFAULT_DISPLAY), NULL, NULL); + + attrib[0] = EGL_SURFACE_TYPE; + attrib[1] = EGL_PBUFFER_BIT; + attrib[2] = EGL_NONE; + + eglChooseConfig(eglGetDisplay(0), attrib, &config, 1, &numConfigs); + + ctx = eglCreateContext(eglGetDisplay(0), config, NULL, NULL); + + attrib[0] = EGL_WIDTH; + attrib[1] = 2; + attrib[2] = EGL_HEIGHT; + attrib[3] = 2; + attrib[4] = EGL_NONE; + + surf = eglCreatePbufferSurface(eglGetDisplay(0), config, attrib); + eglMakeCurrent(eglGetDisplay(0), surf, surf, ctx); + + // We check if proper renderer is used and return value which is stored + // on java side and passed to fuctions where is decided if m3g renders + // into mutable off-screen image or into framebuffer (see + // Java_javax_microedition_m3g_Graphics3D__1bindGraphics and + // releaseGraphicsTarget). + const GLubyte *info; + info = glGetString(GL_RENDERER); // get the renderer string + + // check if "MBX" substring is found + if ( !info || strstr((const char *)info, "MBX")) + { + // HW renderer detected. + // If "MBX" HW is detected we must reset alpha for mutable off-screen + // images by hand (see releaseGraphicsTarget). + isProperRenderer = false; + } + else + { + // Other renderers can use m3g core API m3gSetAlphaWrite without + // performance drop. + isProperRenderer = true; + } + + // destroy the temporary surface & context + eglMakeCurrent(eglGetDisplay(0), NULL, NULL, NULL); + eglDestroySurface(eglGetDisplay(0), surf); + eglDestroyContext(eglGetDisplay(0), ctx); + + return isProperRenderer; +} + +/* + * Must be executed in UI thread + */ +JNIEXPORT jboolean JNICALL Java_javax_microedition_m3g_Graphics3D__1bindGraphics +(JNIEnv* aEnv, jclass, jint aCtx, + jint aSurfaceHandle, jint aClipX, jint aClipY, jint aClipW, jint aClipH, + jboolean aDepth, jint aHintBits, jboolean aIsProperRenderer) +{ + M3GRenderContext ctx = (M3GRenderContext)aCtx; + + // Fetch the native peer of our target object + Java::GFX::WindowSurface* wsurf = reinterpret_cast(aSurfaceHandle); + + wsurf->bind(Java::GFX::WsTypeQtImage | Java::GFX::WsTypeEglSurface); + jboolean isImageTarget = false; /*cmidGraphics->IsImageTarget();*/ + + M3G_DO_LOCK + + /* + * Get the physical screen size and pass it to m3gcore. This affects (improves) the performance + * as the canvas frambuffer (rendering target) is larger than the physical screen size in + * devices that have more than one screen orientation, causing extra copying operations. + * + * This will improve m3g performance and suppresses extra bitmap copying. + */ + + //TRect screenRect = CCoeEnv::Static()->ScreenDevice()->SizeInPixels(); + + eglWaitNative(EGL_CORE_NATIVE_ENGINE); + + if (m3gSetRenderBuffers((M3GRenderContext)aCtx, aDepth ? + M3G_COLOR_BUFFER_BIT|M3G_DEPTH_BUFFER_BIT : + M3G_COLOR_BUFFER_BIT) && m3gSetRenderHints((M3GRenderContext)aCtx, aHintBits)) + { + + switch (wsurf->getType()) + { + case Java::GFX::WsTypeQtImage: + { + QImage* bitmap = wsurf->getQtImage(); + M3GPixelFormat format = mapQtPixelformat(bitmap->format()); + m3gBindMemoryTarget((M3GRenderContext)aCtx, bitmap->bits(), (M3Guint)bitmap->width(), (M3Guint)bitmap->height(), format, (M3Guint)(bitmap->width() * 4), NULL); + break; + } + case Java::GFX::WsTypeEglSurface: + { + if( eglQueryAPI() != EGL_OPENGL_ES_API ) + { + eglMakeCurrent( EGL_DEFAULT_DISPLAY, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT ); + eglBindAPI( EGL_OPENGL_ES_API ); + } + m3gBindEGLSurfaceTarget((M3GRenderContext)aCtx, wsurf->getEglSurface() ); + break; + } + default: + M3G_RAISE_EXCEPTION(aEnv, "java/lang/IllegalArgumentException"); + break; + } + + // Pass the physical screen size to m3gcore + //m3gSetDisplayArea(aCtx, screenRect.Width(), screenRect.Height()); + + m3gSetClipRect((M3GRenderContext)aCtx, aClipX, aClipY, aClipW, aClipH); + m3gSetViewport((M3GRenderContext)aCtx, aClipX, aClipY, aClipW, aClipH); + } + + M3G_DO_UNLOCK(aEnv) + + if (isImageTarget && aIsProperRenderer) + { + m3gSetAlphaWrite(ctx, M3G_FALSE); + } + + return isImageTarget; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Graphics3D__1setViewport +(JNIEnv* aEnv, jclass, jint aHContext, jint aX, jint aY, + jint aWidth, jint aHeight) +{ + M3G_DO_LOCK + m3gSetViewport((M3GRenderContext)aHContext, aX, aY, aWidth, aHeight); + M3G_DO_UNLOCK(aEnv) +} + + +static void releaseTarget(M3GRenderContext aCtx) +{ + eglWaitGL(); + m3gReleaseTarget(aCtx); +} + + +/* +static void releaseGraphicsTarget(M3GRenderContext aCtx, CMIDGraphics *aGraphics, + TBool aIsImageTarget, TBool aIsProperRenderer ) + { + releaseTarget(aCtx); + + // clear alpha for only mutable off-screen images (not for canvas/GameCanvas + // framebuffer) those images are indetified by aIsImageTarget argument + if (aIsImageTarget) + { + if ( aIsProperRenderer ) + { + m3gSetAlphaWrite(aCtx, M3G_TRUE); + } + else + { + CFbsBitmap *bitmap = aGraphics->Bitmap(); + + const TInt width = bitmap->SizeInPixels().iWidth; + const TInt height = bitmap->SizeInPixels().iHeight; + TInt stride = bitmap->ScanLineLength(width, bitmap->DisplayMode()); + + bitmap->LockHeap(); + + for (TInt i = 0; i < height; i++) + { + const void *srcAddr = + ((const char *) bitmap->DataAddress()) + i * stride; + unsigned char *src = (unsigned char *) srcAddr; + TInt count = width; + while (count--) + { + src += 3; //jump to last byte - alpha channel + //setting FF to alpha channel for non-canvas image targets + *src |= 0xff; + src++; + } + } + + bitmap->UnlockHeap(); + } + } + } +*/ +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Graphics3D__1releaseGraphics +(JNIEnv* aEnv, jclass, jint aHandle, + jint aSurfaceHandle, jboolean /*aIsImageTarget*/, jboolean /*aIsProperRenderer*/) +{ + M3G_DO_LOCK + + releaseTarget((M3GRenderContext)aHandle); + + // Release used target surface + Java::GFX::WindowSurface* surf = reinterpret_cast(aSurfaceHandle); + surf->release(); + + /* + CMIDGraphics *cmidGraphics = MIDUnhandObject(aGraphicsHandle); + + CJavaM3GEventSource* eventSource = + JavaUnhand(aEventSourceHandle); + eventSource->ExecuteV(&releaseGraphicsTarget, ((M3GRenderContext) aHandle), + cmidGraphics, ((TBool) aIsImageTarget), ((TBool) aIsProperRenderer) ); + */ + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Graphics3D__1setCamera +(JNIEnv* aEnv, jclass, jint aHContext, jint aHCamera, jbyteArray aTransform) +{ + M3GMatrix *transform = NULL; + if (aTransform) + { + transform = (Matrix *)(aEnv->GetByteArrayElements(aTransform, NULL)); + if (transform == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + } + + M3G_DO_LOCK + m3gSetCamera((M3GRenderContext) aHContext, (M3GCamera) aHCamera, transform); + M3G_DO_UNLOCK(aEnv) + + if (transform) + { + aEnv->ReleaseByteArrayElements(aTransform, (jbyte*)transform, JNI_ABORT); + } +} + +/* +static void renderWorld(M3GRenderContext aHContext, + M3GWorld aHWorld) +{ + m3gRenderWorld(aHContext, aHWorld); +} +*/ + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Graphics3D__1renderWorld +(JNIEnv* aEnv, jclass, jint aHContext, jint aHWorld) +{ + M3G_DO_LOCK + + m3gRenderWorld((M3GRenderContext) aHContext, (M3GWorld) aHWorld); + + /* + CJavaM3GEventSource* eventSource = JavaUnhand(aEventSourceHandle); + eventSource->ExecuteV(&renderWorld, + (M3GRenderContext) aHContext, + (M3GWorld) aHWorld); + */ + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Graphics3D__1ctor +(JNIEnv* aEnv, jclass, jint aM3g) +{ + M3G_DO_LOCK + M3GRenderContext ctx = m3gCreateContext((M3GInterface)aM3g); + M3G_DO_UNLOCK(aEnv) + + return (jint)ctx; +} + +struct RenderStruct +{ + M3GVertexBuffer hVertices; + M3GIndexBuffer hIndices; + M3GAppearance hAppearance; + const M3GMatrix *transform; +}; + +/* +static void renderImmediate(M3GRenderContext aHContext, RenderStruct *aR, jint aScope) +{ + m3gRender(aHContext, + aR->hVertices, + aR->hIndices, + aR->hAppearance, + aR->transform, 1.0f, aScope); +} +*/ + +/* + * Must be executed in UI thread + */ + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Graphics3D__1render +(JNIEnv* aEnv, jclass, jint aHContext, + jint aHVertices, jint aHIndices, jint aHAppearance, jbyteArray aTransform, jint aScope) +{ + M3GMatrix *transform = NULL; + if (aTransform) + { + transform = (M3GMatrix *)aEnv->GetByteArrayElements(aTransform, NULL); + if (transform == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + } + + /* + RenderStruct r; + r.hVertices = (M3GVertexBuffer) aHVertices; + r.hIndices = (M3GIndexBuffer) aHIndices; + r.hAppearance = (M3GAppearance) aHAppearance; + r.transform = transform; + */ + + + M3G_DO_LOCK + + m3gRender((M3GRenderContext) aHContext, (M3GVertexBuffer) aHVertices, (M3GIndexBuffer) aHIndices, (M3GAppearance) aHAppearance, + transform, 1.0f, aScope); + + /* + CJavaM3GEventSource* eventSource = JavaUnhand(aEventSourceHandle); + eventSource->ExecuteV(&renderImmediate, ((M3GRenderContext) aHContext), &r, aScope); + */ + M3G_DO_UNLOCK(aEnv) + + + if (transform) + { + aEnv->ReleaseByteArrayElements(aTransform, (jbyte*)transform, JNI_ABORT); + } +} + +/* +static void clear(M3GRenderContext aHContext, M3GBackground aHBackground) +{ + m3gClear(aHContext, aHBackground); +} +*/ + +/* + * Must be executed in UI thread + */ +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Graphics3D__1clear +(JNIEnv* aEnv, jclass, jint aCtx, jint aBg) +{ + M3G_DO_LOCK + m3gClear((M3GRenderContext)aCtx, (M3GBackground)aBg); + + /* + CJavaM3GEventSource* eventSource = JavaUnhand(aEventSourceHandle); + eventSource->ExecuteV(&clear, (M3GRenderContext)aCtx, (M3GBackground)aBg); + */ + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Graphics3D__1releaseImage +(JNIEnv* aEnv, jclass, jint aHCtx) +{ + M3G_DO_LOCK + + releaseTarget((M3GRenderContext)aHCtx); + + /* + CJavaM3GEventSource* eventSource = JavaUnhand(aEventSourceHandle); + eventSource->ExecuteV(&releaseTarget, (M3GRenderContext)aHCtx); + */ + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Graphics3D__1addRef +(JNIEnv* aEnv, jclass, jint aObject) +{ + M3G_DO_LOCK + m3gAddRef((M3GObject) aObject); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Graphics3D__1addLight +(JNIEnv* aEnv, jclass, jint aHContext, jint aHLight, jbyteArray aTransform) +{ + M3GMatrix *transform = NULL; + if (aTransform) + { + transform = (M3GMatrix *)(aEnv->GetByteArrayElements(aTransform, NULL)); + if (transform == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + } + M3G_DO_LOCK + int idx = m3gAddLight((M3GRenderContext) aHContext, (M3GLight) aHLight, transform); + M3G_DO_UNLOCK(aEnv) + + if (transform) + { + aEnv->ReleaseByteArrayElements(aTransform, (jbyte*)transform, JNI_ABORT); + } + + return idx; +} + +/* +static void bindImage(M3GRenderContext hCtx, M3GImage hImg, M3Gbool depth, M3Gbitmask hintBits) +{ + if (m3gSetRenderBuffers(hCtx, depth ? M3G_COLOR_BUFFER_BIT|M3G_DEPTH_BUFFER_BIT : M3G_COLOR_BUFFER_BIT) && m3gSetRenderHints(hCtx, hintBits)) { + m3gBindImageTarget(hCtx, hImg); + } +} +*/ + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Graphics3D__1bindImage +(JNIEnv* aEnv, jclass, jint aHCtx, jint aImageHandle, jboolean aDepth, jint aHintBits) +{ + M3G_DO_LOCK + + if (m3gSetRenderBuffers((M3GRenderContext)aHCtx, (M3Gbool)aDepth ? M3G_COLOR_BUFFER_BIT|M3G_DEPTH_BUFFER_BIT : M3G_COLOR_BUFFER_BIT) && m3gSetRenderHints((M3GRenderContext)aHCtx, (M3Gbitmask)aHintBits)) + { + m3gBindImageTarget((M3GRenderContext)aHCtx, (M3GImage)aImageHandle); + } + + //CJavaM3GEventSource* eventSource = JavaUnhand(aEventSourceHandle); + //eventSource->ExecuteV(&bindImage, (M3GRenderContext)aHCtx, (M3GImage)aImageHandle, (M3Gbool)aDepth, (M3Gbitmask)aHintBits); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Graphics3D__1resetLights +(JNIEnv* aEnv, jclass, jint aHContext) +{ + M3G_DO_LOCK + m3gClearLights((M3GRenderContext) aHContext); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Graphics3D__1setDepthRange +(JNIEnv* aEnv, jclass, jint aHContext, jfloat aDepthNear, jfloat aDepthFar) +{ + M3G_DO_LOCK + m3gSetDepthRange((M3GRenderContext) aHContext, aDepthNear, aDepthFar); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Graphics3D__1setLight +(JNIEnv* aEnv, jclass, jint aHContext, jint aLightIndex, jint aHLight, jbyteArray aTransform) +{ + M3GMatrix *transform = NULL; + if (aTransform) + { + transform = (M3GMatrix *)(aEnv->GetByteArrayElements(aTransform, NULL)); + if (transform == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + } + + M3G_DO_LOCK + m3gSetLight((M3GRenderContext) aHContext, aLightIndex, (M3GLight) aHLight, transform); + M3G_DO_UNLOCK(aEnv) + + if (transform) + { + aEnv->ReleaseByteArrayElements(aTransform, (jbyte*)transform, JNI_ABORT); + } +} + +/* +static void renderNode(M3GRenderContext aHCtx, + M3GNode aHNode, + const M3GMatrix *aMtx) +{ + m3gRenderNode(aHCtx, aHNode, aMtx); +} +*/ + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Graphics3D__1renderNode +(JNIEnv* aEnv, jclass, jint aHCtx, jint aHNode, jbyteArray aTransform) +{ + M3GMatrix *transform = NULL; + if (aTransform) + { + transform = (M3GMatrix *)(aEnv->GetByteArrayElements(aTransform, NULL)); + if (transform == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + } + + M3G_DO_LOCK + + m3gRenderNode((M3GRenderContext)aHCtx, (M3GNode)aHNode, (const M3GMatrix *)transform); + + //CJavaM3GEventSource* eventSource = JavaUnhand(aEventSourceHandle); + //eventSource->ExecuteV(&renderNode, (M3GRenderContext)aHCtx, (M3GNode)aHNode, (const M3GMatrix *)transform); + M3G_DO_UNLOCK(aEnv) + + if (aTransform) + { + aEnv->ReleaseByteArrayElements(aTransform, (jbyte*)transform, JNI_ABORT); + } +} + +#if defined(M3G_ENABLE_PROFILING) + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Graphics3D__1getStatistics +(JNIEnv* aEnv, jclass, jintArray aStatArray) +{ + const M3Gint *statArray = (M3Gint *)(aStatArray != NULL ? aEnv->GetIntArrayElements(aStatArray, NULL) : NULL); + jint statArrayLength = aStatArray ? aEnv->GetArrayLength(aStatArray) : 0; + + if (statArray != NULL && statArrayLength >= sizeof(m3gs_statistic)) + { + m3gCopy((void*)statArray, m3gs_statistic, sizeof(m3gs_statistic)); + } + + M3G_DO_LOCK + m3gZero(m3gs_statistic, sizeof(m3gs_statistic)); + M3G_DO_UNLOCK(aEnv) + + if (statArray) + { + aEnv->ReleaseIntArrayElements(aStatArray, (jint*)statArray, 0); + } + + return sizeof(m3gs_statistic); +} + +#endif /* M3G_ENABLE_PROFILING */ + + + +/* M3G 1.1 JNI Calls */ + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Graphics3D__1getViewTransform +(JNIEnv* aEnv, jclass, jint aHCtx, jbyteArray aTransform) +{ + M3GMatrix *transform = NULL; + if (aTransform) + { + transform = (M3GMatrix *)(aEnv->GetByteArrayElements(aTransform, NULL)); + if (transform == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + } + + M3G_DO_LOCK + m3gGetViewTransform((M3GRenderContext) aHCtx, transform); + M3G_DO_UNLOCK(aEnv) + + if (transform) + { + /* copy array to Java side and release arrays */ + aEnv->ReleaseByteArrayElements(aTransform, (jbyte*)transform, 0); + } +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Graphics3D__1getCamera +(JNIEnv* aEnv, jclass, jint aHCtx) +{ + M3G_DO_LOCK + jint camera = (jint)m3gGetCamera((M3GRenderContext)aHCtx); + M3G_DO_UNLOCK(aEnv) + + return camera; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Graphics3D__1getLightTransform +(JNIEnv* aEnv, jclass, jint aHCtx, jint aLightIndex, jbyteArray aTransform) +{ + M3GMatrix *transform = NULL; + if (aTransform) + { + transform = (M3GMatrix *)(aEnv->GetByteArrayElements(aTransform, NULL)); + if (transform == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + } + M3G_DO_LOCK + int lightTransform = (M3Guint)m3gGetLightTransform((M3GRenderContext)aHCtx, aLightIndex, transform); + M3G_DO_UNLOCK(aEnv) + + if (transform) + { + aEnv->ReleaseByteArrayElements(aTransform, (jbyte*)transform, 0); + } + + return (jint)lightTransform; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Graphics3D__1getLightCount +(JNIEnv* aEnv, jclass, jint aHCtx) +{ + M3G_DO_LOCK + jint lightCount = (jint)m3gGetLightCount((M3GRenderContext)aHCtx); + M3G_DO_UNLOCK(aEnv) + + return lightCount; +} + +JNIEXPORT jfloat JNICALL Java_javax_microedition_m3g_Graphics3D__1getDepthRangeNear +(JNIEnv* aEnv, jclass, jint aHCtx) +{ + float depthNear = 0; + float depthFar = 0; + + M3G_DO_LOCK + m3gGetDepthRange((M3GRenderContext) aHCtx, &depthNear, &depthFar); + M3G_DO_UNLOCK(aEnv) + + return (jfloat)depthNear; +} + +JNIEXPORT jfloat JNICALL Java_javax_microedition_m3g_Graphics3D__1getDepthRangeFar +(JNIEnv* aEnv, jclass, jint aHCtx) +{ + float depthNear = 0; + float depthFar = 0; + + M3G_DO_LOCK + m3gGetDepthRange((M3GRenderContext) aHCtx, &depthNear, &depthFar); + M3G_DO_UNLOCK(aEnv) + + return (jfloat)depthFar; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Graphics3D__1getViewportX +(JNIEnv* aEnv, jclass, jint aHCtx) +{ + int viewport[4]; + + M3G_DO_LOCK + m3gGetViewport((M3GRenderContext)aHCtx, &viewport[0], + &viewport[1], + &viewport[2], + &viewport[3]); + M3G_DO_UNLOCK(aEnv) + + return (jint)viewport[0]; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Graphics3D__1getViewportY +(JNIEnv* aEnv, jclass, jint aHCtx) +{ + int viewport[4]; + + M3G_DO_LOCK + m3gGetViewport((M3GRenderContext)aHCtx, &viewport[0], + &viewport[1], + &viewport[2], + &viewport[3]); + M3G_DO_UNLOCK(aEnv) + + return (jint)viewport[1]; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Graphics3D__1getViewportWidth +(JNIEnv* aEnv, jclass, jint aHCtx) +{ + int viewport[4]; + + M3G_DO_LOCK + m3gGetViewport((M3GRenderContext)aHCtx, &viewport[0], + &viewport[1], + &viewport[2], + &viewport[3]); + M3G_DO_UNLOCK(aEnv) + + return (jint)viewport[2]; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Graphics3D__1getViewportHeight +(JNIEnv* aEnv, jclass, jint aHCtx) +{ + int viewport[4]; + + M3G_DO_LOCK + m3gGetViewport((M3GRenderContext)aHCtx, &viewport[0], + &viewport[1], + &viewport[2], + &viewport[3]); + M3G_DO_UNLOCK(aEnv) + + return (jint)viewport[3]; +} + +JNIEXPORT jboolean JNICALL Java_javax_microedition_m3g_Graphics3D__1isAASupported +(JNIEnv* /*aEnv*/, jclass, jint aM3g) +{ + M3Gbool aaSupport = M3G_FALSE; + + aaSupport = m3gIsAntialiasingSupported((M3GInterface)aM3g); + + return (jboolean)aaSupport; +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/group.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/group.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,126 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "javax_microedition_m3g_Group.h" + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Group__1addChild +(JNIEnv* aEnv, jclass, jint aHandle, jint aHNode) +{ + M3G_DO_LOCK + m3gAddChild((M3GGroup)aHandle, (M3GNode)aHNode); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Group__1ctor +(JNIEnv* aEnv, jclass, jint aM3g) +{ + M3G_DO_LOCK + jint handle = (jint)m3gCreateGroup((M3GInterface)aM3g); + M3G_DO_UNLOCK(aEnv) + return handle; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Group__1pick2D +(JNIEnv* aEnv, jclass, jint aHandle, jint aMask, jfloat aX, jfloat aY, jint aHCamera, jfloatArray aResult) +{ + jfloat* elems = NULL; + if (aResult) + { + elems = aEnv->GetFloatArrayElements(aResult, NULL); + if (elems == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + } + + M3G_BEGIN_PROFILE(M3G_PROFILE_PICK); + M3G_DO_LOCK + jint ret = (jint)m3gPick2D((M3GGroup)aHandle, aMask, aX, aY, (M3GCamera)aHCamera, (jfloat*)elems); + M3G_DO_UNLOCK(aEnv) + M3G_END_PROFILE(M3G_PROFILE_PICK); + + if (aResult) + aEnv->ReleaseFloatArrayElements(aResult, elems, 0); + return ret; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Group__1getChild +(JNIEnv* aEnv, jclass, jint aHandle, jint aIndex) +{ + M3G_DO_LOCK + jint child = (jint)m3gGetChild((M3GGroup)aHandle, aIndex); + M3G_DO_UNLOCK(aEnv) + return child; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Group__1pick3D +(JNIEnv* aEnv, jclass, jint aHandle, jint aMask, jfloatArray aRay, jfloatArray aResult) +{ + jfloat* rayElems = NULL; + if (aRay) + { + rayElems = aEnv->GetFloatArrayElements(aRay, NULL); + if (rayElems == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + } + + jfloat* resultElems = NULL; + if (aResult) + { + resultElems = aEnv->GetFloatArrayElements(aResult, NULL); + if (resultElems == NULL) + { + if (rayElems) + aEnv->ReleaseFloatArrayElements(aRay, rayElems, JNI_ABORT); + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + } + + M3G_BEGIN_PROFILE(M3G_PROFILE_PICK); + M3G_DO_LOCK + jint ret = (jint)m3gPick3D((M3GGroup)aHandle, aMask, (jfloat*)rayElems, (jfloat*)resultElems); + M3G_DO_UNLOCK(aEnv) + M3G_END_PROFILE(M3G_PROFILE_PICK); + + if (resultElems) + aEnv->ReleaseFloatArrayElements(aResult, resultElems, 0); + if (rayElems) + aEnv->ReleaseFloatArrayElements(aRay, rayElems, 0); + return ret; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Group__1getChildCount +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jint count =(jint)m3gGetChildCount((M3GGroup)aHandle); + M3G_DO_UNLOCK(aEnv) + return count; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Group__1removeChild +(JNIEnv* aEnv, jclass, jint aHandle, jint aHNode) +{ + M3G_DO_LOCK + m3gRemoveChild((M3GGroup)aHandle, (M3GNode)aHNode); + M3G_DO_UNLOCK(aEnv) +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/image2d.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/image2d.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,293 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "javax_microedition_m3g_Image2D.h" + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Image2D__1set +(JNIEnv* aEnv, jclass, jint aHImage2D, jint aX, jint aY, jint aWidth, jint aHeight, jbyteArray aImageArray) +{ + jbyte* imageArray = NULL; + if (aImageArray) + { + imageArray = aEnv->GetByteArrayElements(aImageArray, NULL); + if (imageArray == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + } + M3G_DO_LOCK + m3gSetSubImage((M3GImage)aHImage2D, aX, aY, aWidth, aHeight, aImageArray ? aEnv->GetArrayLength(aImageArray) : NULL, imageArray); + M3G_DO_UNLOCK(aEnv) + + if (imageArray) + { + aEnv->ReleaseByteArrayElements(aImageArray, imageArray, JNI_ABORT); + } +} + +static void getImageScanline(const QImage* qtImage, + M3Gint line, + M3Gint bpl, + M3Guint *pixels, + M3Gbool *trueAlpha) +{ + + // Get pointer to start of requested line + const unsigned char* srcAddr = qtImage->bits() + line * bpl; + + // As input and output are in the same, i.e. #AARRGGBB format, + // just run mem copy from source to destination to copy one line + memcpy(pixels, srcAddr, bpl); + *trueAlpha = false; +} + +/* + * Must be excuted in UI thread + */ +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Image2D__1ctorImage +(JNIEnv* aEnv, jclass, jint aHM3g, jint aFormat, jint aImageHandle) +{ + + if (aImageHandle != 0) + { + Java::GFX::Image* cgfxImage = reinterpret_cast(aImageHandle); + QImage qtImage; + + if (!cgfxImage) + { + return 0; + } + else + { + qtImage = cgfxImage->toImage(); + if (qtImage.isNull()) + { + return 0; + } + } + + // m3g needs format in 32bpp, i.e. in RGB32 or ARGB32 so + // if format is not one of those convert it here + if ((qtImage.format() != QImage::Format_ARGB32) || (qtImage.format() != QImage::Format_RGB32)) + { + qtImage = qtImage.convertToFormat(QImage::Format_ARGB32); + if (qtImage.isNull()) + { + return 0; + } + } + + // Create Image2D + M3GImage image; + M3Gint width = qtImage.width(); + M3Gint height = qtImage.height(); + M3Gint bpl = qtImage.bytesPerLine(); + + M3G_DO_LOCK + + image = m3gCreateImage((M3GInterface)aHM3g, (M3GImageFormat)aFormat, width, height, 0); + if (image == NULL) + { + return 0; // exception automatically raised + } + + M3Guint *tempPixels = (M3Guint *) malloc(width * 4); + if (tempPixels == NULL) + { + m3gDeleteObject((M3GObject) image); + return 0; + } + + // read and write scanline by scanline + for (M3Gint y = 0; y < height; ++y) + { + M3Gbool trueAlpha; + getImageScanline(&qtImage, y, bpl, tempPixels, &trueAlpha); + m3gSetImageScanline(image, y, trueAlpha, tempPixels); + } + + // finally commit image + m3gCommitImage(image); + + M3G_DO_UNLOCK(aEnv) + + // free memory + free(tempPixels); + + cgfxImage = NULL; + return reinterpret_cast(image); + } + return 0; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Image2D__1getFormat +(JNIEnv* aEnv, jclass, jint aHImage2D) +{ + M3G_DO_LOCK + jint format = (jint)m3gGetFormat((M3GImage)aHImage2D); + M3G_DO_UNLOCK(aEnv) + return format; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Image2D__1ctorSizePixelsPalette +(JNIEnv* aEnv, jclass, jint aM3g, jint aFormat, jint aWidth, jint aHeight, jbyteArray aImage, jbyteArray aPalette) +{ + M3GImageFormat format = (M3GImageFormat)aFormat; + + int bpp = jsr184BytesPerPixel(format); + + if (validateArray(aEnv, aImage, aWidth * aHeight)) + { + if (aPalette == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/NullPointerException"); + return 0; + } + int paletteLen = aEnv->GetArrayLength(aPalette); + if ((paletteLen < 256 *(unsigned)bpp) && + (paletteLen % (unsigned)bpp != 0)) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/IllegalArgumentException"); + return 0; + } + else + { + M3G_DO_LOCK + + M3GImage hImg = m3gCreateImage((M3GInterface)aM3g, + format, + aWidth, aHeight, + M3G_PALETTED); + if (hImg != NULL) + { + jbyte* palette = NULL; + + int numEntries = paletteLen / bpp; + if (numEntries > 256) + { + numEntries = 256; + } + + jbyte* image = aEnv->GetByteArrayElements(aImage, NULL); + if (image == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + + m3gSetImage(hImg, image); + + palette = aEnv->GetByteArrayElements(aPalette, NULL); + if (palette == NULL) + { + if (image) + { + aEnv->ReleaseByteArrayElements(aImage, image, JNI_ABORT); + } + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + + m3gSetImagePalette(hImg, numEntries, palette); + m3gCommitImage(hImg); + + if (image) + { + aEnv->ReleaseByteArrayElements(aImage, image, JNI_ABORT); + } + if (palette) + { + aEnv->ReleaseByteArrayElements(aPalette, palette, JNI_ABORT); + } + } + M3G_DO_UNLOCK(aEnv) + return ((unsigned) hImg); + } + } + return 0; +} + +JNIEXPORT jboolean JNICALL Java_javax_microedition_m3g_Image2D__1isMutable +(JNIEnv* aEnv, jclass, jint aHImage2D) +{ + M3G_DO_LOCK + jboolean isMutable = (jboolean)m3gIsMutable((M3GImage)aHImage2D); + M3G_DO_UNLOCK(aEnv) + return isMutable; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Image2D__1getHeight +(JNIEnv* aEnv, jclass, jint aHImage2D) +{ + M3G_DO_LOCK + jint height = (jint)m3gGetHeight((M3GImage)aHImage2D); + M3G_DO_UNLOCK(aEnv) + return height; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Image2D__1ctorSize +(JNIEnv* aEnv, jclass, jint aM3g, jint aFormat, jint aWidth, jint aHeight) +{ + M3G_DO_LOCK + jint handle = (M3Guint) m3gCreateImage((M3GInterface)aM3g, + (M3GImageFormat)aFormat, + aWidth, aHeight, + M3G_DYNAMIC|M3G_RENDERING_TARGET); + M3G_DO_UNLOCK(aEnv) + return handle; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Image2D__1getWidth +(JNIEnv* aEnv, jclass, jint aHImage2D) +{ + M3G_DO_LOCK + jint width = (jint)m3gGetWidth((M3GImage)aHImage2D); + M3G_DO_UNLOCK(aEnv) + return width; +} + + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Image2D__1ctorSizePixels +(JNIEnv* aEnv, jclass, jint aM3g, jint aFormat, jint aWidth, jint aHeight, jbyteArray aImage) +{ + M3GImageFormat format = (M3GImageFormat)aFormat; + + if (validateArray(aEnv, aImage, jsr184BytesPerPixel(format) * aWidth * aHeight)) + { + M3G_DO_LOCK + + M3GImage hImg = m3gCreateImage((M3GInterface)aM3g, format, aWidth, aHeight, 0); + if (hImg != NULL) + { + M3GImageFormat format = (M3GImageFormat)aFormat; + + int bpp = jsr184BytesPerPixel(format); + jbyte* imageScanline = (jbyte*)malloc(aWidth * bpp); + for (int i=0; i < aHeight; i++) + { + aEnv->GetByteArrayRegion(aImage, aWidth * i * bpp, aWidth * bpp, imageScanline); + m3gSetSubImage(hImg, 0, i, aWidth, 1, aWidth * bpp, imageScanline); + } + m3gCommitImage(hImg); + + free(imageScanline); + } + M3G_DO_UNLOCK(aEnv) + return (unsigned) hImg; + } + return 0; +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/interface.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/interface.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "javax_microedition_m3g_Interface.h" + + +/*! + * \brief Error handler for the Java interface + * + * Converts M3G errors to exceptions and throws them automatically. + */ +static void errorHandler(M3Genum errorCode, M3GInterface /*m3g*/) +{ + CSynchronization::InstanceL()->SetErrorCode(errorCode); +} + +/* +static int createInterface(M3Gparams* aCs) +{ + return ((unsigned) m3gCreateInterface(aCs)); +} +*/ + +/* + * Must be executed in UI thread + */ +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Interface__1ctor(JNIEnv* aEnv, jclass) +{ + M3Gparams cs; + memset(&cs, 0, sizeof(cs)); + cs.mallocFunc = malloc; + cs.freeFunc = free; + cs.errorFunc = errorHandler; + + M3G_DO_LOCK + /* Call to the Eventserver side */ + //CJavaM3GEventSource* eventSource = JavaUnhand(aEventSourceHandle); + //jint handle = eventSource->Execute(&createInterface, &cs); + jint handle = (unsigned)m3gCreateInterface(&cs); + M3G_DO_UNLOCK(aEnv); + return handle; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Interface__1getClassID +(JNIEnv* aEnv, jclass, jint aHObject) +{ + M3G_DO_LOCK + jint handle = m3gGetClass((M3GObject)aHObject); + M3G_DO_UNLOCK(aEnv); + return handle; +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/keyframeSequence.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/keyframeSequence.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,187 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "javax_microedition_m3g_KeyframeSequence.h" + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_KeyframeSequence__1getRepeatMode +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jint mode = (jint)m3gGetRepeatMode((M3GKeyframeSequence)aHandle); + M3G_DO_UNLOCK(aEnv) + return mode; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_KeyframeSequence__1setKeyframe +(JNIEnv* aEnv, jclass, jint aHandle, jint aIndex, jint aTime, jfloatArray aValue) +{ + jfloat* elems = NULL; + if (aValue) + { + elems = aEnv->GetFloatArrayElements(aValue, NULL); + if (elems == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + } + + jsize length = aValue ? aEnv->GetArrayLength(aValue) : 0; + + M3G_DO_LOCK + m3gSetKeyframe((M3GKeyframeSequence)aHandle, + aIndex, + aTime, + length, + (const M3Gfloat *)elems); + M3G_DO_UNLOCK(aEnv) + + if (elems) + aEnv->ReleaseFloatArrayElements(aValue, elems, 0); +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_KeyframeSequence__1setRepeatMode +(JNIEnv* aEnv, jclass, jint aHandle, jint aMode) +{ + M3G_DO_LOCK + m3gSetRepeatMode((M3GKeyframeSequence)aHandle, (M3Genum)aMode); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_KeyframeSequence__1setDuration +(JNIEnv* aEnv, jclass, jint aHandle, jint aDuration) +{ + M3G_DO_LOCK + m3gSetDuration((M3GKeyframeSequence)aHandle, (int)aDuration); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_KeyframeSequence__1ctor +(JNIEnv* aEnv, jclass, jint aM3g, jint aNumKeyframes, jint aNumComponents, jint aInterpolation) +{ + M3G_DO_LOCK + jint handle = (jint)m3gCreateKeyframeSequence((M3GInterface)aM3g, aNumKeyframes, + aNumComponents, aInterpolation); + M3G_DO_UNLOCK(aEnv) + return handle; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_KeyframeSequence__1setValidRange +(JNIEnv* aEnv, jclass, jint aHandle, jint aFirst, jint aLast) +{ + M3G_DO_LOCK + m3gSetValidRange((M3GKeyframeSequence)aHandle, aFirst, aLast); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_KeyframeSequence__1getDuration +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jint duration = (jint)m3gGetDuration((M3GKeyframeSequence)aHandle); + M3G_DO_UNLOCK(aEnv) + return duration; +} + +/* M3G 1.1 JNI Calls */ + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_KeyframeSequence__1getComponentCount +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jint count = (jint)m3gGetComponentCount((M3GKeyframeSequence)aHandle); + M3G_DO_UNLOCK(aEnv) + return count; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_KeyframeSequence__1getInterpolationType +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jint type = (jint)m3gGetInterpolationType((M3GKeyframeSequence)aHandle); + M3G_DO_UNLOCK(aEnv) + return type; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_KeyframeSequence__1getKeyframe +(JNIEnv* aEnv, jclass, jint aHandle, jint aIndex, jfloatArray aValue) +{ + jfloat* elems = NULL; + if (aValue) + { + elems = aEnv->GetFloatArrayElements(aValue, NULL); + if (elems == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + } + + jsize length = aValue ? aEnv->GetArrayLength(aValue) : 0; + + if ((length < m3gGetComponentCount((M3GKeyframeSequence)aHandle)) && + (aValue != NULL)) + { + if (elems) + { + aEnv->ReleaseFloatArrayElements(aValue, elems, JNI_ABORT); + } + M3G_RAISE_EXCEPTION(aEnv, "java/lang/IllegalArgumentException"); + return 0; + } + + M3G_DO_LOCK + jint keyFrame = m3gGetKeyframe((M3GKeyframeSequence)aHandle, aIndex, elems); + M3G_DO_UNLOCK(aEnv) + + if (elems) + { + /* copy array to java side and release arrays */ + aEnv->ReleaseFloatArrayElements(aValue, elems, 0); + } + return keyFrame; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_KeyframeSequence__1getKeyframeCount +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jint count = (jint)m3gGetKeyframeCount((M3GKeyframeSequence)aHandle); + M3G_DO_UNLOCK(aEnv) + return count; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_KeyframeSequence__1getValidRangeFirst +(JNIEnv* aEnv, jclass, jint aHandle) +{ + int first = 0; + int last = 0; + M3G_DO_LOCK + m3gGetValidRange((M3GKeyframeSequence)aHandle, &first, &last); + M3G_DO_UNLOCK(aEnv) + return first; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_KeyframeSequence__1getValidRangeLast +(JNIEnv* aEnv, jclass, jint aHandle) +{ + int first = 0; + int last = 0; + M3G_DO_LOCK + m3gGetValidRange((M3GKeyframeSequence)aHandle, &first, &last); + M3G_DO_UNLOCK(aEnv) + return last; +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/light.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/light.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,129 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "javax_microedition_m3g_Light.h" + +JNIEXPORT jfloat JNICALL Java_javax_microedition_m3g_Light__1getSpotAngle +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jfloat angle = (jfloat)m3gGetSpotAngle((M3GLight)aHandle); + M3G_DO_UNLOCK(aEnv) + return angle; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Light__1setSpotExponent +(JNIEnv* aEnv, jclass, jint aHandle, jfloat aExponent) +{ + M3G_DO_LOCK + m3gSetSpotExponent((M3GLight)aHandle, aExponent); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Light__1setMode +(JNIEnv* aEnv, jclass, jint aHandle, jint aMode) +{ + M3G_DO_LOCK + m3gSetLightMode((M3GLight)aHandle, (int)aMode); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Light__1setAttenuation +(JNIEnv* aEnv, jclass, jint aHandle, jfloat aConstant, jfloat aLinear, jfloat aQuadratic) +{ + M3G_DO_LOCK + m3gSetAttenuation((M3GLight)aHandle, aConstant, aLinear, aQuadratic); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Light__1setIntensity +(JNIEnv* aEnv, jclass, jint aHandle, jfloat aIntensity) +{ + M3G_DO_LOCK + m3gSetIntensity((M3GLight)aHandle, aIntensity); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Light__1ctor +(JNIEnv* aEnv, jclass, jint aM3g) +{ + M3G_DO_LOCK + jint handle = (jint)m3gCreateLight((M3GInterface)aM3g); + M3G_DO_UNLOCK(aEnv) + return handle; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Light__1getMode +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jint mode = (jint)m3gGetLightMode((M3GLight)aHandle); + M3G_DO_UNLOCK(aEnv) + return mode; +} + +JNIEXPORT jfloat JNICALL Java_javax_microedition_m3g_Light__1getAttenuation +(JNIEnv* aEnv, jclass, jint aHandle, jint aType) +{ + M3G_DO_LOCK + jfloat att = (jfloat)m3gGetAttenuation((M3GLight)aHandle, aType); + M3G_DO_UNLOCK(aEnv) + return att; +} + +JNIEXPORT jfloat JNICALL Java_javax_microedition_m3g_Light__1getSpotExponent +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jfloat spotExp = (jfloat)m3gGetSpotExponent((M3GLight)aHandle); + M3G_DO_UNLOCK(aEnv) + return spotExp; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Light__1setSpotAngle +(JNIEnv* aEnv, jclass, jint aHandle, jfloat aAngle) +{ + M3G_DO_LOCK + m3gSetSpotAngle((M3GLight)aHandle, aAngle); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jfloat JNICALL Java_javax_microedition_m3g_Light__1getIntensity +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jfloat intensity = (jfloat)m3gGetIntensity((M3GLight)aHandle); + M3G_DO_UNLOCK(aEnv) + return intensity; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Light__1setColor +(JNIEnv* aEnv, jclass, jint aHandle, jint aRGB) +{ + M3G_DO_LOCK + m3gSetLightColor((M3GLight)aHandle, aRGB); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Light__1getColor +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jint color = (jint)m3gGetLightColor((M3GLight)aHandle); + M3G_DO_UNLOCK(aEnv) + return color; +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/loader.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/loader.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,234 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "javax_microedition_m3g_Loader.h" + +#include + +/*! + * \brief Symbian implementation of the block inflation function for + * the Loader class + */ +static M3Gsizei m3gSymbianInflateBlock1(M3Gsizei srcLength, + const M3Gubyte *src, + M3Gsizei dstLength, + M3Gubyte *dst) +{ + unsigned long len = (unsigned long) dstLength; + if (uncompress((Bytef *) dst, &len, + (const Bytef *) src, (uLong) srcLength) != Z_OK) + { + return 0; + } + return (M3Gsizei) len; +} + +JNIEXPORT jboolean JNICALL Java_javax_microedition_m3g_Loader__1inflate +(JNIEnv* aEnv, jclass, jbyteArray aCompressed, jbyteArray aInflated) +{ + M3Guint result; + + M3Gubyte *compressedData = (M3Gubyte *)aEnv->GetByteArrayElements(aCompressed, NULL); + if (compressedData == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + M3Gint compressedLength = aEnv->GetArrayLength(aCompressed); + M3Gubyte *inflatedData = (M3Gubyte *)aEnv->GetByteArrayElements(aInflated, NULL); + if (inflatedData == NULL) + { + if (compressedData) + aEnv->ReleaseByteArrayElements(aCompressed, (jbyte*)compressedData, JNI_ABORT); + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + M3Gint inflatedLength = aEnv->GetArrayLength(aInflated); + + M3G_DO_LOCK + if (m3gSymbianInflateBlock1(compressedLength, compressedData, + inflatedLength, inflatedData)) + { + result = TRUE; + } + else + { + result = FALSE; + } + M3G_DO_UNLOCK(aEnv) + + if (aCompressed) + { + aEnv->ReleaseByteArrayElements(aCompressed, (jbyte*)compressedData, JNI_ABORT); + } + + if (aInflated) + { + aEnv->ReleaseByteArrayElements(aInflated, (jbyte*)inflatedData, 0); + } + + return result; +} + + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Loader__1ctor +(JNIEnv* aEnv, jclass, jint aM3g) +{ + M3G_DO_LOCK + M3GLoader loader = (M3GLoader)m3gCreateLoader((M3GInterface)aM3g); + M3G_DO_UNLOCK(aEnv) + return (M3Guint)loader; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Loader__1decodeData +(JNIEnv* aEnv, jclass, jint aLoader, jint aOffset, jbyteArray aDataArray) +{ + /* null array is never passed */ + M3Gubyte *data = (M3Gubyte *)aEnv->GetByteArrayElements(aDataArray, NULL); + if (data == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + + M3Gint bytes = aEnv->GetArrayLength(aDataArray); + M3GLoader loader = (M3GLoader)aLoader; + + M3G_DO_LOCK + jint retVal = m3gDecodeData(loader, bytes, data + aOffset); + M3G_DO_UNLOCK(aEnv) + + if (aDataArray) + { + aEnv->ReleaseByteArrayElements(aDataArray, (jbyte*)data, JNI_ABORT); + } + + return retVal; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Loader__1getLoadedObjects +(JNIEnv* aEnv, jclass, jint aLoader, jintArray aObjectArray) +{ + M3GObject *objects = NULL; + if (aObjectArray) + { + objects = (M3GObject *)aEnv->GetIntArrayElements(aObjectArray, NULL); + if (objects == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + } + + M3GLoader loader = (M3GLoader)aLoader; + + M3G_DO_LOCK + jint retVal = m3gGetLoadedObjects(loader, objects); + M3G_DO_UNLOCK(aEnv) + + if (aObjectArray) + { + aEnv->ReleaseIntArrayElements(aObjectArray, (jint*)objects, 0); + } + + return retVal; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Loader__1setExternalReferences +(JNIEnv* aEnv, jclass, jint aLoader, jintArray aObjectArray) +{ + /* null array is never passed */ + M3GObject *xRefs = (M3GObject *)aEnv->GetIntArrayElements(aObjectArray, NULL); + if (xRefs == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + + M3Gint numXRefs = aEnv->GetArrayLength(aObjectArray); + M3GLoader loader = (M3GLoader)aLoader; + + M3G_DO_LOCK + m3gImportObjects(loader, numXRefs, xRefs); + M3G_DO_UNLOCK(aEnv) + + aEnv->ReleaseIntArrayElements(aObjectArray, (jint*)xRefs, JNI_ABORT); +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Loader__1getObjectsWithUserParameters +(JNIEnv* aEnv, jclass, jint aLoader, jintArray aObjectArray) +{ + M3GObject *objects = NULL; + if (aObjectArray) + { + objects = (M3GObject *)aEnv->GetIntArrayElements(aObjectArray, NULL); + if (objects == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + } + + M3GLoader loader = (M3GLoader)aLoader; + + M3G_DO_LOCK + jint retVal = m3gGetObjectsWithUserParameters(loader, objects); + M3G_DO_UNLOCK(aEnv) + + if (objects) + { + aEnv->ReleaseIntArrayElements(aObjectArray, (jint*)objects, 0); + } + + return retVal; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Loader__1getNumUserParameters +(JNIEnv* aEnv, jclass, jint aLoader, jint aObj) +{ + M3GLoader loader = (M3GLoader)aLoader; + M3G_DO_LOCK + jint numParams = (jint)m3gGetNumUserParameters(loader, aObj); + M3G_DO_UNLOCK(aEnv) + return numParams; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Loader__1getUserParameter +(JNIEnv* aEnv, jclass, jint aLoader, jint aObj, jint aIndex, jbyteArray aDataArray) +{ + M3Gbyte *data = NULL; + if (aDataArray) + { + data = (M3Gbyte *)aEnv->GetByteArrayElements(aDataArray, NULL); + if (data == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + } + + M3GLoader loader = (M3GLoader)aLoader; + M3G_DO_LOCK + jint retVal = m3gGetUserParameter(loader, aObj, aIndex, data); + M3G_DO_UNLOCK(aEnv) + + if (data) + { + aEnv->ReleaseByteArrayElements(aDataArray, (jbyte*)data, 0); + } + + return retVal; +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/material.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/material.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "javax_microedition_m3g_Material.h" + +JNIEXPORT jboolean JNICALL Java_javax_microedition_m3g_Material__1isVertexColorTrackingEnabled +(JNIEnv* aEnv, jclass, jint aHMaterial) +{ + M3G_DO_LOCK + jboolean enabled = (jboolean)m3gIsVertexColorTrackingEnabled((M3GMaterial)aHMaterial); + M3G_DO_UNLOCK(aEnv) + return enabled; +} + +JNIEXPORT jfloat JNICALL Java_javax_microedition_m3g_Material__1getShininess +(JNIEnv* aEnv, jclass, jint aHMaterial) +{ + M3G_DO_LOCK + jfloat shininess = (jfloat)m3gGetShininess((M3GMaterial)aHMaterial); + M3G_DO_UNLOCK(aEnv) + return shininess; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Material__1setVertexColorTrackingEnable +(JNIEnv* aEnv, jclass, jint aHMaterial, jboolean aEnable) +{ + M3G_DO_LOCK + m3gSetVertexColorTrackingEnable((M3GMaterial)aHMaterial, (M3Gbool)aEnable); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Material__1ctor +(JNIEnv* aEnv, jclass, jint aM3g) +{ + M3G_DO_LOCK + M3GMaterial material = (M3GMaterial)m3gCreateMaterial((M3GInterface)aM3g); + M3G_DO_UNLOCK(aEnv) + return (M3Guint)material; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Material__1setColor +(JNIEnv* aEnv, jclass, jint aHMaterial, jint aTarget, jint aARGB) +{ + M3G_DO_LOCK + m3gSetColor((M3GMaterial)aHMaterial, aTarget, aARGB); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Material__1setShininess +(JNIEnv* aEnv, jclass, jint aHMaterial, jfloat aShininess) +{ + M3G_DO_LOCK + m3gSetShininess((M3GMaterial)aHMaterial, (M3Gfloat)aShininess); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Material__1getColor +(JNIEnv* aEnv, jclass, jint aHMaterial, jint aTarget) +{ + M3G_DO_LOCK + jint color = (jint)m3gGetColor((M3GMaterial)aHMaterial, aTarget); + M3G_DO_UNLOCK(aEnv) + return color; +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/mesh.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/mesh.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,118 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "javax_microedition_m3g_Mesh.h" + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Mesh__1getIndexBuffer +(JNIEnv* aEnv, jclass, jint aHandle, jint aIndex) +{ + M3G_DO_LOCK + jint buffer = (M3Guint)m3gGetIndexBuffer((M3GMesh)aHandle, aIndex); + M3G_DO_UNLOCK(aEnv) + return buffer; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Mesh__1getSubmeshCount +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jint count = (M3Guint)m3gGetSubmeshCount((M3GMesh)aHandle); + M3G_DO_UNLOCK(aEnv) + return count; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Mesh__1ctor +(JNIEnv* aEnv, jclass, jint aM3g, jint aHVertices, jintArray aHTriangles, jintArray aHAppearances) +{ + if (aHVertices == 0 || aHTriangles == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/NullPointerException"); + return 0; + } + + int trianglesLen = aEnv->GetArrayLength(aHTriangles); + int appearancesLen = aHAppearances ? aEnv->GetArrayLength(aHAppearances) : 0; + if (trianglesLen == 0 || (aHAppearances != NULL && appearancesLen < trianglesLen)) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/IllegalArgumentException"); + return 0; + } + + jint* triangle = aEnv->GetIntArrayElements(aHTriangles, NULL); + if (triangle == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + + jint* appearance = NULL; + if (aHAppearances) + { + appearance = aEnv->GetIntArrayElements(aHAppearances, NULL); + if (appearance == NULL) + { + aEnv->ReleaseIntArrayElements(aHTriangles, triangle, JNI_ABORT); + + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + } + M3G_DO_LOCK + M3Guint ret = (M3Guint)m3gCreateMesh((M3GInterface)aM3g, + (M3GVertexBuffer)aHVertices, + (M3GIndexBuffer*)triangle, + (M3GAppearance*)appearance, + trianglesLen); + M3G_DO_UNLOCK(aEnv) + + if (triangle) + { + aEnv->ReleaseIntArrayElements(aHTriangles, triangle, JNI_ABORT); + } + if (appearance) + { + aEnv->ReleaseIntArrayElements(aHAppearances, appearance, JNI_ABORT); + } + + return ret; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Mesh__1getVertexBuffer +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jint vBuffer = (M3Guint)m3gGetVertexBuffer((M3GMesh)aHandle); + M3G_DO_UNLOCK(aEnv) + return vBuffer; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Mesh__1getAppearance +(JNIEnv* aEnv, jclass, jint aHandle, jint aIndex) +{ + M3G_DO_LOCK + jint appearence = (M3Guint)m3gGetAppearance((M3GMesh)aHandle, aIndex); + M3G_DO_UNLOCK(aEnv) + return appearence; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Mesh__1setAppearance +(JNIEnv* aEnv, jclass, jint aHandle, jint aIndex, jint aHAppearance) +{ + M3G_DO_LOCK + m3gSetAppearance((M3GMesh)aHandle, aIndex, (M3GAppearance)aHAppearance); + M3G_DO_UNLOCK(aEnv) +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/morphingMesh.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/morphingMesh.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,168 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "javax_microedition_m3g_MorphingMesh.h" + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_MorphingMesh__1setWeights +(JNIEnv* aEnv, jclass, jint aHandle, jfloatArray aWeightArray) +{ + if (aWeightArray != NULL) + { + jfloat* weightArray = aEnv->GetFloatArrayElements(aWeightArray, NULL); + if (weightArray == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + + M3G_DO_LOCK + m3gSetWeights((M3GMorphingMesh)aHandle, (M3Gfloat *)weightArray, aEnv->GetArrayLength(aWeightArray)); + M3G_DO_UNLOCK(aEnv) + + if (weightArray) + { + aEnv->ReleaseFloatArrayElements(aWeightArray, weightArray, JNI_ABORT); + } + } + else + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/NullPointerException"); + } +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_MorphingMesh__1getMorphTargetCount +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jint count = (M3Guint)m3gGetMorphTargetCount((M3GMorphingMesh)aHandle); + M3G_DO_UNLOCK(aEnv) + return count; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_MorphingMesh__1getWeights +(JNIEnv* aEnv, jclass, jint aHandle, jfloatArray aWeightArray) +{ + if (aWeightArray != NULL) + { + jfloat* weightArray = aEnv->GetFloatArrayElements(aWeightArray, NULL); + if (weightArray == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + + M3G_DO_LOCK + m3gGetWeights((M3GMorphingMesh)aHandle, (M3Gfloat *)weightArray, aEnv->GetArrayLength(aWeightArray)); + M3G_DO_UNLOCK(aEnv) + + if (weightArray) + { + aEnv->ReleaseFloatArrayElements(aWeightArray, weightArray, 0); + } + } + else + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/NullPointerException"); + } +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_MorphingMesh__1ctor +(JNIEnv* aEnv, jclass, jint aM3g, jint aHVertices, jintArray aHTargets, jintArray aHTriangles, jintArray aHAppearances) +{ + if (aHVertices == 0 || aHTargets == NULL || aHTriangles == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/NullPointerException"); + return 0; + } + + int trianglesLen = aEnv->GetArrayLength(aHTriangles); + int targetsLen = aEnv->GetArrayLength(aHTargets); + + if (trianglesLen == 0 || targetsLen == 0) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/IllegalArgumentException"); + return 0; + } + + if (aHAppearances != NULL) + { + int appearancesLen = aEnv->GetArrayLength(aHAppearances); + if (appearancesLen < trianglesLen) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/IllegalArgumentException"); + return 0; + } + } + + jint* targets = aEnv->GetIntArrayElements(aHTargets, NULL); + if (targets == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + + jint* triangles = aEnv->GetIntArrayElements(aHTriangles, NULL); + if (triangles == NULL) + { + aEnv->ReleaseIntArrayElements(aHTargets, targets, JNI_ABORT); + + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + + jint* appearances = NULL; + if (aHAppearances) + { + appearances = aEnv->GetIntArrayElements(aHAppearances, NULL); + if (appearances == NULL) + { + aEnv->ReleaseIntArrayElements(aHTargets, targets, JNI_ABORT); + aEnv->ReleaseIntArrayElements(aHTriangles, triangles, JNI_ABORT); + + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + } + + M3G_DO_LOCK + M3Guint ret = (M3Guint)m3gCreateMorphingMesh((M3GInterface)aM3g, + (M3GVertexBuffer)aHVertices, + (M3GVertexBuffer*)targets, + (M3GIndexBuffer*)triangles, + (M3GAppearance*)appearances, + trianglesLen, + targetsLen); + M3G_DO_UNLOCK(aEnv) + + aEnv->ReleaseIntArrayElements(aHTargets, targets, JNI_ABORT); + aEnv->ReleaseIntArrayElements(aHTriangles, triangles, JNI_ABORT); + if (appearances) + { + aEnv->ReleaseIntArrayElements(aHAppearances, appearances, JNI_ABORT); + } + + return ret; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_MorphingMesh__1getMorphTarget +(JNIEnv* aEnv, jclass, jint aHandle, jint aIndex) +{ + M3G_DO_LOCK + jint target = (M3Guint)m3gGetMorphTarget((M3GMorphingMesh)aHandle, aIndex); + M3G_DO_UNLOCK(aEnv) + return target; +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/node.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/node.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,160 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "javax_microedition_m3g_Node.h" + +JNIEXPORT jboolean JNICALL Java_javax_microedition_m3g_Node__1isEnabled +(JNIEnv* aEnv, jclass, jint aHandle, jint aWhich) +{ + M3G_DO_LOCK + jboolean enabled = (jboolean)m3gIsEnabled((M3GNode)aHandle, aWhich); + M3G_DO_UNLOCK(aEnv) + return enabled; +} + +JNIEXPORT jfloat JNICALL Java_javax_microedition_m3g_Node__1getAlphaFactor +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jfloat alpha = (jfloat)m3gGetAlphaFactor((M3GNode)aHandle); + M3G_DO_UNLOCK(aEnv) + return alpha; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Node__1getParent +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jint parent = (M3Guint)m3gGetParent((M3GNode)aHandle); + M3G_DO_UNLOCK(aEnv) + return parent; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Node__1setScope +(JNIEnv* aEnv, jclass, jint aHandle, jint aId) +{ + M3G_DO_LOCK + m3gSetScope((M3GNode)aHandle, aId); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Node__1getScope +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jint scope = (jint)m3gGetScope((M3GNode)aHandle); + M3G_DO_UNLOCK(aEnv) + return scope; +} + +JNIEXPORT jboolean JNICALL Java_javax_microedition_m3g_Node__1getTransformTo +(JNIEnv* aEnv, jclass, jint aHandle, jint aHTarget, jbyteArray aDstArray) +{ + jboolean ret = 0; + if (aDstArray != NULL && aHTarget != 0) + { + jbyte* dstArray = aEnv->GetByteArrayElements(aDstArray, NULL); + if (dstArray == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + + M3G_DO_LOCK + ret = m3gGetTransformTo((M3GNode)aHandle, (M3GNode)aHTarget, (M3GMatrix *)dstArray); + M3G_DO_UNLOCK(aEnv) + + aEnv->ReleaseByteArrayElements(aDstArray, dstArray, 0); + } + else + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/NullPointerException"); + } + + return ret; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Node__1align +(JNIEnv* aEnv, jclass, jint aHNode, jint aHRef) +{ + M3G_BEGIN_PROFILE(M3G_PROFILE_ALIGN); + M3G_DO_LOCK + m3gAlignNode((M3GNode)aHNode, (M3GNode)aHRef); + M3G_DO_UNLOCK(aEnv) + M3G_END_PROFILE(M3G_PROFILE_ALIGN); +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Node__1setAlphaFactor +(JNIEnv* aEnv, jclass, jint aHandle, jfloat aAlphaFactor) +{ + M3G_DO_LOCK + m3gSetAlphaFactor((M3GNode)aHandle, aAlphaFactor); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Node__1enable +(JNIEnv* aEnv, jclass, jint aHandle, jint aWhich, jboolean aEnabled) +{ + M3G_DO_LOCK + m3gEnable((M3GNode)aHandle, aWhich, (jint)aEnabled); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Node__1setAlignment +(JNIEnv* aEnv, jclass, jint aHandle, jint aHZReference, jint aZTarget, jint aHYReference, jint aYTarget) +{ + M3G_DO_LOCK + m3gSetAlignment((M3GNode)aHandle, (M3GNode)aHZReference, aZTarget, (M3GNode)aHYReference, aYTarget); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Node__1getZRef +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jint zRef = (M3Guint)m3gGetZRef((M3GNode)aHandle); + M3G_DO_UNLOCK(aEnv) + return zRef; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Node__1getYRef +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jint yRef = (M3Guint)m3gGetYRef((M3GNode)aHandle); + M3G_DO_UNLOCK(aEnv) + return yRef; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Node__1getSubtreeSize +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jint size = (M3Guint)m3gGetSubtreeSize((M3GNode)aHandle); + M3G_DO_UNLOCK(aEnv) + return size; +} + +/* M3G 1.1 JNI Calls */ + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Node__1getAlignmentTarget +(JNIEnv* aEnv, jclass, jint aHandle, jint aAxis) +{ + M3G_DO_LOCK + jint target = (jint)m3gGetAlignmentTarget((M3GNode)aHandle, aAxis); + M3G_DO_UNLOCK(aEnv) + return target; +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/object3d.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/object3d.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,149 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "javax_microedition_m3g_Object3D.h" + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Object3D__1animate +(JNIEnv* aEnv, jclass, jint aHObject, jint aTime) +{ + M3G_DO_LOCK + jint anim = (jint)m3gAnimate((M3GObject)aHObject, aTime); + M3G_DO_UNLOCK(aEnv) + return anim; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Object3D__1getAnimationTrack +(JNIEnv* aEnv, jclass, jint aHObject, jint aIndex) +{ + M3G_DO_LOCK + jint handle = (M3Guint)m3gGetAnimationTrack((M3GObject)aHObject, aIndex); + M3G_DO_UNLOCK(aEnv) + return handle; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Object3D__1find +(JNIEnv* aEnv, jclass, jint aHObject, jint aUserID) +{ + M3G_DO_LOCK + jint target = (M3Guint)m3gFind((M3GObject)aHObject, aUserID); + M3G_DO_UNLOCK(aEnv) + return target; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Object3D__1getUserID +(JNIEnv* aEnv, jclass, jint aHObject) +{ + M3G_DO_LOCK + jint id = (jint)m3gGetUserID((M3GObject)aHObject); + M3G_DO_UNLOCK(aEnv) + return id; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Object3D__1addAnimationTrack +(JNIEnv* aEnv, jclass, jint aHObject, jint aHTrack) +{ + M3G_DO_LOCK + jint ret = (jint)m3gAddAnimationTrack((M3GObject)aHObject, (M3GAnimationTrack)aHTrack); + M3G_DO_UNLOCK(aEnv) + return ret; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Object3D__1getAnimationTrackCount +(JNIEnv* aEnv, jclass, jint aHObject) +{ + M3G_DO_LOCK + jint count = (jint)m3gGetAnimationTrackCount((M3GObject)aHObject); + M3G_DO_UNLOCK(aEnv) + return count; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Object3D__1removeAnimationTrack +(JNIEnv* aEnv, jclass, jint aHObject, jint aHTrack) +{ + M3G_DO_LOCK + m3gRemoveAnimationTrack((M3GObject)aHObject, (M3GAnimationTrack)aHTrack); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Object3D__1setUserID +(JNIEnv* aEnv, jclass, jint aHObject, jint aUserID) +{ + M3G_DO_LOCK + m3gSetUserID((M3GObject)aHObject, aUserID); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Object3D__1addRef +(JNIEnv* aEnv, jclass, jint aObject) +{ + M3G_DO_LOCK + m3gAddRef((M3GObject) aObject); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Object3D__1duplicate +(JNIEnv* aEnv, jclass, jint aHObject, jintArray aHReferences) +{ + jint* references = NULL; + if (aHReferences) + { + references = aEnv->GetIntArrayElements(aHReferences, NULL); + if (references == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + } + + M3G_DO_LOCK + M3Guint ret = (M3Guint)m3gDuplicate((M3GObject)aHObject, (M3GObject *)references); + M3G_DO_UNLOCK(aEnv) + + if (references) + { + aEnv->ReleaseIntArrayElements(aHReferences, references, 0); + } + + return ret; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Object3D__1getReferences +(JNIEnv* aEnv, jclass, jint aHObject, jintArray aHReferences) +{ + jint* references = NULL; + if (aHReferences) + { + references = aEnv->GetIntArrayElements(aHReferences, NULL); + if (references == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + } + jint numReferences = aHReferences ? aEnv->GetArrayLength(aHReferences) : 0; + + M3G_DO_LOCK + jint ret = m3gGetReferences((M3GObject)aHObject, (M3GObject *)references, numReferences); + M3G_DO_UNLOCK(aEnv) + + if (references) + { + aEnv->ReleaseIntArrayElements(aHReferences, references, 0); + } + + return ret; +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/platform.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/platform.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,39 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "javax_microedition_m3g_Platform.h" + +/* + * Must be excuted in UI thread + */ +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Platform_finalizeInterface +(JNIEnv* aEnv, jclass, jint aHObj) +{ + M3G_DO_LOCK + m3gDeleteInterface((M3GInterface)aHObj); + M3G_DO_UNLOCK(aEnv) +} + +/* + * Must be excuted in UI thread + */ +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Platform__1finalizeObject +(JNIEnv* aEnv, jclass, jint aHObj) +{ + M3G_DO_LOCK + m3gDeleteObject((M3GObject)aHObj); + M3G_DO_UNLOCK(aEnv) +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/polygonMode.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/polygonMode.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,130 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "javax_microedition_m3g_PolygonMode.h" + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_PolygonMode__1setCulling +(JNIEnv* aEnv, jclass, jint aHPolygonMode, jint aModeBits) +{ + M3G_DO_LOCK + m3gSetCulling((M3GPolygonMode)aHPolygonMode, aModeBits); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_PolygonMode__1getCulling +(JNIEnv* aEnv, jclass, jint aHPolygonMode) +{ + M3G_DO_LOCK + jint culling = (jint)m3gGetCulling((M3GPolygonMode)aHPolygonMode); + M3G_DO_UNLOCK(aEnv) + return culling; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_PolygonMode__1setWinding +(JNIEnv* aEnv, jclass, jint aHPolygonMode, jint aModeBits) +{ + M3G_DO_LOCK + m3gSetWinding((M3GPolygonMode)aHPolygonMode, aModeBits); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_PolygonMode__1getWinding +(JNIEnv* aEnv, jclass, jint aHPolygonMode) +{ + M3G_DO_LOCK + jint winding = (jint)m3gGetWinding((M3GPolygonMode)aHPolygonMode); + M3G_DO_UNLOCK(aEnv) + return winding; +} + +JNIEXPORT jboolean JNICALL Java_javax_microedition_m3g_PolygonMode__1isTwoSidedLightingEnabled +(JNIEnv* aEnv, jclass, jint aHPolygonMode) +{ + M3G_DO_LOCK + jboolean enabled = (jboolean)m3gIsTwoSidedLightingEnabled((M3GPolygonMode)aHPolygonMode); + M3G_DO_UNLOCK(aEnv) + return enabled; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_PolygonMode__1setTwoSidedLightingEnable +(JNIEnv* aEnv, jclass, jint aHPolygonMode, jboolean aEnable) +{ + M3G_DO_LOCK + m3gSetTwoSidedLightingEnable((M3GPolygonMode)aHPolygonMode, (M3Gbool)aEnable); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_PolygonMode__1setPerspectiveCorrectionEnable +(JNIEnv* aEnv, jclass, jint aHPolygonMode, jboolean aEnable) +{ + M3G_DO_LOCK + m3gSetPerspectiveCorrectionEnable((M3GPolygonMode)aHPolygonMode, (M3Gbool)aEnable); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_PolygonMode__1ctor +(JNIEnv* aEnv, jclass, jint aM3g) +{ + M3G_DO_LOCK + M3GPolygonMode gm = m3gCreatePolygonMode((M3GInterface)aM3g); + M3G_DO_UNLOCK(aEnv) + return (M3Guint)gm; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_PolygonMode__1setLocalCameraLightingEnable +(JNIEnv* aEnv, jclass, jint aHPolygonMode, jboolean aEnable) +{ + M3G_DO_LOCK + m3gSetLocalCameraLightingEnable((M3GPolygonMode)aHPolygonMode, (M3Gbool)aEnable); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_PolygonMode__1setShading +(JNIEnv* aEnv, jclass, jint aHPolygonMode, jint aModeBits) +{ + M3G_DO_LOCK + m3gSetShading((M3GPolygonMode)aHPolygonMode, aModeBits); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_PolygonMode__1getShading +(JNIEnv* aEnv, jclass, jint aHPolygonMode) +{ + M3G_DO_LOCK + jint shading = (jint)m3gGetShading((M3GPolygonMode)aHPolygonMode); + M3G_DO_UNLOCK(aEnv) + return shading; +} + +/* M3G 1.1 JNI Calls */ + +JNIEXPORT jboolean JNICALL Java_javax_microedition_m3g_PolygonMode__1isLocalCameraLightingEnabled +(JNIEnv* aEnv, jclass, jint aHPolygonMode) +{ + M3G_DO_LOCK + jboolean enabled = (jboolean)m3gIsLocalCameraLightingEnabled((M3GPolygonMode)aHPolygonMode); + M3G_DO_UNLOCK(aEnv) + return enabled; +} + +JNIEXPORT jboolean JNICALL Java_javax_microedition_m3g_PolygonMode__1isPerspectiveCorrectionEnabled +(JNIEnv* aEnv, jclass, jint aHPolygonMode) +{ + M3G_DO_LOCK + jboolean enabled = (jboolean)m3gIsPerspectiveCorrectionEnabled((M3GPolygonMode)aHPolygonMode); + M3G_DO_UNLOCK(aEnv) + return enabled; +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/skinnedMesh.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/skinnedMesh.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,213 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "javax_microedition_m3g_SkinnedMesh.h" + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_SkinnedMesh__1addTransform +(JNIEnv* aEnv, jclass, jint aHandle, jint aHBone, jint aWeight, jint aFirstVertex, jint aNumVertices) +{ + M3G_DO_LOCK + m3gAddTransform((M3GSkinnedMesh)aHandle, (M3GNode)aHBone, aWeight, aFirstVertex, aNumVertices); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_SkinnedMesh__1ctor +(JNIEnv* aEnv, jclass, jint aM3g, jint aHVertices, jintArray aHTriangles, jintArray aHAppearances, jint aHSkeleton) +{ + jint* appearances = NULL; + if (aHAppearances) + { + appearances = aEnv->GetIntArrayElements(aHAppearances, NULL); + if (appearances == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + } + + jint* triangles = NULL; + if (aHTriangles) + { + triangles = aEnv->GetIntArrayElements(aHTriangles, NULL); + if (triangles == NULL) + { + if (appearances) + { + aEnv->ReleaseIntArrayElements(aHAppearances, appearances, JNI_ABORT); + } + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + } + jint numTriangles = aEnv->GetArrayLength(aHTriangles); + M3GInterface m3g = (M3GInterface) aM3g; + + M3G_DO_LOCK + M3Guint ret = (M3Guint)m3gCreateSkinnedMesh(m3g, + (M3GVertexBuffer)aHVertices, + (M3GIndexBuffer*)triangles, + (M3GAppearance *)appearances, + numTriangles, + (M3GGroup)aHSkeleton); + M3G_DO_UNLOCK(aEnv) + + if (appearances) + { + aEnv->ReleaseIntArrayElements(aHAppearances, appearances, JNI_ABORT); + } + if (triangles) + { + aEnv->ReleaseIntArrayElements(aHTriangles, triangles, JNI_ABORT); + } + + return ret; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_SkinnedMesh__1getSkeleton +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jint skeleton = (M3Guint)m3gGetSkeleton((M3GSkinnedMesh)aHandle); + M3G_DO_UNLOCK(aEnv) + return skeleton; +} + +/* M3G 1.1 JNI Calls */ + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_SkinnedMesh__1getBoneTransform +(JNIEnv* aEnv, jclass, jint aHandle, jint aBone, jbyteArray aTransform) +{ + jbyte *transform = NULL; + if (aTransform) + { + transform = aEnv->GetByteArrayElements(aTransform, NULL); + if (transform == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + } + + M3G_DO_LOCK + m3gGetBoneTransform((M3GSkinnedMesh)aHandle, (M3GNode)aBone, (M3GMatrix *)transform); + M3G_DO_UNLOCK(aEnv) + + if (transform) + { + /* Update array to java side and release arrays */ + aEnv->ReleaseByteArrayElements(aTransform, transform, 0); + } +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_SkinnedMesh__1getBoneVertices +(JNIEnv* aEnv, jclass, jint aHandle, jint aBone, jintArray aIndices, jfloatArray aWeights) +{ + int *indices = NULL; + float *weights = NULL; + jint vertices = 0; + + /* get indices int array */ + if (aIndices != NULL) + { + indices = aEnv->GetIntArrayElements(aIndices, NULL); + if (indices == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + } + + /* get weights float array */ + if (aWeights != NULL) + { + weights = aEnv->GetFloatArrayElements(aWeights, NULL); + if (weights == NULL) + { + if (indices) + { + /* Release indices int array*/ + aEnv->ReleaseIntArrayElements(aIndices, indices, JNI_ABORT); + } + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + } + + M3G_DO_LOCK + /* Get number of vertices */ + int requiredLength = m3gGetBoneVertices((M3GSkinnedMesh)aHandle, (M3GNode)aBone, NULL, NULL); + M3G_DO_UNLOCK(aEnv) + + /* If return value is 0, an error has occured so we leave here */ + if (requiredLength == 0) + { + + /* release arrays before exiting */ + if (indices) + { + /* Release indices int array */ + aEnv->ReleaseIntArrayElements(aIndices, indices, JNI_ABORT); + } + if (weights) + { + /* Release indices int array */ + aEnv->ReleaseFloatArrayElements(aWeights, weights, JNI_ABORT); + } + return 0; + } + /* + * If either of arrays is null, lengths are not checked. + * If length validation fails, exception is automatically raised. + */ + if (indices != NULL && weights != NULL && + (!validateArray(aEnv, (jbyteArray)aIndices, requiredLength) || + !validateArray(aEnv, (jbyteArray)aWeights, requiredLength))) + { + + /* release arrays here */ + if (indices) + { + /* Release indices int array */ + aEnv->ReleaseIntArrayElements(aIndices, indices, JNI_ABORT); + } + if (weights) + { + /* Release indices int array */ + aEnv->ReleaseFloatArrayElements(aWeights, weights, JNI_ABORT); + } + + return 0; + } + else + { + M3G_DO_LOCK + vertices = m3gGetBoneVertices((M3GSkinnedMesh)aHandle, (M3GNode)aBone, indices, weights); + M3G_DO_UNLOCK(aEnv) + } + + if (indices) + { + /* Update array to java side and release arrays */ + aEnv->ReleaseIntArrayElements(aIndices, indices, 0); + } + if (weights) + { + /* Update array to java side and release arrays */ + aEnv->ReleaseFloatArrayElements(aWeights, weights, 0); + } + return vertices; +} + diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/sprite3d.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/sprite3d.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,87 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "javax_microedition_m3g_Sprite3D.h" + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Sprite3D__1setImage +(JNIEnv* aEnv, jclass, jint aHandle, jint aHImage) +{ + M3G_DO_LOCK + m3gSetSpriteImage((M3GSprite)aHandle, (M3GImage)aHImage); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jboolean JNICALL Java_javax_microedition_m3g_Sprite3D__1isScaled +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jboolean scaled = (jboolean)m3gIsScaledSprite((M3GSprite)aHandle); + M3G_DO_UNLOCK(aEnv) + return scaled; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Sprite3D__1getImage +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jint image = (M3Guint)m3gGetSpriteImage((M3GSprite)aHandle); + M3G_DO_UNLOCK(aEnv) + return image; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Sprite3D__1ctor +(JNIEnv* aEnv, jclass, jint aM3g, jboolean aScaled, jint aHImage, jint aHAppearance) +{ + M3G_DO_LOCK + jint handle = (M3Guint)m3gCreateSprite((M3GInterface)aM3g, aScaled, (M3GImage)aHImage, (M3GAppearance)aHAppearance); + M3G_DO_UNLOCK(aEnv) + return handle; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Sprite3D__1getAppearance +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jint appearence = (M3Guint)m3gGetSpriteAppearance((M3GSprite)aHandle); + M3G_DO_UNLOCK(aEnv) + return appearence; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Sprite3D__1getCrop +(JNIEnv* aEnv, jclass, jint aHandle, jint aWhich) +{ + M3G_DO_LOCK + jint crop = (jint)m3gGetCrop((M3GSprite)aHandle, aWhich); + M3G_DO_UNLOCK(aEnv) + return crop; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Sprite3D__1setCrop +(JNIEnv* aEnv, jclass, jint aHandle, jint aCropX, jint aCropY, jint aWidth, jint aHeight) +{ + M3G_DO_LOCK + m3gSetCrop((M3GSprite)aHandle, aCropX, aCropY, aWidth, aHeight); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Sprite3D__1setAppearance +(JNIEnv* aEnv, jclass, jint aHandle, jint aHAppearance) +{ + M3G_DO_LOCK + m3gSetSpriteAppearance((M3GSprite)aHandle, (M3GAppearance)aHAppearance); + M3G_DO_UNLOCK(aEnv) +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/texture2d.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/texture2d.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,135 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "javax_microedition_m3g_Texture2D.h" + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Texture2D__1getBlending +(JNIEnv* aEnv, jclass, jint aHTexture2D) +{ + M3G_DO_LOCK + jint blending = (jint)m3gTextureGetBlending((M3GTexture)aHTexture2D); + M3G_DO_UNLOCK(aEnv) + return blending; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Texture2D__1getWrappingT +(JNIEnv* aEnv, jclass, jint aHTexture2D) +{ + M3G_DO_LOCK + jint wrapping = (jint)m3gGetWrappingT((M3GTexture)aHTexture2D); + M3G_DO_UNLOCK(aEnv) + return wrapping; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Texture2D__1getWrappingS +(JNIEnv* aEnv, jclass, jint aHTexture2D) +{ + M3G_DO_LOCK + jint wrapping = (jint)m3gGetWrappingS((M3GTexture)aHTexture2D); + M3G_DO_UNLOCK(aEnv) + return wrapping; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Texture2D__1setFiltering +(JNIEnv* aEnv, jclass, jint aHTexture2D, jint aLevelFilter, jint aImageFilter) +{ + M3G_DO_LOCK + m3gSetFiltering((M3GTexture)aHTexture2D, aLevelFilter, aImageFilter); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Texture2D__1getBlendColor +(JNIEnv* aEnv, jclass, jint aHTexture2D) +{ + M3G_DO_LOCK + jint color = (jint)m3gGetBlendColor((M3GTexture)aHTexture2D); + M3G_DO_UNLOCK(aEnv) + return color; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Texture2D__1setBlendColor +(JNIEnv* aEnv, jclass, jint aHTexture2D, jint aRGB) +{ + M3G_DO_LOCK + m3gSetBlendColor((M3GTexture)aHTexture2D, aRGB); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Texture2D__1ctor +(JNIEnv* aEnv, jclass, jint aM3g, jint aHImage) +{ + M3G_DO_LOCK + jint handle = (M3Guint)m3gCreateTexture((M3GInterface)aM3g, (M3GImage)aHImage); + M3G_DO_UNLOCK(aEnv) + return handle; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Texture2D__1setWrapping +(JNIEnv* aEnv, jclass, jint aHTexture2D, jint aWrapS, jint aWrapT) +{ + M3G_DO_LOCK + m3gSetWrapping((M3GTexture)aHTexture2D, aWrapS, aWrapT); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Texture2D__1setImage +(JNIEnv* aEnv, jclass, jint aHTex, jint aHImg) +{ + M3G_DO_LOCK + m3gSetTextureImage((M3GTexture)aHTex, (M3GImage)aHImg); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Texture2D__1setBlending +(JNIEnv* aEnv, jclass, jint aHTexture2D, jint aFunc) +{ + M3G_DO_LOCK + m3gTextureSetBlending((M3GTexture)aHTexture2D, aFunc); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Texture2D__1getImage +(JNIEnv* aEnv, jclass, jint aHTex) +{ + M3G_DO_LOCK + jint image = (M3Guint) m3gGetTextureImage((M3GTexture)aHTex); + M3G_DO_UNLOCK(aEnv) + return image; +} + +/* M3G 1.1 JNI Calls */ + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Texture2D__1getImageFilter +(JNIEnv* aEnv, jclass, jint aHTex) +{ + M3Gint levelFilter = 0; + M3Gint imageFilter = 0; + M3G_DO_LOCK + m3gGetFiltering((M3GTexture)aHTex, &levelFilter, &imageFilter); + M3G_DO_UNLOCK(aEnv) + return (jint)imageFilter; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_Texture2D__1getLevelFilter +(JNIEnv* aEnv, jclass, jint aHTex) +{ + M3Gint levelFilter = 0; + M3Gint imageFilter = 0; + M3G_DO_LOCK + m3gGetFiltering((M3GTexture)aHTex, &levelFilter, &imageFilter); + M3G_DO_UNLOCK(aEnv) + return (jint)levelFilter; +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/transform.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/transform.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,367 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "javax_microedition_m3g_Transform.h" + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transform__1transformArray +(JNIEnv* aEnv, jclass, jbyteArray aMatrix, jint aHArray, jfloatArray aOutArray, jboolean aW) +{ + // null pointers are never passed + Matrix* matrix = (Matrix *)(aEnv->GetByteArrayElements(aMatrix, NULL)); + if (matrix == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + + jfloat* outArray = aEnv->GetFloatArrayElements(aOutArray, NULL); + if (outArray == NULL) + { + aEnv->ReleaseByteArrayElements(aMatrix, (jbyte*)matrix, JNI_ABORT); + + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + + int outArrayLen = aEnv->GetArrayLength(aOutArray); + + M3G_DO_LOCK + m3gTransformArray((M3GVertexArray)aHArray, matrix, (M3Gfloat *)outArray, outArrayLen, (M3Gbool)aW); + M3G_DO_UNLOCK(aEnv) + + aEnv->ReleaseByteArrayElements(aMatrix, (jbyte*)matrix, JNI_ABORT); + aEnv->ReleaseFloatArrayElements(aOutArray, outArray, 0); +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transform__1rotateQuat +(JNIEnv* aEnv, jclass, jbyteArray aMatrix, jfloat aQx, jfloat aQy, jfloat aQz, jfloat aQw) +{ + M3GQuat quat; + Matrix* matrix = NULL; + + if (aQx == 0 && aQy == 0 && aQz == 0 && aQw == 0) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/IllegalArgumentException"); + return; + } + + matrix = (Matrix *)(aEnv->GetByteArrayElements(aMatrix, NULL)); + if (matrix == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + + quat.x = aQx; + quat.y = aQy; + quat.z = aQz; + quat.w = aQw; + + M3G_DO_LOCK + m3gNormalizeQuat(&quat); + m3gPostRotateMatrixQuat(matrix, (const Quat *)&quat); + M3G_DO_UNLOCK(aEnv) + + aEnv->ReleaseByteArrayElements(aMatrix, (jbyte*)matrix, 0); +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transform__1setIdentity +(JNIEnv* aEnv, jclass, jbyteArray aMatrix) +{ + Matrix* matrix = (Matrix *)(aEnv->GetByteArrayElements(aMatrix, NULL)); + if (matrix == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + M3G_DO_LOCK + m3gIdentityMatrix(matrix); + M3G_DO_UNLOCK(aEnv) + aEnv->ReleaseByteArrayElements(aMatrix, (jbyte*)matrix, 0); +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transform__1translate +(JNIEnv* aEnv, jclass, jbyteArray aMatrix, jfloat aTx, jfloat aTy, jfloat aTz) +{ + Matrix* matrix = (Matrix *)(aEnv->GetByteArrayElements(aMatrix, NULL)); + if (matrix == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + M3G_DO_LOCK + m3gPostTranslateMatrix(matrix, aTx, aTy, aTz); + M3G_DO_UNLOCK(aEnv) + + aEnv->ReleaseByteArrayElements(aMatrix, (jbyte*)matrix, 0); +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transform__1getMatrix +(JNIEnv* aEnv, jclass, jbyteArray aMatrix, jfloatArray aDstArray) +{ + Matrix *matrix = NULL; + + if (aDstArray == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/NullPointerException"); + return; + } + + if (aEnv->GetArrayLength(aDstArray) < 16) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/IllegalArgumentException"); + return; + } + + matrix = (Matrix *)(aEnv->GetByteArrayElements(aMatrix, NULL)); + if (matrix == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + + float* dstArray = (float*)(aEnv->GetFloatArrayElements(aDstArray, NULL)); + if (dstArray == NULL) + { + aEnv->ReleaseByteArrayElements(aMatrix, (jbyte*)matrix, JNI_ABORT); + + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + + M3G_DO_LOCK + m3gGetMatrixRows(matrix, dstArray); + M3G_DO_UNLOCK(aEnv) + + aEnv->ReleaseByteArrayElements(aMatrix, (jbyte*)matrix, JNI_ABORT); + aEnv->ReleaseFloatArrayElements(aDstArray, dstArray, 0); +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transform__1transformTable +(JNIEnv* aEnv, jclass, jbyteArray aMatrix, jfloatArray aTableArray) +{ + // null pointers are never passed + M3Gfloat *v = (M3Gfloat *)(aEnv->GetFloatArrayElements(aTableArray, NULL)); + if (v == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + int tabelArrayLen = aEnv->GetArrayLength(aTableArray); + Matrix* matrix = (Matrix *)(aEnv->GetByteArrayElements(aMatrix, NULL)); + if (matrix == NULL) + { + aEnv->ReleaseFloatArrayElements(aTableArray, v, JNI_ABORT); + + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + + { + M3Gint i; + M3GVec4 vec; + + M3G_DO_LOCK + for (i = 0; i < tabelArrayLen; i += 4) + { + m3gSetVec4(&vec, v[i + 0], v[i + 1], v[i + 2], v[i + 3]); + m3gTransformVec4(matrix, &vec); + v[i + 0] = vec.x; + v[i + 1] = vec.y; + v[i + 2] = vec.z; + v[i + 3] = vec.w; + } + M3G_DO_UNLOCK(aEnv) + } + + aEnv->ReleaseByteArrayElements(aMatrix, (jbyte*)matrix, JNI_ABORT); + aEnv->ReleaseFloatArrayElements(aTableArray, v, 0); +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transform__1scale +(JNIEnv* aEnv, jclass, jbyteArray aMatrix, jfloat aSx, jfloat aSy, jfloat aSz) +{ + Matrix* matrix = (Matrix *)(aEnv->GetByteArrayElements(aMatrix, NULL)); + if (matrix == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + + M3G_DO_LOCK + m3gPostScaleMatrix(matrix, aSx, aSy, aSz); + M3G_DO_UNLOCK(aEnv) + + aEnv->ReleaseByteArrayElements(aMatrix, (jbyte*)matrix, 0); +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transform__1mul +(JNIEnv* aEnv, jclass, jbyteArray aProdArray, jbyteArray aLeftArray, jbyteArray aRightArray) +{ + + if (aRightArray == NULL || aLeftArray == NULL || aProdArray == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/NullPointerException"); + return; + } + + { + const Matrix *right = (const Matrix *)(aEnv->GetByteArrayElements(aRightArray, NULL)); + if (right == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + + const Matrix *left = (const Matrix *)(aEnv->GetByteArrayElements(aLeftArray, NULL)); + if (left == NULL) + { + aEnv->ReleaseByteArrayElements(aRightArray, (jbyte*)right, JNI_ABORT); + + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + + Matrix *prod = (Matrix *)(aEnv->GetByteArrayElements(aProdArray, NULL)); + if (prod == NULL) + { + aEnv->ReleaseByteArrayElements(aRightArray, (jbyte*)right, JNI_ABORT); + aEnv->ReleaseByteArrayElements(aLeftArray, (jbyte*)left, JNI_ABORT); + + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + + Matrix temp; + M3G_DO_LOCK + m3gMatrixProduct(&temp, left, right); + M3G_DO_UNLOCK(aEnv) + + *prod = temp; + + aEnv->ReleaseByteArrayElements(aRightArray, (jbyte*)right, JNI_ABORT); + aEnv->ReleaseByteArrayElements(aLeftArray, (jbyte*)left, JNI_ABORT); + aEnv->ReleaseByteArrayElements(aProdArray, (jbyte*)prod, 0); + } +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transform__1setMatrix +(JNIEnv* aEnv, jclass, jbyteArray aMatrix, jfloatArray aSrcArray) +{ + Matrix *matrix = NULL; + + if (aSrcArray == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/NullPointerException"); + return; + } + if (aEnv->GetArrayLength(aSrcArray) < 16) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/IllegalArgumentException"); + return; + } + + matrix = (Matrix *)(aEnv->GetByteArrayElements(aMatrix, NULL)); + if (matrix == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + + float* srcArray = aEnv->GetFloatArrayElements(aSrcArray, NULL); + if (srcArray == NULL) + { + aEnv->ReleaseByteArrayElements(aMatrix, (jbyte*)matrix, JNI_ABORT); + + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + + M3G_DO_LOCK + m3gSetMatrixRows(matrix, (const float *)srcArray); + M3G_DO_UNLOCK(aEnv) + + aEnv->ReleaseFloatArrayElements(aSrcArray, srcArray, JNI_ABORT); + aEnv->ReleaseByteArrayElements(aMatrix, (jbyte*)matrix, 0); +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transform__1transpose +(JNIEnv* aEnv, jclass, jbyteArray aMatrix) +{ + Matrix tpos; + Matrix *matrix = (Matrix *)(aEnv->GetByteArrayElements(aMatrix, NULL)); + if (matrix == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + M3G_DO_LOCK + m3gMatrixTranspose(&tpos, matrix); + m3gCopyMatrix(matrix, &tpos); + M3G_DO_UNLOCK(aEnv) + + aEnv->ReleaseByteArrayElements(aMatrix, (jbyte*)matrix, 0); +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transform__1invert +(JNIEnv* aEnv, jclass, jbyteArray aMatrix) +{ + Matrix *matrix = (Matrix *)(aEnv->GetByteArrayElements(aMatrix, NULL)); + if (matrix == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + + M3G_BEGIN_PROFILE(M3G_PROFILE_TRANSFORM_INVERT); + M3G_DO_LOCK + if (!m3gInvertMatrix(matrix)) + { + aEnv->ReleaseByteArrayElements(aMatrix, (jbyte*)matrix, JNI_ABORT); + M3G_RAISE_EXCEPTION(aEnv, "java/lang/ArithmeticException"); + M3G_DO_UNLOCK(aEnv) + return; + } + M3G_DO_UNLOCK(aEnv) + M3G_END_PROFILE(M3G_PROFILE_TRANSFORM_INVERT); + + aEnv->ReleaseByteArrayElements(aMatrix, (jbyte*)matrix, 0); +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transform__1rotate +(JNIEnv* aEnv, jclass, jbyteArray aMatrix, jfloat aAngle, jfloat aAx, jfloat aAy, jfloat aAz) +{ + Matrix *matrix = NULL; + + if (aAx == 0 && aAy == 0 && aAz == 0 && aAngle != 0) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/IllegalArgumentException"); + return; + } + + matrix = (Matrix *)(aEnv->GetByteArrayElements(aMatrix, NULL)); + if (matrix == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + + M3G_DO_LOCK + m3gPostRotateMatrix(matrix, aAngle, aAx, aAy, aAz); + M3G_DO_UNLOCK(aEnv) + + aEnv->ReleaseByteArrayElements(aMatrix, (jbyte*)matrix, 0); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/transformable.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/transformable.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,195 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "javax_microedition_m3g_Transformable.h" + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transformable__1preRotate +(JNIEnv* aEnv, jclass, jint aHandle, jfloat aAngle, jfloat aAx, jfloat aAy, jfloat aAz) +{ + M3G_DO_LOCK + m3gPreRotate((M3GTransformable)aHandle, aAngle, aAx, aAy, aAz); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transformable__1getComposite +(JNIEnv* aEnv, jclass, jint aHandle, jbyteArray aDstArray) +{ + if (validateArray(aEnv, aDstArray, sizeof(M3GMatrix))) + { + jbyte* dstArray = aEnv->GetByteArrayElements(aDstArray, NULL); + if (dstArray == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + + M3G_DO_LOCK + m3gGetCompositeTransform((M3GTransformable)aHandle, (M3GMatrix *)dstArray); + M3G_DO_UNLOCK(aEnv) + aEnv->ReleaseByteArrayElements(aDstArray, dstArray, 0); + } +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transformable__1setTransform +(JNIEnv* aEnv, jclass, jint aHandle, jbyteArray aSrcArray) +{ + if (aSrcArray != NULL) + { + jbyte* srcArray = aEnv->GetByteArrayElements(aSrcArray, NULL); + if (srcArray == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + M3G_DO_LOCK + m3gSetTransform((M3GTransformable)aHandle, (const M3GMatrix *)srcArray); + M3G_DO_UNLOCK(aEnv) + aEnv->ReleaseByteArrayElements(aSrcArray, srcArray, JNI_ABORT); + } + else + { + M3G_DO_LOCK + m3gSetTransform((M3GTransformable)aHandle, NULL); + M3G_DO_UNLOCK(aEnv) + } +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transformable__1setTranslation +(JNIEnv* aEnv, jclass, jint aHandle, jfloat aTx, jfloat aTy, jfloat aTz, jboolean aAbsolute) +{ + + if (aAbsolute) + { + M3G_DO_LOCK + m3gSetTranslation((M3GTransformable)aHandle, aTx, aTy, aTz); + M3G_DO_UNLOCK(aEnv) + } + else + { + M3G_DO_LOCK + m3gTranslate((M3GTransformable)aHandle, aTx, aTy, aTz); + M3G_DO_UNLOCK(aEnv) + } +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transformable__1setOrientation +(JNIEnv* aEnv, jclass, jint aHandle, jfloat aAngle, jfloat aAx, jfloat aAy, jfloat aAz, jboolean aAbsolute) +{ + + if (aAbsolute) + { + M3G_DO_LOCK + m3gSetOrientation((M3GTransformable)aHandle, aAngle, aAx, aAy, aAz); + M3G_DO_UNLOCK(aEnv) + } + else + { + M3G_DO_LOCK + m3gPostRotate((M3GTransformable)aHandle, aAngle, aAx, aAy, aAz); + M3G_DO_UNLOCK(aEnv) + } +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transformable__1getTransform +(JNIEnv* aEnv, jclass, jint aHandle, jbyteArray aDstArray) +{ + if (validateArray(aEnv, aDstArray, sizeof(M3GMatrix))) + { + jbyte* dstArray = aEnv->GetByteArrayElements(aDstArray, NULL); + if (dstArray == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + M3G_DO_LOCK + m3gGetTransform((M3GTransformable)aHandle, (M3GMatrix *)dstArray); + M3G_DO_UNLOCK(aEnv) + aEnv->ReleaseByteArrayElements(aDstArray, dstArray, 0); + } +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transformable__1setScale +(JNIEnv* aEnv, jclass, jint aHandle, jfloat aSx, jfloat aSy, jfloat aSz, jboolean aAbsolute) +{ + + if (aAbsolute) + { + M3G_DO_LOCK + m3gSetScale((M3GTransformable)aHandle, aSx, aSy, aSz); + M3G_DO_UNLOCK(aEnv) + } + else + { + M3G_DO_LOCK + m3gScale((M3GTransformable)aHandle, aSx, aSy, aSz); + M3G_DO_UNLOCK(aEnv) + } +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transformable__1getTranslation +(JNIEnv* aEnv, jclass, jint aHandle, jfloatArray aDstArray) +{ + if (validateArray(aEnv, (jbyteArray)aDstArray, 3)) + { + jfloat* dstArray = aEnv->GetFloatArrayElements(aDstArray, NULL); + if (dstArray == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + M3G_DO_LOCK + m3gGetTranslation((M3GTransformable)aHandle, (M3Gfloat*)dstArray); + M3G_DO_UNLOCK(aEnv) + aEnv->ReleaseFloatArrayElements(aDstArray, dstArray, 0); + } +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transformable__1getScale +(JNIEnv* aEnv, jclass, jint aHandle, jfloatArray aDstArray) +{ + if (validateArray(aEnv, (jbyteArray)aDstArray, 3)) + { + jfloat* dstArray = aEnv->GetFloatArrayElements(aDstArray, NULL); + if (dstArray == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + M3G_DO_LOCK + m3gGetScale((M3GTransformable)aHandle, (M3Gfloat*)dstArray); + M3G_DO_UNLOCK(aEnv) + aEnv->ReleaseFloatArrayElements(aDstArray, dstArray, 0); + } +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_Transformable__1getOrientation +(JNIEnv* aEnv, jclass, jint aHandle, jfloatArray aDstArray) +{ + if (validateArray(aEnv, (jbyteArray)aDstArray, 4)) + { + jfloat* dstArray = aEnv->GetFloatArrayElements(aDstArray, NULL); + if (dstArray == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + M3G_DO_LOCK + m3gGetOrientation((M3GTransformable)aHandle, (M3Gfloat*)dstArray); + M3G_DO_UNLOCK(aEnv) + aEnv->ReleaseFloatArrayElements(aDstArray, dstArray, 0); + } +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/triangleStripArray.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/triangleStripArray.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,137 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "javax_microedition_m3g_TriangleStripArray.h" + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_TriangleStripArray__1createImplicit +(JNIEnv* aEnv, jclass, jint aM3g, jint first, jintArray aLengthArray) +{ + M3GIndexBuffer buffer; + + int *lengths = NULL; + if (aLengthArray) + { + lengths = (int *)(aEnv->GetIntArrayElements(aLengthArray, NULL)); + if (lengths == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + } + int count = aLengthArray != NULL ? aEnv->GetArrayLength(aLengthArray) : 0; + + M3G_DO_LOCK + buffer = m3gCreateImplicitStripBuffer((M3GInterface)aM3g, + count, + lengths, + first); + M3G_DO_UNLOCK(aEnv) + + if (lengths) + { + aEnv->ReleaseIntArrayElements(aLengthArray, lengths, JNI_ABORT); + } + + return (M3Guint) buffer; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_TriangleStripArray__1createExplicit +(JNIEnv* aEnv, jclass, jint aM3g, jintArray aIndices, jintArray aLengths) +{ + M3GIndexBuffer buffer; + + + jint* lengths = NULL; + jint* indices = NULL; + if (aLengths) + { + lengths = aEnv->GetIntArrayElements(aLengths, NULL); + if (lengths == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + } + if (aIndices) + { + indices = aEnv->GetIntArrayElements(aIndices, NULL); + if (indices == NULL) + { + if (lengths) + { + aEnv->ReleaseIntArrayElements(aLengths, lengths, JNI_ABORT); + } + + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + } + M3G_DO_LOCK + buffer = m3gCreateStripBuffer((M3GInterface)aM3g, + M3G_TRIANGLE_STRIPS, + aLengths != NULL ? aEnv->GetArrayLength(aLengths) : 0, + (M3Gsizei *)lengths, + M3G_INT, + aIndices != NULL ? aEnv->GetArrayLength(aIndices) : 0, + (void *)indices); + M3G_DO_UNLOCK(aEnv) + + if (indices) + { + aEnv->ReleaseIntArrayElements(aIndices, indices, JNI_ABORT); + } + if (lengths) + { + aEnv->ReleaseIntArrayElements(aLengths, lengths, JNI_ABORT); + } + + return (M3Guint) buffer; +} + +/* M3G 1.1 JNI Calls */ + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_TriangleStripArray__1getIndexCount +(JNIEnv* aEnv, jclass, jint aHTsa) +{ + M3G_DO_LOCK + jint size = (jint)m3gGetBatchSize((M3GIndexBuffer)aHTsa, 0); + M3G_DO_UNLOCK(aEnv) + return size; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_TriangleStripArray__1getIndices +(JNIEnv* aEnv, jclass, jint aHTsa, jintArray aIndices) +{ + jint* indices = NULL; + + if (aIndices) + { + indices = aEnv->GetIntArrayElements(aIndices, NULL); + if (indices == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + } + M3G_DO_LOCK + m3gGetBatchIndices((M3GIndexBuffer)aHTsa, 0, indices); + M3G_DO_UNLOCK(aEnv) + + if (indices) + { + aEnv->ReleaseIntArrayElements(aIndices, indices, 0); + } +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/vertexArray.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/vertexArray.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,187 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +#include "javax_microedition_m3g_VertexArray.h" + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_VertexArray__1setShort +(JNIEnv* aEnv, jclass, jint aHandle, jint aFirst, jint aCount, jshortArray aSrcArray) +{ + int srcLength = 0; + unsigned short *srcData = NULL; + if (aSrcArray) + { + srcData = (unsigned short *)aEnv->GetShortArrayElements(aSrcArray, NULL); + if (srcData == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + } + + srcLength = aSrcArray ? aEnv->GetArrayLength(aSrcArray) : 0; + + M3G_DO_LOCK + m3gSetVertexArrayElements( + (M3GVertexArray) aHandle, aFirst, aCount, srcLength, M3G_SHORT, srcData); + M3G_DO_UNLOCK(aEnv) + + if (aSrcArray) + { + aEnv->ReleaseShortArrayElements(aSrcArray, (jshort*)srcData, JNI_ABORT); + } +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_VertexArray__1ctor +(JNIEnv* aEnv, jclass, jint aM3g, jint aNumVertices, jint aNumComponents, jint aComponentSize) +{ + M3G_DO_LOCK + M3GVertexArray va = m3gCreateVertexArray((M3GInterface)aM3g, + aNumVertices, + aNumComponents, + (aComponentSize == 1) ? M3G_BYTE : + (aComponentSize == 2) ? M3G_SHORT : + M3G_INT); + M3G_DO_UNLOCK(aEnv) + return (M3Guint) va; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_VertexArray__1setByte +(JNIEnv* aEnv, jclass, jint aHandle, jint aFirst, jint aCount, jbyteArray aSrcArray) +{ + int srcLength = 0; + unsigned char *srcData = NULL; + if (aSrcArray) + { + srcData = (unsigned char *)aEnv->GetByteArrayElements(aSrcArray, NULL); + if (srcData == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + } + + srcLength = aSrcArray ? aEnv->GetArrayLength(aSrcArray) : 0; + + if (validateArray(aEnv, aSrcArray, aCount)) + { + M3G_DO_LOCK + m3gSetVertexArrayElements( + (M3GVertexArray) aHandle, aFirst, aCount, srcLength, M3G_BYTE, srcData); + M3G_DO_UNLOCK(aEnv) + } + + if (aSrcArray) + { + aEnv->ReleaseByteArrayElements(aSrcArray, (jbyte*)srcData, JNI_ABORT); + } +} + +/* M3G 1.1 JNI Calls */ + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_VertexArray__1getByte +(JNIEnv* aEnv, jclass, jint aHandle, jint aFirstVertex, jint aNumVertices, jbyteArray aSrcArray) +{ + int dstLength = 0; + unsigned char *dstData = NULL; + if (aSrcArray) + { + dstData = (unsigned char *)aEnv->GetByteArrayElements(aSrcArray, NULL); + if (dstData == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + } + + dstLength = aSrcArray ? aEnv->GetArrayLength(aSrcArray) : 0; + + /* + * Parameter checking and exception throwing is handled in engine side, thus no + * checking / validation is done here. + */ + M3G_DO_LOCK + m3gGetVertexArrayElements((M3GVertexArray) aHandle, aFirstVertex, aNumVertices, dstLength, M3G_BYTE, dstData); + M3G_DO_UNLOCK(aEnv) + + if (aSrcArray) + { + /* copy dstData array to java side and release both arrays */ + aEnv->ReleaseByteArrayElements(aSrcArray, (jbyte*)dstData, 0); + } +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_VertexArray__1getShort +(JNIEnv* aEnv, jclass, jint aHandle, jint aFirstVertex, jint aNumVertices, jshortArray aSrcArray) +{ + int dstLength = 0; + unsigned short *dstData = NULL; + if (aSrcArray) + { + dstData = (unsigned short *)aEnv->GetShortArrayElements(aSrcArray, NULL); + if (dstData == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + } + + dstLength = aSrcArray ? aEnv->GetArrayLength(aSrcArray) : 0; + + /* + * Parameter checking and exception throwing is handled in engine side, thus no + * checking / validation is done here. + */ + M3G_DO_LOCK + m3gGetVertexArrayElements((M3GVertexArray) aHandle, aFirstVertex, aNumVertices, dstLength, M3G_SHORT, dstData); + M3G_DO_UNLOCK(aEnv) + + if (aSrcArray) + { + /* copy dstData array to java side and release both arrays */ + aEnv->ReleaseShortArrayElements(aSrcArray, (jshort*)dstData, 0); + } +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_VertexArray__1getComponentCount +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3Gsizei size; + M3G_DO_LOCK + m3gGetVertexArrayParams((M3GVertexArray)aHandle, NULL, &size, NULL, NULL); + M3G_DO_UNLOCK(aEnv) + return (jint)size; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_VertexArray__1getComponentType +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3Gdatatype type; + M3G_DO_LOCK + m3gGetVertexArrayParams((M3GVertexArray)aHandle, NULL, NULL, &type, NULL); + M3G_DO_UNLOCK(aEnv) + type = (type == M3G_BYTE) ? (M3Gdatatype) 1 : (M3Gdatatype) 2; + return (jint)type; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_VertexArray__1getVertexCount +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3Gsizei count; + M3G_DO_LOCK + m3gGetVertexArrayParams((M3GVertexArray)aHandle, &count, NULL, NULL, NULL); + M3G_DO_UNLOCK(aEnv) + return (jint)count; +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/vertexBuffer.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/vertexBuffer.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,152 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "javax_microedition_m3g_VertexBuffer.h" + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_VertexBuffer__1setTexCoords +(JNIEnv* aEnv, jclass, jint aHBuffer, jint aTexUnit, jint aHArray, jfloat aScale, jfloatArray aSrcArray) +{ + int biasLength = 0; + float *bias = NULL; + if (aSrcArray) + { + bias = (float *)aEnv->GetFloatArrayElements(aSrcArray, NULL); + if (bias == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + } + + biasLength = aSrcArray ? aEnv->GetArrayLength(aSrcArray) : 0; + + M3G_DO_LOCK + m3gSetTexCoordArray((M3GVertexBuffer)aHBuffer, aTexUnit, (M3GVertexArray)aHArray, aScale, bias, biasLength); + M3G_DO_UNLOCK(aEnv) + + if (aSrcArray) + { + aEnv->ReleaseFloatArrayElements(aSrcArray, bias, JNI_ABORT); + } +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_VertexBuffer__1getArray +(JNIEnv* aEnv, jclass, jint aHBuffer, jint aWhich, jfloatArray aDstArray) +{ + int dstLength = 0; + float *dstData = NULL; + if (aDstArray) + { + dstData = (float *)aEnv->GetFloatArrayElements(aDstArray, NULL); + if (dstData == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return 0; + } + } + + dstLength = aDstArray ? aEnv->GetArrayLength(aDstArray) : 0; + + M3G_DO_LOCK + M3Guint ret = (M3Guint)m3gGetVertexArray((M3GVertexBuffer)aHBuffer, aWhich, dstData, dstLength); + M3G_DO_UNLOCK(aEnv) + + if (aDstArray) + { + aEnv->ReleaseFloatArrayElements(aDstArray, dstData, 0); + } + + return ret; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_VertexBuffer__1getDefaultColor +(JNIEnv* aEnv, jclass, jint aHBuffer) +{ + M3G_DO_LOCK + jint color = (M3Guint)m3gGetVertexDefaultColor((M3GVertexBuffer)aHBuffer); + M3G_DO_UNLOCK(aEnv) + return color; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_VertexBuffer__1ctor +(JNIEnv* aEnv, jclass, jint aM3g) +{ + M3G_DO_LOCK + M3GVertexBuffer vb = m3gCreateVertexBuffer((M3GInterface)aM3g); + M3G_DO_UNLOCK(aEnv) + return (M3Guint) vb; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_VertexBuffer__1setNormals +(JNIEnv* aEnv, jclass, jint aHBuffer, jint aHArray) +{ + M3G_DO_LOCK + m3gSetNormalArray((M3GVertexBuffer) aHBuffer, (M3GVertexArray) aHArray); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_VertexBuffer__1setDefaultColor +(JNIEnv* aEnv, jclass, jint aHBuffer, jint aARGB) +{ + M3G_DO_LOCK + m3gSetVertexDefaultColor((M3GVertexBuffer)aHBuffer, aARGB); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_VertexBuffer__1setColors +(JNIEnv* aEnv, jclass, jint aHBuffer, jint aHArray) +{ + M3G_DO_LOCK + m3gSetColorArray((M3GVertexBuffer) aHBuffer, (M3GVertexArray) aHArray); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_VertexBuffer__1setVertices +(JNIEnv* aEnv, jclass, jint aHBuffer, jint aHArray, jfloat aScale, jfloatArray aSrcArray) +{ + int biasLength = 0; + float *bias = NULL; + if (aSrcArray) + { + bias = (float *)aEnv->GetFloatArrayElements(aSrcArray, NULL); + if (bias == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/OutOfMemoryError"); + return; + } + } + + biasLength = aSrcArray ? aEnv->GetArrayLength(aSrcArray) : 0; + + M3G_DO_LOCK + m3gSetVertexArray((M3GVertexBuffer)aHBuffer, (M3GVertexArray)aHArray, aScale, bias, biasLength); + M3G_DO_UNLOCK(aEnv) + + if (aSrcArray) + { + aEnv->ReleaseFloatArrayElements(aSrcArray, bias, JNI_ABORT); + } +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_VertexBuffer__1getVertexCount +(JNIEnv* aEnv, jclass, jint aHBuffer) +{ + M3G_DO_LOCK + jint count = (M3Guint)m3gGetVertexCount((M3GVertexBuffer)aHBuffer); + M3G_DO_UNLOCK(aEnv) + return count; +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/jni/world.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/jni/world.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +#include "javax_microedition_m3g_World.h" + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_World__1setBackground +(JNIEnv* aEnv, jclass, jint aHandle, jint aHBackground) +{ + M3G_DO_LOCK + m3gSetBackground((M3GWorld)aHandle, (M3GBackground)aHBackground); + M3G_DO_UNLOCK(aEnv) +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_World__1ctor +(JNIEnv* aEnv, jclass, jint aM3g) +{ + M3G_DO_LOCK + jint handle = (M3Guint)m3gCreateWorld((M3GInterface)aM3g); + M3G_DO_UNLOCK(aEnv) + return handle; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_World__1getBackground +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jint bg = (M3Guint)m3gGetBackground((M3GWorld)aHandle); + M3G_DO_UNLOCK(aEnv) + return bg; +} + +JNIEXPORT jint JNICALL Java_javax_microedition_m3g_World__1getActiveCamera +(JNIEnv* aEnv, jclass, jint aHandle) +{ + M3G_DO_LOCK + jint camera = (M3Guint)m3gGetActiveCamera((M3GWorld)aHandle); + M3G_DO_UNLOCK(aEnv) + return camera; +} + +JNIEXPORT void JNICALL Java_javax_microedition_m3g_World__1setActiveCamera +(JNIEnv* aEnv, jclass, jint aHandle, jint aHCamera) +{ + M3G_DO_LOCK + m3gSetActiveCamera((M3GWorld)aHandle, (M3GCamera)aHCamera); + M3G_DO_UNLOCK(aEnv) +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/m3g_jsr184.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/m3g_jsr184.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,109 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +/*! + * \file \brief Global methods for JSR-184 + * + * This file is included, not linked, by specific VM bindings. + * + */ + +#ifndef M3G_JAVA_INCLUDE +# error included by m3g__java_api.c; do not compile separately. +#endif + +#include +#include "m3g_jsr184.h" + +/*---------------------------------------------------------------------- + * Internal functions + *--------------------------------------------------------------------*/ + +/*! + * \brief Returns the number of bytes per pixel for a JSR-184 pixel + * format + * + * \note Dependent on constants in Image2D.java + */ +static M3Guint jsr184BytesPerPixel(int jsrFormat) +{ + switch (jsrFormat) + { + case M3G_ALPHA: + return 1; + case M3G_LUMINANCE: + return 1; + case M3G_LUMINANCE_ALPHA: + return 2; + case M3G_RGB: + return 3; + case M3G_RGBA: + return 4; + default: + return 0; + } +} + +/*! + * \brief Returns m3g core pixel format for qiven Qt based pixel format + * + */ +static M3GPixelFormat mapQtPixelformat(int qtFormat) +{ + switch (qtFormat) + { + case QImage::Format_RGB32: + case QImage::Format_ARGB32: + return M3G_ARGB8; + case QImage::Format_RGB888: + return M3G_RGB8; + case QImage::Format_RGB444: + return M3G_RGB4; + case QImage::Format_RGB16: + return M3G_RGB565; + default: + return M3G_NO_FORMAT; + } +} + + +/*! + * \brief Return a MIDP exception string corresponding to an M3G error + */ +static const char *jsr184Exception(M3Genum errorCode) +{ + switch (errorCode) + { + case M3G_NO_ERROR: + return NULL; + case M3G_OUT_OF_MEMORY: + return "java/lang/OutOfMemoryError"; + case M3G_INVALID_OPERATION: + return "java/lang/IllegalStateException"; + case M3G_INVALID_INDEX: + return "java/lang/IndexOutOfBoundsException"; + case M3G_NULL_POINTER: + return "java/lang/NullPointerException"; + case M3G_ARITHMETIC_ERROR: + return "java/lang/ArithmeticException"; + case M3G_IO_ERROR: + return "java/io/IOException"; + default: + return "java/lang/IllegalArgumentException"; + } +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/m3g_kvm_api.inl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/m3g_kvm_api.inl Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,123 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +/*! + * \file \brief Java bindings for the K Virtual Machine native API + * + */ + + + +#ifndef M3G_JAVA_INCLUDE +# error included by m3g__java_api.c; do not compile separately. +#endif + +/*! + * \brief Macros for dispatching exceptions to vm. + * + */ +#include +#define M3G_RAISE_EXCEPTION(aEnv, aException){\ + if (aEnv != NULL){\ + jclass jException = aEnv->FindClass(aException);\ + if (jException != NULL){\ + aEnv->ThrowNew(jException, NULL);\ + }}}\ + + +/*! + * \brief Macros for serializing m3gcore function calls + * in native threading environment. + */ +#include "CSynchronization.h" +#define M3G_DO_LOCK CSynchronization::InstanceL()->Lock(); +#define M3G_DO_UNLOCK(aEnv) {\ + TInt errorCode = CSynchronization::InstanceL()->GetErrorCode();\ + if ( errorCode != 0){\ + M3G_RAISE_EXCEPTION(aEnv, jsr184Exception(errorCode));\ + }\ + CSynchronization::InstanceL()->Unlock();\ + }\ + + +/*---------------------------------------------------------------------- + * Internal data types + *--------------------------------------------------------------------*/ + + + +/*---------------------------------------------------------------------- + * Internal utility functions + *--------------------------------------------------------------------*/ + +/*! + * \brief Checks that a Java array is non-null and meets a minimum + * length requirement + * + * Throws NullPointerException or IllegalArgumentException if + * constraints violated. + */ +static M3Gbool validateArray(JNIEnv* aEnv, const jbyteArray aArray, M3Gsizei aMinLength) +{ + if (aArray == NULL) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/NullPointerException"); + return M3G_FALSE; + } + + if (aEnv->GetArrayLength(aArray) < aMinLength) + { + M3G_RAISE_EXCEPTION(aEnv, "java/lang/IllegalArgumentException"); + return M3G_FALSE; + } + + return M3G_TRUE; +} + +#include "m3g_jsr184.inl" +#include "jni/triangleStripArray.inl" +#include "jni/vertexBuffer.inl" +#include "jni/fog.inl" +#include "jni/polygonMode.inl" +#include "jni/object3d.inl" +#include "jni/node.inl" +#include "jni/group.inl" +#include "jni/skinnedMesh.inl" +#include "jni/camera.inl" +#include "jni/vertexArray.inl" +#include "jni/transform.inl" +#include "jni/graphics3d.inl" +#include "jni/platform.inl" +#include "jni/compositingMode.inl" +#include "jni/world.inl" +#include "jni/material.inl" +#include "jni/keyframeSequence.inl" +#include "jni/sprite3d.inl" +#include "jni/mesh.inl" +#include "jni/animationTrack.inl" +#include "jni/texture2d.inl" +#include "jni/morphingMesh.inl" +#include "jni/transformable.inl" +#include "jni/background.inl" +#include "jni/image2d.inl" +#include "jni/appearance.inl" +#include "jni/light.inl" +#include "jni/animationController.inl" +#include "jni/interface.inl" +#include "jni/loader.inl" + diff -r dc7c549001d5 -r 85266cc22c7f javauis/m3g_qt/src/m3g_symbian_java_api.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/m3g_qt/src/m3g_symbian_java_api.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,60 @@ +/* +* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +/*! + * \file \brief Symbian Java bindings + * + */ + +#include // Please check if this header is needed + +#include + +#include +#include +#include +#include "graphics.h" +#include +//#include "gdi.h" // CFbsBitmap +#include "fbs.h" + +#include + +struct ImageStruct +{ + CFbsBitmap* color; + CFbsBitmap* mask; +}; + + + +#define M3G_ASSERT(a) ((void)(a)) +#define M3G_BEGIN_PROFILE(a) ((void)(a)) +#define M3G_END_PROFILE(a) ((void)(a)) + +#define Matrix M3GMatrix +#define Quat M3GQuat +#define Vec4 M3GVec4 + +#define M3G_JAVA_INCLUDE +extern "C" +{ +#include "m3g_kvm_api.inl" +} +#undef M3G_JAVA_INCLUDE + diff -r dc7c549001d5 -r 85266cc22c7f javauis/mmapi_qt/baseline/javasrc.emc/com/nokia/microedition/media/ManagerImpl.java --- a/javauis/mmapi_qt/baseline/javasrc.emc/com/nokia/microedition/media/ManagerImpl.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/mmapi_qt/baseline/javasrc.emc/com/nokia/microedition/media/ManagerImpl.java Fri Jun 11 13:33:44 2010 +0300 @@ -466,8 +466,30 @@ { throw new IllegalArgumentException("Locator is null."); } - InternalPlayer player = iProtocolFactory.createPlayer( - new Locator(aLocator)); + InternalPlayer player =null; + /// Implementation done for java ui 3.x req + // in case of AnimationPlayer, we won't be using the ProtocolFactory class. + // + Enumeration plugins = iPlugIns.elements(); + AnimationPlayerFactory apf=null; + while (plugins.hasMoreElements() && (player == null)) + { + PlugIn temp = (PlugIn) plugins.nextElement(); + if (temp instanceof AnimationPlayerFactory) + { + apf = (AnimationPlayerFactory) temp; + break; + } + } + if (apf!=null) + { + player=apf.createPlayer(aLocator); + } + //////////////////////////////////////////////////////// + // if player is still null, try to create the native player + if (player==null) + player =iProtocolFactory.createPlayer( + new Locator(aLocator)); if (player == null) { throw new MediaException("Locator not supported: " + diff -r dc7c549001d5 -r 85266cc22c7f javauis/mmapi_qt/baseline/javasrc/com/nokia/microedition/media/animation/AnimationPlayer.java --- a/javauis/mmapi_qt/baseline/javasrc/com/nokia/microedition/media/animation/AnimationPlayer.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/mmapi_qt/baseline/javasrc/com/nokia/microedition/media/animation/AnimationPlayer.java Fri Jun 11 13:33:44 2010 +0300 @@ -16,12 +16,14 @@ */ package com.nokia.microedition.media.animation; +import java.io.IOException; import java.io.InputStream; import java.util.Enumeration; import java.util.Hashtable; import javax.microedition.media.Control; import javax.microedition.media.MediaException; +import javax.microedition.media.Player; import javax.microedition.media.PlayerListener; import javax.microedition.media.protocol.DataSource; @@ -43,333 +45,418 @@ import com.nokia.mj.impl.nokialcdui.LCDUIInvoker; import com.nokia.mj.impl.utils.Logger; -public class AnimationPlayer extends PlayerBase { - // GIF image information, array length will be equal to the number of frames in image - protected ImageData [] iImageData; - // number of times we need to repeat the animation - // by default it's value is one - private int iTotalLoopCount=1; - // this holds all control related to this player - private Hashtable iControls= new Hashtable(); - // Current frame index of the Animation file - private int iFrameIndex; - // Current Loop Count - private int iCurrentLoopCount; - // Indicates if looping indefinitely - private boolean iRepeatForeEver; - // Current rate of the player, Used for RateControl - // Currently only two mode are supported - // paused and default rate - private int iCurrentRate; - // Display object of the eSWT API, creating this object will integrate the current java code with eSWT API. - private Display iDisplay; - // Control object of ESWT API, return from LCDUIInvoker. - org.eclipse.swt.widgets.Control iControl; - // Following constants are used for comparison of the string, throughout the class - private static final String ANIMATION_CONTENT_TYPE = "image/gif"; - private static final String fVideoControl = VideoControl.class.getName(); - private static final String fFramePositioningControl = FramePositioningControl.class.getName(); - private static final String fStopTimeControl = StopTimeControl.class.getName(); - private static final String fRateControl = RateControl.class.getName(); - - /** +public class AnimationPlayer extends PlayerBase +{ + // GIF image information, array length will be equal to the number of frames in image + protected ImageData [] iImageData; + // number of times we need to repeat the animation + // by default it's value is one + private int iTotalLoopCount=1; + // this holds all control related to this player + private Hashtable iControls= new Hashtable(); + // Current frame index of the Animation file + private int iFrameIndex; + // Current Loop Count + private int iCurrentLoopCount; + // Indicates if looping indefinitely + private boolean iRepeatForeEver; + // Current rate of the player, Used for RateControl + // Currently only two mode are supported + // paused and default rate + private int iCurrentRate; + // Display object of the eSWT API, creating this object will integrate the current java code with eSWT API. + private Display iDisplay; + // Control object of ESWT API, return from LCDUIInvoker. + org.eclipse.swt.widgets.Control iControl; + // Following constants are used for comparison of the string, throughout the class + private static final String ANIMATION_CONTENT_TYPE = "image/gif"; + private static final String fVideoControl = VideoControl.class.getName(); + private static final String fFramePositioningControl = FramePositioningControl.class.getName(); + private static final String fStopTimeControl = StopTimeControl.class.getName(); + private static final String fRateControl = RateControl.class.getName(); + + /** * Default control package. Used when getting control with * getControl method which appends default control package if package is * not specified. */ private static final String CONTROL_DEFAULT_PACKAGE = "javax.microedition.media.control."; - - //For Player listener - protected PlayerListenerImpl iPlayerListenerImpl; - //Image to be displayed, an object of eSWT API. - protected Image iImage; - // Actual dimension of the image, this should be initialized while creating the player - // as user can change the size of the image later, in that case too, getSourceheight and getSourceWidth - // of VideoControl should return the actual width and height of the image - private Point iSourceDimension; - // Total time taken so far to playe the animation - private long iMediaTime; - // Time at which, player should be stopped - // This will set through StopTimeControl.setTime(); - private long iStopTime=Long.MAX_VALUE; - - // Display Location, of the image - // there won't be any use of this, in case of Form(customItem) - private Point iDisplayLocation= new Point(0,0); + + //For Player listener + protected PlayerListenerImpl iPlayerListenerImpl; + //Image to be displayed, an object of eSWT API. + protected Image iImage; + // Actual dimension of the image, this should be initialized while creating the player + // as user can change the size of the image later, in that case too, getSourceheight and getSourceWidth + // of VideoControl should return the actual width and height of the image + private Point iSourceDimension; + // Total time taken so far to playe the animation + private long iMediaTime; + // Time at which, player should be stopped + // This will set through StopTimeControl.setTime(); + private long iStopTime=Long.MAX_VALUE; + + // Display Location, of the image + // there won't be any use of this, in case of Form(customItem) + private Point iDisplayLocation= new Point(0,0); - /** - * - * @param ds DataSource which contains the data to be displayed - */ - public AnimationPlayer(DataSource ds){ - iPlayerListenerImpl= new PlayerListenerImpl(this); - //TODO check if we can do it in better way - // this is temporary solution - // for this I have written two functions getDataSource and getInputStream function - BufferDataSource bds =(BufferDataSource )ds; - InputStreamDataSource isds=(InputStreamDataSource)bds.getDataSource(); - InputStreamSourceStream isss=(InputStreamSourceStream )isds.getStreams()[0]; - InputStream is = isss.getInputStream(); - - if(is!=null){ - ImageLoader imageLoader= new ImageLoader(); - iImageData=imageLoader.load(is); - //iRepeatCount=imageLoader.repeatCount; - iSourceDimension= new Point(imageLoader.logicalScreenWidth, imageLoader.logicalScreenHeight); - } - pupulateControl(); - } - - /** - * - * @param locator - * @throws SWTException - */ - public AnimationPlayer(String locator) throws SWTException{ - ImageLoader imageLoader= new ImageLoader(); - // Following line may throw SWTException - iImageData=imageLoader.load(locator); - //iRepeatCount=imageLoader.repeatCount; - iSourceDimension= new Point(imageLoader.logicalScreenWidth, imageLoader.logicalScreenHeight); - pupulateControl(); - } - - /** - * Moved the player to close state and releases all resources, called from PlayerBase class - */ - protected void doClose() { - iState=CLOSED; - iPlayerListenerImpl.postEvent(PlayerListener.CLOSED, null); - } + private boolean iIsControlVisible=true; + /** + * + * @param ds DataSource which contains the data to be displayed + */ + public AnimationPlayer(DataSource ds) + { + System.out.println("AnimationPlayer(DataSource ds) + "); + iPlayerListenerImpl= new PlayerListenerImpl(this); + //TODO check if we can do it in better way + // this is temporary solution + // for this I have written two functions getDataSource and getInputStream function + BufferDataSource bds =(BufferDataSource)ds; + InputStreamDataSource isds=(InputStreamDataSource)bds.getDataSource(); + InputStreamSourceStream isss=(InputStreamSourceStream)isds.getStreams()[0]; + InputStream is = isss.getInputStream(); + if (is!=null) + { + ImageLoader imageLoader= new ImageLoader(); + iImageData=imageLoader.load(is); + try + { + is.close(); + } + catch (IOException e) + { + e.printStackTrace(); + } + //iRepeatCount=imageLoader.repeatCount; + iSourceDimension= new Point(imageLoader.logicalScreenWidth, imageLoader.logicalScreenHeight); + } + populateControl(); + System.out.println("AnimationPlayer(DataSource ds) - "); + } - protected void doDeallocate() { - // what to do here, nullify image data and display etc??? - } + /** + * + * @param locator + * @throws SWTException + */ + public AnimationPlayer(String locator) throws SWTException + { + System.out.println("AnimationPlayer(String locator) + "); + iPlayerListenerImpl= new PlayerListenerImpl(this); + ImageLoader imageLoader= new ImageLoader(); + // Following line may throw SWTException + iImageData=imageLoader.load(locator); + //iRepeatCount=imageLoader.repeatCount; + iSourceDimension= new Point(imageLoader.logicalScreenWidth, imageLoader.logicalScreenHeight); + populateControl(); + System.out.println("AnimationPlayer(String locator) - "); + } + + /** + * Moved the player to close state and releases all resources, called from PlayerBase class + */ + protected void doClose() + { + iState=CLOSED; + iPlayerListenerImpl.postEvent(PlayerListener.CLOSED, null); + } - protected void doPrefetch() throws MediaException { - iState=PREFETCHED; - } + /** + * Called from the PlayerBase class + */ + protected void doDeallocate() + { + // dummy implementation + } + + protected void doPrefetch() throws MediaException + { + iState=PREFETCHED; + } + + protected void doRealize() throws MediaException + { + iState=REALIZED; + // this is temporary solution implement it in proper way + // initialize the iImage object with first frame + iImage=new Image(iDisplay, iImageData[0]); + } - protected void doRealize() throws MediaException { - iState=REALIZED; - // this is temporary solution implement it in proper way - // initialize the iImage object with first frame - iImage=new Image(iDisplay, iImageData[0]); - } - - /** - * - */ - protected void doStop() throws MediaException { - // since after stopping the player the player state will move to pre-fetched state - iState=PREFETCHED; - iPlayerListenerImpl.postEvent(PlayerListener.STOPPED, new Long(iMediaTime * 10000)); - } + /** + * + */ + protected void doStop() throws MediaException + { + // since after stopping the player the player state will move to pre-fetched state + iState=PREFETCHED; + iPlayerListenerImpl.postEvent(PlayerListener.STOPPED, new Long(iMediaTime * 10000)); + } - public void addControl(Control aControl, String aControlType) - throws MediaException { - iControls.put(aControlType, aControl); - } + /** + * Function of InternalPlayer interface + */ + public void addControl(Control aControl, String aControlType) + { + iControls.put(aControlType, aControl); + } - public void addPlayerListener(PlayerListener aPlayerListener) { - closeCheck(); + /** + * + */ + public void addPlayerListener(PlayerListener aPlayerListener) + { + closeCheck(); iPlayerListenerImpl.addPlayerListener(aPlayerListener); - } - - /** - * Returns the Content type("image/GIF") supported for by this player, - */ - public String getContentType() { - closeCheck(); + } + + /** + * Returns the Content type("image/GIF") supported for by this player, + */ + public String getContentType() + { + closeCheck(); unrealizedCheck(); - return ANIMATION_CONTENT_TYPE; - } - - /** - * This function will return, total time in microseconds this player can be played - */ - public long getDuration() { - closeCheck(); - long time = TIME_UNKNOWN; - int totalNoOfFrames = iImageData.length; - for (int i = 0; i < totalNoOfFrames; i++) { - time += iImageData[i].delayTime; - } - // Since we have to return it in microsecond multiply it with 1000; - return time * 10000; - } - - /** - * This returns the total time taken, till now, to play the video. - */ - public long getMediaTime() { - // Since we have to return it in microsecond multiply it with 1000; - return iMediaTime*10000; - } + return ANIMATION_CONTENT_TYPE; + } + + /** + * This function will return, total time in microseconds this player can be played + */ + public long getDuration() + { + closeCheck(); + long time = TIME_UNKNOWN; + int totalNoOfFrames = iImageData.length; + for (int i = 0; i < totalNoOfFrames; i++) + { + time += iImageData[i].delayTime; + } + // Since we have to return it in microsecond multiply it with 1000; + return time * 10000; + } - public int getState() { - return iState; - } - - /** - * Removes the specified playerListner from this player - */ - public void removePlayerListener(PlayerListener aPlayerListener) { - closeCheck(); + /** + * This returns the total time taken, till now, to play the video. + */ + public long getMediaTime() + { + // Since we have to return it in microsecond multiply it with 1000; + return iMediaTime*10000; + } + + public int getState() + { + return iState; + } + + /** + * Removes the specified playerListner from this player + */ + public void removePlayerListener(PlayerListener aPlayerListener) + { + closeCheck(); iPlayerListenerImpl.removePlayerListener(aPlayerListener); - } - - /** - * - */ - - public void start() throws MediaException { - final String DEBUG_STR = "AnimationPlayer::start()"; - Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STR + "+"); - prefetch(); - // Only prefetched player may be started. If player is already started - // this method returns silently. - if (getState() == PREFETCHED) { - initialize(); - addPaintListener(iControl); - iState = STARTED; - Thread thread = new Thread("Animation") { - // int frameIndex = iFrameindex; - int loopCount = iCurrentLoopCount; - GC gc = null; - public void run() { - final int noOfFrames = iImageData.length; - while (iFrameIndex < noOfFrames - && (iRepeatForeEver || (loopCount < iTotalLoopCount)) - && (iState == STARTED)) { - final int delayTimeForNextFrame = iImageData[iFrameIndex].delayTime; - // Since we are going to display first frame, notify all - // PlayerListener that Player has started - if (iFrameIndex == 0) { - // TODO Is it true that whenever STARTED event will - // be posted - // 2nd argument in postEvent function(mediaTime) - // will be zero? - // in that case just pass the 2nd argument as zero, - // instead of multiplying - // iMediaTime with 10000. - iPlayerListenerImpl.postEvent( - PlayerListener.STARTED, new Long( - iMediaTime * 10000)); - } - // if stop time has become more than the media time - // TODO This solution may not be accurate, if the delay - // between two frames is grater than 1 second. - // Do we need to implement the TimerTask only. - if ( iMediaTime > iStopTime ) { - Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STR+"Going to post Stopped at time event to player Listener "); - iPlayerListenerImpl.postEvent( - PlayerListener.STOPPED_AT_TIME, new Long( - iMediaTime * 10000)); - break; - } - iDisplay.asyncExec(new Runnable() { - public void run() { - try { - if (gc == null) - gc = new GC(iImage); - } catch (Exception e) { - // TODO Auto-generated catch block - // e.printStackTrace(); - } - // iImage.dispose(); - // iImage=new Image(iDisplay, - // iImageData[iFrameIndex]); - Image tempImage = new Image(iDisplay, - iImageData[iFrameIndex]); - gc.drawImage(tempImage, 0, 0); - tempImage.dispose(); - iFrameIndex = (iFrameIndex + 1) % noOfFrames; - iControl.redraw(); - // update the mediaTime, as Animation progress - iMediaTime += delayTimeForNextFrame; + } + + /** + * + */ + + public void start() throws MediaException + { + final String DEBUG_STR = "AnimationPlayer::start()"; + final long inTime= System.currentTimeMillis(); + // Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STR + "++++++++"); + System.out.println(DEBUG_STR + "+++"); + prefetch(); + // Only prefetched player may be started. If player is already started + // this method returns silently. + if (getState() == PREFETCHED) + { + initialize(); + iState = STARTED; + Thread thread = new Thread("Animation") + { + int loopCount = iCurrentLoopCount; + GC gc = null; + + public void run() + { + final int noOfFrames = iImageData.length; + while (iFrameIndex < noOfFrames && + (iRepeatForeEver || (loopCount < iTotalLoopCount))&& + (iState == STARTED)) + { + final int delayTimeForNextFrame = iImageData[iFrameIndex].delayTime; + // if stop time has become more than the media time + // TODO This solution may not give the accurate result, if the delay + // between two frames is grater than 1 second. + // Do we need to implement the TimerTask only? + if (iMediaTime > iStopTime) + { + iPlayerListenerImpl.postEvent( + PlayerListener.STOPPED_AT_TIME, new Long( + iMediaTime * 10000)); + break; + } - // If imageIndex becomes zero it means, all - // frames - // has been displayed - // So increase the loopCount - if (iFrameIndex == 0) { - // send the END_OF_MEDIA event to all - // listener - iPlayerListenerImpl.postEvent( - PlayerListener.END_OF_MEDIA, - new Long(iMediaTime * 10000)); - loopCount++; - // since player is again going to start from - // the - // first frame - // so media time should be set to zero - iMediaTime = 0; - } - System.out - .println(DEBUG_STR - + "\n End of asynchronous block imageIndex is " - + iFrameIndex - + " and loop count is" - + loopCount); - } - }); - try { - Thread.sleep(delayTimeForNextFrame * 10); - } catch (InterruptedException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - iCurrentLoopCount = loopCount; - Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STR - + "Came out side the while loop " + iState - + " iFrameIndex " + iFrameIndex - + " loopCount " + loopCount - ); - } - }; - thread.start(); - } - Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STR + "-"); - } - - /** - * This function is also being called from VideoControl class, - * Since on each event - * @param aControl - * @throws MediaException - */ - void addPaintListener(org.eclipse.swt.widgets.Control aControl) throws MediaException{ - iControl=aControl; - // iDisplay and IControl shouldn't be null here - // Following line should never execute - // TODO check what message to provide in case of Exception - if(iControl==null) - throw new MediaException("Update this message"); - iDisplay.syncExec(new Runnable(){ - public void run() { - iControl.addPaintListener(new PaintListener(){ - public void paintControl(PaintEvent pe) { - if(iImage!=null){ - pe.gc.drawImage(iImage, iDisplayLocation.x, iDisplayLocation.y); - } - } - }); - } - }); - } - /** - * - */ - public Control getControl(String aControlType) { - if (aControlType == null) { - throw new IllegalArgumentException("argument is null"); - } - - String controlType = aControlType; + if (iDisplay != null) + { + iDisplay.asyncExec(new Runnable() + { + public void run() + { + System.out.println(DEBUG_STR+"asynchronous block +++"); + // Since we are going to display first frame, notify all + // PlayerListener that Player has started + if (iFrameIndex == 0) + { + iPlayerListenerImpl.postEvent( + PlayerListener.STARTED, new Long( + iMediaTime * 10000)); + } + if (gc == null) + gc = new GC(iImage); + Image tempImage = new Image(iDisplay, + iImageData[iFrameIndex]); + gc.drawImage(tempImage, 0, 0); + tempImage.dispose(); + iFrameIndex = (iFrameIndex + 1) % noOfFrames; + if (iControl != null) + { + iControl.redraw(); + } + // update the mediaTime, as Animation + // progress + iMediaTime += delayTimeForNextFrame; + // If imageIndex becomes zero it means, all frames + // has been displayed + // So increase the loopCount + if (iFrameIndex == 0) + { + // send the END_OF_MEDIA event to all + // listener + iPlayerListenerImpl.postEvent( + PlayerListener.END_OF_MEDIA, + new Long(iMediaTime * 10000)); + loopCount++; + // set iMediaTime to 0 + iMediaTime = 0; + } + System.out.println(DEBUG_STR+"asynchronous block ---"); + } + }); + } + else + { + System.out.println(DEBUG_STR+"InitDisplaymode has not been called yet"); + if (iFrameIndex == 0) + { + iPlayerListenerImpl.postEvent( + PlayerListener.STARTED, new Long( + iMediaTime * 10000)); + } + // This else block will execute if the initDisplayMode hasn't been called yet + // check if initDisplayMode has been called + initialize(); + iFrameIndex = (iFrameIndex + 1) % noOfFrames; + iMediaTime += delayTimeForNextFrame; + // post EOM event + if (iFrameIndex == 0) + { + // send the END_OF_MEDIA event to all + // listener + iPlayerListenerImpl.postEvent( + PlayerListener.END_OF_MEDIA, new Long( + iMediaTime * 10000)); + loopCount++; + // since player is again going to start from + // the first frame + // so media time should be set to zero + iMediaTime = 0; + } + } + try + { + Thread.sleep(delayTimeForNextFrame * 10); + } + catch (InterruptedException e) + { + // TODO Auto-generated catch block + e.printStackTrace(); + } + System.out.println(DEBUG_STR+"while lopp ---"); + }// end of while loop + iCurrentLoopCount = loopCount; + // Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo, DEBUG_STR + System.out.println(DEBUG_STR + + "Came out side the while loop " + iState + + " iFrameIndex " + iFrameIndex + " loopCount " + + loopCount); + } + }; + thread.start(); + } + // Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STR + "-"); + System.out.println(DEBUG_STR+" Total time taken:> "+(System.currentTimeMillis()-inTime)+" ---"); + } + /** + * This function is also being called from VideoControl class, + * since on each repaint event, control is getting disposed and created each time + * @param aControl + */ + void addPaintListener(org.eclipse.swt.widgets.Control aControl) + { + System.out.println("AnimationPlayer::addPaintListener +++"); + iControl=aControl; + if (iControl != null) + { + iDisplay.syncExec(new Runnable() + { + public void run() + { + iControl.addPaintListener(new PaintListener() + { + public void paintControl(PaintEvent pe) + { + //System.out.println("AnimationPlayer::addpaintListener paintControl "+ iImage+" iIsControlVisible "+iIsControlVisible+"current time is "+System.currentTimeMillis()); + System.out.println("AnimationPlayer::addPaintListener::PaintListener::paintControl"); + if (iImage != null && iIsControlVisible) + { + pe.gc.drawImage(iImage, iDisplayLocation.x, + iDisplayLocation.y); + } + } + }); + } + }); + } + System.out.println("AnimationPlayer::addPaintListener ---"); + } + + + /** + * This returns player Control. + * + * @param controlType - the class name of the Control. The class name should be given either + * as the fully-qualified name of the class; or if the package of the class is not given, the + * package javax.microedition.media.control is assumed. + * + * @return the object that implements the control, or null. + */ + public Control getControl(String aControlType) + { + if (aControlType == null) + { + throw new IllegalArgumentException("argument is null"); + } + closeCheck(); + unrealizedCheck(); + + String controlType = aControlType; // check if package name exists if (controlType.indexOf(".") == -1) { @@ -379,247 +466,295 @@ Control control = (Control)iControls.get(controlType); // If control does not exists with default name, check if there is // is a control with same type ( extends the given class name ). - if (control == null) { - try { - // try to create class for control - Class controlClass = Class.forName(controlType); - Enumeration elements = iControls.elements(); - // search if any control is same type that requested control - while (elements.hasMoreElements()) { - Control tmpControl = (Control) elements.nextElement(); - if (controlClass.isInstance(tmpControl)) { - // control is found - control = tmpControl; - } - } - } catch (ClassNotFoundException cnfe) // the class could not be - // found - { - // Exception is ignored and null is returned from this method - } catch (Error e) // the function failed for any other reason. - { - // Error is ignored and null is returned from this method - } - } + if (control == null) + { + try + { + // try to create class for control + Class controlClass = Class.forName(controlType); + Enumeration elements = iControls.elements(); + // search if any control is same type that requested control + while (elements.hasMoreElements()) + { + Control tmpControl = (Control) elements.nextElement(); + if (controlClass.isInstance(tmpControl)) + { + // control is found + control = tmpControl; + } + } + } + catch (ClassNotFoundException cnfe) // the class could not be + // found + { + // Exception is ignored and null is returned from this method + } + catch (Error e) // the function failed for any other reason. + { + // Error is ignored and null is returned from this method + } + } return control; - } - /** - * Returns all the control associated with this player - */ - public Control[] getControls() { - Control control[]= new Control[iControls.size()]; - Enumeration enumeration= iControls.elements(); - byte index=0; - while(enumeration.hasMoreElements()){ - control[index++]=(Control)enumeration.nextElement(); - } - return control; - } - /** - * - */ - public void setLoopCount(int aCount){ - iRepeatForeEver = ( aCount == -1); - super.setLoopCount(aCount); - iTotalLoopCount=aCount; - } - /** + } + /** + * Returns all the control associated with this player + */ + public Control[] getControls() + { + closeCheck(); + unrealizedCheck(); + Control control[]= new Control[iControls.size()]; + Enumeration enumeration= iControls.elements(); + byte index=0; + while (enumeration.hasMoreElements()) + { + control[index++]=(Control)enumeration.nextElement(); + } + return control; + } + /** + * + */ + public void setLoopCount(int aCount) + { + iRepeatForeEver = (aCount == -1); + super.setLoopCount(aCount); + iTotalLoopCount=aCount; + } + /** * From PlayerBase * Here iFrameIndex variable will be updated according to the argument(aNow) supplied * We are updating the iFrameIndex variable, which is being used in the start function - * + * * @see PlayerBase */ - public long setMediaTime(long aNow) throws MediaException { - final String DEBUG_STR="AnimationPlayer::setmediaTime()"; - long now = super.setMediaTime(aNow); - int totalFrames = iImageData.length; - int totalTime = 0; - for (int i = 0; i < totalFrames; i++) { - totalTime += iImageData[i].delayTime; - if (totalTime*10000 >= now ) { - iFrameIndex=i; - break; - } - } - // we need to update the iMediaTime as well - iMediaTime=totalTime; - return totalTime * 10000; - } - ////////////////////////////////////////////////////////////////////////////////////// - // Following functions are for internal use, and not exposed to MIDlet developer////// - ///////////////////////////////////////////////////////////////////////////////////// + public long setMediaTime(long aNow) throws MediaException + { + final String DEBUG_STR="AnimationPlayer::setmediaTime()"; + long now = super.setMediaTime(aNow); + int totalFrames = iImageData.length; + int totalTime = 0; + for (int i = 0; i < totalFrames; i++) + { + totalTime += iImageData[i].delayTime; + if (totalTime*10000 >= now) + { + iFrameIndex=i; + break; + } + } + // we need to update the iMediaTime as well + iMediaTime=totalTime; + return totalTime * 10000; + } + ////////////////////////////////////////////////////////////////////////////////////// + // Following functions are for internal use, and not exposed to MIDlet developer////// + ///////////////////////////////////////////////////////////////////////////////////// + /** + * This function is responsible for creating all controls and adding it into Controls hashtable. + */ + private void populateControl() + { +// VideoControl videoControl = new VideoControl(this); +// FramePositioningControl fpc = new FramePositioningControl(this); +// StopTimeControl stc = new StopTimeControl(this); +// RateControl rc = new RateControl(this); + // there are four control provided by AnimationPlayer + // adding all one by one to the controlList(iControls) + addControl(new VideoControl(this), fVideoControl); + addControl(new FramePositioningControl(this), fFramePositioningControl); + addControl(new StopTimeControl(this), fStopTimeControl); + addControl(new RateControl(this), fRateControl); + } + + /** + * This function initialize iControl and iDisplay object if it is null, + * otherwise return immediately. + * + * In case of Canvas, eSWT control will be returned immediately from VideoControl(vc.getControl()), + * but in case of CustomItem we need to keep polling, eSWT doesn't return the control for CustomItem + * until CustomItem is appended to Form. + */ + + private void initialize() + { + System.out.println("AnimationPlayer::initialize +++"); + if (iControl == null || iDisplay == null) + { + VideoControl vc = (VideoControl) getControl(fVideoControl); + iDisplay = vc.getiDisplay(); + iControl=vc.getControl(); + addPaintListener(iControl); + System.out.println("AnimationPlayer::initialize iDsplay "+iDisplay+" iControl "+iControl); + // in case of CustomItem, +// while ((iControl = vc.getControl()) == null) { +// try { +// Thread.sleep(100); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } +// } + } + System.out.println("AnimationPlayer::initialize ---"); + } + + /** + * This function will be called from setDisplaySize(int width, int height) of animation/VideoControl class + * When MIDlet developer will try to alter the size of the image + * @param width : to be set of the video(Animated GIF) + * @param height : height to be set of video(Animated GIF) + */ + void updateImageData(int width, int height) + { + int noOfFrames= iImageData.length; + for (int i=0; itotalNoOfFrames) - return -1; - for(int i=0;itotalNoOfFrames) + return -1; + for (int i=0; i aMediaTime){ - frameNumber=i-1; - break; - } - time+=iImagedata[i].delayTime*10000; - } - return frameNumber; - } + /** + * Converts the given media time to the corresponding frame number. + * The method only performs the calculations. It does not position the media to the given media time. + * The frame returned is the nearest frame that has a media time less than or equal to the given media time. + * mapTimeToFrame(0) must not fail and must return the frame number of the first frame. + * @param the input media time for the conversion in microseconds. + * @return the converted frame number for the given media time. If the conversion fails, -1 is returned. + */ + public int mapTimeToFrame(long aMediaTime) + { + checkState(); + int frameNumber=-1; + int totalNoOfFrames=iImagedata.length; + long time=0; + for (int i=0; i aMediaTime) + { + frameNumber=i-1; + break; + } + time+=iImagedata[i].delayTime*10000; + } + return frameNumber; + } - /** - * Seek to a given video frame. The media time of the Player will be updated to reflect - * the new position set. - * This method can be called on a stopped or started Player. If the Player is in the Started state, - * this method may cause the Player to change states. If that happens, the appropriate transition - * events will be posted by the Player when its state changes. - * If the given frame number is less than the first or larger than the last frame number in the media, - * seek will jump to either the first or the last frame respectively. - * @param aFrameNumber the frame to seek to. - * @return the actual number of frames skipped. - */ - public int seek(int aFrameNumber) { - final String DEBUG_STR = "FramePositionControl::seek"; - // Check the state of the player, it shouldn't be in closed state - Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STR + "+"); - checkState(); - int frameNumber = aFrameNumber; - int totalNoOfFrames = iImagedata.length; - if (aFrameNumber < 0) { - frameNumber = 0; - } else { - if (aFrameNumber > totalNoOfFrames) { - frameNumber = totalNoOfFrames; - } - } - long mediaTime = mapFrameToTime(frameNumber); - //if the frame number is equal to total number of frames, we will seek to last frame - // because it's array index, so last index will be total length -1 - frameNumber=(frameNumber == totalNoOfFrames) ? (frameNumber-1) : frameNumber; - try { - long mediaTime1 = iPlayer.setMediaTime(mediaTime); - } catch (MediaException e) { - // Just ignore the exception - e.printStackTrace(); - } - Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STR + "- seeked to "+frameNumber); - return frameNumber; - } + /** + * Seek to a given video frame. The media time of the Player will be updated to reflect + * the new position set. + * This method can be called on a stopped or started Player. If the Player is in the Started state, + * this method may cause the Player to change states. If that happens, the appropriate transition + * events will be posted by the Player when its state changes. + * If the given frame number is less than the first or larger than the last frame number in the media, + * seek will jump to either the first or the last frame respectively. + * @param aFrameNumber the frame to seek to. + * @return the actual number of frames skipped. + */ + public int seek(int aFrameNumber) + { + final String DEBUG_STR = "FramePositionControl::seek"; + // Check the state of the player, it shouldn't be in closed state + Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STR + "+"); + checkState(); + int frameNumber = aFrameNumber; + int totalNoOfFrames = iImagedata.length; + if (aFrameNumber < 0) + { + frameNumber = 0; + } + else + { + if (aFrameNumber > totalNoOfFrames) + { + frameNumber = totalNoOfFrames; + } + } + long mediaTime = mapFrameToTime(frameNumber); + //if the frame number is equal to total number of frames, we will seek to last frame + // because it's array index, so last index will be total length -1 + frameNumber=(frameNumber == totalNoOfFrames) ? (frameNumber-1) : frameNumber; + try + { + long mediaTime1 = iPlayer.setMediaTime(mediaTime); + } + catch (MediaException e) + { + // Just ignore the exception + e.printStackTrace(); + } + Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STR + "- seeked to "+frameNumber); + return frameNumber; + } - /** - * Skip a given number of frames from the current position. The media time of the Player will be - * updated to reflect the new position set. - * This method can be called on a stopped or started Player. If the Player is in the Started state, - * the current position is changing. Hence, the frame actually skipped to will not be exact. - * If the Player is in the Started state, this method may cause the Player to change states. - * If that happens, the appropriate transition events will be posted. - * If the given framesToSkip will cause the position to extend beyond the first or last frame, - * skip will jump to the first or last frame respectively. - * @param framesToSkip - the number of frames to skip from the current position. - * If framesToSkip is positive, it will seek forward by framesToSkip number of frames. - * If framesToSkip is negative, it will seek backward by framesToSkip number of frames. - * e.g. skip(-1) will seek backward one frame. - * - * @return the actual number of frames skipped. - */ - public int skip(int aFramesToSkip) { - final String DEBUG_STR = "FramePositionControl::skip"; - Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STR+"+"); - // check the state of the player, if it closed throw exception - checkState(); - int frameNumberToJump; - if (aFramesToSkip < 0) { - frameNumberToJump = 0; - } - // storing it in local variable, so that current frame index variable will be - // consistent throughout this function, calling to getiFrameIndex(), each time - // may return the different value. - int currentFrameIndex=((AnimationPlayer) iPlayer).getiFrameIndex(); - // we are going to utilize the seek function here - // just get the current frame index from player and - // add it to the number of frame to skip - frameNumberToJump = currentFrameIndex + aFramesToSkip; - //if the frameNumberToJump > total no of frames, then skip to the last frame only - frameNumberToJump =frameNumberToJump > iImagedata.length ? iImagedata.length-1 : frameNumberToJump; - seek(frameNumberToJump); - Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STR+"-"); - return frameNumberToJump - currentFrameIndex; - } + /** + * Skip a given number of frames from the current position. The media time of the Player will be + * updated to reflect the new position set. + * This method can be called on a stopped or started Player. If the Player is in the Started state, + * the current position is changing. Hence, the frame actually skipped to will not be exact. + * If the Player is in the Started state, this method may cause the Player to change states. + * If that happens, the appropriate transition events will be posted. + * If the given framesToSkip will cause the position to extend beyond the first or last frame, + * skip will jump to the first or last frame respectively. + * @param framesToSkip - the number of frames to skip from the current position. + * If framesToSkip is positive, it will seek forward by framesToSkip number of frames. + * If framesToSkip is negative, it will seek backward by framesToSkip number of frames. + * e.g. skip(-1) will seek backward one frame. + * + * @return the actual number of frames skipped. + */ + public int skip(int aFramesToSkip) + { + final String DEBUG_STR = "FramePositionControl::skip"; + Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STR+"+"); + // check the state of the player, if it closed throw exception + checkState(); + int frameNumberToJump; + if (aFramesToSkip < 0) + { + frameNumberToJump = 0; + } + // storing it in local variable, so that current frame index variable will be + // consistent throughout this function, calling to getiFrameIndex(), each time + // may return the different value. + int currentFrameIndex=((AnimationPlayer) iPlayer).getiFrameIndex(); + // we are going to utilize the seek function here + // just get the current frame index from player and + // add it to the number of frame to skip + frameNumberToJump = currentFrameIndex + aFramesToSkip; + //if the frameNumberToJump > total no of frames, then skip to the last frame only + frameNumberToJump =frameNumberToJump > iImagedata.length ? iImagedata.length-1 : frameNumberToJump; + seek(frameNumberToJump); + Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STR+"-"); + return frameNumberToJump - currentFrameIndex; + } } diff -r dc7c549001d5 -r 85266cc22c7f javauis/mmapi_qt/baseline/javasrc/com/nokia/microedition/media/animation/RateControl.java --- a/javauis/mmapi_qt/baseline/javasrc/com/nokia/microedition/media/animation/RateControl.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/mmapi_qt/baseline/javasrc/com/nokia/microedition/media/animation/RateControl.java Fri Jun 11 13:33:44 2010 +0300 @@ -22,55 +22,64 @@ public class RateControl extends ControlImpl implements - javax.microedition.media.control.RateControl { + javax.microedition.media.control.RateControl +{ - private final static int DEFUALT_RATE=100000; - private final static int MIN_RATE=0; - /** - * - * @param aPlayer - */ - public RateControl(Player aPlayer){ - this.iPlayer=aPlayer; - ((AnimationPlayer)iPlayer).setiCurrentRate(DEFUALT_RATE); - } - - /* (non-Javadoc) - * @see javax.microedition.media.control.RateControl#getMaxRate() - */ - public int getMaxRate() { - checkState(); - return DEFUALT_RATE; - } + private final static int DEFUALT_RATE=100000; + private final static int MIN_RATE=0; + /** + * + * @param aPlayer + */ + public RateControl(Player aPlayer) + { + this.iPlayer=aPlayer; + ((AnimationPlayer)iPlayer).setiCurrentRate(DEFUALT_RATE); + } + + /* (non-Javadoc) + * @see javax.microedition.media.control.RateControl#getMaxRate() + */ + public int getMaxRate() + { + checkState(); + return DEFUALT_RATE; + } - /* (non-Javadoc) - * @see javax.microedition.media.control.RateControl#getMinRate() - */ - public int getMinRate() { - checkState(); - return MIN_RATE; - } + /* (non-Javadoc) + * @see javax.microedition.media.control.RateControl#getMinRate() + */ + public int getMinRate() + { + checkState(); + return MIN_RATE; + } - /* (non-Javadoc) - * @see javax.microedition.media.control.RateControl#getRate() - */ - public int getRate() { - checkState(); - return ((AnimationPlayer)iPlayer).getiCurrentRate(); - } + /* (non-Javadoc) + * @see javax.microedition.media.control.RateControl#getRate() + */ + public int getRate() + { + checkState(); + return ((AnimationPlayer)iPlayer).getiCurrentRate(); + } - /** - * Current implementation support only two rate default(100000) or min(0). - * No other rate is supported - */ - public int setRate(int aMilliRate) { - checkState(); - int rate =aMilliRate; - if(rate<=MIN_RATE){ - rate =MIN_RATE; - }else if(rate >= DEFUALT_RATE){ - rate =DEFUALT_RATE; - } - return ((AnimationPlayer)iPlayer).setiCurrentRate(rate) ; - } + /** + * Current implementation support only two rate default(100000) or min(0). + * No other rate is supported + */ + public int setRate(int aMilliRate) + { + checkState(); + int rate =aMilliRate; + if (rate<=MIN_RATE) + { + rate =MIN_RATE; + } + else if (rate >= DEFUALT_RATE) + { + rate =DEFUALT_RATE; + } + return ((AnimationPlayer)iPlayer).setiCurrentRate(rate) ; + } } diff -r dc7c549001d5 -r 85266cc22c7f javauis/mmapi_qt/baseline/javasrc/com/nokia/microedition/media/animation/StopTimeControl.java --- a/javauis/mmapi_qt/baseline/javasrc/com/nokia/microedition/media/animation/StopTimeControl.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/mmapi_qt/baseline/javasrc/com/nokia/microedition/media/animation/StopTimeControl.java Fri Jun 11 13:33:44 2010 +0300 @@ -28,17 +28,19 @@ *

                */ public class StopTimeControl extends ControlImpl implements - javax.microedition.media.control.StopTimeControl { + javax.microedition.media.control.StopTimeControl +{ - private long iStopTime=RESET; - /** - * - */ - public StopTimeControl(Player aPlayer) { - this.iPlayer=aPlayer; - } + private long iStopTime=RESET; + /** + * + */ + public StopTimeControl(Player aPlayer) + { + this.iPlayer=aPlayer; + } - /** + /** * Gets the last value successfully set by setStopTime. * * Returns the constant RESET if no stop time is set. @@ -47,12 +49,13 @@ * @return The current stop time in microseconds. * @see #setStopTime */ - public long getStopTime() { - checkState(); - return iStopTime; - } + public long getStopTime() + { + checkState(); + return iStopTime; + } - /** + /** * * Sets the media time at which you want the Player * to stop. @@ -89,13 +92,15 @@ * media stop-time has already been set. * @see #getStopTime */ - public void setStopTime(long aStopTime) { - checkState(); - if (iPlayer.getState() == Player.STARTED && getStopTime() != RESET) { - throw new IllegalStateException( - "Player is STARTED or setStopTime() is already called successfully"); - } - iStopTime = aStopTime; - ((AnimationPlayer)iPlayer).setiStopTime(iStopTime); - } + public void setStopTime(long aStopTime) + { + checkState(); + if (iPlayer.getState() == Player.STARTED && getStopTime() != RESET) + { + throw new IllegalStateException( + "Player is STARTED or setStopTime() is already called successfully"); + } + iStopTime = aStopTime; + ((AnimationPlayer)iPlayer).setiStopTime(iStopTime); + } } diff -r dc7c549001d5 -r 85266cc22c7f javauis/mmapi_qt/baseline/javasrc/com/nokia/microedition/media/animation/VideoControl.java --- a/javauis/mmapi_qt/baseline/javasrc/com/nokia/microedition/media/animation/VideoControl.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/mmapi_qt/baseline/javasrc/com/nokia/microedition/media/animation/VideoControl.java Fri Jun 11 13:33:44 2010 +0300 @@ -29,8 +29,11 @@ import javax.microedition.media.PlayerListener; import org.eclipse.ercp.swt.mobile.MobileShell; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.ProxyControl; @@ -50,17 +53,18 @@ public class VideoControl extends ControlImpl implements - javax.microedition.media.control.VideoControl , ItemControlStateChangeListener{ + javax.microedition.media.control.VideoControl , ItemControlStateChangeListener +{ - // Following variable has been taken from VideoControl class - private static final String GUI_OBJECT_CLASS_NAME = + // Following variable has been taken from VideoControl class + private static final String GUI_OBJECT_CLASS_NAME = "javax.microedition.lcdui.Item"; - // lcdui package used with UiToolkitRegister + // lcdui package used with UiToolkitRegister private static String LCDUI_PACKAGE = "javax.microedition.lcdui"; // eswt package used with UiToolkitRegister private static String ESWT_PACKAGE = "org.eclipse.swt.widgets"; - // ToolkitRegister class name used with eswt and lcdui + // ToolkitRegister class name used with eSWT and LCDUI private static String DISPLAY = ".Display"; // class name used to check if eswt is included @@ -68,587 +72,661 @@ // class name used to check if eswt is included private static String ESWT_CONTROL = ".control"; - - private static final int NOT_INITIALIZED = -1; - protected int iStatus = NOT_INITIALIZED; - private static final int UNDEFINED_RETURN_VALUE=0; - // For integrating with eSWT API - private Display iDisplay; - // This is reference of eSWT Control, don't get confused with the Player Control - private Control iControl; - /** - * When video display is set to full screen mode, old + + private static final int NOT_INITIALIZED = -1; + protected int iStatus = NOT_INITIALIZED; + private static final int UNDEFINED_RETURN_VALUE=0; + // For integrating with eSWT API + private Display iDisplay; + // This is reference of eSWT Control, don't get confused with the Player Control + private Control iControl; + /** + * When video display is set to full screen mode, old * video position & size is stored to this member. When * full screen mode is turned off, this member is used to * find out if display size has been changed during full * screen mode. This is needed to generate a SIZE_CHANGED * event. */ - private Point iOldDisplaySize; - /** - * A CustomItem which needs to be returned in case USE_GUI_PRIMITIVE and null to MIDlet - * from initDisplayMode function. - */ - // Global??? yes because we need to remove it from player listener, while finalizer will be called - private VideoItem iVideoItem; - - - /** - * Constructor of VideoControl - * @param player - */ - public VideoControl(Player player){ - this.iPlayer=player; - } - /** - * - */ - private Finalizer mFinalizer = new Finalizer(){ - public void finalizeImpl(){ + private Point iOldDisplaySize; + /** + * A CustomItem which needs to be returned in case USE_GUI_PRIMITIVE and null to MIDlet + * from initDisplayMode function. + */ + // Global??? yes because we need to remove it from player listener, while finalizer will be called + private VideoItem iVideoItem; + + + /** + * Constructor of VideoControl + * @param player + */ + public VideoControl(Player player) + { + this.iPlayer=player; + } + /** + * + */ + private Finalizer mFinalizer = new Finalizer() + { + public void finalizeImpl() + { doFinalize(); } }; - /** - * - */ - final void registeredFinalize() { - if (iVideoItem != null) { - iPlayer.removePlayerListener(iVideoItem); - } - } + /** + * + */ + final void registeredFinalize() + { + if (iVideoItem != null) + { + iPlayer.removePlayerListener(iVideoItem); + } + } + + /** + * + */ + private void doFinalize() + { + if (mFinalizer != null) + { + registeredFinalize(); + mFinalizer = null; + } + } - /** - * - */ - private void doFinalize() { - if (mFinalizer != null) { - registeredFinalize(); - mFinalizer = null; - } - } - - /** - * Return the actual height of the current render video. - * @return height of the display video - * @throws java.lang.IllegalStateException - Thrown if initDisplayMode has not been called. - */ - public int getDisplayHeight() { - // this function can't be called, when the player is in closed state - // or until initDisplayMode function is not called - checkState(); - if (iStatus == NOT_INITIALIZED) { - throw new IllegalStateException( - "VideoControl.initDisplayMode() not called yet"); - } - // Following function will always return Player's current height - return ((AnimationPlayer) iPlayer).getImageDimension().x; - } + /** + * Return the actual height of the current render video. + * @return height of the display video + * @throws java.lang.IllegalStateException - Thrown if initDisplayMode has not been called. + */ + public int getDisplayHeight() + { + // this function can't be called, when the player is in closed state + // or until initDisplayMode function is not called + checkState(); + if (iStatus == NOT_INITIALIZED) + { + throw new IllegalStateException( + "VideoControl.initDisplayMode() not called yet"); + } + // Following function will always return Player's current height + return ((AnimationPlayer) iPlayer).getImageDimension().x; + } - /** - * Return the actual width of the current render video. - * @return width of the display video - * @throws java.lang.IllegalStateException - Thrown if initDisplayMode has not been called. - */ - public int getDisplayWidth() { - checkState(); - if (iStatus == NOT_INITIALIZED) { - throw new IllegalStateException( - "VideoControl.initDisplayMode() not called yet"); - } - return ((AnimationPlayer) iPlayer).getImageDimension().x; - } + /** + * Return the actual width of the current render video. + * @return width of the display video + * @throws java.lang.IllegalStateException - Thrown if initDisplayMode has not been called. + */ + public int getDisplayWidth() + { + checkState(); + if (iStatus == NOT_INITIALIZED) + { + throw new IllegalStateException( + "VideoControl.initDisplayMode() not called yet"); + } + return ((AnimationPlayer) iPlayer).getImageDimension().x; + } - /** - * Return the X-coordinate of the video with respect to the GUI object where the video is displayed. - * The coordinate is specified in pixel values relative to the upper left hand corner of the GUI object. - * The return value is undefined if initDisplayMode has not been called. - * @return the X-coordinate of the video. - */ - public int getDisplayX() { - checkState(); - if (iStatus == NOT_INITIALIZED) { - return UNDEFINED_RETURN_VALUE; - } - return ((AnimationPlayer) iPlayer).getiDisplayLocation().x; - } + /** + * Return the X-coordinate of the video with respect to the GUI object where the video is displayed. + * The coordinate is specified in pixel values relative to the upper left hand corner of the GUI object. + * The return value is undefined if initDisplayMode has not been called. + * @return the X-coordinate of the video. + */ + public int getDisplayX() + { + checkState(); + if (iStatus == NOT_INITIALIZED) + { + return UNDEFINED_RETURN_VALUE; + } + return ((AnimationPlayer) iPlayer).getiDisplayLocation().x; + } - /** - * Return the Y-coordinate of the video with respective to the GUI object where the video is displayed. - * The coordinate is specified in pixel values relative to the upper left hand corner of the GUI object. - * The return value is undefined if initDisplayMode has not been called. - * @return the Y-coordinate of the video. - */ - public int getDisplayY() { - checkState(); - if (iStatus == NOT_INITIALIZED) { - return UNDEFINED_RETURN_VALUE; - } - return ((AnimationPlayer) iPlayer).getiDisplayLocation().y; - } + /** + * Return the Y-coordinate of the video with respective to the GUI object where the video is displayed. + * The coordinate is specified in pixel values relative to the upper left hand corner of the GUI object. + * The return value is undefined if initDisplayMode has not been called. + * @return the Y-coordinate of the video. + */ + public int getDisplayY() + { + checkState(); + if (iStatus == NOT_INITIALIZED) + { + return UNDEFINED_RETURN_VALUE; + } + return ((AnimationPlayer) iPlayer).getiDisplayLocation().y; + } - /** - * Get a snapshot of the displayed content. Features and format of the captured image are specified by - * imageType. Supported formats can be queried from System.getProperty with video.snapshot.encodings - * as the key. The first format in the supported list is the default capture format. - * @param imageType - Format and resolution of the returned image. - * If null is given, the default capture format is used. - * - * @return image as a byte array in required format. - * @throws java.lang.IllegalStateException - Thrown if initDisplayMode has not been called. - * @throws MediaException - Thrown if the requested format is not supported or the Player does not support snapshots. - * @throws java.lang.SecurityException - Thrown if the caller does not have the security permission to take the snapshot. - */ - //TODO Implementation pending, need discussion with UI team - public byte[] getSnapshot(String aImageType) throws MediaException { - checkState(); - if (iStatus == NOT_INITIALIZED) { - throw new IllegalStateException( - "VideoControl.initDisplayMode() not called yet"); - } - Image image=((AnimationPlayer)iPlayer).getCurrentFrame(aImageType); - byte bytArry[]= null;//getByteArray(image); - // TODO Enable the permission check - // Commented out below line, because I was getting exception + /** + * Get a snapshot of the displayed content. Features and format of the captured image are specified by + * imageType. Supported formats can be queried from System.getProperty with video.snapshot.encodings + * as the key. The first format in the supported list is the default capture format. + * @param imageType - Format and resolution of the returned image. + * If null is given, the default capture format is used. + * + * @return image as a byte array in required format. + * @throws java.lang.IllegalStateException - Thrown if initDisplayMode has not been called. + * @throws MediaException - Thrown if the requested format is not supported or the Player does not support snapshots. + * @throws java.lang.SecurityException - Thrown if the caller does not have the security permission to take the snapshot. + */ + //TODO Implementation pending, need discussion with UI team + public byte[] getSnapshot(String aImageType) throws MediaException + { + checkState(); + if (iStatus == NOT_INITIALIZED) + { + throw new IllegalStateException( + "VideoControl.initDisplayMode() not called yet"); + } + Image image=((AnimationPlayer)iPlayer).getCurrentFrame(aImageType); + byte bytArry[]= null;//getByteArray(image); + // TODO Enable the permission check + // Commented out below line, because I was getting exception // Check the permission here, so 'the moment' is not lost? //Security.ensurePermission(PERMISSION, PERMISSION, PERM_ARGS); // ApplicationUtils appUtils = ApplicationUtils.getInstance(); // PlayerPermission per = new PlayerPermission("audio/video recording","snapshot"); // appUtils.checkPermission(per); - return bytArry; - } + return bytArry; + } - /** - * Return the height of the source video. The height must be a positive number. - * @return the height of the source video. - */ - public int getSourceHeight() { - checkState(); - return ((AnimationPlayer)iPlayer).getSourceDimension().y; - } + /** + * Return the height of the source video. The height must be a positive number. + * @return the height of the source video. + */ + public int getSourceHeight() + { + checkState(); + return ((AnimationPlayer)iPlayer).getSourceDimension().y; + } - /** - * Return the width of the source video. The width must be a positive number. - * @return the width of the source video - */ - public int getSourceWidth() { - checkState(); - return ((AnimationPlayer)iPlayer).getSourceDimension().x; - } + /** + * Return the width of the source video. The width must be a positive number. + * @return the width of the source video + */ + public int getSourceWidth() + { + checkState(); + return ((AnimationPlayer)iPlayer).getSourceDimension().x; + } - /** - * Initialize the mode on how the video is displayed. - * This method must be called before video can be displayed. - * Two modes are defined: + /** + * Initialize the mode on how the video is displayed. + * This method must be called before video can be displayed. + * Two modes are defined: * USE_GUI_PRIMITIVE (inherited from GUIControl) - * USE_DIRECT_VIDEO - * @see javax.microedition.media.control.VideoControl#initDisplayMode(int, java.lang.Object) - */ - public Object initDisplayMode(int aMode, Object aArg) { - final String DEBUG_STRING = "VideoControl::initDisplayMode(int, Object)"; - Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STRING + "+"); - // To check if state is in not closed state - checkState(); - if (iStatus != NOT_INITIALIZED) { - // IllegalStateException - Thrown if initDisplayMode is - // called again after it has previously been called successfully. - throw new IllegalStateException( - "initDisplayMode() already called successfully"); - } - Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STRING+"Mode = "+aMode+" Argument = "+aArg); - // if the aArg is equal to the name of eSWT Control class name - // create the Display object in following, assuming Display - // object is already created in MIDlet. - if(aArg!=null && aArg.equals(Control.class.getName())){ - // Following line will return the same Display object - // Which is created in Midlet - iDisplay =Display.getDefault(); - }else{ - // Get the Display object of ESWT - iDisplay = com.nokia.mj.impl.nokialcdui.LCDUIInvoker.getEswtDisplay(); - } - if (aMode == USE_GUI_PRIMITIVE) { - Object guiObject = null; - if (aArg == null) { - guiObject = initNullMode(); - } else { - if (aArg.equals(GUI_OBJECT_CLASS_NAME)) { - guiObject = initLCDUI(); - } else // try load dynamic display mode - { - guiObject = initDynamicDisplayMode(aArg); - // Since it is eswtControl itself so no need of LCDUIInvoker here - // assign it in iControl and return immediately from here - iControl=(Control)guiObject; - // Now we will change the status, when MIDlet developer will call the setParent - iStatus = USE_GUI_PRIMITIVE; - return iControl; - } - } - // this will return the control as null, because the item might not - // have been appended in form - // Solution to this is as:- Add the listener through LCDUIInvoker - // and when item will be appended - // by midlet developer, notifyControlAvailable function of - // ItemStateChangeListener will be called - iControl = com.nokia.mj.impl.nokialcdui.LCDUIInvoker - .getEswtControl(guiObject); - // add this class as item state change listener - com.nokia.mj.impl.nokialcdui.LCDUIInvoker - .setItemControlStateChangeListener(this, (Item)guiObject); - iStatus = USE_GUI_PRIMITIVE; - return guiObject; - } else if (aMode == USE_DIRECT_VIDEO) { - if (aArg != null) { - if (!(aArg instanceof javax.microedition.lcdui.Canvas)) { - throw new java.lang.IllegalArgumentException( - "For USE_DIRECT_VIDEO mode argument should be of type Canvas"); - } - } else { - throw new java.lang.IllegalArgumentException( - "For USE_DIRECT_VIDEO mode argument should not be null"); - } - iControl = com.nokia.mj.impl.nokialcdui.LCDUIInvoker - .getEswtControl(aArg); - Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STRING - + "This is USE_DIRECT_VIDEO mode, control is " + iControl); - iStatus = USE_DIRECT_VIDEO; - } else { - throw new java.lang.IllegalArgumentException( - "Mode not supported or invalid, " - + "valid modes are USE_DIRECT_VIDEO and USE_GUI_PRIMITIVE"); - } - Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STRING + "-"); - return null; - } - /** - * Creates the VideoItem object of size of image(gif) - * @return VideoItem(a CustomItem ) object - */ - private Object initLCDUI(){ - final String DEBUG_STR="VideoControl::initLCDUI()"; - Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STR+"+"); - iVideoItem = new VideoItem(((AnimationPlayer)iPlayer).getImageDimension()); + * USE_DIRECT_VIDEO + * @see javax.microedition.media.control.VideoControl#initDisplayMode(int, java.lang.Object) + */ + public Object initDisplayMode(int aMode, Object aArg) + { + final String DEBUG_STRING = "VideoControl::initDisplayMode(int, Object)"; + Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STRING + "+"); + // To check if state is in not closed state + checkState(); + if (iStatus != NOT_INITIALIZED) + { + // IllegalStateException - Thrown if initDisplayMode is + // called again after it has previously been called successfully. + throw new IllegalStateException( + "initDisplayMode() already called successfully"); + } + // if the aArg is equal to the name of eSWT Control class name + // create the Display object in following, assuming Display + // object is already created in MIDlet. + if (aArg!=null && aArg.equals(Control.class.getName())) + { + // Following line will return the same Display object + // Which is created in Midlet + iDisplay =Display.getDefault(); + } + else + { + // Get the Display object of ESWT + iDisplay = com.nokia.mj.impl.nokialcdui.LCDUIInvoker.getEswtDisplay(); + } + if (aMode == USE_GUI_PRIMITIVE) + { + Object guiObject = null; + if (aArg == null) + { + guiObject = initNullMode(); + } + else + { + if (aArg.equals(GUI_OBJECT_CLASS_NAME)) + { + guiObject = initLCDUI(); + } + else // try load dynamic display mode + { + guiObject = initDynamicDisplayMode(aArg); + // Since it is eswtControl itself so no need of LCDUIInvoker here + // assign it in iControl and return immediately from here + iControl=(Control)guiObject; + // Now we will change the status, when MIDlet developer will call the setParent + iStatus = USE_GUI_PRIMITIVE; + return iControl; + } + } + // this will return the control as null, because the item might not + // have been appended in form + // Solution to this is as:- Add the listener through LCDUIInvoker + // and when item will be appended + // by MIDlet developer, notifyControlAvailable function of + // ItemStateChangeListener will be called + iControl = com.nokia.mj.impl.nokialcdui.LCDUIInvoker + .getEswtControl(guiObject); + // add this class as item state change listener + com.nokia.mj.impl.nokialcdui.LCDUIInvoker + .setItemControlStateChangeListener(this, (Item)guiObject); + iStatus = USE_GUI_PRIMITIVE; + return guiObject; + } + else if (aMode == USE_DIRECT_VIDEO) + { + if (aArg != null) + { + if (!(aArg instanceof javax.microedition.lcdui.Canvas)) + { + throw new java.lang.IllegalArgumentException( + "For USE_DIRECT_VIDEO mode argument should be of type Canvas"); + } + } + else + { + throw new java.lang.IllegalArgumentException( + "For USE_DIRECT_VIDEO mode argument should not be null"); + } + iControl = com.nokia.mj.impl.nokialcdui.LCDUIInvoker + .getEswtControl(aArg); + + //If USE_DIRECT_VIDEO is set, the video by default is not + //shown when the canvas is displayed until setVisible(true) is called + //iIsControlVisible variable of AnimationPlayer class decides, whether + //animation should be visible or not, and by default it is true; + //So making it false here. + ((AnimationPlayer)iPlayer).setiIsControlVisible(false); + iStatus = USE_DIRECT_VIDEO; + } + else + { + throw new java.lang.IllegalArgumentException( + "Mode not supported or invalid, " + + "valid modes are USE_DIRECT_VIDEO and USE_GUI_PRIMITIVE"); + } + Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STRING + "-"); + return null; + } + /** + * Creates the VideoItem object of size of image(gif) + * @return VideoItem(a CustomItem ) object + */ + private Object initLCDUI() + { + final String DEBUG_STR="VideoControl::initLCDUI()"; + Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STR+"+"); + iVideoItem = new VideoItem(((AnimationPlayer)iPlayer).getImageDimension()); iPlayer.addPlayerListener(iVideoItem); iStatus = USE_GUI_PRIMITIVE; Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STR+"-"); return iVideoItem; - } + } + + /** + * Initializes USE_GUI_PRIMITIVE mode when null parameter is given to + * initDisplayMode method. + * UI toolkit gets selected when application uses UI toolkit + * first time. After this selection null parameter must be + * interpreted as the selected UI toolkit. initDisplayMode call + * with null parameter before the selection must cause + * IllegalArgumentException if there are several toolkits. + * @return GUI object + */ + private Object initNullMode() + { + String DEBUG_STR = "VideoControl::initNullMode()"; + // TODO remove this 'toolkit' variable + String toolkit = null; + Object guiObject = null; - /** - * Initializes USE_GUI_PRIMITIVE mode when null parameter is given to - * initDisplayMode method. - * UI toolkit gets selected when application uses UI toolkit - * first time. After this selection null parameter must be - * interpreted as the selected UI toolkit. initDisplayMode call - * with null parameter before the selection must cause - * IllegalArgumentException if there are several toolkits. - * @return GUI object - */ - private Object initNullMode() { - String DEBUG_STR = "VideoControl::initNullMode()"; - // Removing following line as per new requirement. - // there won't be any toolkit -// UiToolkitRegister uiRegister = RuntimeInfoFactory.getRuntimeInfo() -// .getUiToolkitRegister(); -// // returns always non null array with zero or more strings -// String[] toolkits = uiRegister.getRegisteredUiToolkits(); - // selected toolkit or null if not selected - //String toolkit = (toolkits.length > 0) ? toolkits[0] : null; - // TODO remove this 'toolkit' variable - String toolkit = null; - Object guiObject = null; + // If LCDUI was selected init it even if there might be several + // toolkits. This is done to support existing applications. + if ((LCDUI_PACKAGE + DISPLAY).equals(toolkit)) + { + Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STR + "going to use initLCDUI function "); + guiObject = initLCDUI(); + } + else + { + try + { + // Several UI toolkits are supported if there are eSWT classes + // and eSWT direct content component + // Trying to load eSWT Listener interface or eSWT GUI factory + // does not cause any initialization to eSWT. + Class.forName(ESWT_PACKAGE + LISTENER); + // check if eSWT was selected + if ((ESWT_PACKAGE + DISPLAY).equals(toolkit)) + { + Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STR + + "It is eswtPackage going to call initDynamicDisplay "); + guiObject = initDynamicDisplayMode(ESWT_PACKAGE + + ESWT_CONTROL); - // If lcdui was selected init it even if there might be several - // toolkits. This is done to support existing applications. - if ((LCDUI_PACKAGE + DISPLAY).equals(toolkit)) { - Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STR + "going to use initLCDUI function "); - guiObject = initLCDUI(); - } else { - try { - // Several UI toolkits are supported if there are eSWT classes - // and eSWT direct content component - // Trying to load eSWT Listener interface or eSWT GUI factory - // does not cause any initialization to eSWT. - Class.forName(ESWT_PACKAGE + LISTENER); - // check if eSWT was selected - if ((ESWT_PACKAGE + DISPLAY).equals(toolkit)) - { - Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,DEBUG_STR - + "It is eswtPackage going to call initDynamicDisplay "); - guiObject = initDynamicDisplayMode(ESWT_PACKAGE - + ESWT_CONTROL); + } + else + { + // If no toolkit is registered and if LCDUI library exists + // select it + try + { + Class.forName(LCDUI_PACKAGE + DISPLAY); + guiObject = initLCDUI(); + } + catch (ClassNotFoundException cnfe) + { + // If there are several toolkits and none is selected + // IllegalArgumentException must be thrown + throw new IllegalArgumentException( + "UI toolkit is not available or found."); + } + } + } + catch (ClassNotFoundException cnfe) + { + Logger.LOG(Logger.EJavaMMAPI, Logger.EError,DEBUG_STR + + "Exception caought, going to call initLCDUI funtion"); + // Only lcdui is supported + guiObject = initLCDUI(); + } + } + return guiObject; + } - } else { - // If no toolkit is registered and if LCDUI library exists - // select it - try { - Class.forName(LCDUI_PACKAGE + DISPLAY); - guiObject = initLCDUI(); - } catch (ClassNotFoundException cnfe) { - // If there are several toolkits and none is selected - // IllegalArgumentException must be thrown - throw new IllegalArgumentException( - "UI toolkit is not available or found."); - } - } - } catch (ClassNotFoundException cnfe) { - Logger.LOG(Logger.EJavaMMAPI, Logger.EError,DEBUG_STR - + "Exception caought, going to call initLCDUI funtion"); - // Only lcdui is supported - guiObject = initLCDUI(); - } - } - return guiObject; - } - - /** - * - * @param aMode class name of the component - * @return - */ - // TODO this ProxyControl object should not be used as member variable of VC. - private ProxyControl control=null; - private Object initDynamicDisplayMode(Object aMode) { - final String DEBUG_STR="VideoControl::initDynamicDisplayMode()"; - try { - // Following line make sure that class name provided in aMode is proper - // TODO is it necessary to load the class name - Class guiClass = Class.forName((String)aMode); - iDisplay.syncExec(new Runnable() { - public void run() { - control=new ProxyControl(((AnimationPlayer)iPlayer).getImageDimension()); - } - }); - } catch (ClassNotFoundException cnfe) { - // if the class could not be found - throw new IllegalArgumentException( - "Mode not supported or invalid, " - + "valid modes are USE_DIRECT_VIDEO and USE_GUI_PRIMITIVE"); -// } catch (IllegalAccessException iae) { -// // if the class or initializer is not accessible -// throw new IllegalArgumentException("Mode: " + aMode + " caused " -// + iae); -// } catch (InstantiationException ie) { -// // if an application tries to instantiate an abstract class or an -// // interface, or if the instantiation fails for some other reason -// throw new IllegalArgumentException("Mode: " + aMode + " caused " -// +[= ie); - } catch (ClassCastException cce) { - // Thrown to indicate that the code has attempted to cast an - // object to a subclass of which it is not an instance. - throw new IllegalArgumentException("Mode: " + aMode + " caused " - + cce); - } - // TODO remove this catch(Exception) block, it is added for testing purpose - catch(Exception e){ - Logger.LOG(Logger.EJavaMMAPI, Logger.EError,"Exception thrown while creating the control object"+e); - e.printStackTrace(); - } - return control; - } - - /* (non-Javadoc) - * @see javax.microedition.media.control.VideoControl#setDisplayFullScreen(boolean) - */ - public void setDisplayFullScreen(final boolean aFullScreenMode) - throws MediaException { - if (iStatus == NOT_INITIALIZED) { - throw new IllegalStateException( - "VideoControl.initDisplayMode() not called yet"); - } - //if this is in case of form, return silently - //This is as per earlier NOKIA implementation, - // however MMAPI documentation is saying something different - // if Full screen mode is not supported, it should throw MediaException - // TODO further check and discuss.... - if(iVideoItem!=null) { - return; - } - if(aFullScreenMode){ - // Before going to full screen mode, we need to store the current display size; - // so that when user will exit from the full screen, - // it will return to it's previous size - iOldDisplaySize = ((AnimationPlayer)iPlayer).getImageDimension(); - Rectangle displayDimension=calculateFullScreenDimension(); - ((AnimationPlayer)iPlayer).updateImageData(displayDimension.width, displayDimension.height); - setDisplayLocation(displayDimension.x, displayDimension.y); - ((AnimationPlayer)iPlayer).getiPlayerListenerImpl().postEvent(PlayerListener.SIZE_CHANGED, this); - }else{ - // user may call setFullScreen(false), prior to setting it full screen - if(iOldDisplaySize!=null){ - ((AnimationPlayer)iPlayer).updateImageData(iOldDisplaySize); - // Do we need to make it null? - iOldDisplaySize=null; - // post event to player Listener - ((AnimationPlayer)iPlayer).getiPlayerListenerImpl().postEvent(PlayerListener.SIZE_CHANGED, this); - } - } - } + /** + * + * @param aMode class name of the component + * @return + */ + // TODO this ProxyControl object should not be used as member variable of VC. + private ProxyControl control=null; + private Object initDynamicDisplayMode(Object aMode) + { + try + { + // Following line make sure that class name provided in aMode is proper + // TODO is it necessary to load the class name + Class guiClass = Class.forName((String)aMode); + iDisplay.syncExec(new Runnable() + { + public void run() + { + control=new ProxyControl(((AnimationPlayer)iPlayer).getImageDimension()); + } + }); + } + catch (ClassNotFoundException cnfe) + { + // if the class could not be found + throw new IllegalArgumentException( + "Mode not supported or invalid, " + + "valid modes are USE_DIRECT_VIDEO and USE_GUI_PRIMITIVE"); +// } catch (IllegalAccessException iae) { +// // if the class or initializer is not accessible +// throw new IllegalArgumentException("Mode: " + aMode + " caused " +// + iae); +// } catch (InstantiationException ie) { +// // if an application tries to instantiate an abstract class or an +// // interface, or if the instantiation fails for some other reason +// throw new IllegalArgumentException("Mode: " + aMode + " caused " +// +[= ie); + } + catch (ClassCastException cce) + { + // Thrown to indicate that the code has attempted to cast an + // object to a subclass of which it is not an instance. + throw new IllegalArgumentException("Mode: " + aMode + " caused " + + cce); + } + // TODO remove this catch(Exception) block, it is added for testing purpose + catch (Exception e) + { + Logger.LOG(Logger.EJavaMMAPI, Logger.EError,"Exception thrown while creating the control object"+e); + e.printStackTrace(); + } + return control; + } + + /* (non-Javadoc) + * @see javax.microedition.media.control.VideoControl#setDisplayFullScreen(boolean) + */ + public void setDisplayFullScreen(final boolean aFullScreenMode) + throws MediaException + { + if (iStatus == NOT_INITIALIZED) + { + throw new IllegalStateException( + "VideoControl.initDisplayMode() not called yet"); + } + //if this is in case of form, return silently + //This is as per earlier NOKIA implementation, + if (iVideoItem!=null) + { + return; + } + if (aFullScreenMode) + { + // Before going to full screen mode, we need to store the current display size; + // so that when user will exit from the full screen, + // it will return to it's previous size + iOldDisplaySize = ((AnimationPlayer)iPlayer).getImageDimension(); + Rectangle displayDimension=calculateFullScreenDimension(); + ((AnimationPlayer)iPlayer).updateImageData(displayDimension.width, displayDimension.height); + setDisplayLocation(displayDimension.x, displayDimension.y); + ((AnimationPlayer)iPlayer).getiPlayerListenerImpl().postEvent(PlayerListener.SIZE_CHANGED, this); + } + else + { + // user may call setFullScreen(false), prior to setting it full screen + // so making it sure here that iOldDisplaySize is not null + if (iOldDisplaySize!=null) + { + ((AnimationPlayer)iPlayer).updateImageData(iOldDisplaySize); + // Do we need to make it null? + iOldDisplaySize=null; + // post event to player Listener + ((AnimationPlayer)iPlayer).getiPlayerListenerImpl().postEvent(PlayerListener.SIZE_CHANGED, this); + } + } + } - /* (non-Javadoc) - * @see javax.microedition.media.control.VideoControl#setDisplayLocation(int, int) - */ - public void setDisplayLocation(int aX, int aY) { - // in case of customItem, we are getting canvasExtension as control - // and in this case we need to ignore the setDisplayLocation call. - // it is also possible that iControl may be null( it will be null until and unless - // notifyControlAvailable function is not get called) - if(iControl==null || (iControl instanceof org.eclipse.swt.internal.extension.CanvasExtension)) - return ; - ((AnimationPlayer)iPlayer).setDisplayLocation(aX, aY); - } + /* (non-Javadoc) + * @see javax.microedition.media.control.VideoControl#setDisplayLocation(int, int) + */ + public void setDisplayLocation(int aX, int aY) + { + // Need to ignore this call in case of USE_GUI_PRIMITIVE + // in case of customItem, we are getting canvasExtension as control + // and in this case we need to ignore the setDisplayLocation call. + // it is also possible that iControl may be null( it will be null until and unless + // notifyControlAvailable function is not get called) + System.out.println("VideoControl::setDisplayLocation() curretn status is "+iStatus); + if (iControl==null || (iControl instanceof org.eclipse.swt.internal.extension.CanvasExtension)) + return ; + ((AnimationPlayer)iPlayer).setDisplayLocation(aX, aY); + } - /** - * (non-Javadoc) - * @see javax.microedition.media.control.VideoControl#setDisplaySize(int, int) - */ - // TODO we need to handle here the following scenario - // if the player is in FULL_SCREEN mode, just change the display size in background(means do not exit from - // the full screen mode and don't send event to player Listener the player size changed ) - // and changed side should take effect - public void setDisplaySize(int aWidth, int aHeight) throws MediaException { - if (iStatus == NOT_INITIALIZED) { - throw new IllegalStateException( - "VideoControl.initDisplayMode() not called yet"); - } - if (aWidth <= 0 || aHeight <= 0) { - throw new IllegalArgumentException( - "Width and height must be positive"); - } - // resize the all frames - ((AnimationPlayer) iPlayer).updateImageData(aWidth, aHeight); - // Since the DisplaySize is being changed, we need to change the - // size of VideoItem as well - // if the videoItem is not null, it means currently we are playing - // animation on form - if (iVideoItem != null)// means it is for customItem - iVideoItem.setPreferredSize(aWidth, aHeight); - // Notify to all player listener that video Size has been changed - ((AnimationPlayer) iPlayer).getiPlayerListenerImpl().postEvent( - PlayerListener.SIZE_CHANGED, this); - } + /** + * (non-Javadoc) + * @see javax.microedition.media.control.VideoControl#setDisplaySize(int, int) + */ + // TODO we need to handle here the following scenario + // if the player is in FULL_SCREEN mode, just change the display size in background(means do not exit from + // the full screen mode and don't send event to player Listener the player size changed ) + // and changed side should take effect + public void setDisplaySize(int aWidth, int aHeight) throws MediaException + { + if (iStatus == NOT_INITIALIZED) + { + throw new IllegalStateException( + "VideoControl.initDisplayMode() not called yet"); + } + if (aWidth <= 0 || aHeight <= 0) + { + throw new IllegalArgumentException( + "Width and height must be positive"); + } + // resize the all frames + ((AnimationPlayer) iPlayer).updateImageData(aWidth, aHeight); + // Since the DisplaySize is being changed, we need to change the + // size of VideoItem as well + // if the videoItem is not null, it means currently we are playing + // animation on form + if (iVideoItem != null)// means it is for customItem + iVideoItem.setPreferredSize(aWidth, aHeight); + // Notify to all player listener that video Size has been changed + ((AnimationPlayer) iPlayer).getiPlayerListenerImpl().postEvent( + PlayerListener.SIZE_CHANGED, this); + } + + /** + * Show or hide the video. + * If USE_GUI_PRIMITIVE is set, the video by default is shown when the GUI primitive is displayed. + * If USE_DIRECT_VIDEO is set, the video by default is not shown when the canvas is displayed until + * setVisible(true) is called. If the canvas is removed from the screen, the video will not be displayed. + * + * @return visible - Show the video if true, hide it otherwise. + * @throws java.lang.IllegalStateException - Thrown if initDisplayMode has not been called. + */ + public void setVisible(final boolean aVisible) + { + if (iStatus == NOT_INITIALIZED) + { + throw new IllegalStateException( + "VideoControl.initDisplayMode() not called yet"); + } + if (iControl != null) + { + ((AnimationPlayer)iPlayer).setiIsControlVisible(aVisible); + // even if the player is stopped, need to give the effect of + // setVisible + iDisplay.syncExec(new Runnable() + { + public void run() + { + iControl.redraw();//setVisible(aVisible); + } + }); + } + } + /*******************************FOLLOWING FUNCTIONS ARE USED FOR INTERNAL PURPOSE***********************/ + /** + * + * @return Display object retrieved from ESWT + */ + Display getiDisplay() + { + return iDisplay; + } - /** - * Show or hide the video. - * If USE_GUI_PRIMITIVE is set, the video by default is shown when the GUI primitive is displayed. - * If USE_DIRECT_VIDEO is set, the video by default is not shown when the canvas is displayed until - * setVisible(true) is called. If the canvas is removed from the screen, the video will not be displayed. - * - * @return visible - Show the video if true, hide it otherwise. - * @throws java.lang.IllegalStateException - Thrown if initDisplayMode has not been called. - */ - public void setVisible(final boolean aVisible) { - if (iStatus == NOT_INITIALIZED) { - throw new IllegalStateException( - "VideoControl.initDisplayMode() not called yet"); - } - // if this is in case of Form and eSWT Control then this implementation is OK - // but in case of Canvas, entire Canvas is getting invisible, which is not OK. - // TODO handle the case of Canvas case as well - //TODO in case of Canvas visiblity should be false by default - // while in case of Form it should be true. - if (iControl != null) { - iDisplay.syncExec(new Runnable() { - public void run() { - iControl.setVisible(aVisible); - } - }); - } - } - /*******************************FOLLOWING FUNCTIONS ARE USED FOR INTERNAL PURPOSE***********************/ - /** - * - * @return Display object retrieved from ESWT - */ - Display getiDisplay() { - return iDisplay; - } - - /** - * - * @return - */ - Control getControl() { - return iControl; - } - /** - * Function of ItemStateChangeListener - * Notified by LCDUI implementation - * @param ctrl - * @param item - */ - public void notifyControlAvailable(Control ctrl,Item item){ - final String DEBUG_STR= "VideoControl::notifyControlAvailable(Control ctrl,Item item)"; - iControl=ctrl; - Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo, DEBUG_STR+"Control is "+ctrl.hashCode()+ " Item is "+item); - //TODO is it proper here to put the below line in try/catch?, remove if we can. - // Otherwise it may deteriorate the performance, as in case of CustomItem on each - // repaint, eSWT control is getting destroyed, and reconstructed - try { - ((AnimationPlayer)iPlayer).addPaintListener(iControl); - } catch (MediaException e) { - // TODO What to do here - e.printStackTrace(); - } - } - /** - * Function of ItemStateChangeListener - * We don't need to do anything in this function - * - * @param item - */ - public void notifyControlDisposed(Item item){ - final String DEBUG_STR= "VideoControl::notifyControlDisposed(Item item)"; - Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo, DEBUG_STR+"Item Disposed is "+item); - } - - /** - * This function calculate the size and location of the image in case of full screen - * So that Aspect ratio should be maintained - * @return Rectangle, After calculating the size of the Video(image) in full screen mode - */ - // It is not the proper way to declare the variable as global variable - // only for the reason that it should be accessible in inner class. - // Following variable(deviceDimension) declared shouldn't be the part of VideoControl object. - // My suggestion:- Move it to some utility class - // TODO let's discuss - private Rectangle deviceDimension; - private Rectangle calculateFullScreenDimension(){ - Point actualImageSize = ((AnimationPlayer)iPlayer).getImageDimension(); - // initialize the deviceDimension, in local variable - iDisplay.syncExec(new Runnable() { - public void run() { - //deviceDimension=iDisplay.getBounds(); - deviceDimension=iDisplay.getClientArea(); - } - }); - int deviceWidth=deviceDimension.width; - int deviceHeight=deviceDimension.height; - //Returning the following rectangle after alteration - Rectangle rect= new Rectangle (0,0,deviceWidth,deviceHeight); + /** + * + * @return + */ + Control getControl() + { + return iControl; + } + /** + * Function of ItemStateChangeListener + * Notified by LCDUI implementation + * @param ctrl + * @param item + */ + public void notifyControlAvailable(Control ctrl,Item item) + { + final String DEBUG_STR= "VideoControl::notifyControlAvailable(Control ctrl,Item item)"; + iControl=ctrl; + Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo, DEBUG_STR+"Control is "+ctrl.hashCode()+ " Item is "+item); + //TODO is it proper here to put the below line in try/catch?, remove if we can. + // Otherwise it may deteriorate the performance, as in case of CustomItem on each + // repaint, eSWT control is getting destroyed, and reconstructed + ((AnimationPlayer)iPlayer).addPaintListener(iControl); + } + /** + * Function of ItemStateChangeListener + * We don't need to do anything in this function + * + * @param item + */ + public void notifyControlDisposed(Item item) + { + final String DEBUG_STR= "VideoControl::notifyControlDisposed(Item item)"; + Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo, DEBUG_STR+"Item Disposed is "+item); + } - // to handle the divide by zero - if(actualImageSize.x==0 && actualImageSize.y==0) - return rect; - // Following logic has been copied from - //earlier native implementation ( from cmmadisplay.cpp::ScaleToFullScreen) - // Smaller dimension scale ratio will be scaled. - // Changed to area calculation to avoid reals and dimension - // with smaller area will be scaled. - // remember that the argument received in this function is a point - // and it's x and y coordinate represent the width and height of the image respectively - int vDiff=(deviceWidth - actualImageSize.x)* actualImageSize.y; - int hDiff= (deviceHeight - actualImageSize.y) * actualImageSize.x; - // Check which side to scale to full screen size. - // Width or Height will be full size. - if(hDiff > vDiff){ - rect.height = (deviceWidth * actualImageSize.y)/actualImageSize.x; - rect.y= (deviceHeight - rect.height)>>1;// divide by 2 - }else { - rect.width = (deviceHeight * actualImageSize.x)/actualImageSize.y; - rect.x= (deviceWidth - rect.width)>>1; - } - return rect; - } - + /** + * This function calculate the size and location of the image in case of full screen + * So that Aspect ratio should be maintained + * @return Rectangle, After calculating the size of the Video(image) in full screen mode + */ + // It is not the proper way to declare the variable as global variable + // only for the reason that it should be accessible in inner class. + // Following variable(deviceDimension) declared shouldn't be the part of VideoControl object. + // My suggestion:- Move it to some utility class + // TODO let's discuss + private Rectangle deviceDimension; + private Rectangle calculateFullScreenDimension() + { + Point actualImageSize = ((AnimationPlayer)iPlayer).getImageDimension(); + // initialize the deviceDimension, in local variable + iDisplay.syncExec(new Runnable() + { + public void run() + { + //deviceDimension=iDisplay.getBounds(); + deviceDimension=iDisplay.getClientArea(); + } + }); + int deviceWidth=deviceDimension.width; + int deviceHeight=deviceDimension.height; + //Returning the following rectangle after alteration + Rectangle rect= new Rectangle(0,0,deviceWidth,deviceHeight); + + // to handle the divide by zero + if (actualImageSize.x==0 && actualImageSize.y==0) + return rect; + // Following logic has been copied from + //earlier native implementation ( from cmmadisplay.cpp::ScaleToFullScreen) + // Smaller dimension scale ratio will be scaled. + // Changed to area calculation to avoid reals and dimension + // with smaller area will be scaled. + // remember that the argument received in this function is a point + // and it's x and y coordinate represent the width and height of the image respectively + int vDiff=(deviceWidth - actualImageSize.x)* actualImageSize.y; + int hDiff= (deviceHeight - actualImageSize.y) * actualImageSize.x; + // Check which side to scale to full screen size. + // Width or Height will be full size. + if (hDiff > vDiff) + { + rect.height = (deviceWidth * actualImageSize.y)/actualImageSize.x; + rect.y= (deviceHeight - rect.height)>>1;// divide by 2 + } + else + { + rect.width = (deviceHeight * actualImageSize.x)/actualImageSize.y; + rect.x= (deviceWidth - rect.width)>>1; + } + return rect; + } + } diff -r dc7c549001d5 -r 85266cc22c7f javauis/mmapi_qt/baseline/javasrc/com/nokia/microedition/media/animation/VideoItem.java --- a/javauis/mmapi_qt/baseline/javasrc/com/nokia/microedition/media/animation/VideoItem.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/mmapi_qt/baseline/javasrc/com/nokia/microedition/media/animation/VideoItem.java Fri Jun 11 13:33:44 2010 +0300 @@ -25,87 +25,98 @@ import com.nokia.mj.impl.utils.Logger; -public class VideoItem extends CustomItem implements PlayerListener { - - /** - * Width of this item - */ - - int iWidth; - - /** - * Height of this item - */ - int iHeight; - - /** - * - * @param dimension - */ - protected VideoItem(Point dimension ) { - super(""); - iWidth=dimension.x; - iHeight=dimension.y; - } - - /** - * - * @param w - * @param h - */ - protected VideoItem(int w, int h) { - super(""); - iWidth=w; - iHeight=h; - } - /** - * @return the minimum content width of the item, used by form while layouting the item - */ - protected int getMinContentWidth() { - return iWidth; - } +public class VideoItem extends CustomItem implements PlayerListener +{ + + /** + * Width of this item + */ + + int iWidth; + + /** + * Height of this item + */ + int iHeight; + + /** + * + * @param dimension + */ + protected VideoItem(Point dimension) + { + super(""); + iWidth=dimension.x; + iHeight=dimension.y; + } + + /** + * + * @param w + * @param h + */ + protected VideoItem(int w, int h) + { + super(""); + iWidth=w; + iHeight=h; + } + /** + * @return the minimum content width of the item, used by form while layouting the item + */ + protected int getMinContentWidth() + { + return iWidth; + } - /** - * @return the minimum content height of the item, used by form while layouting the item - */ - protected int getMinContentHeight() { - return iHeight; - } - - /** - * @return the preferred content width of the item, used by form while layouting the item - */ - protected int getPrefContentWidth(int height) { - return iWidth; - } + /** + * @return the minimum content height of the item, used by form while layouting the item + */ + protected int getMinContentHeight() + { + return iHeight; + } - /** - * @return the preferred content height of the item, used by form while layouting the item - */ + /** + * @return the preferred content width of the item, used by form while layouting the item + */ + protected int getPrefContentWidth(int height) + { + return iWidth; + } + + /** + * @return the preferred content height of the item, used by form while layouting the item + */ - protected int getPrefContentHeight(int width) { - return iHeight; - } - /** - * This is dummy implementation of the paint method. - */ - int count; - protected void paint(Graphics g, int w, int h) { - //TODO remove this code later - // this is added just for testing purpose - g.setColor(0x00a000); - g.fillRect(0,0,w,h); - g.setColor(0xFFFFFF); - g.drawString("paint"+(count++), w>>1, h>>1, Graphics.BASELINE|Graphics.HCENTER); - } - - /** - * Whenever player will be resized this function will be invoked and it will call the invalidate method of custom item - */ - public void playerUpdate(Player aPlayer, String aEvent, Object aEventData) { - Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,"VideoItem::playerUpdate() Event is "+aEvent+"Event Data is "+aEventData); - if (aEvent == SIZE_CHANGED) { - invalidate(); - } - } + protected int getPrefContentHeight(int width) + { + return iHeight; + } + /** + * This is dummy implementation of the paint method. + */ + int count; + protected void paint(Graphics g, int w, int h) + { + //TODO remove this code later + // this is added just for testing purpose + System.out.println("VideoItem::paint()"); + g.setColor(0x00a000); + g.fillRect(0,0,w,h); + g.setColor(0xFFFFFF); + g.drawString("paint"+(count++), w>>1, h>>1, Graphics.BASELINE|Graphics.HCENTER); + } + + /** + * Whenever player will be resized this function will be invoked and it will call the invalidate method of custom item + */ + public void playerUpdate(Player aPlayer, String aEvent, Object aEventData) + { + Logger.LOG(Logger.EJavaMMAPI, Logger.EInfo,"VideoItem::playerUpdate() Event is "+aEvent+"Event Data is "+aEventData); + if (aEvent == SIZE_CHANGED) + { + invalidate(); + } + } } diff -r dc7c549001d5 -r 85266cc22c7f javauis/mmapi_qt/baseline/src/cmmacameraplayer.cpp --- a/javauis/mmapi_qt/baseline/src/cmmacameraplayer.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javauis/mmapi_qt/baseline/src/cmmacameraplayer.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -19,6 +19,7 @@ // INCLUDE FILES #include #include +#include #include "cmmacameraplayer.h" #include "tmmaparametervalidator.h" #include "mmmadisplay.h" diff -r dc7c549001d5 -r 85266cc22c7f javauis/mmapi_qt/src_drmv2/src/cmmadrmplayerfactory.cpp --- a/javauis/mmapi_qt/src_drmv2/src/cmmadrmplayerfactory.cpp Thu May 27 12:49:31 2010 +0300 +++ b/javauis/mmapi_qt/src_drmv2/src/cmmadrmplayerfactory.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -19,9 +19,10 @@ // INCLUDE FILES #include +#include +#include #include #include -#include #include "cmmadrmplayerfactory.h" #include "cmmadrmaudioplayer.h" diff -r dc7c549001d5 -r 85266cc22c7f javauis/nokiasound/build/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/nokiasound/build/build.xml Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + diff -r dc7c549001d5 -r 85266cc22c7f javauis/nokiasound/build/bwins/javanokiasoundu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/nokiasound/build/bwins/javanokiasoundu.def Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,3 @@ +EXPORTS + ?jni_lookup@@YAP6AXXZPBD@Z @ 1 NONAME ; void (*)(void) jni_lookup(char const *) + diff -r dc7c549001d5 -r 85266cc22c7f javauis/nokiasound/build/eabi/javanokiasoundu.def --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/nokiasound/build/eabi/javanokiasoundu.def Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,3 @@ +EXPORTS + _Z10jni_lookupPKc @ 1 NONAME + diff -r dc7c549001d5 -r 85266cc22c7f javauis/nokiasound/build/javanokiasound.pro --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/nokiasound/build/javanokiasound.pro Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,28 @@ +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +TEMPLATE=lib +TARGET=javanokiasound +CONFIG += omj java stl +CONFIG -= qt + +LIBS += -lcenrepnotifhandler \ + -lcentralrepository \ + -lmediaclientaudio \ + -lcommonengine \ + -ljavautils + +include(../../../build/omj.pri) diff -r dc7c549001d5 -r 85266cc22c7f javauis/nokiasound/inc/CMIDClip.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/nokiasound/inc/CMIDClip.h Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,73 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This class implements wav playing. +* +*/ + + +#ifndef CMIDCLIP_H +#define CMIDCLIP_H + +// INCLUDES +#include +#include + +#include "CMIDSoundImpl.h" + +// FORWARD DECLARATIONS +class MMIDEventSender; + +// CLASS DEFINITION +/** + * This class implements wav playing. + * + */ +NONSHARABLE_CLASS(CMIDClip): public CMIDSoundImpl, + public MMdaAudioPlayerCallback +{ +public: + + static CMIDClip* NewL(const TDesC8* aData, MMIDEventSender* aEventSender); + // Destructor + ~CMIDClip(); + +protected: + + // C++ constructor + CMIDClip(MMIDEventSender* aEventSender); + // Second phase + void ConstructL(const TDesC8* aData); + +public: + + virtual TInt Play(TInt aLoop); + virtual void Stop(); + virtual void SetVolume(TInt aVolume); + virtual TInt Volume(); + virtual void Release(); + +public: // from MMdaAudioPlayerCallback + void MapcInitComplete(TInt aError, + const TTimeIntervalMicroSeconds& aDuration); + void MapcPlayComplete(TInt aError); + +private: + + HBufC8* iClip; + CMdaAudioPlayerUtility* iMdaAudioPlayerUtility; + TInt iLoops; + TInt iVolume; +}; + +#endif // CMIDCLIP_H diff -r dc7c549001d5 -r 85266cc22c7f javauis/nokiasound/inc/CMIDSound.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/nokiasound/inc/CMIDSound.h Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,106 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Wrapper for CMIDClip and CMIDTone class initialisations. +* +*/ + + +// INCLUDES +#include +#include +#include +#include "MMIDEventSender.h" +#include "functionserver.h" + +// FORWARD DECLARATIONS +class CMIDSoundImpl; + +// CLASS DEFINITION +/** + * CMIDSound is a wrapper that handles which class is + * wanted to be initialised, CMIDClip or CMIDTone + * + */ +NONSHARABLE_CLASS(CMIDSound): + public CBase, MCenRepNotifyHandlerCallback, MMIDEventSender, java::util::FunctionServer +{ + +public: + + // Destructor + ~CMIDSound(); + +public: // From MCenRepNotifyHandlerCallback + /** + * Notifies this class about changes in the audio enable status + */ + void HandleNotifyInt(TUint32 aId, TInt aNewValue); + +public: // From MMIDEventSender + /** + * Sends event to Java SoundListener. + * @since 3.0 + * @param aEventType Type of the event to send + */ + void SendEvent(TInt aEventType); + +protected: + + // C++ default constructor + CMIDSound(); + +private: + TBool IsAudioEnabled(); + +public: + + static CMIDSound* NewL(JNIEnv& aJni, jobject aSound); + void SetBeep(TInt aFreq, TInt64 aDuration); + TInt Init(TInt aType, const TDesC8* aData); + void InitL(TInt aType, const TDesC8* aData); + TInt InitProfileListener(); + void InitProfileListenerL(); + TInt Play(TInt aLoop); + TInt DoPlay(TInt aLoop); + void Resume(); + void DoResume(); + void Stop(); + void DoStop(); + TInt SoundVolume(); + TInt Volume(); + void SetVolume(TInt aVolume); + void DoSetVolume(TInt aVolume); + TInt State(); + TInt PlayerState(); + void Release(); + void DoRelease(); + + +private: + + CMIDSoundImpl* iMIDSound; + TInt iFreq; + TInt64 iDur; + TInt iSource; + TInt iRealVolume; + + // owned, informs about changes in iRepository + CCenRepNotifyHandler* iProfileListener; + + // owned, current profile + CRepository* iRepository; + + TInt iHandle; +}; + diff -r dc7c549001d5 -r 85266cc22c7f javauis/nokiasound/inc/CMIDSoundEvent.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/nokiasound/inc/CMIDSoundEvent.h Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,71 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Class for sound related events. +* +*/ + + +#ifndef CMIDSOUNDEVENT_H +#define CMIDSOUNDEVENT_H + +#include + +// CLASS DEFINITION + +/** + * Class for sound related events. + */ +NONSHARABLE_CLASS(CMIDSoundEvent) +{ +public: // constructor + CMIDSoundEvent(TInt aEvent); + +public: // new methods + /** + * Setter for listener + * @param aListener this event will be sent to this listener + */ + void SetListener(jobject aListener); + + /** + * Setter for method ID + * @param aMethodID this event will be sent by calling this method + */ + void SetMethodID(jmethodID aMethodID); + + /** + * Adds a global reference to peer object, this reference is + * removed when the event is dispatched. This prevents peer + * object from being deleted by garbage collector before the + * event has been dispatched. + */ + void AddGlobalRef(JavaVM* javaVM); + + +private: + void Dispatch(JNIEnv& aJni); + +private: + jobject iListener; + jmethodID iMethodID; + TInt iEvent; + jobject iGlobalRef; + // Number of times the global reference has been added. + // The actual global reference is removed when the counter reaches zero. + TInt iRefCount; + +}; + + +#endif // CMIDSOUNDEVENT_H diff -r dc7c549001d5 -r 85266cc22c7f javauis/nokiasound/inc/CMIDSoundImpl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/nokiasound/inc/CMIDSoundImpl.h Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,93 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Interface and a base class for CMIDClip and CMIDTone. +* +*/ + + + +#ifndef CMIDSOUNDIMPL_H +#define CMIDSOUNDIMPL_H + +// INCLUDES +#include + +// FORWARD DECLARATIONS +class MMIDEventSender; + + +// CLASS DEFINITION +/** + * This class is interface and a base class for CMIDClip and CMIDTone + * + */ +NONSHARABLE_CLASS(CMIDSoundImpl): public CBase +{ + +public: + + enum TState + { + ENotReady, + EReadyToPlay, + EPlaying, + ENotSupported, + EInitialising + }; + +public: + + // destructor + ~CMIDSoundImpl(); + +protected: + + void ConstructL(); + + // C++ constructor + CMIDSoundImpl(MMIDEventSender* aEventSender); + +public: + + void Resume(); + + virtual TInt Play(TInt aLoop) = 0; + virtual void Stop() = 0; + virtual void SetVolume(TInt aVolume) = 0; + virtual TInt Volume() = 0; + virtual void Release() = 0; + + inline TInt State() const; + +protected: + + + TInt iState; + + // true if playback has been started. + TBool iPlayed; + + CActiveSchedulerWait* iSchedulerWait; + + // events are sent through this interface + MMIDEventSender* iEventSender; + +}; + +inline TInt CMIDSoundImpl::State() const +{ + return iState; +}; + +#endif // CMIDSOUNDIMPL_H diff -r dc7c549001d5 -r 85266cc22c7f javauis/nokiasound/inc/CMIDTone.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/nokiasound/inc/CMIDTone.h Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This class implements beep playing and OTA ringingtone playing. +* +*/ + + +#ifndef CMIDTONE_H +#define CMIDTONE_H + +// INCLUDES +#include +#include + +#include "CMIDSoundImpl.h" + +// FORWARD DECLARATIONS +class MMIDEventSender; + +// CLASS DEFINITION +/** + * This class implements beep playing and OTA ringingtone playing. + * + */ +NONSHARABLE_CLASS(CMIDTone): public CMIDSoundImpl, public MMdaAudioToneObserver +{ +public: + + static CMIDTone* NewL(TInt aFreq, TInt64 aDuration, + MMIDEventSender* aEventSender); + static CMIDTone* NewL(const TDesC8& aData, MMIDEventSender* aEventSender); + // Destructor + ~CMIDTone(); + +protected: + + // C++ constructor + CMIDTone(MMIDEventSender* aEventSender); + // Second phase + void ConstructL(TInt aFreq, TInt64 aDuration); + void ConstructL(const TDesC8& aData); + +public: + + virtual TInt Play(TInt aLoop); + virtual void Stop(); + virtual void SetVolume(TInt aVolume); + virtual TInt Volume(); + virtual void Release(); + +public: // from MMdaAudioToneObserver + + void MatoPrepareComplete(TInt aError); + void MatoPlayComplete(TInt aError); + +private: + + TInt iFreq; + TInt64 iDuration; + CMdaAudioToneUtility* iMdaAudioToneUtility; +}; + +#endif // CMIDTONE_H diff -r dc7c549001d5 -r 85266cc22c7f javauis/nokiasound/inc/MMIDEventSender.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/nokiasound/inc/MMIDEventSender.h Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: SoundImpl instances can send events through this interface +* +*/ + + + +#ifndef MMIDEVENTSENDER_H +#define MMIDEVENTSENDER_H + +/** +* SoundImpl instances cand send events through this interface. +* This interface has only one method, SendEvent(), which can be used +* for sending all types of sound events. +* +* @since 3.0 +*/ +NONSHARABLE_CLASS(MMIDEventSender) +{ + +public: // New functions + + /** + * Sends event to Java SoundListener. + * @since 3.0 + * @param aEventType Type of the event to send + */ + virtual void SendEvent(TInt aEventType) = 0; + +protected: + + /** + * C++ default constructor. + */ + MMIDEventSender() { } + +private: + + // Prohibit copy constructor if not deriving from CBase. + MMIDEventSender(const MMIDEventSender&) { } + // Prohibit assigment operator if not deriving from CBase. + MMIDEventSender& operator=(const MMIDEventSender&) + { + return *this; + } + +}; + +#endif // MMIDEVENTSENDER_H + +// End of File diff -r dc7c549001d5 -r 85266cc22c7f javauis/nokiasound/javasrc/com/nokia/mid/sound/Sound.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/nokiasound/javasrc/com/nokia/mid/sound/Sound.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,698 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Provides Sound API for playing tones and digitized audio. +* +*/ + + +package com.nokia.mid.sound; + +import com.nokia.mj.impl.rt.support.Finalizer; +import java.util.Vector; +import com.nokia.mj.impl.utils.Logger; +import java.lang.Thread; + +/** + *

                + * Provides simple Sound API for playing tones and digitized audio. + *

                + * Since MIDP doesn't have any Sound API for games there is a need + * for proprietary sound extension to support devices audio + * capabilities. Every implementation has capability to produce tone + * sounds (e.g. ringing tones), this is the minimum support. Currently + * some products support or will support also digitized audio formats. + * The Game sound API will support both buzzer and digitized audio. + * Buzzer must be supported by all implementations. If implementation + * doesn't have buzzer the buzzer tones are emulated. + *

                + * Since implementations have different audio capabilities, + * application can query which audio formats are supported by + * implementation by calling {@link #getSupportedFormats()}. + *

                + * All implementations need to support at least tone based sounds + * (type FORMAT_TONE) via {@link #Sound(int freq, long duration)} and + * {@link #init(int freq, long duration)}. In addition all implementations + * must support Smart messaging ringingtone format (type FORMAT_TONE) + * via {@link #Sound(byte[] data, int type)} and + * {@link #init(byte[] data, int type) }. + *

                + * Note that there is also work going on with Multimedia API that + * is done in JCP as + * JSR 135. + * The standard Multimedia API + * will replace the proprietary Game Sound API when it is ready. However + * Sound API will be supported also later on but probably it will be + * stated as deprecated. + *

                + * @version 1.1 + * @see com.nokia.mid.ui.DeviceControl + * @since 1.0 + */ + +public class Sound +{ + + /** + * Tone based format is used. + * + * init(int freq, int duration) puts sound into this format. + * @since 1.0 + * + */ + public static final int FORMAT_TONE = 1; + + /** + * Content is in WAV format. + * @since 1.0 + * + */ + public static final int FORMAT_WAV = 5; + + /** + * Sound is playing. + * @since 1.0 + * + */ + public static final int SOUND_PLAYING = 0; + + /** + * Sound is stopped. + * @since 1.0 + * + */ + public static final int SOUND_STOPPED = 1; + + /** + * Sound is uninitialized (released). + * @since 1.0 + */ + public static final int SOUND_UNINITIALIZED = 3; + + /** + * Sound is reinitialising + */ + private static final int SOUND_REINITIALISING = 4; + + private static final int FORMAT_BEEP = 2; + private static final int NOT_SUPPORTED_ERROR = 3; + + private static final int ERR_NOT_READY = -18; + private static final int ERR_ARGUMENT = -6; + + private int iHandle; + + private Finalizer iFinalizer; + private int iCurrentType; + private int iState; + private int iGain = -1; + + Vector iSoundListeners = new Vector(); + + private static Sound iPlayingSound; + + static + { + com.nokia.mj.impl.rt.support.Jvm.loadSystemLibrary("javanokiasound"); + } + + /** + * Constructors initialize the Sound object so that it is ready for + * playback. This constructor is used for initializing Sound + * object based on byte array data. The data should contain the data + * presented in the data format specified by type parameter. The Sound + * class defines also generally supported types as constants. + *

                + * All implementations need to support at least Nokia + * Smart Messaging, Over the Air (OTA) ringingtone format. + * The type of this format is FORMAT_TONE. + *

                + * Note: some implementations can't throw exceptions about + * sound data being corrupted or illegal during construction. + * This will result that IllagalArgumentException is delayed until + * play(int loop) method is called. Applications thus need to except + * that IllegalArgumentException is thrown in this method or during + * play method call. + *

                + * @throws java.lang.IllegalArgumentException if the data can not be + recognized to + * given type or the type is unsupported or unknown + * @throws java.lang.NullPointerException if the data is null + * @since 1.0 + * + */ + public Sound(byte[] data, int type) + { + Logger.LOG(Logger.EJavaUI, Logger.EInfo, "Sound Constructor"); + iFinalizer = registerForFinalization(); + + iHandle = _create(); + + iState = SOUND_UNINITIALIZED; + + init(data, type); + } + + /** + * Constructors initialize the Sound object so that it is ready for + * playback. Sound is initialized as a simple tone based sound. + *

                + * See method {@link #init(int freq, long duration)} for + * freq value descriptions. See also a note on exceptions semantics in + * {@link #init(int freq, long duration)}. + * + * @param freq a frequency value + * @param duration the duration of the tone in milliseconds + * @throws java.lang.IllegalArgumentException if parameter values are + * illegal, freq is not in given range or duration is negative or zero + * @since 1.0 + */ + public Sound(int freq, long duration) + { + + iFinalizer = registerForFinalization(); + iHandle = _create(); + + iState = SOUND_UNINITIALIZED; + + init(freq, duration); + } + + /** + * Called when this object is finalized, frees native resources + */ + + public Finalizer registerForFinalization() + { + + return new Finalizer() + { + public void finalizeImpl() + { + doFinalize(); + } + }; + } + + void doFinalize() + { + + if (iFinalizer == null) + { + return; + } + iFinalizer = null; + + if (iHandle > 0) + { + _dispose(iHandle); + } + } + + /** + * Releases audio resources reserved by this object. After object + * is released it goes to uninitialized state. This method should + * be called when Sound object is not needed anymore. + * @since 1.0 + */ + public void release() + { + if ((iState != SOUND_UNINITIALIZED) && + (iState != SOUND_REINITIALISING)) + { + iState = SOUND_REINITIALISING; + soundStateChanged(SOUND_UNINITIALIZED); + } + + _release(iHandle); + + iState = SOUND_UNINITIALIZED; + + } + + /** + * Initializes Sound to play a simple beep. + *

                + * Note: some implementations may not support the full frequency + * scale defined in table below. They will throw + * IllegalArgumentException instead for unsupported values. The + * exception may also be delayed + * until the play(int loop) method is called. + *

                + * Following table describes some freq argument + * values: + *

                +     * Description            Frequency
                +     * Freq off               0
                +     * Ring freq A0           220
                +     * Ring freq B0b          233
                +     * Ring freq B0           247
                +     * Ring freq C0           262
                +     * Ring freq D0b          277
                +     * Ring freq D0           294
                +     * Ring freq E0b          311
                +     * Ring freq E0           330
                +     * Ring freq F0           349
                +     * Ring freq G0b          370
                +     * Ring freq G0           392
                +     * Ring freq A1b          416
                +     * Ring freq A1           440
                +     * Ring freq B1b          466
                +     * Ring freq B1           494
                +     * Ring freq C1           523
                +     * Ring freq D1b          554
                +     * Ring freq D1           587
                +     * Ring freq E1b          622
                +     * Ring freq E1           659
                +     * Ring freq F1           698
                +     * Ring freq G1b          740
                +     * Ring freq G1           784
                +     * Ring freq A2b          831
                +     * Ring freq A2           880
                +     * Ring freq B2b          932
                +     * Ring freq B2           988
                +     * Ring freq C2           1047
                +     * Ring freq D2b          1109
                +     * Ring freq D2           1175
                +     * Ring freq E2b          1245
                +     * Ring freq E2           1319
                +     * Ring freq F2           1397
                +     * Ring freq G2b          1480
                +     * Ring freq G2           1568
                +     * Ring freq A3b          1661
                +     * Ring freq A3           1760
                +     * Ring freq B3b          1865
                +     * Ring freq B3           1976
                +     * Ring freq C3           2093
                +     * Ring freq D3b          2217
                +     * Ring freq D3           2349
                +     * Ring freq E3b          2489
                +     * Ring freq E3           2637
                +     * Ring freq F3           2794
                +     * Ring freq G3b          2960
                +     * Ring freq G3           3136
                +     * Ring freq A4b          3322
                +     * Ring freq A4           3520
                +     * Ring freq B4b          3729
                +     * Ring freq B4           3951
                +     * Ring freq C4           4186
                +     * Ring freq D4b          4434
                +     * Ring freq D4           4698
                +     * Ring freq E4b          4978
                +     * Ring freq E4           5274
                +     * Ring freq F4           5588
                +     * Ring freq G4b          5920
                +     * Ring freq G4           6272
                +     * Ring freq A5b          6644
                +     * Ring freq A5           7040
                +     * Ring freq B5b          7458
                +     * Ring freq B5           7902
                +     * Ring freq C5           8372
                +     * Ring freq D5b          8870
                +     * Ring freq D5           9396
                +     * Ring freq E5b          9956
                +     * Ring freq E5           10548
                +     * Ring freq F5           11176
                +     * Ring freq G5b          11840
                +     * Ring freq G5           12544
                +     * Ring freq A6b          13288
                +     *
                +     * 
                + * + * @param duration length of the beep in milliseconds + * @param freq frequency to be played + * @throws java.lang.IllegalArgumentException if parameter values are + * illegal, freq is not in given range or duration is negative or zero + * @since 1.0 + */ + public void init(int freq, long duration) + { + if (duration < 1 || duration > 10000000) + { + throw(new IllegalArgumentException( + "Bad duration value, must be 1-10000000")); + } + if (freq < 0 || freq > 15000) + { + throw(new IllegalArgumentException( + "Bad frequency value, must be 0-15000")); + } + // if the uninitialised event is sent from native side, it reaches + // listener too late in TCK test sound8004, thus we send the event + // already here + if ((iState != SOUND_UNINITIALIZED) && + (iState != SOUND_REINITIALISING)) + { + iState = SOUND_REINITIALISING; + soundStateChanged(SOUND_UNINITIALIZED); + } // end of if (iState != SOUND_UNINITIALIZED) + + iCurrentType = FORMAT_BEEP; + int err = _init(iHandle, iCurrentType, null, freq, duration); + if (err == ERR_NOT_READY) + { + throw new RuntimeException(Integer.toString(err)); + } + else if (err == ERR_ARGUMENT) + { + throw new IllegalArgumentException("Data is invalid"); + } + iState = SOUND_STOPPED; + } + + /** + * Initializes Sound object based on byte + * array data. The data should contain the data presented in the data + * format specified by type parameter. The Sound class defines also + * generally supported types as constants. + *

                + * All implementations need to support at least Nokia + * Smart Messaging, Over the Air (OTA) ringingtone format. + * The type of this format is FORMAT_TONE. + *

                + * Note: some implementations can't throw exceptions about + * sound data being corrupted or illegal during this method call. + * This will result that IllagalArgumentException is delayed until + * play(int loop) method is called. Applications thus need to except + * that IllegalArgumentException is thrown in this method or during + * play method call. + *

                + * @param data a byte array containing the data to be played + * @param type type of the audio + * @throws java.lang.IllegalArgumentException if the data can not be + recognized to + * given type or the type is unsupported or unknown + * @throws java.lang.NullPointerException if the data is null + * @since 1.0 + */ + public void init(byte[] data, int type) + { + if (!(type == FORMAT_WAV || type == FORMAT_TONE)) + { + throw(new IllegalArgumentException("Type is not supported")); + } + if (data == null) + { + throw(new NullPointerException("Data is null")); + } + + if ((iState != SOUND_UNINITIALIZED) && + (iState != SOUND_REINITIALISING)) + { + iState = SOUND_REINITIALISING; + soundStateChanged(SOUND_UNINITIALIZED); + } // end of if (iState != SOUND_UNINITIALIZED) + + iCurrentType = type; + int err = _init(iHandle, iCurrentType, data, 0, 0); + if (err == ERR_NOT_READY || err == ERR_ARGUMENT ) + { + throw new IllegalArgumentException("Data is invalid"); + } + + iState = SOUND_STOPPED; + } + + + /** + * Get the current state of the Sound object. + * + * @return current state, SOUND_PLAYING, SOUND_STOPPED or + SOUND_UNINITIALIZED + * @since 1.0 + * + */ + public int getState() + { + if (iState == SOUND_REINITIALISING) + { + return SOUND_UNINITIALIZED; + } + + iState = _getState(iHandle); + switch (iState) + { + case(0): // ENotReady + case(4): // EInitialising + iState = SOUND_UNINITIALIZED; + break; + case(1): // EReadyToPlay + iState = SOUND_STOPPED; + break; + case(2): // EPlaying + iState = SOUND_PLAYING; + break; + default: + } + return iState; + } + + /** + * This method is used for starting the playback from the beginning of a + * sound object. The loop parameter defined the loop count for playback. + * Argument zero (0) means continuos looping. For uninitialized sound the + * play method doesn't do anything and silently returns. For stopped and + * playing sounds the playback starts from beginning of the sound with new + * looping information. + *

                + * This method will throw IllegalStateException if playback cannot be + * started since all channels are in use, or playback is not possible + * because there is more higher priority system sounds being played. + *

                + * If Sound playback is possible this method will return immediately and + * thus will not block the calling thread during the playback. If any error + * that prevents the playback is encountered during the playback, the + * playback is silently stopped as if called to the stop method. + * + * @param number number of times audio is played. Value 0 plays audio in + * continous loop. + * @throws java.lang.IllegalStateException if the sound object cannot be + * played because all the channels are already in use. + * @throws java.lang.IllegalArgumentException if the loop value is negative, + * or if sound values/date is illegal or corrupted. + * @since 1.0 + * + */ + public void play(int loop) throws IllegalArgumentException + { + if (loop < 0) + { + throw(new IllegalArgumentException("Negative loop value")); + } + if (iState == SOUND_REINITIALISING) + { + return; + } // end of if (iState == SOUND_REINITIALISING) + + if (iPlayingSound != null) + { + if (iPlayingSound.getState() == SOUND_PLAYING) + { + iPlayingSound.stop(); + } + } // end of if (iPlayingSound != null) + + int error = _play(iHandle, loop); + if ((error == NOT_SUPPORTED_ERROR)) + { + throw(new IllegalArgumentException("Sound is not supported")); + } + iPlayingSound = this; + } + + /** + * The method will stop the sound playback, storing the current position. + * For sound that has never been started (may be uninitialized), or is + * currently being stopped the method call doesn't do anything and returns + * silently. + * + * Note that for tone based sounds it is not possible to resume from + * position the sound was stopped at, to be specific, stop will reset + * the position to the beginning of the sound. + * @since 1.0 + */ + public void stop() + { + if (iState == SOUND_REINITIALISING) + { + return; + } // end of if (iState == SOUND_REINITIALISING) + _stop(iHandle); + } + + /** + * The method will continue the stopped sound object from the position it + * was stopped to. For sound that has never been started (may be + * uninitialized), or is currently being played the method call doesn't + * do anything. + *

                + * Note: For tone based sounds the resume starts the sound from the + * beginning of the sound clip. + * @since 1.0 + * + */ + public void resume() + { + if (iState == SOUND_REINITIALISING) + { + return; + } // end of if (iState == SOUND_REINITIALISING) + _resume(iHandle); + } + + /** + * Sets the gain for the sound object. The gain is a value between + * 0 and 255. Implementation scales the gain value to the limits it + * supports. Notice that any gain value > 0 should result a gain + * value > 0. If the gain is smaller than this minimum value then + * gain is set to 0, if the gain greater than this maximum value + * then the gain is set to maximum value (255). + * + * @param gain gain value: 0 - 255 + * @throws java.lang.IllegalArgumentException if the gain not 0 - 255 + * @since 1.0 + */ + public void setGain(int gain) + { + if (iState == SOUND_REINITIALISING) + { + return; + } // end of if (iState == SOUND_REINITIALISING) + if (gain < 0) + { + gain = 0; + } + else if (gain > 255) + { + gain = 255; + } + iGain = gain; + _setVolume(iHandle, iGain); + } + + /** + * Get the gain (or volume) of Sound object. The gain is a value + * between 0 and 255. System returns a scaled value based on the + * limits it supports. Notice that any system gain value > 0 should + * return a gain value > 0. + * + * @return gain value 0 - 255 + * @since 1.0 + * + */ + public int getGain() + { + if (iGain == -1) + { + return _volume(iHandle); + } + // we have previously set gain + return iGain; + } + + /** + * Returns number of concurrent sounds the device can play for + * specific audio type. Returns 1 if only one sound can be played + * at a time. Notice that most types use same channel resources. + * @return total number of available channels. + * @param type the media type + * @throws java.lang.IllegalArgumentException if the type is unsupported + * or unknown + * @since 1.0 + */ + public static int getConcurrentSoundCount(int type) + { + if ((type != FORMAT_TONE) && (type != FORMAT_WAV)) + { + throw(new IllegalArgumentException("Type is not supported")); + } + + return 1; + } + + /** + * Returns the supported audio formats as an int array. + * + * @return an array containing supported audio formats as + * int values (e.g. FORMAT_TONE, FORMAT_WAV), + * or an empty array if no audio formats are supported. + * @since 1.0 + */ + static public int[] getSupportedFormats() + { + return(new int[] { FORMAT_TONE, FORMAT_WAV }); + } + + /** + * Registeres a listener for playback state notifications. + * @see com.nokia.mid.sound.SoundListener + * @param listener a listener that is notified when state + * changes occur or null if listener is to be + * removed. + * @since 1.0 + * + */ + public void setSoundListener(SoundListener listener) + { + iSoundListeners.addElement(listener); + } + + /** + * Callback method when sound state changes + * + */ + public void soundStateChanged(final int event) + { + /* + for(int i = 0; i < iSoundListeners.size(); i++) + { + ((SoundListener)iSoundListeners.elementAt(i)).soundStateChanged(this, event); + } + */ + //Notify SoundState Listeners in a separate thread, so that application doesn't + //block main thread + new Thread(new Runnable() + { + public void run() + { + notifySoundStateListeners(event); + } + }).start(); + } + + /** + * Notify Sound State Listeners + */ + public synchronized void notifySoundStateListeners(int event) + { + for (int i = 0; i < iSoundListeners.size(); i++) + { + ((SoundListener)iSoundListeners.elementAt(i)).soundStateChanged(this, event); + } + } + + private native void _dispose(int aHandle); + private native int _create(); + private native int _init(int aHandle, int aType, + byte[] aData, + int aFrequency, long aDuration); + private native void _release(int aHandle); + private native int _play(int aHandle, int aLoop); + private native void _stop(int aHandle); + private native void _resume(int aHandle); + private native void _setVolume(int aHandle, int aVolume); + private native int _volume(int aHandle); + private native int _getState(int aHandle); + +} //End of Sound class + diff -r dc7c549001d5 -r 85266cc22c7f javauis/nokiasound/javasrc/com/nokia/mid/sound/SoundListener.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/nokiasound/javasrc/com/nokia/mid/sound/SoundListener.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,47 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Interface indicating changes in the playback state. +* +*/ + + +package com.nokia.mid.sound; + +/** + *

                + * This interface is used by applications which need to receive events + * that indicate changes in the playback state of the Sound objects. + *

                + * @see com.nokia.mid.sound.Sound + * @version 1.1 + * @since 1.0 + */ + +public interface SoundListener +{ + + /** + * Called when playback state of an Sound has been changed. + * Listener will be notified when playback has been started + * or stopped. + * @see com.nokia.mid.sound.Sound#setSoundListener(SoundListener listener) + * @see com.nokia.mid.sound.Sound#SOUND_PLAYING + * @see com.nokia.mid.sound.Sound#SOUND_STOPPED + * @param sound the sound object this event relates to + * @param event the sound changed event, SOUND_PLAYING or SOUND_STOPPED + * @since 1.0 + */ + public abstract void soundStateChanged(Sound sound, int event); + +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/nokiasound/src/CMIDSoundImpl.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/nokiasound/src/CMIDSoundImpl.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,44 @@ +/* +* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Interface and a base class for CMIDClip and CMIDTone. +* +*/ + + +#include "CMIDSoundImpl.h" +#include "CMIDSoundEvent.h" +#include "com_nokia_mid_sound_Sound.h" + +CMIDSoundImpl::~CMIDSoundImpl() +{ + +} + +CMIDSoundImpl::CMIDSoundImpl(MMIDEventSender* aEventSender) +{ + iEventSender = aEventSender; +} + +void CMIDSoundImpl::ConstructL() +{ + +} + +void CMIDSoundImpl::Resume() +{ + if (iPlayed && (iState == EReadyToPlay)) + { + Play(1); + } +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/nokiasound/src/cmidclip.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/nokiasound/src/cmidclip.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,196 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This class implements wav playing. +* +*/ + + +#include +#include + +#include "com_nokia_mid_sound_Sound.h" +#include "CMIDClip.h" +#include "MMIDEventSender.h" + +namespace +{ +const TInt KMIDMaxJavaVolume = 255; +const TInt KMIDMinNativeVolume = 1; +const TInt KMIDHeaderLength = 4; +_LIT8(KMIDHeaderWAV, "RIFF"); +_LIT8(KMIDHeaderAMR, "#!AM"); +const TInt KMIDClipForever = 999999; +const TInt KMIDMinDataSize = 4; +} + +CMIDClip* CMIDClip::NewL(const TDesC8* aData, MMIDEventSender* aEventSender) +{ + CMIDClip* self = new(ELeave) CMIDClip(aEventSender); + CleanupStack::PushL(self); + self->ConstructL(aData); + CleanupStack::Pop(self); + return self; +} + +CMIDClip::~CMIDClip() +{ + if (iMdaAudioPlayerUtility) + { + if (iState == EPlaying) + { + iMdaAudioPlayerUtility->Stop(); + } + } + delete iMdaAudioPlayerUtility; + delete iClip; + delete iSchedulerWait; +} + +CMIDClip::CMIDClip(MMIDEventSender* aEventSender) + : CMIDSoundImpl(aEventSender) +{ +} + +void CMIDClip::ConstructL(const TDesC8* aData) +{ + CMIDSoundImpl::ConstructL(); + iSchedulerWait = new(ELeave) CActiveSchedulerWait; + + if (aData->Length() < KMIDMinDataSize) + { + iState = ENotSupported; + User::Leave(KErrArgument); + } + + TPtrC8 header = aData->Left(KMIDHeaderLength); + + if ((header != KMIDHeaderWAV()) && (header != KMIDHeaderAMR)) + { + iState = ENotSupported; + User::Leave(KErrArgument); + } + + iState = EInitialising; + iClip = aData->AllocL(); + iMdaAudioPlayerUtility = + CMdaAudioPlayerUtility:: + NewDesPlayerReadOnlyL(*iClip, *this, + KAudioPriorityRecording); + iMdaAudioPlayerUtility->UseSharedHeap(); + iSchedulerWait->Start(); +} + +TInt CMIDClip::Play(TInt aLoop) +{ + __ASSERT_DEBUG(iState == EReadyToPlay, User::Invariant()); + + if (aLoop == 0) + { + // There is no known working method to play clip forever, so we play + // it for a long time instead. + aLoop = KMIDClipForever; + } + + --aLoop; + + // Setting repeats to 1 causes sound played twice + if (aLoop > 0) + { + iMdaAudioPlayerUtility->SetRepeats(aLoop, TTimeIntervalMicroSeconds(0)); + } + + iEventSender->SendEvent(com_nokia_mid_sound_Sound_SOUND_PLAYING); + + iMdaAudioPlayerUtility->Play(); + iState = EPlaying; + iPlayed = ETrue; + return KErrNone; +} + +void CMIDClip::Stop() +{ + if (iState == EPlaying) + { + iEventSender->SendEvent(com_nokia_mid_sound_Sound_SOUND_STOPPED); + iMdaAudioPlayerUtility->Stop(); + iState = EReadyToPlay; + } +} + +void CMIDClip::SetVolume(TInt aVolume) +{ + iVolume = aVolume; + TInt volume = 0; + if (aVolume) + { + volume = (((iMdaAudioPlayerUtility->MaxVolume() + - KMIDMinNativeVolume + 1) + * aVolume) + / (KMIDMaxJavaVolume + 1)) + KMIDMinNativeVolume; + } + iMdaAudioPlayerUtility->SetVolume(volume); +} + +TInt CMIDClip::Volume() +{ + return iVolume; +} + +void CMIDClip::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/) +{ + if (aError == KErrNone) + { + //Setting iVolume to max because + //CMdaAudioPlayerUtility doesn't have Volume() + iVolume = KMIDMaxJavaVolume; + iState = EReadyToPlay; + } + else + { + if (aError == KErrNotSupported) + { + iState = ENotSupported; + } + else + { + iState = ENotReady; + } + } + iSchedulerWait->AsyncStop(); +} + +void CMIDClip::MapcPlayComplete(TInt /*aError*/) +{ + iEventSender->SendEvent(com_nokia_mid_sound_Sound_SOUND_STOPPED); + iState = EReadyToPlay; +} + +void CMIDClip::Release() +{ + if (iMdaAudioPlayerUtility) + { + if (iState == EPlaying) + { + iMdaAudioPlayerUtility->Stop(); + } + } + delete iMdaAudioPlayerUtility; + iMdaAudioPlayerUtility = NULL; + delete iClip; + iClip = NULL; + iState = ENotReady; +} + +//End of File + diff -r dc7c549001d5 -r 85266cc22c7f javauis/nokiasound/src/cmidsound.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/nokiasound/src/cmidsound.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,313 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: Wrapper for CMIDClip and CMIDTone class initialisations. +* +*/ + + +#include +#include +#include + +#include "CMIDSound.h" +#include "CMIDTone.h" +#include "CMIDClip.h" +#include "logger.h" +#include "fs_methodcall.h" +#include "com_nokia_mid_sound_Sound.h" + + +CMIDSound* CMIDSound::NewL(JNIEnv& aJni, jobject aPeer) +{ + JELOG2(EJavaUI); + + CMIDSound* self = new CMIDSound(); + if (self != NULL) + { + self->attachToVm(aJni, aPeer); + } + return self; +} + +CMIDSound::~CMIDSound() +{ + delete iMIDSound; + + // CENREP + if (iProfileListener) + { + iProfileListener->StopListening(); + delete iProfileListener; + } + delete iRepository; +} + +void CMIDSound::HandleNotifyInt(TUint32 aId, TInt aNewValue) +{ + JELOG2(EJavaUI); + if (aId == KProEngActiveWarningTones) + { + if (iMIDSound) + { + iMIDSound->SetVolume(aNewValue == 0 ? 0 : iRealVolume); + } + } +} + +void CMIDSound::SendEvent(TInt aEventType) +{ + /** + *Callback to Java + */ + JELOG2(EJavaUI); + + jclass javaPeerClass = mJniEnv->FindClass("com/nokia/mid/sound/Sound"); + + jmethodID soundStateChangeCallback = mJniEnv->GetMethodID( + javaPeerClass /*mJavaPeerClass */, "soundStateChanged", "(I)V"); + + + mJniEnv->CallVoidMethod(mJavaPeerObject, soundStateChangeCallback, + aEventType); +} + +CMIDSound::CMIDSound() + : java::util::FunctionServer("CMIDSoundFunctionServer"), + iMIDSound(0) +{ + JELOG2(EJavaUI); + createServerToNewThread(); +} + +int CMIDSound::InitProfileListener() +{ + TRAPD(err, CallMethodL(this, &CMIDSound::InitProfileListenerL, this)); + return err; +} + +void CMIDSound::InitProfileListenerL() +{ + JELOG2(EJavaUI); + // repository for profile + iRepository = CRepository::NewL(KCRUidProfileEngine); + + // get notifies about changes in KProEngActiveWarningTones + iProfileListener = CCenRepNotifyHandler::NewL(*this, + *iRepository, + CCenRepNotifyHandler::EIntKey, + KProEngActiveWarningTones); + + // Changes will be informed to HandleNotifyInt + iProfileListener->StartListeningL(); +} + +TBool CMIDSound::IsAudioEnabled(/*CMIDSound* aSelf*/) +{ + JELOG2(EJavaUI); + TInt isProfileOn = 0; + TInt error = iRepository->Get(KProEngActiveWarningTones, isProfileOn); + TBool retVal = EFalse; + + // If getting profile status fails do not play any tones. + if ((isProfileOn == 1) && + (error == KErrNone)) + { + retVal = ETrue; + } + return retVal; +} + +void CMIDSound::SetBeep(TInt aFreq, TInt64 aDuration) +{ + JELOG2(EJavaUI); + iFreq = aFreq; + iDur = aDuration; +} + +TInt CMIDSound::Init(TInt aType, const TDesC8* aData) +{ + JELOG2(EJavaUI); + TRAPD(err, CallMethodL(this, &CMIDSound::InitL, aType, aData, this)); + return err; +} + +void CMIDSound::InitL(TInt aType, const TDesC8* aData) +{ + JELOG2(EJavaUI); + + if (iMIDSound) + { + if (iMIDSound->State() == CMIDSoundImpl::EInitialising) + { + return; + } + if (iMIDSound->State() == CMIDSoundImpl::EReadyToPlay || + iMIDSound->State() == CMIDSoundImpl::EPlaying) + { + iMIDSound->Release(); + } + } + + CMIDSoundImpl* soundImpl = NULL; + switch (aType) + { + case com_nokia_mid_sound_Sound_FORMAT_TONE: //Tone + { + soundImpl = CMIDTone::NewL(*aData, this); + break; + } + case com_nokia_mid_sound_Sound_FORMAT_BEEP: //Beep + { + soundImpl = CMIDTone::NewL(iFreq, iDur, this); + break; + } + case com_nokia_mid_sound_Sound_FORMAT_WAV: //Wav + { + soundImpl = CMIDClip::NewL(aData, this); + break; + } + default: + { + break; + } + } + + if (soundImpl) + { + if (soundImpl->State() != CMIDSoundImpl::EReadyToPlay) + { + TInt state = soundImpl->State(); + delete soundImpl; + User::Leave(KErrNotReady); + } + iRealVolume = soundImpl->Volume(); + } + + delete iMIDSound; + iMIDSound = soundImpl; +} + +TInt CMIDSound::Play(TInt aLoop) +{ + JELOG2(EJavaUI); + TInt err; + CallMethodL(err, this, &CMIDSound::DoPlay, aLoop, this); + return err; +} + +TInt CMIDSound::DoPlay(TInt aLoop) +{ + JELOG2(EJavaUI); + + if (iMIDSound) + { + TInt state = iMIDSound->State(); + if (state != CMIDSoundImpl::EReadyToPlay) + { + return state; + } + } + else + { + return CMIDSoundImpl::ENotSupported; + } + if (!IsAudioEnabled()) + { + iMIDSound->SetVolume(0); + } + return iMIDSound->Play(aLoop); +} + +void CMIDSound::Resume() +{ + JELOG2(EJavaUI); + CallMethod(this, &CMIDSound::DoResume, this); +} + +void CMIDSound::DoResume() +{ + JELOG2(EJavaUI); + iMIDSound->Resume(); +} + +void CMIDSound::Stop() +{ + JELOG2(EJavaUI); + CallMethod(this, &CMIDSound::DoStop, this); +} + +void CMIDSound::DoStop() +{ + JELOG2(EJavaUI); + iMIDSound->Stop(); +} + +TInt CMIDSound::SoundVolume() +{ + JELOG2(EJavaUI); + TInt result; + CallMethodL(result, this, &CMIDSound::Volume, this); + return result; +} + +TInt CMIDSound::Volume() +{ + JELOG2(EJavaUI); + return iMIDSound->Volume(); +} + +void CMIDSound::SetVolume(TInt aVolume) +{ + JELOG2(EJavaUI); + CallMethod(this, &CMIDSound::DoSetVolume, aVolume, this); +} + +void CMIDSound::DoSetVolume(TInt aVolume) +{ + JELOG2(EJavaUI); + iRealVolume = aVolume; + TInt currentState = iMIDSound->State(); + if ((currentState == CMIDSoundImpl::EReadyToPlay) || + (currentState == CMIDSoundImpl::EPlaying)) + { + iMIDSound->SetVolume(IsAudioEnabled() ? aVolume : 0); + } +} + + +TInt CMIDSound::PlayerState() +{ + JELOG2(EJavaUI); + TInt result; + CallMethodL(result, this, &CMIDSound::State, this); + return result; +} + +TInt CMIDSound::State() +{ + JELOG2(EJavaUI); + return iMIDSound->State(); +} + +void CMIDSound::Release() +{ + JELOG2(EJavaUI); + CallMethod(this, &CMIDSound::DoRelease, this); +} + +void CMIDSound::DoRelease() +{ + JELOG2(EJavaUI); + iMIDSound->Release(); +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/nokiasound/src/cmidtone.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/nokiasound/src/cmidtone.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,244 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: This class implements beep playing and OTA ringingtone playing. +* +*/ + + +#include +#include + +#include "com_nokia_mid_sound_Sound.h" +#include "CMIDTone.h" +#include "MMIDEventSender.h" + +namespace +{ +const TInt KMIDMaxJavaVolume = 255; +const TInt KMIDMinNativeVolume = 1; +const TInt KMIDStopSleepTime = 10000; +const TInt KMIDMicrosInMilli = 1000; +const TInt KMIDMinDataLength = 4; +const TInt KMIDLoopForever = 999999; +} + +CMIDTone* CMIDTone::NewL(TInt aFreq, TInt64 aDuration, + MMIDEventSender* aEventSender) +{ + CMIDTone* self = new(ELeave) CMIDTone(aEventSender); + CleanupStack::PushL(self); + self->ConstructL(aFreq, aDuration); + CleanupStack::Pop(self); + return self; +} + +CMIDTone* CMIDTone::NewL(const TDesC8& aData, MMIDEventSender* aEventSender) +{ + CMIDTone* self = new(ELeave) CMIDTone(aEventSender); + CleanupStack::PushL(self); + self->ConstructL(aData); + CleanupStack::Pop(self); + return self; +} + + +CMIDTone::~CMIDTone() +{ + if (iMdaAudioToneUtility) + { + if (iMdaAudioToneUtility->State() == EMdaAudioToneUtilityNotReady) + { + iMdaAudioToneUtility->CancelPrepare(); + } + else if (iMdaAudioToneUtility->State() + == EMdaAudioToneUtilityPlaying) + { + iMdaAudioToneUtility->CancelPlay(); + } + } + delete iMdaAudioToneUtility; + delete iSchedulerWait; +} + +CMIDTone::CMIDTone(MMIDEventSender* aEventSender) + : CMIDSoundImpl(aEventSender) +{ +} + +void CMIDTone::ConstructL(TInt aFreq, TInt64 aDuration) +{ + CMIDSoundImpl::ConstructL(); + iSchedulerWait = new(ELeave) CActiveSchedulerWait; + iFreq = aFreq; + iDuration = aDuration; + iState = EInitialising; + iMdaAudioToneUtility = CMdaAudioToneUtility::NewL(*this); + iMdaAudioToneUtility->PrepareToPlayTone(iFreq, + TTimeIntervalMicroSeconds(iDuration * KMIDMicrosInMilli)); + iSchedulerWait->Start(); +} + +void CMIDTone::ConstructL(const TDesC8& aData) +{ + CMIDSoundImpl::ConstructL(); + iSchedulerWait = new(ELeave) CActiveSchedulerWait; + // first byte is the number of command parts + iFreq = 0; + iDuration = 0; + iState = EInitialising; + + if (aData.Length() < KMIDMinDataLength) + { + iState = ENotSupported; + User::Leave(KErrArgument); + } + + if (aData[0x000] == 0x02 && aData[0x001] == 0x4a && aData[0x002] == 0x3a) + { + iState = EInitialising; + } + else if (aData[0x000] == 0x03 && aData[0x001] == 0x4a && aData[0x002] == + 0x44 && aData[0x003] == 0x3a) + { + iState = EInitialising; + } + else if (aData[0] == 0x00 && aData[1] == 0x11) + { + iState = EInitialising; + } + else + { + iState = ENotSupported; + User::Leave(KErrArgument); + } + iMdaAudioToneUtility = CMdaAudioToneUtility::NewL(*this); + iMdaAudioToneUtility->PrepareToPlayDesSequence(aData); + iSchedulerWait->Start(); + +} + +TInt CMIDTone::Play(TInt aLoop) +{ + __ASSERT_DEBUG(iState == EReadyToPlay, User::Invariant()); + + if (aLoop == 0) + { + // There is no known working method to play tone forever + aLoop = KMIDLoopForever; + } + + // Setting repeats to 1 causes sound played twice + if (aLoop == 1) + { + iMdaAudioToneUtility->SetRepeats(0, TTimeIntervalMicroSeconds(0)); + } + else if (aLoop > 1) + { + iMdaAudioToneUtility->SetRepeats(aLoop, TTimeIntervalMicroSeconds(0)); + } + + iMdaAudioToneUtility->Play(); + + iEventSender->SendEvent(com_nokia_mid_sound_Sound_SOUND_PLAYING); + iState = EPlaying; + iPlayed = ETrue; + + return KErrNone; +} + +void CMIDTone::Stop() +{ + if (iState == EPlaying) + { + iMdaAudioToneUtility->CancelPlay(); + // sleep to make sure the device has time to stop + User::After(TTimeIntervalMicroSeconds32(KMIDStopSleepTime)); // CSI: 92 MdaAudioToneUtility does not send event when stopping has finished # + iEventSender->SendEvent(com_nokia_mid_sound_Sound_SOUND_STOPPED); + iState = EReadyToPlay; + } +} + +void CMIDTone::SetVolume(TInt aVolume) +{ + TInt maxVolume = iMdaAudioToneUtility->MaxVolume(); + TInt volume = 0; + if (aVolume) + { + volume = (((maxVolume + - KMIDMinNativeVolume + 1) + * aVolume) + / (KMIDMaxJavaVolume + 1)) + KMIDMinNativeVolume; + } + iMdaAudioToneUtility->SetVolume(volume); +} + +TInt CMIDTone::Volume() +{ + TInt maxVolume = iMdaAudioToneUtility->MaxVolume(); + TInt volume = (iMdaAudioToneUtility->Volume() * + KMIDMaxJavaVolume) / maxVolume; + + return volume; +} + +void CMIDTone::MatoPrepareComplete(TInt aError) +{ + if (aError == KErrNone) + { + iState = EReadyToPlay; + } + else + { + if (aError == KErrNotSupported) + { + iState = ENotSupported; + } + else + { + iState = ENotReady; + } + } + iSchedulerWait->AsyncStop(); +} + +void CMIDTone::MatoPlayComplete(TInt aError) +{ + if (KErrNone == aError) + { + iEventSender->SendEvent(com_nokia_mid_sound_Sound_SOUND_STOPPED); + iState = EReadyToPlay; + } +} + +void CMIDTone::Release() +{ + iState = ENotReady; + if (iMdaAudioToneUtility) + { + if (iMdaAudioToneUtility->State() == EMdaAudioToneUtilityNotReady) + { + iMdaAudioToneUtility->CancelPrepare(); + } + else if (iMdaAudioToneUtility->State() == EMdaAudioToneUtilityPlaying + || iState == EPlaying) + { + iMdaAudioToneUtility->CancelPlay(); + } + } + delete iMdaAudioToneUtility; + iMdaAudioToneUtility = NULL; + iState = ENotReady; +} + +// End of File diff -r dc7c549001d5 -r 85266cc22c7f javauis/nokiasound/src/sound.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/nokiasound/src/sound.cpp Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,209 @@ +/* +* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: JNI class for Sound.java. +* +*/ + + +#include // MAKE_TINT64 Warning fix + +#include "com_nokia_mid_sound_Sound.h" +#include "CMIDSound.h" +#include "javajniutils.h" +#include "javacommonutils.h" +#include "logger.h" + +/* + * Class: com_nokia_mid_sound_Sound + * Method: _dispose + * Signature: (II)V + */ +JNIEXPORT void JNICALL Java_com_nokia_mid_sound_Sound__1dispose +(JNIEnv* /* aJni */, jobject /* aSound */, jint aHandle) +{ + JELOG2(EJavaUI); + CMIDSound* sound = reinterpret_cast(aHandle); + delete sound; +} + +/* + * Class: com_nokia_mid_sound_Sound + * Method: _create + * Signature: (I)I + */ +JNIEXPORT jint JNICALL Java_com_nokia_mid_sound_Sound__1create +(JNIEnv* aJni, jobject aSound) +{ + JELOG2(EJavaUI); + + TInt handle(0); + CMIDSound* sound = 0; + TRAPD(err, + { + sound = CMIDSound::NewL(*aJni, aSound); + if (sound != 0) + { + sound->InitProfileListener(); + } + }); + + if (err != KErrNone) + { + + java::util::JniUtils::throwNewException(aJni, "java/lang/RuntimeException" , + "Failed to create Native Peer " + + java::util::JavaCommonUtils::intToString(err)); + } + else + { + + handle = reinterpret_cast(sound); + } + return handle; +} + +/* + * Class: com_nokia_mid_sound_Sound + * Method: _init + * Signature: (III[BIJ)I + */ +JNIEXPORT jint JNICALL Java_com_nokia_mid_sound_Sound__1init +(JNIEnv* aJni, jobject, jint aHandle, jint aType, jbyteArray aData, + jint aFrequency, jlong aDuration) +{ + JELOG2(EJavaUI); + TInt freq(aFrequency); + TInt64 duration = *reinterpret_cast(&aDuration); + + CMIDSound* sound = reinterpret_cast(aHandle); + + TPtrC8 ptr; + jbyte* data = NULL; + + if (aType != com_nokia_mid_sound_Sound_FORMAT_BEEP) + { + if (!aData) + { + return KErrGeneral; + } + data = aJni->GetByteArrayElements(aData,0); + jint length = aJni->GetArrayLength(aData); + ptr.Set((TUint8*)data, length); + } + + // Had to make SetBeep() due to number of maximum parameters in ExecuteTrap. + sound->SetBeep(freq, duration); + TInt err = sound->Init(aType, (const TDesC8*)&ptr); + + if (aType != com_nokia_mid_sound_Sound_FORMAT_BEEP) + { + aJni->ReleaseByteArrayElements(aData, data, 0); + } + return err; +} + +/* + * Class: com_nokia_mid_sound_Sound + * Method: _release + * Signature: (II)V + */ +JNIEXPORT void JNICALL Java_com_nokia_mid_sound_Sound__1release +(JNIEnv*, jobject, jint aHandle) +{ + JELOG2(EJavaUI); + CMIDSound* sound = reinterpret_cast(aHandle); + sound->Release(); +} + + +/* + * Class: com_nokia_mid_sound_Sound + * Method: _play + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_com_nokia_mid_sound_Sound__1play +(JNIEnv*, jobject, jint aHandle, jint aLoop) +{ + JELOG2(EJavaUI); + CMIDSound* sound = reinterpret_cast(aHandle); + TInt err = sound->Play(aLoop); + return err; +} + +/* + * Class: com_nokia_mid_sound_Sound + * Method: _stop + * Signature: (II)V + */ +JNIEXPORT void JNICALL Java_com_nokia_mid_sound_Sound__1stop +(JNIEnv*, jobject, jint aHandle) +{ + JELOG2(EJavaUI); + CMIDSound* sound = reinterpret_cast(aHandle); + sound->Stop(); +} + +/* + * Class: com_nokia_mid_sound_Sound + * Method: _resume + * Signature: (II)V + */ +JNIEXPORT void JNICALL Java_com_nokia_mid_sound_Sound__1resume +(JNIEnv*, jobject, jint aHandle) +{ + JELOG2(EJavaUI); + CMIDSound* sound = reinterpret_cast(aHandle); + sound->Resume(); +} + +/* + * Class: com_nokia_mid_sound_Sound + * Method: _setVolume + * Signature: (III)V + */ +JNIEXPORT void JNICALL Java_com_nokia_mid_sound_Sound__1setVolume +(JNIEnv*, jobject, jint aHandle, jint aVolume) +{ + JELOG2(EJavaUI); + CMIDSound* sound = reinterpret_cast(aHandle); + sound->SetVolume(aVolume); +} + +/* + * Class: com_nokia_mid_sound_Sound + * Method: _volume + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_com_nokia_mid_sound_Sound__1volume +(JNIEnv*, jobject, jint aHandle) +{ + JELOG2(EJavaUI); + CMIDSound* sound = reinterpret_cast(aHandle); + TInt volume = sound->SoundVolume(); + return(volume); +} + +/* + * Class: com_nokia_mid_sound_Sound + * Method: _getState + * Signature: (II)I + */ +JNIEXPORT jint JNICALL Java_com_nokia_mid_sound_Sound__1getState +(JNIEnv*, jobject, jint aHandle) +{ + JELOG2(EJavaUI); + CMIDSound* sound = reinterpret_cast(aHandle); + TInt state = sound->PlayerState(); + return state; +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/subsystem.mk --- a/javauis/subsystem.mk Thu May 27 12:49:31 2010 +0300 +++ b/javauis/subsystem.mk Fri Jun 11 13:33:44 2010 +0300 @@ -23,13 +23,16 @@ NONQTSUBSYSTEMS += \ coreui/build +COMPONENTS += nokiasound/build # # Common legacy utilities # SUBSYSTEMS += javalegacyutils -SYMBIAN_ONLY += javalegacyutils + +SYMBIAN_ONLY += javalegacyutils nokiasound/build + # diff -r dc7c549001d5 -r 85266cc22c7f javauis/subsystem_akn.mk --- a/javauis/subsystem_akn.mk Thu May 27 12:49:31 2010 +0300 +++ b/javauis/subsystem_akn.mk Fri Jun 11 13:33:44 2010 +0300 @@ -22,7 +22,6 @@ m2g_akn/build \ m3g_akn/build \ mmapi_akn/build \ - nokiasound_akn/build \ remconobserver_akn/build \ runtimeui_akn/build \ softnotification_akn/build diff -r dc7c549001d5 -r 85266cc22c7f javauis/subsystem_qt.mk --- a/javauis/subsystem_qt.mk Thu May 27 12:49:31 2010 +0300 +++ b/javauis/subsystem_qt.mk Fri Jun 11 13:33:44 2010 +0300 @@ -1,5 +1,5 @@ # -# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# Copyright (c) 2009, 2010 Nokia Corporation and/or its subsidiary(-ies). # All rights reserved. # This component and the accompanying materials are made available # under the terms of "Eclipse Public License v1.0" @@ -14,6 +14,10 @@ # Description: Makefile for Qt based components and subsystems # -COMPONENTS += eswt_qt/build lcdui_qt/build runtimeui_qt/build nokiauiapi_qt/build mmapi_qt/build amms_qt/build +SUBSYSTEMS += eswt_qt/build +COMPONENTS += lcdui_qt/build runtimeui_qt/build nokiauiapi_qt/build mmapi_qt/build amms_qt/build m3g_qt/build SYMBIAN_ONLY += mmapi_qt/build amms_qt/build m3g_qt/build + +# Build order dependency +lcdui_qt/build runtimeui_qt/build nokiauiapi_qt/build mmapi_qt/build amms_qt/build m3g_qt/build: eswt_qt/build diff -r dc7c549001d5 -r 85266cc22c7f javauis/tsrc/fute/lcdui/Midp_Form_01/build.xml --- a/javauis/tsrc/fute/lcdui/Midp_Form_01/build.xml Thu May 27 12:49:31 2010 +0300 +++ b/javauis/tsrc/fute/lcdui/Midp_Form_01/build.xml Fri Jun 11 13:33:44 2010 +0300 @@ -28,7 +28,7 @@ - + diff -r dc7c549001d5 -r 85266cc22c7f javauis/tsrc/fute/lcdui/Midp_Form_01/src/FormMethodsTests.java --- a/javauis/tsrc/fute/lcdui/Midp_Form_01/src/FormMethodsTests.java Thu May 27 12:49:31 2010 +0300 +++ b/javauis/tsrc/fute/lcdui/Midp_Form_01/src/FormMethodsTests.java Fri Jun 11 13:33:44 2010 +0300 @@ -56,7 +56,7 @@ private final String imgStr = "ImageItem"; - private final String spacerStr = "Spacer"; + private final String spacerStr = "Spacer (100x100)"; private ChoiceGroup cg = null; @@ -324,7 +324,7 @@ else if (item.equals(imgStr)) addImageItem(); else if (item.equals(spacerStr)) - addSpacer(10,10); + addSpacer(100,100); else if (item.equals(tfStr)) { addTextField("ANY", TextField.ANY); diff -r dc7c549001d5 -r 85266cc22c7f javauis/tsrc/fute/lcdui/Midp_General/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/tsrc/fute/lcdui/Midp_General/build.xml Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -r dc7c549001d5 -r 85266cc22c7f javauis/tsrc/fute/lcdui/Midp_General/res/small.png Binary file javauis/tsrc/fute/lcdui/Midp_General/res/small.png has changed diff -r dc7c549001d5 -r 85266cc22c7f javauis/tsrc/fute/lcdui/Midp_General/src/EmptyForm.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/tsrc/fute/lcdui/Midp_General/src/EmptyForm.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,41 @@ +/* +* Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +/** + * import midp classes. + */ +import javax.microedition.midlet.*; +import javax.microedition.lcdui.*; + +/** + * This is the main class for the empty Form. + */ + +public class EmptyForm extends Form +{ + + /** + * The constructor creates and displays the Form. + * + *@param parent is the parent midlet. + */ + public EmptyForm(MIDlet parent) + { + super(parent.getClass().getName()); + Display.getDisplay(parent).setCurrent(this); + } +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/tsrc/fute/lcdui/Midp_General/src/Midp_General_01.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/tsrc/fute/lcdui/Midp_General/src/Midp_General_01.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,72 @@ +/* +* Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +/** + * import midp classes. + */ +import javax.microedition.midlet.*; +import javax.microedition.lcdui.*; + +/** + * This is the main class for the Midp_General_01 tests. + */ + +public class Midp_General_01 extends MIDlet implements CommandListener +{ + private Form theForm; + private Command cmdExit = new Command("Exit", Command.EXIT, 1); + + /** + * Signals the MIDlet to start and enter the Active state. + */ + protected void startApp() + { + theForm = new EmptyForm(this); + theForm.addCommand(cmdExit); + theForm.setCommandListener(this); + } + + /** + * Signals the MIDlet to terminate and enter the Destroyed state. + * + */ + protected void destroyApp(boolean unconditional) + { + } + + /** + * Signals the MIDlet to stop and enter the Paused state. + */ + protected void pauseApp() + { + } + + /** + * This method handles command invocations. + * + *@param c This is the command responsible for the event. + *@param s Should be equal to this. + */ + public void commandAction(Command c, Displayable s) + { + if (c == cmdExit) + { + destroyApp(false); + notifyDestroyed(); + } + } +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/tsrc/fute/lcdui/Midp_General/src/Midp_General_02.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/tsrc/fute/lcdui/Midp_General/src/Midp_General_02.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,89 @@ +/* +* Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +/** + * import midp classes. + */ +import javax.microedition.midlet.*; +import javax.microedition.lcdui.*; + +/** + * This is the main class for the Midp_General_02 tests. + */ + +public class Midp_General_02 extends MIDlet implements CommandListener +{ + + TextBox tb; + Display display; + private Command cmdExit = new Command("Exit", Command.EXIT, 1); + + String theText = "This is a TextBox with very long text blah blah blah blah blah blah" + + "blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah" + + "blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah" + + "blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah" + + "blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah" + + "blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah" + + "blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah" + + "This is the last sentence."; + + public Midp_General_02() + { + tb = new TextBox("TextBox", theText, 1000, TextField.ANY); + tb.addCommand(cmdExit); + tb.setCommandListener(this); + display = Display.getDisplay(this); + } + + /** + * Signals the MIDlet to start and enter the Active state. + */ + protected void startApp() + { + display.setCurrent(tb); + } + + /** + * Signals the MIDlet to terminate and enter the Destroyed state. + * + */ + protected void destroyApp(boolean unconditional) + { + } + + /** + * Signals the MIDlet to stop and enter the Paused state. + */ + protected void pauseApp() + { + } + + /** + * This method handles command invocations. + * + *@param c This is the command responsible for the event. + *@param s Should be equal to this. + */ + public void commandAction(Command c, Displayable s) + { + if (c == cmdExit) + { + destroyApp(false); + notifyDestroyed(); + } + } +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/tsrc/fute/lcdui/Midp_General/src/Midp_General_03.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/tsrc/fute/lcdui/Midp_General/src/Midp_General_03.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +/** + * import midp classes. + */ +import javax.microedition.midlet.*; +import javax.microedition.lcdui.*; + +/** + * This is the main class for the Midp_General_03 tests. + */ + +public class Midp_General_03 extends MIDlet implements CommandListener +{ + + private List emptyList; + private Display display; + private Command cmdExit = new Command("Exit", Command.EXIT, 1); + + public Midp_General_03() + { + emptyList = new List("List", List.EXCLUSIVE); + emptyList.addCommand(cmdExit); + emptyList.setCommandListener(this); + display = Display.getDisplay(this); + } + + /** + * Signals the MIDlet to start and enter the Active state. + */ + protected void startApp() + { + display.setCurrent(emptyList); + } + + /** + * Signals the MIDlet to terminate and enter the Destroyed state. + * + */ + protected void destroyApp(boolean unconditional) + { + } + + /** + * Signals the MIDlet to stop and enter the Paused state. + */ + protected void pauseApp() + { + } + + /** + * This method handles command invocations. + * + *@param c This is the command responsible for the event. + *@param s Should be equal to this. + */ + public void commandAction(Command c, Displayable s) + { + if (c == cmdExit) + { + destroyApp(false); + notifyDestroyed(); + } + } +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/tsrc/fute/lcdui/Midp_General/src/Midp_General_04.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/tsrc/fute/lcdui/Midp_General/src/Midp_General_04.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,108 @@ +/* +* Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +/** + * import midp classes. + */ +import javax.microedition.midlet.*; +import javax.microedition.lcdui.*; + +/** + * This is the main class for the Midp_General_04 tests. + */ + +public class Midp_General_04 extends MIDlet implements CommandListener +{ + + private Alert alert; + private Display display; + private Gauge indicator; + private Image image; + private Command cmdScreen = new Command("Screen cmd", Command.SCREEN, 1); + private Command cmdExit = new Command("Exit", Command.EXIT, 1); + + private String alertText = "This is a modal alert with very long text blah blah blah blah blah blah " + + "blah blah blah blah blah blah blah blah blah blah blah blah blah blah " + + "blah blah blah blah blah blah blah blah blah blah blah blah blah blah " + + "blah blah blah blah blah blah blah blah blah blah blah blah blah blah " + + "blah blah blah blah blah blah blah blah blah blah blah blah blah blah " + + "blah blah blah blah blah blah blah blah blah blah blah blah blah blah " + + "blah blah blah blah blah blah blah blah blah blah blah blah blah blah"; + + public Midp_General_04() + { + alert = new Alert("Alert title", alertText, null, AlertType.INFO); + alert.addCommand(cmdExit); + alert.addCommand(cmdScreen); + alert.setCommandListener(this); + indicator = new Gauge(null, false, Gauge.INDEFINITE, Gauge.CONTINUOUS_RUNNING); + alert.setIndicator(indicator); + + try + { + image = Image.createImage("/small.png"); + } + catch (java.io.IOException e) + { + } + alert.setImage(image); + + display = Display.getDisplay(this); + } + + /** + * Signals the MIDlet to start and enter the Active state. + */ + protected void startApp() + { + display.setCurrent(alert); + } + + /** + * Signals the MIDlet to terminate and enter the Destroyed state. + * + */ + protected void destroyApp(boolean unconditional) + { + } + + /** + * Signals the MIDlet to stop and enter the Paused state. + */ + protected void pauseApp() + { + } + + /** + * This method handles command invocations. + * + *@param c This is the command responsible for the event. + *@param s Should be equal to this. + */ + public void commandAction(Command c, Displayable s) + { + if (c == cmdExit) + { + destroyApp(false); + notifyDestroyed(); + } + else if (c == cmdScreen) + { + alert.setTitle("Command run"); + } + } +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/tsrc/fute/lcdui/Midp_General/src/Midp_General_05.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/javauis/tsrc/fute/lcdui/Midp_General/src/Midp_General_05.java Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,89 @@ +/* +* Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + +/** + * import midp classes. + */ +import javax.microedition.midlet.*; +import javax.microedition.lcdui.*; + +/** + * This is the main class for the Midp_General_05 tests. + */ + +public class Midp_General_05 extends MIDlet implements CommandListener +{ + + private Canvas canvas; + private Display display; + private Command cmdExit = new Command("Exit", Command.EXIT, 1); + + public Midp_General_05() + { + display = Display.getDisplay(this); + canvas = new EmptyCanvas(); + canvas.addCommand(cmdExit); + canvas.setCommandListener(this); + } + + /** + * Signals the MIDlet to start and enter the Active state. + */ + protected void startApp() + { + display.setCurrent(canvas); + } + + /** + * Signals the MIDlet to terminate and enter the Destroyed state. + * + */ + protected void destroyApp(boolean unconditional) + { + } + + /** + * Signals the MIDlet to stop and enter the Paused state. + */ + protected void pauseApp() + { + } + + /** + * This method handles command invocations. + * + *@param c This is the command responsible for the event. + *@param s Should be equal to this. + */ + public void commandAction(Command c, Displayable s) + { + if (c == cmdExit) + { + destroyApp(false); + notifyDestroyed(); + } + } +} + +class EmptyCanvas extends Canvas +{ + protected void paint(Graphics g) + { + g.setColor(0, 0, 0); + g.drawString("Empty Canvas", getWidth()/2, getHeight()/2, Graphics.TOP | Graphics.HCENTER); + } +} diff -r dc7c549001d5 -r 85266cc22c7f javauis/tsrc/fute/lcdui/Midp_General_02/build.xml --- a/javauis/tsrc/fute/lcdui/Midp_General_02/build.xml Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff -r dc7c549001d5 -r 85266cc22c7f javauis/tsrc/fute/lcdui/Midp_General_02/src/Midp_General_02.java --- a/javauis/tsrc/fute/lcdui/Midp_General_02/src/Midp_General_02.java Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* -* Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -/** - * import midp classes. - */ -import javax.microedition.midlet.*; -import javax.microedition.lcdui.*; - -/** - * - */ - -public class Midp_General_02 extends MIDlet -{ - - TextBox tb; - Display display; - - public Midp_General_02() - { - tb = new TextBox("TextBox", null, 1000, TextField.ANY); - display = Display.getDisplay(this); - } - - /** - * Signals the MIDlet to start and enter the Active state. - */ - protected void startApp() - { - display.setCurrent(tb); - } - - /** - * Signals the MIDlet to terminate and enter the Destroyed state. - * - */ - protected void destroyApp(boolean unconditional) - { - } - - /** - * Signals the MIDlet to stop and enter the Paused state. - */ - protected void pauseApp() - { - } -} - diff -r dc7c549001d5 -r 85266cc22c7f javauis/tsrc/fute/lcdui/Midp_General_04/build.xml --- a/javauis/tsrc/fute/lcdui/Midp_General_04/build.xml Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff -r dc7c549001d5 -r 85266cc22c7f javauis/tsrc/fute/lcdui/Midp_General_04/src/Midp_General_04.java --- a/javauis/tsrc/fute/lcdui/Midp_General_04/src/Midp_General_04.java Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -/* -* Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -/** - * import midp classes. - */ -import javax.microedition.midlet.*; -import javax.microedition.lcdui.*; - -/** - * - */ - -public class Midp_General_04 extends MIDlet -{ - - private Alert alert; - private Display display; - - public Midp_General_04() - { - alert = new Alert("Alert title", "Alert Text", null, AlertType.INFO); - display = Display.getDisplay(this); - } - - /** - * Signals the MIDlet to start and enter the Active state. - */ - protected void startApp() - { - display.setCurrent(alert); - } - - /** - * Signals the MIDlet to terminate and enter the Destroyed state. - * - */ - protected void destroyApp(boolean unconditional) - { - } - - /** - * Signals the MIDlet to stop and enter the Paused state. - */ - protected void pauseApp() - { - } -} - diff -r dc7c549001d5 -r 85266cc22c7f javauis/tsrc/fute/lcdui/Midp_General_05/build.xml --- a/javauis/tsrc/fute/lcdui/Midp_General_05/build.xml Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff -r dc7c549001d5 -r 85266cc22c7f javauis/tsrc/fute/lcdui/Midp_General_05/src/Midp_General_05.java --- a/javauis/tsrc/fute/lcdui/Midp_General_05/src/Midp_General_05.java Thu May 27 12:49:31 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -/* -* Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: -* -*/ - -/** - * import midp classes. - */ -import javax.microedition.midlet.*; -import javax.microedition.lcdui.*; - -/** - * - */ - -public class Midp_General_05 extends MIDlet -{ - - private Canvas canvas; - private Display display; - - public Midp_General_05() - { - display = Display.getDisplay(this); - canvas = new EmptyCanvas(); - } - - /** - * Signals the MIDlet to start and enter the Active state. - */ - protected void startApp() - { - display.setCurrent(canvas); - } - - /** - * Signals the MIDlet to terminate and enter the Destroyed state. - * - */ - protected void destroyApp(boolean unconditional) - { - } - - /** - * Signals the MIDlet to stop and enter the Paused state. - */ - protected void pauseApp() - { - } -} - -class EmptyCanvas extends Canvas -{ - protected void paint(Graphics g) - { - g.setColor(0, 0, 0); - g.drawString("Empty Canvas", getWidth()/2, getHeight()/2, Graphics.TOP | Graphics.HCENTER); - } -} - diff -r dc7c549001d5 -r 85266cc22c7f rom/java_2_1.iby --- a/rom/java_2_1.iby Thu May 27 12:49:31 2010 +0300 +++ b/rom/java_2_1.iby Fri Jun 11 13:33:44 2010 +0300 @@ -354,6 +354,7 @@ data=ZRESOURCE\java\midpOdcList JAVA_RES_IMG\midpodclist data=ZRESOURCE\java\installerOdcList JAVA_RES_IMG\installerodclist data=ZRESOURCE\java\tckRunnerOdcList JAVA_RES_IMG\tckrunnerodclist +data=ZRESOURCE\java\javacontrolpanelodclist JAVA_RES_IMG\javacontrolpanelodclist // trust roots list data=ZRESOURCE\java\security\trustroots\midprootslist JAVA_RES_IMG\security\trustroots\midprootslist diff -r dc7c549001d5 -r 85266cc22c7f rom/java_3_1.iby --- a/rom/java_3_1.iby Thu May 27 12:49:31 2010 +0300 +++ b/rom/java_3_1.iby Fri Jun 11 13:33:44 2010 +0300 @@ -36,11 +36,9 @@ // stub sis data=ZSYSTEM\install\java.sis System\Install\java.sis -#ifdef RD_JAVA_APPLICATION_SETTINGS_QT // Application settings -//file=ABI_DIR\BUILD_DIR\javaapplicationsettingsview.dll SHARED_LIB_DIR\javaapplicationsettingsview.dll -//data=DATAZ_\resource\qt\plugins\appsettings\javaapplicationsettingsview.qtplugin resource\qt\plugins\appsettings\javaapplicationsettingsview.qtplugin -#endif +file=ABI_DIR\BUILD_DIR\javaapplicationsettingsview.dll SHARED_LIB_DIR\javaapplicationsettingsview.dll +data=DATAZ_\resource\qt\plugins\appsettings\javaapplicationsettingsview.qtplugin resource\qt\plugins\appsettings\javaapplicationsettingsview.qtplugin // Captain file=ABI_DIR\BUILD_DIR\javacaptain_ext_btdeviceclassmanager.dll SHARED_LIB_DIR\javacaptain_ext_btdeviceclassmanager.dll @@ -61,8 +59,6 @@ file=ABI_DIR\BUILD_DIR\javasizehelperserver.dll SHARED_LIB_DIR\javasizehelperserver.dll // Installer -ECOM_PLUGIN(ifeui.dll,ifeui.rsc) -data=ZRESOURCE\plugins\ifeui.rsc ECOM_RESOURCE_DIR\ifeui.rsc data=ZPRIVATE\10003a3f\apps\javainstaller_reg.rsc \private\10003a3f\import\apps\javainstaller_reg.rsc data=ZRESOURCE\apps\javainstaller_loc.rsc APP_RESOURCE_DIR\javainstaller_loc.rsc data=ZRESOURCE\apps\javainstaller_icon.mif APP_BITMAP_DIR\javainstaller_icon.mif @@ -117,6 +113,8 @@ // eSWT file=ABI_DIR\BUILD_DIR\eswtqt.dll SHARED_LIB_DIR\eswtqt.dll data=JAVA_VM_RES_BLD\eswtqt.odc JAVA_VM_RES_IMG\eswtqt.odc +file=ABI_DIR\BUILD_DIR\eswtqtwebkit.dll SHARED_LIB_DIR\eswtqtwebkit.dll +data=JAVA_VM_RES_BLD\eswtqtwebkit.odc JAVA_VM_RES_IMG\eswtqtwebkit.odc // LCDUI file=ABI_DIR\BUILD_DIR\openlcdui.dll SHARED_LIB_DIR\openlcdui.dll @@ -146,22 +144,21 @@ data=JAVA_VM_RES_BLD\javasoftnotification.odc JAVA_VM_RES_IMG\javasoftnotification.odc */ -// 2G API +// M2G API /*file=ABI_DIR\BUILD_DIR\javam2g.dll SHARED_LIB_DIR\javam2g.dll data=JAVA_VM_RES_BLD\javam2g.odc JAVA_VM_RES_IMG\javam2g.odc */ -// 3G API -/*file=ABI_DIR\BUILD_DIR\javam3g.dll SHARED_LIB_DIR\javam3g.dll +// M3G API +file=ABI_DIR\BUILD_DIR\javam3g.dll SHARED_LIB_DIR\javam3g.dll data=JAVA_VM_RES_BLD\javam3g.odc JAVA_VM_RES_IMG\javam3g.odc -*/ + // Nokia UI API file=ABI_DIR\BUILD_DIR\javanokiaui.dll SHARED_LIB_DIR\javanokiaui.dll data=JAVA_VM_RES_BLD\javanokiaui.odc JAVA_VM_RES_IMG\javanokiaui.odc // Nokia Sound API -/*file=ABI_DIR\BUILD_DIR\javanokiasound.dll SHARED_LIB_DIR\javanokiasound.dll +file=ABI_DIR\BUILD_DIR\javanokiasound.dll SHARED_LIB_DIR\javanokiasound.dll data=JAVA_VM_RES_BLD\javanokiasound.odc JAVA_VM_RES_IMG\javanokiasound.odc -*/ // Remote Connection Observer /*file=ABI_DIR\BUILD_DIR\javaremconobserver.dll SHARED_LIB_DIR\javaremconobserver.dll @@ -356,6 +353,7 @@ data=ZRESOURCE\java\midpOdcList JAVA_RES_IMG\midpodclist data=ZRESOURCE\java\installerOdcList JAVA_RES_IMG\installerodclist data=ZRESOURCE\java\tckRunnerOdcList JAVA_RES_IMG\tckrunnerodclist +data=ZRESOURCE\java\javacontrolpanelodclist JAVA_RES_IMG\javacontrolpanelodclist // trust roots list data=ZRESOURCE\java\security\trustroots\midprootslist JAVA_RES_IMG\security\trustroots\midprootslist diff -r dc7c549001d5 -r 85266cc22c7f rom/javacontrolpanelodclist --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rom/javacontrolpanelodclist Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,7 @@ +javautils.odc +javacomms.odc +javalegacyutils.odc +eswt.odc +eswtdirectcontent.odc +resources.jar +javacontrolpanel.odc diff -r dc7c549001d5 -r 85266cc22c7f rom/javacontrolpanelodclist30 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rom/javacontrolpanelodclist30 Fri Jun 11 13:33:44 2010 +0300 @@ -0,0 +1,5 @@ +javautils.odc +javacomms.odc +eswtqt.odc +resources.jar +javacontrolpanel.odc diff -r dc7c549001d5 -r 85266cc22c7f rom/javatest.iby --- a/rom/javatest.iby Thu May 27 12:49:31 2010 +0300 +++ b/rom/javatest.iby Fri Jun 11 13:33:44 2010 +0300 @@ -46,9 +46,10 @@ data=JAVA_CERT_BLD\test_trustedthirdparty.der JAVA_CERT_IMG\test_trustedthirdparty.der data=JAVA_CERT_BLD\test_trustedthirdparty.metadata JAVA_CERT_IMG\test_trustedthirdparty.metadata -// JavaCap App test utility -file=ABI_DIR\BUILD_DIR\JavaCap.exe PROGRAMS_DIR\JavaCap.exe -data=ZPRIVATE\10003a3f\apps\JavaCap_reg.rsc \private\10003a3f\import\apps\JavaCap_reg.rsc -data=\epoc32\data\z\resource\apps\JavaCap.rsc \resource\apps\JavaCap.rsc +// Java Control Panel test utility +file=ABI_DIR\BUILD_DIR\javacontrolpanel.exe PROGRAMS_DIR\javacontrolpanel.exe +file=ABI_DIR\BUILD_DIR\javacontrolpanel.dll SHARED_LIB_DIR\javacontrolpanel.dll +data=JAVA_VM_ODC_BLD\javacontrolpanel.odc JAVA_VM_ODC_IMG\javacontrolpanel.odc +data=ZPRIVATE\10003a3f\apps\javacontrolpanel_reg.rsc \private\10003a3f\import\apps\javacontrolpanel_reg.rsc #endif diff -r dc7c549001d5 -r 85266cc22c7f rom/midpodclist30 --- a/rom/midpodclist30 Thu May 27 12:49:31 2010 +0300 +++ b/rom/midpodclist30 Fri Jun 11 13:33:44 2010 +0300 @@ -1,4 +1,5 @@ eswtqt.odc +javaamms.odc javabluecove.odc javabluetooth.odc javabluetoothcommons.odc @@ -17,6 +18,7 @@ javam3g.odc javamidpruntime.odc javamobinfo.odc +javamobilemedia.odc javanokiasound.odc javapim.odc javapushregistry.odc