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 * Respresents 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    {
045        this.name = name;
046        this.jid = jid;
047        this.autoJoin = autoJoin;
048        this.nickname = nickname;
049        this.password = password;
050    }
051
052
053    /**
054     * Returns the display label representing the Conference room.
055     *
056     * @return the name of the conference room.
057     */
058    public String getName() {
059        return name;
060    }
061
062    protected void setName(String name) {
063        this.name = name;
064    }
065
066    /**
067     * Returns true if this conference room should be auto-joined on startup.
068     *
069     * @return true if room should be joined on startup, otherwise false.
070     */
071    public boolean isAutoJoin() {
072        return autoJoin;
073    }
074
075    protected void setAutoJoin(boolean autoJoin) {
076        this.autoJoin = autoJoin;
077    }
078
079    /**
080     * Returns the full JID of this conference room. (ex.dev@conference.jivesoftware.com)
081     *
082     * @return the full JID of  this conference room.
083     */
084    public EntityBareJid getJid() {
085        return jid;
086    }
087
088    /**
089     * Returns the nickname to use when joining this conference room. This is an optional
090     * value and may return null.
091     *
092     * @return the nickname to use when joining, null may be returned.
093     */
094    public Resourcepart getNickname() {
095        return nickname;
096    }
097
098    protected void setNickname(Resourcepart nickname) {
099        this.nickname = nickname;
100    }
101
102    /**
103     * Returns the password to use when joining this conference room. This is an optional
104     * value and may return null.
105     *
106     * @return the password to use when joining this conference room, null may be returned.
107     */
108    public String getPassword() {
109        return password;
110    }
111
112    protected void setPassword(String password) {
113        this.password = password;
114    }
115
116    @Override
117    public boolean equals(Object obj) {
118        if (obj == null || !(obj instanceof BookmarkedConference)) {
119            return false;
120        }
121        BookmarkedConference conference = (BookmarkedConference) obj;
122        return conference.getJid().equals(jid);
123    }
124
125    @Override
126    public int hashCode() {
127        return getJid().hashCode();
128    }
129
130    protected void setShared(boolean isShared) {
131        this.isShared = isShared;
132    }
133
134    @Override
135    public boolean isShared() {
136        return isShared;
137    }
138}