diff options
author | lookshe <github@lookshe.org> | 2015-08-11 20:30:11 +0200 |
---|---|---|
committer | lookshe <github@lookshe.org> | 2015-08-11 20:30:11 +0200 |
commit | 639babfdb5289a035e0a22bf607c068caefa5c99 (patch) | |
tree | 6a11aa6a189f3a5988d5d1e1c733d2027bc3494f /src/main/java/de/thedevstack/conversationsplus/generator | |
parent | 1b5966ae3b1108c88a810d7d32a0aefa8812d11f (diff) | |
parent | 8fd688ca96005152be754eeba1be72c7c0aab9ad (diff) |
Merge branch 'trz/rebase' into trz/rename
Conflicts:
build.gradle
src/main/java/de/thedevstack/conversationsplus/crypto/OtrEngine.java
src/main/java/de/thedevstack/conversationsplus/entities/Account.java
src/main/java/de/thedevstack/conversationsplus/entities/Contact.java
src/main/java/de/thedevstack/conversationsplus/entities/Downloadable.java
src/main/java/de/thedevstack/conversationsplus/entities/DownloadableFile.java
src/main/java/de/thedevstack/conversationsplus/entities/DownloadablePlaceholder.java
src/main/java/de/thedevstack/conversationsplus/entities/Message.java
src/main/java/de/thedevstack/conversationsplus/generator/IqGenerator.java
src/main/java/de/thedevstack/conversationsplus/http/HttpConnection.java
src/main/java/de/thedevstack/conversationsplus/http/HttpConnectionManager.java
src/main/java/de/thedevstack/conversationsplus/parser/AbstractParser.java
src/main/java/de/thedevstack/conversationsplus/parser/MessageParser.java
src/main/java/de/thedevstack/conversationsplus/parser/PresenceParser.java
src/main/java/de/thedevstack/conversationsplus/persistance/DatabaseBackend.java
src/main/java/de/thedevstack/conversationsplus/persistance/FileBackend.java
src/main/java/de/thedevstack/conversationsplus/services/NotificationService.java
src/main/java/de/thedevstack/conversationsplus/services/XmppConnectionService.java
src/main/java/de/thedevstack/conversationsplus/ui/ConversationActivity.java
src/main/java/de/thedevstack/conversationsplus/ui/ConversationFragment.java
src/main/java/de/thedevstack/conversationsplus/ui/SettingsActivity.java
src/main/java/de/thedevstack/conversationsplus/ui/StartConversationActivity.java
src/main/java/de/thedevstack/conversationsplus/ui/adapter/AccountAdapter.java
src/main/java/de/thedevstack/conversationsplus/ui/adapter/ConversationAdapter.java
src/main/java/de/thedevstack/conversationsplus/ui/adapter/ListItemAdapter.java
src/main/java/de/thedevstack/conversationsplus/ui/adapter/MessageAdapter.java
src/main/java/de/thedevstack/conversationsplus/utils/UIHelper.java
src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleConnection.java
src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleConnectionManager.java
src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleInbandTransport.java
src/main/java/de/thedevstack/conversationsplus/xmpp/jingle/JingleSocks5Transport.java
src/main/java/de/thedevstack/conversationsplus/xmpp/stanzas/MessagePacket.java
src/main/java/eu/siacs/conversations/crypto/OtrEngine.java
src/main/java/eu/siacs/conversations/crypto/OtrService.java
src/main/java/eu/siacs/conversations/entities/DownloadablePlaceholder.java
src/main/java/eu/siacs/conversations/entities/TransferablePlaceholder.java
src/main/java/eu/siacs/conversations/http/HttpConnection.java
src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java
src/main/res/layout/activity_about.xml
Diffstat (limited to 'src/main/java/de/thedevstack/conversationsplus/generator')
3 files changed, 47 insertions, 12 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/generator/IqGenerator.java b/src/main/java/de/thedevstack/conversationsplus/generator/IqGenerator.java index ccba1e1d..8199e59c 100644 --- a/src/main/java/de/thedevstack/conversationsplus/generator/IqGenerator.java +++ b/src/main/java/de/thedevstack/conversationsplus/generator/IqGenerator.java @@ -6,8 +6,10 @@ import java.util.List; import de.thedevstack.conversationsplus.entities.Account; import de.thedevstack.conversationsplus.entities.Conversation; +import de.thedevstack.conversationsplus.entities.DownloadableFile; import de.thedevstack.conversationsplus.services.MessageArchiveService; import de.thedevstack.conversationsplus.services.XmppConnectionService; +import de.thedevstack.conversationsplus.utils.PhoneHelper; import de.thedevstack.conversationsplus.utils.Xmlns; import de.thedevstack.conversationsplus.xml.Element; import de.thedevstack.conversationsplus.xmpp.forms.Data; @@ -90,7 +92,7 @@ public class IqGenerator extends AbstractGenerator { return publish("urn:xmpp:avatar:metadata", item); } - public IqPacket retrieveAvatar(final Avatar avatar) { + public IqPacket retrievePepAvatar(final Avatar avatar) { final Element item = new Element("item"); item.setAttribute("id", avatar.sha1sum); final IqPacket packet = retrieve("urn:xmpp:avatar:data", item); @@ -98,6 +100,13 @@ public class IqGenerator extends AbstractGenerator { return packet; } + public IqPacket retrieveVcardAvatar(final Avatar avatar) { + final IqPacket packet = new IqPacket(IqPacket.TYPE.GET); + packet.setTo(avatar.owner); + packet.addChild("vCard", "vcard-temp"); + return packet; + } + public IqPacket retrieveAvatarMetaData(final Jid to) { final IqPacket packet = retrieve("urn:xmpp:avatar:metadata", null); if (to != null) { @@ -186,4 +195,13 @@ public class IqGenerator extends AbstractGenerator { item.setAttribute("role", role); return packet; } + + public IqPacket requestHttpUploadSlot(Jid host, DownloadableFile file) { + IqPacket packet = new IqPacket(IqPacket.TYPE.GET); + packet.setTo(host); + Element request = packet.addChild("request",Xmlns.HTTP_UPLOAD); + request.addChild("filename").setContent(file.getName()); + request.addChild("size").setContent(String.valueOf(file.getExpectedSize())); + return packet; + } } diff --git a/src/main/java/de/thedevstack/conversationsplus/generator/MessageGenerator.java b/src/main/java/de/thedevstack/conversationsplus/generator/MessageGenerator.java index 41b41882..fa327141 100644 --- a/src/main/java/de/thedevstack/conversationsplus/generator/MessageGenerator.java +++ b/src/main/java/de/thedevstack/conversationsplus/generator/MessageGenerator.java @@ -71,8 +71,16 @@ public class MessageGenerator extends AbstractGenerator { MessagePacket packet = preparePacket(message, addDelay); packet.addChild("private", "urn:xmpp:carbons:2"); packet.addChild("no-copy", "urn:xmpp:hints"); + packet.addChild("no-permanent-store", "urn:xmpp:hints"); + packet.addChild("no-permanent-storage", "urn:xmpp:hints"); try { - packet.setBody(otrSession.transformSending(message.getBody())[0]); + String content; + if (message.hasFileOnRemoteHost()) { + content = message.getFileParams().url.toString(); + } else { + content = message.getBody(); + } + packet.setBody(otrSession.transformSending(content)[0]); return packet; } catch (OtrException e) { return null; @@ -85,7 +93,11 @@ public class MessageGenerator extends AbstractGenerator { public MessagePacket generateChat(Message message, boolean addDelay) { MessagePacket packet = preparePacket(message, addDelay); - packet.setBody(message.getBody()); + if (message.hasFileOnRemoteHost()) { + packet.setBody(message.getFileParams().url.toString()); + } else { + packet.setBody(message.getBody()); + } return packet; } @@ -95,13 +107,11 @@ public class MessageGenerator extends AbstractGenerator { public MessagePacket generatePgpChat(Message message, boolean addDelay) { MessagePacket packet = preparePacket(message, addDelay); - packet.setBody("This is an XEP-0027 encryted message"); + packet.setBody("This is an XEP-0027 encrypted message"); if (message.getEncryption() == Message.ENCRYPTION_DECRYPTED) { - packet.addChild("x", "jabber:x:encrypted").setContent( - message.getEncryptedBody()); + packet.addChild("x", "jabber:x:encrypted").setContent(message.getEncryptedBody()); } else if (message.getEncryption() == Message.ENCRYPTION_PGP) { - packet.addChild("x", "jabber:x:encrypted").setContent( - message.getBody()); + packet.addChild("x", "jabber:x:encrypted").setContent(message.getBody()); } return packet; } @@ -172,7 +182,7 @@ public class MessageGenerator extends AbstractGenerator { return receivedPacket; } - public MessagePacket generateOtrError(Jid to, String id) { + public MessagePacket generateOtrError(Jid to, String id, String errorText) { MessagePacket packet = new MessagePacket(); packet.setType(MessagePacket.TYPE_ERROR); packet.setAttribute("id",id); @@ -181,7 +191,7 @@ public class MessageGenerator extends AbstractGenerator { error.setAttribute("code","406"); error.setAttribute("type","modify"); error.addChild("not-acceptable","urn:ietf:params:xml:ns:xmpp-stanzas"); - error.addChild("text").setContent("unreadable OTR message received"); + error.addChild("text").setContent("?OTR Error:" + errorText); return packet; } } diff --git a/src/main/java/de/thedevstack/conversationsplus/generator/PresenceGenerator.java b/src/main/java/de/thedevstack/conversationsplus/generator/PresenceGenerator.java index 27fdd501..896aad71 100644 --- a/src/main/java/de/thedevstack/conversationsplus/generator/PresenceGenerator.java +++ b/src/main/java/de/thedevstack/conversationsplus/generator/PresenceGenerator.java @@ -49,9 +49,16 @@ public class PresenceGenerator extends AbstractGenerator { Element cap = packet.addChild("c", "http://jabber.org/protocol/caps"); cap.setAttribute("hash", "sha-1"); - cap.setAttribute("node", "http://conversions.im"); + cap.setAttribute("node", "http://conversations.im"); cap.setAttribute("ver", capHash); } return packet; } -}
\ No newline at end of file + + public PresencePacket sendOfflinePresence(Account account) { + PresencePacket packet = new PresencePacket(); + packet.setFrom(account.getJid()); + packet.setAttribute("type","unavailable"); + return packet; + } +} |