diff options
Diffstat (limited to 'src/main/java/eu/siacs/conversations')
3 files changed, 26 insertions, 16 deletions
diff --git a/src/main/java/eu/siacs/conversations/entities/MucOptions.java b/src/main/java/eu/siacs/conversations/entities/MucOptions.java index d4b997fc..0eb41c55 100644 --- a/src/main/java/eu/siacs/conversations/entities/MucOptions.java +++ b/src/main/java/eu/siacs/conversations/entities/MucOptions.java @@ -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)) { diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 28a353b6..521991ba 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -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()); diff --git a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java index 9e38790a..399d9fdf 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConferenceDetailsActivity.java @@ -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()) { |