001package com.github.theholywaffle.teamspeak3.api.wrapper;
002
003/*
004 * #%L
005 * TeamSpeak 3 Java API
006 * %%
007 * Copyright (C) 2014 Bert De Geyter
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.ClientProperty;
030
031import java.util.Map;
032
033public class ClientInfo extends Client {
034
035        private final int clientId;
036
037        public ClientInfo(int clientId, Map<String, String> map) {
038                super(map);
039                this.clientId = clientId;
040        }
041
042        @Override
043        public int getId() {
044                return clientId;
045        }
046
047        public String getAvatar() {
048                return get(ClientProperty.CLIENT_FLAG_AVATAR);
049        }
050
051        public long getBandwidthReceivedLastMinute() {
052                return getLong(ClientProperty.CONNECTION_BANDWIDTH_RECEIVED_LAST_MINUTE_TOTAL);
053        }
054
055        public long getBandwidthReceivedLastSecond() {
056                return getLong(ClientProperty.CONNECTION_BANDWIDTH_RECEIVED_LAST_SECOND_TOTAL);
057        }
058
059        public long getBandwidthSentlastMinute() {
060                return getLong(ClientProperty.CONNECTION_BANDWIDTH_SENT_LAST_MINUTE_TOTAL);
061        }
062
063        public long getBandwidthSentLastSecond() {
064                return getLong(ClientProperty.CONNECTION_BANDWIDTH_SENT_LAST_SECOND_TOTAL);
065        }
066
067        public String getBase64ClientUId() {
068                return get("client_base64HashClientUID");
069        }
070
071        public int getDefaultChannel() {
072                // TeamSpeak decided to prefix the channel ID with a forward slash (/)...
073                final String channelId = get(ClientProperty.CLIENT_DEFAULT_CHANNEL);
074                if (channelId.isEmpty()) return -1;
075                return Integer.parseInt(channelId.substring(1));
076        }
077
078        public String getDefaultToken() {
079                return get(ClientProperty.CLIENT_DEFAULT_TOKEN);
080        }
081
082        public String getDescription() {
083                return get(ClientProperty.CLIENT_DESCRIPTION);
084        }
085
086        public long getFiletransferBandwidthReceived() {
087                return getLong(ClientProperty.CONNECTION_FILETRANSFER_BANDWIDTH_RECEIVED);
088        }
089
090        public long getFiletransferBandwidthSent() {
091                return getLong(ClientProperty.CONNECTION_FILETRANSFER_BANDWIDTH_SENT);
092        }
093
094        public String getLoginName() {
095                return get(ClientProperty.CLIENT_LOGIN_NAME);
096        }
097
098        public String getMetaData() {
099                return get(ClientProperty.CLIENT_META_DATA);
100        }
101
102        public long getMonthlyBytesDownloaded() {
103                return getLong(ClientProperty.CLIENT_MONTH_BYTES_DOWNLOADED);
104        }
105
106        public long getMonthlyBytesUploaded() {
107                return getLong(ClientProperty.CLIENT_MONTH_BYTES_UPLOADED);
108        }
109
110        public int getNeededServerQueryViewPower() {
111                return getInt(ClientProperty.CLIENT_NEEDED_SERVERQUERY_VIEW_POWER);
112        }
113
114        public String getPhoneticNickname() {
115                return get(ClientProperty.CLIENT_NICKNAME_PHONETIC);
116        }
117
118        public String getTalkRequestMessage() {
119                return get(ClientProperty.CLIENT_TALK_REQUEST_MSG);
120        }
121
122        public long getTimeConnected() { // milliseconds
123                return getLong(ClientProperty.CONNECTION_CONNECTED_TIME);
124        }
125
126        public long getTotalBytesDownloaded() {
127                return getLong(ClientProperty.CLIENT_TOTAL_BYTES_DOWNLOADED);
128        }
129
130        public long getTotalBytesReceived() {
131                return getLong(ClientProperty.CONNECTION_BYTES_RECEIVED_TOTAL);
132        }
133
134        public long getTotalBytesSent() {
135                return getLong(ClientProperty.CONNECTION_BYTES_SENT_TOTAL);
136        }
137
138        public long getTotalBytesUploaded() {
139                return getLong(ClientProperty.CLIENT_TOTAL_BYTES_UPLOADED);
140        }
141
142        public int getTotalConnections() {
143                return getInt(ClientProperty.CLIENT_TOTALCONNECTIONS);
144        }
145
146        public long getTotalPacketsReceived() {
147                return getLong(ClientProperty.CONNECTION_PACKETS_RECEIVED_TOTAL);
148        }
149
150        public long getTotalPacketsSent() {
151                return getLong(ClientProperty.CONNECTION_PACKETS_SENT_TOTAL);
152        }
153
154        public int getUnreadMessages() {
155                return getInt(ClientProperty.CLIENT_UNREAD_MESSAGES);
156        }
157
158        public boolean isOutputOnlyMuted() {
159                return getBoolean(ClientProperty.CLIENT_OUTPUTONLY_MUTED);
160        }
161
162        public boolean isRequestingToTalk() {
163                return getBoolean(ClientProperty.CLIENT_TALK_REQUEST);
164        }
165
166        @Override
167        public boolean isTalking() {
168                throw new UnsupportedOperationException();
169        }
170}