Improved error handling for filetransfer:http:delete, Check for httpupload feature available extended to include filetransfer:http as well, method to check if http upload is available moved from data class 'Account' to 'AccountUtil'
This commit is contained in:
parent
563fcfa775
commit
0a9bba2861
14 changed files with 160 additions and 79 deletions
|
@ -56,14 +56,6 @@ public class Account extends AbstractEntity {
|
|||
public static final int OPTION_USECOMPRESSION = 3;
|
||||
public final HashSet<Pair<String, String>> inProgressDiscoFetches = new HashSet<>();
|
||||
|
||||
public boolean httpUploadAvailable(long filesize) {
|
||||
return xmppConnection != null && xmppConnection.getFeatures().httpUpload(filesize);
|
||||
}
|
||||
|
||||
public boolean httpUploadAvailable() {
|
||||
return httpUploadAvailable(0);
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,6 @@ import org.openintents.openpgp.util.OpenPgpApi;
|
|||
import org.openintents.openpgp.util.OpenPgpServiceConnection;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.ArrayList;
|
||||
|
@ -53,11 +52,11 @@ import java.util.Locale;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import de.duenndns.ssl.MemorizingTrustManager;
|
||||
import de.thedevstack.android.logcat.Logging;
|
||||
import de.thedevstack.conversationsplus.ConversationsPlusApplication;
|
||||
import de.thedevstack.conversationsplus.ConversationsPlusPreferences;
|
||||
import de.thedevstack.conversationsplus.services.filetransfer.FileTransferManager;
|
||||
import de.thedevstack.conversationsplus.utils.AccountUtil;
|
||||
import de.thedevstack.conversationsplus.utils.ImageUtil;
|
||||
import de.thedevstack.conversationsplus.utils.MessageUtil;
|
||||
import de.thedevstack.conversationsplus.utils.UiUpdateHelper;
|
||||
|
@ -85,7 +84,6 @@ import de.thedevstack.conversationsplus.entities.TransferablePlaceholder;
|
|||
import de.thedevstack.conversationsplus.generator.IqGenerator;
|
||||
import de.thedevstack.conversationsplus.generator.MessageGenerator;
|
||||
import de.thedevstack.conversationsplus.generator.PresenceGenerator;
|
||||
import de.thedevstack.conversationsplus.http.HttpConnectionManager;
|
||||
import de.thedevstack.conversationsplus.parser.IqParser;
|
||||
import de.thedevstack.conversationsplus.parser.MessageParser;
|
||||
import de.thedevstack.conversationsplus.parser.PresenceParser;
|
||||
|
@ -1080,7 +1078,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
|||
} else {
|
||||
for (Conversation conversation : getConversations()) {
|
||||
if (conversation.getMode() == Conversation.MODE_SINGLE
|
||||
|| conversation.getAccount().httpUploadAvailable()) {
|
||||
|| AccountUtil.isHttpUploadAvailable(conversation.getAccount())) {
|
||||
list.add(conversation);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,14 +31,18 @@ public class DeleteRemoteFileService implements SimpleUserDecisionCallback {
|
|||
path = this.message.getFileParams().getUrl();
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onYes() {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,8 +13,10 @@ import de.thedevstack.conversationsplus.persistance.FileBackend;
|
|||
import de.thedevstack.conversationsplus.services.AbstractConnectionManager;
|
||||
import de.thedevstack.conversationsplus.services.FileTransferService;
|
||||
import de.thedevstack.conversationsplus.services.filetransfer.AbstractFileTransferService;
|
||||
import de.thedevstack.conversationsplus.utils.AccountUtil;
|
||||
import de.thedevstack.conversationsplus.utils.MessageUtil;
|
||||
import de.thedevstack.conversationsplus.utils.XmppSendUtil;
|
||||
import de.thedevstack.conversationsplus.xmpp.filetransfer.http.FileTransferHttp;
|
||||
import de.thedevstack.conversationsplus.xmpp.filetransfer.http.upload.HttpUpload;
|
||||
import de.thedevstack.conversationsplus.xmpp.filetransfer.http.upload.HttpUploadRequestSlotPacketGenerator;
|
||||
import de.thedevstack.conversationsplus.xmpp.jid.Jid;
|
||||
|
@ -62,19 +64,29 @@ public class HttpUploadFileTransferService extends AbstractFileTransferService i
|
|||
file.setExpectedSize(inputStreamAndExpectedSize.second);
|
||||
|
||||
Logging.d("httpupload", "Requesting upload slot for file upload");
|
||||
Jid host = account.getXmppConnection().findDiscoItemByFeature(HttpUpload.NAMESPACE);
|
||||
Jid host = this.getHost(account);
|
||||
if (null != host) {
|
||||
IqPacket request = HttpUploadRequestSlotPacketGenerator.generate(host, file.getName(), file.getSize(), file.getMimeType());
|
||||
XmppSendUtil.sendIqPacket(account, request, new HttpUploadSlotRequestReceived(entity));
|
||||
MessageUtil.markMessage(message, Message.STATUS_UNSEND);
|
||||
|
||||
Logging.d("httpupload", "Upload slot for file upload requested");
|
||||
started = true;
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
Logging.e("httpupload", "Could not find file, exception message: " + e.getMessage());
|
||||
}
|
||||
return started;
|
||||
}
|
||||
|
||||
private Jid getHost(Account account) {
|
||||
Jid host = account.getXmppConnection().findDiscoItemByFeature(FileTransferHttp.NAMESPACE);
|
||||
if (null == host) {
|
||||
host = account.getXmppConnection().findDiscoItemByFeature(HttpUpload.NAMESPACE);
|
||||
}
|
||||
return host;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a message can be sent using this service or not.
|
||||
*
|
||||
|
@ -87,6 +99,6 @@ public class HttpUploadFileTransferService extends AbstractFileTransferService i
|
|||
&& null != message.getConversation()
|
||||
&& null != message.getConversation().getAccount()
|
||||
&& null != message.getFileParams()
|
||||
&& message.getConversation().getAccount().httpUploadAvailable(message.getFileParams().getSize());
|
||||
&& AccountUtil.isHttpUploadAvailable(message.getConversation().getAccount(), message.getFileParams().getSize());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ import java.util.List;
|
|||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import de.thedevstack.android.logcat.Logging;
|
||||
import de.thedevstack.conversationsplus.utils.AccountUtil;
|
||||
import de.timroes.android.listview.EnhancedListView;
|
||||
|
||||
import de.thedevstack.conversationsplus.Config;
|
||||
|
@ -422,7 +423,7 @@ public class ConversationActivity extends XmppActivity
|
|||
}
|
||||
if (this.getSelectedConversation().getMode() == Conversation.MODE_MULTI) {
|
||||
menuContactDetails.setVisible(false);
|
||||
menuAttach.setVisible(getSelectedConversation().getAccount().httpUploadAvailable() && getSelectedConversation().getMucOptions().participating());
|
||||
menuAttach.setVisible(AccountUtil.isHttpUploadAvailable(getSelectedConversation().getAccount()) && getSelectedConversation().getMucOptions().participating());
|
||||
menuInviteContact.setVisible(getSelectedConversation().getMucOptions().canInvite());
|
||||
menuSecure.setVisible((Config.supportOpenPgp() || Config.supportOmemo()) && Config.multipleEncryptionChoices()); //only if pgp is supported we have a choice
|
||||
} else {
|
||||
|
@ -493,7 +494,7 @@ public class ConversationActivity extends XmppActivity
|
|||
}
|
||||
}
|
||||
};
|
||||
if ((account.httpUploadAvailable() || attachmentChoice == ATTACHMENT_CHOICE_LOCATION) && encryption != Message.ENCRYPTION_OTR) {
|
||||
if ((AccountUtil.isHttpUploadAvailable(account) || attachmentChoice == ATTACHMENT_CHOICE_LOCATION) && encryption != Message.ENCRYPTION_OTR) {
|
||||
conversation.setNextCounterpart(null);
|
||||
callback.onPresenceSelected();
|
||||
} else {
|
||||
|
|
|
@ -69,8 +69,7 @@ import de.thedevstack.conversationsplus.ui.adapter.MessageAdapter.OnContactPictu
|
|||
import de.thedevstack.conversationsplus.ui.adapter.MessageAdapter.OnContactPictureLongClicked;
|
||||
import de.thedevstack.conversationsplus.ui.listeners.ConversationSwipeRefreshListener;
|
||||
import de.thedevstack.conversationsplus.ui.listeners.DeleteFileCallback;
|
||||
import de.thedevstack.conversationsplus.ui.listeners.SimpleUserDecisionCallback;
|
||||
import de.thedevstack.conversationsplus.ui.listeners.UserDecisionListener;
|
||||
import de.thedevstack.conversationsplus.utils.AccountUtil;
|
||||
import de.thedevstack.conversationsplus.utils.GeoHelper;
|
||||
import de.thedevstack.conversationsplus.utils.MessageUtil;
|
||||
import de.thedevstack.conversationsplus.utils.UIHelper;
|
||||
|
@ -578,7 +577,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
|
|||
deleteFile.setVisible(true);
|
||||
deleteFile.setTitle(activity.getString(R.string.delete_x_file,UIHelper.getFileDescriptionString(activity, m)));
|
||||
}
|
||||
if (m.isHttpUploaded() && MessageUtil.isMessageSent(m)) {
|
||||
if (m.isHttpUploaded() && MessageUtil.isMessageSent(m) && AccountUtil.isFileTransferHttpAvailable(m.getConversation().getAccount())) {
|
||||
MenuItem deleteRemoteFile = menu.findItem(R.id.msg_ctx_menu_delete_remote_file);
|
||||
deleteRemoteFile.setVisible(true);
|
||||
}
|
||||
|
@ -1038,7 +1037,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
|
|||
final String text = this.mEditMessage == null ? "" : this.mEditMessage.getText().toString();
|
||||
final boolean empty = text.length() == 0;
|
||||
final boolean conference = c.getMode() == Conversation.MODE_MULTI;
|
||||
if (conference && !c.getAccount().httpUploadAvailable()) {
|
||||
if (conference && !AccountUtil.isHttpUploadAvailable(c.getAccount())) {
|
||||
if (empty && c.getNextCounterpart() != null) {
|
||||
action = SendButtonAction.CANCEL;
|
||||
} else {
|
||||
|
|
|
@ -15,7 +15,6 @@ import android.widget.Toast;
|
|||
|
||||
import java.net.URLConnection;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
|
@ -28,9 +27,9 @@ import de.thedevstack.conversationsplus.R;
|
|||
import de.thedevstack.conversationsplus.entities.Account;
|
||||
import de.thedevstack.conversationsplus.entities.Conversation;
|
||||
import de.thedevstack.conversationsplus.entities.Message;
|
||||
import de.thedevstack.conversationsplus.persistance.FileBackend;
|
||||
import de.thedevstack.conversationsplus.services.XmppConnectionService;
|
||||
import de.thedevstack.conversationsplus.ui.adapter.ConversationAdapter;
|
||||
import de.thedevstack.conversationsplus.utils.AccountUtil;
|
||||
import de.thedevstack.conversationsplus.utils.ConversationUtil;
|
||||
import de.thedevstack.conversationsplus.utils.FileUtils;
|
||||
import de.thedevstack.conversationsplus.xmpp.jid.InvalidJidException;
|
||||
|
@ -307,7 +306,7 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer
|
|||
}
|
||||
};
|
||||
}
|
||||
if (account.httpUploadAvailable()
|
||||
if (AccountUtil.isHttpUploadAvailable(account)
|
||||
&& (conversation.getMode() == Conversation.MODE_MULTI
|
||||
|| FileUtils.allFilesUnderSize(this, share.uris, max))
|
||||
&& conversation.getNextEncryption() != Message.ENCRYPTION_OTR) {
|
||||
|
|
|
@ -57,6 +57,8 @@ import de.thedevstack.conversationsplus.utils.CryptoHelper;
|
|||
import de.thedevstack.conversationsplus.utils.GeoHelper;
|
||||
import de.thedevstack.conversationsplus.utils.MessageUtil;
|
||||
import de.thedevstack.conversationsplus.utils.UIHelper;
|
||||
import de.thedevstack.conversationsplus.utils.ui.TextViewUtil;
|
||||
import de.thedevstack.conversationsplus.utils.ui.ViewUtil;
|
||||
|
||||
public class MessageAdapter extends ArrayAdapter<Message> {
|
||||
|
||||
|
@ -605,8 +607,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
ViewHolder viewHolder = new ViewHolder(view);
|
||||
if (SENT == type
|
||||
|| RECEIVED == type) {
|
||||
viewHolder.message_box = (LinearLayout) view.findViewById(R.id.message_box);
|
||||
viewHolder.message_box.setVisibility(View.VISIBLE);
|
||||
viewHolder.message_box = ViewUtil.visible(view, R.id.message_box);
|
||||
viewHolder.indicator = (ImageView) view.findViewById(R.id.security_indicator);
|
||||
viewHolder.messageBody = (TextView) view.findViewById(R.id.message_body);
|
||||
viewHolder.time = (TextView) view.findViewById(R.id.message_time);
|
||||
|
@ -618,17 +619,17 @@ public class MessageAdapter extends ArrayAdapter<Message> {
|
|||
viewHolder.image = (ImageView) view.findViewById(R.id.message_image);
|
||||
}
|
||||
if (RECEIVED == type) { // Extra block as preparation for new /me representation
|
||||
viewHolder.contact_picture = (ImageView) view.findViewById(R.id.message_photo);
|
||||
viewHolder.contact_picture.setVisibility(View.VISIBLE);
|
||||
viewHolder.contact_picture = ViewUtil.visible(view, R.id.message_photo);
|
||||
}
|
||||
if (RECEIVED == type) {
|
||||
viewHolder.encryption = (TextView) view.findViewById(R.id.message_encryption);
|
||||
}
|
||||
if (STATUS == type) {
|
||||
viewHolder.contact_picture = (ImageView) view.findViewById(R.id.message_photo);
|
||||
viewHolder.contact_picture.setVisibility(View.VISIBLE);
|
||||
viewHolder.status_message = (TextView) view.findViewById(R.id.status_message);
|
||||
viewHolder.status_message.setVisibility(View.VISIBLE);
|
||||
viewHolder.contact_picture = ViewUtil.visible(view, R.id.message_photo);
|
||||
viewHolder.status_message = TextViewUtil.visible(view, R.id.status_message);
|
||||
}
|
||||
if (SENT == type) {
|
||||
viewHolder.remoteFileStatus = TextViewUtil.visible(view, R.id.remote_file_status);
|
||||
}
|
||||
view.setTag(viewHolder);
|
||||
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package de.thedevstack.conversationsplus.utils;
|
||||
|
||||
import de.thedevstack.conversationsplus.entities.Account;
|
||||
|
||||
/**
|
||||
* Utility class to work with accounts.
|
||||
*/
|
||||
public final class AccountUtil {
|
||||
|
||||
public static boolean isHttpUploadAvailable(Account account, long filesize) {
|
||||
return null != account
|
||||
&& null != account.getXmppConnection()
|
||||
&& null != account.getXmppConnection().getFeatures()
|
||||
&& account.getXmppConnection().getFeatures().httpUpload(filesize);
|
||||
}
|
||||
|
||||
public static boolean isHttpUploadAvailable(Account account) {
|
||||
return null != account
|
||||
&& null != account.getXmppConnection()
|
||||
&& null != account.getXmppConnection().getFeatures()
|
||||
&& account.getXmppConnection().getFeatures().httpUpload(0);
|
||||
}
|
||||
|
||||
public static boolean isFileTransferHttpAvailable(Account account) {
|
||||
return null != account
|
||||
&& null != account.getXmppConnection()
|
||||
&& null != account.getXmppConnection().getFeatures()
|
||||
&& account.getXmppConnection().getFeatures().hasFeatureFileTransferHttp(0);
|
||||
}
|
||||
|
||||
private AccountUtil() {
|
||||
// avoid instantiation of utility class
|
||||
}
|
||||
}
|
|
@ -1,11 +1,8 @@
|
|||
package de.thedevstack.conversationsplus.utils;
|
||||
|
||||
import de.thedevstack.conversationsplus.Config;
|
||||
|
||||
public final class Xmlns {
|
||||
public static final String BLOCKING = "urn:xmpp:blocking";
|
||||
public static final String ROSTER = "jabber:iq:roster";
|
||||
public static final String REGISTER = "jabber:iq:register";
|
||||
public static final String BYTE_STREAMS = "http://jabber.org/protocol/bytestreams";
|
||||
public static final String HTTP_UPLOAD = "urn:xmpp:http:upload";
|
||||
}
|
||||
|
|
|
@ -71,6 +71,8 @@ import de.thedevstack.conversationsplus.xml.Element;
|
|||
import de.thedevstack.conversationsplus.xml.Tag;
|
||||
import de.thedevstack.conversationsplus.xml.TagWriter;
|
||||
import de.thedevstack.conversationsplus.xml.XmlReader;
|
||||
import de.thedevstack.conversationsplus.xmpp.filetransfer.http.FileTransferHttp;
|
||||
import de.thedevstack.conversationsplus.xmpp.filetransfer.http.upload.HttpUpload;
|
||||
import de.thedevstack.conversationsplus.xmpp.forms.Data;
|
||||
import de.thedevstack.conversationsplus.xmpp.forms.Field;
|
||||
import de.thedevstack.conversationsplus.xmpp.jid.InvalidJidException;
|
||||
|
@ -1534,31 +1536,58 @@ public class XmppConnection implements Runnable {
|
|||
this.blockListRequested = value;
|
||||
}
|
||||
|
||||
public boolean httpUpload(long filesize) {
|
||||
public boolean hasFeatureFileTransferHttp(long filesize) {
|
||||
if (Config.DISABLE_HTTP_UPLOAD) {
|
||||
return false;
|
||||
} else {
|
||||
List<Entry<Jid, ServiceDiscoveryResult>> items = findDiscoItemsByFeature(Xmlns.HTTP_UPLOAD);
|
||||
List<Entry<Jid, ServiceDiscoveryResult>> items = findDiscoItemsByFeature(FileTransferHttp.NAMESPACE);
|
||||
if (items.size() > 0) {
|
||||
try {
|
||||
long maxsize = Long.parseLong(items.get(0).getValue().getExtendedDiscoInformation(Xmlns.HTTP_UPLOAD, "max-file-size"));
|
||||
long maxsize = this.parseMaxHttpUploadSize(items.get(0), FileTransferHttp.NAMESPACE);
|
||||
return filesize <= maxsize;
|
||||
} catch (Exception e) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public long getMaxHttpUploadSize() {
|
||||
List<Entry<Jid, ServiceDiscoveryResult>> items = findDiscoItemsByFeature(Xmlns.HTTP_UPLOAD);
|
||||
public boolean httpUpload(long filesize) {
|
||||
if (Config.DISABLE_HTTP_UPLOAD) {
|
||||
return false;
|
||||
} else {
|
||||
if (hasFeatureFileTransferHttp(filesize)) {
|
||||
return true;
|
||||
} else {
|
||||
List<Entry<Jid, ServiceDiscoveryResult>> items = findDiscoItemsByFeature(HttpUpload.NAMESPACE);
|
||||
if (items.size() > 0) {
|
||||
long maxsize = this.parseMaxHttpUploadSize(items.get(0), HttpUpload.NAMESPACE);
|
||||
return filesize <= maxsize;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private long parseMaxHttpUploadSize(Entry<Jid, ServiceDiscoveryResult> item, String namespace) {
|
||||
long maxsize = Long.MAX_VALUE;
|
||||
if (null != item && null != namespace) {
|
||||
try {
|
||||
return Long.parseLong(items.get(0).getValue().getExtendedDiscoInformation(Xmlns.HTTP_UPLOAD, "max-file-size"));
|
||||
maxsize = Long.parseLong(item.getValue().getExtendedDiscoInformation(namespace, "max-file-size"));
|
||||
} catch (Exception e) {
|
||||
// Suppress exception
|
||||
}
|
||||
}
|
||||
return maxsize;
|
||||
}
|
||||
|
||||
public long getMaxHttpUploadSize() {
|
||||
List<Entry<Jid, ServiceDiscoveryResult>> items = findDiscoItemsByFeature(HttpUpload.NAMESPACE);
|
||||
if (items.size() > 0) {
|
||||
long maxsize = this.parseMaxHttpUploadSize(items.get(0), HttpUpload.NAMESPACE);
|
||||
if (Long.MAX_VALUE == maxsize) { // For code compatibility - legacy behavior returns -1 in case of no max-file-size
|
||||
return -1;
|
||||
} else {
|
||||
return maxsize;
|
||||
}
|
||||
} else {
|
||||
return -1;
|
||||
|
|
|
@ -14,20 +14,23 @@ import de.thedevstack.conversationsplus.xmpp.exceptions.UndefinedConditionExcept
|
|||
public final class ErrorIqPacketExceptionHelper {
|
||||
private final static String ERROR_NAMESPACE = "urn:ietf:params:xml:ns:xmpp-stanzas";
|
||||
|
||||
public static void throwIqErrorException(Element packet) throws IqPacketErrorException {
|
||||
public static void throwIqErrorException(Element errorIqPacket) throws IqPacketErrorException {
|
||||
Element packet = IqPacketParser.findChild(errorIqPacket, "error", "jabber:client");
|
||||
if (null != packet) {
|
||||
if (hasErrorElement(packet, "bad-request")) {
|
||||
throw new BadRequestIqErrorException(packet, getErrorText(packet));
|
||||
throw new BadRequestIqErrorException(errorIqPacket, getErrorText(packet));
|
||||
}
|
||||
if (hasErrorElement(packet, "service-unavailable")) {
|
||||
throw new ServiceUnavailableException(packet, getErrorText(packet));
|
||||
throw new ServiceUnavailableException(errorIqPacket, getErrorText(packet));
|
||||
}
|
||||
if (hasErrorElement(packet, "internal-server-error")) {
|
||||
throw new InternalServerErrorException(packet, getErrorText(packet));
|
||||
throw new InternalServerErrorException(errorIqPacket, getErrorText(packet));
|
||||
}
|
||||
if (hasErrorElement(packet, "undefined-condition")) {
|
||||
throw new UndefinedConditionException(packet, getErrorText(packet));
|
||||
throw new UndefinedConditionException(errorIqPacket, getErrorText(packet));
|
||||
}
|
||||
throw new IqPacketErrorException(packet, "Unknown error packet.");
|
||||
}
|
||||
throw new IqPacketErrorException(errorIqPacket, "Unknown error packet.");
|
||||
}
|
||||
|
||||
private static boolean hasErrorElement(Element packet, String elementName) {
|
||||
|
|
|
@ -682,4 +682,6 @@
|
|||
<string name="file_not_on_remote_host">No file on remote host</string>
|
||||
<string name="dlg_msg_details_original_filename">Original Filename</string>
|
||||
<string name="cplus_open">Open</string>
|
||||
<string name="cplus_remote_file_delete_service_unavailable">Remote File Deletion Service currently unavailable. Please try again later.</string>
|
||||
<string name="cplus_remote_file_delete_failed">Failed to delete remote file.</string>
|
||||
</resources>
|
||||
|
|
Loading…
Reference in a new issue