aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/crypto
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2014-05-12 14:59:46 +0200
committerDaniel Gultsch <daniel@gultsch.de>2014-05-12 14:59:46 +0200
commit3455d10a4a87916bfe5da52ca9c401dafa8d5155 (patch)
treee7b6cc4520ad0dd64e348d2e9a27ffe7a81db696 /src/eu/siacs/conversations/crypto
parent4d0bf7971ec321a55f180b833b033ceaa6635fdf (diff)
Better error handling if attach file doesnt work (on permission denied)
and unified encrypted and unencrypted file attachment
Diffstat (limited to 'src/eu/siacs/conversations/crypto')
-rw-r--r--src/eu/siacs/conversations/crypto/OnPgpEngineResult.java11
-rw-r--r--src/eu/siacs/conversations/crypto/PgpEngine.java33
2 files changed, 14 insertions, 30 deletions
diff --git a/src/eu/siacs/conversations/crypto/OnPgpEngineResult.java b/src/eu/siacs/conversations/crypto/OnPgpEngineResult.java
deleted file mode 100644
index 8e1158390..000000000
--- a/src/eu/siacs/conversations/crypto/OnPgpEngineResult.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package eu.siacs.conversations.crypto;
-
-import org.openintents.openpgp.OpenPgpError;
-
-import android.app.PendingIntent;
-
-public interface OnPgpEngineResult {
- public void success();
- public void error(OpenPgpError openPgpError);
- public void userInputRequried(PendingIntent pi);
-}
diff --git a/src/eu/siacs/conversations/crypto/PgpEngine.java b/src/eu/siacs/conversations/crypto/PgpEngine.java
index 229b43008..48750e240 100644
--- a/src/eu/siacs/conversations/crypto/PgpEngine.java
+++ b/src/eu/siacs/conversations/crypto/PgpEngine.java
@@ -14,12 +14,13 @@ import org.openintents.openpgp.OpenPgpSignatureResult;
import org.openintents.openpgp.util.OpenPgpApi;
import org.openintents.openpgp.util.OpenPgpApi.IOpenPgpCallback;
+import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.services.XmppConnectionService;
+import eu.siacs.conversations.ui.UiCallback;
import eu.siacs.conversations.xmpp.jingle.JingleFile;
-
import android.app.PendingIntent;
import android.content.Intent;
import android.graphics.BitmapFactory;
@@ -34,7 +35,7 @@ public class PgpEngine {
this.mXmppConnectionService = service;
}
- public void decrypt(final Message message, final OnPgpEngineResult callback) {
+ public void decrypt(final Message message, final UiCallback callback) {
Log.d("xmppService","decrypting message "+message.getUuid());
Intent params = new Intent();
params.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY);
@@ -59,8 +60,7 @@ public class PgpEngine {
.getParcelableExtra(OpenPgpApi.RESULT_INTENT));
return;
case OpenPgpApi.RESULT_CODE_ERROR:
- callback.error((OpenPgpError) result
- .getParcelableExtra(OpenPgpApi.RESULT_ERROR));
+ callback.error(R.string.openpgp_error);
return;
default:
return;
@@ -97,8 +97,7 @@ public class PgpEngine {
.getParcelableExtra(OpenPgpApi.RESULT_INTENT));
return;
case OpenPgpApi.RESULT_CODE_ERROR:
- callback.error((OpenPgpError) result
- .getParcelableExtra(OpenPgpApi.RESULT_ERROR));
+ callback.error(R.string.openpgp_error);
return;
default:
return;
@@ -106,15 +105,15 @@ public class PgpEngine {
}
});
} catch (FileNotFoundException e) {
- callback.error(new OpenPgpError(0, "file not found: "+e.getMessage()));
+ callback.error(R.string.error_decrypting_file);
} catch (IOException e) {
- callback.error(new OpenPgpError(0, "io exception: "+e.getMessage()));
+ callback.error(R.string.error_decrypting_file);
}
}
}
- public void encrypt(final Message message,final OnPgpEngineResult callback) {
+ public void encrypt(final Message message,final UiCallback callback) {
long[] keys = { message.getConversation().getContact().getPgpKeyId() };
Intent params = new Intent();
params.setAction(OpenPgpApi.ACTION_ENCRYPT);
@@ -146,8 +145,7 @@ public class PgpEngine {
.getParcelableExtra(OpenPgpApi.RESULT_INTENT));
break;
case OpenPgpApi.RESULT_CODE_ERROR:
- callback.error((OpenPgpError) result
- .getParcelableExtra(OpenPgpApi.RESULT_ERROR));
+ callback.error(R.string.openpgp_error);
break;
}
}
@@ -173,8 +171,7 @@ public class PgpEngine {
.getParcelableExtra(OpenPgpApi.RESULT_INTENT));
break;
case OpenPgpApi.RESULT_CODE_ERROR:
- callback.error((OpenPgpError) result
- .getParcelableExtra(OpenPgpApi.RESULT_ERROR));
+ callback.error(R.string.openpgp_error);
break;
}
}
@@ -235,7 +232,7 @@ public class PgpEngine {
}
public void generateSignature(final Account account, String status,
- final OnPgpEngineResult callback) {
+ final UiCallback callback) {
Intent params = new Intent();
params.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
params.setAction(OpenPgpApi.ACTION_SIGN);
@@ -261,15 +258,14 @@ public class PgpEngine {
.getParcelableExtra(OpenPgpApi.RESULT_INTENT));
return;
case OpenPgpApi.RESULT_CODE_ERROR:
- callback.error((OpenPgpError) result
- .getParcelableExtra(OpenPgpApi.RESULT_ERROR));
+ callback.error(R.string.openpgp_error);
return;
}
}
});
}
- public void hasKey(Contact contact, final OnPgpEngineResult callback) {
+ public void hasKey(Contact contact, final UiCallback callback) {
Intent params = new Intent();
params.setAction(OpenPgpApi.ACTION_GET_KEY);
params.putExtra(OpenPgpApi.EXTRA_KEY_ID, contact.getPgpKeyId());
@@ -287,8 +283,7 @@ public class PgpEngine {
.getParcelableExtra(OpenPgpApi.RESULT_INTENT));
return;
case OpenPgpApi.RESULT_CODE_ERROR:
- callback.error((OpenPgpError) result
- .getParcelableExtra(OpenPgpApi.RESULT_ERROR));
+ callback.error(R.string.openpgp_error);
return;
}
}