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
020/**
021 * Respresents a Conference Room bookmarked on the server using XEP-0048 Bookmark Storage XEP.
022 *
023 * @author Derek DeMoro
024 */
025public class BookmarkedConference implements SharedBookmark {
026
027    private String name;
028    private boolean autoJoin;
029    private final String jid;
030
031    private String nickname;
032    private String password;
033    private boolean isShared;
034
035    protected BookmarkedConference(String jid) {
036        this.jid = jid;
037    }
038
039    protected BookmarkedConference(String name, String jid, boolean autoJoin, String nickname,
040            String password)
041    {
042        this.name = name;
043        this.jid = jid;
044        this.autoJoin = autoJoin;
045        this.nickname = nickname;
046        this.password = password;
047    }
048
049
050    /**
051     * Returns the display label representing the Conference room.
052     *
053     * @return the name of the conference room.
054     */
055    public String getName() {
056        return name;
057    }
058
059    protected void setName(String name) {
060        this.name = name;
061    }
062
063    /**
064     * Returns true if this conference room should be auto-joined on startup.
065     *
066     * @return true if room should be joined on startup, otherwise false.
067     */
068    public boolean isAutoJoin() {
069        return autoJoin;
070    }
071
072    protected void setAutoJoin(boolean autoJoin) {
073        this.autoJoin = autoJoin;
074    }
075
076    /**
077     * Returns the full JID of this conference room. (ex.dev@conference.jivesoftware.com)
078     *
079     * @return the full JID of  this conference room.
080     */
081    public String getJid() {
082        return jid;
083    }
084
085    /**
086     * Returns the nickname to use when joining this conference room. This is an optional
087     * value and may return null.
088     *
089     * @return the nickname to use when joining, null may be returned.
090     */
091    public String getNickname() {
092        return nickname;
093    }
094
095    protected void setNickname(String nickname) {
096        this.nickname = nickname;
097    }
098
099    /**
100     * Returns the password to use when joining this conference room. This is an optional
101     * value and may return null.
102     *
103     * @return the password to use when joining this conference room, null may be returned.
104     */
105    public String getPassword() {
106        return password;
107    }
108
109    protected void setPassword(String password) {
110        this.password = password;
111    }
112
113    public boolean equals(Object obj) {
114        if(obj == null || !(obj instanceof BookmarkedConference)) {
115            return false;
116        }
117        BookmarkedConference conference = (BookmarkedConference)obj;
118        return conference.getJid().equalsIgnoreCase(jid);
119    }
120
121    protected void setShared(boolean isShared) {
122        this.isShared = isShared;
123    }
124
125    public boolean isShared() {
126        return isShared;
127    }
128}