aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs/conversations/xmpp
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2015-06-28 11:19:07 +0200
committerDaniel Gultsch <daniel@gultsch.de>2015-06-29 15:21:41 +0200
commit9eb9a522050589e60bc7c76b2b040b1dadb7fd1d (patch)
treea63423bf28f848cf93cfabaf02a8e605dbc47ed7 /src/main/java/eu/siacs/conversations/xmpp
parent6ee11e5323ac3e78caf64d5e205cba9a405f87f8 (diff)
initial http upload support
be careful: little error handling and no encryption
Diffstat (limited to 'src/main/java/eu/siacs/conversations/xmpp')
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java14
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java20
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java8
3 files changed, 13 insertions, 29 deletions
diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
index 8a438906..87dfb897 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -1025,18 +1025,18 @@ public class XmppConnection implements Runnable {
this.streamId = null;
}
- public List<String> findDiscoItemsByFeature(final String feature) {
- final List<String> items = new ArrayList<>();
+ public List<Jid> findDiscoItemsByFeature(final String feature) {
+ final List<Jid> items = new ArrayList<>();
for (final Entry<Jid, Info> cursor : disco.entrySet()) {
if (cursor.getValue().features.contains(feature)) {
- items.add(cursor.getKey().toString());
+ items.add(cursor.getKey());
}
}
return items;
}
- public String findDiscoItemByFeature(final String feature) {
- final List<String> items = findDiscoItemsByFeature(feature);
+ public Jid findDiscoItemByFeature(final String feature) {
+ final List<Jid> items = findDiscoItemsByFeature(feature);
if (items.size() >= 1) {
return items.get(0);
}
@@ -1191,6 +1191,10 @@ public class XmppConnection implements Runnable {
public void setBlockListRequested(boolean value) {
this.blockListRequested = value;
}
+
+ public boolean httpUpload() {
+ return findDiscoItemsByFeature(Xmlns.HTTP_UPLOAD).size() > 0;
+ }
}
private IqGenerator getIqGenerator() {
diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
index c9bb9c93..8e4282a9 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
@@ -954,24 +954,4 @@ public class JingleConnection implements Downloadable {
public int getProgress() {
return this.mProgress;
}
-
- @Override
- public String getMimeType() {
- if (this.message.getType() == Message.TYPE_FILE) {
- String mime = null;
- String path = this.message.getRelativeFilePath();
- if (path != null && !this.message.getRelativeFilePath().isEmpty()) {
- mime = URLConnection.guessContentTypeFromName(this.message.getRelativeFilePath());
- if (mime!=null) {
- return mime;
- } else {
- return "";
- }
- } else {
- return "";
- }
- } else {
- return "image/webp";
- }
- }
}
diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java
index c19dd04c..f0cf5d8a 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnectionManager.java
@@ -87,10 +87,10 @@ public class JingleConnectionManager extends AbstractConnectionManager {
return;
}
if (!this.primaryCandidates.containsKey(account.getJid().toBareJid())) {
- final String proxy = account.getXmppConnection().findDiscoItemByFeature(Xmlns.BYTE_STREAMS);
+ final Jid proxy = account.getXmppConnection().findDiscoItemByFeature(Xmlns.BYTE_STREAMS);
if (proxy != null) {
IqPacket iq = new IqPacket(IqPacket.TYPE.GET);
- iq.setAttribute("to", proxy);
+ iq.setTo(proxy);
iq.query(Xmlns.BYTE_STREAMS);
account.getXmppConnection().sendIqPacket(iq,new OnIqPacketReceived() {
@@ -105,11 +105,11 @@ public class JingleConnectionManager extends AbstractConnectionManager {
candidate.setHost(host);
candidate.setPort(Integer.parseInt(port));
candidate.setType(JingleCandidate.TYPE_PROXY);
- candidate.setJid(Jid.fromString(proxy));
+ candidate.setJid(proxy);
candidate.setPriority(655360 + 65535);
primaryCandidates.put(account.getJid().toBareJid(),candidate);
listener.onPrimaryCandidateFound(true,candidate);
- } catch (final NumberFormatException | InvalidJidException e) {
+ } catch (final NumberFormatException e) {
listener.onPrimaryCandidateFound(false,null);
return;
}