001package com.github.theholywaffle.teamspeak3.api.wrapper;
002
003/*
004 * #%L
005 * TeamSpeak 3 Java API
006 * %%
007 * Copyright (C) 2014 - 2015 Bert De Geyter, Roger Baumgartner
008 * %%
009 * Permission is hereby granted, free of charge, to any person obtaining a copy
010 * of this software and associated documentation files (the "Software"), to deal
011 * in the Software without restriction, including without limitation the rights
012 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
013 * copies of the Software, and to permit persons to whom the Software is
014 * furnished to do so, subject to the following conditions:
015 * 
016 * The above copyright notice and this permission notice shall be included in
017 * all copies or substantial portions of the Software.
018 * 
019 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
020 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
021 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
022 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
023 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
024 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
025 * THE SOFTWARE.
026 * #L%
027 */
028
029import com.github.theholywaffle.teamspeak3.api.ChannelBannerMode;
030import com.github.theholywaffle.teamspeak3.api.ChannelProperty;
031import com.github.theholywaffle.teamspeak3.api.Codec;
032
033import java.util.Map;
034
035public abstract class ChannelBase extends Wrapper {
036
037        protected ChannelBase(Map<String, String> map) {
038                super(map);
039        }
040
041        public abstract int getId();
042
043        public int getParentChannelId() {
044                return getInt(ChannelProperty.PID);
045        }
046
047        public int getOrder() {
048                return getInt(ChannelProperty.CHANNEL_ORDER);
049        }
050
051        public String getName() {
052                return get(ChannelProperty.CHANNEL_NAME);
053        }
054
055        public String getTopic() {
056                return get(ChannelProperty.CHANNEL_TOPIC);
057        }
058
059        public boolean isDefault() {
060                return getBoolean(ChannelProperty.CHANNEL_FLAG_DEFAULT);
061        }
062
063        public boolean hasPassword() {
064                return getBoolean(ChannelProperty.CHANNEL_FLAG_PASSWORD);
065        }
066
067        public boolean isPermanent() {
068                return getBoolean(ChannelProperty.CHANNEL_FLAG_PERMANENT);
069        }
070
071        public boolean isSemiPermanent() {
072                return getBoolean(ChannelProperty.CHANNEL_FLAG_SEMI_PERMANENT);
073        }
074
075        public ChannelBannerMode getBannerMode() {
076                final int mode = getInt(ChannelProperty.CHANNEL_BANNER_MODE);
077                for (final ChannelBannerMode m : ChannelBannerMode.values()) {
078                        if (m.getIndex() == mode) {
079                                return m;
080                        }
081                }
082                return ChannelBannerMode.UNKNOWN;
083        }
084
085        public String getBannerGraphicsUrl() {
086                return get(ChannelProperty.CHANNEL_BANNER_GFX_URL);
087        }
088
089        public Codec getCodec() {
090                final int codec = getInt(ChannelProperty.CHANNEL_CODEC);
091                for (final Codec c : Codec.values()) {
092                        if (c.getIndex() == codec) {
093                                return c;
094                        }
095                }
096                return Codec.UNKNOWN;
097        }
098
099        public int getCodecQuality() {
100                return getInt(ChannelProperty.CHANNEL_CODEC_QUALITY);
101        }
102
103        public int getNeededTalkPower() {
104                return getInt(ChannelProperty.CHANNEL_NEEDED_TALK_POWER);
105        }
106
107        public long getIconId() {
108                return getLong(ChannelProperty.CHANNEL_ICON_ID);
109        }
110
111        public int getMaxClients() {
112                return getInt(ChannelProperty.CHANNEL_MAXCLIENTS);
113        }
114
115        public int getMaxFamilyClients() {
116                return getInt(ChannelProperty.CHANNEL_MAXFAMILYCLIENTS);
117        }
118
119        public int getSecondsEmpty() {
120                return getInt(ChannelProperty.SECONDS_EMPTY);
121        }
122
123        /**
124         * @return {@code true}, if the channel and all child channels are empty, {@code false} otherwise.
125         */
126        abstract public boolean isFamilyEmpty();
127}