Search in sources :

Example 71 with NetworkPacket

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

the class SystemVolumePlugin method sendVolume.

void sendVolume(String name, int volume) {
    NetworkPacket np = new NetworkPacket(PACKET_TYPE_SYSTEMVOLUME_REQUEST);
    np.set("volume", volume);
    np.set("name", name);
    device.sendPacket(np);
}
Also used : NetworkPacket(org.kde.kdeconnect.NetworkPacket)

Example 72 with NetworkPacket

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

the class SystemVolumePlugin method sendMute.

void sendMute(String name, boolean mute) {
    NetworkPacket np = new NetworkPacket(PACKET_TYPE_SYSTEMVOLUME_REQUEST);
    np.set("muted", mute);
    np.set("name", name);
    device.sendPacket(np);
}
Also used : NetworkPacket(org.kde.kdeconnect.NetworkPacket)

Example 73 with NetworkPacket

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

the class SystemVolumePlugin method requestSinkList.

void requestSinkList() {
    NetworkPacket np = new NetworkPacket(PACKET_TYPE_SYSTEMVOLUME_REQUEST);
    np.set("requestSinks", true);
    device.sendPacket(np);
}
Also used : NetworkPacket(org.kde.kdeconnect.NetworkPacket)

Example 74 with NetworkPacket

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

the class PresenterPlugin method sendFullscreen.

public void sendFullscreen() {
    NetworkPacket np = new NetworkPacket(PACKET_TYPE_MOUSEPAD_REQUEST);
    np.set("specialKey", SpecialKeysMap.get(KeyEvent.KEYCODE_F5));
    device.sendPacket(np);
}
Also used : NetworkPacket(org.kde.kdeconnect.NetworkPacket)

Example 75 with NetworkPacket

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

the class RemoteKeyboardPlugin method onPacketReceived.

@Override
public boolean onPacketReceived(NetworkPacket np) {
    if (!np.getType().equals(PACKET_TYPE_MOUSEPAD_REQUEST) || (!np.has("key") && !np.has("specialKey"))) {
        // expect at least key OR specialKey
        Log.e("RemoteKeyboardPlugin", "Invalid package for remotekeyboard plugin!");
        return false;
    }
    if (RemoteKeyboardService.instance == null) {
        Log.i("RemoteKeyboardPlugin", "Remote keyboard is not the currently selected input method, dropping key");
        return false;
    }
    if (!RemoteKeyboardService.instance.visible && PreferenceManager.getDefaultSharedPreferences(context).getBoolean(context.getString(R.string.remotekeyboard_editing_only), true)) {
        Log.i("RemoteKeyboardPlugin", "Remote keyboard is currently not visible, dropping key");
        return false;
    }
    if (!handleEvent(np)) {
        Log.i("RemoteKeyboardPlugin", "Could not handle event!");
        return false;
    }
    if (np.getBoolean("sendAck")) {
        NetworkPacket reply = new NetworkPacket(PACKET_TYPE_MOUSEPAD_ECHO);
        reply.set("key", np.getString("key"));
        if (np.has("specialKey"))
            reply.set("specialKey", np.getInt("specialKey"));
        if (np.has("shift"))
            reply.set("shift", np.getBoolean("shift"));
        if (np.has("ctrl"))
            reply.set("ctrl", np.getBoolean("ctrl"));
        if (np.has("alt"))
            reply.set("alt", np.getBoolean("alt"));
        reply.set("isAck", true);
        device.sendPacket(reply);
    }
    return true;
}
Also used : NetworkPacket(org.kde.kdeconnect.NetworkPacket)

Aggregations

NetworkPacket (org.kde.kdeconnect.NetworkPacket)77 IOException (java.io.IOException)6 SSLSocket (javax.net.ssl.SSLSocket)4 SMSHelper (org.kde.kdeconnect.Helpers.SMSHelper)4 BufferedReader (java.io.BufferedReader)3 InputStreamReader (java.io.InputStreamReader)3 ServerSocket (java.net.ServerSocket)3 Socket (java.net.Socket)3 SocketException (java.net.SocketException)3 ArrayList (java.util.ArrayList)3 Timer (java.util.Timer)3 SuppressLint (android.annotation.SuppressLint)2 Uri (android.net.Uri)2 SmsMessage (android.telephony.SmsMessage)2 SpannableString (android.text.SpannableString)2 InputStream (java.io.InputStream)2 OutputStream (java.io.OutputStream)2 DatagramSocket (java.net.DatagramSocket)2 InetAddress (java.net.InetAddress)2 InetSocketAddress (java.net.InetSocketAddress)2