org.jivesoftware.smackx.muc.Occupant Java Examples
The following examples show how to use
org.jivesoftware.smackx.muc.Occupant.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XmppConnection.java From Zom-Android-XMPP with GNU General Public License v3.0 | 6 votes |
@Override public void joined(EntityFullJid entityFullJid) { XmppAddress xa = new XmppAddress(entityFullJid.toString()); ChatGroup chatGroup = mChatGroupManager.getChatGroup(xa); MultiUserChat muc = mChatGroupManager.getMultiUserChat(entityFullJid.asBareJid().toString()); Occupant occupant = muc.getOccupant(entityFullJid); Jid jidSource = (occupant != null) ? occupant.getJid() : null; if (jidSource != null) xa = new XmppAddress(jidSource.toString()); else xa = new XmppAddress(entityFullJid.toString()); Contact mucContact = new Contact(xa, xa.getUser(), Imps.Contacts.TYPE_NORMAL); chatGroup.notifyMemberJoined(entityFullJid.toString(),mucContact); if (occupant != null) { chatGroup.notifyMemberRoleUpdate(mucContact, occupant.getRole().name(), occupant.getAffiliation().toString()); } }
Example #2
Source File: UserManager.java From Spark with Apache License 2.0 | 5 votes |
/** * Returns the occupant of the room identified by their nickname. * * @param groupChatRoom the GroupChatRoom. * @param nickname the users nickname. * @return the Occupant found. */ public Occupant getOccupant(GroupChatRoom groupChatRoom, Resourcepart nickname) { EntityFullJid userJID = JidCreate.entityFullFrom(groupChatRoom.getRoomname(), nickname); Occupant occ = null; try { occ = groupChatRoom.getMultiUserChat().getOccupant(userJID); } catch (Exception e) { Log.error(e); } return occ; }
Example #3
Source File: UserManager.java From Spark with Apache License 2.0 | 5 votes |
public boolean hasVoice(GroupChatRoom groupChatRoom, Resourcepart nickname) { Occupant occupant = getOccupant(groupChatRoom, nickname); if (occupant != null) { if ( MUCRole.visitor == occupant.getRole()) { return false; } } return true; }
Example #4
Source File: XmppConnection.java From Zom-Android-XMPP with GNU General Public License v3.0 | 4 votes |
private void handleMessage (org.jivesoftware.smack.packet.Message smackMessage, boolean isOmemo, boolean notifyUser) { String body = smackMessage.getBody(); boolean isGroupMessage = smackMessage.getType() == org.jivesoftware.smack.packet.Message.Type.groupchat; if (smackMessage.getError() != null) { // smackMessage.getError().getCode(); String error = "Error " + smackMessage.getError() + " (" + smackMessage.getError().getCondition() + "): " + smackMessage.getError().getConditionText(); debug(TAG, error); return; } if (TextUtils.isEmpty(body)) { Collection<org.jivesoftware.smack.packet.Message.Body> mColl = smackMessage.getBodies(); for (org.jivesoftware.smack.packet.Message.Body bodyPart : mColl) { String msg = bodyPart.getMessage(); if (msg != null) { body = msg; break; } } } ChatSession session = findOrCreateSession(smackMessage.getFrom().toString(), isGroupMessage, false); if (session != null) //not subscribed so don't do anything { if ((!TextUtils.isEmpty(body)) && session != null) { Message rec = new Message(body); rec.setTo(new XmppAddress(smackMessage.getTo().toString())); rec.setFrom(new XmppAddress(smackMessage.getFrom().toString())); rec.setDateTime(new Date()); rec.setID(smackMessage.getStanzaId()); if (isOmemo) rec.setType(Imps.MessageType.INCOMING_ENCRYPTED_VERIFIED); else rec.setType(Imps.MessageType.INCOMING); // Detect if this was said by us, and mark message as outgoing if (isGroupMessage) { if (TextUtils.isEmpty(rec.getFrom().getResource())) { return; //do nothing if there is no resource since that is a system message } else if (rec.getFrom().getResource().equals(rec.getTo().getUser())) { try { //rec.setType(Imps.MessageType.OUTGOING); Occupant oc = mChatGroupManager.getMultiUserChat(rec.getFrom().getBareAddress()).getOccupant(JidCreate.entityFullFrom(rec.getFrom().getAddress())); if (oc != null && oc.getJid().equals(mUser.getAddress().getAddress())) return; //do nothing if it is from us } catch (Exception e){ debug(TAG,"error parsing address",e); } } } else { Contact contact = (Contact)session.getParticipant(); if (contact.getPresence() == null || contact.getPresence().getResource() == null) { session.updateParticipant(handlePresenceChanged(mRoster.getPresence(smackMessage.getFrom().asBareJid()))); } } boolean good = session.onReceiveMessage(rec, notifyUser); if (smackMessage.getExtension("request", DeliveryReceipt.NAMESPACE) != null) { if (good) { debug(TAG, "sending delivery receipt"); // got XEP-0184 request, send receipt sendReceipt(smackMessage); session.onReceiptsExpected(true); } else { debug(TAG, "not sending delivery receipt due to processing error"); } } else { //no request for delivery receipt session.onReceiptsExpected(false); } } } }
Example #5
Source File: UserManager.java From Spark with Apache License 2.0 | 2 votes |
/** * Checks to see if the Occupant is the owner of the room. * * @param occupant the occupant of a room. * @return true if the user is an owner. */ public boolean isOwner(Occupant occupant) { return occupant != null && occupant.getAffiliation() == MUCAffiliation.owner; }
Example #6
Source File: UserManager.java From Spark with Apache License 2.0 | 2 votes |
/** * Checks if the Occupant is a Member in this Room<br> * <b>admins and owners are also members!!!</b> * @param occupant * @return true if member, else false */ public boolean isMember(Occupant occupant) { return occupant != null && ( occupant.getAffiliation() == MUCAffiliation.owner || occupant.getAffiliation() == MUCAffiliation.member || occupant.getAffiliation() == MUCAffiliation.admin ); }
Example #7
Source File: UserManager.java From Spark with Apache License 2.0 | 2 votes |
/** * Checks to see if the Occupant is a moderator. * * @param occupant the Occupant of a room. * @return true if the user is a moderator. */ public boolean isModerator(Occupant occupant) { return occupant != null && occupant.getRole() == MUCRole.moderator; }
Example #8
Source File: UserManager.java From Spark with Apache License 2.0 | 2 votes |
/** * Checks to see if the user is either an owner or admin of the given room. * * @param occupant the <code>Occupant</code> to check. * @return true if the user is either an owner or admin of the room. */ public boolean isOwnerOrAdmin(Occupant occupant) { return isOwner( occupant ) || isAdmin( occupant ); }
Example #9
Source File: UserManager.java From Spark with Apache License 2.0 | 2 votes |
/** * Checks to see if the Occupant is an admin. * * @param occupant the occupant of a room. * @return true if the user is an admin. */ public boolean isAdmin(Occupant occupant) { return occupant != null && occupant.getAffiliation() == MUCAffiliation.admin; }