mirror of
https://github.com/moparisthebest/Conversations
synced 2024-11-24 17:52:17 -05:00
made xmppconnection service available in generators
This commit is contained in:
parent
c282ef4645
commit
295bfb7f1d
@ -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 {
|
||||
@ -20,6 +22,12 @@ public abstract class AbstractGenerator {
|
||||
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();
|
||||
s.append("client/" + IDENTITY_TYPE + "//" + IDENTITY_NAME + "<");
|
||||
|
@ -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());
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user