make newly created conferences private by default
This commit is contained in:
parent
c4e82eb3f8
commit
841e718d6a
|
@ -118,6 +118,7 @@ public class MucOptions {
|
||||||
|
|
||||||
public static final String STATUS_CODE_ROOM_CONFIG_CHANGED = "104";
|
public static final String STATUS_CODE_ROOM_CONFIG_CHANGED = "104";
|
||||||
public static final String STATUS_CODE_SELF_PRESENCE = "110";
|
public static final String STATUS_CODE_SELF_PRESENCE = "110";
|
||||||
|
public static final String STATUS_CODE_ROOM_CREATED = "201";
|
||||||
public static final String STATUS_CODE_BANNED = "301";
|
public static final String STATUS_CODE_BANNED = "301";
|
||||||
public static final String STATUS_CODE_CHANGED_NICK = "303";
|
public static final String STATUS_CODE_CHANGED_NICK = "303";
|
||||||
public static final String STATUS_CODE_KICKED = "307";
|
public static final String STATUS_CODE_KICKED = "307";
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.siacs.conversations.generator;
|
package eu.siacs.conversations.generator;
|
||||||
|
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
@ -343,4 +344,13 @@ public class IqGenerator extends AbstractGenerator {
|
||||||
packet.query("http://jabber.org/protocol/muc#admin").addChild("item").setAttribute("affiliation",affiliation);
|
packet.query("http://jabber.org/protocol/muc#admin").addChild("item").setAttribute("affiliation",affiliation);
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Bundle defaultRoomConfiguration() {
|
||||||
|
Bundle options = new Bundle();
|
||||||
|
options.putString("muc#roomconfig_persistentroom", "1");
|
||||||
|
options.putString("muc#roomconfig_membersonly", "1");
|
||||||
|
options.putString("muc#roomconfig_publicroom", "0");
|
||||||
|
options.putString("muc#roomconfig_whois", "anyone");
|
||||||
|
return options;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import eu.siacs.conversations.entities.Conversation;
|
||||||
import eu.siacs.conversations.entities.Message;
|
import eu.siacs.conversations.entities.Message;
|
||||||
import eu.siacs.conversations.entities.MucOptions;
|
import eu.siacs.conversations.entities.MucOptions;
|
||||||
import eu.siacs.conversations.entities.Presence;
|
import eu.siacs.conversations.entities.Presence;
|
||||||
|
import eu.siacs.conversations.generator.IqGenerator;
|
||||||
import eu.siacs.conversations.generator.PresenceGenerator;
|
import eu.siacs.conversations.generator.PresenceGenerator;
|
||||||
import eu.siacs.conversations.services.XmppConnectionService;
|
import eu.siacs.conversations.services.XmppConnectionService;
|
||||||
import eu.siacs.conversations.xml.Element;
|
import eu.siacs.conversations.xml.Element;
|
||||||
|
@ -77,6 +78,15 @@ public class PresenceParser extends AbstractParser implements
|
||||||
} else {
|
} else {
|
||||||
mucOptions.addUser(user);
|
mucOptions.addUser(user);
|
||||||
}
|
}
|
||||||
|
if (codes.contains(MucOptions.STATUS_CODE_ROOM_CREATED)) {
|
||||||
|
Log.d(Config.LOGTAG,mucOptions.getAccount().getJid().toBareJid()
|
||||||
|
+": room '"
|
||||||
|
+mucOptions.getConversation().getJid().toBareJid()
|
||||||
|
+"' created. pushing default configuration");
|
||||||
|
mXmppConnectionService.pushConferenceConfiguration(mucOptions.getConversation(),
|
||||||
|
IqGenerator.defaultRoomConfiguration(),
|
||||||
|
null);
|
||||||
|
}
|
||||||
if (mXmppConnectionService.getPgpEngine() != null) {
|
if (mXmppConnectionService.getPgpEngine() != null) {
|
||||||
Element signed = packet.findChild("x", "jabber:x:signed");
|
Element signed = packet.findChild("x", "jabber:x:signed");
|
||||||
if (signed != null) {
|
if (signed != null) {
|
||||||
|
|
|
@ -2034,7 +2034,10 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createAdhocConference(final Account account, final Iterable<Jid> jids, final UiCallback<Conversation> callback) {
|
public void createAdhocConference(final Account account,
|
||||||
|
final String subject,
|
||||||
|
final Iterable<Jid> jids,
|
||||||
|
final UiCallback<Conversation> callback) {
|
||||||
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": creating adhoc conference with " + jids.toString());
|
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": creating adhoc conference with " + jids.toString());
|
||||||
if (account.getStatus() == Account.State.ONLINE) {
|
if (account.getStatus() == Account.State.ONLINE) {
|
||||||
try {
|
try {
|
||||||
|
@ -2045,20 +2048,18 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String name = new BigInteger(75, getRNG()).toString(32);
|
String localpart = new BigInteger(75, getRNG()).toString(32);
|
||||||
Jid jid = Jid.fromParts(name, server, null);
|
Jid jid = Jid.fromParts(localpart, server, null);
|
||||||
final Conversation conversation = findOrCreateConversation(account, jid, true);
|
final Conversation conversation = findOrCreateConversation(account, jid, true);
|
||||||
joinMuc(conversation, new OnConferenceJoined() {
|
joinMuc(conversation, new OnConferenceJoined() {
|
||||||
@Override
|
@Override
|
||||||
public void onConferenceJoined(final Conversation conversation) {
|
public void onConferenceJoined(final Conversation conversation) {
|
||||||
Bundle options = new Bundle();
|
pushConferenceConfiguration(conversation, IqGenerator.defaultRoomConfiguration(), new OnConferenceOptionsPushed() {
|
||||||
options.putString("muc#roomconfig_persistentroom", "1");
|
|
||||||
options.putString("muc#roomconfig_membersonly", "1");
|
|
||||||
options.putString("muc#roomconfig_publicroom", "0");
|
|
||||||
options.putString("muc#roomconfig_whois", "anyone");
|
|
||||||
pushConferenceConfiguration(conversation, options, new OnConferenceOptionsPushed() {
|
|
||||||
@Override
|
@Override
|
||||||
public void onPushSucceeded() {
|
public void onPushSucceeded() {
|
||||||
|
if (subject != null && !subject.trim().isEmpty()) {
|
||||||
|
pushSubjectToConference(conversation, subject);
|
||||||
|
}
|
||||||
for (Jid invite : jids) {
|
for (Jid invite : jids) {
|
||||||
invite(conversation, invite);
|
invite(conversation, invite);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1159,7 +1159,7 @@ public abstract class XmppActivity extends Activity {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
jids.add(conversation.getJid().toBareJid());
|
jids.add(conversation.getJid().toBareJid());
|
||||||
service.createAdhocConference(conversation.getAccount(), jids, activity.adhocCallback);
|
service.createAdhocConference(conversation.getAccount(), null, jids, activity.adhocCallback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue