idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
19,600
public LeafNode getLeafNode ( String id ) throws NotALeafNodeException , NoResponseException , NotConnectedException , InterruptedException , XMPPErrorException , NotAPubSubNodeException { Node node ; try { node = getNode ( id ) ; } catch ( XMPPErrorException e ) { if ( e . getStanzaError ( ) . getCondition ( ) == Condition . service_unavailable ) { return getLeafNodeProsodyWorkaround ( id ) ; } throw e ; } if ( node instanceof LeafNode ) { return ( LeafNode ) node ; } throw new PubSubException . NotALeafNodeException ( id , pubSubService ) ; }
Try to get a leaf node with the given node ID .
19,601
public DiscoverItems discoverNodes ( String nodeId ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { DiscoverItems items = new DiscoverItems ( ) ; if ( nodeId != null ) items . setNode ( nodeId ) ; items . setTo ( pubSubService ) ; DiscoverItems nodeItems = connection ( ) . createStanzaCollectorAndSend ( items ) . nextResultOrThrow ( ) ; return nodeItems ; }
Get all the nodes that currently exist as a child of the specified collection node . If the service does not support collection nodes then all nodes will be returned .
19,602
public List < Subscription > getSubscriptions ( ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { Stanza reply = sendPubsubPacket ( Type . get , new NodeExtension ( PubSubElementType . SUBSCRIPTIONS ) , null ) ; SubscriptionsExtension subElem = reply . getExtension ( PubSubElementType . SUBSCRIPTIONS . getElementName ( ) , PubSubElementType . SUBSCRIPTIONS . getNamespace ( ) . getXmlns ( ) ) ; return subElem . getSubscriptions ( ) ; }
Gets the subscriptions on the root node .
19,603
public List < Affiliation > getAffiliations ( ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { PubSub reply = sendPubsubPacket ( Type . get , new NodeExtension ( PubSubElementType . AFFILIATIONS ) , null ) ; AffiliationsExtension listElem = reply . getExtension ( PubSubElementType . AFFILIATIONS ) ; return listElem . getAffiliations ( ) ; }
Gets the affiliations on the root node .
19,604
public boolean deleteNode ( String nodeId ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { boolean res = true ; try { sendPubsubPacket ( Type . set , new NodeExtension ( PubSubElementType . DELETE , nodeId ) , PubSubElementType . DELETE . getNamespace ( ) ) ; } catch ( XMPPErrorException e ) { if ( e . getStanzaError ( ) . getCondition ( ) == StanzaError . Condition . item_not_found ) { res = false ; } else { throw e ; } } nodeMap . remove ( nodeId ) ; return res ; }
Delete the specified node .
19,605
public ConfigureForm getDefaultConfiguration ( ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { PubSub reply = sendPubsubPacket ( Type . get , new NodeExtension ( PubSubElementType . DEFAULT ) , PubSubElementType . DEFAULT . getNamespace ( ) ) ; return NodeUtils . getFormFromPacket ( reply , PubSubElementType . DEFAULT ) ; }
Returns the default settings for Node configuration .
19,606
public boolean supportsAutomaticNodeCreation ( ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { ServiceDiscoveryManager sdm = ServiceDiscoveryManager . getInstanceFor ( connection ( ) ) ; return sdm . supportsFeature ( pubSubService , AUTO_CREATE_FEATURE ) ; }
Check if the PubSub service supports automatic node creation .
19,607
public static DomainBareJid getPubSubService ( XMPPConnection connection ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { return ServiceDiscoveryManager . getInstanceFor ( connection ) . findService ( PubSub . NAMESPACE , true , "pubsub" , "service" ) ; }
Get the default PubSub service for a given XMPP connection . The default PubSub service is simply an arbitrary XMPP service with the PubSub feature and an identity of category pubsub and type service .
19,608
protected void triggerCandidateAdded ( TransportCandidate cand ) throws NotConnectedException , InterruptedException { Iterator < TransportResolverListener > iter = getListenersList ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { TransportResolverListener trl = iter . next ( ) ; if ( trl instanceof TransportResolverListener . Resolver ) { TransportResolverListener . Resolver li = ( TransportResolverListener . Resolver ) trl ; LOGGER . fine ( "triggerCandidateAdded : " + cand . getLocalIp ( ) ) ; li . candidateAdded ( cand ) ; } } }
Trigger a new candidate added event .
19,609
private void triggerResolveInit ( ) { Iterator < TransportResolverListener > iter = getListenersList ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { TransportResolverListener trl = iter . next ( ) ; if ( trl instanceof TransportResolverListener . Resolver ) { TransportResolverListener . Resolver li = ( TransportResolverListener . Resolver ) trl ; li . init ( ) ; } } }
Trigger a event notifying the initialization of the resolution process .
19,610
private void triggerResolveEnd ( ) { Iterator < TransportResolverListener > iter = getListenersList ( ) . iterator ( ) ; while ( iter . hasNext ( ) ) { TransportResolverListener trl = iter . next ( ) ; if ( trl instanceof TransportResolverListener . Resolver ) { TransportResolverListener . Resolver li = ( TransportResolverListener . Resolver ) trl ; li . end ( ) ; } } }
Trigger a event notifying the obtainment of all the candidates .
19,611
protected void addCandidate ( TransportCandidate cand ) throws NotConnectedException , InterruptedException { synchronized ( candidates ) { if ( ! candidates . contains ( cand ) ) candidates . add ( cand ) ; } triggerCandidateAdded ( cand ) ; }
Add a new transport candidate
19,612
public TransportCandidate getPreferredCandidate ( ) { TransportCandidate result = null ; ArrayList < ICECandidate > cands = new ArrayList < > ( ) ; for ( TransportCandidate tpcan : getCandidatesList ( ) ) { if ( tpcan instanceof ICECandidate ) cands . add ( ( ICECandidate ) tpcan ) ; } if ( cands . size ( ) > 0 ) { Collections . sort ( cands ) ; result = cands . get ( cands . size ( ) - 1 ) ; LOGGER . fine ( "Result: " + result . getIp ( ) ) ; } return result ; }
Get the candidate with the highest preference .
19,613
public TransportCandidate getCandidate ( int i ) { TransportCandidate cand ; synchronized ( candidates ) { cand = candidates . get ( i ) ; } return cand ; }
Get the n - th candidate .
19,614
public void initializeAndWait ( ) throws XMPPException , SmackException , InterruptedException { this . initialize ( ) ; try { LOGGER . fine ( "Initializing transport resolver..." ) ; while ( ! this . isInitialized ( ) ) { LOGGER . fine ( "Resolver init still pending" ) ; Thread . sleep ( 1000 ) ; } LOGGER . fine ( "Transport resolved" ) ; } catch ( Exception e ) { LOGGER . log ( Level . WARNING , "exception" , e ) ; } }
Initialize Transport Resolver and wait until it is completely uninitialized .
19,615
public final List < SRVRecord > lookupSRVRecords ( DnsName name , List < HostAddress > failedAddresses , DnssecMode dnssecMode ) { checkIfDnssecRequestedAndSupported ( dnssecMode ) ; return lookupSRVRecords0 ( name , failedAddresses , dnssecMode ) ; }
Gets a list of service records for the specified service .
19,616
MUCInitialPresence . History getMUCHistory ( ) { if ( ! isConfigured ( ) ) { return null ; } return new MUCInitialPresence . History ( maxChars , maxStanzas , seconds , since ) ; }
Returns the History that manages the amount of discussion history provided on entering a room .
19,617
public static ToMatchesFilter create ( Jid address ) { return new ToMatchesFilter ( address , address != null ? address . hasNoResource ( ) : false ) ; }
Creates a filter matching on the to field . If the filter address is bare compares the filter address with the bare from address . Otherwise compares the filter address with the full from address .
19,618
public static MediaSession createSession ( String localhost , int localPort , String remoteHost , int remotePort , MediaSessionListener eventHandler , int quality , boolean secure , boolean micOn ) throws NoProcessorException , UnsupportedFormatException , IOException , GeneralSecurityException { SpeexFormat . setFramesPerPacket ( 1 ) ; byte [ ] masterKey = new byte [ ] { ( byte ) 0xE1 , ( byte ) 0xF9 , 0x7A , 0x0D , 0x3E , 0x01 , ( byte ) 0x8B , ( byte ) 0xE0 , ( byte ) 0xD6 , 0x4F , ( byte ) 0xA3 , 0x2C , 0x06 , ( byte ) 0xDE , 0x41 , 0x39 } ; byte [ ] masterSalt = new byte [ ] { 0x0E , ( byte ) 0xC6 , 0x75 , ( byte ) 0xAD , 0x49 , ( byte ) 0x8A , ( byte ) 0xFE , ( byte ) 0xEB , ( byte ) 0xB6 , ( byte ) 0x96 , 0x0B , 0x3A , ( byte ) 0xAB , ( byte ) 0xE6 } ; DatagramSocket [ ] localPorts = MediaSession . getLocalPorts ( InetAddress . getByName ( localhost ) , localPort ) ; MediaSession session = MediaSession . createInstance ( remoteHost , remotePort , localPorts , quality , secure , masterKey , masterSalt ) ; session . setListener ( eventHandler ) ; session . setSourceDescription ( new SourceDescription [ ] { new SourceDescription ( SourceDescription . SOURCE_DESC_NAME , "Superman" , 1 , false ) , new SourceDescription ( SourceDescription . SOURCE_DESC_EMAIL , "cdcie.tester@je.jfcom.mil" , 1 , false ) , new SourceDescription ( SourceDescription . SOURCE_DESC_LOC , InetAddress . getByName ( localhost ) + " Port " + session . getLocalDataPort ( ) , 1 , false ) , new SourceDescription ( SourceDescription . SOURCE_DESC_TOOL , "JFCOM CDCIE Audio Chat" , 1 , false ) } ) ; return session ; }
Create a Session using Speex Codec .
19,619
public void startTransmit ( ) { try { LOGGER . fine ( "start" ) ; mediaSession . start ( true ) ; this . mediaReceived ( "" ) ; } catch ( IOException e ) { LOGGER . log ( Level . WARNING , "exception" , e ) ; } }
Starts transmission and for NAT Traversal reasons start receiving also .
19,620
protected HeadersExtension parseHeaders ( XmlPullParser parser ) throws IOException , XmlPullParserException , SmackParsingException { HeadersExtension headersExtension = null ; if ( parser . next ( ) == XmlPullParser . START_TAG && parser . getName ( ) . equals ( HeadersExtension . ELEMENT ) ) { headersExtension = HeadersProvider . INSTANCE . parse ( parser ) ; parser . next ( ) ; } return headersExtension ; }
Parses HeadersExtension element if any .
19,621
protected AbstractHttpOverXmpp . Data parseData ( XmlPullParser parser ) throws XmlPullParserException , IOException { NamedElement child = null ; boolean done = false ; AbstractHttpOverXmpp . Data data = null ; if ( parser . getEventType ( ) == XmlPullParser . START_TAG ) { while ( ! done ) { int eventType = parser . next ( ) ; if ( eventType == XmlPullParser . START_TAG ) { switch ( parser . getName ( ) ) { case ELEMENT_TEXT : child = parseText ( parser ) ; break ; case ELEMENT_BASE_64 : child = parseBase64 ( parser ) ; break ; case ELEMENT_CHUNKED_BASE_64 : child = parseChunkedBase64 ( parser ) ; break ; case ELEMENT_XML : child = parseXml ( parser ) ; break ; case ELEMENT_IBB : child = parseIbb ( parser ) ; break ; case ELEMENT_SIPUB : throw new UnsupportedOperationException ( "sipub is not supported yet" ) ; case ELEMENT_JINGLE : throw new UnsupportedOperationException ( "jingle is not supported yet" ) ; default : throw new IllegalArgumentException ( "unsupported child tag: " + parser . getName ( ) ) ; } } else if ( eventType == XmlPullParser . END_TAG ) { if ( parser . getName ( ) . equals ( ELEMENT_DATA ) ) { done = true ; } } } data = new AbstractHttpOverXmpp . Data ( child ) ; } return data ; }
Parses Data element if any .
19,622
public List < PayloadType > getPayloads ( ) { List < PayloadType > list = new ArrayList < > ( ) ; if ( preferredPayloadType != null ) list . add ( preferredPayloadType ) ; for ( JingleMediaManager manager : managers ) { for ( PayloadType payloadType : manager . getPayloads ( ) ) { if ( ! list . contains ( payloadType ) && ! payloadType . equals ( preferredPayloadType ) ) list . add ( payloadType ) ; } } return list ; }
Return all supported Payloads for this Manager .
19,623
public static boolean isServiceEnabled ( XMPPConnection connection , Jid userID ) throws XMPPException , SmackException , InterruptedException { return ServiceDiscoveryManager . getInstanceFor ( connection ) . supportsFeature ( userID , Jingle . NAMESPACE ) ; }
Returns true if the specified user handles Jingle messages .
19,624
public synchronized void addJingleSessionRequestListener ( final JingleSessionRequestListener jingleSessionRequestListener ) { if ( jingleSessionRequestListener != null ) { if ( jingleSessionRequestListeners == null ) { initJingleSessionRequestListeners ( ) ; } synchronized ( jingleSessionRequestListeners ) { jingleSessionRequestListeners . add ( jingleSessionRequestListener ) ; } } }
Add a Jingle session request listenerJingle to listen to incoming session requests .
19,625
public void triggerSessionCreated ( JingleSession jingleSession ) { jingleSessions . add ( jingleSession ) ; jingleSession . addListener ( this ) ; for ( CreatedJingleSessionListener createdJingleSessionListener : creationListeners ) { try { createdJingleSessionListener . sessionCreated ( jingleSession ) ; } catch ( Exception e ) { LOGGER . log ( Level . WARNING , "exception" , e ) ; } } }
Trigger CreatedJingleSessionListeners that a session was created .
19,626
private void initJingleSessionRequestListeners ( ) { StanzaFilter initRequestFilter = new StanzaFilter ( ) { public boolean accept ( Stanza pin ) { if ( pin instanceof IQ ) { IQ iq = ( IQ ) pin ; if ( iq . getType ( ) . equals ( IQ . Type . set ) ) { if ( iq instanceof Jingle ) { Jingle jin = ( Jingle ) pin ; if ( jin . getAction ( ) . equals ( JingleActionEnum . SESSION_INITIATE ) ) { return true ; } } } } return false ; } } ; jingleSessionRequestListeners = new ArrayList < > ( ) ; connection . addAsyncStanzaListener ( new StanzaListener ( ) { public void processStanza ( Stanza packet ) { triggerSessionRequested ( ( Jingle ) packet ) ; } } , initRequestFilter ) ; }
Register the listenerJingles waiting for a Jingle stanza that tries to establish a new session .
19,627
public void disconnectAllSessions ( ) { List < JingleSession > sessions = jingleSessions . subList ( 0 , jingleSessions . size ( ) ) ; for ( JingleSession jingleSession : sessions ) try { jingleSession . terminate ( ) ; } catch ( Exception e ) { LOGGER . log ( Level . WARNING , "exception" , e ) ; } sessions . clear ( ) ; }
Disconnect all Jingle Sessions .
19,628
void triggerSessionRequested ( Jingle initJin ) { JingleSessionRequestListener [ ] jingleSessionRequestListeners ; synchronized ( this . jingleSessionRequestListeners ) { jingleSessionRequestListeners = new JingleSessionRequestListener [ this . jingleSessionRequestListeners . size ( ) ] ; this . jingleSessionRequestListeners . toArray ( jingleSessionRequestListeners ) ; } JingleSessionRequest request = new JingleSessionRequest ( this , initJin ) ; for ( int i = 0 ; i < jingleSessionRequestListeners . length ; i ++ ) { jingleSessionRequestListeners [ i ] . sessionRequested ( request ) ; } }
Activates the listenerJingles on a Jingle session request .
19,629
public JingleSession createOutgoingJingleSession ( EntityFullJid responder ) throws XMPPException { JingleSession session = new JingleSession ( connection , null , connection . getUser ( ) , responder , jingleMediaManagers ) ; triggerSessionCreated ( session ) ; return session ; }
Creates an Jingle session to start a communication with another user .
19,630
public JingleSession createIncomingJingleSession ( JingleSessionRequest request ) throws XMPPException { if ( request == null ) { throw new NullPointerException ( "Received request cannot be null" ) ; } JingleSession session = new JingleSession ( connection , request , request . getFrom ( ) , connection . getUser ( ) , jingleMediaManagers ) ; triggerSessionCreated ( session ) ; return session ; }
When the session request is acceptable this method should be invoked . It will create an JingleSession which allows the negotiation to procede .
19,631
public JingleSession getSession ( String jid ) { for ( JingleSession jingleSession : jingleSessions ) { if ( jingleSession . getResponder ( ) . equals ( jid ) ) { return jingleSession ; } } return null ; }
Get a session with the informed JID . If no session is found return null .
19,632
public String blocksOf8Chars ( ) { StringBuilder pretty = new StringBuilder ( ) ; for ( int i = 0 ; i < 8 ; i ++ ) { if ( i != 0 ) pretty . append ( ' ' ) ; pretty . append ( this . fingerprintString . substring ( 8 * i , 8 * ( i + 1 ) ) ) ; } return pretty . toString ( ) ; }
Split the fingerprint in blocks of 8 characters with spaces between .
19,633
public static synchronized IoTDataManager getInstanceFor ( XMPPConnection connection ) { IoTDataManager manager = INSTANCES . get ( connection ) ; if ( manager == null ) { manager = new IoTDataManager ( connection ) ; INSTANCES . put ( connection , manager ) ; } return manager ; }
Get the manger instance responsible for the given connection .
19,634
public List < IoTFieldsExtension > requestMomentaryValuesReadOut ( EntityFullJid jid ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { final XMPPConnection connection = connection ( ) ; final int seqNr = nextSeqNr . incrementAndGet ( ) ; IoTDataRequest iotDataRequest = new IoTDataRequest ( seqNr , true ) ; iotDataRequest . setTo ( jid ) ; StanzaFilter doneFilter = new IoTFieldsExtensionFilter ( seqNr , true ) ; StanzaFilter dataFilter = new IoTFieldsExtensionFilter ( seqNr , false ) ; StanzaCollector doneCollector = connection . createStanzaCollector ( doneFilter ) ; StanzaCollector . Configuration dataCollectorConfiguration = StanzaCollector . newConfiguration ( ) . setStanzaFilter ( dataFilter ) . setCollectorToReset ( doneCollector ) ; StanzaCollector dataCollector = connection . createStanzaCollector ( dataCollectorConfiguration ) ; try { connection . createStanzaCollectorAndSend ( iotDataRequest ) . nextResultOrThrow ( ) ; doneCollector . nextResult ( ) ; } finally { dataCollector . cancel ( ) ; } int collectedCount = dataCollector . getCollectedCount ( ) ; List < IoTFieldsExtension > res = new ArrayList < > ( collectedCount ) ; for ( int i = 0 ; i < collectedCount ; i ++ ) { Message message = dataCollector . pollResult ( ) ; IoTFieldsExtension iotFieldsExtension = IoTFieldsExtension . from ( message ) ; res . add ( iotFieldsExtension ) ; } return res ; }
Try to read out a things momentary values .
19,635
public static synchronized BlockingCommandManager getInstanceFor ( XMPPConnection connection ) { BlockingCommandManager blockingCommandManager = INSTANCES . get ( connection ) ; if ( blockingCommandManager == null ) { blockingCommandManager = new BlockingCommandManager ( connection ) ; INSTANCES . put ( connection , blockingCommandManager ) ; } return blockingCommandManager ; }
Get the singleton instance of BlockingCommandManager .
19,636
public List < Jid > getBlockList ( ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { if ( blockListCached == null ) { BlockListIQ blockListIQ = new BlockListIQ ( ) ; BlockListIQ blockListIQResult = connection ( ) . createStanzaCollectorAndSend ( blockListIQ ) . nextResultOrThrow ( ) ; blockListCached = blockListIQResult . getBlockedJidsCopy ( ) ; } return Collections . unmodifiableList ( blockListCached ) ; }
Returns the block list .
19,637
public void blockContacts ( List < Jid > jids ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { BlockContactsIQ blockContactIQ = new BlockContactsIQ ( jids ) ; connection ( ) . createStanzaCollectorAndSend ( blockContactIQ ) . nextResultOrThrow ( ) ; }
Block contacts .
19,638
public void unblockContacts ( List < Jid > jids ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { UnblockContactsIQ unblockContactIQ = new UnblockContactsIQ ( jids ) ; connection ( ) . createStanzaCollectorAndSend ( unblockContactIQ ) . nextResultOrThrow ( ) ; }
Unblock contacts .
19,639
public void unblockAll ( ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { UnblockContactsIQ unblockContactIQ = new UnblockContactsIQ ( ) ; connection ( ) . createStanzaCollectorAndSend ( unblockContactIQ ) . nextResultOrThrow ( ) ; }
Unblock all .
19,640
public void execute ( Form form ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { executeAction ( Action . execute , form ) ; }
Executes the default action of the command with the information provided in the Form . This form must be the answer form of the previous stage . If there is a problem executing the command it throws an XMPPException .
19,641
public synchronized void controllerUpdate ( ControllerEvent ce ) { Player p = ( Player ) ce . getSourceController ( ) ; if ( p == null ) return ; if ( ce instanceof RealizeCompleteEvent ) { p . start ( ) ; } if ( ce instanceof ControllerErrorEvent ) { p . removeControllerListener ( this ) ; LOGGER . severe ( "Receiver internal error: " + ce ) ; } }
ControllerListener for the Players .
19,642
public void addAlgorithmsToFeatures ( List < ALGORITHM > algorithms ) { ServiceDiscoveryManager sdm = ServiceDiscoveryManager . getInstanceFor ( connection ( ) ) ; for ( ALGORITHM algo : algorithms ) { sdm . addFeature ( asFeature ( algo ) ) ; } }
Announce support for the given list of algorithms .
19,643
public static synchronized HashManager getInstanceFor ( XMPPConnection connection ) { HashManager hashManager = INSTANCES . get ( connection ) ; if ( hashManager == null ) { hashManager = new HashManager ( connection ) ; INSTANCES . put ( connection , hashManager ) ; } return hashManager ; }
Get an instance of the HashManager for the given connection .
19,644
public OutgoingFileTransfer createOutgoingFileTransfer ( EntityFullJid userID ) { if ( userID == null ) { throw new IllegalArgumentException ( "userID was null" ) ; } return new OutgoingFileTransfer ( connection ( ) . getUser ( ) , userID , FileTransferNegotiator . getNextStreamID ( ) , fileTransferNegotiator ) ; }
Creates an OutgoingFileTransfer to send a file to another user .
19,645
protected IncomingFileTransfer createIncomingFileTransfer ( FileTransferRequest request ) { if ( request == null ) { throw new NullPointerException ( "ReceiveRequest cannot be null" ) ; } IncomingFileTransfer transfer = new IncomingFileTransfer ( request , fileTransferNegotiator ) ; transfer . setFileInfo ( request . getFileName ( ) , request . getFileSize ( ) ) ; return transfer ; }
When the file transfer request is acceptable this method should be invoked . It will create an IncomingFileTransfer which allows the transmission of the file to proceed .
19,646
public void accept ( ) throws NotConnectedException , InterruptedException { Stanza acceptPacket = new AcceptPacket ( this . session . getWorkgroupJID ( ) ) ; connection . sendStanza ( acceptPacket ) ; accepted = true ; }
Accepts the offer .
19,647
public void reject ( ) throws NotConnectedException , InterruptedException { RejectPacket rejectPacket = new RejectPacket ( this . session . getWorkgroupJID ( ) ) ; connection . sendStanza ( rejectPacket ) ; rejected = true ; }
Rejects the offer .
19,648
public String toXML ( org . jivesoftware . smack . packet . XmlEnvironment enclosingNamespace ) { StringBuilder buf = new StringBuilder ( ) ; buf . append ( '<' ) . append ( getElementName ( ) ) . append ( " xmlns=\"" ) . append ( getNamespace ( ) ) . append ( "\">" ) ; if ( isOffline ( ) ) buf . append ( '<' ) . append ( MessageEvent . OFFLINE ) . append ( "/>" ) ; if ( isDelivered ( ) ) buf . append ( '<' ) . append ( MessageEvent . DELIVERED ) . append ( "/>" ) ; if ( isDisplayed ( ) ) buf . append ( '<' ) . append ( MessageEvent . DISPLAYED ) . append ( "/>" ) ; if ( isComposing ( ) ) buf . append ( '<' ) . append ( MessageEvent . COMPOSING ) . append ( "/>" ) ; if ( getStanzaId ( ) != null ) buf . append ( "<id>" ) . append ( getStanzaId ( ) ) . append ( "</id>" ) ; buf . append ( "</" ) . append ( getElementName ( ) ) . append ( '>' ) ; return buf . toString ( ) ; }
Returns the XML representation of a Message Event according the specification .
19,649
public static DirectoryRosterStore init ( final File baseDir ) { DirectoryRosterStore store = new DirectoryRosterStore ( baseDir ) ; if ( store . setRosterVersion ( "" ) ) { return store ; } else { return null ; } }
Creates a new roster store on disk .
19,650
public static DirectoryRosterStore open ( final File baseDir ) { DirectoryRosterStore store = new DirectoryRosterStore ( baseDir ) ; String s = FileUtils . readFile ( store . getVersionFile ( ) ) ; if ( s != null && s . startsWith ( STORE_ID + "\n" ) ) { return store ; } else { return null ; } }
Opens a roster store .
19,651
public static BoBHash fromSrc ( String src ) { String hashType = src . substring ( src . lastIndexOf ( "cid:" ) + 4 , src . indexOf ( "+" ) ) ; String hash = src . substring ( src . indexOf ( "+" ) + 1 , src . indexOf ( "@bob.xmpp.org" ) ) ; return new BoBHash ( hash , hashType ) ; }
Get BoB hash from src attribute string .
19,652
public static BoBHash fromCid ( String cid ) { String hashType = cid . substring ( 0 , cid . indexOf ( "+" ) ) ; String hash = cid . substring ( cid . indexOf ( "+" ) + 1 , cid . indexOf ( "@bob.xmpp.org" ) ) ; return new BoBHash ( hash , hashType ) ; }
Get BoB hash from cid attribute string .
19,653
public static void preApproveSubscriptionIfRequiredAndPossible ( Roster roster , BareJid jid ) throws NotLoggedInException , NotConnectedException , InterruptedException { if ( ! roster . isSubscriptionPreApprovalSupported ( ) ) { return ; } RosterEntry entry = roster . getEntry ( jid ) ; if ( entry == null || ( ! entry . canSeeMyPresence ( ) && ! entry . isApproved ( ) ) ) { try { roster . preApprove ( jid ) ; } catch ( FeatureNotSupportedException e ) { throw new AssertionError ( e ) ; } } }
Pre - approve the subscription if it is required and possible .
19,654
protected TransportResolver createResolver ( JingleSession session ) { BridgedResolver bridgedResolver = new BridgedResolver ( this . xmppConnection ) ; return bridgedResolver ; }
Return the correspondent resolver
19,655
private static List < HostAddress > sortSRVRecords ( List < SRVRecord > records ) { if ( records . size ( ) == 1 && records . get ( 0 ) . getFQDN ( ) . isRootLabel ( ) ) return Collections . emptyList ( ) ; Collections . sort ( records ) ; SortedMap < Integer , List < SRVRecord > > buckets = new TreeMap < Integer , List < SRVRecord > > ( ) ; for ( SRVRecord r : records ) { Integer priority = r . getPriority ( ) ; List < SRVRecord > bucket = buckets . get ( priority ) ; if ( bucket == null ) { bucket = new LinkedList < SRVRecord > ( ) ; buckets . put ( priority , bucket ) ; } bucket . add ( r ) ; } List < HostAddress > res = new ArrayList < HostAddress > ( records . size ( ) ) ; for ( Integer priority : buckets . keySet ( ) ) { List < SRVRecord > bucket = buckets . get ( priority ) ; int bucketSize ; while ( ( bucketSize = bucket . size ( ) ) > 0 ) { int [ ] totals = new int [ bucketSize ] ; int running_total = 0 ; int count = 0 ; int zeroWeight = 1 ; for ( SRVRecord r : bucket ) { if ( r . getWeight ( ) > 0 ) { zeroWeight = 0 ; break ; } } for ( SRVRecord r : bucket ) { running_total += ( r . getWeight ( ) + zeroWeight ) ; totals [ count ] = running_total ; count ++ ; } int selectedPos ; if ( running_total == 0 ) { selectedPos = ( int ) ( Math . random ( ) * bucketSize ) ; } else { double rnd = Math . random ( ) * running_total ; selectedPos = bisect ( totals , rnd ) ; } SRVRecord chosenSRVRecord = bucket . remove ( selectedPos ) ; res . add ( chosenSRVRecord ) ; } } return res ; }
Sort a given list of SRVRecords as described in RFC 2782 Note that we follow the RFC with one exception . In a group of the same priority only the first entry is calculated by random . The others are ore simply ordered by their priority .
19,656
public static List < ClassLoader > getClassLoaders ( ) { ClassLoader [ ] classLoaders = new ClassLoader [ 2 ] ; classLoaders [ 0 ] = FileUtils . class . getClassLoader ( ) ; classLoaders [ 1 ] = Thread . currentThread ( ) . getContextClassLoader ( ) ; List < ClassLoader > loaders = new ArrayList < ClassLoader > ( classLoaders . length ) ; for ( ClassLoader classLoader : classLoaders ) { if ( classLoader != null ) { loaders . add ( classLoader ) ; } } return loaders ; }
Returns default classloaders .
19,657
@ SuppressWarnings ( "DefaultCharset" ) public static String readFileOrThrow ( File file ) throws IOException { try ( Reader reader = new FileReader ( file ) ) { char [ ] buf = new char [ 8192 ] ; int len ; StringBuilder s = new StringBuilder ( ) ; while ( ( len = reader . read ( buf ) ) >= 0 ) { s . append ( buf , 0 , len ) ; } return s . toString ( ) ; } }
Reads the contents of a File .
19,658
public OfferRequestPacket parse ( XmlPullParser parser , int initialDepth , XmlEnvironment xmlEnvironment ) throws XmlPullParserException , IOException , SmackParsingException { int eventType = parser . getEventType ( ) ; String sessionID = null ; int timeout = - 1 ; OfferContent content = null ; boolean done = false ; Map < String , List < String > > metaData = new HashMap < > ( ) ; if ( eventType != XmlPullParser . START_TAG ) { } Jid userJID = ParserUtils . getJidAttribute ( parser ) ; Jid userID = userJID ; while ( ! done ) { eventType = parser . next ( ) ; if ( eventType == XmlPullParser . START_TAG ) { String elemName = parser . getName ( ) ; if ( "timeout" . equals ( elemName ) ) { timeout = Integer . parseInt ( parser . nextText ( ) ) ; } else if ( MetaData . ELEMENT_NAME . equals ( elemName ) ) { metaData = MetaDataUtils . parseMetaData ( parser ) ; } else if ( SessionID . ELEMENT_NAME . equals ( elemName ) ) { sessionID = parser . getAttributeValue ( "" , "id" ) ; } else if ( UserID . ELEMENT_NAME . equals ( elemName ) ) { userID = ParserUtils . getJidAttribute ( parser , "id" ) ; } else if ( "user-request" . equals ( elemName ) ) { content = UserRequest . getInstance ( ) ; } else if ( RoomInvitation . ELEMENT_NAME . equals ( elemName ) ) { RoomInvitation invitation = ( RoomInvitation ) PacketParserUtils . parseExtensionElement ( RoomInvitation . ELEMENT_NAME , RoomInvitation . NAMESPACE , parser , xmlEnvironment ) ; content = new InvitationRequest ( invitation . getInviter ( ) , invitation . getRoom ( ) , invitation . getReason ( ) ) ; } else if ( RoomTransfer . ELEMENT_NAME . equals ( elemName ) ) { RoomTransfer transfer = ( RoomTransfer ) PacketParserUtils . parseExtensionElement ( RoomTransfer . ELEMENT_NAME , RoomTransfer . NAMESPACE , parser , xmlEnvironment ) ; content = new TransferRequest ( transfer . getInviter ( ) , transfer . getRoom ( ) , transfer . getReason ( ) ) ; } } else if ( eventType == XmlPullParser . END_TAG ) { if ( "offer" . equals ( parser . getName ( ) ) ) { done = true ; } } } OfferRequestPacket offerRequest = new OfferRequestPacket ( userJID , userID , timeout , metaData , sessionID , content ) ; offerRequest . setType ( IQ . Type . set ) ; return offerRequest ; }
happen anytime soon .
19,659
public static synchronized ReconnectionManager getInstanceFor ( AbstractXMPPConnection connection ) { ReconnectionManager reconnectionManager = INSTANCES . get ( connection ) ; if ( reconnectionManager == null ) { reconnectionManager = new ReconnectionManager ( connection ) ; INSTANCES . put ( connection , reconnectionManager ) ; } return reconnectionManager ; }
Get a instance of ReconnectionManager for the given connection .
19,660
public synchronized void enableAutomaticReconnection ( ) { if ( automaticReconnectEnabled ) { return ; } XMPPConnection connection = weakRefConnection . get ( ) ; if ( connection == null ) { throw new IllegalStateException ( "Connection instance no longer available" ) ; } connection . addConnectionListener ( connectionListener ) ; automaticReconnectEnabled = true ; }
Enable the automatic reconnection mechanism . Does nothing if already enabled .
19,661
public synchronized void disableAutomaticReconnection ( ) { if ( ! automaticReconnectEnabled ) { return ; } XMPPConnection connection = weakRefConnection . get ( ) ; if ( connection == null ) { throw new IllegalStateException ( "Connection instance no longer available" ) ; } connection . removeConnectionListener ( connectionListener ) ; automaticReconnectEnabled = false ; }
Disable the automatic reconnection mechanism . Does nothing if already disabled .
19,662
private synchronized void reconnect ( ) { XMPPConnection connection = this . weakRefConnection . get ( ) ; if ( connection == null ) { LOGGER . fine ( "Connection is null, will not reconnect" ) ; return ; } if ( reconnectionThread != null && reconnectionThread . isAlive ( ) ) return ; reconnectionThread = Async . go ( reconnectionRunnable , "Smack Reconnection Manager (" + connection . getConnectionCounter ( ) + ')' ) ; }
Starts a reconnection mechanism if it was configured to do that . The algorithm is been executed when the first connection error is detected .
19,663
public List < V > remove ( K key , int num ) { List < V > values = map . get ( key ) ; if ( values == null ) { return Collections . emptyList ( ) ; } final int resultSize = values . size ( ) > num ? num : values . size ( ) ; final List < V > result = new ArrayList < > ( resultSize ) ; for ( int i = 0 ; i < resultSize ; i ++ ) { result . add ( values . get ( 0 ) ) ; } if ( values . isEmpty ( ) ) { map . remove ( key ) ; } return result ; }
Remove the given number of values for a given key . May return less values then requested .
19,664
public List < V > values ( ) { List < V > values = new ArrayList < > ( size ( ) ) ; for ( List < V > list : map . values ( ) ) { values . addAll ( list ) ; } return values ; }
Returns a new list containing all values of this multi map .
19,665
public void initialize ( ) { JingleSession session = getJingleSession ( ) ; if ( session != null && session . getInitiator ( ) . equals ( session . getConnection ( ) . getUser ( ) ) ) { try { InetAddress remote = InetAddress . getByName ( getRemote ( ) . getIp ( ) ) ; transmitter = new ImageTransmitter ( new DatagramSocket ( getLocal ( ) . getPort ( ) ) , remote , getRemote ( ) . getPort ( ) , new Rectangle ( 0 , 0 , width , height ) ) ; } catch ( Exception e ) { LOGGER . log ( Level . WARNING , "exception" , e ) ; } } else { JFrame window = new JFrame ( ) ; JPanel jp = new JPanel ( ) ; window . add ( jp ) ; window . setLocation ( 0 , 0 ) ; window . setSize ( 600 , 600 ) ; window . addWindowListener ( new WindowAdapter ( ) { public void windowClosed ( WindowEvent e ) { receiver . stop ( ) ; } } ) ; try { receiver = new ImageReceiver ( InetAddress . getByName ( "0.0.0.0" ) , getRemote ( ) . getPort ( ) , getLocal ( ) . getPort ( ) , width , height ) ; LOGGER . fine ( "Receiving on:" + receiver . getLocalPort ( ) ) ; } catch ( UnknownHostException e ) { LOGGER . log ( Level . WARNING , "exception" , e ) ; } jp . add ( receiver ) ; receiver . setVisible ( true ) ; window . setAlwaysOnTop ( true ) ; window . setVisible ( true ) ; } }
Initialize the screen share channels .
19,666
public static void addSpoiler ( Message message , String hint ) { message . addExtension ( new SpoilerElement ( null , hint ) ) ; }
Add a SpoilerElement with a hint to a message .
19,667
public static void addSpoiler ( Message message , String lang , String hint ) { message . addExtension ( new SpoilerElement ( lang , hint ) ) ; }
Add a SpoilerElement with a hint in a certain language to a message .
19,668
public static Map < String , String > getSpoilers ( Message message ) { if ( ! containsSpoiler ( message ) ) { return Collections . emptyMap ( ) ; } List < ExtensionElement > spoilers = message . getExtensions ( SpoilerElement . ELEMENT , NAMESPACE ) ; Map < String , String > map = new HashMap < > ( ) ; for ( ExtensionElement e : spoilers ) { SpoilerElement s = ( SpoilerElement ) e ; if ( s . getLanguage ( ) == null || s . getLanguage ( ) . equals ( "" ) ) { map . put ( "" , s . getHint ( ) ) ; } else { map . put ( s . getLanguage ( ) , s . getHint ( ) ) ; } } return map ; }
Return a map of all spoilers contained in a message . The map uses the language of a spoiler as key . If a spoiler has no language attribute its key will be an empty String .
19,669
public AgentRoster getAgentRoster ( ) throws NotConnectedException , InterruptedException { if ( agentRoster == null ) { agentRoster = new AgentRoster ( connection , workgroupJID ) ; } int elapsed = 0 ; while ( ! agentRoster . rosterInitialized && elapsed <= 2000 ) { try { Thread . sleep ( 500 ) ; } catch ( Exception e ) { } elapsed += 500 ; } return agentRoster ; }
Returns the agent roster for the workgroup which contains .
19,670
public void setMetaData ( String key , String val ) throws XMPPException , SmackException , InterruptedException { synchronized ( this . metaData ) { List < String > oldVals = metaData . get ( key ) ; if ( oldVals == null || ! oldVals . get ( 0 ) . equals ( val ) ) { oldVals . set ( 0 , val ) ; setStatus ( presenceMode , maxChats ) ; } } }
Allows the addition of a new key - value pair to the agent s meta data if the value is new data the revised meta data will be rebroadcast in an agent s presence broadcast .
19,671
public void removeMetaData ( String key ) throws XMPPException , SmackException , InterruptedException { synchronized ( this . metaData ) { List < String > oldVal = metaData . remove ( key ) ; if ( oldVal != null ) { setStatus ( presenceMode , maxChats ) ; } } }
Allows the removal of data from the agent s meta data if the key represents existing data the revised meta data will be rebroadcast in an agent s presence broadcast .
19,672
public void setOnline ( boolean online ) throws XMPPException , SmackException , InterruptedException { if ( this . online == online ) { return ; } Presence presence ; if ( online ) { presence = new Presence ( Presence . Type . available ) ; presence . setTo ( workgroupJID ) ; presence . addExtension ( new StandardExtensionElement ( AgentStatus . ELEMENT_NAME , AgentStatus . NAMESPACE ) ) ; StanzaCollector collector = this . connection . createStanzaCollectorAndSend ( new AndFilter ( new StanzaTypeFilter ( Presence . class ) , FromMatchesFilter . create ( workgroupJID ) ) , presence ) ; presence = collector . nextResultOrThrow ( ) ; this . online = online ; } else { this . online = online ; presence = new Presence ( Presence . Type . unavailable ) ; presence . setTo ( workgroupJID ) ; presence . addExtension ( new StandardExtensionElement ( AgentStatus . ELEMENT_NAME , AgentStatus . NAMESPACE ) ) ; connection . sendStanza ( presence ) ; } }
Sets whether the agent is online with the workgroup . If the user tries to go online with the workgroup but is not allowed to be an agent an XMPPError with error code 401 will be thrown .
19,673
public void dequeueUser ( EntityJid userID ) throws XMPPException , NotConnectedException , InterruptedException { DepartQueuePacket departPacket = new DepartQueuePacket ( workgroupJID , userID ) ; this . connection . sendStanza ( departPacket ) ; }
Removes a user from the workgroup queue . This is an administrative action that the
19,674
public OccupantsInfo getOccupantsInfo ( String roomID ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { OccupantsInfo request = new OccupantsInfo ( roomID ) ; request . setType ( IQ . Type . get ) ; request . setTo ( workgroupJID ) ; OccupantsInfo response = ( OccupantsInfo ) connection . createStanzaCollectorAndSend ( request ) . nextResultOrThrow ( ) ; return response ; }
Asks the workgroup for information about the occupants of the specified room . The returned information will include the real JID of the occupants the nickname of the user in the room as well as the date when the user joined the room .
19,675
public WorkgroupQueue getQueue ( String queueName ) { Resourcepart queueNameResourcepart ; try { queueNameResourcepart = Resourcepart . from ( queueName ) ; } catch ( XmppStringprepException e ) { throw new IllegalArgumentException ( e ) ; } return getQueue ( queueNameResourcepart ) ; }
Get queue .
19,676
public void addOfferListener ( OfferListener offerListener ) { synchronized ( offerListeners ) { if ( ! offerListeners . contains ( offerListener ) ) { offerListeners . add ( offerListener ) ; } } }
Adds an offer listener .
19,677
public void addInvitationListener ( WorkgroupInvitationListener invitationListener ) { synchronized ( invitationListeners ) { if ( ! invitationListeners . contains ( invitationListener ) ) { invitationListeners . add ( invitationListener ) ; } } }
Adds an invitation listener .
19,678
public void setNote ( String sessionID , String note ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { ChatNotes notes = new ChatNotes ( ) ; notes . setType ( IQ . Type . set ) ; notes . setTo ( workgroupJID ) ; notes . setSessionID ( sessionID ) ; notes . setNotes ( note ) ; connection . createStanzaCollectorAndSend ( notes ) . nextResultOrThrow ( ) ; }
Creates a ChatNote that will be mapped to the given chat session .
19,679
public ChatNotes getNote ( String sessionID ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { ChatNotes request = new ChatNotes ( ) ; request . setType ( IQ . Type . get ) ; request . setTo ( workgroupJID ) ; request . setSessionID ( sessionID ) ; ChatNotes response = connection . createStanzaCollectorAndSend ( request ) . nextResultOrThrow ( ) ; return response ; }
Retrieves the ChatNote associated with a given chat session .
19,680
public AgentChatHistory getAgentHistory ( EntityBareJid jid , int maxSessions , Date startDate ) throws XMPPException , NotConnectedException , InterruptedException { AgentChatHistory request ; if ( startDate != null ) { request = new AgentChatHistory ( jid , maxSessions , startDate ) ; } else { request = new AgentChatHistory ( jid , maxSessions ) ; } request . setType ( IQ . Type . get ) ; request . setTo ( workgroupJID ) ; AgentChatHistory response = connection . createStanzaCollectorAndSend ( request ) . nextResult ( ) ; return response ; }
Retrieves the AgentChatHistory associated with a particular agent jid .
19,681
public SearchSettings getSearchSettings ( ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { SearchSettings request = new SearchSettings ( ) ; request . setType ( IQ . Type . get ) ; request . setTo ( workgroupJID ) ; SearchSettings response = connection . createStanzaCollectorAndSend ( request ) . nextResultOrThrow ( ) ; return response ; }
Asks the workgroup for it s Search Settings .
19,682
public MacroGroup getMacros ( boolean global ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { Macros request = new Macros ( ) ; request . setType ( IQ . Type . get ) ; request . setTo ( workgroupJID ) ; request . setPersonal ( ! global ) ; Macros response = connection . createStanzaCollectorAndSend ( request ) . nextResultOrThrow ( ) ; return response . getRootGroup ( ) ; }
Asks the workgroup for it s Global Macros .
19,683
public void saveMacros ( MacroGroup group ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { Macros request = new Macros ( ) ; request . setType ( IQ . Type . set ) ; request . setTo ( workgroupJID ) ; request . setPersonal ( true ) ; request . setPersonalMacroGroup ( group ) ; connection . createStanzaCollectorAndSend ( request ) . nextResultOrThrow ( ) ; }
Persists the Personal Macro for an agent .
19,684
public Map < String , List < String > > getChatMetadata ( String sessionID ) throws XMPPException , NotConnectedException , InterruptedException { ChatMetadata request = new ChatMetadata ( ) ; request . setType ( IQ . Type . get ) ; request . setTo ( workgroupJID ) ; request . setSessionID ( sessionID ) ; ChatMetadata response = connection . createStanzaCollectorAndSend ( request ) . nextResult ( ) ; return response . getMetadata ( ) ; }
Query for metadata associated with a session id .
19,685
public GenericSettings getGenericSettings ( XMPPConnection con , String query ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { GenericSettings setting = new GenericSettings ( ) ; setting . setType ( IQ . Type . get ) ; setting . setTo ( workgroupJID ) ; GenericSettings response = connection . createStanzaCollectorAndSend ( setting ) . nextResultOrThrow ( ) ; return response ; }
Returns the generic metadata of the workgroup the agent belongs to .
19,686
public boolean isNull ( ) { if ( ip == null ) { return true ; } else if ( ip . length ( ) == 0 ) { return true ; } else if ( port < 0 ) { return true ; } else { return false ; } }
Return true if the candidate is not valid .
19,687
public int compareTo ( ICECandidate arg ) { if ( getPreference ( ) < arg . getPreference ( ) ) { return - 1 ; } else if ( getPreference ( ) > arg . getPreference ( ) ) { return 1 ; } return 0 ; }
Compare the to other Transport candidate .
19,688
public static Stanza parseStanza ( XmlPullParser parser , XmlEnvironment outerXmlEnvironment ) throws Exception { ParserUtils . assertAtStartTag ( parser ) ; final String name = parser . getName ( ) ; switch ( name ) { case Message . ELEMENT : return parseMessage ( parser , outerXmlEnvironment ) ; case IQ . IQ_ELEMENT : return parseIQ ( parser , outerXmlEnvironment ) ; case Presence . ELEMENT : return parsePresence ( parser , outerXmlEnvironment ) ; default : throw new IllegalArgumentException ( "Can only parse message, iq or presence, not " + name ) ; } }
Tries to parse and return either a Message IQ or Presence stanza .
19,689
public static Message parseMessage ( XmlPullParser parser , XmlEnvironment outerXmlEnvironment ) throws XmlPullParserException , IOException , SmackParsingException { ParserUtils . assertAtStartTag ( parser ) ; assert ( parser . getName ( ) . equals ( Message . ELEMENT ) ) ; XmlEnvironment messageXmlEnvironment = XmlEnvironment . from ( parser , outerXmlEnvironment ) ; final int initialDepth = parser . getDepth ( ) ; Message message = new Message ( ) ; message . setStanzaId ( parser . getAttributeValue ( "" , "id" ) ) ; message . setTo ( ParserUtils . getJidAttribute ( parser , "to" ) ) ; message . setFrom ( ParserUtils . getJidAttribute ( parser , "from" ) ) ; String typeString = parser . getAttributeValue ( "" , "type" ) ; if ( typeString != null ) { message . setType ( Message . Type . fromString ( typeString ) ) ; } String language = ParserUtils . getXmlLang ( parser ) ; message . setLanguage ( language ) ; String thread = null ; outerloop : while ( true ) { int eventType = parser . next ( ) ; switch ( eventType ) { case XmlPullParser . START_TAG : String elementName = parser . getName ( ) ; String namespace = parser . getNamespace ( ) ; switch ( elementName ) { case "subject" : String xmlLangSubject = ParserUtils . getXmlLang ( parser ) ; String subject = parseElementText ( parser ) ; if ( message . getSubject ( xmlLangSubject ) == null ) { message . addSubject ( xmlLangSubject , subject ) ; } break ; case "thread" : if ( thread == null ) { thread = parser . nextText ( ) ; } break ; case "error" : message . setError ( parseError ( parser , messageXmlEnvironment ) ) ; break ; default : PacketParserUtils . addExtensionElement ( message , parser , elementName , namespace , messageXmlEnvironment ) ; break ; } break ; case XmlPullParser . END_TAG : if ( parser . getDepth ( ) == initialDepth ) { break outerloop ; } break ; } } message . setThread ( thread ) ; return message ; }
Parses a message packet .
19,690
public static Presence parsePresence ( XmlPullParser parser , XmlEnvironment outerXmlEnvironment ) throws XmlPullParserException , IOException , SmackParsingException { ParserUtils . assertAtStartTag ( parser ) ; final int initialDepth = parser . getDepth ( ) ; XmlEnvironment presenceXmlEnvironment = XmlEnvironment . from ( parser , outerXmlEnvironment ) ; Presence . Type type = Presence . Type . available ; String typeString = parser . getAttributeValue ( "" , "type" ) ; if ( typeString != null && ! typeString . equals ( "" ) ) { type = Presence . Type . fromString ( typeString ) ; } Presence presence = new Presence ( type ) ; presence . setTo ( ParserUtils . getJidAttribute ( parser , "to" ) ) ; presence . setFrom ( ParserUtils . getJidAttribute ( parser , "from" ) ) ; presence . setStanzaId ( parser . getAttributeValue ( "" , "id" ) ) ; String language = ParserUtils . getXmlLang ( parser ) ; if ( language != null && ! "" . equals ( language . trim ( ) ) ) { presence . setLanguage ( language ) ; } outerloop : while ( true ) { int eventType = parser . next ( ) ; switch ( eventType ) { case XmlPullParser . START_TAG : String elementName = parser . getName ( ) ; String namespace = parser . getNamespace ( ) ; switch ( elementName ) { case "status" : presence . setStatus ( parser . nextText ( ) ) ; break ; case "priority" : int priority = Integer . parseInt ( parser . nextText ( ) ) ; presence . setPriority ( priority ) ; break ; case "show" : String modeText = parser . nextText ( ) ; if ( StringUtils . isNotEmpty ( modeText ) ) { presence . setMode ( Presence . Mode . fromString ( modeText ) ) ; } else { LOGGER . warning ( "Empty or null mode text in presence show element form " + presence . getFrom ( ) + " with id '" + presence . getStanzaId ( ) + "' which is invalid according to RFC6121 4.7.2.1" ) ; } break ; case "error" : presence . setError ( parseError ( parser , presenceXmlEnvironment ) ) ; break ; default : try { PacketParserUtils . addExtensionElement ( presence , parser , elementName , namespace , presenceXmlEnvironment ) ; } catch ( Exception e ) { LOGGER . warning ( "Failed to parse extension element in Presence stanza: \"" + e + "\" from: '" + presence . getFrom ( ) + " id: '" + presence . getStanzaId ( ) + "'" ) ; } break ; } break ; case XmlPullParser . END_TAG : if ( parser . getDepth ( ) == initialDepth ) { break outerloop ; } break ; } } return presence ; }
Parses a presence packet .
19,691
public static IQ parseIQ ( XmlPullParser parser , XmlEnvironment outerXmlEnvironment ) throws Exception { ParserUtils . assertAtStartTag ( parser ) ; final int initialDepth = parser . getDepth ( ) ; XmlEnvironment iqXmlEnvironment = XmlEnvironment . from ( parser , outerXmlEnvironment ) ; IQ iqPacket = null ; StanzaError . Builder error = null ; final String id = parser . getAttributeValue ( "" , "id" ) ; final Jid to = ParserUtils . getJidAttribute ( parser , "to" ) ; final Jid from = ParserUtils . getJidAttribute ( parser , "from" ) ; final IQ . Type type = IQ . Type . fromString ( parser . getAttributeValue ( "" , "type" ) ) ; outerloop : while ( true ) { int eventType = parser . next ( ) ; switch ( eventType ) { case XmlPullParser . START_TAG : String elementName = parser . getName ( ) ; String namespace = parser . getNamespace ( ) ; switch ( elementName ) { case "error" : error = PacketParserUtils . parseError ( parser , iqXmlEnvironment ) ; break ; default : IQProvider < IQ > provider = ProviderManager . getIQProvider ( elementName , namespace ) ; if ( provider != null ) { iqPacket = provider . parse ( parser , outerXmlEnvironment ) ; } else { iqPacket = new UnparsedIQ ( elementName , namespace , parseElement ( parser ) ) ; } break ; } break ; case XmlPullParser . END_TAG : if ( parser . getDepth ( ) == initialDepth ) { break outerloop ; } break ; } } if ( iqPacket == null ) { switch ( type ) { case error : iqPacket = new ErrorIQ ( error ) ; break ; case result : iqPacket = new EmptyResultIQ ( ) ; break ; default : break ; } } iqPacket . setStanzaId ( id ) ; iqPacket . setTo ( to ) ; iqPacket . setFrom ( from ) ; iqPacket . setType ( type ) ; iqPacket . setError ( error ) ; return iqPacket ; }
Parses an IQ packet .
19,692
public static Collection < String > parseMechanisms ( XmlPullParser parser ) throws XmlPullParserException , IOException { List < String > mechanisms = new ArrayList < String > ( ) ; boolean done = false ; while ( ! done ) { int eventType = parser . next ( ) ; if ( eventType == XmlPullParser . START_TAG ) { String elementName = parser . getName ( ) ; if ( elementName . equals ( "mechanism" ) ) { mechanisms . add ( parser . nextText ( ) ) ; } } else if ( eventType == XmlPullParser . END_TAG ) { if ( parser . getName ( ) . equals ( "mechanisms" ) ) { done = true ; } } } return mechanisms ; }
Parse the available SASL mechanisms reported from the server .
19,693
public static Compress . Feature parseCompressionFeature ( XmlPullParser parser ) throws IOException , XmlPullParserException { assert ( parser . getEventType ( ) == XmlPullParser . START_TAG ) ; String name ; final int initialDepth = parser . getDepth ( ) ; List < String > methods = new LinkedList < > ( ) ; outerloop : while ( true ) { int eventType = parser . next ( ) ; switch ( eventType ) { case XmlPullParser . START_TAG : name = parser . getName ( ) ; switch ( name ) { case "method" : methods . add ( parser . nextText ( ) ) ; break ; } break ; case XmlPullParser . END_TAG : name = parser . getName ( ) ; switch ( name ) { case Compress . Feature . ELEMENT : if ( parser . getDepth ( ) == initialDepth ) { break outerloop ; } } } } assert ( parser . getEventType ( ) == XmlPullParser . END_TAG ) ; assert ( parser . getDepth ( ) == initialDepth ) ; return new Compress . Feature ( methods ) ; }
Parse the Compression Feature reported from the server .
19,694
public static SASLFailure parseSASLFailure ( XmlPullParser parser ) throws XmlPullParserException , IOException { final int initialDepth = parser . getDepth ( ) ; String condition = null ; Map < String , String > descriptiveTexts = null ; outerloop : while ( true ) { int eventType = parser . next ( ) ; switch ( eventType ) { case XmlPullParser . START_TAG : String name = parser . getName ( ) ; if ( name . equals ( "text" ) ) { descriptiveTexts = parseDescriptiveTexts ( parser , descriptiveTexts ) ; } else { assert ( condition == null ) ; condition = parser . getName ( ) ; } break ; case XmlPullParser . END_TAG : if ( parser . getDepth ( ) == initialDepth ) { break outerloop ; } break ; } } return new SASLFailure ( condition , descriptiveTexts ) ; }
Parses SASL authentication error packets .
19,695
public static StreamError parseStreamError ( XmlPullParser parser , XmlEnvironment outerXmlEnvironment ) throws XmlPullParserException , IOException , SmackParsingException { final int initialDepth = parser . getDepth ( ) ; List < ExtensionElement > extensions = new ArrayList < > ( ) ; Map < String , String > descriptiveTexts = null ; StreamError . Condition condition = null ; String conditionText = null ; XmlEnvironment streamErrorXmlEnvironment = XmlEnvironment . from ( parser , outerXmlEnvironment ) ; outerloop : while ( true ) { int eventType = parser . next ( ) ; switch ( eventType ) { case XmlPullParser . START_TAG : String name = parser . getName ( ) ; String namespace = parser . getNamespace ( ) ; switch ( namespace ) { case StreamError . NAMESPACE : switch ( name ) { case "text" : descriptiveTexts = parseDescriptiveTexts ( parser , descriptiveTexts ) ; break ; default : condition = StreamError . Condition . fromString ( name ) ; if ( ! parser . isEmptyElementTag ( ) ) { conditionText = parser . nextText ( ) ; } break ; } break ; default : PacketParserUtils . addExtensionElement ( extensions , parser , name , namespace , streamErrorXmlEnvironment ) ; break ; } break ; case XmlPullParser . END_TAG : if ( parser . getDepth ( ) == initialDepth ) { break outerloop ; } break ; } } return new StreamError ( condition , conditionText , descriptiveTexts , extensions ) ; }
Parses stream error packets .
19,696
public static StanzaError . Builder parseError ( XmlPullParser parser , XmlEnvironment outerXmlEnvironment ) throws XmlPullParserException , IOException , SmackParsingException { final int initialDepth = parser . getDepth ( ) ; Map < String , String > descriptiveTexts = null ; XmlEnvironment stanzaErrorXmlEnvironment = XmlEnvironment . from ( parser , outerXmlEnvironment ) ; List < ExtensionElement > extensions = new ArrayList < > ( ) ; StanzaError . Builder builder = StanzaError . getBuilder ( ) ; builder . setType ( StanzaError . Type . fromString ( parser . getAttributeValue ( "" , "type" ) ) ) ; builder . setErrorGenerator ( parser . getAttributeValue ( "" , "by" ) ) ; outerloop : while ( true ) { int eventType = parser . next ( ) ; switch ( eventType ) { case XmlPullParser . START_TAG : String name = parser . getName ( ) ; String namespace = parser . getNamespace ( ) ; switch ( namespace ) { case StanzaError . ERROR_CONDITION_AND_TEXT_NAMESPACE : switch ( name ) { case Stanza . TEXT : descriptiveTexts = parseDescriptiveTexts ( parser , descriptiveTexts ) ; break ; default : builder . setCondition ( StanzaError . Condition . fromString ( name ) ) ; if ( ! parser . isEmptyElementTag ( ) ) { builder . setConditionText ( parser . nextText ( ) ) ; } break ; } break ; default : PacketParserUtils . addExtensionElement ( extensions , parser , name , namespace , stanzaErrorXmlEnvironment ) ; } break ; case XmlPullParser . END_TAG : if ( parser . getDepth ( ) == initialDepth ) { break outerloop ; } } } builder . setExtensions ( extensions ) . setDescriptiveTexts ( descriptiveTexts ) ; return builder ; }
Parses error sub - packets .
19,697
public static ExtensionElement parseExtensionElement ( String elementName , String namespace , XmlPullParser parser , XmlEnvironment outerXmlEnvironment ) throws XmlPullParserException , IOException , SmackParsingException { ParserUtils . assertAtStartTag ( parser ) ; ExtensionElementProvider < ExtensionElement > provider = ProviderManager . getExtensionProvider ( elementName , namespace ) ; if ( provider != null ) { return provider . parse ( parser , outerXmlEnvironment ) ; } return StandardExtensionElementProvider . INSTANCE . parse ( parser , outerXmlEnvironment ) ; }
Parses an extension element .
19,698
private void fireMessageEventRequestListeners ( Jid from , String packetID , String methodName ) { try { Method method = MessageEventRequestListener . class . getDeclaredMethod ( methodName , new Class < ? > [ ] { Jid . class , String . class , MessageEventManager . class } ) ; for ( MessageEventRequestListener listener : messageEventRequestListeners ) { method . invoke ( listener , new Object [ ] { from , packetID , this } ) ; } } catch ( Exception e ) { LOGGER . log ( Level . SEVERE , "Error while invoking MessageEventRequestListener's " + methodName , e ) ; } }
Fires message event request listeners .
19,699
private void fireMessageEventNotificationListeners ( Jid from , String packetID , String methodName ) { try { Method method = MessageEventNotificationListener . class . getDeclaredMethod ( methodName , new Class < ? > [ ] { Jid . class , String . class } ) ; for ( MessageEventNotificationListener listener : messageEventNotificationListeners ) { method . invoke ( listener , new Object [ ] { from , packetID } ) ; } } catch ( Exception e ) { LOGGER . log ( Level . SEVERE , "Error while invoking MessageEventNotificationListener's " + methodName , e ) ; } }
Fires message event notification listeners .