ClientSession.java 6.11 KB
Newer Older
1 2 3 4 5
/**
 * $RCSfile$
 * $Revision: 3187 $
 * $Date: 2005-12-11 13:34:34 -0300 (Sun, 11 Dec 2005) $
 *
6
 * Copyright (C) 2005-2008 Jive Software. All rights reserved.
7
 *
8 9 10 11 12 13 14 15 16 17 18
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
19 20
 */

21
package org.jivesoftware.openfire.session;
22

23 24
import org.jivesoftware.openfire.privacy.PrivacyList;
import org.jivesoftware.openfire.user.UserNotFoundException;
25 26 27 28 29 30 31
import org.xmpp.packet.Presence;

/**
 * Represents a session between the server and a client.
 *
 * @author Gaston Dombiak
 */
32
public interface ClientSession extends Session {
33 34 35 36 37 38 39

    /**
     * Returns the Privacy list that overrides the default privacy list. This list affects
     * only this session and only for the duration of the session.
     *
     * @return the Privacy list that overrides the default privacy list.
     */
40
    public PrivacyList getActiveList();
41 42 43 44 45 46 47

    /**
     * Sets the Privacy list that overrides the default privacy list. This list affects
     * only this session and only for the duration of the session.
     *
     * @param activeList the Privacy list that overrides the default privacy list.
     */
48
    public void setActiveList(PrivacyList activeList);
49 50 51 52 53 54 55

    /**
     * Returns the default Privacy list used for the session's user. This list is
     * processed if there is no active list set for the session.
     *
     * @return the default Privacy list used for the session's user.
     */
56
    public PrivacyList getDefaultList();
57 58 59 60 61 62 63

    /**
     * Sets the default Privacy list used for the session's user. This list is
     * processed if there is no active list set for the session.
     *
     * @param defaultList the default Privacy list used for the session's user.
     */
64
    public void setDefaultList(PrivacyList defaultList);
65 66 67 68 69 70 71 72 73

    /**
     * Returns the username associated with this session. Use this information
     * with the user manager to obtain the user based on username.
     *
     * @return the username associated with this session
     * @throws UserNotFoundException if a user is not associated with a session
     *      (the session has not authenticated yet)
     */
74
    public String getUsername() throws UserNotFoundException;
75

76 77 78 79 80 81 82 83 84
    /**
     * Returns true if the authetnicated user is an anonymous user or if
     * the use has not authenticated yet.
     *
     * @return true if the authetnicated user is an anonymous user or if
     * the use has not authenticated yet.
     */
    boolean isAnonymousUser();

85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
    /**
     * Flag indicating if this session has been initialized once coming
     * online. Session initialization occurs after the session receives
     * the first "available" presence update from the client. Initialization
     * actions include pushing offline messages, presence subscription requests,
     * and presence statuses to the client. Initialization occurs only once
     * following the first available presence transition.
     *
     * @return True if the session has already been initializsed
     */
    public boolean isInitialized();

    /**
     * Sets the initialization state of the session.
     *
     * @param isInit True if the session has been initialized
     * @see #isInitialized
     */
    public void setInitialized(boolean isInit);

105 106 107 108 109 110 111 112 113 114
    /**
     * Returns true if the offline messages of the user should be sent to the user when
     * the user becomes online. If the user sent a disco request with node
     * "http://jabber.org/protocol/offline" before the available presence then do not
     * flood the user with the offline messages. If the user is connected from many resources
     * then if one of the sessions stopped the flooding then no session should flood the user.
     *
     * @return true if the offline messages of the user should be sent to the user when the user
     *         becomes online.
     */
115
    public boolean canFloodOfflineMessages();
116 117 118 119 120 121 122 123 124 125 126

    /**
     * Returns true if the user requested to not receive offline messages when sending
     * an available presence. The user may send a disco request with node
     * "http://jabber.org/protocol/offline" so that no offline messages are sent to the
     * user when he becomes online. If the user is connected from many resources then
     * if one of the sessions stopped the flooding then no session should flood the user.
     *
     * @return true if the user requested to not receive offline messages when sending
     *         an available presence.
     */
127
    public boolean isOfflineFloodStopped();
128 129 130 131 132 133

    /**
     * Obtain the presence of this session.
     *
     * @return The presence of this session or null if not authenticated
     */
134
    public Presence getPresence();
135 136 137 138 139 140

    /**
     * Set the presence of this session
     *
     * @param presence The presence for the session
     */
141
    public void setPresence(Presence presence);
142 143

    /**
144
     * Increments the conflict by one and returns new number of conflicts detected on this session.
145
     *
146
     * @return the new number of conflicts detected on this session.
147
     */
148
    public int incrementConflictCount();
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163

    /**
     * Indicates, whether message carbons are enabled.
     *
     * @return True, if message carbons are enabled.
     */
    boolean isMessageCarbonsEnabled();

    /**
     * Enables or disables <a href="http://xmpp.org/extensions/xep-0280.html">XEP-0280: Message Carbons</a> for this session.
     *
     * @param enabled True, if message carbons are enabled.
     * @see <a href="hhttp://xmpp.org/extensions/xep-0280.html">XEP-0280: Message Carbons</a>
     */
    void setMessageCarbonsEnabled(boolean enabled);
164
}