public static void join(String name, String pass, int maxStanzas) {
    StaticData sd = StaticData.getInstance();

    ConferenceGroup grp = sd.roster.initMuc(name, pass);
    // требуется для возможности нормального выхода
    // sd.roster.mucContact(name, Contact.ORIGIN_GC_MYSELF);
    // sd.roster.activeRooms.addElement(jid);

    JabberDataBlock x = new JabberDataBlock("x", null, null);
    x.setNameSpace("http://jabber.org/protocol/muc");
    if (pass.length() != 0) {
      // adding password to presence
      x.addChild("password", pass);
    }

    JabberDataBlock history = x.addChild("history", null);
    history.setAttribute("maxstanzas", String.valueOf(maxStanzas));
    history.setAttribute("maxchars", "32768");
    try {
      long last = grp.getConference().lastMessageTime;
      long delay = (grp.conferenceJoinTime - last) / 1000;
      if (last != 0)
        history.setAttribute("seconds", String.valueOf(delay)); // todo: change to since
    } catch (Exception e) {
    }
    ;

    // sd.roster.groups.getGroup(name.substring(0,
    // name.indexOf('@'))).imageExpandedIndex=ImageList.ICON_GCJOIN_INDEX;
    sd.roster.sendPresence(name, null, x);
    sd.roster.reEnumRoster();
  }
예제 #2
0
  public void commandAction(Command command, Displayable displayable) {
    if (command == cmdOk) {
      JabberDataBlock resultForm = new JabberDataBlock("x", null, null);
      resultForm.setNameSpace("jabber:x:data");
      resultForm.setTypeAttribute("submit");

      for (Enumeration e = items.elements(); e.hasMoreElements(); ) {
        JabberDataBlock ch = ((XDataField) e.nextElement()).constructJabberDataBlock();
        if (ch != null) resultForm.addChild(ch);
      }
      XDataFormSubmit(resultForm);
    }
    BombusQD.sd.canvas.show(parentView);
  }