001/**
002 *
003 * Copyright 2003-2007 Jive Software.
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License");
006 * you may not use this file except in compliance with the License.
007 * You may obtain a copy of the License at
008 *
009 *     http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018package org.jivesoftware.smackx.bookmarks;
019
020import org.jxmpp.jid.EntityBareJid;
021import org.jxmpp.jid.parts.Resourcepart;
022
023/**
024 * Represents a Conference Room bookmarked on the server using XEP-0048 Bookmark Storage XEP.
025 *
026 * @author Derek DeMoro
027 */
028public class BookmarkedConference implements SharedBookmark {
029
030    private String name;
031    private boolean autoJoin;
032    private final EntityBareJid jid;
033
034    private Resourcepart nickname;
035    private String password;
036    private boolean isShared;
037
038    protected BookmarkedConference(EntityBareJid jid) {
039        this.jid = jid;
040    }
041
042    protected BookmarkedConference(String name, EntityBareJid jid, boolean autoJoin, Resourcepart nickname,
043            String password) {
044        this.name = name;
045        this.jid = jid;
046        this.autoJoin = autoJoin;
047        this.nickname = nickname;
048        this.password = password;
049    }
050
051
052    /**
053     * Returns the display label representing the Conference room.
054     *
055     * @return the name of the conference room.
056     */
057    public String getName() {
058        return name;
059    }
060
061    protected void setName(String name) {
062        this.name = name;
063    }
064
065    /**
066     * Returns true if this conference room should be auto-joined on startup.
067     *
068     * @return true if room should be joined on startup, otherwise false.
069     */
070    public boolean isAutoJoin() {
071        return autoJoin;
072    }
073
074    protected void setAutoJoin(boolean autoJoin) {
075        this.autoJoin = autoJoin;
076    }
077
078    /**
079     * Returns the full JID of this conference room. (ex.dev@conference.jivesoftware.com)
080     *
081     * @return the full JID of  this conference room.
082     */
083    public EntityBareJid getJid() {
084        return jid;
085    }
086
087    /**
088     * Returns the nickname to use when joining this conference room. This is an optional
089     * value and may return null.
090     *
091     * @return the nickname to use when joining, null may be returned.
092     */
093    public Resourcepart getNickname() {
094        return nickname;
095    }
096
097    protected void setNickname(Resourcepart nickname) {
098        this.nickname = nickname;
099    }
100
101    /**
102     * Returns the password to use when joining this conference room. This is an optional
103     * value and may return null.
104     *
105     * @return the password to use when joining this conference room, null may be returned.
106     */
107    public String getPassword() {
108        return password;
109    }
110
111    protected void setPassword(String password) {
112        this.password = password;
113    }
114
115    @Override
116    public boolean equals(Object obj) {
117        if (obj == null || !(obj instanceof BookmarkedConference)) {
118            return false;
119        }
120        BookmarkedConference conference = (BookmarkedConference) obj;
121        return conference.getJid().equals(jid);
122    }
123
124    @Override
125    public int hashCode() {
126        return getJid().hashCode();
127    }
128
129    protected void setShared(boolean isShared) {
130        this.isShared = isShared;
131    }
132
133    @Override
134    public boolean isShared() {
135        return isShared;
136    }
137}