aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/ui/ConversationActivity.java
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-05-06 21:34:30 +0200
committerDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-05-06 21:34:30 +0200
commit461f2ffb16ebb877a1ab28e8815b07196e424a36 (patch)
tree6532617f4be9137d87077d0b49470ef2f47af8a0 /src/eu/siacs/conversations/ui/ConversationActivity.java
parentf7033cb7e06740576d23e1f8fbf473db337e13fe (diff)
basic pgp encrypted file transfer
Diffstat (limited to 'src/eu/siacs/conversations/ui/ConversationActivity.java')
-rw-r--r--src/eu/siacs/conversations/ui/ConversationActivity.java46
1 files changed, 43 insertions, 3 deletions
diff --git a/src/eu/siacs/conversations/ui/ConversationActivity.java b/src/eu/siacs/conversations/ui/ConversationActivity.java
index fc19ecc7..85025108 100644
--- a/src/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/eu/siacs/conversations/ui/ConversationActivity.java
@@ -6,7 +6,10 @@ import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
+import org.openintents.openpgp.OpenPgpError;
+
import eu.siacs.conversations.R;
+import eu.siacs.conversations.crypto.OnPgpEngineResult;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
@@ -18,9 +21,11 @@ import android.os.Bundle;
import android.preference.PreferenceManager;
import android.app.AlertDialog;
import android.app.FragmentTransaction;
+import android.app.PendingIntent;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
+import android.content.IntentSender.SendIntentException;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
@@ -59,6 +64,7 @@ public class ConversationActivity extends XmppActivity {
public static final int REQUEST_SEND_MESSAGE = 0x75441;
public static final int REQUEST_DECRYPT_PGP = 0x76783;
private static final int ATTACH_FILE = 0x48502;
+ private static final int REQUEST_SEND_PGP_IMAGE = 0x53883;
protected SlidingPaneLayout spl;
@@ -69,6 +75,8 @@ public class ConversationActivity extends XmppActivity {
private boolean paneShouldBeOpen = true;
private boolean useSubject = true;
private ArrayAdapter<Conversation> listAdapter;
+
+ public Message pendingMessage = null;
private OnConversationListChangedListener onConvChanged = new OnConversationListChangedListener() {
@@ -581,10 +589,42 @@ public class ConversationActivity extends XmppActivity {
selectedFragment.hidePgpPassphraseBox();
}
} else if (requestCode == ATTACH_FILE) {
- Conversation conversation = getSelectedConversation();
+ final Conversation conversation = getSelectedConversation();
String presence = conversation.getNextPresence();
- xmppConnectionService.attachImageToConversation(conversation, presence, data.getData());
-
+ if (conversation.nextMessageEncryption == Message.ENCRYPTION_NONE) {
+ xmppConnectionService.attachImageToConversation(conversation, presence, data.getData());
+ } else if (conversation.nextMessageEncryption == Message.ENCRYPTION_PGP) {
+ pendingMessage = xmppConnectionService.attachEncryptedImageToConversation(conversation, presence, data.getData(), new OnPgpEngineResult() {
+
+ @Override
+ public void userInputRequried(PendingIntent pi) {
+ Log.d(LOGTAG,"user input requried");
+ try {
+ startIntentSenderForResult(pi.getIntentSender(),
+ ConversationActivity.REQUEST_SEND_PGP_IMAGE, null, 0,
+ 0, 0);
+ } catch (SendIntentException e1) {
+ Log.d("xmppService","failed to start intent to send message");
+ }
+ }
+
+ @Override
+ public void success() {
+ conversation.getMessages().add(pendingMessage);
+ pendingMessage.setStatus(Message.STATUS_OFFERED);
+ xmppConnectionService.databaseBackend.createMessage(pendingMessage);
+ xmppConnectionService.sendMessage(pendingMessage, null);
+ xmppConnectionService.updateUi(conversation, false);
+ }
+
+ @Override
+ public void error(OpenPgpError openPgpError) {
+ Log.d(LOGTAG,"pgp error"+openPgpError.getMessage());
+ }
+ });
+ } else {
+ Log.d(LOGTAG,"unknown next message encryption: "+conversation.nextMessageEncryption);
+ }
}
}
}