cleanup for presence parser
This commit is contained in:
parent
99935dd630
commit
99fe44a737
|
@ -118,7 +118,7 @@ public class MessageGenerator {
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessagePacket conversationSubject(Conversation conversation,String subject) {
|
public MessagePacket conferenceSubject(Conversation conversation,String subject) {
|
||||||
MessagePacket packet = new MessagePacket();
|
MessagePacket packet = new MessagePacket();
|
||||||
packet.setType(MessagePacket.TYPE_GROUPCHAT);
|
packet.setType(MessagePacket.TYPE_GROUPCHAT);
|
||||||
packet.setTo(conversation.getContactJid().split("/")[0]);
|
packet.setTo(conversation.getContactJid().split("/")[0]);
|
||||||
|
|
|
@ -6,36 +6,28 @@ import eu.siacs.conversations.xmpp.stanzas.PresencePacket;
|
||||||
|
|
||||||
public class PresenceGenerator {
|
public class PresenceGenerator {
|
||||||
|
|
||||||
public PresencePacket requestPresenceUpdatesFrom(Contact contact) {
|
private PresencePacket subscription(String type, Contact contact) {
|
||||||
PresencePacket packet = new PresencePacket();
|
PresencePacket packet = new PresencePacket();
|
||||||
packet.setAttribute("type", "subscribe");
|
packet.setAttribute("type", type);
|
||||||
packet.setAttribute("to", contact.getJid());
|
packet.setAttribute("to", contact.getJid());
|
||||||
packet.setAttribute("from", contact.getAccount().getJid());
|
packet.setAttribute("from", contact.getAccount().getJid());
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PresencePacket requestPresenceUpdatesFrom(Contact contact) {
|
||||||
|
return subscription("subscribe", contact);
|
||||||
|
}
|
||||||
|
|
||||||
public PresencePacket stopPresenceUpdatesFrom(Contact contact) {
|
public PresencePacket stopPresenceUpdatesFrom(Contact contact) {
|
||||||
PresencePacket packet = new PresencePacket();
|
return subscription("unsubscribe", contact);
|
||||||
packet.setAttribute("type", "unsubscribe");
|
|
||||||
packet.setAttribute("to", contact.getJid());
|
|
||||||
packet.setAttribute("from", contact.getAccount().getJid());
|
|
||||||
return packet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PresencePacket stopPresenceUpdatesTo(Contact contact) {
|
public PresencePacket stopPresenceUpdatesTo(Contact contact) {
|
||||||
PresencePacket packet = new PresencePacket();
|
return subscription("unsubscribed", contact);
|
||||||
packet.setAttribute("type", "unsubscribed");
|
|
||||||
packet.setAttribute("to", contact.getJid());
|
|
||||||
packet.setAttribute("from", contact.getAccount().getJid());
|
|
||||||
return packet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PresencePacket sendPresenceUpdatesTo(Contact contact) {
|
public PresencePacket sendPresenceUpdatesTo(Contact contact) {
|
||||||
PresencePacket packet = new PresencePacket();
|
return subscription("subscribed", contact);
|
||||||
packet.setAttribute("type", "subscribed");
|
|
||||||
packet.setAttribute("to", contact.getJid());
|
|
||||||
packet.setAttribute("from", contact.getAccount().getJid());
|
|
||||||
return packet;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PresencePacket sendPresence(Account account) {
|
public PresencePacket sendPresence(Account account) {
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class MucDetailsActivity extends XmppActivity {
|
||||||
String subject = mSubject.getText().toString();
|
String subject = mSubject.getText().toString();
|
||||||
MucOptions options = conversation.getMucOptions();
|
MucOptions options = conversation.getMucOptions();
|
||||||
if (!subject.equals(options.getSubject())) {
|
if (!subject.equals(options.getSubject())) {
|
||||||
MessagePacket packet = xmppConnectionService.getMessageGenerator().conversationSubject(conversation, subject);
|
MessagePacket packet = xmppConnectionService.getMessageGenerator().conferenceSubject(conversation, subject);
|
||||||
xmppConnectionService.sendMessagePacket(conversation.getAccount(), packet);
|
xmppConnectionService.sendMessagePacket(conversation.getAccount(), packet);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue