Search in sources :

Example 1 with BaseLink

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

the class Device method sendPackageBlocking.

public boolean sendPackageBlocking(final NetworkPackage np, final SendPackageStatusCallback callback) {
    /*
        if (!m_outgoingCapabilities.contains(np.getType()) && !NetworkPackage.protocolPackageTypes.contains(np.getType())) {
            Log.e("Device/sendPackage", "Plugin tried to send an undeclared package: " + np.getType());
            Log.w("Device/sendPackage", "Declared outgoing package types: " + Arrays.toString(m_outgoingCapabilities.toArray()));
        }
        */
    hackToMakeRetrocompatiblePacketTypes(np);
    boolean useEncryption = (protocolVersion < LanLinkProvider.MIN_VERSION_WITH_SSL_SUPPORT && (!np.getType().equals(NetworkPackage.PACKAGE_TYPE_PAIR) && isPaired()));
    boolean success = false;
    //Make a copy to avoid concurrent modification exception if the original list changes
    for (final BaseLink link : links) {
        //Since we made a copy, maybe somebody destroyed the link in the meanwhile
        if (link == null)
            continue;
        if (useEncryption) {
            success = link.sendPackageEncrypted(np, callback, publicKey);
        } else {
            success = link.sendPackage(np, callback);
        }
        //If the link didn't call sendSuccess(), try the next one
        if (success)
            break;
    }
    if (!success) {
        Log.e("KDE/sendPackage", "No device link (of " + links.size() + " available) could send the package. Package " + np.getType() + " to " + name + " lost!");
    }
    return success;
}
Also used : BaseLink(org.kde.kdeconnect.Backends.BaseLink)

Example 2 with BaseLink

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

the class Device method removeLink.

public void removeLink(BaseLink link) {
    // FilesHelper.LogOpenFileCount();
    /* Remove pairing handler corresponding to that link too if it was the only link*/
    boolean linkPresent = false;
    for (BaseLink bl : links) {
        if (bl.getName().equals(link.getName())) {
            linkPresent = true;
            break;
        }
    }
    if (!linkPresent) {
        pairingHandlers.remove(link.getName());
    }
    link.removePacketReceiver(this);
    links.remove(link);
    Log.i("KDE/Device", "removeLink: " + link.getLinkProvider().getName() + " -> " + getName() + " active links: " + links.size());
    if (links.isEmpty()) {
        reloadPluginsFromSettings();
        if (packetQueue != null) {
            packetQueue.disconnected();
            packetQueue = null;
        }
    }
}
Also used : BaseLink(org.kde.kdeconnect.Backends.BaseLink)

Aggregations

BaseLink (org.kde.kdeconnect.Backends.BaseLink)2