make room persistant when changing subject or other muc options

This commit is contained in:
Daniel Gultsch 2015-01-10 23:10:32 +01:00
parent 158f5dd17c
commit 18eb187949
3 changed files with 26 additions and 16 deletions

View File

@ -227,6 +227,10 @@ public class MucOptions {
return hasFeature("muc_nonanonymous");
}
public boolean persistent() {
return hasFeature("muc_persistent");
}
public void deleteUser(String name) {
for (int i = 0; i < users.size(); ++i) {
if (users.get(i).getName().equals(name)) {

View File

@ -1544,6 +1544,18 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
});
}
public void pushSubjectToConference(final Conversation conference, final String subject) {
MessagePacket packet = this.getMessageGenerator().conferenceSubject(conference, subject);
this.sendMessagePacket(conference.getAccount(), packet);
final MucOptions mucOptions = conference.getMucOptions();
final MucOptions.User self = mucOptions.getSelf();
if (!mucOptions.persistent() && self.getAffiliation().ranks(MucOptions.Affiliation.OWNER)) {
Bundle options = new Bundle();
options.putString("muc#roomconfig_persistentroom", "1");
this.pushConferenceConfiguration(conference,options,null);
}
}
public void changeAffiliationInConference(final Conversation conference, Jid user, MucOptions.Affiliation affiliation, final OnAffiliationChanged callback) {
final Jid jid = user.toBareJid();
IqPacket request = this.mIqGenerator.changeAffiliation(conference, jid, affiliation.toString());

View File

@ -39,7 +39,6 @@ import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.services.XmppConnectionService.OnMucRosterUpdate;
import eu.siacs.conversations.services.XmppConnectionService.OnConversationUpdate;
import eu.siacs.conversations.xmpp.jid.Jid;
import eu.siacs.conversations.xmpp.stanzas.MessagePacket;
public class ConferenceDetailsActivity extends XmppActivity implements OnConversationUpdate, OnMucRosterUpdate, XmppConnectionService.OnAffiliationChanged, XmppConnectionService.OnRoleChanged, XmppConnectionService.OnConferenceOptionsPushed {
public static final String ACTION_VIEW_MUC = "view_muc";
@ -63,7 +62,6 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
private ImageButton mChangeConferenceSettingsButton;
private Button mInviteButton;
private String uuid = null;
private List<User> users = new ArrayList<>();
private User mSelectedUser = null;
private boolean mAdvancedMode = false;
@ -125,6 +123,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
Bundle options = new Bundle();
options.putString("muc#roomconfig_membersonly", values[0] ? "1" : "0");
options.putString("muc#roomconfig_whois", values[1] ? "anyone" : "moderators");
options.putString("muc#roomconfig_persistentroom", "1");
xmppConnectionService.pushConferenceConfiguration(mConversation,
options,
ConferenceDetailsActivity.this);
@ -133,6 +132,13 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
builder.create().show();
}
};
private OnValueEdited onSubjectEdited = new OnValueEdited() {
@Override
public void onValueEdited(String value) {
xmppConnectionService.pushSubjectToConference(mConversation,value);
}
};
@Override
public void onConversationUpdate() {
@ -202,17 +208,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
break;
case R.id.action_edit_subject:
if (mConversation != null) {
quickEdit(mConversation.getName(), new OnValueEdited() {
@Override
public void onValueEdited(String value) {
MessagePacket packet = xmppConnectionService
.getMessageGenerator().conferenceSubject(
mConversation, value);
xmppConnectionService.sendMessagePacket(
mConversation.getAccount(), packet);
}
});
quickEdit(mConversation.getName(),this.onSubjectEdited);
}
break;
case R.id.action_save_as_bookmark:
@ -277,7 +273,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
if (contact != null) {
name = contact.getDisplayName();
} else {
name = user.getName();
name = user.getJid().toBareJid().toString();
}
menu.setHeaderTitle(name);
MenuItem startConversation = menu.findItem(R.id.start_conversation);
@ -433,8 +429,6 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
mChangeConferenceSettingsButton.setVisibility(View.GONE);
}
}
this.users.clear();
this.users.addAll(mucOptions.getUsers());
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
membersView.removeAllViews();
for (final User user : mConversation.getMucOptions().getUsers()) {