javauis/eswt_qt/org.eclipse.swt/Eclipse SWT/qt/org/eclipse/ercp/swt/mobile/MobileDevice.java
changeset 50 023eef975703
parent 35 85266cc22c7f
equal deleted inserted replaced
49:35baca0e7a2e 50:023eef975703
    42  * @see Input
    42  * @see Input
    43  * @see MobileDeviceListener
    43  * @see MobileDeviceListener
    44  */
    44  */
    45 public class MobileDevice {
    45 public class MobileDevice {
    46 
    46 
    47     private static int 		handleMobileDevice;
    47     private static int  handleMobileDevice;
    48     private Vector		mobileDeviceListeners;
    48     private Vector      mobileDeviceListeners;
    49     private Screen[]	screens;
    49     private Screen[]    screens;
    50     private Input[]		inputs;
    50     private Input[]     inputs;
    51     private int			alertLevel;
    51     private int         alertLevel;
    52     private boolean		isOpen;
    52     private boolean     isOpen;
    53     private static int desktopWidgetHandle;
    53     private static int  desktopWidgetHandle;
    54     static MobileDevice currentMobileDevice;
    54     static MobileDevice currentMobileDevice;
    55     private int activeScreenId;
    55     private int         activeScreenId;
    56     
    56     
    57     
    57     
    58 
    58 
    59     
    59     
    60     /** 
    60     /** 
    61      * feature which is permanently attached to the mobile device and always available
    61      * feature which is permanently attached to the mobile device and always available
    62      */	
    62      */    
    63     public static final int LOCAL = 0;
    63     public static final int LOCAL = 0;
    64 
    64 
    65 	/**
    65     /**
    66 	 * local feature which is only available when mobile device is opened
    66      * local feature which is only available when mobile device is opened
    67 	 */
    67      */
    68 	public static final int INTERNAL = 1;
    68     public static final int INTERNAL = 1;
    69 
    69 
    70 	/**
    70     /**
    71 	 * local feature which is only available when mobile device is closed
    71      * local feature which is only available when mobile device is closed
    72 	 */
    72      */
    73 	public static final int EXTERNAL = 2;
    73     public static final int EXTERNAL = 2;
    74 	
    74     
    75 	/**
    75     /**
    76 	 * feature which is not part of the mobile device unless connected via wire or wireless signal
    76      * feature which is not part of the mobile device unless connected via wire or wireless signal
    77 	 */
    77      */
    78 	public static final int REMOTE = 3;
    78     public static final int REMOTE = 3;
    79 	
    79     
    80 	/**
    80     /**
    81 	 * alert level indicating simple notification (ex. e-mail arrival)
    81      * alert level indicating simple notification (ex. e-mail arrival)
    82 	 */
    82      */
    83 	public static final int ALERT_LOW_IMPORTANCE = 1;
    83     public static final int ALERT_LOW_IMPORTANCE = 1;
    84 	
    84     
    85 	/**
    85     /**
    86 	 * alert level indicating user attention desired (ex. instant message arrival)
    86      * alert level indicating user attention desired (ex. instant message arrival)
    87 	 */
    87      */
    88 	public static final int ALERT_HIGH_IMPORTANCE = 2;
    88     public static final int ALERT_HIGH_IMPORTANCE = 2;
    89 	
    89     
    90 	/**
    90     /**
    91 	 * alert level indicating immediate attention is required (ex. battery level at 1%)
    91      * alert level indicating immediate attention is required (ex. battery level at 1%)
    92 	 */
    92      */
    93 	public static final int ALERT_CRITICAL = 3;
    93     public static final int ALERT_CRITICAL = 3;
    94    /**
    94    /**
    95     * virtual keyboard status indicating normal show and hide operation
    95     * virtual keyboard status indicating normal show and hide operation
    96     */
    96     */
    97 	public static final int VK_NORMAL = 1;
    97     public static final int VK_NORMAL = 1;
    98 
    98 
    99 	/**
    99     /**
   100 	 * virtual keyboard status indicating keyboard is always visible
   100      * virtual keyboard status indicating keyboard is always visible
   101 	 */
   101      */
   102 	public static final int VK_ALWAYS_ON = 2;
   102     public static final int VK_ALWAYS_ON = 2;
   103 
   103 
   104 	/**
   104     /**
   105 	 * virtual keyboard status indicating keyboard is always hidden
   105      * virtual keyboard status indicating keyboard is always hidden
   106 	 */
   106      */
   107 	public static final int VK_ALWAYS_OFF = 3;	  
   107     public static final int VK_ALWAYS_OFF = 3;      
   108 	
   108     
   109 	/**
   109     /**
   110 	 * Constructs a new instance of this class. Non-public to prevent
   110      * Constructs a new instance of this class. Non-public to prevent
   111 	 * instantiation outside this package.
   111      * instantiation outside this package.
   112 	 * 
   112      * 
   113 	 */
   113      */
   114 	MobileDevice () {
   114     MobileDevice () {
   115 	   
   115        
   116 	    (getDisplay()).syncExec(new Runnable() {
   116         (getDisplay()).syncExec(new Runnable() {
   117 			public void run() {
   117             public void run() {
   118 				handleMobileDevice = Internal_PackageSupport.initializeMobileDevice(
   118                 handleMobileDevice = Internal_PackageSupport.initializeMobileDevice(
   119 						Internal_PackageSupport.getDisplayInstance());
   119                         Internal_PackageSupport.getDisplayInstance());
   120 				OS.MobileDevice_createFlipWatch(handleMobileDevice);
   120                 if (handleMobileDevice == 0) {
   121 			}
   121                     SWT.error(SWT.ERROR_NO_HANDLES);
   122 		}); 
   122                 }
   123 	    mobileDeviceListeners = new Vector();
   123                 OS.MobileDevice_createFlipWatch(handleMobileDevice);
   124 	    isOpen = true;
   124             }
   125 	}
   125         }); 
   126 	
   126         mobileDeviceListeners = new Vector();
   127 	private static Display getDisplay(){
   127         isOpen = true;
   128 		Display display = Internal_PackageSupport.getDisplayInstance();
   128     }
   129 		
   129     
   130 		// Following if-statement (getting default display) should be removed
   130     private static Display getDisplay(){
   131 		// if agreed that MobileDevice shouldn't create the display.
   131         Display display = Internal_PackageSupport.getDisplayInstance();
   132 		if(display==null){
   132         
   133 			display = Display.getDefault();
   133         // Following if-statement (getting default display) should be removed
   134 		}
   134         // if agreed that MobileDevice shouldn't create the display.
   135 		
   135         if(display==null){
   136 		if(display == null || display.isDisposed()){
   136             display = Display.getDefault();
   137 	    	SWT.error(SWT.ERROR_DEVICE_DISPOSED);
   137         }
   138 	    }
   138         
   139 		return display;
   139         if(display == null || display.isDisposed()){
   140 	}
   140             SWT.error(SWT.ERROR_DEVICE_DISPOSED);
   141 	
   141         }
   142 	private void sendMobileDeviceChangedEvent(int eventType) {
   142         return display;
   143 		// MobileDevice changed event for open and closed
   143     }
   144 		int count = mobileDeviceListeners.size();
   144     
   145 		for (int i = 0; i <count; ++i) {
   145     private void sendMobileDeviceChangedEvent(int eventType) {
   146 			MobileDeviceEvent event = new MobileDeviceEvent(this);
   146         // MobileDevice changed event for open and closed
   147 			event.type = eventType;
   147         int count = mobileDeviceListeners.size();
   148 			MobileDeviceListener listener = (MobileDeviceListener) mobileDeviceListeners.elementAt(i);
   148         for (int i = 0; i <count; ++i) {
   149 			listener.deviceChanged(event);
   149             MobileDeviceEvent event = new MobileDeviceEvent(this);
   150 		}
   150             event.type = eventType;
   151 	}
   151             MobileDeviceListener listener = (MobileDeviceListener) mobileDeviceListeners.elementAt(i);
   152 	
   152             listener.deviceChanged(event);
   153 	void qt_swt_event_mobiledevice_changed(boolean aStatus) {
   153         }
   154 		// update MobileDevice status to opened/closed
   154     }
   155 		isOpen = aStatus;
   155     
   156 		
   156     void qt_swt_event_mobiledevice_changed(boolean aStatus) {
   157 		if(isOpen){
   157         // update MobileDevice status to opened/closed
   158 			sendMobileDeviceChangedEvent(MobileDeviceEvent.OPENED);
   158         isOpen = aStatus;
   159 		}else{
   159         
   160 			sendMobileDeviceChangedEvent(MobileDeviceEvent.CLOSED);
   160         if(isOpen){
   161 		}
   161             sendMobileDeviceChangedEvent(MobileDeviceEvent.OPENED);
   162 	}
   162         }else{
   163 	
   163             sendMobileDeviceChangedEvent(MobileDeviceEvent.CLOSED);
   164 	void qt_swt_event_mobiledevice_screen_activate(boolean aStatus) {
   164         }
   165 		
   165     }
   166 		if(screens.length > 0 && activeScreenId<screens.length){
   166     
   167 			if(aStatus){
   167     void qt_swt_event_mobiledevice_screen_activate(boolean aStatus) {
   168 				// update the active screen
   168         
   169 				activeScreenId = OS.getScreenDeviceNumber();
   169         if(screens.length > 0 && activeScreenId<screens.length){
   170 				//forward to screen activated event to new active screen
   170             if(aStatus){
   171 				screens[activeScreenId].internal_sendScreenEventActivated();
   171                 // update the active screen
   172 			}else {
   172                 activeScreenId = OS.getScreenDeviceNumber();
   173 				//forward to screen deactivated event to old active screen
   173                 //forward to screen activated event to new active screen
   174 				screens[activeScreenId].internal_sendScreenEventDeactivated();
   174                 screens[activeScreenId].internal_sendScreenEventActivated();
   175 			}
   175             }else {
   176 		}
   176                 //forward to screen deactivated event to old active screen
   177 	}
   177                 screens[activeScreenId].internal_sendScreenEventDeactivated();
   178 	
   178             }
   179 	void qt_swt_event_mobiledevice_orientationchanged() {
   179         }
   180 		activeScreenId = OS.getScreenDeviceNumber();
   180     }
   181 		if(activeScreenId<screens.length){
   181     
   182 			// forward to orientation change event to active screen
   182     void qt_swt_event_mobiledevice_orientationchanged() {
   183 			screens[activeScreenId].internal_sendOrientationScreenChanged();
   183         activeScreenId = OS.getScreenDeviceNumber();
   184 		}
   184         if(activeScreenId<screens.length){
   185 	}
   185             // forward to orientation change event to active screen
   186 	
   186             screens[activeScreenId].internal_sendOrientationScreenChanged();
   187 	private void sendMobileDeviceScreenChangedEvent(int eventType, Screen screen) {
   187         }
   188 		int count = mobileDeviceListeners.size();
   188     }
   189 		for (int i = 0; i <count; ++i) {
   189     
   190 			MobileDeviceEvent event = new MobileDeviceEvent(this);
   190     private void sendMobileDeviceScreenChangedEvent(int eventType, Screen screen) {
   191 			event.type = eventType;
   191         int count = mobileDeviceListeners.size();
   192 			event.data = screen;
   192         for (int i = 0; i <count; ++i) {
   193 			event.feature = screen;
   193             MobileDeviceEvent event = new MobileDeviceEvent(this);
   194 			MobileDeviceListener listener = (MobileDeviceListener) mobileDeviceListeners.elementAt(i);
   194             event.type = eventType;
   195 			listener.screenChanged(event);
   195             event.data = screen;
   196 		}
   196             event.feature = screen;
   197 	}
   197             MobileDeviceListener listener = (MobileDeviceListener) mobileDeviceListeners.elementAt(i);
   198 	
   198             listener.screenChanged(event);
   199 	void qt_signal_screen_changed(int aCount) {
   199         }
   200 		int type = 0;
   200     }
   201 		Screen screen = null;
   201     
   202 		Screen []newScreens = new Screen[aCount];
   202     void qt_signal_screen_changed(int aCount) {
   203 		
   203         int type = 0;
   204 		// if getScreen is not called and if still want 
   204         Screen screen = null;
   205 		// screen changed event in the MobileDevice
   205         Screen []newScreens = new Screen[aCount];
   206 		if(screens.length==0){
   206         
   207 			getScreens();
   207         // if getScreen is not called and if still want 
   208 		}
   208         // screen changed event in the MobileDevice
   209 		
   209         if(screens.length==0){
   210 		if(screens.length > aCount){
   210             getScreens();
   211 			// screen removed
   211         }
   212 			int screenHandle = 0;
   212         
   213 			for(int j=0; j<screens.length; j++) {
   213         if(screens.length > aCount){
   214 				// found removed screen
   214             // screen removed
   215 				boolean found = false;
   215             int screenHandle = 0;
   216 				for(int i=0; i<aCount; i++) {     
   216             for(int j=0; j<screens.length; j++) {
   217 					screenHandle = OS.QDesktopWidget_screen(desktopWidgetHandle, i);
   217                 // found removed screen
   218 					if(screens[j].screenHandle== screenHandle){
   218                 boolean found = false;
   219 						newScreens[i] = screens[j];
   219                 for(int i=0; i<aCount; i++) {     
   220 						newScreens[i].id = i;
   220                     screenHandle = OS.QDesktopWidget_screen(desktopWidgetHandle, i);
   221 						found = true;
   221                     if(screens[j].screenHandle== screenHandle){
   222 						break;
   222                         newScreens[i] = screens[j];
   223 		        	 }
   223                         newScreens[i].id = i;
   224 				}
   224                         found = true;
   225 		        if(!found){
   225                         break;
   226 		        	screen = screens[j];
   226                      }
   227 		        	screens[j].internal_dispose();
   227                 }
   228 		        } 
   228                 if(!found){
   229 		    }
   229                     screen = screens[j];
   230 			screens = new Screen[aCount];
   230                     screens[j].internal_dispose();
   231 			// remove detached screen from 'screens'
   231                 } 
   232 			System.arraycopy(newScreens, 0, screens, 0, aCount);
   232             }
   233 			type = MobileDeviceEvent.REMOVED;
   233             screens = new Screen[aCount];
   234 		} else if( screens.length < aCount){
   234             // remove detached screen from 'screens'
   235 			// screen attached
   235             System.arraycopy(newScreens, 0, screens, 0, aCount);
   236 			for(int i=0; i<aCount; i++) {   
   236             type = MobileDeviceEvent.REMOVED;
   237 				// found added screen
   237         } else if( screens.length < aCount){
   238 				int screenHandle = OS.QDesktopWidget_screen(desktopWidgetHandle, i);
   238             // screen attached
   239 				boolean found=false;
   239             for(int i=0; i<aCount; i++) {   
   240 				for(int j=0; j<screens.length; j++) {
   240                 // found added screen
   241 					if(screens[j].screenHandle== screenHandle){
   241                 int screenHandle = OS.QDesktopWidget_screen(desktopWidgetHandle, i);
   242 						newScreens[i] = screens[j];
   242                 boolean found=false;
   243 						newScreens[i].id = i;
   243                 for(int j=0; j<screens.length; j++) {
   244 						found = true;
   244                     if(screens[j].screenHandle== screenHandle){
   245 						break;
   245                         newScreens[i] = screens[j];
   246 					}
   246                         newScreens[i].id = i;
   247 				}
   247                         found = true;
   248 				if(!found){
   248                         break;
   249 					screen = screens[i];
   249                     }
   250 					newScreens[i] = new Screen(i, desktopWidgetHandle);
   250                 }
   251 				} 
   251                 if(!found){
   252 			}
   252                     screen = screens[i];
   253 			screens = new Screen[aCount];
   253                     newScreens[i] = new Screen(i, desktopWidgetHandle);
   254 			// add attached screen to 'screens'
   254                 } 
   255 			System.arraycopy(newScreens, 0, screens, 0, aCount);
   255             }
   256 			type = MobileDeviceEvent.ADDED;
   256             screens = new Screen[aCount];
   257 		}
   257             // add attached screen to 'screens'
   258 		sendMobileDeviceScreenChangedEvent(type, screen);
   258             System.arraycopy(newScreens, 0, screens, 0, aCount);
   259 		activeScreenId = OS.getScreenDeviceNumber();
   259             type = MobileDeviceEvent.ADDED;
   260 	}
   260         }
   261 	
   261         sendMobileDeviceScreenChangedEvent(type, screen);
   262 	private static void hookEvents() {
   262         activeScreenId = OS.getScreenDeviceNumber();
   263 	    int screenSignalProxy = OS.SignalHandler_new(desktopWidgetHandle, OS.QSIGNAL_QDESKTOPWIDGET_SCREENCOUNTCHANGED);
   263     }
   264 	    OS.QObject_connectOrThrow(desktopWidgetHandle, "screenCountChanged(int)", screenSignalProxy,
   264     
   265 	            "widgetSignal(int)", OS.QT_AUTOCONNECTION);
   265     private static void hookEvents() {
   266 	}
   266         int screenSignalProxy = OS.SignalHandler_new(desktopWidgetHandle, OS.QSIGNAL_QDESKTOPWIDGET_SCREENCOUNTCHANGED);
   267 
   267         OS.QObject_connectOrThrow(desktopWidgetHandle, "screenCountChanged(int)", screenSignalProxy,
   268 	/**
   268                 "widgetSignal(int)", OS.QT_AUTOCONNECTION);
   269 	 * Adds the listener to the collection of listeners who will be notified when a device 
   269     }
   270 	 * configuration change occurs, by calling one of the methods defined in the 
   270 
   271 	 * <code>MobileDeviceListener</code> interface. 
   271     /**
   272 	 * <p>
   272      * Adds the listener to the collection of listeners who will be notified when a device 
   273 	 * <code>screenChanged</code> is called when a monitor configuration changes.<br>
   273      * configuration change occurs, by calling one of the methods defined in the 
   274 	 * <code>inputChanged</code> is called when an input configuration changes.<br>
   274      * <code>MobileDeviceListener</code> interface. 
   275 	 * <code>deviceChanged</code> is called when the device is opened or closed.<br>
   275      * <p>
   276 	 *
   276      * <code>screenChanged</code> is called when a monitor configuration changes.<br>
   277 	 * @param listener instance called when device events occur
   277      * <code>inputChanged</code> is called when an input configuration changes.<br>
   278 	 *
   278      * <code>deviceChanged</code> is called when the device is opened or closed.<br>
   279 	 * @exception IllegalArgumentException <ul>
   279      *
   280 	 *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
   280      * @param listener instance called when device events occur
   281 	 * </ul>
   281      *
   282 	 * @exception SWTError <ul>
   282      * @exception IllegalArgumentException <ul>
   283 	 *    <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>
   283      *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
   284 	 * </ul>
   284      * </ul>
   285 	 *
   285      * @exception SWTError <ul>
   286 	 * @see #removeMobileDeviceListener
   286      *    <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>
   287 	 * @see MobileDeviceListener
   287      * </ul>
   288 	 */
   288      *
   289 	public void addMobileDeviceListener(MobileDeviceListener listener) {
   289      * @see #removeMobileDeviceListener
   290 	    if (listener == null) {
   290      * @see MobileDeviceListener
   291 			SWT.error (SWT.ERROR_NULL_ARGUMENT);
   291      */
   292 		}
   292     public void addMobileDeviceListener(MobileDeviceListener listener) {
   293 		mobileDeviceListeners.addElement(listener);
   293         if (listener == null) {
   294 	}
   294             SWT.error (SWT.ERROR_NULL_ARGUMENT);
   295 	
   295         }
   296 	
   296         mobileDeviceListeners.addElement(listener);
   297 	/**
   297     }
   298 	 * Alerts the user using device specific mechanisms such as sounds, flashing, or
   298     
   299 	 * vibration. <code>Level</code> must be one of ALERT_LOW_IMPORTANCE,
   299     
   300 	 * ALERT_HIGH_IMPORTANCE, or ALERT_CRITICAL. The method maps these levels to
   300     /**
   301 	 * device specific features that may also be dependent upon user configuration
   301      * Alerts the user using device specific mechanisms such as sounds, flashing, or
   302 	 * or current profile.
   302      * vibration. <code>Level</code> must be one of ALERT_LOW_IMPORTANCE,
   303 	 * 
   303      * ALERT_HIGH_IMPORTANCE, or ALERT_CRITICAL. The method maps these levels to
   304 	 * @param level
   304      * device specific features that may also be dependent upon user configuration
   305 	 *            constant describing the importance of the alert
   305      * or current profile.
   306 	 * 
   306      * 
   307 	 * @exception IllegalArgumentException
   307      * @param level
   308 	 *                <ul>
   308      *            constant describing the importance of the alert
   309 	 *                <li>ERROR_INVALID_ARGUMENT - if level is not one of the
   309      * 
   310 	 *                allowed class constants</li>
   310      * @exception IllegalArgumentException
   311 	 *                </ul>
   311      *                <ul>
   312 	 * 
   312      *                <li>ERROR_INVALID_ARGUMENT - if level is not one of the
   313 	 * @see #ALERT_LOW_IMPORTANCE
   313      *                allowed class constants</li>
   314 	 * @see #ALERT_HIGH_IMPORTANCE
   314      *                </ul>
   315 	 * @see #ALERT_CRITICAL
   315      * 
   316 	 */
   316      * @see #ALERT_LOW_IMPORTANCE
   317 	public void alert(int level) {
   317      * @see #ALERT_HIGH_IMPORTANCE
   318 	    if (	level != ALERT_LOW_IMPORTANCE &&
   318      * @see #ALERT_CRITICAL
   319 	            level != ALERT_HIGH_IMPORTANCE &&
   319      */
   320 	            level != ALERT_CRITICAL) {
   320     public void alert(int level) {
   321 	        SWT.error(SWT.ERROR_INVALID_ARGUMENT);
   321         if (    level != ALERT_LOW_IMPORTANCE &&
   322 	    }
   322                 level != ALERT_HIGH_IMPORTANCE &&
   323 	    alertLevel = level;
   323                 level != ALERT_CRITICAL) {
   324 		(getDisplay()).syncExec(new Runnable() {
   324             SWT.error(SWT.ERROR_INVALID_ARGUMENT);
   325 			public void run() {
   325         }
   326 				if(alertLevel == ALERT_LOW_IMPORTANCE){
   326         alertLevel = level;
   327 					OS.QApplication_beep();
   327         (getDisplay()).syncExec(new Runnable() {
   328 				}else if(alertLevel == ALERT_HIGH_IMPORTANCE){
   328             public void run() {
   329 					OS.MobileDevice_flashLights(handleMobileDevice, 3000);
   329                 if(alertLevel == ALERT_LOW_IMPORTANCE){
   330 					OS.MobileDevice_vibration(handleMobileDevice, 3000);
   330                     OS.QApplication_beep();
   331 				}else if(alertLevel == ALERT_CRITICAL){
   331                 }else if(alertLevel == ALERT_HIGH_IMPORTANCE){
   332 					OS.QApplication_beep();
   332                     OS.MobileDevice_flashLights(handleMobileDevice, 3000);
   333 					OS.MobileDevice_flashLights(handleMobileDevice, 3000);
   333                     OS.MobileDevice_vibration(handleMobileDevice, 3000);
   334 					OS.MobileDevice_vibration(handleMobileDevice, 3000);
   334                 }else if(alertLevel == ALERT_CRITICAL){
   335 				}
   335                     OS.QApplication_beep();
   336 			   
   336                     OS.MobileDevice_flashLights(handleMobileDevice, 3000);
   337 			}
   337                     OS.MobileDevice_vibration(handleMobileDevice, 3000);
   338 		}); 
   338                 }
   339 	}
   339                
   340 	
   340             }
   341 	
   341         }); 
   342 	/**
   342     }
   343 	 * Returns an array of Input objects describing the input features available to the device. 
   343     
   344 	 * The return value may be <code>null</code> if there are no input features available.
   344     
   345 	 * 
   345     /**
   346 	 * @exception SWTError <ul>
   346      * Returns an array of Input objects describing the input features available to the device. 
   347 	 *    <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because 
   347      * The return value may be <code>null</code> if there are no input features available.
   348 	 * 		of an operating system failure</li>
   348      * 
   349 	 * </ul> 
   349      * @exception SWTError <ul>
   350 	 *
   350      *    <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because 
   351 	 * @see Input
   351      *         of an operating system failure</li>
   352 	 */
   352      * </ul> 
   353 	public Input[] getInputs() {
   353      *
   354 		if(inputs == null) {
   354      * @see Input
   355 		    try {
   355      */
   356 			    (getDisplay()).syncExec(new Runnable() {
   356     public Input[] getInputs() {
   357 					public void run() {
   357         if(inputs == null) {
   358 						int mask = OS.getHwInputs();
   358             try {
   359 						int nbInputs = 0;
   359                 (getDisplay()).syncExec(new Runnable() {
   360 						
   360                     public void run() {
   361 						// finding out number of keyboards available
   361                         int mask = OS.getHwInputs();
   362 						if((mask & OS.SYMBIAN_KEYBOARD_FULL)!=0){
   362                         int nbInputs = 0;
   363 							nbInputs+=2;
   363                         
   364 						}
   364                         // finding out number of keyboards available
   365 						
   365                         if((mask & OS.SYMBIAN_KEYBOARD_FULL)!=0){
   366 						if((mask & OS.SYMBIAN_KEYBOARD_KEYPAD)!=0){
   366                             nbInputs+=2;
   367 							nbInputs+=2;
   367                         }
   368 						}
   368                         
   369 						// create java counter part of Inputs and
   369                         if((mask & OS.SYMBIAN_KEYBOARD_KEYPAD)!=0){
   370 						// add location and type
   370                             nbInputs+=2;
   371 					    inputs = new Input[nbInputs];
   371                         }
   372 					    int i=0;
   372                         // create java counter part of Inputs and
   373 					    int location;
   373                         // add location and type
   374 					    if((mask & OS.SYMBIAN_KEYBOARD_FULL)!=0){
   374                         inputs = new Input[nbInputs];
   375 					    	if((mask & OS.SYMBIAN_KEYBOARD_KEYPAD)!=0){
   375                         int i=0;
   376 								location = MobileDevice.INTERNAL;
   376                         int location;
   377 							} else {
   377                         if((mask & OS.SYMBIAN_KEYBOARD_FULL)!=0){
   378 								location = MobileDevice.LOCAL;
   378                             if((mask & OS.SYMBIAN_KEYBOARD_KEYPAD)!=0){
   379 							}
   379                                 location = MobileDevice.INTERNAL;
   380 					    	inputs[i] = new Input(i);
   380                             } else {
   381 					    	inputs[i].setLocation(location);
   381                                 location = MobileDevice.LOCAL;
   382 					    	inputs[i].setType(Input.SOFTKEYS);
   382                             }
   383 					    	i+=1;
   383                             inputs[i] = new Input(i);
   384 					    	inputs[i] = new Input(i);
   384                             inputs[i].setLocation(location);
   385 					    	inputs[i].setLocation(location);
   385                             inputs[i].setType(Input.SOFTKEYS);
   386 					    	inputs[i].setType(Input.FULL_KEYBOARD);
   386                             i+=1;
   387 					    	i+=1;
   387                             inputs[i] = new Input(i);
   388 						}
   388                             inputs[i].setLocation(location);
   389 					    
   389                             inputs[i].setType(Input.FULL_KEYBOARD);
   390 					    if((mask & OS.SYMBIAN_KEYBOARD_KEYPAD)!=0){
   390                             i+=1;
   391 					    	if((mask & OS.SYMBIAN_KEYBOARD_FULL)!=0){
   391                         }
   392 								location = MobileDevice.EXTERNAL;
   392                         
   393 							} else {
   393                         if((mask & OS.SYMBIAN_KEYBOARD_KEYPAD)!=0){
   394 								location = MobileDevice.LOCAL;
   394                             if((mask & OS.SYMBIAN_KEYBOARD_FULL)!=0){
   395 							}
   395                                 location = MobileDevice.EXTERNAL;
   396 					    	inputs[i] = new Input(i);
   396                             } else {
   397 					    	inputs[i].setLocation(location);
   397                                 location = MobileDevice.LOCAL;
   398 					    	inputs[i].setType(Input.SOFTKEYS);
   398                             }
   399 					    	i+=1;
   399                             inputs[i] = new Input(i);
   400 					    	inputs[i] = new Input(i);
   400                             inputs[i].setLocation(location);
   401 					    	inputs[i].setLocation(location);
   401                             inputs[i].setType(Input.SOFTKEYS);
   402 					    	inputs[i].setType(Input.KEYPAD);
   402                             i+=1;
   403 						}
   403                             inputs[i] = new Input(i);
   404 					}
   404                             inputs[i].setLocation(location);
   405 				});
   405                             inputs[i].setType(Input.KEYPAD);
   406 		    } catch(Throwable e) {
   406                         }
   407 		        SWT.error(SWT.ERROR_CANNOT_GET_SELECTION);	       
   407                     }
   408 		    }
   408                 });
   409 	    }
   409             } catch(Throwable e) {
   410 	    return inputs;
   410                 SWT.error(SWT.ERROR_CANNOT_GET_SELECTION);           
   411 	}
   411             }
   412 	
   412         }
   413 	
   413         return inputs;
   414 	/**
   414     }
   415 	 * Returns an array of Screen objects describing the display features available to the device. 
   415     
   416 	 * The return value may be <code>null</code> if there are no display screens available.
   416     
   417 	 * 
   417     /**
   418 	 * @exception SWTError <ul>
   418      * Returns an array of Screen objects describing the display features available to the device. 
   419 	 *    <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because 
   419      * The return value may be <code>null</code> if there are no display screens available.
   420 	 * 		of an operating system failure</li>
   420      * 
   421 	 * </ul> 
   421      * @exception SWTError <ul>
   422 	 *
   422      *    <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because 
   423 	 * @see Screen
   423      *         of an operating system failure</li>
   424 	 */
   424      * </ul> 
   425 	public Screen[] getScreens() {
   425      *
   426 		if(screens == null) {
   426      * @see Screen
   427 		    try {
   427      */
   428 			    (getDisplay()).syncExec(new Runnable() {
   428     public Screen[] getScreens() {
   429 					public void run() {
   429         if(screens == null) {
   430 					    int nbScreens = OS.QDesktopWidget_screenCount(desktopWidgetHandle);
   430             try {
   431 					    activeScreenId = OS.getScreenDeviceNumber();
   431                 (getDisplay()).syncExec(new Runnable() {
   432 					    screens = new Screen[nbScreens];
   432                     public void run() {
   433 					    for(int i=0; i<nbScreens; i++) {
   433                         int nbScreens = OS.QDesktopWidget_screenCount(desktopWidgetHandle);
   434 					        screens[i] = new Screen(i, desktopWidgetHandle);
   434                         activeScreenId = OS.getScreenDeviceNumber();
   435 					    }
   435                         screens = new Screen[nbScreens];
   436 					}
   436                         for(int i=0; i<nbScreens; i++) {
   437 				});
   437                             screens[i] = new Screen(i, desktopWidgetHandle);
   438 		    } catch(Throwable e) {
   438                         }
   439 		        SWT.error(SWT.ERROR_CANNOT_GET_SELECTION);	       
   439                     }
   440 		    }
   440                 });
   441 	    }
   441             } catch(Throwable e) {
   442 	    return screens;
   442                 SWT.error(SWT.ERROR_CANNOT_GET_SELECTION);           
   443 	}
   443             }
   444 	
   444         }
   445 	
   445         return screens;
   446 	/**
   446     }
   447 	 * Returns singleton instance of MobileDevice class.
   447     
   448 	 * 
   448     
   449 	 * @return singleton of MobileDevice class. Must not be Null.
   449     /**
   450 	 * 
   450      * Returns singleton instance of MobileDevice class.
   451 	 * @exception SWTError <ul>
   451      * 
   452 	 *    <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of 
   452      * @return singleton of MobileDevice class. Must not be Null.
   453 	 * 		an operating system failure</li>
   453      * 
   454 	 * </ul> 
   454      * @exception SWTError <ul>
   455 	 */ 
   455      *    <li>ERROR_CANNOT_GET_SELECTION - if the operation fails because of 
   456 	public static MobileDevice getMobileDevice() {
   456      *         an operating system failure</li>
   457 	    if(currentMobileDevice == null) {
   457      * </ul> 
   458 	        try {
   458      */ 
   459 		        currentMobileDevice = new MobileDevice(); 
   459     public static MobileDevice getMobileDevice() {
   460 		        Internal_PackageSupport.setMobileDevice(getDisplay(),currentMobileDevice);
   460         if(currentMobileDevice == null) {
   461 			    desktopWidgetHandle = OS.QApplication_desktop();
   461             try {
   462 			    hookEvents();
   462                 currentMobileDevice = new MobileDevice(); 
   463 	        } catch (Throwable e) {
   463                 Internal_PackageSupport.setMobileDevice(getDisplay(),currentMobileDevice);
   464 	            SWT.error(SWT.ERROR_CANNOT_GET_SELECTION);
   464                 desktopWidgetHandle = OS.QApplication_desktop();
   465 	        }
   465                 hookEvents();
   466 	    }
   466             } catch (Throwable e) {
   467 	    return currentMobileDevice;
   467                 SWT.error(SWT.ERROR_CANNOT_GET_SELECTION);
   468 	}
   468             }
   469 	 
   469         }
   470 	 
   470         return currentMobileDevice;
   471 	/**
   471     }
   472 	 * Returns whether device is opened. For devices that have no internal screens 
   472      
   473 	 * or input features, the method always returns <code>true</code>.
   473      
   474 	 */
   474     /**
   475 	public boolean isOpen() { 
   475      * Returns whether device is opened. For devices that have no internal screens 
   476 	    getDisplay();
   476      * or input features, the method always returns <code>true</code>.
   477 
   477      */
   478 	    return isOpen; 
   478     public boolean isOpen() { 
   479 	}
   479         getDisplay();
   480 
   480 
   481 	
   481         return isOpen; 
   482 	/**
   482     }
   483 	 * Call to dispose the Screen object.
   483 
   484 	 *
   484     
   485 	 */
   485     /**
   486 	void internal_dispose() {
   486      * Call to dispose the Screen object.
   487 		if (inputs != null) {
   487      *
   488 			for (int i = 0; i < inputs.length; i++) {
   488      */
   489 				if (inputs[i] != null) {
   489     void internal_dispose() {
   490 					inputs[i].internal_dispose();
   490         if (inputs != null) {
   491 				}
   491             for (int i = 0; i < inputs.length; i++) {
   492 			}
   492                 if (inputs[i] != null) {
   493 		}
   493                     inputs[i].internal_dispose();
   494 
   494                 }
   495 		if (screens != null) {
   495             }
   496 			for (int i = 0; i < screens.length; i++) {
   496         }
   497 				if (screens[i] != null) {
   497 
   498 					screens[i].internal_dispose();
   498         if (screens != null) {
   499 				}
   499             for (int i = 0; i < screens.length; i++) {
   500 			}
   500                 if (screens[i] != null) {
   501 		}
   501                     screens[i].internal_dispose();
   502 		// actual native counter part is deleted in display
   502                 }
   503 		currentMobileDevice = null;
   503             }
   504 		handleMobileDevice = 0;
   504         }
   505 		inputs = null;
   505         // actual native counter part is deleted in display
   506 		screens = null;
   506         currentMobileDevice = null;
   507 		desktopWidgetHandle = 0;
   507         handleMobileDevice = 0;
   508 	}
   508         inputs = null;
   509 	
   509         screens = null;
   510 	
   510         desktopWidgetHandle = 0;
   511 	/**
   511     }
   512 	 * Removes the listener from the collection of listeners who will be notified when a device 
   512     
   513 	 * configuration change occurs. 
   513     
   514 	 *
   514     /**
   515 	 * @param listener instance called when device events occur
   515      * Removes the listener from the collection of listeners who will be notified when a device 
   516 	 *
   516      * configuration change occurs. 
   517 	 * @exception IllegalArgumentException <ul>
   517      *
   518 	 *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
   518      * @param listener instance called when device events occur
   519 	 * </ul>
   519      *
   520 	 * @exception SWTError <ul>
   520      * @exception IllegalArgumentException <ul>
   521 	 *    <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because 
   521      *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
   522 	 * 		of an operating system failure</li>
   522      * </ul>
   523 	 * </ul>
   523      * @exception SWTError <ul>
   524 	 *
   524      *    <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because 
   525 	 * @see #addMobileDeviceListener
   525      *         of an operating system failure</li>
   526 	 * @see MobileDeviceListener
   526      * </ul>
   527 	 */
   527      *
   528 	public void removeMobileDeviceListener(MobileDeviceListener listener) {
   528      * @see #addMobileDeviceListener
   529 		if (listener == null) {
   529      * @see MobileDeviceListener
   530 			SWT.error (SWT.ERROR_NULL_ARGUMENT);
   530      */
   531 		}
   531     public void removeMobileDeviceListener(MobileDeviceListener listener) {
   532 
   532         if (listener == null) {
   533 		//remove listener
   533             SWT.error (SWT.ERROR_NULL_ARGUMENT);
   534 		//Remove method of Vector class never fails,
   534         }
   535 		//so ERROR_ITEM_NOT_REMOVED could never be thrown.
   535 
   536 		mobileDeviceListeners.removeElement(listener);
   536         //remove listener
   537 	}
   537         //Remove method of Vector class never fails,
   538 	
   538         //so ERROR_ITEM_NOT_REMOVED could never be thrown.
   539 	 /**
   539         mobileDeviceListeners.removeElement(listener);
   540 	  * Sets the status of the system virtual keyboard (if one is available).
   540     }
   541 	  * By default, or when status is set to VK_NORMAL, a system virtual keyboard
   541     
   542 	  * is displayed when a widget capable of text input gains focus and is
   542      /**
   543 	  * hidden when that widget looses focus. However, there are cases where 
   543       * Sets the status of the system virtual keyboard (if one is available).
   544 	  * an application may wish to continuously display the virtual keyboard
   544       * By default, or when status is set to VK_NORMAL, a system virtual keyboard
   545 	  * or always keep it hidden. Setting the status to VK_ALWAYS_ON or VK_ALWAYS_OFF
   545       * is displayed when a widget capable of text input gains focus and is
   546 	  * will accomplish this and the effect is immediate. Changing focus will
   546       * hidden when that widget looses focus. However, there are cases where 
   547 	  * then have no affect on the virtual keyboard. Note: By default, widgets which 
   547       * an application may wish to continuously display the virtual keyboard
   548 	  * normally accept input but are set to <i>read only</i> do not cause the 
   548       * or always keep it hidden. Setting the status to VK_ALWAYS_ON or VK_ALWAYS_OFF
   549 	  * the virtual keyboard to display.
   549       * will accomplish this and the effect is immediate. Changing focus will
   550 	  *
   550       * then have no affect on the virtual keyboard. Note: By default, widgets which 
   551 	  * @param status virtual keyboard mode. One of VK_NORMAL, VK_ALWAYS_ON, VK_ALWAYS_OFF
   551       * normally accept input but are set to <i>read only</i> do not cause the 
   552 	  * 
   552       * the virtual keyboard to display.
   553 	  * @exception IllegalArgumentException <ul>
   553       *
   554 	  *    <li>ERROR_INVALID_ARGUMENT - if the status parameter is not valid</li>
   554       * @param status virtual keyboard mode. One of VK_NORMAL, VK_ALWAYS_ON, VK_ALWAYS_OFF
   555 	  * </ul>
   555       * 
   556 	  *
   556       * @exception IllegalArgumentException <ul>
   557 	  * @see #VK_NORMAL
   557       *    <li>ERROR_INVALID_ARGUMENT - if the status parameter is not valid</li>
   558 	  * @see #VK_ALWAYS_ON
   558       * </ul>
   559 	  * @see #VK_ALWAYS_OFF
   559       *
   560 	  */
   560       * @see #VK_NORMAL
   561 	public void setVKStatus(int status){
   561       * @see #VK_ALWAYS_ON
   562 		
   562       * @see #VK_ALWAYS_OFF
   563 	}
   563       */
       
   564     public void setVKStatus(int status){
       
   565         
       
   566     }
   564 }
   567 }