idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
19,500 | private static OmemoDeviceListElement fetchDeviceList ( XMPPConnection connection , BareJid contact ) throws InterruptedException , PubSubException . NotALeafNodeException , SmackException . NoResponseException , SmackException . NotConnectedException , XMPPException . XMPPErrorException , PubSubException . NotAPubSubNodeException { PubSubManager pm = PubSubManager . getInstanceFor ( connection , contact ) ; String nodeName = OmemoConstants . PEP_NODE_DEVICE_LIST ; LeafNode node = pm . getLeafNode ( nodeName ) ; if ( node == null ) { return null ; } List < PayloadItem < OmemoDeviceListElement > > items = node . getItems ( ) ; if ( items . isEmpty ( ) ) { return null ; } return items . get ( items . size ( ) - 1 ) . getPayload ( ) ; } | Retrieve the OMEMO device list of a contact . |
19,501 | static void publishDeviceList ( XMPPConnection connection , OmemoDeviceListElement deviceList ) throws InterruptedException , XMPPException . XMPPErrorException , SmackException . NotConnectedException , SmackException . NoResponseException { PubSubManager . getInstanceFor ( connection , connection . getUser ( ) . asBareJid ( ) ) . tryToPublishAndPossibleAutoCreate ( OmemoConstants . PEP_NODE_DEVICE_LIST , new PayloadItem < > ( deviceList ) ) ; } | Publish the given device list to the server . |
19,502 | OmemoCachedDeviceList cleanUpDeviceList ( OmemoDevice userDevice ) { OmemoCachedDeviceList cachedDeviceList ; if ( OmemoConfiguration . getDeleteStaleDevices ( ) ) { cachedDeviceList = deleteStaleDevices ( userDevice ) ; } else { cachedDeviceList = getOmemoStoreBackend ( ) . loadCachedDeviceList ( userDevice ) ; } if ( ! cachedDeviceList . getActiveDevices ( ) . contains ( userDevice . getDeviceId ( ) ) ) { cachedDeviceList . addDevice ( userDevice . getDeviceId ( ) ) ; } getOmemoStoreBackend ( ) . storeCachedDeviceList ( userDevice , userDevice . getJid ( ) , cachedDeviceList ) ; return cachedDeviceList ; } | Add our load the deviceList of the user from cache delete stale devices if needed add the users device back if necessary store the refurbished list in cache and return it . |
19,503 | OmemoCachedDeviceList refreshDeviceList ( XMPPConnection connection , OmemoDevice userDevice , BareJid contact ) throws InterruptedException , PubSubException . NotALeafNodeException , XMPPException . XMPPErrorException , SmackException . NotConnectedException , SmackException . NoResponseException { OmemoDeviceListElement publishedList ; try { publishedList = fetchDeviceList ( connection , contact ) ; } catch ( PubSubException . NotAPubSubNodeException e ) { LOGGER . log ( Level . WARNING , "Error refreshing deviceList: " , e ) ; publishedList = null ; } if ( publishedList == null ) { publishedList = new OmemoDeviceListElement_VAxolotl ( Collections . < Integer > emptySet ( ) ) ; } return getOmemoStoreBackend ( ) . mergeCachedDeviceList ( userDevice , contact , publishedList ) ; } | Refresh and merge device list of contact . |
19,504 | void buildFreshSessionWithDevice ( XMPPConnection connection , OmemoDevice userDevice , OmemoDevice contactsDevice ) throws CannotEstablishOmemoSessionException , SmackException . NotConnectedException , InterruptedException , SmackException . NoResponseException , CorruptedOmemoKeyException { if ( contactsDevice . equals ( userDevice ) ) { return ; } OmemoBundleElement bundleElement ; try { bundleElement = fetchBundle ( connection , contactsDevice ) ; } catch ( XMPPException . XMPPErrorException | PubSubException . NotALeafNodeException | PubSubException . NotAPubSubNodeException e ) { throw new CannotEstablishOmemoSessionException ( contactsDevice , e ) ; } HashMap < Integer , T_Bundle > bundlesList = getOmemoStoreBackend ( ) . keyUtil ( ) . BUNDLE . bundles ( bundleElement , contactsDevice ) ; int randomIndex = new Random ( ) . nextInt ( bundlesList . size ( ) ) ; T_Bundle randomPreKeyBundle = new ArrayList < > ( bundlesList . values ( ) ) . get ( randomIndex ) ; OmemoManager omemoManager = OmemoManager . getInstanceFor ( connection , userDevice . getDeviceId ( ) ) ; processBundle ( omemoManager , randomPreKeyBundle , contactsDevice ) ; } | Fetch the bundle of a contact and build a fresh OMEMO session with the contacts device . Note that this builds a fresh session regardless if we have had a session before or not . |
19,505 | private Set < OmemoDevice > getUndecidedDevices ( OmemoDevice userDevice , OmemoTrustCallback callback , Set < OmemoDevice > devices ) { Set < OmemoDevice > undecidedDevices = new HashSet < > ( ) ; for ( OmemoDevice device : devices ) { OmemoFingerprint fingerprint ; try { fingerprint = getOmemoStoreBackend ( ) . getFingerprint ( userDevice , device ) ; } catch ( CorruptedOmemoKeyException | NoIdentityKeyException e ) { LOGGER . log ( Level . WARNING , "Could not load fingerprint of " + device , e ) ; undecidedDevices . add ( device ) ; continue ; } if ( callback . getTrust ( device , fingerprint ) == TrustState . undecided ) { undecidedDevices . add ( device ) ; } } return undecidedDevices ; } | Return a set of all devices from the provided set which trust level is undecided . A device is also considered undecided if its fingerprint cannot be loaded . |
19,506 | private boolean hasSession ( OmemoDevice userDevice , OmemoDevice contactsDevice ) { return getOmemoStoreBackend ( ) . loadRawSession ( userDevice , contactsDevice ) != null ; } | Return true if the OmemoManager of userDevice has a session with the contactsDevice . |
19,507 | private boolean shouldRotateSignedPreKey ( OmemoDevice userDevice ) { if ( ! OmemoConfiguration . getRenewOldSignedPreKeys ( ) ) { return false ; } Date now = new Date ( ) ; Date lastRenewal = getOmemoStoreBackend ( ) . getDateOfLastSignedPreKeyRenewal ( userDevice ) ; if ( lastRenewal == null ) { lastRenewal = new Date ( ) ; getOmemoStoreBackend ( ) . setDateOfLastSignedPreKeyRenewal ( userDevice , lastRenewal ) ; } long allowedAgeMillis = MILLIS_PER_HOUR * OmemoConfiguration . getRenewOldSignedPreKeysAfterHours ( ) ; return now . getTime ( ) - lastRenewal . getTime ( ) > allowedAgeMillis ; } | Returns true if a rotation of the signed preKey is necessary . |
19,508 | private OmemoCachedDeviceList removeStaleDevicesFromDeviceList ( OmemoDevice userDevice , BareJid contact , OmemoCachedDeviceList contactsDeviceList , int maxAgeHours ) { OmemoCachedDeviceList deviceList = new OmemoCachedDeviceList ( contactsDeviceList ) ; for ( int deviceId : contactsDeviceList . getActiveDevices ( ) ) { OmemoDevice device = new OmemoDevice ( contact , deviceId ) ; Date lastDeviceIdPublication = getOmemoStoreBackend ( ) . getDateOfLastDeviceIdPublication ( userDevice , device ) ; if ( lastDeviceIdPublication == null ) { lastDeviceIdPublication = new Date ( ) ; getOmemoStoreBackend ( ) . setDateOfLastDeviceIdPublication ( userDevice , device , lastDeviceIdPublication ) ; } Date lastMessageReceived = getOmemoStoreBackend ( ) . getDateOfLastReceivedMessage ( userDevice , device ) ; if ( lastMessageReceived == null ) { lastMessageReceived = new Date ( ) ; getOmemoStoreBackend ( ) . setDateOfLastReceivedMessage ( userDevice , device , lastMessageReceived ) ; } boolean stale = isStale ( userDevice , device , lastDeviceIdPublication , maxAgeHours ) ; stale &= isStale ( userDevice , device , lastMessageReceived , maxAgeHours ) ; if ( stale ) { deviceList . addInactiveDevice ( deviceId ) ; } } return deviceList ; } | Return a copy of the given deviceList of user contact but with stale devices marked as inactive . Never mark our own device as stale . If we haven t yet received a message from a device store the current date as last date of message receipt to allow future decisions . |
19,509 | static void removeOurDevice ( OmemoDevice userDevice , Collection < OmemoDevice > devices ) { if ( devices . contains ( userDevice ) ) { devices . remove ( userDevice ) ; } } | Remove our device from the collection of devices . |
19,510 | private void repairBrokenSessionWithPreKeyMessage ( OmemoManager . LoggedInOmemoManager managerGuard , OmemoDevice brokenDevice ) { LOGGER . log ( Level . WARNING , "Attempt to repair the session by sending a fresh preKey message to " + brokenDevice ) ; OmemoManager manager = managerGuard . get ( ) ; try { buildFreshSessionWithDevice ( manager . getConnection ( ) , manager . getOwnDevice ( ) , brokenDevice ) ; sendRatchetUpdate ( managerGuard , brokenDevice ) ; } catch ( CannotEstablishOmemoSessionException | CorruptedOmemoKeyException e ) { LOGGER . log ( Level . WARNING , "Unable to repair session with " + brokenDevice , e ) ; } catch ( SmackException . NotConnectedException | InterruptedException | SmackException . NoResponseException e ) { LOGGER . log ( Level . WARNING , "Could not fetch fresh bundle for " + brokenDevice , e ) ; } catch ( CryptoFailedException | NoSuchAlgorithmException e ) { LOGGER . log ( Level . WARNING , "Could not create PreKeyMessage" , e ) ; } } | Fetch and process a fresh bundle and send an empty preKeyMessage in order to establish a fresh session . |
19,511 | private void sendRatchetUpdate ( OmemoManager . LoggedInOmemoManager managerGuard , OmemoDevice contactsDevice ) throws CorruptedOmemoKeyException , InterruptedException , SmackException . NoResponseException , NoSuchAlgorithmException , SmackException . NotConnectedException , CryptoFailedException , CannotEstablishOmemoSessionException { OmemoManager manager = managerGuard . get ( ) ; OmemoElement ratchetUpdate = createRatchetUpdateElement ( managerGuard , contactsDevice ) ; Message m = new Message ( ) ; m . setTo ( contactsDevice . getJid ( ) ) ; m . addExtension ( ratchetUpdate ) ; manager . getConnection ( ) . sendStanza ( m ) ; } | Send an empty OMEMO message to contactsDevice in order to forward the ratchet . |
19,512 | public void purgeDeviceList ( OmemoManager . LoggedInOmemoManager managerGuard ) throws InterruptedException , XMPPException . XMPPErrorException , SmackException . NotConnectedException , SmackException . NoResponseException { OmemoManager omemoManager = managerGuard . get ( ) ; OmemoDevice userDevice = omemoManager . getOwnDevice ( ) ; OmemoDeviceListElement_VAxolotl newList = new OmemoDeviceListElement_VAxolotl ( Collections . singleton ( userDevice . getDeviceId ( ) ) ) ; getOmemoStoreBackend ( ) . mergeCachedDeviceList ( userDevice , userDevice . getJid ( ) , newList ) ; OmemoService . publishDeviceList ( omemoManager . getConnection ( ) , newList ) ; } | Publish a new DeviceList with just our device in it . |
19,513 | protected List < JingleListener > getListenersList ( ) { ArrayList < JingleListener > result ; synchronized ( listeners ) { result = new ArrayList < > ( listeners ) ; } return result ; } | Get a copy of the listeners |
19,514 | public void sendMessage ( String text ) throws NotConnectedException , InterruptedException { Message message = createMessage ( ) ; message . setBody ( text ) ; connection . sendStanza ( message ) ; } | Sends a message to the chat room . |
19,515 | public void sendMessage ( Message message ) throws NotConnectedException , InterruptedException { message . setTo ( room ) ; message . setType ( Message . Type . groupchat ) ; connection . sendStanza ( message ) ; } | Sends a Message to the chat room . |
19,516 | private void removeConnectionCallbacks ( ) { connection . removeSyncStanzaListener ( messageListener ) ; if ( messageCollector != null ) { messageCollector . cancel ( ) ; messageCollector = null ; } } | Remove the connection callbacks used by this MUC Light from the connection . |
19,517 | public void leave ( ) throws NotConnectedException , InterruptedException , NoResponseException , XMPPErrorException { HashMap < Jid , MUCLightAffiliation > affiliations = new HashMap < > ( ) ; affiliations . put ( connection . getUser ( ) , MUCLightAffiliation . none ) ; MUCLightChangeAffiliationsIQ changeAffiliationsIQ = new MUCLightChangeAffiliationsIQ ( room , affiliations ) ; IQ responseIq = connection . createStanzaCollectorAndSend ( changeAffiliationsIQ ) . nextResultOrThrow ( ) ; boolean roomLeft = responseIq . getType ( ) . equals ( IQ . Type . result ) ; if ( roomLeft ) { removeConnectionCallbacks ( ) ; } } | Leave the MUCLight . |
19,518 | public MUCLightRoomInfo getFullInfo ( String version ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { MUCLightGetInfoIQ mucLightGetInfoIQ = new MUCLightGetInfoIQ ( room , version ) ; IQ responseIq = connection . createStanzaCollectorAndSend ( mucLightGetInfoIQ ) . nextResultOrThrow ( ) ; MUCLightInfoIQ mucLightInfoResponseIQ = ( MUCLightInfoIQ ) responseIq ; return new MUCLightRoomInfo ( mucLightInfoResponseIQ . getVersion ( ) , room , mucLightInfoResponseIQ . getConfiguration ( ) , mucLightInfoResponseIQ . getOccupants ( ) ) ; } | Get the MUC Light info . |
19,519 | public MUCLightRoomConfiguration getConfiguration ( String version ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { MUCLightGetConfigsIQ mucLightGetConfigsIQ = new MUCLightGetConfigsIQ ( room , version ) ; IQ responseIq = connection . createStanzaCollectorAndSend ( mucLightGetConfigsIQ ) . nextResultOrThrow ( ) ; MUCLightConfigurationIQ mucLightConfigurationIQ = ( MUCLightConfigurationIQ ) responseIq ; return mucLightConfigurationIQ . getConfiguration ( ) ; } | Get the MUC Light configuration . |
19,520 | public void changeAffiliations ( HashMap < Jid , MUCLightAffiliation > affiliations ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { MUCLightChangeAffiliationsIQ changeAffiliationsIQ = new MUCLightChangeAffiliationsIQ ( room , affiliations ) ; connection . createStanzaCollectorAndSend ( changeAffiliationsIQ ) . nextResultOrThrow ( ) ; } | Change the MUC Light affiliations . |
19,521 | public void destroy ( ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { MUCLightDestroyIQ mucLightDestroyIQ = new MUCLightDestroyIQ ( room ) ; IQ responseIq = connection . createStanzaCollectorAndSend ( mucLightDestroyIQ ) . nextResultOrThrow ( ) ; boolean roomDestroyed = responseIq . getType ( ) . equals ( IQ . Type . result ) ; if ( roomDestroyed ) { removeConnectionCallbacks ( ) ; } } | Destroy the MUC Light . Only will work if it is requested by the owner . |
19,522 | public void changeSubject ( String subject ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { MUCLightSetConfigsIQ mucLightSetConfigIQ = new MUCLightSetConfigsIQ ( room , null , subject , null ) ; connection . createStanzaCollectorAndSend ( mucLightSetConfigIQ ) . nextResultOrThrow ( ) ; } | Change the subject of the MUC Light . |
19,523 | public void changeRoomName ( String roomName ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { MUCLightSetConfigsIQ mucLightSetConfigIQ = new MUCLightSetConfigsIQ ( room , roomName , null ) ; connection . createStanzaCollectorAndSend ( mucLightSetConfigIQ ) . nextResultOrThrow ( ) ; } | Change the name of the room . |
19,524 | public static synchronized FileTransferNegotiator getInstanceFor ( final XMPPConnection connection ) { FileTransferNegotiator fileTransferNegotiator = INSTANCES . get ( connection ) ; if ( fileTransferNegotiator == null ) { fileTransferNegotiator = new FileTransferNegotiator ( connection ) ; INSTANCES . put ( connection , fileTransferNegotiator ) ; } return fileTransferNegotiator ; } | Returns the file transfer negotiator related to a particular connection . When this class is requested on a particular connection the file transfer service is automatically enabled . |
19,525 | private static void setServiceEnabled ( final XMPPConnection connection , final boolean isEnabled ) { ServiceDiscoveryManager manager = ServiceDiscoveryManager . getInstanceFor ( connection ) ; List < String > namespaces = new ArrayList < > ( ) ; namespaces . addAll ( Arrays . asList ( NAMESPACE ) ) ; namespaces . add ( DataPacketExtension . NAMESPACE ) ; if ( ! IBB_ONLY ) { namespaces . add ( Bytestream . NAMESPACE ) ; } for ( String namespace : namespaces ) { if ( isEnabled ) { manager . addFeature ( namespace ) ; } else { manager . removeFeature ( namespace ) ; } } } | Enable the Jabber services related to file transfer on the particular connection . |
19,526 | public static boolean isServiceEnabled ( final XMPPConnection connection ) { ServiceDiscoveryManager manager = ServiceDiscoveryManager . getInstanceFor ( connection ) ; List < String > namespaces = new ArrayList < > ( ) ; namespaces . addAll ( Arrays . asList ( NAMESPACE ) ) ; namespaces . add ( DataPacketExtension . NAMESPACE ) ; if ( ! IBB_ONLY ) { namespaces . add ( Bytestream . NAMESPACE ) ; } for ( String namespace : namespaces ) { if ( ! manager . includesFeature ( namespace ) ) { return false ; } } return true ; } | Checks to see if all file transfer related services are enabled on the connection . |
19,527 | public static Collection < String > getSupportedProtocols ( ) { List < String > protocols = new ArrayList < > ( ) ; protocols . add ( DataPacketExtension . NAMESPACE ) ; if ( ! IBB_ONLY ) { protocols . add ( Bytestream . NAMESPACE ) ; } return Collections . unmodifiableList ( protocols ) ; } | Returns a collection of the supported transfer protocols . |
19,528 | public StreamNegotiator selectStreamNegotiator ( FileTransferRequest request ) throws NotConnectedException , NoStreamMethodsOfferedException , NoAcceptableTransferMechanisms , InterruptedException { StreamInitiation si = request . getStreamInitiation ( ) ; FormField streamMethodField = getStreamMethodField ( si . getFeatureNegotiationForm ( ) ) ; if ( streamMethodField == null ) { String errorMessage = "No stream methods contained in stanza." ; StanzaError . Builder error = StanzaError . from ( StanzaError . Condition . bad_request , errorMessage ) ; IQ iqPacket = IQ . createErrorResponse ( si , error ) ; connection ( ) . sendStanza ( iqPacket ) ; throw new FileTransferException . NoStreamMethodsOfferedException ( ) ; } StreamNegotiator selectedStreamNegotiator ; try { selectedStreamNegotiator = getNegotiator ( streamMethodField ) ; } catch ( NoAcceptableTransferMechanisms e ) { IQ iqPacket = IQ . createErrorResponse ( si , StanzaError . from ( StanzaError . Condition . bad_request , "No acceptable transfer mechanism" ) ) ; connection ( ) . sendStanza ( iqPacket ) ; throw e ; } return selectedStreamNegotiator ; } | Selects an appropriate stream negotiator after examining the incoming file transfer request . |
19,529 | public static String getNextStreamID ( ) { StringBuilder buffer = new StringBuilder ( ) ; buffer . append ( STREAM_INIT_PREFIX ) ; buffer . append ( randomGenerator . nextInt ( Integer . MAX_VALUE ) + randomGenerator . nextInt ( Integer . MAX_VALUE ) ) ; return buffer . toString ( ) ; } | Returns a new unique stream ID to identify a file transfer . |
19,530 | public HashMap < Integer , byte [ ] > getPreKeys ( ) { if ( preKeys == null ) { preKeys = new HashMap < > ( ) ; for ( int id : preKeysB64 . keySet ( ) ) { preKeys . put ( id , Base64 . decode ( preKeysB64 . get ( id ) ) ) ; } } return this . preKeys ; } | Return the HashMap of preKeys in the bundle . The map uses the preKeys ids as key and the preKeys as value . |
19,531 | public final XmlStringBuilder getChildElementXML ( XmlEnvironment enclosingXmlEnvironment ) { XmlStringBuilder xml = new XmlStringBuilder ( ) ; if ( type == Type . error ) { appendErrorIfExists ( xml , enclosingXmlEnvironment ) ; } else if ( childElementName != null ) { IQChildElementXmlStringBuilder iqChildElement = getIQChildElementBuilder ( new IQChildElementXmlStringBuilder ( this ) ) ; if ( iqChildElement != null ) { xml . append ( iqChildElement ) ; List < ExtensionElement > extensionsXml = getExtensions ( ) ; if ( iqChildElement . isEmptyElement ) { if ( extensionsXml . isEmpty ( ) ) { xml . closeEmptyElement ( ) ; return xml ; } else { xml . rightAngleBracket ( ) ; } } xml . append ( extensionsXml ) ; xml . closeElement ( iqChildElement . element ) ; } } return xml ; } | Returns the sub - element XML section of the IQ packet or the empty String if there isn t one . |
19,532 | public void setName ( String name ) throws NotConnectedException , NoResponseException , XMPPErrorException , InterruptedException { synchronized ( entries ) { for ( RosterEntry entry : entries ) { RosterPacket packet = new RosterPacket ( ) ; packet . setType ( IQ . Type . set ) ; RosterPacket . Item item = RosterEntry . toRosterItem ( entry ) ; item . removeGroupName ( this . name ) ; item . addGroupName ( name ) ; packet . addRosterItem ( item ) ; connection ( ) . createStanzaCollectorAndSend ( packet ) . nextResultOrThrow ( ) ; } } } | Sets the name of the group . Changing the group s name is like moving all the group entries of the group to a new group specified by the new name . Since this group won t have entries it will be removed from the roster . This means that all the references to this object will be invalid and will need to be updated to the new group specified by the new name . |
19,533 | public static synchronized ChatMarkersManager getInstanceFor ( XMPPConnection connection ) { ChatMarkersManager chatMarkersManager = INSTANCES . get ( connection ) ; if ( chatMarkersManager == null ) { chatMarkersManager = new ChatMarkersManager ( connection ) ; INSTANCES . put ( connection , chatMarkersManager ) ; } return chatMarkersManager ; } | Get the singleton instance of ChatMarkersManager . |
19,534 | public synchronized boolean addIncomingChatMarkerMessageListener ( ChatMarkersListener listener ) { boolean res = incomingListeners . add ( listener ) ; if ( ! enabled ) { serviceDiscoveryManager . addFeature ( ChatMarkersElements . NAMESPACE ) ; enabled = true ; } return res ; } | Register a ChatMarkersListener . That listener will be informed about new incoming markable messages . |
19,535 | public synchronized boolean removeIncomingChatMarkerMessageListener ( ChatMarkersListener listener ) { boolean res = incomingListeners . remove ( listener ) ; if ( incomingListeners . isEmpty ( ) && enabled ) { serviceDiscoveryManager . removeFeature ( ChatMarkersElements . NAMESPACE ) ; enabled = false ; } return res ; } | Unregister a ChatMarkersListener . |
19,536 | public boolean isEnabledSaslMechanism ( String saslMechanism ) { if ( enabledSaslMechanisms == null ) { return ! SASLAuthentication . getBlacklistedSASLMechanisms ( ) . contains ( saslMechanism ) ; } return enabledSaslMechanisms . contains ( saslMechanism ) ; } | Check if the given SASL mechansism is enabled in this connection configuration . |
19,537 | public static StanzaIdElement getStanzaId ( Message message ) { return message . getExtension ( StanzaIdElement . ELEMENT , StableUniqueStanzaIdManager . NAMESPACE ) ; } | Return the stanza - id element of a message . |
19,538 | public void setTo ( String to ) { Jid jid ; try { jid = JidCreate . from ( to ) ; } catch ( XmppStringprepException e ) { throw new IllegalArgumentException ( e ) ; } setTo ( jid ) ; } | Sets who the stanza is being sent to . The XMPP protocol often makes the to attribute optional so it does not always need to be set . |
19,539 | public void setFrom ( String from ) { Jid jid ; try { jid = JidCreate . from ( from ) ; } catch ( XmppStringprepException e ) { throw new IllegalArgumentException ( e ) ; } setFrom ( jid ) ; } | Sets who the stanza is being sent from . The XMPP protocol often makes the from attribute optional so it does not always need to be set . |
19,540 | public void setError ( StanzaError . Builder xmppErrorBuilder ) { if ( xmppErrorBuilder == null ) { return ; } xmppErrorBuilder . setStanza ( this ) ; error = xmppErrorBuilder . build ( ) ; } | Sets the error for this stanza . |
19,541 | public void addExtension ( ExtensionElement extension ) { if ( extension == null ) return ; String key = XmppStringUtils . generateKey ( extension . getElementName ( ) , extension . getNamespace ( ) ) ; synchronized ( packetExtensions ) { packetExtensions . put ( key , extension ) ; } } | Adds a stanza extension to the packet . Does nothing if extension is null . |
19,542 | public ExtensionElement overrideExtension ( ExtensionElement extension ) { if ( extension == null ) return null ; synchronized ( packetExtensions ) { ExtensionElement removedExtension = removeExtension ( extension . getElementName ( ) , extension . getNamespace ( ) ) ; addExtension ( extension ) ; return removedExtension ; } } | Add the given extension and override eventually existing extensions with the same name and namespace . |
19,543 | public void addExtensions ( Collection < ExtensionElement > extensions ) { if ( extensions == null ) return ; for ( ExtensionElement packetExtension : extensions ) { addExtension ( packetExtension ) ; } } | Adds a collection of stanza extensions to the packet . Does nothing if extensions is null . |
19,544 | public boolean hasExtension ( String namespace ) { synchronized ( packetExtensions ) { for ( ExtensionElement packetExtension : packetExtensions . values ( ) ) { if ( packetExtension . getNamespace ( ) . equals ( namespace ) ) { return true ; } } } return false ; } | Check if a stanza extension with the given namespace exists . |
19,545 | public ExtensionElement removeExtension ( String elementName , String namespace ) { String key = XmppStringUtils . generateKey ( elementName , namespace ) ; synchronized ( packetExtensions ) { return packetExtensions . remove ( key ) ; } } | Remove the stanza extension with the given elementName and namespace . |
19,546 | public ExtensionElement removeExtension ( ExtensionElement extension ) { String key = XmppStringUtils . generateKey ( extension . getElementName ( ) , extension . getNamespace ( ) ) ; synchronized ( packetExtensions ) { List < ExtensionElement > list = packetExtensions . getAll ( key ) ; boolean removed = list . remove ( extension ) ; if ( removed ) { return extension ; } } return null ; } | Removes a stanza extension from the packet . |
19,547 | protected void appendErrorIfExists ( XmlStringBuilder xml , XmlEnvironment enclosingXmlEnvironment ) { StanzaError error = getError ( ) ; if ( error != null ) { xml . append ( error . toXML ( enclosingXmlEnvironment ) ) ; } } | Append an XMPPError is this stanza has one set . |
19,548 | public String getName ( ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { AgentInfo agentInfo = new AgentInfo ( ) ; agentInfo . setType ( IQ . Type . get ) ; agentInfo . setTo ( workgroupJID ) ; agentInfo . setFrom ( getUser ( ) ) ; AgentInfo response = connection . createStanzaCollectorAndSend ( agentInfo ) . nextResultOrThrow ( ) ; return response . getName ( ) ; } | Return the agents name . |
19,549 | public void setName ( String newName ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { AgentInfo agentInfo = new AgentInfo ( ) ; agentInfo . setType ( IQ . Type . set ) ; agentInfo . setTo ( workgroupJID ) ; agentInfo . setFrom ( getUser ( ) ) ; agentInfo . setName ( newName ) ; connection . createStanzaCollectorAndSend ( agentInfo ) . nextResultOrThrow ( ) ; } | Changes the name of the agent in the server . The server may have this functionality disabled for all the agents or for this agent in particular . If the agent is not allowed to change his name then an exception will be thrown with a service_unavailable error code . |
19,550 | public synchronized void setProperty ( String name , Object value ) { if ( ! ( value instanceof Serializable ) ) { throw new IllegalArgumentException ( "Value must be serializable" ) ; } properties . put ( name , value ) ; } | Sets a property with an Object as the value . The value must be Serializable or an IllegalArgumentException will be thrown . |
19,551 | public synchronized Collection < String > getPropertyNames ( ) { if ( properties == null ) { return Collections . emptySet ( ) ; } return Collections . unmodifiableSet ( new HashSet < > ( properties . keySet ( ) ) ) ; } | Returns an unmodifiable collection of all the property names that are set . |
19,552 | public synchronized Map < String , Object > getProperties ( ) { if ( properties == null ) { return Collections . emptyMap ( ) ; } return Collections . unmodifiableMap ( new HashMap < > ( properties ) ) ; } | Returns an unmodifiable map of all properties . |
19,553 | public void addPixels ( int [ ] pixels , int offset , int count ) { for ( int i = 0 ; i < count ; i ++ ) { insertColor ( pixels [ i + offset ] ) ; if ( colors > reduceColors ) reduceTree ( reduceColors ) ; } } | Add pixels to the quantizer . |
19,554 | public void buildColorTable ( int [ ] inPixels , int [ ] table ) { int count = inPixels . length ; maximumColors = table . length ; for ( int i = 0 ; i < count ; i ++ ) { insertColor ( inPixels [ i ] ) ; if ( colors > reduceColors ) reduceTree ( reduceColors ) ; } if ( colors > maximumColors ) reduceTree ( maximumColors ) ; buildColorTable ( root , table , 0 ) ; } | A quick way to use the quantizer . Just create a table the right size and pass in the pixels . |
19,555 | private Presence enter ( MucEnterConfiguration conf ) throws NotConnectedException , NoResponseException , XMPPErrorException , InterruptedException , NotAMucServiceException { final DomainBareJid mucService = room . asDomainBareJid ( ) ; if ( ! KNOWN_MUC_SERVICES . containsKey ( mucService ) ) { if ( multiUserChatManager . providesMucService ( mucService ) ) { KNOWN_MUC_SERVICES . put ( mucService , null ) ; } else { throw new NotAMucServiceException ( this ) ; } } Presence joinPresence = conf . getJoinPresence ( this ) ; connection . addSyncStanzaListener ( messageListener , fromRoomGroupchatFilter ) ; StanzaFilter presenceFromRoomFilter = new AndFilter ( fromRoomFilter , StanzaTypeFilter . PRESENCE , PossibleFromTypeFilter . ENTITY_FULL_JID ) ; connection . addSyncStanzaListener ( presenceListener , presenceFromRoomFilter ) ; connection . addSyncStanzaListener ( subjectListener , new AndFilter ( fromRoomFilter , MessageWithSubjectFilter . INSTANCE , new NotFilter ( MessageTypeFilter . ERROR ) , new NotFilter ( MessageWithBodiesFilter . INSTANCE ) , new NotFilter ( MessageWithThreadFilter . INSTANCE ) ) ) ; connection . addSyncStanzaListener ( declinesListener , new AndFilter ( fromRoomFilter , DECLINE_FILTER ) ) ; connection . addStanzaInterceptor ( presenceInterceptor , new AndFilter ( ToMatchesFilter . create ( room ) , StanzaTypeFilter . PRESENCE ) ) ; messageCollector = connection . createStanzaCollector ( fromRoomGroupchatFilter ) ; StanzaFilter responseFilter = new AndFilter ( StanzaTypeFilter . PRESENCE , new OrFilter ( new AndFilter ( FromMatchesFilter . createBare ( getRoom ( ) ) , MUCUserStatusCodeFilter . STATUS_110_PRESENCE_TO_SELF ) , new AndFilter ( FromMatchesFilter . createFull ( joinPresence . getTo ( ) ) , new StanzaIdFilter ( joinPresence ) , PresenceTypeFilter . ERROR ) ) ) ; StanzaCollector presenceStanzaCollector = null ; Presence presence ; try { StanzaCollector selfPresenceCollector = connection . createStanzaCollectorAndSend ( responseFilter , joinPresence ) ; StanzaCollector . Configuration presenceStanzaCollectorConfguration = StanzaCollector . newConfiguration ( ) . setCollectorToReset ( selfPresenceCollector ) . setStanzaFilter ( presenceFromRoomFilter ) ; presenceStanzaCollector = connection . createStanzaCollector ( presenceStanzaCollectorConfguration ) ; presence = selfPresenceCollector . nextResultOrThrow ( conf . getTimeout ( ) ) ; } catch ( NotConnectedException | InterruptedException | NoResponseException | XMPPErrorException e ) { removeConnectionCallbacks ( ) ; throw e ; } finally { if ( presenceStanzaCollector != null ) { presenceStanzaCollector . cancel ( ) ; } } Resourcepart receivedNickname = presence . getFrom ( ) . getResourceOrThrow ( ) ; setNickname ( receivedNickname ) ; joined = true ; multiUserChatManager . addJoinedRoom ( room ) ; return presence ; } | Enter a room as described in XEP - 45 7 . 2 . |
19,556 | public MucEnterConfiguration . Builder getEnterConfigurationBuilder ( Resourcepart nickname ) { return new MucEnterConfiguration . Builder ( nickname , connection . getReplyTimeout ( ) ) ; } | Get a new MUC enter configuration builder . |
19,557 | public synchronized MucCreateConfigFormHandle createOrJoin ( Resourcepart nickname ) throws NoResponseException , XMPPErrorException , InterruptedException , MucAlreadyJoinedException , NotConnectedException , NotAMucServiceException { MucEnterConfiguration mucEnterConfiguration = getEnterConfigurationBuilder ( nickname ) . build ( ) ; return createOrJoin ( mucEnterConfiguration ) ; } | Create or join the MUC room with the given nickname . |
19,558 | public MucCreateConfigFormHandle createOrJoinIfNecessary ( Resourcepart nickname , String password ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException , NotAMucServiceException { if ( isJoined ( ) ) { return null ; } MucEnterConfiguration mucEnterConfiguration = getEnterConfigurationBuilder ( nickname ) . withPassword ( password ) . build ( ) ; try { return createOrJoin ( mucEnterConfiguration ) ; } catch ( MucAlreadyJoinedException e ) { return null ; } } | Create or join a MUC if it is necessary i . e . if not the MUC is not already joined . |
19,559 | public void join ( Resourcepart nickname ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException , NotAMucServiceException { MucEnterConfiguration . Builder builder = getEnterConfigurationBuilder ( nickname ) ; join ( builder . build ( ) ) ; } | Joins the chat room using the specified nickname . If already joined using another nickname this method will first leave the room and then re - join using the new nickname . The default connection timeout for a reply from the group chat server that the join succeeded will be used . After joining the room the room will decide the amount of history to send . |
19,560 | public synchronized Presence leave ( ) throws NotConnectedException , InterruptedException , NoResponseException , XMPPErrorException , MucNotJoinedException { userHasLeft ( ) ; final EntityFullJid myRoomJid = this . myRoomJid ; if ( myRoomJid == null ) { throw new MucNotJoinedException ( this ) ; } Presence leavePresence = new Presence ( Presence . Type . unavailable ) ; leavePresence . setTo ( myRoomJid ) ; StanzaFilter reflectedLeavePresenceFilter = new AndFilter ( StanzaTypeFilter . PRESENCE , new StanzaIdFilter ( leavePresence ) , new OrFilter ( new AndFilter ( FromMatchesFilter . createFull ( myRoomJid ) , PresenceTypeFilter . UNAVAILABLE , MUCUserStatusCodeFilter . STATUS_110_PRESENCE_TO_SELF ) , new AndFilter ( fromRoomFilter , PresenceTypeFilter . ERROR ) ) ) ; Presence reflectedLeavePresence = connection . createStanzaCollectorAndSend ( reflectedLeavePresenceFilter , leavePresence ) . nextResultOrThrow ( ) ; return reflectedLeavePresence ; } | Leave the chat room . |
19,561 | public void sendConfigurationForm ( Form form ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { MUCOwner iq = new MUCOwner ( ) ; iq . setTo ( room ) ; iq . setType ( IQ . Type . set ) ; iq . addExtension ( form . getDataFormToSend ( ) ) ; connection . createStanzaCollectorAndSend ( iq ) . nextResultOrThrow ( ) ; } | Sends the completed configuration form to the server . The room will be configured with the new settings defined in the form . |
19,562 | private void fireInvitationRejectionListeners ( Message message , MUCUser . Decline rejection ) { EntityBareJid invitee = rejection . getFrom ( ) ; String reason = rejection . getReason ( ) ; InvitationRejectionListener [ ] listeners ; synchronized ( invitationRejectionListeners ) { listeners = new InvitationRejectionListener [ invitationRejectionListeners . size ( ) ] ; invitationRejectionListeners . toArray ( listeners ) ; } for ( InvitationRejectionListener listener : listeners ) { listener . invitationDeclined ( invitee , reason , message , rejection ) ; } } | Fires invitation rejection listeners . |
19,563 | public String getReservedNickname ( ) throws SmackException , InterruptedException { try { DiscoverInfo result = ServiceDiscoveryManager . getInstanceFor ( connection ) . discoverInfo ( room , "x-roomuser-item" ) ; for ( DiscoverInfo . Identity identity : result . getIdentities ( ) ) { return identity . getName ( ) ; } } catch ( XMPPException e ) { LOGGER . log ( Level . SEVERE , "Error retrieving room nickname" , e ) ; } return null ; } | Returns the reserved room nickname for the user in the room . A user may have a reserved nickname for example through explicit room registration or database integration . In such cases it may be desirable for the user to discover the reserved nickname before attempting to enter the room . |
19,564 | public void requestVoice ( ) throws NotConnectedException , InterruptedException { DataForm form = new DataForm ( DataForm . Type . submit ) ; FormField formTypeField = new FormField ( FormField . FORM_TYPE ) ; formTypeField . addValue ( MUCInitialPresence . NAMESPACE + "#request" ) ; form . addField ( formTypeField ) ; FormField requestVoiceField = new FormField ( "muc#role" ) ; requestVoiceField . setType ( FormField . Type . text_single ) ; requestVoiceField . setLabel ( "Requested role" ) ; requestVoiceField . addValue ( "participant" ) ; form . addField ( requestVoiceField ) ; Message message = new Message ( room ) ; message . addExtension ( form ) ; connection . sendStanza ( message ) ; } | Sends a voice request to the MUC . The room moderators usually need to approve this request . |
19,565 | public void grantVoice ( Collection < Resourcepart > nicknames ) throws XMPPErrorException , NoResponseException , NotConnectedException , InterruptedException { changeRole ( nicknames , MUCRole . participant ) ; } | Grants voice to visitors in the room . In a moderated room a moderator may want to manage who does and does not have voice in the room . To have voice means that a room occupant is able to send messages to the room occupants . |
19,566 | public void grantVoice ( Resourcepart nickname ) throws XMPPErrorException , NoResponseException , NotConnectedException , InterruptedException { changeRole ( nickname , MUCRole . participant , null ) ; } | Grants voice to a visitor in the room . In a moderated room a moderator may want to manage who does and does not have voice in the room . To have voice means that a room occupant is able to send messages to the room occupants . |
19,567 | public void revokeVoice ( Collection < Resourcepart > nicknames ) throws XMPPErrorException , NoResponseException , NotConnectedException , InterruptedException { changeRole ( nicknames , MUCRole . visitor ) ; } | Revokes voice from participants in the room . In a moderated room a moderator may want to revoke an occupant s privileges to speak . To have voice means that a room occupant is able to send messages to the room occupants . |
19,568 | public void revokeVoice ( Resourcepart nickname ) throws XMPPErrorException , NoResponseException , NotConnectedException , InterruptedException { changeRole ( nickname , MUCRole . visitor , null ) ; } | Revokes voice from a participant in the room . In a moderated room a moderator may want to revoke an occupant s privileges to speak . To have voice means that a room occupant is able to send messages to the room occupants . |
19,569 | public void grantModerator ( Collection < Resourcepart > nicknames ) throws XMPPErrorException , NoResponseException , NotConnectedException , InterruptedException { changeRole ( nicknames , MUCRole . moderator ) ; } | Grants moderator privileges to participants or visitors . Room administrators may grant moderator privileges . A moderator is allowed to kick users grant and revoke voice invite other users modify room s subject plus all the partcipants privileges . |
19,570 | public void grantModerator ( Resourcepart nickname ) throws XMPPErrorException , NoResponseException , NotConnectedException , InterruptedException { changeRole ( nickname , MUCRole . moderator , null ) ; } | Grants moderator privileges to a participant or visitor . Room administrators may grant moderator privileges . A moderator is allowed to kick users grant and revoke voice invite other users modify room s subject plus all the partcipants privileges . |
19,571 | public void grantOwnership ( Collection < ? extends Jid > jids ) throws XMPPErrorException , NoResponseException , NotConnectedException , InterruptedException { changeAffiliationByAdmin ( jids , MUCAffiliation . owner ) ; } | Grants ownership privileges to other users . Room owners may grant ownership privileges . Some room implementations will not allow to grant ownership privileges to other users . An owner is allowed to change defining room features as well as perform all administrative functions . |
19,572 | public void grantOwnership ( Jid jid ) throws XMPPErrorException , NoResponseException , NotConnectedException , InterruptedException { changeAffiliationByAdmin ( jid , MUCAffiliation . owner , null ) ; } | Grants ownership privileges to another user . Room owners may grant ownership privileges . Some room implementations will not allow to grant ownership privileges to other users . An owner is allowed to change defining room features as well as perform all administrative functions . |
19,573 | public void revokeOwnership ( Collection < ? extends Jid > jids ) throws XMPPErrorException , NoResponseException , NotConnectedException , InterruptedException { changeAffiliationByAdmin ( jids , MUCAffiliation . admin ) ; } | Revokes ownership privileges from other users . The occupant that loses ownership privileges will become an administrator . Room owners may revoke ownership privileges . Some room implementations will not allow to grant ownership privileges to other users . |
19,574 | public void revokeOwnership ( Jid jid ) throws XMPPErrorException , NoResponseException , NotConnectedException , InterruptedException { changeAffiliationByAdmin ( jid , MUCAffiliation . admin , null ) ; } | Revokes ownership privileges from another user . The occupant that loses ownership privileges will become an administrator . Room owners may revoke ownership privileges . Some room implementations will not allow to grant ownership privileges to other users . |
19,575 | public void grantAdmin ( Jid jid ) throws XMPPErrorException , NoResponseException , NotConnectedException , InterruptedException { changeAffiliationByAdmin ( jid , MUCAffiliation . admin ) ; } | Grants administrator privileges to another user . Room owners may grant administrator privileges to a member or unaffiliated user . An administrator is allowed to perform administrative functions such as banning users and edit moderator list . |
19,576 | public void revokeAdmin ( EntityJid jid ) throws XMPPErrorException , NoResponseException , NotConnectedException , InterruptedException { changeAffiliationByAdmin ( jid , MUCAffiliation . member ) ; } | Revokes administrator privileges from a user . The occupant that loses administrator privileges will become a member . Room owners may revoke administrator privileges from a member or unaffiliated user . |
19,577 | public void changeSubject ( final String subject ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { Message message = createMessage ( ) ; message . setSubject ( subject ) ; StanzaFilter responseFilter = new AndFilter ( fromRoomGroupchatFilter , new StanzaFilter ( ) { public boolean accept ( Stanza packet ) { Message msg = ( Message ) packet ; return subject . equals ( msg . getSubject ( ) ) ; } } ) ; StanzaCollector response = connection . createStanzaCollectorAndSend ( responseFilter , message ) ; response . nextResultOrThrow ( ) ; } | Changes the subject within the room . As a default only users with a role of moderator are allowed to change the subject in a room . Although some rooms may be configured to allow a mere participant or even a visitor to change the subject . |
19,578 | private void checkPresenceCode ( Set < Status > statusCodes , boolean isUserModification , MUCUser mucUser , EntityFullJid from ) { if ( statusCodes . contains ( Status . KICKED_307 ) ) { if ( isUserModification ) { userHasLeft ( ) ; for ( UserStatusListener listener : userStatusListeners ) { listener . kicked ( mucUser . getItem ( ) . getActor ( ) , mucUser . getItem ( ) . getReason ( ) ) ; } } else { for ( ParticipantStatusListener listener : participantStatusListeners ) { listener . kicked ( from , mucUser . getItem ( ) . getActor ( ) , mucUser . getItem ( ) . getReason ( ) ) ; } } } if ( statusCodes . contains ( Status . BANNED_301 ) ) { if ( isUserModification ) { joined = false ; for ( UserStatusListener listener : userStatusListeners ) { listener . banned ( mucUser . getItem ( ) . getActor ( ) , mucUser . getItem ( ) . getReason ( ) ) ; } occupantsMap . clear ( ) ; myRoomJid = null ; userHasLeft ( ) ; } else { for ( ParticipantStatusListener listener : participantStatusListeners ) { listener . banned ( from , mucUser . getItem ( ) . getActor ( ) , mucUser . getItem ( ) . getReason ( ) ) ; } } } if ( statusCodes . contains ( Status . REMOVED_AFFIL_CHANGE_321 ) ) { if ( isUserModification ) { joined = false ; for ( UserStatusListener listener : userStatusListeners ) { listener . membershipRevoked ( ) ; } occupantsMap . clear ( ) ; myRoomJid = null ; userHasLeft ( ) ; } } if ( statusCodes . contains ( Status . NEW_NICKNAME_303 ) ) { for ( ParticipantStatusListener listener : participantStatusListeners ) { listener . nicknameChanged ( from , mucUser . getItem ( ) . getNick ( ) ) ; } } if ( mucUser . getDestroy ( ) != null ) { MultiUserChat alternateMUC = multiUserChatManager . getMultiUserChat ( mucUser . getDestroy ( ) . getJid ( ) ) ; for ( UserStatusListener listener : userStatusListeners ) { listener . roomDestroyed ( alternateMUC , mucUser . getDestroy ( ) . getReason ( ) ) ; } occupantsMap . clear ( ) ; myRoomJid = null ; userHasLeft ( ) ; } } | Fires events according to the received presence code . |
19,579 | public static void addMention ( Stanza stanza , int begin , int end , BareJid jid ) { URI uri ; try { uri = new URI ( "xmpp:" + jid . toString ( ) ) ; } catch ( URISyntaxException e ) { throw new AssertionError ( "Cannot create URI from bareJid." ) ; } ReferenceElement reference = new ReferenceElement ( begin , end , ReferenceElement . Type . mention , null , uri ) ; stanza . addExtension ( reference ) ; } | Add a reference to another users bare jid to a stanza . |
19,580 | public static List < ReferenceElement > getReferencesFromStanza ( Stanza stanza ) { List < ReferenceElement > references = new ArrayList < > ( ) ; List < ExtensionElement > extensions = stanza . getExtensions ( ReferenceElement . ELEMENT , ReferenceManager . NAMESPACE ) ; for ( ExtensionElement e : extensions ) { references . add ( ( ReferenceElement ) e ) ; } return references ; } | Return a list of all reference extensions contained in a stanza . If there are no reference elements return an empty list . |
19,581 | public static boolean isSupported ( XMPPConnection connection ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { return AMPManager . isConditionSupported ( connection , NAME ) ; } | Check if server supports expire - at condition . |
19,582 | public static OriginIdElement addOriginId ( Message message ) { OriginIdElement originId = new OriginIdElement ( ) ; message . addExtension ( originId ) ; return originId ; } | Add an origin - id element to a message and set the stanzas id to the same id as in the origin - id element . |
19,583 | public static OriginIdElement getOriginId ( Message message ) { return message . getExtension ( OriginIdElement . ELEMENT , StableUniqueStanzaIdManager . NAMESPACE ) ; } | Return the origin - id element of a message or null if absent . |
19,584 | public static List < String > getSharedGroups ( XMPPConnection connection ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { SharedGroupsInfo info = new SharedGroupsInfo ( ) ; info . setType ( IQ . Type . get ) ; SharedGroupsInfo result = connection . createStanzaCollectorAndSend ( info ) . nextResultOrThrow ( ) ; return result . getGroups ( ) ; } | Returns the collection that will contain the name of the shared groups where the user logged in with the specified session belongs . |
19,585 | public static List < IQProvider < IQ > > getIQProviders ( ) { List < IQProvider < IQ > > providers = new ArrayList < > ( iqProviders . size ( ) ) ; providers . addAll ( iqProviders . values ( ) ) ; return providers ; } | Returns an unmodifiable collection of all IQProvider instances . Each object in the collection will either be an IQProvider instance or a Class object that implements the IQProvider interface . |
19,586 | @ SuppressWarnings ( "unchecked" ) public static void addExtensionProvider ( String elementName , String namespace , Object provider ) { validate ( elementName , namespace ) ; String key = removeExtensionProvider ( elementName , namespace ) ; if ( provider instanceof ExtensionElementProvider ) { extensionProviders . put ( key , ( ExtensionElementProvider < ExtensionElement > ) provider ) ; } else { throw new IllegalArgumentException ( "Provider must be a PacketExtensionProvider" ) ; } } | Adds an extension provider with the specified element name and name space . The provider will override any providers loaded through the classpath . The provider must be either a PacketExtensionProvider instance or a Class object of a Javabean . |
19,587 | public static List < ExtensionElementProvider < ExtensionElement > > getExtensionProviders ( ) { List < ExtensionElementProvider < ExtensionElement > > providers = new ArrayList < > ( extensionProviders . size ( ) ) ; providers . addAll ( extensionProviders . values ( ) ) ; return providers ; } | Returns an unmodifiable collection of all PacketExtensionProvider instances . Each object in the collection will either be a PacketExtensionProvider instance or a Class object that implements the PacketExtensionProvider interface . |
19,588 | public XmlStringBuilder toXML ( ) { XmlStringBuilder buf = new XmlStringBuilder ( ) ; buf . halfOpenElement ( ELEMENT ) . xmlnsAttribute ( NAMESPACE ) . rightAngleBracket ( ) ; for ( BookmarkedURL urlStorage : getBookmarkedURLS ( ) ) { if ( urlStorage . isShared ( ) ) { continue ; } buf . halfOpenElement ( "url" ) . attribute ( "name" , urlStorage . getName ( ) ) . attribute ( "url" , urlStorage . getURL ( ) ) ; buf . condAttribute ( urlStorage . isRss ( ) , "rss" , "true" ) ; buf . closeEmptyElement ( ) ; } for ( BookmarkedConference conference : getBookmarkedConferences ( ) ) { if ( conference . isShared ( ) ) { continue ; } buf . halfOpenElement ( "conference" ) ; buf . attribute ( "name" , conference . getName ( ) ) ; buf . attribute ( "autojoin" , Boolean . toString ( conference . isAutoJoin ( ) ) ) ; buf . attribute ( "jid" , conference . getJid ( ) ) ; buf . rightAngleBracket ( ) ; buf . optElement ( "nick" , conference . getNickname ( ) ) ; buf . optElement ( "password" , conference . getPassword ( ) ) ; buf . closeElement ( "conference" ) ; } buf . closeElement ( ELEMENT ) ; return buf ; } | Returns the XML representation of the PrivateData . |
19,589 | public void addContents ( final List < JingleContent > contentList ) { if ( contentList != null ) { synchronized ( contents ) { contents . addAll ( contentList ) ; } } } | Add a list of JingleContent elements . |
19,590 | public static int getSessionHash ( final String sid , final Jid initiator ) { final int PRIME = 31 ; int result = 1 ; result = PRIME * result + ( initiator == null ? 0 : initiator . hashCode ( ) ) ; result = PRIME * result + ( sid == null ? 0 : sid . hashCode ( ) ) ; return result ; } | Get a hash key for the session this stanza belongs to . |
19,591 | protected IQChildElementXmlStringBuilder getIQChildElementBuilder ( IQChildElementXmlStringBuilder buf ) { if ( getInitiator ( ) != null ) { buf . append ( " initiator=\"" ) . append ( getInitiator ( ) ) . append ( '"' ) ; } if ( getResponder ( ) != null ) { buf . append ( " responder=\"" ) . append ( getResponder ( ) ) . append ( '"' ) ; } if ( getAction ( ) != null ) { buf . append ( " action=\"" ) . append ( getAction ( ) . toString ( ) ) . append ( '"' ) ; } if ( getSid ( ) != null ) { buf . append ( " sid=\"" ) . append ( getSid ( ) ) . append ( '"' ) ; } buf . append ( '>' ) ; synchronized ( contents ) { for ( JingleContent content : contents ) { buf . append ( content . toXML ( ) ) ; } } if ( contentInfo != null ) { buf . append ( contentInfo . toXML ( ) ) ; } return buf ; } | Return the XML representation of the packet . |
19,592 | public boolean isSupported ( ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { Jid archiveAddress = getArchiveAddress ( ) ; return serviceDiscoveryManager . supportsFeature ( archiveAddress , MamElements . NAMESPACE ) ; } | Check if this MamManager s archive address supports MAM . |
19,593 | public MamPrefsResult retrieveArchivingPreferences ( ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException , NotLoggedInException { MamPrefsIQ mamPrefIQ = new MamPrefsIQ ( ) ; return queryMamPrefs ( mamPrefIQ ) ; } | Get the preferences stored in the server . |
19,594 | public boolean isAffiliationModification ( ) { if ( jid != null && affiliation != null ) { assert ( node == null && namespace == AffiliationNamespace . owner ) ; return true ; } return false ; } | Check if this is an affiliation element to modify affiliations on a node . |
19,595 | public LeafNode createNode ( ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { PubSub reply = sendPubsubPacket ( Type . set , new NodeExtension ( PubSubElementType . CREATE ) , null ) ; NodeExtension elem = reply . getExtension ( "create" , PubSubNamespace . basic . getXmlns ( ) ) ; LeafNode newNode = new LeafNode ( this , elem . getNode ( ) ) ; nodeMap . put ( newNode . getId ( ) , newNode ) ; return newNode ; } | Creates an instant node if supported . |
19,596 | public LeafNode createNode ( String nodeId ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { return ( LeafNode ) createNode ( nodeId , null ) ; } | Creates a node with default configuration . |
19,597 | public Node createNode ( String nodeId , Form config ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { PubSub request = PubSub . createPubsubPacket ( pubSubService , Type . set , new NodeExtension ( PubSubElementType . CREATE , nodeId ) ) ; boolean isLeafNode = true ; if ( config != null ) { request . addExtension ( new FormNode ( FormNodeType . CONFIGURE , config ) ) ; FormField nodeTypeField = config . getField ( ConfigureNodeFields . node_type . getFieldName ( ) ) ; if ( nodeTypeField != null ) isLeafNode = nodeTypeField . getValues ( ) . get ( 0 ) . toString ( ) . equals ( NodeType . leaf . toString ( ) ) ; } sendPubsubPacket ( request ) ; Node newNode = isLeafNode ? new LeafNode ( this , nodeId ) : new CollectionNode ( this , nodeId ) ; nodeMap . put ( newNode . getId ( ) , newNode ) ; return newNode ; } | Creates a node with specified configuration . |
19,598 | public Node getNode ( String id ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException , NotAPubSubNodeException { Node node = nodeMap . get ( id ) ; if ( node == null ) { DiscoverInfo info = new DiscoverInfo ( ) ; info . setTo ( pubSubService ) ; info . setNode ( id ) ; DiscoverInfo infoReply = connection ( ) . createStanzaCollectorAndSend ( info ) . nextResultOrThrow ( ) ; if ( infoReply . hasIdentity ( PubSub . ELEMENT , "leaf" ) ) { node = new LeafNode ( this , id ) ; } else if ( infoReply . hasIdentity ( PubSub . ELEMENT , "collection" ) ) { node = new CollectionNode ( this , id ) ; } else { throw new PubSubException . NotAPubSubNodeException ( id , infoReply ) ; } nodeMap . put ( id , node ) ; } return node ; } | Retrieves the requested node if it exists . It will throw an exception if it does not . |
19,599 | public LeafNode getOrCreateLeafNode ( final String id ) throws NoResponseException , NotConnectedException , InterruptedException , XMPPErrorException , NotALeafNodeException { try { return getLeafNode ( id ) ; } catch ( NotAPubSubNodeException e ) { return createNode ( id ) ; } catch ( XMPPErrorException e1 ) { if ( e1 . getStanzaError ( ) . getCondition ( ) == Condition . item_not_found ) { try { return createNode ( id ) ; } catch ( XMPPErrorException e2 ) { if ( e2 . getStanzaError ( ) . getCondition ( ) == Condition . conflict ) { try { return getLeafNode ( id ) ; } catch ( NotAPubSubNodeException e ) { throw new IllegalStateException ( e ) ; } } throw e2 ; } } if ( e1 . getStanzaError ( ) . getCondition ( ) == Condition . service_unavailable ) { LOGGER . warning ( "The PubSub service " + pubSubService + " threw an DiscoInfoNodeAssertionError, trying workaround for Prosody bug #805 (https://prosody.im/issues/issue/805)" ) ; return getOrCreateLeafNodeProsodyWorkaround ( id ) ; } throw e1 ; } } | Try to get a leaf node and create one if it does not already exist . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.