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