Ejemplo n.º 1
0
  public VCard(JabberDataBlock data) {
    this();
    jid = data.getAttribute("from");
    id = data.getAttribute("id");
    int itemsCount = getCount();
    vCardData = new Vector(itemsCount);
    vCardData.setSize(itemsCount);

    if (data == null) return;
    if (data.getTypeAttribute().equals("error")) return;
    JabberDataBlock vcard = data.findNamespace("vcard-temp");
    if (vcard == null) return; // "No vCard available"

    empty = false;

    for (int i = 0; i < itemsCount; i++) {
      try {
        String f1 = (String) VCard.vCardFields.elementAt(i);
        String f2 = (String) VCard.vCardFields2.elementAt(i);

        JabberDataBlock d2 = (f2 == null) ? vcard : vcard.getChildBlock(f2);

        String field = d2.getChildBlockText(f1);

        if (field.length() > 0) setVCardData(i, field);
      } catch (Exception e) {
        /**/
      }
    }

    try {
      JabberDataBlock photoXML = vcard.getChildBlock("PHOTO").getChildBlock("BINVAL");
      photo = (byte[]) photoXML.getChildBlocks().lastElement();
    } catch (Exception e) {
    }
    ;
  }
Ejemplo n.º 2
0
  public XDataForm(JabberDataBlock data, String id, String from) {
    this.id = id;
    this.from = from;

    cmdOk = new Command(SR.get(SR.MS_SEND), Command.OK /*Command.SCREEN*/, 1);
    cmdCancel = new Command(SR.get(SR.MS_BACK), Command.BACK, 99);
    // #ifdef DEBUG_CONSOLE
    // #         midlet.BombusQD.debug.add("captcha<<< " + data.toString(),10);
    // #endif

    JabberDataBlock challenge = data.findNamespace("captcha", "urn:xmpp:captcha");
    JabberDataBlock xdata = challenge.findNamespace("x", "jabber:x:data");
    JabberDataBlock oob = data.findNamespace("x", "jabber:x:oob");

    String url = oob.getChildBlockText("url");
    String title = xdata.getChildBlockText("title");

    Vector xData = xdata.getChildBlocks();

    if (null == title) title = "";

    f = new Form(title);
    items = new Vector(0);

    if (url.length() > 0) {
      TextField formItem = new TextField("URL", url, url.length(), TextField.UNEDITABLE);
      f.append(formItem);
    }

    XDataField field;
    String msgcid = "";

    int size = xData.size();
    for (int i = 0; i < size; ++i) {
      JabberDataBlock ch = (JabberDataBlock) xData.elementAt(i);

      if (ch.getTagName().equals("instructions")) {
        f.append(ch.getText());
        f.append("\n");
        continue;
      }
      ;
      if (!ch.getTagName().equals("field")) continue;

      field = new XDataField(ch);
      items.addElement(field);

      if (field.hidden) continue;

      if (field.media != null) msgcid = field.mediaUri.substring(4);
      f.append(field.formItem);
    }

    JabberDataBlock dataImage = data.findNamespace("data", "urn:xmpp:bob");
    String cid = dataImage.getAttribute("cid");
    if (cid.indexOf(msgcid) == 0) {
      try {
        byte[] bytes = Strconv.fromBase64(dataImage.getText());
        Image img = Image.createImage(bytes, 0, bytes.length);
        f.append(new ImageItem(null, img, Item.LAYOUT_CENTER, null));
      } catch (OutOfMemoryError eom) {
        // #ifdef DEBUG_CONSOLE
        // #                 midlet.BombusQD.debug.add("XDataForm OutOfMem",10);
        // #endif
      } catch (Exception e) {
      }
    }

    f.setCommandListener(this);
    f.addCommand(cmdOk);
    f.addCommand(cmdCancel);

    this.parentView = BombusQD.sd.canvas.getCanvas();
    BombusQD.setCurrentView(f);
  }