diff options
author | Daniel Gultsch <daniel@gultsch.de> | 2016-08-30 13:12:09 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-09-02 23:05:22 +0200 |
commit | b2b1b0ad38cdbd42049664e399485eaf302013b5 (patch) | |
tree | 3cf6cd5716558f4d756dc5f8d9a6a2f28c4022a5 /src | |
parent | 939b8d1c757f38fc46b72adfe04a31e2813f2234 (diff) |
add more logging to pgp engine
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/de/pixart/messenger/crypto/PgpEngine.java | 27 | ||||
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java | 6 |
2 files changed, 20 insertions, 13 deletions
diff --git a/src/main/java/de/pixart/messenger/crypto/PgpEngine.java b/src/main/java/de/pixart/messenger/crypto/PgpEngine.java index 6c272f941..c77603219 100644 --- a/src/main/java/de/pixart/messenger/crypto/PgpEngine.java +++ b/src/main/java/de/pixart/messenger/crypto/PgpEngine.java @@ -4,6 +4,7 @@ import android.app.PendingIntent; import android.content.Intent; import android.util.Log; +import org.openintents.openpgp.OpenPgpError; import org.openintents.openpgp.OpenPgpSignatureResult; import org.openintents.openpgp.util.OpenPgpApi; import org.openintents.openpgp.util.OpenPgpApi.IOpenPgpCallback; @@ -90,6 +91,7 @@ public class PgpEngine { message); break; case OpenPgpApi.RESULT_CODE_ERROR: + logError(conversation.getAccount(), (OpenPgpError) result.getParcelableExtra(OpenPgpApi.RESULT_ERROR)); callback.error(R.string.openpgp_error, message); break; } @@ -127,6 +129,7 @@ public class PgpEngine { message); break; case OpenPgpApi.RESULT_CODE_ERROR: + logError(conversation.getAccount(), (OpenPgpError) result.getParcelableExtra(OpenPgpApi.RESULT_ERROR)); callback.error(R.string.openpgp_error, message); break; } @@ -176,6 +179,7 @@ public class PgpEngine { case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED: return 0; case OpenPgpApi.RESULT_CODE_ERROR: + logError(account, (OpenPgpError) result.getParcelableExtra(OpenPgpApi.RESULT_ERROR)); return 0; } return 0; @@ -198,6 +202,7 @@ public class PgpEngine { account); return; case OpenPgpApi.RESULT_CODE_ERROR: + logError(account, (OpenPgpError) result.getParcelableExtra(OpenPgpApi.RESULT_ERROR)); callback.error(R.string.openpgp_error, account); } } @@ -254,6 +259,7 @@ public class PgpEngine { account); return; case OpenPgpApi.RESULT_CODE_ERROR: + logError(account, (OpenPgpError) result.getParcelableExtra(OpenPgpApi.RESULT_ERROR)); callback.error(R.string.unable_to_connect_to_keychain, account); } } @@ -278,27 +284,30 @@ public class PgpEngine { contact); return; case OpenPgpApi.RESULT_CODE_ERROR: + logError(contact.getAccount(), (OpenPgpError) result.getParcelableExtra(OpenPgpApi.RESULT_ERROR)); callback.error(R.string.openpgp_error, contact); } } }); } + private static void logError(Account account, OpenPgpError error) { + if (error != null) { + Log.d(Config.LOGTAG,account.getJid().toBareJid().toString()+": OpenKeychain error '"+error.getMessage()+"' code="+error.getErrorId()); + } else { + Log.d(Config.LOGTAG,account.getJid().toBareJid().toString()+": OpenKeychain error with no message"); + } + } + public PendingIntent getIntentForKey(Contact contact) { - Intent params = new Intent(); - params.setAction(OpenPgpApi.ACTION_GET_KEY); - params.putExtra(OpenPgpApi.EXTRA_KEY_ID, contact.getPgpKeyId()); - Intent result = api.executeApi(params, null, null); - return (PendingIntent) result - .getParcelableExtra(OpenPgpApi.RESULT_INTENT); + return getIntentForKey(contact.getPgpKeyId()); } - public PendingIntent getIntentForKey(Account account, long pgpKeyId) { + public PendingIntent getIntentForKey(long pgpKeyId) { Intent params = new Intent(); params.setAction(OpenPgpApi.ACTION_GET_KEY); params.putExtra(OpenPgpApi.EXTRA_KEY_ID, pgpKeyId); Intent result = api.executeApi(params, null, null); - return (PendingIntent) result - .getParcelableExtra(OpenPgpApi.RESULT_INTENT); + return (PendingIntent) result.getParcelableExtra(OpenPgpApi.RESULT_INTENT); } } diff --git a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java index ef66f0c41..30a9404cc 100644 --- a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java @@ -629,12 +629,10 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers private void viewPgpKey(User user) { PgpEngine pgp = xmppConnectionService.getPgpEngine(); if (pgp != null) { - PendingIntent intent = pgp.getIntentForKey( - mConversation.getAccount(), user.getPgpKeyId()); + PendingIntent intent = pgp.getIntentForKey(user.getPgpKeyId()); if (intent != null) { try { - startIntentSenderForResult(intent.getIntentSender(), 0, - null, 0, 0, 0); + startIntentSenderForResult(intent.getIntentSender(), 0, null, 0, 0, 0); } catch (SendIntentException ignored) { } |