diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-09-20 15:29:06 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-09-20 15:29:06 +0200 |
commit | 295bfb7f1de98649d8a7dd5f77745e50bfc25f56 (patch) | |
tree | 5c2ba7a2f1118412c5ea504ad4ec53d73bcf778e /src/eu | |
parent | c282ef464565afd66b7a4a0d6c59162d71d9a6fe (diff) |
made xmppconnection service available in generators
Diffstat (limited to 'src/eu')
5 files changed, 27 insertions, 4 deletions
diff --git a/src/eu/siacs/conversations/generator/AbstractGenerator.java b/src/eu/siacs/conversations/generator/AbstractGenerator.java index 05d3d988..61f290e4 100644 --- a/src/eu/siacs/conversations/generator/AbstractGenerator.java +++ b/src/eu/siacs/conversations/generator/AbstractGenerator.java @@ -6,6 +6,8 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import eu.siacs.conversations.services.XmppConnectionService; + import android.util.Base64; public abstract class AbstractGenerator { @@ -19,6 +21,12 @@ public abstract class AbstractGenerator { "urn:xmpp:avatar:metadata+notify" }; public final String IDENTITY_NAME = "Conversations 0.7"; public final String IDENTITY_TYPE = "phone"; + + protected XmppConnectionService mXmppConnectionService; + + protected AbstractGenerator(XmppConnectionService service) { + this.mXmppConnectionService = service; + } public String getCapHash() { StringBuilder s = new StringBuilder(); diff --git a/src/eu/siacs/conversations/generator/IqGenerator.java b/src/eu/siacs/conversations/generator/IqGenerator.java index b5ecafb5..d44bf0ca 100644 --- a/src/eu/siacs/conversations/generator/IqGenerator.java +++ b/src/eu/siacs/conversations/generator/IqGenerator.java @@ -4,12 +4,17 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xmpp.pep.Avatar; import eu.siacs.conversations.xmpp.stanzas.IqPacket; public class IqGenerator extends AbstractGenerator { + public IqGenerator(XmppConnectionService service) { + super(service); + } + public IqPacket discoResponse(IqPacket request) { IqPacket packet = new IqPacket(IqPacket.TYPE_RESULT); packet.setId(request.getId()); diff --git a/src/eu/siacs/conversations/generator/MessageGenerator.java b/src/eu/siacs/conversations/generator/MessageGenerator.java index ecfb4744..8c0d4e23 100644 --- a/src/eu/siacs/conversations/generator/MessageGenerator.java +++ b/src/eu/siacs/conversations/generator/MessageGenerator.java @@ -10,10 +10,15 @@ import net.java.otr4j.session.Session; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Message; +import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xmpp.stanzas.MessagePacket; -public class MessageGenerator { +public class MessageGenerator extends AbstractGenerator { + public MessageGenerator(XmppConnectionService service) { + super(service); + } + private MessagePacket preparePacket(Message message, boolean addDelay) { Conversation conversation = message.getConversation(); Account account = conversation.getAccount(); diff --git a/src/eu/siacs/conversations/generator/PresenceGenerator.java b/src/eu/siacs/conversations/generator/PresenceGenerator.java index 87e361f5..d896dd00 100644 --- a/src/eu/siacs/conversations/generator/PresenceGenerator.java +++ b/src/eu/siacs/conversations/generator/PresenceGenerator.java @@ -2,11 +2,16 @@ package eu.siacs.conversations.generator; import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Contact; +import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xmpp.stanzas.PresencePacket; public class PresenceGenerator extends AbstractGenerator { + public PresenceGenerator(XmppConnectionService service) { + super(service); + } + private PresencePacket subscription(String type, Contact contact) { PresencePacket packet = new PresencePacket(); packet.setAttribute("type", type); diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java index 03f81d9a..0012713a 100644 --- a/src/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/eu/siacs/conversations/services/XmppConnectionService.java @@ -96,8 +96,8 @@ public class XmppConnectionService extends Service { private MessageParser mMessageParser = new MessageParser(this); private PresenceParser mPresenceParser = new PresenceParser(this); private IqParser mIqParser = new IqParser(this); - private MessageGenerator mMessageGenerator = new MessageGenerator(); - private PresenceGenerator mPresenceGenerator = new PresenceGenerator(); + private MessageGenerator mMessageGenerator = new MessageGenerator(this); + private PresenceGenerator mPresenceGenerator = new PresenceGenerator(this); private List<Account> accounts; private CopyOnWriteArrayList<Conversation> conversations = null; @@ -1097,7 +1097,7 @@ public class XmppConnectionService extends Service { } private OnRenameListener renameListener = null; - private IqGenerator mIqGenerator = new IqGenerator(); + private IqGenerator mIqGenerator = new IqGenerator(this); public void setOnRenameListener(OnRenameListener listener) { this.renameListener = listener; |