Constantin Kaplinsky | 2844fd5 | 2008-04-14 08:02:25 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright (C) 2003 Constantin Kaplinsky. All Rights Reserved. |
| 3 | // |
| 4 | // This is free software; you can redistribute it and/or modify |
| 5 | // it under the terms of the GNU General Public License as published by |
| 6 | // the Free Software Foundation; either version 2 of the License, or |
| 7 | // (at your option) any later version. |
| 8 | // |
| 9 | // This software is distributed in the hope that it will be useful, |
| 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | // GNU General Public License for more details. |
| 13 | // |
| 14 | // You should have received a copy of the GNU General Public License |
| 15 | // along with this software; if not, write to the Free Software |
| 16 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 17 | // USA. |
| 18 | // |
| 19 | |
| 20 | // |
| 21 | // CapabilityInfo.java - A class to hold information about a |
| 22 | // particular capability as used in the RFB protocol 3.130. |
| 23 | // |
| 24 | |
Adam Tkac | f53e62a | 2009-03-13 13:20:26 +0000 | [diff] [blame^] | 25 | package com.tigervnc.vncviewer; |
Constantin Kaplinsky | 90d8a50 | 2008-04-14 09:45:50 +0000 | [diff] [blame] | 26 | |
Constantin Kaplinsky | 2844fd5 | 2008-04-14 08:02:25 +0000 | [diff] [blame] | 27 | class CapabilityInfo { |
| 28 | |
| 29 | // Public methods |
| 30 | |
| 31 | public CapabilityInfo(int code, |
| 32 | String vendorSignature, |
| 33 | String nameSignature, |
| 34 | String description) { |
| 35 | this.code = code; |
| 36 | this.vendorSignature = vendorSignature; |
| 37 | this.nameSignature = nameSignature; |
| 38 | this.description = description; |
| 39 | enabled = false; |
| 40 | } |
| 41 | |
| 42 | public CapabilityInfo(int code, |
| 43 | byte[] vendorSignature, |
| 44 | byte[] nameSignature) { |
| 45 | this.code = code; |
| 46 | this.vendorSignature = new String(vendorSignature); |
| 47 | this.nameSignature = new String(nameSignature); |
| 48 | this.description = null; |
| 49 | enabled = false; |
| 50 | } |
| 51 | |
| 52 | public int getCode() { |
| 53 | return code; |
| 54 | } |
| 55 | |
| 56 | public String getDescription() { |
| 57 | return description; |
| 58 | } |
| 59 | |
| 60 | public boolean isEnabled() { |
| 61 | return enabled; |
| 62 | } |
| 63 | |
| 64 | public void enable() { |
| 65 | enabled = true; |
| 66 | } |
| 67 | |
| 68 | public boolean equals(CapabilityInfo other) { |
| 69 | return (other != null && this.code == other.code && |
| 70 | this.vendorSignature.equals(other.vendorSignature) && |
| 71 | this.nameSignature.equals(other.nameSignature)); |
| 72 | } |
| 73 | |
| 74 | public boolean enableIfEquals(CapabilityInfo other) { |
| 75 | if (this.equals(other)) |
| 76 | enable(); |
| 77 | |
| 78 | return isEnabled(); |
| 79 | } |
| 80 | |
| 81 | // Protected data |
| 82 | |
| 83 | protected int code; |
| 84 | protected String vendorSignature; |
| 85 | protected String nameSignature; |
| 86 | |
| 87 | protected String description; |
| 88 | protected boolean enabled; |
| 89 | } |