SubscribeListener.java

  1. /**
  2.  *
  3.  * Copyright 2015-2017 Florian Schmaus
  4.  *
  5.  * Licensed under the Apache License, Version 2.0 (the "License");
  6.  * you may not use this file except in compliance with the License.
  7.  * You may obtain a copy of the License at
  8.  *
  9.  *     http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */

  17. package org.jivesoftware.smack.roster;

  18. import org.jivesoftware.smack.packet.Presence;

  19. import org.jxmpp.jid.Jid;


  20. /**
  21.  * Handle incoming requests to subscribe to our presence. The
  22.  * {@link #processSubscribe(Jid, Presence)} method may return a subscribe
  23.  * answer. If no subscribe answer is returned, the next listener will be
  24.  * notified and asked. If no listener returns an answer, then nothing happens.
  25.  *
  26.  */
  27. public interface SubscribeListener {

  28.     enum SubscribeAnswer {
  29.         /**
  30.          * Approve the subscription request.
  31.          */
  32.         Approve,

  33.         /**
  34.          * Approve the subscription request and also request subscription from the other party if not already subscribed.
  35.          * @since 4.2.2
  36.          */
  37.         ApproveAndAlsoRequestIfRequired,

  38.         /**
  39.          * Deny the subscription request.
  40.          */
  41.         Deny,
  42.     }

  43.     /**
  44.      * Handle incoming presence subscription requests.
  45.      *
  46.      * @param from the JID requesting the subscription.
  47.      * @param subscribeRequest the presence stanza used for the request.
  48.      * @return a answer to the request, or <code>null</code>
  49.      */
  50.     SubscribeAnswer processSubscribe(Jid from, Presence subscribeRequest);

  51. }