diff options
author | steckbrief <steckbrief@chefmail.de> | 2016-08-23 11:23:40 +0200 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2016-08-23 11:23:40 +0200 |
commit | ad096f4bfd220a106aab670105275397bfcbfd0e (patch) | |
tree | 0a4d3b171f3d7fc9de7aeca8c37dcaa72ce16f0c /src/main/java/de/thedevstack/conversationsplus/services | |
parent | e91e8a30b1f4a806d77d74871df5af6cdb87ca0e (diff) |
Confirmation dialog added before sending delete command for remote file
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/services')
-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 + } } |