Exemplo n.º 1
1
  public void commandAction(Command c, Displayable d) {
    if (c == mExitCommand) {
      destroyApp(true);
      notifyDestroyed();
    } else if ((c == List.SELECT_COMMAND) && (d == mMenu)) {
      int selection = mMenu.getSelectedIndex();
      String item = "[none]";

      if ((selection >= 0) && (selection < mMenu.size())) {
        item = mMenu.getString(selection);
      }

      if (item == kQuerySlots) {
        Form slotList = new Form("Slots");
        String slots = System.getProperty("microedition.smartcardslots");
        int index = 0;

        while (index < slots.length()) {
          String slot;
          int comma = slots.indexOf(',', index);

          if (comma == -1) {
            slot = slots.substring(index).trim();
            index = slots.length();
          } else {
            slot = slots.substring(index, comma).trim();
            index = comma + 1;
          }

          StringItem slotItem = new StringItem(null, slot);
          slotItem.setLayout(Item.LAYOUT_2 | Item.LAYOUT_NEWLINE_AFTER);
          slotList.append(slotItem);
        }

        slotList.addCommand(mBackCommand);
        slotList.setCommandListener(this);
        mDisplay.setCurrent(slotList);
      } else if (item == kSignTest) {
        System.out.println("Starting sign test...");

        /*
        try {
          CMSMessageSignatureService.sign(
            "This is the message to sign",
            CMSMessageSignatureService.SIG_INCLUDE_CONTENT |
                CMSMessageSignatureService.SIG_INCLUDE_CERTIFICATE,
            null,
            "This is the prompt");
        }
        catch (Exception e) {
          System.out.println("sign() barfed: " + e);
        }*/
        new Thread() {
          public void run() {
            fromSpecification();
            System.out.println("Sign test finished.");
          }
        }.start();
      }
    } else if (c == mBackCommand) {
      mDisplay.setCurrent(mMenu);
    }
  }
Exemplo n.º 2
0
 public SettingsForm(MainForm mf) {
   super("HipoqihPlugin");
   setCommandListener(this);
   mainForm = mf;
   labelUser.setLayout(Item.LAYOUT_LEFT | Item.LAYOUT_TOP | Item.LAYOUT_2);
   this.append(labelUser);
   textUser.setLayout(
       Item.LAYOUT_LEFT | Item.LAYOUT_TOP | Item.LAYOUT_NEWLINE_AFTER | Item.LAYOUT_2);
   this.append(textUser);
   labelPass.setLayout(Item.LAYOUT_LEFT | Item.LAYOUT_TOP | Item.LAYOUT_2);
   this.append(labelPass);
   textPass.setLayout(
       Item.LAYOUT_LEFT | Item.LAYOUT_TOP | Item.LAYOUT_NEWLINE_AFTER | Item.LAYOUT_2);
   this.append(textPass);
   labelPeriod.setLayout(
       Item.LAYOUT_LEFT | Item.LAYOUT_TOP | Item.LAYOUT_NEWLINE_AFTER | Item.LAYOUT_2);
   this.append(labelPeriod);
   textPeriod.setLayout(
       Item.LAYOUT_LEFT | Item.LAYOUT_TOP | Item.LAYOUT_NEWLINE_AFTER | Item.LAYOUT_2);
   this.append(textPeriod);
   this.addCommand(cmdSave);
   this.addCommand(cmdCancel);
 }
Exemplo n.º 3
0
  /**
   * We have to provide this method due to "do not do network operation in command listener method"
   * restriction, which is caused by crooked midp design.
   *
   * <p>This method is called by BTImageClient after it is done with bluetooth initialization and
   * next screen is ready to appear.
   */
  void completeInitialization(boolean isBTReady) {
    // bluetooth was initialized successfully.
    if (isBTReady) {
      StringItem si = new StringItem("Ready for images search!", null);
      si.setLayout(StringItem.LAYOUT_CENTER | StringItem.LAYOUT_VCENTER);
      mainScreen.append(si);
      Display.getDisplay(parent).setCurrent(mainScreen);

      return;
    }

    // something wrong
    Alert al = new Alert("Error", "Can't initialize bluetooth", null, AlertType.ERROR);
    al.setTimeout(DemoMIDlet.ALERT_TIMEOUT);
    Display.getDisplay(parent).setCurrent(al, parent.getDisplayable());
  }