blob: 470a6010b4b9cfb3b57a89a7ed57fe5e0a26802c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
package de.thedevstack.conversationsplus.services.filetransfer.http.delete;
import android.widget.Toast;
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.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.DeletedPacketParser;
import de.thedevstack.conversationsplus.xmpp.stanzas.IqPacket;
/**
*
*/
public class DeletedIqPacketReceived implements OnIqPacketReceived {
private final DeleteRemoteFile remoteFile;
public DeletedIqPacketReceived(DeleteRemoteFile remoteFile) {
this.remoteFile = remoteFile;
}
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
try {
boolean fileIsDeleted = DeletedPacketParser.parseDeleteToken(packet);
if (fileIsDeleted) {
MessageUtil.setAndSaveFileStatus(remoteFile.getMessage(), FileStatus.DELETED);
Logging.i("filetransfer.http.delete", "Remote file successfully deleted '" + remoteFile.getPath() + "'");
} else {
Logging.e("filetransfer.http.delete", "Unexpectedly failed to delete remote file.");
}
} catch (XmppException e) {
Logging.e("filetransfer.http.delete", "Error while trying to delete remote file: " + 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);
}
}
}
|