示例#1
0
  RoomInfo(DiscoverInfo info) {
    super();
    this.room = info.getFrom();
    // Get the information based on the discovered features
    this.membersOnly = info.containsFeature("muc_membersonly");
    this.moderated = info.containsFeature("muc_moderated");
    this.nonanonymous = info.containsFeature("muc_nonanonymous");
    this.passwordProtected = info.containsFeature("muc_passwordprotected");
    this.persistent = info.containsFeature("muc_persistent");
    // Get the information based on the discovered extended information
    Form form = Form.getFormFrom(info);
    if (form != null) {
      FormField descField = form.getField("muc#roominfo_description");
      this.description =
          (descField == null || !(descField.getValues().hasNext()))
              ? ""
              : descField.getValues().next();

      FormField subjField = form.getField("muc#roominfo_subject");
      this.subject =
          (subjField == null || !(subjField.getValues().hasNext()))
              ? ""
              : subjField.getValues().next();

      FormField occCountField = form.getField("muc#roominfo_occupants");
      this.occupantsCount =
          occCountField == null ? -1 : Integer.parseInt(occCountField.getValues().next());
    }
  }
示例#2
0
  /**
   * Returns the Form to use for all clients of a workgroup. It is unlikely that the server will
   * change the form (without a restart) so it is safe to keep the returned form for future
   * submissions.
   *
   * @return the Form to use for searching transcripts.
   * @throws XMPPException if an error occurs while sending the request to the server.
   */
  public Form getWorkgroupForm() throws XMPPException {
    WorkgroupForm workgroupForm = new WorkgroupForm();
    workgroupForm.setType(IQ.Type.GET);
    workgroupForm.setTo(workgroupJID);

    WorkgroupForm response =
        (WorkgroupForm) connection.createPacketCollectorAndSend(workgroupForm).nextResultOrThrow();
    return Form.getFormFrom(response);
  }