diff options
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/services/filetransfer')
-rw-r--r-- | src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/delete/DeleteRemoteFileService.java | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/delete/DeleteRemoteFileService.java b/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/delete/DeleteRemoteFileService.java index 42410ed4..2b26fd85 100644 --- a/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/delete/DeleteRemoteFileService.java +++ b/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/delete/DeleteRemoteFileService.java @@ -2,6 +2,7 @@ package de.thedevstack.conversationsplus.services.filetransfer.http.delete; import de.thedevstack.conversationsplus.entities.Account; import de.thedevstack.conversationsplus.entities.Message; +import de.thedevstack.conversationsplus.ui.listeners.SimpleUserDecisionCallback; import de.thedevstack.conversationsplus.utils.XmppSendUtil; import de.thedevstack.conversationsplus.xmpp.filetransfer.http.FileTransferHttp; import de.thedevstack.conversationsplus.xmpp.filetransfer.http.delete.FileTransferHttpDeleteSlotRequestPacketGenerator; @@ -11,20 +12,36 @@ import de.thedevstack.conversationsplus.xmpp.stanzas.IqPacket; /** * Created by steckbrief on 21.08.2016. */ -public class DeleteRemoteFileService { - public void deleteRemoteFile(Message message) { - if (message.isHttpUploaded()) { - String path = message.getBody(); - if (message.hasFileOnRemoteHost()) { - path = message.getFileParams().url.toString(); +public class DeleteRemoteFileService implements SimpleUserDecisionCallback { + private Message message; + + public DeleteRemoteFileService(Message message) { + this.message = message; + } + + public void deleteRemoteFile() { + if (this.message.isHttpUploaded()) { + String path = this.message.getBody(); + if (this.message.hasFileOnRemoteHost()) { + path = this.message.getFileParams().url.toString(); } - DeleteRemoteFile remoteFile = new DeleteRemoteFile(path, message); - Account account = message.getConversation().getAccount(); + DeleteRemoteFile remoteFile = new DeleteRemoteFile(path, this.message); + Account account = this.message.getConversation().getAccount(); Jid host = account.getXmppConnection().findDiscoItemByFeature(FileTransferHttp.NAMESPACE); IqPacket request = FileTransferHttpDeleteSlotRequestPacketGenerator.generate(host, path); XmppSendUtil.sendIqPacket(account, request, new DeleteTokenReceived(remoteFile)); } } + + @Override + public void onYes() { + this.deleteRemoteFile(); + } + + @Override + public void onNo() { + // Nothing to do + } } |