Commit e84fce76 authored by LIly's avatar LIly
Browse files

update bintray version, exampleapp

parent ee7c930c
......@@ -17,7 +17,7 @@ buildscript {
subprojects {
ext {
groupID = 'org.mpisws'
libraryVersion = '0.1.8'
libraryVersion = '0.1.0.1'
}
repositories {
jcenter()
......
......@@ -41,7 +41,7 @@
-dontnote com.google.android.gms.common.internal.**
# Preserve the options class
-keepclasseswithmembers class org.mpisws.encounters.clients.Options { *; }
-keepclasseswithmembers class org.mpisws.encounters.lib.Options { *; }
# Preserve all public classes, and their public and protected fields and
# methods.
......
......@@ -11,9 +11,9 @@ import org.mpisws.database.DBEncounterInfo;
import org.mpisws.embeddedsocial.ESClient;
import org.mpisws.embeddedsocial.ESMessage;
import org.mpisws.encounters.EncounterBasedCommunication;
import org.mpisws.encounters.encounterhistory.PMessagingChannels;
import org.mpisws.encounters.encounterhistory.PPrivateMessagingChannels;
import org.mpisws.encounters.encounterhistory.bridges.MessagingChannelsBridge;
import org.mpisws.encounters.encounterhistory.models.MMessagingChannel;
import org.mpisws.encounters.encounterhistory.models.MPrivateMessagingChannel;
import org.mpisws.encounters.lib.Preferences;
import org.mpisws.helpers.GlobalObjectRegistry;
import org.mpisws.helpers.Identifier;
......@@ -158,10 +158,10 @@ public class CommunicationClient implements EncounterBasedCommunication.ICommuni
@Override
public void getConversationOnPrivateChannel(String topicTitle, ESClient.GetReceivedMessagesCallback callback) {
MessagingChannelsBridge messagingChannelsBridge = new MessagingChannelsBridge(context);
MMessagingChannel mMessagingChannel = messagingChannelsBridge.getEntryFromTopicTitle(topicTitle);
MPrivateMessagingChannel mPrivateMessagingChannel = messagingChannelsBridge.getEntryFromTopicTitle(topicTitle);
ThreadPoolManager.getInstance().runTask(() -> {
String otherTopicHandle = mMessagingChannel.getOtherTopicHandle();
String otherTopicHandle = mPrivateMessagingChannel.getOtherTopicHandle();
if (otherTopicHandle == null || otherTopicHandle.compareTo("") == 0) {
otherTopicHandle = ESClient.getInstance().getOneTopicHandle(
new Identifier(Utils.hexStringToByteArray(topicTitle)));
......@@ -169,18 +169,18 @@ public class CommunicationClient implements EncounterBasedCommunication.ICommuni
return;
}
ContentValues values = new ContentValues();
values.put(PMessagingChannels.Columns.otherTopicHandle, otherTopicHandle);
messagingChannelsBridge.updateFromContentValues(mMessagingChannel.getPKID(), values);
values.put(PPrivateMessagingChannels.Columns.otherTopicHandle, otherTopicHandle);
messagingChannelsBridge.updateFromContentValues(mPrivateMessagingChannel.getPKID(), values);
}
List<ESMessage> messagesToMe = ESClient.getInstance().getMessagesOnTopic(mMessagingChannel.getMyTopicHandle());
List<ESMessage> messagesToMe = ESClient.getInstance().getMessagesOnTopic(mPrivateMessagingChannel.getMyTopicHandle());
List<ESMessage> messagesFromMe = ESClient.getInstance().getMessagesOnTopic(otherTopicHandle);
List<ReceivedMessageWrapper> recMessages = new ArrayList<>();
for (ESMessage msg : messagesToMe) {
recMessages.add(new ReceivedMessageWrapper(msg, mMessagingChannel.getSharedSecret()));
recMessages.add(new ReceivedMessageWrapper(msg, mPrivateMessagingChannel.getSharedSecret()));
}
for (ESMessage msg : messagesFromMe) {
recMessages.add(new ReceivedMessageWrapper(msg, mMessagingChannel.getSharedSecret()));
recMessages.add(new ReceivedMessageWrapper(msg, mPrivateMessagingChannel.getSharedSecret()));
}
// sort by oldest to newest
......
......@@ -9,17 +9,17 @@ import org.apache.commons.lang3.tuple.Pair;
import org.mpisws.embeddedsocial.ESClient;
import org.mpisws.embeddedsocial.ESMessage;
import org.mpisws.encounters.encounterformation.SDDR_Native;
import org.mpisws.encounters.encounterhistory.PMessagingChannels;
import org.mpisws.encounters.encounterhistory.PPrivateMessagingChannels;
import org.mpisws.encounters.encounterhistory.bridges.EncounterEntriesBridge;
import org.mpisws.encounters.encounterhistory.bridges.InitiateMessagingChannelsBridge;
import org.mpisws.encounters.encounterhistory.bridges.MessagingChannelsBridge;
import org.mpisws.encounters.encounterhistory.models.MInitiateMessagingChannel;
import org.mpisws.encounters.encounterhistory.models.MMessagingChannel;
import org.mpisws.encounters.encounterhistory.models.MInitiatePrivateMessagingChannel;
import org.mpisws.encounters.encounterhistory.models.MPrivateMessagingChannel;
import org.mpisws.helpers.Coder;
import org.mpisws.helpers.Identifier;
import org.mpisws.messaging.EncounterForwardingMessage;
import org.mpisws.messaging.InitiateMessageChannelMessage;
import org.mpisws.messaging.MessageChannelMessage;
import org.mpisws.messaging.InitiatePrivateMessagingMessage;
import org.mpisws.messaging.PrivateMessage;
import org.mpisws.messaging.ReceivedMessageWrapper;
import java.util.ArrayList;
......@@ -60,8 +60,8 @@ public class CommunicationHelpers {
ReceivedMessageWrapper receivedMessageWrapper,
Context context) {
MessagingChannelsBridge messagingChannelsBridge = new MessagingChannelsBridge(context);
MMessagingChannel mMessagingChannel = messagingChannelsBridge.getEntryFromTopicHandle(receivedMessageWrapper.getTopicHandle());
getMessagingChannelTopicHandleAndPostReply(replyMessageText, mMessagingChannel, messagingChannelsBridge);
MPrivateMessagingChannel mPrivateMessagingChannel = messagingChannelsBridge.getEntryFromTopicHandle(receivedMessageWrapper.getTopicHandle());
getMessagingChannelTopicHandleAndPostReply(replyMessageText, mPrivateMessagingChannel, messagingChannelsBridge);
}
public static void createKeyAndPostReplyToEncounterForwardingMessage (
......@@ -78,11 +78,11 @@ public class CommunicationHelpers {
}
// see if we've replied to this public key before; if so, follow the reply procedure
MMessagingChannel mMessagingChannel = messagingChannelsBridge.getEntryFromOtherPubKey(otherPubKey);
if (mMessagingChannel != null) {
MPrivateMessagingChannel mPrivateMessagingChannel = messagingChannelsBridge.getEntryFromOtherPubKey(otherPubKey);
if (mPrivateMessagingChannel != null) {
getMessagingChannelTopicHandleAndPostReply(
replyMessageText,
mMessagingChannel,
mPrivateMessagingChannel,
messagingChannelsBridge);
return;
}
......@@ -119,13 +119,13 @@ public class CommunicationHelpers {
secretId, channelName, myTopicHandle, null);
// post the initial message and our message on our channel
String encryptedMessageTextOriginal = new MessageChannelMessage.MessageChannelMessageBuilder()
String encryptedMessageTextOriginal = new PrivateMessage.MessageChannelMessageBuilder()
.addMessage(encounterForwardingMessage.getMsgText())
.build()
.toSendMessageText(secret);
// post our message on our channel
String encryptedMessageTextReply = new MessageChannelMessage.MessageChannelMessageBuilder()
String encryptedMessageTextReply = new PrivateMessage.MessageChannelMessageBuilder()
.addMessage(replyMessageText)
.build()
.toSendMessageText(secret);
......@@ -137,7 +137,7 @@ public class CommunicationHelpers {
// post our public key on their channel (note that we need to do this last, since
// they might query for our message as soon as they receive this post)
String publicKeyText = new InitiateMessageChannelMessage.InitiateMessageChannelMessageBuilder()
String publicKeyText = new InitiatePrivateMessagingMessage.InitiateMessageChannelMessageBuilder()
.addPublicKey(myPublicKey)
.build()
.toSendMessageText();
......@@ -147,42 +147,42 @@ public class CommunicationHelpers {
public static void getMessagingChannelTopicHandleAndPostReply(
String replyText,
MMessagingChannel mMessagingChannel,
MPrivateMessagingChannel mPrivateMessagingChannel,
MessagingChannelsBridge messagingChannelsBridge)
{
if (mMessagingChannel == null) return;
if (mPrivateMessagingChannel == null) return;
// get the other topic handle if it exists
String otherTopicHandle = mMessagingChannel.getOtherTopicHandle();
String otherTopicHandle = mPrivateMessagingChannel.getOtherTopicHandle();
if (otherTopicHandle == null || otherTopicHandle.compareTo("") ==0) {
otherTopicHandle = ESClient.getInstance().getOneTopicHandle(new Identifier(mMessagingChannel.getChannelName()));
otherTopicHandle = ESClient.getInstance().getOneTopicHandle(new Identifier(mPrivateMessagingChannel.getChannelName()));
}
if (otherTopicHandle != null) {
// if found, update our database entry
ContentValues values = new ContentValues();
values.put(PMessagingChannels.Columns.otherTopicHandle, otherTopicHandle);
messagingChannelsBridge.updateFromContentValues(mMessagingChannel.getPKID(), values);
values.put(PPrivateMessagingChannels.Columns.otherTopicHandle, otherTopicHandle);
messagingChannelsBridge.updateFromContentValues(mPrivateMessagingChannel.getPKID(), values);
}
String encryptedPrivateMessageText = new MessageChannelMessage.MessageChannelMessageBuilder()
String encryptedPrivateMessageText = new PrivateMessage.MessageChannelMessageBuilder()
.addMessage(replyText)
.build()
.toSendMessageText(mMessagingChannel.getSharedSecret());
.toSendMessageText(mPrivateMessagingChannel.getSharedSecret());
Log.d(TAG, "Posting reply to private message " + replyText + ", encrypted " + encryptedPrivateMessageText);
// post our message on their channel if we found the topic handle; if not, post on our channel
// (they'll have to get the whole channel messages to receive this one)
ESClient.getInstance().sendOneMessage(encryptedPrivateMessageText,
otherTopicHandle == null ? mMessagingChannel.getMyTopicHandle() : otherTopicHandle);
otherTopicHandle == null ? mPrivateMessagingChannel.getMyTopicHandle() : otherTopicHandle);
}
public static List<ReceivedMessageWrapper> createPrivateChannelAndGetReply(ReceivedMessageWrapper msgWrapper, Context context) {
// (1) create shared secret
InitiateMessageChannelMessage initiateMessageChannelMessage = msgWrapper.getInitiateMessageChannelMessage();
InitiatePrivateMessagingMessage initiateMessageChannelMessage = msgWrapper.getInitiateMessageChannelMessage();
MInitiateMessagingChannel mInitiateMessagingChannel =
MInitiatePrivateMessagingChannel mInitiatePrivateMessagingChannel =
new InitiateMessagingChannelsBridge(context).getEntryWithTopicHandle(msgWrapper.getTopicHandle());
byte[] dhKey = mInitiateMessagingChannel.getMyDHPrivKey();
byte[] dhKey = mInitiatePrivateMessagingChannel.getMyDHPrivKey();
byte[] secret = SDDR_Native.c_computeSecretKey(dhKey, initiateMessageChannelMessage.getPublicKey().getBytes());
if (secret == null) return null;
Identifier secretId = new Identifier(secret);
......@@ -201,7 +201,7 @@ public class CommunicationHelpers {
}
// (4) insert into database
new MessagingChannelsBridge(context).insertEntry(new Identifier(mInitiateMessagingChannel.getMyDHPubKey()),
new MessagingChannelsBridge(context).insertEntry(new Identifier(mInitiatePrivateMessagingChannel.getMyDHPubKey()),
secretId, channelName, myTopicHandle, otherTopicHandle);
// (5) get the message they posted for us to read (on their channel)
......@@ -242,7 +242,7 @@ public class CommunicationHelpers {
Log.d(TAG, "Found EEB secret with topic handle " + msg.getTopicHandle() + ", "
+ ((secret == null) ? "" : new Identifier(secret).toString()));
}
if (msg.getMsgText() != null && (secret != null || msg.getMsgText().contains(InitiateMessageChannelMessage.FLAG))) {
if (msg.getMsgText() != null && (secret != null || msg.getMsgText().contains(InitiatePrivateMessagingMessage.FLAG))) {
ReceivedMessageWrapper receivedMessageWrapper = new ReceivedMessageWrapper(msg, secret);
if (receivedMessageWrapper.getMsgType() == NONE)
continue;
......@@ -268,7 +268,7 @@ public class CommunicationHelpers {
Log.d(TAG, "Found EEB secret with topic handle " + msg.getTopicHandle() + ", "
+ ((secret == null) ? "" : new Identifier(secret).toString()));
}
if (msg.getMsgText() != null && (secret != null || msg.getMsgText().contains(InitiateMessageChannelMessage.FLAG))) {
if (msg.getMsgText() != null && (secret != null || msg.getMsgText().contains(InitiatePrivateMessagingMessage.FLAG))) {
ReceivedMessageWrapper receivedMessageWrapper = new ReceivedMessageWrapper(msg, secret);
if (receivedMessageWrapper.getMsgType() == NONE)
continue;
......
......@@ -24,8 +24,8 @@ public class EncounterHistoryAPM extends AggregatePersistenceModel {
private static final EncounterHistoryAPM instance = new EncounterHistoryAPM();
public static final PEncounterEntries encounterEntries = PEncounterEntries.getInstance();
public static final PLocation locations = PLocation.getInstance();
public static final PMessagingChannels messageChannels = PMessagingChannels.getInstance();
public static final PInitiateMessagingChannels initiateMessagingChannels = PInitiateMessagingChannels.getInstance();
public static final PPrivateMessagingChannels messageChannels = PPrivateMessagingChannels.getInstance();
public static final PInitiatePrivateMessagingChannels initiateMessagingChannels = PInitiatePrivateMessagingChannels.getInstance();
public static final List<DBModel> models = new LinkedList<>();
static {
......
......@@ -2,15 +2,14 @@ package org.mpisws.encounters.encounterhistory;
import android.database.Cursor;
import org.mpisws.database.databaseSchema.DBInitiateMessagingChannels;
import org.mpisws.database.databaseSchema.DBMessagingChannels;
import org.mpisws.database.databaseSchema.DBInitiatePrivateMessagingChannels;
public class PInitiateMessagingChannels extends DBInitiateMessagingChannels {
private static PInitiateMessagingChannels instance = new PInitiateMessagingChannels();
private PInitiateMessagingChannels() {
public class PInitiatePrivateMessagingChannels extends DBInitiatePrivateMessagingChannels {
private static PInitiatePrivateMessagingChannels instance = new PInitiatePrivateMessagingChannels();
private PInitiatePrivateMessagingChannels() {
super();
};
public static PInitiateMessagingChannels getInstance() {return instance;}
public static PInitiatePrivateMessagingChannels getInstance() {return instance;}
public static String extractPubKeyTopicHandle(final Cursor cursor) {
return cursor.getString(cursor.getColumnIndexOrThrow(Columns.pubKeyTopicHandle));
......
......@@ -2,21 +2,21 @@ package org.mpisws.encounters.encounterhistory;
import android.database.Cursor;
import org.mpisws.database.databaseSchema.DBMessagingChannels;
import org.mpisws.database.databaseSchema.DBPrivateMessagingChannels;
public class PMessagingChannels extends DBMessagingChannels {
private static PMessagingChannels instance = new PMessagingChannels();
private PMessagingChannels() {
public class PPrivateMessagingChannels extends DBPrivateMessagingChannels {
private static PPrivateMessagingChannels instance = new PPrivateMessagingChannels();
private PPrivateMessagingChannels() {
super();
};
public static PMessagingChannels getInstance() {return instance;}
public static PPrivateMessagingChannels getInstance() {return instance;}
public static String extractMyTopicHandle(final Cursor cursor) {
return cursor.getString(cursor.getColumnIndexOrThrow(DBMessagingChannels.Columns.myTopicHandle));
return cursor.getString(cursor.getColumnIndexOrThrow(DBPrivateMessagingChannels.Columns.myTopicHandle));
}
public static String extractOtherTopicHandle(final Cursor cursor) {
return cursor.getString(cursor.getColumnIndexOrThrow(DBMessagingChannels.Columns.otherTopicHandle));
return cursor.getString(cursor.getColumnIndexOrThrow(DBPrivateMessagingChannels.Columns.otherTopicHandle));
}
public static byte[] extractSharedSecret(final Cursor cursor) {
......
......@@ -231,7 +231,10 @@ public class EncounterEntriesBridge extends AbstractEncountersBridge<MEncounterE
String whereClause = "HEX(" + PEncounterEntries.Columns.receivedNonce + ") = ? AND HEX(" + PEncounterEntries.Columns.myNonce + ") = ?";
String[] selectArgs = new String[] {MEncounterEntry.getReceivedNonce().toString(), MEncounterEntry.getMyNonce().toString()};
int updatedRows = context.getContentResolver().update(EncounterHistoryAPM.getContentURI(EncounterHistoryAPM.encounterEntries), values, whereClause, selectArgs);
Utils.myAssert(updatedRows == 1);
if (updatedRows == 1) {
Log.e(TAG, "UPDATED " + updatedRows + " ROWS WITH NONCES " +
MEncounterEntry.getReceivedNonce().toString() + " and " + MEncounterEntry.getMyNonce().toString());
}
/* FIREBASE: log encounter confirm event
Bundle params = new Bundle();
......
......@@ -6,17 +6,13 @@ import android.content.Context;
import android.database.Cursor;
import org.mpisws.database.DBModel;
import org.mpisws.database.databaseSchema.DBInitiateMessagingChannels;
import org.mpisws.encounters.dbplatform.AbstractEncountersBridge;
import org.mpisws.encounters.encounterhistory.EncounterHistoryAPM;
import org.mpisws.encounters.encounterhistory.PInitiateMessagingChannels;
import org.mpisws.encounters.encounterhistory.PMessagingChannels;
import org.mpisws.encounters.encounterhistory.models.MInitiateMessagingChannel;
import org.mpisws.encounters.encounterhistory.models.MMessagingChannel;
import org.mpisws.helpers.Coder;
import org.mpisws.encounters.encounterhistory.PInitiatePrivateMessagingChannels;
import org.mpisws.encounters.encounterhistory.models.MInitiatePrivateMessagingChannel;
import org.mpisws.helpers.Identifier;
public class InitiateMessagingChannelsBridge extends AbstractEncountersBridge<MInitiateMessagingChannel> {
public class InitiateMessagingChannelsBridge extends AbstractEncountersBridge<MInitiatePrivateMessagingChannel> {
private static final String TAG = InitiateMessagingChannelsBridge.class.getSimpleName();
private final ContentResolver contentResolver;
private final Context context;
......@@ -33,33 +29,33 @@ public class InitiateMessagingChannelsBridge extends AbstractEncountersBridge<MI
}
@Override
protected ContentValues itemToContentValues(MInitiateMessagingChannel item) {
protected ContentValues itemToContentValues(MInitiatePrivateMessagingChannel item) {
return null;
}
@Override
public MInitiateMessagingChannel cursorToItem(Cursor cursor) {
public MInitiatePrivateMessagingChannel cursorToItem(Cursor cursor) {
final long pkID = EncounterHistoryAPM.extractPKID(cursor);
return new MInitiateMessagingChannel(
return new MInitiatePrivateMessagingChannel(
pkID,
PInitiateMessagingChannels.extractMyDHPrivKey(cursor),
PInitiateMessagingChannels.extractMyDHPubKey(cursor),
PInitiateMessagingChannels.extractPubKeyTopicHandle(cursor));
PInitiatePrivateMessagingChannels.extractMyDHPrivKey(cursor),
PInitiatePrivateMessagingChannels.extractMyDHPubKey(cursor),
PInitiatePrivateMessagingChannels.extractPubKeyTopicHandle(cursor));
}
public void insertEntry(Identifier myDHPrivKey, Identifier myDHPubKey, String pubKeyTopicHandle) {
final ContentValues values = new ContentValues();
values.put(PInitiateMessagingChannels.Columns.myDHPrivKey, myDHPrivKey.getBytes());
values.put(PInitiateMessagingChannels.Columns.myDHPubKey, myDHPubKey.getBytes());
values.put(PInitiateMessagingChannels.Columns.pubKeyTopicHandle, pubKeyTopicHandle);
values.put(PInitiatePrivateMessagingChannels.Columns.myDHPrivKey, myDHPrivKey.getBytes());
values.put(PInitiatePrivateMessagingChannels.Columns.myDHPubKey, myDHPubKey.getBytes());
values.put(PInitiatePrivateMessagingChannels.Columns.pubKeyTopicHandle, pubKeyTopicHandle);
context.getContentResolver().insert(EncounterHistoryAPM.getContentURI(EncounterHistoryAPM.initiateMessagingChannels), values);
}
public MInitiateMessagingChannel getEntryWithTopicHandle(final String topicHandle) {
MInitiateMessagingChannel result = null;
public MInitiatePrivateMessagingChannel getEntryWithTopicHandle(final String topicHandle) {
MInitiatePrivateMessagingChannel result = null;
final Cursor cursor = context.getContentResolver().query(EncounterHistoryAPM.getContentURI(EncounterHistoryAPM.initiateMessagingChannels), null,
PInitiateMessagingChannels.Columns.pubKeyTopicHandle + " = ?", new String[] { topicHandle }, null);
PInitiatePrivateMessagingChannels.Columns.pubKeyTopicHandle + " = ?", new String[] { topicHandle }, null);
if (cursor.moveToNext()) {
result = cursorToItem(cursor);
}
......
......@@ -4,36 +4,16 @@ import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import com.google.firebase.analytics.FirebaseAnalytics;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.mpisws.database.DBEncounterInfo;
import org.mpisws.database.DBModel;
import org.mpisws.database.databaseSchema.DBEncounterEntries;
import org.mpisws.database.databaseSchema.DBMessagingChannels;
import org.mpisws.encounters.dbplatform.AbstractEncountersBridge;
import org.mpisws.encounters.encounterhistory.EncounterHistoryAPM;
import org.mpisws.encounters.encounterhistory.PEncounterEntries;
import org.mpisws.encounters.encounterhistory.PMessagingChannels;
import org.mpisws.encounters.encounterhistory.models.MEncounterEntry;
import org.mpisws.encounters.encounterhistory.models.MLocation;
import org.mpisws.encounters.encounterhistory.models.MMessagingChannel;
import org.mpisws.encounters.lib.time.TimeInterval;
import org.mpisws.helpers.Coder;
import org.mpisws.helpers.GlobalObjectRegistry;
import org.mpisws.encounters.encounterhistory.PPrivateMessagingChannels;
import org.mpisws.encounters.encounterhistory.models.MPrivateMessagingChannel;
import org.mpisws.helpers.Identifier;
import org.mpisws.helpers.Utils;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
public class MessagingChannelsBridge extends AbstractEncountersBridge<MMessagingChannel> {
public class MessagingChannelsBridge extends AbstractEncountersBridge<MPrivateMessagingChannel> {
private static final String TAG = MessagingChannelsBridge.class.getSimpleName();
private final ContentResolver contentResolver;
private final Context context;
......@@ -50,36 +30,36 @@ public class MessagingChannelsBridge extends AbstractEncountersBridge<MMessaging
}
@Override
protected ContentValues itemToContentValues(MMessagingChannel item) {
protected ContentValues itemToContentValues(MPrivateMessagingChannel item) {
throw new UnsupportedOperationException();
}
@Override
public MMessagingChannel cursorToItem(Cursor cursor) {
public MPrivateMessagingChannel cursorToItem(Cursor cursor) {
final long pkID = EncounterHistoryAPM.extractPKID(cursor);
return new MMessagingChannel(
return new MPrivateMessagingChannel(
pkID,
PMessagingChannels.extractChannelName(cursor),
PMessagingChannels.extractSharedSecret(cursor),
PMessagingChannels.extractMyTopicHandle(cursor),
PMessagingChannels.extractOtherTopicHandle(cursor));
PPrivateMessagingChannels.extractChannelName(cursor),
PPrivateMessagingChannels.extractSharedSecret(cursor),
PPrivateMessagingChannels.extractMyTopicHandle(cursor),
PPrivateMessagingChannels.extractOtherTopicHandle(cursor));
}
public void insertEntry(Identifier otherPubKey, Identifier sharedSecret, Identifier channelName, String myTopicHandle, String otherTopicHandle) {
Log.d(TAG, "Inserting entry for channel " + channelName.toString() + ", " + myTopicHandle + ", " + otherTopicHandle);
final ContentValues values = new ContentValues();
values.put(PMessagingChannels.Columns.otherPubKey, otherPubKey.getBytes());
values.put(PMessagingChannels.Columns.channelName, channelName.getBytes());
values.put(PMessagingChannels.Columns.sharedSecret, sharedSecret.getBytes());
values.put(PMessagingChannels.Columns.myTopicHandle, myTopicHandle);
values.put(PMessagingChannels.Columns.otherTopicHandle, otherTopicHandle);
values.put(PPrivateMessagingChannels.Columns.otherPubKey, otherPubKey.getBytes());
values.put(PPrivateMessagingChannels.Columns.channelName, channelName.getBytes());
values.put(PPrivateMessagingChannels.Columns.sharedSecret, sharedSecret.getBytes());
values.put(PPrivateMessagingChannels.Columns.myTopicHandle, myTopicHandle);
values.put(PPrivateMessagingChannels.Columns.otherTopicHandle, otherTopicHandle);
context.getContentResolver().insert(EncounterHistoryAPM.getContentURI(EncounterHistoryAPM.messageChannels), values);
}
public byte[] getSharedSecretByTopicHandle(final String myTopicHandle) {
byte[] result = null;
final Cursor cursor = context.getContentResolver().query(EncounterHistoryAPM.getContentURI(EncounterHistoryAPM.messageChannels), null,
PMessagingChannels.Columns.myTopicHandle + " = ?", new String[] { myTopicHandle }, null);
PPrivateMessagingChannels.Columns.myTopicHandle + " = ?", new String[] { myTopicHandle }, null);
if (cursor.moveToNext()) {
result = EncounterHistoryAPM.messageChannels.extractSharedSecret(cursor);
}
......@@ -87,11 +67,11 @@ public class MessagingChannelsBridge extends AbstractEncountersBridge<MMessaging
return result;
}
public MMessagingChannel getEntryFromTopicHandle(final String myTopicHandle) {
public MPrivateMessagingChannel getEntryFromTopicHandle(final String myTopicHandle) {
Log.d(TAG, "Getting entry with topic handle " + myTopicHandle);
MMessagingChannel result = null;
MPrivateMessagingChannel result = null;
final Cursor cursor = context.getContentResolver().query(EncounterHistoryAPM.getContentURI(EncounterHistoryAPM.messageChannels), null,
PMessagingChannels.Columns.myTopicHandle + " = ?", new String[] { myTopicHandle }, null);
PPrivateMessagingChannels.Columns.myTopicHandle + " = ?", new String[] { myTopicHandle }, null);
if (cursor.moveToNext()) {
result = cursorToItem(cursor);
}
......@@ -99,11 +79,11 @@ public class MessagingChannelsBridge extends AbstractEncountersBridge<MMessaging
return result;
}
public MMessagingChannel getEntryFromTopicTitle(String topicTitle) {
public MPrivateMessagingChannel getEntryFromTopicTitle(String topicTitle) {
Log.d(TAG, "Getting entry with topic title " + topicTitle);
MMessagingChannel result = null;
MPrivateMessagingChannel result = null;
final Cursor cursor = context.getContentResolver().query(EncounterHistoryAPM.getContentURI(EncounterHistoryAPM.messageChannels), null,
"HEX("+PMessagingChannels.Columns.channelName+")" + " = ?", new String[] { topicTitle }, null);
"HEX("+ PPrivateMessagingChannels.Columns.channelName+")" + " = ?", new String[] { topicTitle }, null);
if (cursor.moveToNext()) {
result = cursorToItem(cursor);
}
......@@ -111,10 +91,10 @@ public class MessagingChannelsBridge extends AbstractEncountersBridge<MMessaging
return result;
}
public MMessagingChannel getEntryFromOtherPubKey(String otherPubKey) {
MMessagingChannel result = null;
public MPrivateMessagingChannel getEntryFromOtherPubKey(String otherPubKey) {
MPrivateMessagingChannel result = null;
final Cursor cursor = context.getContentResolver().query(EncounterHistoryAPM.getContentURI(EncounterHistoryAPM.messageChannels), null,
"HEX("+PMessagingChannels.Columns.otherPubKey +")" + " = ?", new String[] { otherPubKey }, null);
"HEX("+ PPrivateMessagingChannels.Columns.otherPubKey +")" + " = ?", new String[] { otherPubKey }, null);
if (cursor.moveToNext()) {
result = cursorToItem(cursor);
}
......
......@@ -2,7 +2,7 @@ package org.mpisws.encounters.encounterhistory.models;
import org.mpisws.encounters.dbplatform.AbstractMemoryObject;
public class MInitiateMessagingChannel extends AbstractMemoryObject {
public class MInitiatePrivateMessagingChannel extends AbstractMemoryObject {
private long pkid;
private String pubKeyTopicHandle;
......@@ -25,7 +25,7 @@ public class MInitiateMessagingChannel extends AbstractMemoryObject {
return myDHPubKey;
}
public MInitiateMessagingChannel(long pkid, byte[] myDHPrivKey, byte[]myDHPubKey, String pubKeyTopicHandle) {
public MInitiatePrivateMessagingChannel(long pkid, byte[] myDHPrivKey, byte[]myDHPubKey, String pubKeyTopicHandle) {
super(pkid);
this.pkid = pkid;
this.myDHPrivKey = myDHPrivKey;
......
......@@ -2,7 +2,7 @@ package org.mpisws.encounters.encounterhistory.models;
import org.mpisws.encounters.dbplatform.AbstractMemoryObject;
public class MMessagingChannel extends AbstractMemoryObject {
public class MPrivateMessagingChannel extends AbstractMemoryObject {
long pkid;
private byte[] channelName;
private byte[] sharedSecret;
......@@ -25,7 +25,7 @@ public class MMessagingChannel extends AbstractMemoryObject {
return otherTopicHandle;
}
public MMessagingChannel(long pkid, byte[] channelName, byte[] sharedSecret, String myTopicHandle, String otherTopicHandle) {
public MPrivateMessagingChannel(long pkid, byte[] channelName, byte[] sharedSecret, String myTopicHandle, String otherTopicHandle) {
super(pkid);
this.pkid = pkid;
this.channelName = channelName;
......
......@@ -22,6 +22,5 @@ COMMON_SOURCE_FILES += third-party/jerasure/reed_sol.c
COMMON_SOURCE_FILES += source/BloomFilter.cpp
COMMON_SOURCE_FILES += source/SegmentedBloomFilter.cpp
COMMON_SOURCE_FILES += source/SDDRRadio.cpp
#COMMON_SOURCE_FILES += source/SSLClient.cpp
EXECUTABLE_SOURCE_FILES += c_SDDRRadio.cpp
EXECUTABLE_SOURCE_FILES += source/sddr.pb.cc