mirror of
https://github.com/moparisthebest/Conversations
synced 2024-12-25 00:48:52 -05:00
This commit is contained in:
parent
b09b8136d2
commit
39bb8ad05f
@ -167,11 +167,13 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class Invite {
|
private class Invite {
|
||||||
Jid jid;
|
final Jid jid;
|
||||||
String password;
|
final String password;
|
||||||
Invite(Jid jid, String password) {
|
final Contact inviter;
|
||||||
|
Invite(Jid jid, String password, Contact inviter) {
|
||||||
this.jid = jid;
|
this.jid = jid;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
|
this.inviter = inviter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean execute(Account account) {
|
public boolean execute(Account account) {
|
||||||
@ -180,7 +182,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
|||||||
if (!conversation.getMucOptions().online()) {
|
if (!conversation.getMucOptions().online()) {
|
||||||
conversation.getMucOptions().setPassword(password);
|
conversation.getMucOptions().setPassword(password);
|
||||||
mXmppConnectionService.databaseBackend.updateConversation(conversation);
|
mXmppConnectionService.databaseBackend.updateConversation(conversation);
|
||||||
mXmppConnectionService.joinMuc(conversation);
|
mXmppConnectionService.joinMuc(conversation, inviter != null && inviter.mutualPresenceSubscription());
|
||||||
mXmppConnectionService.updateConversationUi();
|
mXmppConnectionService.updateConversationUi();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -189,18 +191,22 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Invite extractInvite(Element message) {
|
private Invite extractInvite(Account account, Element message) {
|
||||||
Element x = message.findChild("x", "http://jabber.org/protocol/muc#user");
|
Element x = message.findChild("x", "http://jabber.org/protocol/muc#user");
|
||||||
if (x != null) {
|
if (x != null) {
|
||||||
Element invite = x.findChild("invite");
|
Element invite = x.findChild("invite");
|
||||||
if (invite != null) {
|
if (invite != null) {
|
||||||
Element pw = x.findChild("password");
|
Element pw = x.findChild("password");
|
||||||
return new Invite(message.getAttributeAsJid("from"), pw != null ? pw.getContent(): null);
|
Jid from = invite.getAttributeAsJid("from");
|
||||||
|
Contact contact = from == null ? null : account.getRoster().getContact(from);
|
||||||
|
return new Invite(message.getAttributeAsJid("from"), pw != null ? pw.getContent(): null, contact);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
x = message.findChild("x","jabber:x:conference");
|
x = message.findChild("x","jabber:x:conference");
|
||||||
if (x != null) {
|
if (x != null) {
|
||||||
return new Invite(x.getAttributeAsJid("jid"),x.getAttribute("password"));
|
Jid from = message.getAttributeAsJid("from");
|
||||||
|
Contact contact = from == null ? null : account.getRoster().getContact(from);
|
||||||
|
return new Invite(x.getAttributeAsJid("jid"),x.getAttribute("password"),contact);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -364,7 +370,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
|
|||||||
counterpart = from;
|
counterpart = from;
|
||||||
}
|
}
|
||||||
|
|
||||||
Invite invite = extractInvite(packet);
|
Invite invite = extractInvite(account, packet);
|
||||||
if (invite != null && invite.execute(account)) {
|
if (invite != null && invite.execute(account)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2047,10 +2047,18 @@ public class XmppConnectionService extends Service {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void joinMuc(Conversation conversation) {
|
public void joinMuc(Conversation conversation) {
|
||||||
joinMuc(conversation, null);
|
joinMuc(conversation,null, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void joinMuc(Conversation conversation, boolean followedInvite) {
|
||||||
|
joinMuc(conversation, null, followedInvite);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void joinMuc(Conversation conversation, final OnConferenceJoined onConferenceJoined) {
|
private void joinMuc(Conversation conversation, final OnConferenceJoined onConferenceJoined) {
|
||||||
|
joinMuc(conversation,onConferenceJoined,false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void joinMuc(Conversation conversation, final OnConferenceJoined onConferenceJoined, final boolean followedInvite) {
|
||||||
Account account = conversation.getAccount();
|
Account account = conversation.getAccount();
|
||||||
account.pendingConferenceJoins.remove(conversation);
|
account.pendingConferenceJoins.remove(conversation);
|
||||||
account.pendingConferenceLeaves.remove(conversation);
|
account.pendingConferenceLeaves.remove(conversation);
|
||||||
@ -2095,6 +2103,9 @@ public class XmppConnectionService extends Service {
|
|||||||
}
|
}
|
||||||
if (mucOptions.membersOnly() && mucOptions.nonanonymous()) {
|
if (mucOptions.membersOnly() && mucOptions.nonanonymous()) {
|
||||||
fetchConferenceMembers(conversation);
|
fetchConferenceMembers(conversation);
|
||||||
|
if (followedInvite && conversation.getBookmark() == null) {
|
||||||
|
saveConversationAsBookmark(conversation,null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sendUnsentMessages(conversation);
|
sendUnsentMessages(conversation);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user