Skip to content

Commit 2475c26

Browse files
committed
works with new ASAPJava version.
1 parent cb024c2 commit 2475c26

6 files changed

Lines changed: 94 additions & 19 deletions

File tree

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44
* Be sure to have the ASAPEngine in one of your library directories!
55
*/
66
public class ASAPAndroid {
7-
public static final String USER = "user";
7+
public static final String SENDER_E2E = "senderE2E";
88
public static final String FOLDER = "folder";
9-
public static final String RECIPIENT = "recipient";
9+
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";
1014

1115
public static final String ASAP_CHUNK_RECEIVED_ACTION = "net.sharksystem.asap.received";
1216

@@ -15,4 +19,5 @@ public class ASAPAndroid {
1519
public static final String ONLINE_EXCHANGE_PARAMETER_NAME = "ASAP_ONLINE_EXCHANGE";
1620
public static final String MAX_EXECUTION_TIME_PARAMETER_NAME = "ASAP_MAX_EXECUTION_TIME";
1721
public static final String SUPPORTED_FORMATS_PARAMETER_NAME = "ASAP_SUPPORTED_FORMATS";
22+
1823
}

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

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,54 @@
22

33
import android.content.Intent;
44

5+
import net.sharksystem.EncounterConnectionType;
6+
import net.sharksystem.SharkNotSupportedException;
57
import net.sharksystem.asap.ASAPException;
68

79
public class ASAPChunkReceivedBroadcastIntent extends Intent {
810

11+
private final String senderPoint2Point;
12+
private final boolean verified;
13+
private final boolean encrypted;
14+
private final EncounterConnectionType connectionType;
915
private CharSequence folder;
1016
private CharSequence uri;
1117
private int era;
12-
private CharSequence user;
18+
private CharSequence senderE2E;
1319
private CharSequence format;
1420

15-
public ASAPChunkReceivedBroadcastIntent(CharSequence format, CharSequence user, CharSequence folderName,
16-
CharSequence uri, int eraInt) throws ASAPException {
21+
public ASAPChunkReceivedBroadcastIntent(CharSequence format, CharSequence senderE2E,
22+
CharSequence folderName,
23+
CharSequence uri, int era,
24+
String senderPoint2Point, boolean verified, boolean encrypted,
25+
EncounterConnectionType connectionType) throws ASAPException {
26+
1727
super();
1828

19-
if(format == null || folderName == null || uri == null || user == null)
29+
if(format == null || folderName == null || uri == null || senderE2E == null)
2030
throw new ASAPException("parameters must no be null");
2131

2232
this.setAction(ASAPAndroid.ASAP_CHUNK_RECEIVED_ACTION);
2333

24-
this.putExtra(ASAPServiceMethods.ERA_TAG, eraInt);
34+
this.putExtra(ASAPServiceMethods.ERA_TAG, era);
2535
this.putExtra(ASAPServiceMethods.FORMAT_TAG, format);
2636
this.putExtra(ASAPAndroid.FOLDER, folderName);
2737
this.putExtra(ASAPServiceMethods.URI_TAG, uri);
28-
this.putExtra(ASAPAndroid.USER, user);
38+
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);
2943

3044
this.format = format;
3145
this.folder = folderName;
3246
this.uri = uri;
3347
this.era = era;
34-
this.user = user;
48+
this.senderE2E = senderE2E;
49+
this.senderPoint2Point = senderPoint2Point;
50+
this.verified = verified;
51+
this.encrypted = encrypted;
52+
this.connectionType = connectionType;
3553
}
3654

3755
public ASAPChunkReceivedBroadcastIntent(Intent intent) throws ASAPException {
@@ -42,7 +60,11 @@ public ASAPChunkReceivedBroadcastIntent(Intent intent) throws ASAPException {
4260
this.folder = intent.getStringExtra(ASAPAndroid.FOLDER);
4361
this.uri = intent.getStringExtra(ASAPServiceMethods.URI_TAG);
4462
this.era = intent.getIntExtra(ASAPServiceMethods.ERA_TAG, 0);
45-
this.user = intent.getStringExtra(ASAPAndroid.USER);
63+
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;
4668
}
4769

4870
public CharSequence getFoldername() {
@@ -53,13 +75,31 @@ public CharSequence getUri() {
5375
return this.uri;
5476
}
5577

56-
public CharSequence getUser() {
57-
return this.user;
78+
public CharSequence getSenderE2E() {
79+
// TODO E2ESender == owner???
80+
return this.senderE2E;
5881
}
5982

6083
public int getEra() {
6184
return this.era;
6285
}
6386

6487
public CharSequence getFormat() { return this.format; }
88+
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");
104+
}
65105
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public ASAPServiceCreationIntent(Activity activity, CharSequence owner, CharSequ
4242
this.onlineExchange = onlineExchange;
4343
this.maxExecutionTime = maxExecutionTime;
4444

45-
this.putExtra(ASAPAndroid.USER, owner);
45+
this.putExtra(ASAPAndroid.SENDER_E2E, owner);
4646
this.putExtra(ASAPAndroid.FOLDER, rootFolder);
4747
this.putExtra(ASAPAndroid.ONLINE_EXCHANGE_PARAMETER_NAME, onlineExchange);
4848
this.putExtra(ASAPAndroid.MAX_EXECUTION_TIME_PARAMETER_NAME, maxExecutionTime);
@@ -62,7 +62,7 @@ public ASAPServiceCreationIntent(Intent intent) {
6262
super();
6363

6464
// just parse extras
65-
this.owner = intent.getStringExtra(ASAPAndroid.USER);
65+
this.owner = intent.getStringExtra(ASAPAndroid.SENDER_E2E);
6666
this.rootFolder = intent.getStringExtra(ASAPAndroid.FOLDER);
6767
this.onlineExchange = intent.getBooleanExtra(ASAPAndroid.ONLINE_EXCHANGE_PARAMETER_NAME,
6868
ASAPPeer.ONLINE_EXCHANGE_DEFAULT);

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

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import android.util.Log;
1414
import android.widget.Toast;
1515

16+
import net.sharksystem.SharkNotSupportedException;
1617
import net.sharksystem.asap.ASAPEnvironmentChangesListener;
1718
import net.sharksystem.asap.ASAPException;
1819
import net.sharksystem.asap.ASAPMessageReceivedListener;
@@ -303,6 +304,16 @@ public ASAPStorage getASAPStorage(CharSequence format) throws IOException, ASAPE
303304
return this.getASAPPeerApplicationSide().getASAPStorage(format);
304305
}
305306

307+
@Override
308+
public boolean isASAPRoutingAllowed(CharSequence charSequence) throws IOException, ASAPException {
309+
throw new SharkNotSupportedException("no implemented yet");
310+
}
311+
312+
@Override
313+
public void setASAPRoutingAllowed(CharSequence charSequence, boolean b) throws IOException, ASAPException {
314+
throw new SharkNotSupportedException("no implemented yet");
315+
}
316+
306317
private void askForPermissions(Activity activity) {
307318
if(this.requiredPermissions.size() < 1) {
308319
Log.d(this.getLogStart(), "no further permissions to ask for");
@@ -556,12 +567,22 @@ public void onReceive(Context context, Intent intent) {
556567
ASAPChunkReceivedBroadcastIntent asapReceivedIntent
557568
= new ASAPChunkReceivedBroadcastIntent(intent);
558569

570+
/*
571+
void chunkReceived(String format, String senderE2E, String uri, int era, // E2E part
572+
String senderPoint2Point, boolean verified, boolean encrypted, // Point2Point part
573+
EncounterConnectionType connectionType) throws IOException;
574+
*/
559575
// delegate to local peer proxy
560576
this.getASAPPeerApplicationSide().chunkReceived(
561577
asapReceivedIntent.getFormat().toString(),
562-
asapReceivedIntent.getUser().toString(),
578+
asapReceivedIntent.getSenderE2E().toString(),
563579
asapReceivedIntent.getUri().toString(),
564-
asapReceivedIntent.getEra());
580+
asapReceivedIntent.getEra(),
581+
asapReceivedIntent.getSenderPoint2Point(),
582+
asapReceivedIntent.getVerified(),
583+
asapReceivedIntent.getEncrypted(),
584+
asapReceivedIntent.getConnectionType()
585+
);
565586
} catch (ASAPException | IOException e) {
566587
Log.w(this.getLogStart(), "could call chunk received in local peer proxy: "
567588
+ e.getLocalizedMessage());

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import android.widget.EditText;
88
import android.widget.TextView;
99

10+
import net.sharksystem.EncounterConnectionType;
1011
import net.sharksystem.asap.ASAPException;
1112
import net.sharksystem.asap.ASAPMessageReceivedListener;
1213
import net.sharksystem.asap.android.R;
@@ -42,7 +43,10 @@ protected void onCreate(Bundle savedInstanceState) {
4243

4344
this.receivedListener = new ASAPMessageReceivedListener() {
4445
@Override
45-
public void asapMessagesReceived(ASAPMessages asapMessages) {
46+
public void asapMessagesReceived(ASAPMessages asapMessages,
47+
String senderE2E, // E2E part
48+
String senderPoint2Point, boolean verified, boolean encrypted, // Point2Point part
49+
EncounterConnectionType connectionType) {
4650
Log.d(getLogStart(), "asapMessageReceived");
4751
ASAPExampleMessagingActivity.this.doHandleReceivedMessages(asapMessages);
4852
}

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

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

14+
import net.sharksystem.EncounterConnectionType;
1415
import net.sharksystem.asap.ASAPEnvironmentChangesListener;
1516
import net.sharksystem.asap.ASAPException;
1617
import net.sharksystem.asap.ASAPPeer;
@@ -399,14 +400,18 @@ public void run() {
399400
private List<ASAPChunkReceivedBroadcastIntent> chunkReceivedBroadcasts = new ArrayList<>();
400401

401402
@Override
402-
public void chunkReceived(String format, String sender, String uri, int era) {
403+
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) {
406+
403407
Log.d(this.getLogStart(), "was notified by asap engine that chunk received - broadcast. Uri: "
404408
+ uri);
405409
// issue broadcast
406410
ASAPChunkReceivedBroadcastIntent intent = null;
407411
try {
408412
intent = new ASAPChunkReceivedBroadcastIntent(
409-
format, sender, this.getASAPRootFolderName(), uri, era);
413+
format, senderE2E, this.getASAPRootFolderName(), uri, era,
414+
senderPoint2Point, verified, encrypted, connectionType);
410415
} catch (ASAPException e) {
411416
e.printStackTrace();
412417
return;

0 commit comments

Comments
 (0)