aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-07-21 16:04:53 +0200
committeriNPUTmice <daniel@gultsch.de>2014-07-21 16:04:53 +0200
commitf9ed76f5e130f744e118ac752728949688a206a9 (patch)
tree25f25b1f82026cf51ab46d56d2af6bb79dd7f6e9 /src
parent87aff4c6d8ba516bf847b69bab25e5601a3bcd76 (diff)
switched to direct invites. fixes #284
Diffstat (limited to 'src')
-rw-r--r--src/eu/siacs/conversations/generator/MessageGenerator.java10
-rw-r--r--src/eu/siacs/conversations/parser/MessageParser.java15
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java16
-rw-r--r--src/eu/siacs/conversations/ui/XmppActivity.java2
4 files changed, 27 insertions, 16 deletions
diff --git a/src/eu/siacs/conversations/generator/MessageGenerator.java b/src/eu/siacs/conversations/generator/MessageGenerator.java
index 5a216a7ef..3195c953a 100644
--- a/src/eu/siacs/conversations/generator/MessageGenerator.java
+++ b/src/eu/siacs/conversations/generator/MessageGenerator.java
@@ -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;
+ }
}
diff --git a/src/eu/siacs/conversations/parser/MessageParser.java b/src/eu/siacs/conversations/parser/MessageParser.java
index 1b03f4ee3..08930a3b3 100644
--- a/src/eu/siacs/conversations/parser/MessageParser.java
+++ b/src/eu/siacs/conversations/parser/MessageParser.java
@@ -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();
+ }
+ }
}
}
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index 0ac1adf76..ad522fd94 100644
--- a/src/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -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,
diff --git a/src/eu/siacs/conversations/ui/XmppActivity.java b/src/eu/siacs/conversations/ui/XmppActivity.java
index 2bf7cf5a1..fc51abeff 100644
--- a/src/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/eu/siacs/conversations/ui/XmppActivity.java
@@ -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));
}