Java Code Examples for org.jxmpp.jid.Jid#asBareJid()
The following examples show how to use
org.jxmpp.jid.Jid#asBareJid() .
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: RosterGroup.java From Smack with Apache License 2.0 | 6 votes |
/** * Returns the roster entry associated with the given XMPP address or * <code>null</code> if the user is not an entry in the group. * * @param user the XMPP address of the user (eg "[email protected]"). * @return the roster entry or <code>null</code> if it does not exist in the group. */ public RosterEntry getEntry(Jid user) { if (user == null) { return null; } // Roster entries never include a resource so remove the resource // if it's a part of the XMPP address. user = user.asBareJid(); synchronized (entries) { for (RosterEntry entry : entries) { if (entry.getJid().equals(user)) { return entry; } } } return null; }
Example 2
Source File: IoTIsFriendResponseProvider.java From Smack with Apache License 2.0 | 5 votes |
@Override public IoTIsFriendResponse parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws XmppStringprepException { Jid jid = ParserUtils.getJidAttribute(parser); BareJid bareJid = jid.asBareJid(); boolean result = ParserUtils.getBooleanAttribute(parser, "result"); return new IoTIsFriendResponse(bareJid, result); }
Example 3
Source File: IoTRemoveProvider.java From Smack with Apache License 2.0 | 5 votes |
@Override public IoTRemove parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) throws IOException { Jid jid = ParserUtils.getJidAttribute(parser); if (jid.hasResource()) { // TODO: Should be SmackParseException. throw new IOException("JID must be without resourcepart"); } BareJid bareJid = jid.asBareJid(); NodeInfo nodeInfo = NodeInfoParser.parse(parser); return new IoTRemove(bareJid, nodeInfo); }
Example 4
Source File: AbstractFromToMatchesFilter.java From Smack with Apache License 2.0 | 5 votes |
/** * Creates a filter matching on the address returned by {@link #getAddressToCompare(Stanza)}. The address must be * the same as the filter address. The second parameter specifies whether the full or the bare addresses are * compared. * * @param address The address to filter for. If <code>null</code> is given, then * {@link #getAddressToCompare(Stanza)} must also return <code>null</code> to match. * @param ignoreResourcepart TODO javadoc me please */ protected AbstractFromToMatchesFilter(Jid address, boolean ignoreResourcepart) { if (address != null && ignoreResourcepart) { this.address = address.asBareJid(); } else { this.address = address; } this.ignoreResourcepart = ignoreResourcepart; }
Example 5
Source File: AbstractFromToMatchesFilter.java From Smack with Apache License 2.0 | 5 votes |
@Override public final boolean accept(final Stanza stanza) { Jid stanzaAddress = getAddressToCompare(stanza); if (stanzaAddress == null) { return address == null; } if (ignoreResourcepart) { stanzaAddress = stanzaAddress.asBareJid(); } return stanzaAddress.equals(address); }
Example 6
Source File: Roster.java From Smack with Apache License 2.0 | 5 votes |
/** * Check if the given JID is subscribed to the user's presence. * <p> * If the JID is subscribed to the user's presence then it is allowed to see the presence and * will get notified about presence changes. Also returns true, if the JID is the service * name of the XMPP connection (the "XMPP domain"), i.e. the XMPP service is treated like * having an implicit subscription to the users presence. * </p> * Note that if the roster is not loaded, then this method will always return false. * * @param jid TODO javadoc me please * @return true if the given JID is allowed to see the users presence. * @since 4.1 */ public boolean isSubscribedToMyPresence(Jid jid) { if (jid == null) { return false; } BareJid bareJid = jid.asBareJid(); if (connection().getXMPPServiceDomain().equals(bareJid)) { return true; } RosterEntry entry = getEntry(bareJid); if (entry == null) { return false; } return entry.canSeeMyPresence(); }
Example 7
Source File: Roster.java From Smack with Apache License 2.0 | 5 votes |
/** * Check if the XMPP entity this roster belongs to is subscribed to the presence of the given JID. * * @param jid the jid to check. * @return <code>true</code> if we are subscribed to the presence of the given jid. * @since 4.2 */ public boolean iAmSubscribedTo(Jid jid) { if (jid == null) { return false; } BareJid bareJid = jid.asBareJid(); RosterEntry entry = getEntry(bareJid); if (entry == null) { return false; } return entry.canSeeHisPresence(); }
Example 8
Source File: NotificationPlugin.java From Spark with Apache License 2.0 | 5 votes |
@Override public void processStanza(Stanza stanza) { final Presence presence = (Presence)stanza; Jid jid = presence.getFrom(); if (jid == null) { return; } // Make sure the user is in the contact list. ContactItem contactItem = SparkManager.getWorkspace().getContactList().getContactItemByJID(jid); if (contactItem == null) { return; } BareJid bareJid = jid.asBareJid(); boolean isOnline = onlineUsers.contains(jid); if (presence.isAvailable()) { if (preferences.isOnlineNotificationsOn()) { if (!isOnline) { notifyUserOnline(bareJid, presence); } } onlineUsers.add(bareJid); } else { if (preferences.isOfflineNotificationsOn() && isOnline) { notifyUserOffline(bareJid, presence); } onlineUsers.remove(bareJid); } }
Example 9
Source File: CallPeerJabberImpl.java From jitsi with Apache License 2.0 | 4 votes |
/** * Processes a specific "XEP-0251: Jingle Session Transfer" * <tt>transfer</tt> packet (extension). * * @param transfer the "XEP-0251: Jingle Session Transfer" transfer packet * (extension) to process * @throws OperationFailedException if anything goes wrong while processing * the specified <tt>transfer</tt> packet (extension) */ public void processTransfer(TransferPacketExtension transfer) throws OperationFailedException { Jid attendantAddress = transfer.getFrom(); if (attendantAddress == null) { throw new OperationFailedException( "Session transfer must contain a \'from\' attribute value.", OperationFailedException.ILLEGAL_ARGUMENT); } Jid calleeAddress = transfer.getTo(); if (calleeAddress == null) { throw new OperationFailedException( "Session transfer must contain a \'to\' attribute value.", OperationFailedException.ILLEGAL_ARGUMENT); } // Checks if the transfer remote peer is contained by the roster of this // account. Roster roster = Roster.getInstanceFor(getProtocolProvider().getConnection()); if(!roster.contains(calleeAddress.asBareJid())) { String failedMessage = "Transfer impossible:\n" + "Account roster does not contain transfer peer: " + calleeAddress.asBareJid(); setState(CallPeerState.FAILED, failedMessage); logger.info(failedMessage); } OperationSetBasicTelephonyJabberImpl basicTelephony = (OperationSetBasicTelephonyJabberImpl) getProtocolProvider() .getOperationSet(OperationSetBasicTelephony.class); CallJabberImpl calleeCall = new CallJabberImpl(basicTelephony); TransferPacketExtension calleeTransfer = new TransferPacketExtension(); String sid = transfer.getSID(); calleeTransfer.setFrom(attendantAddress); if (sid != null) { calleeTransfer.setSID(sid); calleeTransfer.setTo(calleeAddress); } basicTelephony.createOutgoingCall( calleeCall, calleeAddress.toString(), Arrays.asList(new ExtensionElement[] { calleeTransfer })); }
Example 10
Source File: Workspace.java From Spark with Apache License 2.0 | 4 votes |
private void handleIncomingPacket(Stanza stanza) throws SmackException.NotConnectedException, InterruptedException { // We only handle message packets here. if (stanza instanceof Message) { final Message message = (Message)stanza; boolean isGroupChat = message.getType() == Message.Type.groupchat; // Check if Conference invite. If so, do not handle here. if (message.getExtension("x", "jabber:x:conference") != null) { return; } final String body = message.getBody(); final JivePropertiesExtension extension = ((JivePropertiesExtension) message.getExtension( JivePropertiesExtension.NAMESPACE )); final boolean broadcast = extension != null && extension.getProperty( "broadcast" ) != null; // Handle offline message. DelayInformation offlineInformation = message.getExtension("delay", "urn:xmpp:delay"); if (offlineInformation != null && (Message.Type.chat == message.getType() || Message.Type.normal == message.getType())) { handleOfflineMessage(message); } if (body == null || isGroupChat || broadcast || message.getType() == Message.Type.normal || message.getType() == Message.Type.headline || message.getType() == Message.Type.error) { return; } // Create new chat room for Agent Invite. final Jid from = stanza.getFrom(); final String host = SparkManager.getSessionManager().getServerAddress(); // Don't allow workgroup notifications to come through here. final BareJid bareJID = from.asBareJid(); if (host.equalsIgnoreCase(from.toString()) || from == null) { return; } ChatRoom room = null; try { room = SparkManager.getChatManager().getChatContainer().getChatRoom(bareJID); } catch (ChatRoomNotFoundException e) { // Ignore } // Check for non-existent rooms. if (room == null) { EntityBareJid entityBareJid = bareJID.asEntityBareJidIfPossible(); if (entityBareJid != null) { createOneToOneRoom(entityBareJid, message); } } } }
Example 11
Source File: PresenceChangePlugin.java From Spark with Apache License 2.0 | 4 votes |
public void addWatch(Jid user){ BareJid bareAddress = user.asBareJid(); sparkContacts.add(bareAddress); }
Example 12
Source File: PresenceChangePlugin.java From Spark with Apache License 2.0 | 4 votes |
public void removeWatch(Jid user){ BareJid bareAddress = user.asBareJid(); sparkContacts.remove(bareAddress); }
Example 13
Source File: PresenceChangePlugin.java From Spark with Apache License 2.0 | 4 votes |
public boolean getWatched(Jid user) { BareJid bareAddress = user.asBareJid(); return sparkContacts.contains(bareAddress) ; }