aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/delete
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/delete')
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/delete/DeleteRemoteFileService.java16
-rw-r--r--src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/delete/DeleteTokenReceived.java10
2 files changed, 20 insertions, 6 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 eb9f1b04..2085cf4b 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
@@ -31,12 +31,16 @@ public class DeleteRemoteFileService implements SimpleUserDecisionCallback {
path = this.message.getFileParams().getUrl();
}
- 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);
- MessageUtil.setAndSaveFileStatus(this.message, FileStatus.DELETING);
- XmppSendUtil.sendIqPacket(account, request, new DeleteTokenReceived(remoteFile));
+ if (null != path) {
+ DeleteRemoteFile remoteFile = new DeleteRemoteFile(path, this.message);
+ Account account = this.message.getConversation().getAccount();
+ Jid host = account.getXmppConnection().findDiscoItemByFeature(FileTransferHttp.NAMESPACE);
+ if (null != host) {
+ IqPacket request = FileTransferHttpDeleteSlotRequestPacketGenerator.generate(host, path);
+ MessageUtil.setAndSaveFileStatus(this.message, FileStatus.DELETING);
+ XmppSendUtil.sendIqPacket(account, request, new DeleteTokenReceived(remoteFile));
+ }
+ }
}
}
diff --git a/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/delete/DeleteTokenReceived.java b/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/delete/DeleteTokenReceived.java
index 186454e4..83a250de 100644
--- a/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/delete/DeleteTokenReceived.java
+++ b/src/main/java/de/thedevstack/conversationsplus/services/filetransfer/http/delete/DeleteTokenReceived.java
@@ -1,16 +1,21 @@
package de.thedevstack.conversationsplus.services.filetransfer.http.delete;
+import android.widget.Toast;
+
import org.json.JSONException;
import org.json.JSONObject;
import java.io.IOException;
import de.thedevstack.android.logcat.Logging;
+import de.thedevstack.conversationsplus.R;
import de.thedevstack.conversationsplus.entities.Account;
import de.thedevstack.conversationsplus.enums.FileStatus;
import de.thedevstack.conversationsplus.http.HttpClient;
import de.thedevstack.conversationsplus.utils.MessageUtil;
+import de.thedevstack.conversationsplus.utils.ui.ConversationsPlusToast;
import de.thedevstack.conversationsplus.xmpp.OnIqPacketReceived;
+import de.thedevstack.conversationsplus.xmpp.exceptions.ServiceUnavailableException;
import de.thedevstack.conversationsplus.xmpp.exceptions.XmppException;
import de.thedevstack.conversationsplus.xmpp.filetransfer.http.delete.DeleteSlotPacketParser;
import de.thedevstack.conversationsplus.xmpp.stanzas.IqPacket;
@@ -81,6 +86,11 @@ public class DeleteTokenReceived implements OnIqPacketReceived {
} catch (XmppException e) {
Logging.e("filetransfer.http.delete", "Error while trying to get the delete token: " + e.getMessage());
+ int messageResId = R.string.cplus_remote_file_delete_failed;
+ if (e instanceof ServiceUnavailableException) {
+ messageResId = R.string.cplus_remote_file_delete_service_unavailable;
+ }
+ ConversationsPlusToast.makeErrorToast(messageResId, Toast.LENGTH_LONG);
MessageUtil.setAndSaveFileStatus(remoteFile.getMessage(), FileStatus.DELETE_FAILED);
}
}