1 /* |
1 /* |
2 * Copyright (c) 2003 - 2004 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2003 - 2004 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of the License "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 * |
8 * |
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 package com.symbian.tools.j2me.sei.emulator; |
18 package com.symbian.tools.j2me.sei.emulator; |
19 |
19 |
556 * @throws Exception |
556 * @throws Exception |
557 * if some error occured |
557 * if some error occured |
558 */ |
558 */ |
559 protected void assignSessionPorts() throws Exception { |
559 protected void assignSessionPorts() throws Exception { |
560 Debug.println(this, "+EmulatorLauncher.assignSessionPorts()"); |
560 Debug.println(this, "+EmulatorLauncher.assignSessionPorts()"); |
561 // find free verbose port |
561 |
562 int consolePort = iSession.getFreePort(); |
562 String[] comm = (String[])iSEICommand.getArguments(); |
563 iVMLaunchArguments.getVMArguments().setVMConsolePort(consolePort); |
563 for (int i = 0; i < comm.length; i++) { |
564 Debug.println(this, "console port: " + consolePort); |
564 System.out.println(comm[i]); |
|
565 } |
|
566 |
|
567 /* Pranav: |
|
568 * Console IP address & port were part of the IDE VM arguments. |
|
569 * Those were being used for console/Diagnostic output. Not required...code removed from here.. |
|
570 */ |
|
571 |
565 if (iMode == DEBUG_MODE) { |
572 if (iMode == DEBUG_MODE) { |
566 // Emulator in server mode: |
573 // Emulator in server mode: Phone VM connects to the port in command line |
567 // Phone VM connects to the port in command line |
574 // Emulator in client mode: Phone VM listens on the port given |
568 // Emulator in client mode: |
575 |
569 // Phone VM listens on the port given |
576 //Pranav: Write VM arguments for MIDlet Debug from the iSEICommand |
570 iVMLaunchArguments.getVMArguments().setVMDebugPort( |
577 String[] seiCommands = (String[])iSEICommand.getArguments(); |
571 iSEICommand.getVMRemotePort(), |
578 |
572 iSEICommand.isEmulatorServerMode()); |
579 String parmaDebug = ""; |
|
580 String paramJdwp = ""; |
|
581 for (int i = 0; i < seiCommands.length; i++) { |
|
582 System.out.println(seiCommands[i]); |
|
583 if (seiCommands[i].startsWith("-Xdebug")) parmaDebug = seiCommands[i]; |
|
584 else if (seiCommands[i].startsWith("-Xrunjdwp")) paramJdwp = seiCommands[i]; |
|
585 |
|
586 if(!parmaDebug.equals("") && !paramJdwp.equals("")){ |
|
587 break; |
|
588 } |
|
589 } |
|
590 iVMLaunchArguments.getVMArguments().setVMDebugPort(iSEICommand.getVMRemotePort(), parmaDebug.trim(), paramJdwp.trim()); |
|
591 |
573 Debug.println(this, "debug port: " + iSEICommand.getVMRemotePort()); |
592 Debug.println(this, "debug port: " + iSEICommand.getVMRemotePort()); |
574 } |
593 } |
575 } |
594 } |
576 |
595 |
577 // |
596 // |
630 File lib = new File(SDKRuntimeProperties.SDK_HOME, "lib"); |
649 File lib = new File(SDKRuntimeProperties.SDK_HOME, "lib"); |
631 if (!lib.isDirectory()) { |
650 if (!lib.isDirectory()) { |
632 lib = new File(new File(SDKRuntimeProperties.EPOC_HOME) |
651 lib = new File(new File(SDKRuntimeProperties.EPOC_HOME) |
633 .getParentFile().getParentFile(), "lib"); |
652 .getParentFile().getParentFile(), "lib"); |
634 } |
653 } |
635 /*if (lib.isDirectory()) { |
|
636 String[] jars = lib.list(new FilenameFilter() { |
|
637 public boolean accept(File dir, String name) { |
|
638 return (name.toLowerCase().endsWith(".jar") || name |
|
639 .toLowerCase().endsWith(".zip")); |
|
640 } |
|
641 }); |
|
642 if (jars != null && jars.length > 0) { |
|
643 for (int i = 0; i < jars.length; i++) { |
|
644 JarFile jarFile = new JarFile(lib.getAbsolutePath() |
|
645 + File.separatorChar + jars[i]); |
|
646 Manifest manifest = jarFile.getManifest(); |
|
647 if(manifest != null) |
|
648 { |
|
649 Attributes atr = manifest.getMainAttributes(); |
|
650 String apiName = atr.getValue("API"); |
|
651 String apiVersion = atr |
|
652 .getValue("API-Specification-Version"); |
|
653 if(!apiName.equalsIgnoreCase("CLDC") && !apiName.equalsIgnoreCase("MIDP")){ |
|
654 if(optionalApis.length()>0){ optionalApis.append(", ");} |
|
655 optionalApis.append(apiName + "-" + apiVersion); |
|
656 } |
|
657 } |
|
658 } |
|
659 |
|
660 // TODO |
|
661 // 1) Form an array of API names from jar manifests: |
|
662 // profile, configuration, optionalAPIs |
|
663 // 2) Form an array of API names from properties file |
|
664 // 3) Form resulting array of API names: |
|
665 // add an api to the array 1. from JAR array, |
|
666 // if absent - from properties array |
|
667 |
|
668 } |
|
669 }*/ |
|
670 |
654 |
671 if (lib.isDirectory()) { |
655 if (lib.isDirectory()) { |
672 String[] jars = lib.list(new FilenameFilter() { |
656 String[] jars = lib.list(new FilenameFilter() { |
673 public boolean accept(File dir, String name) { |
657 public boolean accept(File dir, String name) { |
674 return (name.toLowerCase().endsWith(".jar") || name.toLowerCase().endsWith(".zip")); |
658 return (name.toLowerCase().endsWith(".jar") || name.toLowerCase().endsWith(".zip")); |
698 } catch (Exception e) { |
682 } catch (Exception e) { |
699 // TODO: handle exception |
683 // TODO: handle exception |
700 } |
684 } |
701 } |
685 } |
702 |
686 |
703 // TODO |
|
704 // 1) Form an array of API names from jar manifests: |
|
705 // profile, configuration, optionalAPIs |
|
706 // 2) Form an array of API names from properties file |
|
707 // 3) Form resulting array of API names: |
|
708 // add an api to the array 1. from JAR array, |
|
709 // if absent - from properties array |
|
710 |
|
711 } |
687 } |
712 } |
688 } |
713 /*for (int i = 0; i < defaultOptionalApis.length; i++) { |
|
714 String defaultApiName = defaultOptionalApis[i] |
|
715 .substring(0, defaultOptionalApis[i].indexOf('-')); |
|
716 if (optionalApis.indexOf(defaultApiName) == -1) { |
|
717 optionalApis.append(", " + defaultOptionalApis[i]); |
|
718 } |
|
719 }*/ |
|
720 |
|
721 System.out.println("Profile: " + profile); |
689 System.out.println("Profile: " + profile); |
722 System.out.println("Configuration: " + configuration); |
690 System.out.println("Configuration: " + configuration); |
723 System.out.println("Optional: " + optionalApis); |
691 System.out.println("Optional: " + optionalApis); |
724 } |
692 } |
725 |
693 |
873 BufferedReader bReader = new BufferedReader(new InputStreamReader(dataIn)); |
841 BufferedReader bReader = new BufferedReader(new InputStreamReader(dataIn)); |
874 |
842 |
875 String epocLine = ""; |
843 String epocLine = ""; |
876 String resolutionFileName = ""; |
844 String resolutionFileName = ""; |
877 while ((epocLine = bReader.readLine()) != null) { |
845 while ((epocLine = bReader.readLine()) != null) { |
|
846 if (!epocLine.equals("")){ |
878 if (epocLine.substring(0, epocLine.indexOf(" ")).trim().equals( |
847 if (epocLine.substring(0, epocLine.indexOf(" ")).trim().equals( |
879 "configuration")) { |
848 "configuration")) { |
880 |
849 |
881 //Get resolution file name |
850 //Get resolution file name |
882 resolutionFileName = epocLine.substring(epocLine.indexOf(" ")+1); |
851 resolutionFileName = epocLine.substring(epocLine.indexOf(" ")+1); |