Search in sources :

Example 51 with NetworkPacket

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

the class BigscreenPlugin method sendUp.

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

Example 52 with NetworkPacket

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

the class BigscreenPlugin method sendSelect.

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

Example 53 with NetworkPacket

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

the class BigscreenPlugin method sendHome.

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

Example 54 with NetworkPacket

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

the class ReceiveNotificationsPlugin method onCreate.

@Override
public boolean onCreate() {
    // request all existing notifications
    NetworkPacket np = new NetworkPacket(PACKET_TYPE_NOTIFICATION_REQUEST);
    np.set("request", true);
    device.sendPacket(np);
    return true;
}
Also used : NetworkPacket(org.kde.kdeconnect.NetworkPacket)

Example 55 with NetworkPacket

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

the class SMSPlugin method handleRequestSingleConversation.

private boolean handleRequestSingleConversation(NetworkPacket packet) {
    SMSHelper.ThreadID threadID = new SMSHelper.ThreadID(packet.getLong("threadID"));
    long rangeStartTimestamp = packet.getLong("rangeStartTimestamp", -1);
    Long numberToGet = packet.getLong("numberToRequest", -1);
    if (numberToGet < 0) {
        numberToGet = null;
    }
    List<SMSHelper.Message> conversation;
    if (rangeStartTimestamp < 0) {
        conversation = SMSHelper.getMessagesInThread(this.context, threadID, numberToGet);
    } else {
        conversation = SMSHelper.getMessagesInRange(this.context, threadID, rangeStartTimestamp, numberToGet, true);
    }
    // Sometimes when desktop app is kept open while android app is restarted for any reason
    // mostRecentTimeStamp must be updated in that scenario too if a user request for a
    // single conversation and not the entire conversation list
    mostRecentTimestampLock.lock();
    for (SMSHelper.Message message : conversation) {
        if (message.date > mostRecentTimestamp) {
            mostRecentTimestamp = message.date;
        }
    }
    mostRecentTimestampLock.unlock();
    NetworkPacket reply = constructBulkMessagePacket(conversation);
    device.sendPacket(reply);
    return true;
}
Also used : SmsMessage(android.telephony.SmsMessage) SMSHelper(org.kde.kdeconnect.Helpers.SMSHelper) 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