made xmppconnection service available in generators

This commit is contained in:
iNPUTmice 2014-09-20 15:29:06 +02:00
parent c282ef4645
commit 295bfb7f1d
5 changed files with 27 additions and 4 deletions

View file

@ -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();

View file

@ -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());

View file

@ -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();

View file

@ -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);

View file

@ -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;