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.valueOf(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 getIp() { 095 return get(ClientProperty.CONNECTION_CLIENT_IP); 096 } 097 098 public String getLoginName() { 099 return get(ClientProperty.CLIENT_LOGIN_NAME); 100 } 101 102 public String getMetaData() { 103 return get(ClientProperty.CLIENT_META_DATA); 104 } 105 106 public long getMonthlyBytesDownloaded() { 107 return getLong(ClientProperty.CLIENT_MONTH_BYTES_DOWNLOADED); 108 } 109 110 public long getMonthlyBytesUploaded() { 111 return getLong(ClientProperty.CLIENT_MONTH_BYTES_UPLOADED); 112 } 113 114 public int getNeededServerQueryViewPower() { 115 return getInt(ClientProperty.CLIENT_NEEDED_SERVERQUERY_VIEW_POWER); 116 } 117 118 public String getPhoneticNickname() { 119 return get(ClientProperty.CLIENT_NICKNAME_PHONETIC); 120 } 121 122 public String getTalkRequestMessage() { 123 return get(ClientProperty.CLIENT_TALK_REQUEST_MSG); 124 } 125 126 public long getTimeConnected() { // milliseconds 127 return getLong(ClientProperty.CONNECTION_CONNECTED_TIME); 128 } 129 130 public long getTotalBytesDownloaded() { 131 return getLong(ClientProperty.CLIENT_TOTAL_BYTES_DOWNLOADED); 132 } 133 134 public long getTotalBytesReceived() { 135 return getLong(ClientProperty.CONNECTION_BYTES_RECEIVED_TOTAL); 136 } 137 138 public long getTotalBytesSent() { 139 return getLong(ClientProperty.CONNECTION_BYTES_SENT_TOTAL); 140 } 141 142 public long getTotalBytesUploaded() { 143 return getLong(ClientProperty.CLIENT_TOTAL_BYTES_UPLOADED); 144 } 145 146 public int getTotalConnections() { 147 return getInt(ClientProperty.CLIENT_TOTALCONNECTIONS); 148 } 149 150 public long getTotalPacketsReceived() { 151 return getLong(ClientProperty.CONNECTION_PACKETS_RECEIVED_TOTAL); 152 } 153 154 public long getTotalPacketsSent() { 155 return getLong(ClientProperty.CONNECTION_PACKETS_SENT_TOTAL); 156 } 157 158 public int getUnreadMessages() { 159 return getInt(ClientProperty.CLIENT_UNREAD_MESSAGES); 160 } 161 162 public boolean isOutputOnlyMuted() { 163 return getBoolean(ClientProperty.CLIENT_OUTPUTONLY_MUTED); 164 } 165 166 public boolean isRequestingToTalk() { 167 return getBoolean(ClientProperty.CLIENT_TALK_REQUEST); 168 } 169 170 @Override 171 public boolean isTalking() { 172 throw new UnsupportedOperationException(); 173 } 174}