use of de.pixart.messenger.entities.MucOptions in project Pix-Art-Messenger by kriztan.
the class XmppConnectionService method pushSubjectToConference.
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 (self.getAffiliation().ranks(MucOptions.Affiliation.OWNER)) {
Bundle options = new Bundle();
options.putString("muc#roomconfig_persistentroom", "1");
options.putString("muc#roomconfig_roomname", subject);
this.pushConferenceConfiguration(conference, options, null);
}
}
use of de.pixart.messenger.entities.MucOptions in project Pix-Art-Messenger by kriztan.
the class XmppConnectionService method joinMuc.
private void joinMuc(Conversation conversation, final OnConferenceJoined onConferenceJoined, final boolean followedInvite) {
Account account = conversation.getAccount();
account.pendingConferenceJoins.remove(conversation);
account.pendingConferenceLeaves.remove(conversation);
if (account.getStatus() == Account.State.ONLINE) {
// disabled for testing strange MUC leaves
sendPresencePacket(account, mPresenceGenerator.leave(conversation.getMucOptions()));
conversation.resetMucOptions();
if (onConferenceJoined != null) {
conversation.getMucOptions().flagNoAutoPushConfiguration();
}
conversation.setHasMessagesLeftOnServer(false);
fetchConferenceConfiguration(conversation, new OnConferenceConfigurationFetched() {
private void join(Conversation conversation) {
Account account = conversation.getAccount();
final MucOptions mucOptions = conversation.getMucOptions();
final Jid joinJid = mucOptions.getSelf().getFullJid();
Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": joining conversation " + joinJid.toString());
PresencePacket packet = mPresenceGenerator.selfPresence(account, Presence.Status.ONLINE, mucOptions.nonanonymous() || onConferenceJoined != null);
packet.setTo(joinJid);
Element x = packet.addChild("x", "http://jabber.org/protocol/muc");
if (conversation.getMucOptions().getPassword() != null) {
x.addChild("password").setContent(mucOptions.getPassword());
}
if (mucOptions.mamSupport()) {
// Use MAM instead of the limited muc history to get history
x.addChild("history").setAttribute("maxchars", "0");
} else {
// Fallback to muc history
x.addChild("history").setAttribute("since", PresenceGenerator.getTimestamp(conversation.getLastMessageTransmitted().getTimestamp()));
}
sendPresencePacket(account, packet);
if (onConferenceJoined != null) {
onConferenceJoined.onConferenceJoined(conversation);
}
if (!joinJid.equals(conversation.getJid())) {
conversation.setContactJid(joinJid);
databaseBackend.updateConversation(conversation);
}
if (mucOptions.mamSupport()) {
getMessageArchiveService().catchupMUC(conversation);
}
if (mucOptions.isPrivateAndNonAnonymous()) {
fetchConferenceMembers(conversation);
if (followedInvite && conversation.getBookmark() == null) {
saveConversationAsBookmark(conversation, null);
}
}
sendUnsentMessages(conversation);
}
@Override
public void onConferenceConfigurationFetched(Conversation conversation) {
join(conversation);
}
@Override
public void onFetchFailed(final Conversation conversation, Element error) {
if (error != null && "remote-server-not-found".equals(error.getName())) {
conversation.getMucOptions().setError(MucOptions.Error.SERVER_NOT_FOUND);
updateConversationUi();
} else {
join(conversation);
fetchConferenceConfiguration(conversation);
}
}
});
updateConversationUi();
} else {
account.pendingConferenceJoins.add(conversation);
conversation.resetMucOptions();
conversation.setHasMessagesLeftOnServer(false);
updateConversationUi();
}
}
use of de.pixart.messenger.entities.MucOptions in project Pix-Art-Messenger by kriztan.
the class ConferenceDetailsActivity method updateView.
private void updateView() {
invalidateOptionsMenu();
final MucOptions mucOptions = mConversation.getMucOptions();
final User self = mucOptions.getSelf();
String account;
if (Config.DOMAIN_LOCK != null) {
account = mConversation.getAccount().getJid().getLocalpart();
} else {
account = mConversation.getAccount().getJid().toBareJid().toString();
}
if (getSupportActionBar() != null) {
final ActionBar ab = getSupportActionBar();
if (ab != null) {
ab.setCustomView(R.layout.ab_title);
ab.setDisplayShowCustomEnabled(true);
TextView abtitle = findViewById(android.R.id.text1);
TextView absubtitle = findViewById(android.R.id.text2);
abtitle.setText(mConversation.getName());
abtitle.setSelected(true);
abtitle.setClickable(false);
absubtitle.setVisibility(View.GONE);
absubtitle.setClickable(false);
}
}
ConferenceName.setText(mConversation.getName());
mAccountJid.setText(getString(R.string.using_account, account));
if (xmppConnectionService.multipleAccounts()) {
mAccountJid.setVisibility(View.VISIBLE);
} else {
mAccountJid.setVisibility(View.GONE);
}
mYourPhoto.setImageBitmap(avatarService().get(mConversation.getAccount(), getPixel(48)));
setTitle(mConversation.getName());
mFullJid.setText(mConversation.getJid().toBareJid().toString());
mYourNick.setText(mucOptions.getActualNick());
TextView mRoleAffiliaton = findViewById(R.id.muc_role);
if (mucOptions.online()) {
mMoreDetails.setVisibility(View.VISIBLE);
mMucSettings.setVisibility(View.VISIBLE);
mConferenceInfoTable.setVisibility(this.mAdvancedMode ? View.VISIBLE : View.GONE);
final String status = getStatus(self);
if (status != null) {
mRoleAffiliaton.setVisibility(View.VISIBLE);
mRoleAffiliaton.setText(status);
} else {
mRoleAffiliaton.setVisibility(View.GONE);
}
if (mucOptions.membersOnly()) {
mConferenceType.setText(R.string.private_conference);
} else {
mConferenceType.setText(R.string.public_conference);
}
if (mucOptions.mamSupport()) {
mConferenceInfoMam.setText(R.string.server_info_available);
} else {
mConferenceInfoMam.setText(R.string.server_info_unavailable);
}
if (self.getAffiliation().ranks(MucOptions.Affiliation.OWNER)) {
mDestroyButton.setVisibility(View.VISIBLE);
mChangeConferenceSettingsButton.setVisibility(View.VISIBLE);
} else {
mDestroyButton.setVisibility(View.GONE);
mChangeConferenceSettingsButton.setVisibility(View.GONE);
}
} else {
mMoreDetails.setVisibility(View.GONE);
mMucSettings.setVisibility(View.GONE);
mConferenceInfoTable.setVisibility(View.GONE);
}
long mutedTill = mConversation.getLongAttribute(Conversation.ATTRIBUTE_MUTED_TILL, 0);
if (mutedTill == Long.MAX_VALUE) {
mNotifyStatusText.setText(R.string.notify_never);
mNotifyStatusButton.setImageResource(R.drawable.ic_notifications_off_grey600_24dp);
} else if (System.currentTimeMillis() < mutedTill) {
mNotifyStatusText.setText(R.string.notify_paused);
mNotifyStatusButton.setImageResource(R.drawable.ic_notifications_paused_grey600_24dp);
} else if (mConversation.alwaysNotify()) {
mNotifyStatusButton.setImageResource(R.drawable.ic_notifications_grey600_24dp);
mNotifyStatusText.setText(R.string.notify_on_all_messages);
} else {
mNotifyStatusButton.setImageResource(R.drawable.ic_notifications_none_grey600_24dp);
mNotifyStatusText.setText(R.string.notify_only_when_highlighted);
}
final LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
membersView.removeAllViews();
if (inflater == null) {
return;
}
final ArrayList<User> users = mucOptions.getUsers();
Collections.sort(users);
for (final User user : users) {
ContactBinding binding = DataBindingUtil.inflate(inflater, R.layout.contact, membersView, false);
final Contact contact = user.getContact();
final String name = user.getName();
this.setListItemBackgroundOnView(binding.getRoot());
if (contact != null && contact.showInRoster()) {
binding.getRoot().setOnClickListener((OnClickListener) view -> switchToContactDetails(contact));
}
registerForContextMenu(binding.getRoot());
binding.getRoot().setTag(user);
if (mAdvancedMode && user.getPgpKeyId() != 0) {
binding.key.setVisibility(View.VISIBLE);
binding.key.setOnClickListener(v -> viewPgpKey(user));
binding.key.setText(OpenPgpUtils.convertKeyIdToHex(user.getPgpKeyId()));
}
if (contact != null) {
binding.contactDisplayName.setText(contact.getDisplayName());
binding.contactJid.setText((name != null ? name + " \u2022 " : "") + getStatus(user));
} else {
binding.contactDisplayName.setText(name == null ? "" : name);
binding.contactJid.setText(getStatus(user));
}
loadAvatar(user, binding.contactPhoto);
if (user.getRole() == MucOptions.Role.NONE) {
binding.contactDisplayName.setAlpha(INACTIVE_ALPHA);
binding.key.setAlpha(INACTIVE_ALPHA);
binding.contactJid.setAlpha(INACTIVE_ALPHA);
binding.contactPhoto.setAlpha(INACTIVE_ALPHA);
}
membersView.addView(binding.getRoot());
if (mConversation.getMucOptions().canInvite()) {
mInviteButton.setVisibility(View.VISIBLE);
} else {
mInviteButton.setVisibility(View.GONE);
}
}
}
use of de.pixart.messenger.entities.MucOptions in project Pix-Art-Messenger by kriztan.
the class ConversationFragment method updateStatusMessages.
protected void updateStatusMessages() {
updateDateBubbles();
synchronized (this.messageList) {
if (showLoadMoreMessages(conversation)) {
this.messageList.add(0, Message.createLoadMoreMessage(conversation));
}
if (conversation.getMode() == Conversation.MODE_MULTI) {
final MucOptions mucOptions = conversation.getMucOptions();
final List<MucOptions.User> allUsers = mucOptions.getUsers();
final Set<ReadByMarker> addedMarkers = new HashSet<>();
ChatState state = ChatState.COMPOSING;
List<MucOptions.User> users = conversation.getMucOptions().getUsersWithChatState(state, 5);
if (users.size() == 0) {
state = ChatState.PAUSED;
users = conversation.getMucOptions().getUsersWithChatState(state, 5);
}
if (mucOptions.isPrivateAndNonAnonymous()) {
for (int i = this.messageList.size() - 1; i >= 0; --i) {
final Set<ReadByMarker> markersForMessage = messageList.get(i).getReadByMarkers();
final List<MucOptions.User> shownMarkers = new ArrayList<>();
for (ReadByMarker marker : markersForMessage) {
if (!ReadByMarker.contains(marker, addedMarkers)) {
// may be put outside this condition. set should do dedup anyway
addedMarkers.add(marker);
MucOptions.User user = mucOptions.findUser(marker);
shownMarkers.add(user);
}
}
final ReadByMarker markerForSender = ReadByMarker.from(messageList.get(i));
final Message statusMessage;
final int size = shownMarkers.size();
if (size > 1) {
final String body;
if (size <= 4) {
body = getString(R.string.contacts_have_read_up_to_this_point, UIHelper.concatNames(shownMarkers));
} else {
body = getString(R.string.contacts_and_n_more_have_read_up_to_this_point, UIHelper.concatNames(shownMarkers, 3), size - 3);
}
statusMessage = Message.createStatusMessage(conversation, body);
statusMessage.setCounterparts(shownMarkers);
} else if (size == 1) {
statusMessage = Message.createStatusMessage(conversation, getString(R.string.contact_has_read_up_to_this_point, UIHelper.getDisplayName(shownMarkers.get(0))));
statusMessage.setCounterpart(shownMarkers.get(0).getFullJid());
statusMessage.setTrueCounterpart(shownMarkers.get(0).getRealJid());
} else {
statusMessage = null;
}
if (statusMessage != null) {
this.messageList.add(i + 1, statusMessage);
}
addedMarkers.add(markerForSender);
if (ReadByMarker.allUsersRepresented(allUsers, addedMarkers)) {
break;
}
}
}
}
}
}
use of de.pixart.messenger.entities.MucOptions in project Pix-Art-Messenger by kriztan.
the class PresenceParser method parseConferencePresence.
public void parseConferencePresence(PresencePacket packet, Account account) {
final Conversation conversation = packet.getFrom() == null ? null : mXmppConnectionService.find(account, packet.getFrom().toBareJid());
if (conversation != null) {
final MucOptions mucOptions = conversation.getMucOptions();
boolean before = mucOptions.online();
int count = mucOptions.getUserCount();
final List<MucOptions.User> tileUserBefore = mucOptions.getUsers(5);
processConferencePresence(packet, conversation);
final List<MucOptions.User> tileUserAfter = mucOptions.getUsers(5);
if (!tileUserAfter.equals(tileUserBefore)) {
mXmppConnectionService.getAvatarService().clear(mucOptions);
}
if (before != mucOptions.online() || (mucOptions.online() && count != mucOptions.getUserCount())) {
mXmppConnectionService.updateConversationUi();
} else if (mucOptions.online()) {
mXmppConnectionService.updateMucRosterUi();
}
}
}
Aggregations