FileDocCategorySizeDatePackage
AppInfo.javaAPI DocphoneME MR2 API (J2ME)11487Wed May 02 18:00:06 BST 2007com.sun.midp.appmanager

AppInfo

public class AppInfo extends Form
The Graphical MIDlet suite information display.

The application property "arg0" will have the ID of the suite to display.

Fields Summary
Image
suiteIcon
Cache of the suite icon.
Image
singleSuiteIcon
Cache of the single suite icon.
Image
icon
Icon to display for the suite
MIDletSuiteStorage
midletSuiteStorage
MIDlet Suite storage object.
ApplicationManager
manager
Switch to the manager when "Back" is activated
InstallInfo
installInfo
Installation information of the suite.
int
numberOfMidlets
Number of MIDlets in the suite.
String
displayName
Display name of the suite.
Constructors Summary
public AppInfo(int suiteId)
Create and initialize a new Application Info MIDlet.

param
suiteId - the id of the suite for which the AppInfo should be displayed
exception
Exception if error occurs


        super(null);

        midletSuiteStorage = MIDletSuiteStorage.getMIDletSuiteStorage();

        displaySuiteInfo(suiteId);
    
Methods Summary
private voidappendMIDletsToForm(MIDletSuiteImpl midletSuite)
Appends a names of all the MIDlets in a suite to a Form, one per line.

param
midletSuite information of a suite of MIDlets

        int numberOfMidlets;
        MIDletInfo midletInfo;
        StringItem item;

        numberOfMidlets = midletSuite.getNumberOfMIDlets();
        for (int i = 1; i <= numberOfMidlets; i++) {
            midletInfo = new MIDletInfo(
                             midletSuite.getProperty("MIDlet-" + i));

            item = new StringItem(null, midletInfo.name);
            item.setLayout(Item.LAYOUT_NEWLINE_AFTER | Item.LAYOUT_2);
            append(item);
        }
    
private voiddisplaySuiteInfo(int suiteId)
Display the information for a suite.

param
suiteId ID for suite to display
exception
Exception if error occurs

        StringBuffer label = new StringBuffer(40);
        StringBuffer value = new StringBuffer(40);
        Item item;
        String[] authPath;
        String temp;
        MIDletSuiteImpl midletSuite = null;

        try {
            midletSuite = midletSuiteStorage.getMIDletSuite(suiteId, false);

            initMidletSuiteInfo(midletSuite);

            label.append(Resource.getString(ResourceConstants.INFO));
            label.append(": ");
            label.append(displayName);
            setTitle(label.toString());

            append(
                new ImageItem(null, icon, ImageItem.LAYOUT_NEWLINE_BEFORE +
                              ImageItem.LAYOUT_CENTER +
                              ImageItem.LAYOUT_NEWLINE_AFTER, null));

            if (!midletSuite.isEnabled()) {
                item = new StringItem(null, Resource.getString(
                           ResourceConstants.AMS_SUITE_DISABLED_NOTE));
                item.setLayout(Item.LAYOUT_NEWLINE_AFTER | Item.LAYOUT_2);
                append(item);
            }

            // round up the size to a Kilobyte
            label.setLength(0);
            label.append(Resource.getString(ResourceConstants.AMS_SIZE));
            label.append(": ");
            value.append(
                Integer.toString((MIDletSuiteStorage.getMIDletSuiteStorage().
                    getStorageUsed(midletSuite.getID()) +
                    1023) / 1024));
            value.append(" K");
            item = new StringItem(label.toString(), value.toString());
            item.setLayout(Item.LAYOUT_NEWLINE_AFTER | Item.LAYOUT_2);
            append(item);

            label.setLength(0);
            label.append(Resource.getString(ResourceConstants.AMS_VERSION));
            label.append(": ");
            item = new StringItem(label.toString(),
                midletSuite.getProperty(MIDletSuite.VERSION_PROP));
            item.setLayout(Item.LAYOUT_NEWLINE_AFTER | Item.LAYOUT_2);
            append(item);

            label.setLength(0);

            if (midletSuite.isTrusted()) {
                temp = Resource.getString
                          (ResourceConstants.AMS_MGR_AUTH_VENDOR);
            } else {
                temp = Resource.getString
                          (ResourceConstants.AMS_MGR_VENDOR);
            }

            label.append(temp);
            label.append(": ");
            item = new StringItem(label.toString(),
                midletSuite.getProperty(MIDletSuite.VENDOR_PROP));
            item.setLayout(Item.LAYOUT_NEWLINE_AFTER | Item.LAYOUT_2);
            append(item);

            temp = midletSuite.getProperty(MIDletSuite.DESC_PROP);
            if (temp != null) {
                label.setLength(0);
                label.append(Resource.getString
                             (ResourceConstants.AMS_DESCRIPTION));
                label.append(": ");
                item = new StringItem(label.toString(), temp);
                item.setLayout(Item.LAYOUT_NEWLINE_AFTER | Item.LAYOUT_2);
                append(item);
            }

            if (numberOfMidlets != 1) {
                label.setLength(0);
                label.append(Resource.getString
                             (ResourceConstants.AMS_CONTENTS));
                label.append(":");
                item = new StringItem(label.toString(), "");
                item.setLayout(Item.LAYOUT_NEWLINE_AFTER | Item.LAYOUT_2);
                append(item);
                appendMIDletsToForm(midletSuite);
            }

            label.setLength(0);
            label.append(Resource.getString(ResourceConstants.AMS_WEBSITE));
            label.append(": ");
            item = new StringItem(label.toString(),
                       installInfo.getDownloadUrl());
            item.setLayout(Item.LAYOUT_NEWLINE_AFTER | Item.LAYOUT_2);
            append(item);


            label.setLength(0);
            label.append(Resource.getString(ResourceConstants.AMS_ADVANCED));
            label.append(": ");
            item = new StringItem(label.toString(), "");
            item.setLayout(Item.LAYOUT_NEWLINE_AFTER | Item.LAYOUT_2);
            append(item);

            if (midletSuite.isTrusted()) {
                append(new ImageItem(null, TrustedMIDletIcon.getIcon(),
                    ImageItem.LAYOUT_DEFAULT, null));
                temp = Resource.getString
                          (ResourceConstants.AMS_MGR_TRUSTED);
            } else {
                temp = Resource.getString
                          (ResourceConstants.AMS_MGR_UNTRUSTED);
            }

            item = new StringItem(null, temp);
            item.setLayout(Item.LAYOUT_NEWLINE_AFTER | Item.LAYOUT_2);
            append(item);

            // Append classes verification state to advanced section
            if (Constants.VERIFY_ONCE && midletSuite.isVerified()) {
                item = new StringItem(null, Resource.getString(
                    ResourceConstants.AMS_VERIFIED_CLASSES));
                item.setLayout(Item.LAYOUT_NEWLINE_AFTER | Item.LAYOUT_2);
                append(item);

            }

            authPath = installInfo.getAuthPath();
            if (authPath != null) {
                label.setLength(0);
                label.append(Resource.getString
                             (ResourceConstants.AMS_AUTHORIZED_BY));
                label.append(": ");
                temp = label.toString();
                for (int i = 0; i < authPath.length; i++) {
                    item = new StringItem(temp, authPath[i]);
                    item.setLayout(Item.LAYOUT_NEWLINE_AFTER | Item.LAYOUT_2);
                    append(item);
                    temp = null;
                }
            }

            temp = PushRegistryInternal.listConnections(
                       midletSuite.getID(), false);
            if (temp != null) {
                label.setLength(0);
                label.append(Resource.getString
                             (ResourceConstants.AMS_AUTO_START_CONN));
                label.append(": ");
                item = new StringItem(label.toString(), temp);
                item.setLayout(Item.LAYOUT_NEWLINE_AFTER | Item.LAYOUT_2);
                append(item);
            }
        } catch (Throwable t) {
            throw t;
        } finally {
            if (midletSuite != null) {
                midletSuite.close();
            }
        }
    
private ImagegetSingleSuiteIcon()
Gets the single MIDlet suite icon from storage.

return
icon image

        if (singleSuiteIcon != null) {
            return singleSuiteIcon;
        }

        singleSuiteIcon = GraphicalInstaller.
            getImageFromInternalStorage("_single8");
        return singleSuiteIcon;
    
private ImagegetSuiteIcon()
Gets the MIDlet suite icon from storage.

return
icon image

        if (suiteIcon != null) {
            return suiteIcon;
        }

        suiteIcon = GraphicalInstaller.getImageFromInternalStorage("_suite8");
        return suiteIcon;
    
private voidinitMidletSuiteInfo(MIDletSuiteImpl midletSuite)
Initialize the MIDlet suite info fields for a given suite.

param
midletSuite the MIDletSuiteImpl object instance
exception
Exception if problem occurs while getting the suite info


        installInfo = midletSuite.getInstallInfo();
        numberOfMidlets = midletSuite.getNumberOfMIDlets();

        if (numberOfMidlets == 1) {
            String value = midletSuite.getProperty("MIDlet-1");
            MIDletInfo temp = new MIDletInfo(value);
            displayName = temp.name;
            icon = getSingleSuiteIcon();
        } else {
            displayName =
                midletSuite.getProperty(MIDletSuiteImpl.SUITE_NAME_PROP);
            icon = getSuiteIcon();
        }