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.Collections;
import java.util.List; import java.util.List;
import eu.siacs.conversations.services.XmppConnectionService;
import android.util.Base64; import android.util.Base64;
public abstract class AbstractGenerator { public abstract class AbstractGenerator {
@ -19,6 +21,12 @@ public abstract class AbstractGenerator {
"urn:xmpp:avatar:metadata+notify" }; "urn:xmpp:avatar:metadata+notify" };
public final String IDENTITY_NAME = "Conversations 0.7"; public final String IDENTITY_NAME = "Conversations 0.7";
public final String IDENTITY_TYPE = "phone"; public final String IDENTITY_TYPE = "phone";
protected XmppConnectionService mXmppConnectionService;
protected AbstractGenerator(XmppConnectionService service) {
this.mXmppConnectionService = service;
}
public String getCapHash() { public String getCapHash() {
StringBuilder s = new StringBuilder(); StringBuilder s = new StringBuilder();

View File

@ -4,12 +4,17 @@ import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xml.Element;
import eu.siacs.conversations.xmpp.pep.Avatar; import eu.siacs.conversations.xmpp.pep.Avatar;
import eu.siacs.conversations.xmpp.stanzas.IqPacket; import eu.siacs.conversations.xmpp.stanzas.IqPacket;
public class IqGenerator extends AbstractGenerator { public class IqGenerator extends AbstractGenerator {
public IqGenerator(XmppConnectionService service) {
super(service);
}
public IqPacket discoResponse(IqPacket request) { public IqPacket discoResponse(IqPacket request) {
IqPacket packet = new IqPacket(IqPacket.TYPE_RESULT); IqPacket packet = new IqPacket(IqPacket.TYPE_RESULT);
packet.setId(request.getId()); 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.Account;
import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xml.Element;
import eu.siacs.conversations.xmpp.stanzas.MessagePacket; 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) { private MessagePacket preparePacket(Message message, boolean addDelay) {
Conversation conversation = message.getConversation(); Conversation conversation = message.getConversation();
Account account = conversation.getAccount(); 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.Account;
import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.xml.Element; import eu.siacs.conversations.xml.Element;
import eu.siacs.conversations.xmpp.stanzas.PresencePacket; import eu.siacs.conversations.xmpp.stanzas.PresencePacket;
public class PresenceGenerator extends AbstractGenerator { public class PresenceGenerator extends AbstractGenerator {
public PresenceGenerator(XmppConnectionService service) {
super(service);
}
private PresencePacket subscription(String type, Contact contact) { private PresencePacket subscription(String type, Contact contact) {
PresencePacket packet = new PresencePacket(); PresencePacket packet = new PresencePacket();
packet.setAttribute("type", type); packet.setAttribute("type", type);

View File

@ -96,8 +96,8 @@ public class XmppConnectionService extends Service {
private MessageParser mMessageParser = new MessageParser(this); private MessageParser mMessageParser = new MessageParser(this);
private PresenceParser mPresenceParser = new PresenceParser(this); private PresenceParser mPresenceParser = new PresenceParser(this);
private IqParser mIqParser = new IqParser(this); private IqParser mIqParser = new IqParser(this);
private MessageGenerator mMessageGenerator = new MessageGenerator(); private MessageGenerator mMessageGenerator = new MessageGenerator(this);
private PresenceGenerator mPresenceGenerator = new PresenceGenerator(); private PresenceGenerator mPresenceGenerator = new PresenceGenerator(this);
private List<Account> accounts; private List<Account> accounts;
private CopyOnWriteArrayList<Conversation> conversations = null; private CopyOnWriteArrayList<Conversation> conversations = null;
@ -1097,7 +1097,7 @@ public class XmppConnectionService extends Service {
} }
private OnRenameListener renameListener = null; private OnRenameListener renameListener = null;
private IqGenerator mIqGenerator = new IqGenerator(); private IqGenerator mIqGenerator = new IqGenerator(this);
public void setOnRenameListener(OnRenameListener listener) { public void setOnRenameListener(OnRenameListener listener) {
this.renameListener = listener; this.renameListener = listener;