/*
 * cid.java
 *
 * Created on 29 Ноябрь 2007 г., 19:04
 */

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

/**
 *
 * @author  evgs
 * @version
 */
public class cid extends MIDlet implements CommandListener {
    private Command cmdExit=new Command("Exit", 1, Command.EXIT);
    
    public void startApp() {
        Form f=new Form("Props");
        //Nokia and signed midlet???
        append(f, "CELLID");
        append(f, "LAC");
        append(f, "MCC");
        append(f, "MNC");
        
        //SE
        append(f, "com.sonyericsson.imei");
        //SE JP-7.2
        append(f, "com.sonyericsson.sim.subscribernumber");
        //SE JP-7.3 and higher
        append(f, "com.sonyericsson.net.cellid");
        append(f, "com.sonyericsson.net.rat");
        append(f, "com.sonyericsson.net.lac");
        append(f, "com.sonyericsson.net.mnc");
        append(f, "com.sonyericsson.net.cmnc");
        append(f, "com.sonyericsson.net.mcc");
        append(f, "com.sonyericsson.net.cmcc");

        //SE P910?
        append(f, "IMEI");
        
        //Motorola
        append(f, "CellID");
        append(f, "LocAreaCode");
        append(f, "IMSI");
        
        
        f.setCommandListener(this);
        f.addCommand(cmdExit);
        Display.getDisplay(this).setCurrent(f);
    }
    
    public void pauseApp() {
    }
    
    public void destroyApp(boolean unconditional) {
    }
    
    private String getProperty(String key) {
        try {
            String s = System.getProperty(key);
            if (s==null) return "<null>";
            return s;
        } catch (Exception e) {
            e.printStackTrace();
            return "<exception>";
        }
    }
    
    private void append (Form f, String key) {
        f.append(new StringItem (key + "=", getProperty(key)));
    }

    public void commandAction(Command command, Displayable displayable) {
        notifyDestroyed();
    }
}
