switched to direct invites. fixes #284

This commit is contained in:
iNPUTmice 2014-07-21 16:04:53 +02:00
parent 87aff4c6d8
commit f9ed76f5e1
4 changed files with 27 additions and 16 deletions

View File

@ -128,4 +128,14 @@ public class MessageGenerator {
packet.setFrom(conversation.getAccount().getJid());
return packet;
}
public MessagePacket invite(Conversation conversation, String contact) {
MessagePacket packet = new MessagePacket();
packet.setType(MessagePacket.TYPE_NORMAL);
packet.setTo(contact);
packet.setFrom(conversation.getAccount().getFullJid());
Element x = packet.addChild("x", "jabber:x:conference");
x.setAttribute("jid", conversation.getContactJid().split("/")[0]);
return packet;
}
}

View File

@ -221,8 +221,8 @@ public class MessageParser extends AbstractParser implements
updateLastseen(packet, account, false);
mXmppConnectionService.markMessage(account, fromParts[0], id,
Message.STATUS_SEND_RECEIVED);
} else if (packet.hasChild("x")) {
Element x = packet.findChild("x");
} else if (packet.hasChild("x","http://jabber.org/protocol/muc#user")) {
Element x = packet.findChild("x","http://jabber.org/protocol/muc#user");
if (x.hasChild("invite")) {
Conversation conversation = mXmppConnectionService
.findOrCreateConversation(account,
@ -233,6 +233,17 @@ public class MessageParser extends AbstractParser implements
}
}
} else if (packet.hasChild("x", "jabber:x:conference")) {
Element x = packet.findChild("x", "jabber:x:conference");
String jid = x.getAttribute("jid");
if (jid!=null) {
Conversation conversation = mXmppConnectionService
.findOrCreateConversation(account,jid, true);
if (!conversation.getMucOptions().online()) {
mXmppConnectionService.joinMuc(conversation);
mXmppConnectionService.updateConversationUi();
}
}
}
}

View File

@ -1223,19 +1223,9 @@ public class XmppConnectionService extends Service {
}).start();
}
public void inviteToConference(Conversation conversation, String contactJid) {
Account account = conversation.getAccount();
MessagePacket packet = new MessagePacket();
packet.setTo(conversation.getContactJid().split("/")[0]);
packet.setFrom(account.getFullJid());
Element x = new Element("x");
x.setAttribute("xmlns", "http://jabber.org/protocol/muc#user");
Element invite = new Element("invite");
invite.setAttribute("to", contactJid);
x.addChild(invite);
packet.addChild(x);
sendMessagePacket(account,packet);
Log.d(LOGTAG,packet.toString());
public void invite(Conversation conversation, String contact) {
MessagePacket packet = mMessageGenerator.invite(conversation, contact);
sendMessagePacket(conversation.getAccount(),packet);
}
public boolean markMessage(Account account, String recipient, String uuid,

View File

@ -349,7 +349,7 @@ public abstract class XmppActivity extends Activity {
String conversationUuid = data.getStringExtra("conversation");
Conversation conversation = xmppConnectionService.findConversationByUuid(conversationUuid);
if (conversation.getMode() == Conversation.MODE_MULTI) {
xmppConnectionService.inviteToConference(conversation, contactJid);
xmppConnectionService.invite(conversation, contactJid);
}
Log.d("xmppService","inviting "+contactJid+" to "+conversation.getName(true));
}