From 0adaa2a7ac46dbf373bc5cf3c8ae544b829e0071 Mon Sep 17 00:00:00 2001 From: peli0101 Date: Fri, 1 May 2009 16:03:30 +0000 Subject: [PATCH] OI Safe: Return content provider URI for future compatibility with other safes. git-svn-id: http://openintents.googlecode.com/svn/trunk/Safe@2061 72b678ce-9140-0410-bee8-679b907dd61a --- .../openintents/intents/CryptoIntents.java | 8 +++++- src/org/openintents/safe/IntentHandler.java | 28 +++++++++++-------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/org/openintents/intents/CryptoIntents.java b/src/org/openintents/intents/CryptoIntents.java index a55cd7e..4b6678b 100644 --- a/src/org/openintents/intents/CryptoIntents.java +++ b/src/org/openintents/intents/CryptoIntents.java @@ -31,6 +31,9 @@ public class CryptoIntents { * If a file URI is given, the file is encrypted. * The new file URI is returned. * + * If the extra EXTRA_SESSION_KEY is provided, the session key is returned, + * and the content URI is returned in the data field. + * * Returns all encrypted string in the same extra(s). * *

Constant Value: "org.openintents.action.ENCRYPT"

@@ -44,6 +47,9 @@ public class CryptoIntents { * If a file URI is given, the file is decrypted. * The new file URI is returned. * + * If the extra EXTRA_SESSION_KEY is provided, the session key is returned, + * and the content URI is returned in the data field. + * * Returns all decrypted string in the same extra(s). * *

Constant Value: "org.openintents.action.DECRYPT"

@@ -117,7 +123,7 @@ public class CryptoIntents { * * Include this extra with non-empty value to the ENCRYPT or DECRYPT action, * and the resulting intent will contain the current session key, valid until - * OI Safe logs out. + * OI Safe logs out, and the content URI as data. * *

Constant Value: "org.openintents.extra.SESSION_KEY"

*/ diff --git a/src/org/openintents/safe/IntentHandler.java b/src/org/openintents/safe/IntentHandler.java index 7911cf0..4b1e34f 100644 --- a/src/org/openintents/safe/IntentHandler.java +++ b/src/org/openintents/safe/IntentHandler.java @@ -270,11 +270,6 @@ public class IntentHandler extends Activity { } callbackIntent.putExtra(CryptoIntents.EXTRA_TEXT_ARRAY, out); } - - if (thisIntent.hasExtra(CryptoIntents.EXTRA_SESSION_KEY)) { - String sessionkey = ch.getCurrentSessionKey(); - callbackIntent.putExtra(CryptoIntents.EXTRA_SESSION_KEY, sessionkey); - } if (thisIntent.getData() != null) { // Encrypt file from file URI @@ -284,7 +279,14 @@ public class IntentHandler extends Activity { callbackIntent.setData(newFileUri); } - // Support for binary fields could be added here (like images?) + + if (thisIntent.hasExtra(CryptoIntents.EXTRA_SESSION_KEY)) { + String sessionkey = ch.getCurrentSessionKey(); + callbackIntent.putExtra(CryptoIntents.EXTRA_SESSION_KEY, sessionkey); + + // Warning! This overwrites any data intent set previously. + callbackIntent.setData(CryptoContentProvider.CONTENT_URI); + } callbackResult = RESULT_OK; } catch (CryptoHelperException e) { @@ -324,11 +326,6 @@ public class IntentHandler extends Activity { callbackIntent.putExtra(CryptoIntents.EXTRA_TEXT_ARRAY, out); } - if (thisIntent.hasExtra(CryptoIntents.EXTRA_SESSION_KEY)) { - String sessionkey = ch.getCurrentSessionKey(); - callbackIntent.putExtra(CryptoIntents.EXTRA_SESSION_KEY, sessionkey); - } - if (thisIntent.getData() != null) { // Decrypt file from file URI Uri fileUri = thisIntent.getData(); @@ -337,7 +334,14 @@ public class IntentHandler extends Activity { callbackIntent.setData(newFileUri); } - // Support for binary fields could be added here (like images?) + + if (thisIntent.hasExtra(CryptoIntents.EXTRA_SESSION_KEY)) { + String sessionkey = ch.getCurrentSessionKey(); + callbackIntent.putExtra(CryptoIntents.EXTRA_SESSION_KEY, sessionkey); + + // Warning! This overwrites any data intent set previously. + callbackIntent.setData(CryptoContentProvider.CONTENT_URI); + } callbackResult = RESULT_OK; } catch (CryptoHelperException e) { -- 2.50.1