Skip to content

Commit 0509770

Browse files
committed
I would call it release candidate
1 parent 2475c26 commit 0509770

5 files changed

Lines changed: 28 additions & 51 deletions

File tree

app/src/main/java/net/sharksystem/asap/android/ASAPAndroid.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ public class ASAPAndroid {
77
public static final String SENDER_E2E = "senderE2E";
88
public static final String FOLDER = "folder";
99
public static final String RECEIVER = "receiver";
10-
public static final String SENDER_POINT2POINT = "senderP2P";
11-
public static final String VERIFIED = "verified";
12-
public static final String ENCRYPTED = "encrypted";
13-
public static final String CONNECTION_TYPE = "connectionType";
10+
public static final String ASAP_HOP = "asapHop";
1411

1512
public static final String ASAP_CHUNK_RECEIVED_ACTION = "net.sharksystem.asap.received";
1613

app/src/main/java/net/sharksystem/asap/android/ASAPChunkReceivedBroadcastIntent.java

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22

33
import android.content.Intent;
44

5-
import net.sharksystem.EncounterConnectionType;
65
import net.sharksystem.SharkNotSupportedException;
76
import net.sharksystem.asap.ASAPException;
7+
import net.sharksystem.asap.ASAPHop;
8+
import net.sharksystem.asap.utils.ASAPSerialization;
9+
import net.sharksystem.utils.Log;
10+
11+
import java.io.IOException;
812

913
public class ASAPChunkReceivedBroadcastIntent extends Intent {
1014

11-
private final String senderPoint2Point;
12-
private final boolean verified;
13-
private final boolean encrypted;
14-
private final EncounterConnectionType connectionType;
15+
private final ASAPHop asapHop;
1516
private CharSequence folder;
1617
private CharSequence uri;
1718
private int era;
@@ -21,8 +22,7 @@ public class ASAPChunkReceivedBroadcastIntent extends Intent {
2122
public ASAPChunkReceivedBroadcastIntent(CharSequence format, CharSequence senderE2E,
2223
CharSequence folderName,
2324
CharSequence uri, int era,
24-
String senderPoint2Point, boolean verified, boolean encrypted,
25-
EncounterConnectionType connectionType) throws ASAPException {
25+
ASAPHop asapHop) throws ASAPException {
2626

2727
super();
2828

@@ -36,23 +36,24 @@ public ASAPChunkReceivedBroadcastIntent(CharSequence format, CharSequence sender
3636
this.putExtra(ASAPAndroid.FOLDER, folderName);
3737
this.putExtra(ASAPServiceMethods.URI_TAG, uri);
3838
this.putExtra(ASAPAndroid.SENDER_E2E, senderE2E);
39-
this.putExtra(ASAPAndroid.SENDER_POINT2POINT, senderPoint2Point);
40-
this.putExtra(ASAPAndroid.VERIFIED, verified);
41-
this.putExtra(ASAPAndroid.ENCRYPTED, encrypted);
42-
this.putExtra(ASAPAndroid.CONNECTION_TYPE, connectionType);
39+
try {
40+
byte[] asapHopBytes = ASAPSerialization.asapHop2ByteArray(asapHop);
41+
this.putExtra(ASAPAndroid.ASAP_HOP, asapHopBytes);
42+
}
43+
catch(IOException e) {
44+
// ignore
45+
Log.writeLogErr(this, "cannot serialize ASAPHop: " + asapHop);
46+
}
4347

4448
this.format = format;
4549
this.folder = folderName;
4650
this.uri = uri;
4751
this.era = era;
4852
this.senderE2E = senderE2E;
49-
this.senderPoint2Point = senderPoint2Point;
50-
this.verified = verified;
51-
this.encrypted = encrypted;
52-
this.connectionType = connectionType;
53+
this.asapHop = asapHop;
5354
}
5455

55-
public ASAPChunkReceivedBroadcastIntent(Intent intent) throws ASAPException {
56+
public ASAPChunkReceivedBroadcastIntent(Intent intent) throws ASAPException, IOException {
5657
super();
5758

5859
// just parse extras
@@ -61,10 +62,8 @@ public ASAPChunkReceivedBroadcastIntent(Intent intent) throws ASAPException {
6162
this.uri = intent.getStringExtra(ASAPServiceMethods.URI_TAG);
6263
this.era = intent.getIntExtra(ASAPServiceMethods.ERA_TAG, 0);
6364
this.senderE2E = intent.getStringExtra(ASAPAndroid.SENDER_E2E);
64-
this.senderPoint2Point = intent.getStringExtra(ASAPAndroid.SENDER_POINT2POINT);
65-
this.verified = intent.getBooleanExtra(ASAPAndroid.VERIFIED, false);
66-
this.encrypted = intent.getBooleanExtra(ASAPAndroid.ENCRYPTED, false);
67-
this.connectionType = null;
65+
byte[] asapHopBytes = intent.getByteArrayExtra(ASAPAndroid.ASAP_HOP);
66+
this.asapHop = ASAPSerialization.byteArray2ASAPHop(asapHopBytes);
6867
}
6968

7069
public CharSequence getFoldername() {
@@ -86,20 +85,7 @@ public int getEra() {
8685

8786
public CharSequence getFormat() { return this.format; }
8887

89-
public String getSenderPoint2Point() {
90-
return this.senderPoint2Point;
91-
}
92-
93-
public boolean getVerified() {
94-
return this.verified;
95-
}
96-
97-
public boolean getEncrypted() {
98-
return this.encrypted;
99-
}
100-
101-
// TODO
102-
public EncounterConnectionType getConnectionType() {
103-
throw new SharkNotSupportedException("no implemented yet");
88+
public ASAPHop getASAPHop() {
89+
return this.asapHop;
10490
}
10591
}

app/src/main/java/net/sharksystem/asap/android/apps/ASAPAndroidPeer.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -578,10 +578,7 @@ void chunkReceived(String format, String senderE2E, String uri, int era, // E2E
578578
asapReceivedIntent.getSenderE2E().toString(),
579579
asapReceivedIntent.getUri().toString(),
580580
asapReceivedIntent.getEra(),
581-
asapReceivedIntent.getSenderPoint2Point(),
582-
asapReceivedIntent.getVerified(),
583-
asapReceivedIntent.getEncrypted(),
584-
asapReceivedIntent.getConnectionType()
581+
asapReceivedIntent.getASAPHop()
585582
);
586583
} catch (ASAPException | IOException e) {
587584
Log.w(this.getLogStart(), "could call chunk received in local peer proxy: "

app/src/main/java/net/sharksystem/asap/android/example/ASAPExampleMessagingActivity.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import android.widget.EditText;
88
import android.widget.TextView;
99

10-
import net.sharksystem.EncounterConnectionType;
1110
import net.sharksystem.asap.ASAPException;
11+
import net.sharksystem.asap.ASAPHop;
1212
import net.sharksystem.asap.ASAPMessageReceivedListener;
1313
import net.sharksystem.asap.android.R;
1414
import net.sharksystem.asap.android.apps.ASAPActivity;
@@ -45,8 +45,7 @@ protected void onCreate(Bundle savedInstanceState) {
4545
@Override
4646
public void asapMessagesReceived(ASAPMessages asapMessages,
4747
String senderE2E, // E2E part
48-
String senderPoint2Point, boolean verified, boolean encrypted, // Point2Point part
49-
EncounterConnectionType connectionType) {
48+
ASAPHop asapHop) {
5049
Log.d(getLogStart(), "asapMessageReceived");
5150
ASAPExampleMessagingActivity.this.doHandleReceivedMessages(asapMessages);
5251
}

app/src/main/java/net/sharksystem/asap/android/service/ASAPService.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
import androidx.core.content.ContextCompat;
1212
import android.util.Log;
1313

14-
import net.sharksystem.EncounterConnectionType;
1514
import net.sharksystem.asap.ASAPEnvironmentChangesListener;
1615
import net.sharksystem.asap.ASAPException;
16+
import net.sharksystem.asap.ASAPHop;
1717
import net.sharksystem.asap.ASAPPeer;
1818
import net.sharksystem.asap.ASAPPeerFS;
1919
import net.sharksystem.asap.ASAPPeerService;
@@ -401,17 +401,15 @@ public void run() {
401401

402402
@Override
403403
public void chunkReceived(String format, String senderE2E, String uri, int era, // E2E part
404-
String senderPoint2Point, boolean verified, boolean encrypted, // Point2Point part
405-
EncounterConnectionType connectionType) {
404+
ASAPHop asapHop) {
406405

407406
Log.d(this.getLogStart(), "was notified by asap engine that chunk received - broadcast. Uri: "
408407
+ uri);
409408
// issue broadcast
410409
ASAPChunkReceivedBroadcastIntent intent = null;
411410
try {
412411
intent = new ASAPChunkReceivedBroadcastIntent(
413-
format, senderE2E, this.getASAPRootFolderName(), uri, era,
414-
senderPoint2Point, verified, encrypted, connectionType);
412+
format, senderE2E, this.getASAPRootFolderName(), uri, era, asapHop);
415413
} catch (ASAPException e) {
416414
e.printStackTrace();
417415
return;

0 commit comments

Comments
 (0)