aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/services
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2014-03-15 04:59:18 +0100
committerDaniel Gultsch <daniel@gultsch.de>2014-03-15 04:59:18 +0100
commitafe12447098424254366f5714645420973b37f36 (patch)
treec951a639f70aea05da34848b8db4ceaf2594ac4a /src/eu/siacs/conversations/services
parentf3b6c9969300e09da5203436718760fbec852a31 (diff)
muc creation
Diffstat (limited to 'src/eu/siacs/conversations/services')
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java39
1 files changed, 34 insertions, 5 deletions
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index 99fc961a..54fbbbbd 100644
--- a/src/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -148,8 +148,20 @@ public class XmppConnectionService extends Service {
}
} else if (packet.getType() == MessagePacket.TYPE_ERROR) {
message = MessageParser.parseError(packet, account, service);
- } else {
- // Log.d(LOGTAG, "unparsed message " + packet.toString());
+ } else if (packet.getType() == MessagePacket.TYPE_NORMAL) {
+ if (packet.hasChild("x")) {
+ Element x = packet.findChild("x");
+ if (x.hasChild("invite")) {
+ findOrCreateConversation(account, packet.getFrom(), true);
+ if (convChangedListener != null) {
+ convChangedListener.onConversationListChanged();
+ }
+ Log.d(LOGTAG,"invitation received to "+packet.getFrom());
+ }
+
+ } else {
+ Log.d(LOGTAG, "unparsed message " + packet.toString());
+ }
}
if ((message == null)||(message.getBody() == null)) {
return;
@@ -223,7 +235,7 @@ public class XmppConnectionService extends Service {
&& (packet.findChild("x").getAttribute("xmlns")
.startsWith("http://jabber.org/protocol/muc"))) {
Conversation muc = findMuc(packet.getAttribute("from").split(
- "/")[0]);
+ "/")[0],account);
if (muc != null) {
int error = muc.getMucOptions().getError();
muc.getMucOptions().processPacket(packet);
@@ -336,9 +348,9 @@ public class XmppConnectionService extends Service {
}
- protected Conversation findMuc(String name) {
+ protected Conversation findMuc(String name, Account account) {
for (Conversation conversation : this.conversations) {
- if (conversation.getContactJid().split("/")[0].equals(name)) {
+ if (conversation.getContactJid().split("/")[0].equals(name)&&(conversation.getAccount() == account)) {
return conversation;
}
}
@@ -1246,4 +1258,21 @@ public class XmppConnectionService extends Service {
account.getXmppConnection().sendMessagePacket(packet);
}
}
+
+ public void inviteToConference(Conversation conversation,
+ List<Contact> contacts) {
+ for(Contact contact : contacts) {
+ MessagePacket packet = new MessagePacket();
+ packet.setTo(conversation.getContactJid().split("/")[0]);
+ packet.setFrom(conversation.getAccount().getFullJid());
+ Element x = new Element("x");
+ x.setAttribute("xmlns", "http://jabber.org/protocol/muc#user");
+ Element invite = new Element("invite");
+ invite.setAttribute("to", contact.getJid());
+ x.addChild(invite);
+ packet.addChild(x);
+ conversation.getAccount().getXmppConnection().sendMessagePacket(packet);
+ }
+
+ }
} \ No newline at end of file