/**
* @see ScriptableFunctionBase#execute(Object, Object[])
*/
public Object execute( Object thiz, Object[] args ) throws Exception {
DataInputStream dis = null;
InputConnection ic = null;
try {
BrowserFieldRequest bfr = new BrowserFieldRequest( args[ 0 ].toString() );
ic = ((BrowserFieldController)_weakReferenceBrwoserFieldController.get()).handleResourceRequest( bfr );
dis = ic.openDataInputStream();
ByteVector vc = new ByteVector();
for( int b = dis.read(); b != -1; b = dis.read() ) {
vc.addElement( (byte) b );
}
// An application could have multiple entry points and each entry point has its own icon.
// We need to update icons for all entry points to be the same one.
Bitmap image = Bitmap.createBitmapFromBytes( vc.getArray(), 0, vc.size(), 1 );
ApplicationDescriptor current = ApplicationDescriptor.currentApplicationDescriptor();
int moduleHandle = current.getModuleHandle();
ApplicationDescriptor[] descriptors = CodeModuleManager.getApplicationDescriptors( moduleHandle );
if( args.length == 1 || !( (Boolean) args[ 1 ] ).booleanValue() ) {
for( int i = 0; i < descriptors.length; i++ ) {
HomeScreen.updateIcon( image, descriptors[ i ] );
}
} else {
for( int i = 0; i < descriptors.length; i++ ) {
HomeScreen.setRolloverIcon( image, descriptors[ i ] );
}
}
} finally {
try {
if( dis != null ) {
dis.close();
}
if( ic != null ) {
ic.close();
}
} catch( IOException e ) {
}
}