From ec7333dc9a74209aa73d68c30bec96c3abd84d3a Mon Sep 17 00:00:00 2001 From: Albert Vaca Date: Wed, 7 Aug 2013 19:14:17 +0200 Subject: [PATCH] Don't connect to myself --- .../kde/connect/LinkProviders/BroadcastTcpLinkProvider.java | 5 +++++ KdeConnect/src/main/java/org/kde/connect/NetworkPackage.java | 5 +++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/KdeConnect/src/main/java/org/kde/connect/LinkProviders/BroadcastTcpLinkProvider.java b/KdeConnect/src/main/java/org/kde/connect/LinkProviders/BroadcastTcpLinkProvider.java index 96b96804..5033bea1 100644 --- a/KdeConnect/src/main/java/org/kde/connect/LinkProviders/BroadcastTcpLinkProvider.java +++ b/KdeConnect/src/main/java/org/kde/connect/LinkProviders/BroadcastTcpLinkProvider.java @@ -145,6 +145,11 @@ public class BroadcastTcpLinkProvider extends BaseLinkProvider { if (!np.getType().equals(NetworkPackage.PACKAGE_TYPE_IDENTITY)) { Log.e("BroadcastTcpLinkProvider", "1 Expecting an identity package"); return; + } else { + String myId = NetworkPackage.createIdentityPackage(context).getString("deviceId"); + if (np.getType().equals(myId)) { + return; + } } Log.e("BroadcastTcpLinkProvider", "It is an identity package, creating link"); diff --git a/KdeConnect/src/main/java/org/kde/connect/NetworkPackage.java b/KdeConnect/src/main/java/org/kde/connect/NetworkPackage.java index 2a22d56a..523c6636 100644 --- a/KdeConnect/src/main/java/org/kde/connect/NetworkPackage.java +++ b/KdeConnect/src/main/java/org/kde/connect/NetworkPackage.java @@ -104,8 +104,9 @@ public class NetworkPackage { jo.put("version",mVersion); } catch(Exception e) { } - Log.e("NetworkPackage.serialize",jo.toString()+"\n"); - return jo.toString(); + String json = jo.toString()+"\n"; + Log.e("NetworkPackage.serialize",json); + return json; } static public NetworkPackage unserialize(String s) {