proper cleanup after pgp image decryption
This commit is contained in:
parent
f45a841caf
commit
698572d218
|
@ -10,12 +10,10 @@ import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import org.openintents.openpgp.OpenPgpError;
|
|
||||||
import org.openintents.openpgp.OpenPgpSignatureResult;
|
import org.openintents.openpgp.OpenPgpSignatureResult;
|
||||||
import org.openintents.openpgp.util.OpenPgpApi;
|
import org.openintents.openpgp.util.OpenPgpApi;
|
||||||
import org.openintents.openpgp.util.OpenPgpApi.IOpenPgpCallback;
|
import org.openintents.openpgp.util.OpenPgpApi.IOpenPgpCallback;
|
||||||
|
|
||||||
import eu.siacs.conversations.Config;
|
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
import eu.siacs.conversations.entities.Account;
|
import eu.siacs.conversations.entities.Account;
|
||||||
import eu.siacs.conversations.entities.Contact;
|
import eu.siacs.conversations.entities.Contact;
|
||||||
|
@ -27,7 +25,7 @@ import eu.siacs.conversations.ui.UiCallback;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.util.Log;
|
import android.net.Uri;
|
||||||
|
|
||||||
public class PgpEngine {
|
public class PgpEngine {
|
||||||
private OpenPgpApi api;
|
private OpenPgpApi api;
|
||||||
|
@ -40,7 +38,6 @@ public class PgpEngine {
|
||||||
|
|
||||||
public void decrypt(final Message message,
|
public void decrypt(final Message message,
|
||||||
final UiCallback<Message> callback) {
|
final UiCallback<Message> callback) {
|
||||||
Log.d(Config.LOGTAG, "decrypting message " + message.getUuid());
|
|
||||||
Intent params = new Intent();
|
Intent params = new Intent();
|
||||||
params.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY);
|
params.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY);
|
||||||
params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, message
|
params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, message
|
||||||
|
@ -79,10 +76,6 @@ public class PgpEngine {
|
||||||
message);
|
message);
|
||||||
return;
|
return;
|
||||||
case OpenPgpApi.RESULT_CODE_ERROR:
|
case OpenPgpApi.RESULT_CODE_ERROR:
|
||||||
OpenPgpError error = result
|
|
||||||
.getParcelableExtra(OpenPgpApi.RESULT_ERROR);
|
|
||||||
Log.d(Config.LOGTAG,
|
|
||||||
"openpgp error: " + error.getMessage());
|
|
||||||
callback.error(R.string.openpgp_error, message);
|
callback.error(R.string.openpgp_error, message);
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
|
@ -128,7 +121,10 @@ public class PgpEngine {
|
||||||
message.setEncryption(Message.ENCRYPTION_DECRYPTED);
|
message.setEncryption(Message.ENCRYPTION_DECRYPTED);
|
||||||
PgpEngine.this.mXmppConnectionService
|
PgpEngine.this.mXmppConnectionService
|
||||||
.updateMessage(message);
|
.updateMessage(message);
|
||||||
;
|
inputFile.delete();
|
||||||
|
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
|
||||||
|
intent.setData(Uri.fromFile(outputFile));
|
||||||
|
mXmppConnectionService.sendBroadcast(intent);
|
||||||
callback.success(message);
|
callback.success(message);
|
||||||
return;
|
return;
|
||||||
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
|
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
|
||||||
|
@ -242,9 +238,11 @@ public class PgpEngine {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
Log.d(Config.LOGTAG, "file not found: " + e.getMessage());
|
callback.error(R.string.openpgp_error, message);
|
||||||
|
return;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.d(Config.LOGTAG, "io exception during file encrypt");
|
callback.error(R.string.openpgp_error, message);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,11 +286,6 @@ public class PgpEngine {
|
||||||
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
|
case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
|
||||||
return 0;
|
return 0;
|
||||||
case OpenPgpApi.RESULT_CODE_ERROR:
|
case OpenPgpApi.RESULT_CODE_ERROR:
|
||||||
Log.d(Config.LOGTAG,
|
|
||||||
"openpgp error: "
|
|
||||||
+ ((OpenPgpError) result
|
|
||||||
.getParcelableExtra(OpenPgpApi.RESULT_ERROR))
|
|
||||||
.getMessage());
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue