Search in sources :

Example 26 with NetworkPackage

use of org.kde.kdeconnect.NetworkPackage in project kdeconnect-android by KDE.

the class LanLinkProvider method tcpPackageReceived.

//They received my UDP broadcast and are connecting to me. The first thing they sned should be their identity.
void tcpPackageReceived(Socket socket) throws Exception {
    NetworkPackage networkPackage;
    try {
        BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        String message = reader.readLine();
        networkPackage = NetworkPackage.unserialize(message);
    //Log.e("TcpListener","Received TCP package: "+networkPackage.serialize());
    } catch (Exception e) {
        e.printStackTrace();
        return;
    }
    if (!networkPackage.getType().equals(NetworkPackage.PACKAGE_TYPE_IDENTITY)) {
        Log.e("KDE/LanLinkProvider", "Expecting an identity package instead of " + networkPackage.getType());
        return;
    }
    Log.i("KDE/LanLinkProvider", "Identity package received from a TCP connection from " + networkPackage.getString("deviceName"));
    identityPackageReceived(networkPackage, socket, LanLink.ConnectionStarted.Locally);
}
Also used : InputStreamReader(java.io.InputStreamReader) NetworkPackage(org.kde.kdeconnect.NetworkPackage) BufferedReader(java.io.BufferedReader) SocketException(java.net.SocketException) IOException(java.io.IOException)

Example 27 with NetworkPackage

use of org.kde.kdeconnect.NetworkPackage in project kdeconnect-android by KDE.

the class MousePadPlugin method sendMouseDelta.

public void sendMouseDelta(float dx, float dy, float sensitivity) {
    NetworkPackage np = new NetworkPackage(PACKAGE_TYPE_MOUSEPAD_REQUEST);
    if (sensitivity <= 0.0001f) {
        sensitivity = 1.0f;
    }
    np.set("dx", dx * sensitivity);
    np.set("dy", dy * sensitivity);
    device.sendPackage(np);
}
Also used : NetworkPackage(org.kde.kdeconnect.NetworkPackage)

Example 28 with NetworkPackage

use of org.kde.kdeconnect.NetworkPackage in project kdeconnect-android by KDE.

the class KeyListenerView method sendChars.

public void sendChars(CharSequence chars) {
    final NetworkPackage np = new NetworkPackage(MousePadPlugin.PACKAGE_TYPE_MOUSEPAD_REQUEST);
    np.set("key", chars.toString());
    sendKeyPressPackage(np);
}
Also used : NetworkPackage(org.kde.kdeconnect.NetworkPackage)

Example 29 with NetworkPackage

use of org.kde.kdeconnect.NetworkPackage in project kdeconnect-android by KDE.

the class MousePadPlugin method sendRightClick.

public void sendRightClick() {
    NetworkPackage np = new NetworkPackage(PACKAGE_TYPE_MOUSEPAD_REQUEST);
    np.set("rightclick", true);
    device.sendPackage(np);
}
Also used : NetworkPackage(org.kde.kdeconnect.NetworkPackage)

Example 30 with NetworkPackage

use of org.kde.kdeconnect.NetworkPackage in project kdeconnect-android by KDE.

the class MousePadPlugin method sendScroll.

public void sendScroll(float dx, float dy) {
    NetworkPackage np = new NetworkPackage(PACKAGE_TYPE_MOUSEPAD_REQUEST);
    np.set("scroll", true);
    np.set("dx", dx);
    np.set("dy", dy);
    device.sendPackage(np);
}
Also used : NetworkPackage(org.kde.kdeconnect.NetworkPackage)

Aggregations

NetworkPackage (org.kde.kdeconnect.NetworkPackage)41 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 SocketException (java.net.SocketException)3 Uri (android.net.Uri)2 BufferedReader (java.io.BufferedReader)2 File (java.io.File)2 InputStreamReader (java.io.InputStreamReader)2 DatagramSocket (java.net.DatagramSocket)2 InetAddress (java.net.InetAddress)2 ServerSocket (java.net.ServerSocket)2 Socket (java.net.Socket)2 Timer (java.util.Timer)2 TimerTask (java.util.TimerTask)2 Cipher (javax.crypto.Cipher)2 SSLSocket (javax.net.ssl.SSLSocket)2 JSONArray (org.json.JSONArray)2 Notification (android.app.Notification)1 ContentResolver (android.content.ContentResolver)1 Intent (android.content.Intent)1