Exemplo n.º 1
0
  /**
   * <code>delRosterItem</code> deletes a roster item. The rosterItem can be taken directly from a
   * valid Roster Extension object.
   *
   * <p>The server will respond to this, at which time any registered RosterListener interfaces will
   * be notified via a 'changed' type event.
   *
   * @param ri a <code>RosterItem</code> to delete
   * @exception InstantiationException if there is an error building objects, this may be removed
   *     later, after debugging.
   */
  public synchronized void delRosterItem(RosterItem ri) throws InstantiationException {
    // create builder if not used before.
    if (IQBuilder == null) IQBuilder = new InfoQueryBuilder();
    else
      // we have used  this builder before - make sure it is clean.
      IQBuilder.reset();
    IQBuilder.setType("set");

    if (rosterBuilder == null) rosterBuilder = new RosterBuilder();
    else rosterBuilder.reset();

    if (rosterItemBuilder == null) rosterItemBuilder = new RosterItemBuilder();
    else
      // we have used this builder before - make sure it is clean.
      rosterItemBuilder.reset();

    // copy existing roster item
    rosterItemBuilder.copyItem(ri);

    // change subscription type to 'remove' to tell the server to delete the
    // item
    rosterItemBuilder.setSubscriptionType("remove");

    // this should never throw an exception, since we are based on
    // the original roster item.
    rosterBuilder.addRosterItem(rosterItemBuilder.build());

    // this should never throw an exception, because we added the
    // roster item above first
    IQBuilder.addExtension(rosterBuilder.build());

    // this also should just work.
    connection.send((InfoQuery) IQBuilder.build());
  }
Exemplo n.º 2
0
  /**
   * <code>refreshRoster</code> does a complete reload of the user roster.
   *
   * @exception InstantiationException should never be thrown (may be removed after this is proven
   *     to be true)
   */
  public void refreshRoster() throws InstantiationException {
    // create builder if not used before.
    if (IQBuilder == null) IQBuilder = new InfoQueryBuilder();
    else
      // we have used  this builder before - make sure it is clean.
      IQBuilder.reset();
    IQBuilder.setType("get");

    if (rosterBuilder == null) rosterBuilder = new RosterBuilder();
    else rosterBuilder.reset();

    // this should never throw an exception
    IQBuilder.addExtension(rosterBuilder.build());

    // build and send out over the interface
    connection.send((InfoQuery) IQBuilder.build());
  }
Exemplo n.º 3
0
  /**
   * <code>addRosterItem</code> adds one precreated roster item to the roster, as stored on the
   * server. A response will be sent by the server, which will trigger a changed event on any
   * registered RosterListener interface.
   *
   * @param ri a <code>RosterItem</code> object to add
   * @exception InstantiationException if the build processes fail - this may be removed after
   *     debugging.
   */
  public synchronized void addRosterItem(RosterItem ri) throws InstantiationException {
    // create builder if not used before.
    if (IQBuilder == null) IQBuilder = new InfoQueryBuilder();
    else
      // we have used  this builder before - make sure it is clean.
      IQBuilder.reset();
    IQBuilder.setType("set");

    if (rosterBuilder == null) rosterBuilder = new RosterBuilder();
    else rosterBuilder.reset();

    rosterBuilder.addRosterItem(ri);

    // this should never throw an exception, because we added the
    // roster item above first
    IQBuilder.addExtension(rosterBuilder.build());

    // this also should just work.
    connection.send((InfoQuery) IQBuilder.build());
  }
Exemplo n.º 4
0
 /**
  * <code>setIQBean</code> sets the IQBean 'parent' for this class, which is used to send and
  * receive events from the interface with the jabber server.
  *
  * @param connection an <code>IQBean</code>
  */
 public void setIQBean(IQBean connection) {
   this.connection = connection;
   listener = new RosterPacketListener();
   connection.addPacketListener(listener);
 }