Changeset View
Changeset View
Standalone View
Standalone View
src/org/kde/kdeconnect/Backends/LanBackend/LanLink.java
Show First 20 Lines • Show All 144 Lines • ▼ Show 20 Line(s) | 143 | if (socket == null) { | |||
---|---|---|---|---|---|
145 | callback.onFailure(new NotYetConnectedException()); | 145 | callback.onFailure(new NotYetConnectedException()); | ||
146 | return false; | 146 | return false; | ||
147 | } | 147 | } | ||
148 | 148 | | |||
149 | try { | 149 | try { | ||
150 | 150 | | |||
151 | //Prepare socket for the payload | 151 | //Prepare socket for the payload | ||
152 | final ServerSocket server; | 152 | final ServerSocket server; | ||
153 | if (np.hasPayload() && np.getPayloadSize() != 0) { | 153 | if (np.hasPayload()) { | ||
154 | server = LanLinkProvider.openServerSocketOnFreePort(LanLinkProvider.PAYLOAD_TRANSFER_MIN_PORT); | 154 | server = LanLinkProvider.openServerSocketOnFreePort(LanLinkProvider.PAYLOAD_TRANSFER_MIN_PORT); | ||
155 | JSONObject payloadTransferInfo = new JSONObject(); | 155 | JSONObject payloadTransferInfo = new JSONObject(); | ||
156 | payloadTransferInfo.put("port", server.getLocalPort()); | 156 | payloadTransferInfo.put("port", server.getLocalPort()); | ||
157 | np.setPayloadTransferInfo(payloadTransferInfo); | 157 | np.setPayloadTransferInfo(payloadTransferInfo); | ||
158 | } else { | 158 | } else { | ||
159 | server = null; | 159 | server = null; | ||
160 | } | 160 | } | ||
161 | 161 | | |||
▲ Show 20 Lines • Show All 96 Lines • ▼ Show 20 Line(s) | 257 | try { | |||
258 | np = RsaHelper.decrypt(np, privateKey); | 258 | np = RsaHelper.decrypt(np, privateKey); | ||
259 | } catch(Exception e) { | 259 | } catch(Exception e) { | ||
260 | e.printStackTrace(); | 260 | e.printStackTrace(); | ||
261 | Log.e("KDE/onPacketReceived","Exception decrypting the package"); | 261 | Log.e("KDE/onPacketReceived","Exception decrypting the package"); | ||
262 | } | 262 | } | ||
263 | } | 263 | } | ||
264 | 264 | | |||
265 | if (np.hasPayloadTransferInfo()) { | 265 | if (np.hasPayloadTransferInfo()) { | ||
266 | | ||||
267 | Socket payloadSocket = new Socket(); | 266 | Socket payloadSocket = new Socket(); | ||
268 | try { | 267 | try { | ||
269 | int tcpPort = np.getPayloadTransferInfo().getInt("port"); | 268 | int tcpPort = np.getPayloadTransferInfo().getInt("port"); | ||
270 | InetSocketAddress deviceAddress = (InetSocketAddress) socket.getRemoteSocketAddress(); | 269 | InetSocketAddress deviceAddress = (InetSocketAddress) socket.getRemoteSocketAddress(); | ||
271 | payloadSocket.connect(new InetSocketAddress(deviceAddress.getAddress(), tcpPort)); | 270 | payloadSocket.connect(new InetSocketAddress(deviceAddress.getAddress(), tcpPort)); | ||
272 | // Use ssl if existing link is on ssl | 271 | // Use ssl if existing link is on ssl | ||
273 | if (socket instanceof SSLSocket) { | 272 | if (socket instanceof SSLSocket) { | ||
274 | payloadSocket = SslHelper.convertToSslSocket(context, payloadSocket, getDeviceId(), true, true); | 273 | payloadSocket = SslHelper.convertToSslSocket(context, payloadSocket, getDeviceId(), true, true); | ||
Show All 24 Lines |