mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-24 17:52:17 -05:00
untested pgp support for http upload
This commit is contained in:
parent
fdd46f1c91
commit
0030bbf472
@ -143,11 +143,15 @@ public class PgpEngine {
|
||||
params.putExtra(OpenPgpApi.EXTRA_ACCOUNT_NAME, message
|
||||
.getConversation().getAccount().getJid().toBareJid().toString());
|
||||
|
||||
if (message.getType() == Message.TYPE_TEXT) {
|
||||
if (!message.needsUploading()) {
|
||||
params.putExtra(OpenPgpApi.EXTRA_REQUEST_ASCII_ARMOR, true);
|
||||
|
||||
InputStream is = new ByteArrayInputStream(message.getBody()
|
||||
.getBytes());
|
||||
String body;
|
||||
if (message.hasFileOnRemoteHost()) {
|
||||
body = message.getImageParams().url.toString();
|
||||
} else {
|
||||
body = message.getBody();
|
||||
}
|
||||
InputStream is = new ByteArrayInputStream(body.getBytes());
|
||||
final OutputStream os = new ByteArrayOutputStream();
|
||||
api.executeApiAsync(params, is, os, new IOpenPgpCallback() {
|
||||
|
||||
@ -184,7 +188,7 @@ public class PgpEngine {
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (message.getType() == Message.TYPE_IMAGE || message.getType() == Message.TYPE_FILE) {
|
||||
} else {
|
||||
try {
|
||||
DownloadableFile inputFile = this.mXmppConnectionService
|
||||
.getFileBackend().getFile(message, true);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package eu.siacs.conversations.http;
|
||||
|
||||
import android.app.PendingIntent;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -16,6 +17,7 @@ import eu.siacs.conversations.entities.DownloadableFile;
|
||||
import eu.siacs.conversations.entities.Message;
|
||||
import eu.siacs.conversations.persistance.FileBackend;
|
||||
import eu.siacs.conversations.services.XmppConnectionService;
|
||||
import eu.siacs.conversations.ui.UiCallback;
|
||||
import eu.siacs.conversations.utils.CryptoHelper;
|
||||
import eu.siacs.conversations.utils.Xmlns;
|
||||
import eu.siacs.conversations.xml.Element;
|
||||
@ -159,7 +161,26 @@ public class HttpUploadConnection implements Downloadable {
|
||||
message.setBody(mGetUrl.toString()+"|"+String.valueOf(params.size)+"|"+String.valueOf(params.width)+"|"+String.valueOf(params.height));
|
||||
message.setDownloadable(null);
|
||||
message.setCounterpart(message.getConversation().getJid().toBareJid());
|
||||
if (message.getEncryption() == Message.ENCRYPTION_DECRYPTED) {
|
||||
mXmppConnectionService.getPgpEngine().encrypt(message, new UiCallback<Message>() {
|
||||
@Override
|
||||
public void success(Message message) {
|
||||
mXmppConnectionService.resendMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(int errorCode, Message object) {
|
||||
fail();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void userInputRequried(PendingIntent pi, Message object) {
|
||||
fail();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mXmppConnectionService.resendMessage(message);
|
||||
}
|
||||
} else {
|
||||
fail();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user