Android Open Source - valence Valence Device






From Project

Back to project page valence.

License

The source code is released under:

Apache License

If you think the Android project valence listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*
 * Copyright 2011 David Simmons//from ww  w .j a  v a 2  s.  com
 * http://cafbit.com/
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.cafbit.valence.device;

import java.net.InetAddress;
import java.net.UnknownHostException;

import com.cafbit.motelib.model.Device;
import com.cafbit.motelib.model.DeviceClass;
import com.cafbit.xmlfoo.annotations.LameCrypt;

public class ValenceDevice extends Device {

    public int port = 5900;
    public String serverName;
    public String serverVersion;
    @LameCrypt
    public String password;
    public boolean ard35Compatibility = false;
    public boolean macAuthentication = false;
    public String username;

    public ValenceDevice() {
    }

    public ValenceDevice(DeviceClass deviceClass) {
        this.deviceClass = deviceClass;
    }

    public InetAddress getInetAddress() {
        if (address == null) {
            return null;
        }
        InetAddress inetAddress;
        try {
            InetAddress addresses[] =
                InetAddress.getAllByName(address);
            // is this check really necessary?
            if (addresses.length == 0) {
                throw new UnknownHostException("No such host.");
            }
            inetAddress = addresses[0];
        } catch (UnknownHostException e) {
            e.printStackTrace();
            return null;
        }
        return inetAddress;
    }

    @Override
    public String getHeadline() {
        return serverName;
    }

    @Override
    public String getDescription() {
        StringBuilder sb = new StringBuilder();

        String name;
        if (serverName == null) {
            name = "";
        } else if (serverName.contains("@")) {
            name = serverName.substring(0, serverName.indexOf('@')) + "@";
        } else {
            name = serverName + "@";
        }

        String version;
        if (serverVersion != null) {
            version = " (v"+serverVersion+")";
        } else {
            version = "";
        }

        sb.append(name);
        sb.append(address);
        if (port != 5900) {
            sb.append(":"+port);
        }
        sb.append(version);

        return sb.toString();
    }

    public String toString() {
        return "valence://"+address+"/";
    }

    // the superclass hashes address; we hash port
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = super.hashCode();
        result = prime * result + port;
        return result;
    }

    // the superclass compares address; we compare port
    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (!super.equals(obj))
            return false;
        if (getClass() != obj.getClass())
            return false;
        ValenceDevice other = (ValenceDevice) obj;
        if (port != other.port)
            return false;
        return true;
    }

}




Java Source Code List

com.cafbit.valence.HelpActivity.java
com.cafbit.valence.MoteContextImpl.java
com.cafbit.valence.OptionsMenuHelper.java
com.cafbit.valence.RFBRecvThread.java
com.cafbit.valence.RFBThread.java
com.cafbit.valence.SelectionActivity.java
com.cafbit.valence.TouchPadEvent.java
com.cafbit.valence.TouchPadHandler.java
com.cafbit.valence.TouchPadView.java
com.cafbit.valence.ValenceActivity.java
com.cafbit.valence.ValenceApplication.java
com.cafbit.valence.ValenceIOException.java
com.cafbit.valence.device.ValenceDeviceClass.java
com.cafbit.valence.device.ValenceDeviceSetupView.java
com.cafbit.valence.device.ValenceDevice.java
com.cafbit.valence.device.ValenceMDNSDiscoveryHandler.java
com.cafbit.valence.rfb.DES.java
com.cafbit.valence.rfb.KeyTranslator.java
com.cafbit.valence.rfb.RFBConnection.java
com.cafbit.valence.rfb.RFBEvent.java
com.cafbit.valence.rfb.RFBException.java
com.cafbit.valence.rfb.RFBKeyEvent.java
com.cafbit.valence.rfb.RFBMessage.java
com.cafbit.valence.rfb.RFBPointerEvent.java
com.cafbit.valence.rfb.RFBSecurityARD.java
com.cafbit.valence.rfb.RFBSecurityNone.java
com.cafbit.valence.rfb.RFBSecurityVNC.java
com.cafbit.valence.rfb.RFBSecurity.java
com.cafbit.valence.rfb.RFBStream.java
com.cafbit.valence.rfb.Security.java
com.cafbit.valence.rfb.Util.java
com.cafbit.valence.rfb.Version.java