aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Straub <andreas.straub@rwth-aachen.de>2015-06-25 17:01:42 +0200
committerAndreas Straub <andy@strb.org>2015-07-05 17:26:19 +0200
commite8e126f2ce815165c27d27331690c488e48d0231 (patch)
tree3e29ac1132024667fa92c5e1d3157b443825ed4c
parent61f18d4dfc6afe2d9fb8f6cdc3b2f4cf410b5259 (diff)
Added axolotl activation code to UI
-rw-r--r--src/main/java/eu/siacs/conversations/services/XmppConnectionService.java9
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java20
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationActivity.java18
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationFragment.java10
-rw-r--r--src/main/java/eu/siacs/conversations/ui/XmppActivity.java23
5 files changed, 80 insertions, 0 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
index ae9acf2e..d852341b 100644
--- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
@@ -757,6 +757,15 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
}
}
break;
+ case Message.ENCRYPTION_AXOLOTL:
+ try {
+ packet = mMessageGenerator.generateAxolotlChat(message);
+ Log.d(Config.LOGTAG, "Succeeded generating axolotl chat message!");
+ } catch (NoSessionsCreatedException e) {
+ message.setStatus(Message.STATUS_WAITING);
+ }
+ break;
+
}
if (packet != null) {
if (account.getXmppConnection().getFeatures().sm() || conversation.getMode() == Conversation.MODE_MULTI) {
diff --git a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java
index c190caed..fb04946a 100644
--- a/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ContactDetailsActivity.java
@@ -29,6 +29,7 @@ import android.widget.QuickContactBadge;
import android.widget.TextView;
import org.openintents.openpgp.util.OpenPgpUtils;
+import org.whispersystems.libaxolotl.IdentityKey;
import java.util.List;
@@ -376,6 +377,25 @@ public class ContactDetailsActivity extends XmppActivity implements OnAccountUpd
}
});
}
+ for(final IdentityKey identityKey:contact.getAxolotlIdentityKeys()) {
+ hasKeys = true;
+ View view = inflater.inflate(R.layout.contact_key, keys, false);
+ TextView key = (TextView) view.findViewById(R.id.key);
+ TextView keyType = (TextView) view.findViewById(R.id.key_type);
+ ImageButton remove = (ImageButton) view
+ .findViewById(R.id.button_remove);
+ remove.setVisibility(View.VISIBLE);
+ keyType.setText("Axolotl Fingerprint");
+ key.setText(identityKey.getFingerprint());
+ keys.addView(view);
+ remove.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ //confirmToDeleteFingerprint(otrFingerprint);
+ }
+ });
+ }
if (contact.getPgpKeyId() != 0) {
hasKeys = true;
View view = inflater.inflate(R.layout.contact_key, keys, false);
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
index 770129ab..41a8cda6 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
@@ -16,6 +16,7 @@ import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v4.widget.SlidingPaneLayout;
import android.support.v4.widget.SlidingPaneLayout.PanelSlideListener;
+import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@@ -34,6 +35,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Blockable;
@@ -752,6 +754,17 @@ public class ConversationActivity extends XmppActivity
showInstallPgpDialog();
}
break;
+ case R.id.encryption_choice_axolotl:
+ Log.d(Config.LOGTAG, "Trying to enable axolotl...");
+ if(conversation.getAccount().getAxolotlService().isContactAxolotlCapable(conversation.getContact())) {
+ Log.d(Config.LOGTAG, "Enabled axolotl for Contact " + conversation.getContact().getJid() );
+ conversation.setNextEncryption(Message.ENCRYPTION_AXOLOTL);
+ item.setChecked(true);
+ } else {
+ Log.d(Config.LOGTAG, "Contact " + conversation.getContact().getJid() + " not axolotl capable!");
+ showAxolotlNoSessionsDialog();
+ }
+ break;
default:
conversation.setNextEncryption(Message.ENCRYPTION_NONE);
break;
@@ -784,6 +797,11 @@ public class ConversationActivity extends XmppActivity
popup.getMenu().findItem(R.id.encryption_choice_pgp)
.setChecked(true);
break;
+ case Message.ENCRYPTION_AXOLOTL:
+ Log.d(Config.LOGTAG, "Axolotl confirmed. Setting menu item checked!");
+ popup.getMenu().findItem(R.id.encryption_choice_axolotl)
+ .setChecked(true);
+ break;
default:
popup.getMenu().findItem(R.id.encryption_choice_none)
.setChecked(true);
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
index 20c6681b..1da2b519 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
@@ -302,6 +302,8 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
sendOtrMessage(message);
} else if (conversation.getNextEncryption(activity.forceEncryption()) == Message.ENCRYPTION_PGP) {
sendPgpMessage(message);
+ } else if (conversation.getNextEncryption(activity.forceEncryption()) == Message.ENCRYPTION_AXOLOTL) {
+ sendAxolotlMessage(message);
} else {
sendPlainTextMessage(message);
}
@@ -1114,6 +1116,14 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
builder.create().show();
}
+ protected void sendAxolotlMessage(final Message message) {
+ final ConversationActivity activity = (ConversationActivity) getActivity();
+ final XmppConnectionService xmppService = activity.xmppConnectionService;
+ //message.setCounterpart(conversation.getNextCounterpart());
+ xmppService.sendMessage(message);
+ messageSent();
+ }
+
protected void sendOtrMessage(final Message message) {
final ConversationActivity activity = (ConversationActivity) getActivity();
final XmppConnectionService xmppService = activity.xmppConnectionService;
diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
index 934c696f..e916598f 100644
--- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java
@@ -266,6 +266,29 @@ public abstract class XmppActivity extends Activity {
builder.create().show();
}
+ public void showAxolotlNoSessionsDialog() {
+ Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle("No Sessions");
+ builder.setIconAttribute(android.R.attr.alertDialogIcon);
+ builder.setMessage("Your contact is not Axolotl-capable!");
+ builder.setNegativeButton(getString(R.string.cancel), null);
+ builder.setNeutralButton("Foo",
+ new OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ }
+ });
+ builder.setPositiveButton("Bar",
+ new OnClickListener() {
+
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ }
+ });
+ builder.create().show();
+ }
+
abstract void onBackendConnected();
protected void registerListeners() {